Re: [OpenWrt-Devel] [PATCH] ramips:Allow funcs in multiple groups in pinctrl-rt2880.c for UARTF pin sharing

2015-11-22 Thread John Crispin


On 22/11/2015 20:26, Noble Pepper wrote:
> Hi, thanks for looking at this. 
> 
> I actually tried this approach before deciding groups that are not a
> fixed set of pins would require modifying pinctrl/pinmux.c and possibly
> pinctrl/core.c thus would affect a lot more than just the ralink
> drivers.
> 
> The problem arises when pinmux_enable_setting() in pinmux.c calls
> rt2880_get_group_pins() without any information about which function is
> to be used. pinmux_enable_setting() then allocates the pins thus
> obtained before calling rt2880_pmx_group_enable (specifying which
> function) and the damage is already done.

ok, i had a look at the core.c but not in that detail. i'll have another
look tomorrow to see if i can think of another solution.

> 
> The section titled "PINMUX interfaces" in Documentation/pinctrl.txt
> seems to imply that a group is a fixed set of pins and pinmux.c and
> core.c look to have been written assuming this is true.
> 
> Regards, Noble
> 
> On Sat, 2015-11-21 at 21:32 +0100, John Crispin wrote:
>> Hi,
>>
>> i had a closer look at the code. what you want to do instead of adding 2
>> dummy muxes is to modify
>>
>> static int rt2880_pmx_group_enable(struct pinctrl_dev *pctrldev,
>>
>> and change this part
>>
>> /* mark the pins as gpio */
>> for (i = 0; i < p->groups[group].func[0].pin_count; i++)
>> p->gpio[p->groups[group].func[0].pins[i]] = 1;
>>
>> to not use [0] but the real mux which will enable the upper 4 gpio for
>> gpio usage.
>>
>>  John
>>
>> On 03/11/2015 13:26, Noble Pepper wrote:
>>>
>>> Signed-off-by: Noble Pepper 
>>> ---
>>> Existing pinctrl-rt2880.c code only kept track of one pin group that
>>> functions other than gpio may use. Functions in rt305x.c had differing
>>> numbers of pins which caused rt2880_get_group_pins() to sometimes return
>>> incorrect pins. Example: when trying to use "gpio uartf" function pins
>>> 7-14 instead of 7-10 may be claimed for uartf preventing using gpio on
>>> pins 11-14. Usage of groups and functions added to rt305x.c is shown in
>>> VOCORE.dtsi. 
>>>
>>>
  target/linux/ramips/dts/VOCORE.dtsi| 40 -
  ...ralink-allow-functions-on-multiple-groups.patch | 98 
 ++
  2 files changed, 119 insertions(+), 19 deletions(-)
  create mode 100644 
 target/linux/ramips/patches-3.18/0031-pinctrl-ralink-allow-functions-on-multiple-groups.patch

 diff --git a/target/linux/ramips/dts/VOCORE.dtsi 
 b/target/linux/ramips/dts/VOCORE.dtsi
 index ff031fa..a5a213f 100644
 --- a/target/linux/ramips/dts/VOCORE.dtsi
 +++ b/target/linux/ramips/dts/VOCORE.dtsi
 @@ -1,3 +1,10 @@
 +/ {
 +  palmbus@1000 {
 +  uartlite@c00 {
 +  status = "okay";
 +  };
 +  };
 +};
  /include/ "rt5350.dtsi"
  
  / {
 @@ -5,6 +12,9 @@
model = "VoCore";
  
palmbus@1000 {
 +  uart@500 {
 +  status = "okay";
 +  };
gpio1: gpio@660 {
status = "okay";
};
 @@ -25,9 +35,15 @@
};
  
pinctrl {
 +  uartf_pins: uartf {
 +  uartf {
 +  ralink,group = "uartf_low";
 +  ralink,function = "gpio uartf";
 +  };
 +  };
state_default: pinctrl0 {
gpio {
 -  ralink,group = "jtag", "uartf", "led";
 +  ralink,group = "jtag", "led", "uartf_high";
ralink,function = "gpio";
};
};
 @@ -64,25 +80,11 @@
};
  
/* UARTF */
 -  gpio7 {
 -  /* UARTF_RTS_N */
 -  gpio-export,name = "gpio7";
 +  gpio11 {
 +  /* uartf_dtr_n */
 +  gpio-export,name = "gpio11";
gpio-export,direction_may_change = <1>;
 -  gpios = <&gpio0 7 0>;
 -  };
 -
 -  gpio8 {
 -  /* UARTF_TXD */
 -  gpio-export,name = "gpio8";
 -  gpio-export,direction_may_change = <1>;
 -  gpios = <&gpio0 8 0>;
 -  };
 -
 -  gpio9 {
 -  /* UARTF_CTS_N */
 -  gpio-export,name = "gpio9";
 -  gpio-export,direction_may_change = <1>;
 -  gpios = <&gpio0 9 0>;
 +  gpios = <&gpio0 11 0>;
};
  
gpio12 {
 diff --git 
 a/target/linux/ramips/patches-3.18/0031-pinctrl-ralink-allow-functions-on-multiple-groups.patch
  
 b/target/linux/ramips/patches-3.18/0

Re: [OpenWrt-Devel] [PATCH] ramips:Allow funcs in multiple groups in pinctrl-rt2880.c for UARTF pin sharing

2015-11-22 Thread Noble Pepper
Hi, thanks for looking at this. 

I actually tried this approach before deciding groups that are not a
fixed set of pins would require modifying pinctrl/pinmux.c and possibly
pinctrl/core.c thus would affect a lot more than just the ralink
drivers.

The problem arises when pinmux_enable_setting() in pinmux.c calls
rt2880_get_group_pins() without any information about which function is
to be used. pinmux_enable_setting() then allocates the pins thus
obtained before calling rt2880_pmx_group_enable (specifying which
function) and the damage is already done.

The section titled "PINMUX interfaces" in Documentation/pinctrl.txt
seems to imply that a group is a fixed set of pins and pinmux.c and
core.c look to have been written assuming this is true.

Regards, Noble

On Sat, 2015-11-21 at 21:32 +0100, John Crispin wrote:
> Hi,
> 
> i had a closer look at the code. what you want to do instead of adding 2
> dummy muxes is to modify
> 
> static int rt2880_pmx_group_enable(struct pinctrl_dev *pctrldev,
> 
> and change this part
> 
> /* mark the pins as gpio */
> for (i = 0; i < p->groups[group].func[0].pin_count; i++)
> p->gpio[p->groups[group].func[0].pins[i]] = 1;
> 
> to not use [0] but the real mux which will enable the upper 4 gpio for
> gpio usage.
> 
>   John
> 
> On 03/11/2015 13:26, Noble Pepper wrote:
> > 
> > Signed-off-by: Noble Pepper 
> > ---
> > Existing pinctrl-rt2880.c code only kept track of one pin group that
> > functions other than gpio may use. Functions in rt305x.c had differing
> > numbers of pins which caused rt2880_get_group_pins() to sometimes return
> > incorrect pins. Example: when trying to use "gpio uartf" function pins
> > 7-14 instead of 7-10 may be claimed for uartf preventing using gpio on
> > pins 11-14. Usage of groups and functions added to rt305x.c is shown in
> > VOCORE.dtsi. 
> > 
> > 
> >>  target/linux/ramips/dts/VOCORE.dtsi| 40 -
> >>  ...ralink-allow-functions-on-multiple-groups.patch | 98 
> >> ++
> >>  2 files changed, 119 insertions(+), 19 deletions(-)
> >>  create mode 100644 
> >> target/linux/ramips/patches-3.18/0031-pinctrl-ralink-allow-functions-on-multiple-groups.patch
> >>
> >> diff --git a/target/linux/ramips/dts/VOCORE.dtsi 
> >> b/target/linux/ramips/dts/VOCORE.dtsi
> >> index ff031fa..a5a213f 100644
> >> --- a/target/linux/ramips/dts/VOCORE.dtsi
> >> +++ b/target/linux/ramips/dts/VOCORE.dtsi
> >> @@ -1,3 +1,10 @@
> >> +/ {
> >> +  palmbus@1000 {
> >> +  uartlite@c00 {
> >> +  status = "okay";
> >> +  };
> >> +  };
> >> +};
> >>  /include/ "rt5350.dtsi"
> >>  
> >>  / {
> >> @@ -5,6 +12,9 @@
> >>model = "VoCore";
> >>  
> >>palmbus@1000 {
> >> +  uart@500 {
> >> +  status = "okay";
> >> +  };
> >>gpio1: gpio@660 {
> >>status = "okay";
> >>};
> >> @@ -25,9 +35,15 @@
> >>};
> >>  
> >>pinctrl {
> >> +  uartf_pins: uartf {
> >> +  uartf {
> >> +  ralink,group = "uartf_low";
> >> +  ralink,function = "gpio uartf";
> >> +  };
> >> +  };
> >>state_default: pinctrl0 {
> >>gpio {
> >> -  ralink,group = "jtag", "uartf", "led";
> >> +  ralink,group = "jtag", "led", "uartf_high";
> >>ralink,function = "gpio";
> >>};
> >>};
> >> @@ -64,25 +80,11 @@
> >>};
> >>  
> >>/* UARTF */
> >> -  gpio7 {
> >> -  /* UARTF_RTS_N */
> >> -  gpio-export,name = "gpio7";
> >> +  gpio11 {
> >> +  /* uartf_dtr_n */
> >> +  gpio-export,name = "gpio11";
> >>gpio-export,direction_may_change = <1>;
> >> -  gpios = <&gpio0 7 0>;
> >> -  };
> >> -
> >> -  gpio8 {
> >> -  /* UARTF_TXD */
> >> -  gpio-export,name = "gpio8";
> >> -  gpio-export,direction_may_change = <1>;
> >> -  gpios = <&gpio0 8 0>;
> >> -  };
> >> -
> >> -  gpio9 {
> >> -  /* UARTF_CTS_N */
> >> -  gpio-export,name = "gpio9";
> >> -  gpio-export,direction_may_change = <1>;
> >> -  gpios = <&gpio0 9 0>;
> >> +  gpios = <&gpio0 11 0>;
> >>};
> >>  
> >>gpio12 {
> >> diff --git 
> >> a/target/linux/ramips/patches-3.18/0031-pinctrl-ralink-allow-functions-on-multiple-groups.patch
> >>  
> >> b/target/linux/ramips/patches-3.18/0031-pinctrl-ralink-allow-functions-on-multiple-groups.patch
> >> new file mode 100644
> >> index 000..1eab406
> >> --- /dev/null
> >> +++ 
> >> b/target/linux/ramips/patches-3.18/0031-pinctrl-ralink-allow-functions-on-m

Re: [OpenWrt-Devel] [PATCH] ramips:Allow funcs in multiple groups in pinctrl-rt2880.c for UARTF pin sharing

2015-11-21 Thread John Crispin
Hi,

i had a closer look at the code. what you want to do instead of adding 2
dummy muxes is to modify

static int rt2880_pmx_group_enable(struct pinctrl_dev *pctrldev,

and change this part

/* mark the pins as gpio */
for (i = 0; i < p->groups[group].func[0].pin_count; i++)
p->gpio[p->groups[group].func[0].pins[i]] = 1;

to not use [0] but the real mux which will enable the upper 4 gpio for
gpio usage.

John

On 03/11/2015 13:26, Noble Pepper wrote:
> 
> Signed-off-by: Noble Pepper 
> ---
> Existing pinctrl-rt2880.c code only kept track of one pin group that
> functions other than gpio may use. Functions in rt305x.c had differing
> numbers of pins which caused rt2880_get_group_pins() to sometimes return
> incorrect pins. Example: when trying to use "gpio uartf" function pins
> 7-14 instead of 7-10 may be claimed for uartf preventing using gpio on
> pins 11-14. Usage of groups and functions added to rt305x.c is shown in
> VOCORE.dtsi. 
> 
> 
>>  target/linux/ramips/dts/VOCORE.dtsi| 40 -
>>  ...ralink-allow-functions-on-multiple-groups.patch | 98 
>> ++
>>  2 files changed, 119 insertions(+), 19 deletions(-)
>>  create mode 100644 
>> target/linux/ramips/patches-3.18/0031-pinctrl-ralink-allow-functions-on-multiple-groups.patch
>>
>> diff --git a/target/linux/ramips/dts/VOCORE.dtsi 
>> b/target/linux/ramips/dts/VOCORE.dtsi
>> index ff031fa..a5a213f 100644
>> --- a/target/linux/ramips/dts/VOCORE.dtsi
>> +++ b/target/linux/ramips/dts/VOCORE.dtsi
>> @@ -1,3 +1,10 @@
>> +/ {
>> +palmbus@1000 {
>> +uartlite@c00 {
>> +status = "okay";
>> +};
>> +};
>> +};
>>  /include/ "rt5350.dtsi"
>>  
>>  / {
>> @@ -5,6 +12,9 @@
>>  model = "VoCore";
>>  
>>  palmbus@1000 {
>> +uart@500 {
>> +status = "okay";
>> +};
>>  gpio1: gpio@660 {
>>  status = "okay";
>>  };
>> @@ -25,9 +35,15 @@
>>  };
>>  
>>  pinctrl {
>> +uartf_pins: uartf {
>> +uartf {
>> +ralink,group = "uartf_low";
>> +ralink,function = "gpio uartf";
>> +};
>> +};
>>  state_default: pinctrl0 {
>>  gpio {
>> -ralink,group = "jtag", "uartf", "led";
>> +ralink,group = "jtag", "led", "uartf_high";
>>  ralink,function = "gpio";
>>  };
>>  };
>> @@ -64,25 +80,11 @@
>>  };
>>  
>>  /* UARTF */
>> -gpio7 {
>> -/* UARTF_RTS_N */
>> -gpio-export,name = "gpio7";
>> +gpio11 {
>> +/* uartf_dtr_n */
>> +gpio-export,name = "gpio11";
>>  gpio-export,direction_may_change = <1>;
>> -gpios = <&gpio0 7 0>;
>> -};
>> -
>> -gpio8 {
>> -/* UARTF_TXD */
>> -gpio-export,name = "gpio8";
>> -gpio-export,direction_may_change = <1>;
>> -gpios = <&gpio0 8 0>;
>> -};
>> -
>> -gpio9 {
>> -/* UARTF_CTS_N */
>> -gpio-export,name = "gpio9";
>> -gpio-export,direction_may_change = <1>;
>> -gpios = <&gpio0 9 0>;
>> +gpios = <&gpio0 11 0>;
>>  };
>>  
>>  gpio12 {
>> diff --git 
>> a/target/linux/ramips/patches-3.18/0031-pinctrl-ralink-allow-functions-on-multiple-groups.patch
>>  
>> b/target/linux/ramips/patches-3.18/0031-pinctrl-ralink-allow-functions-on-multiple-groups.patch
>> new file mode 100644
>> index 000..1eab406
>> --- /dev/null
>> +++ 
>> b/target/linux/ramips/patches-3.18/0031-pinctrl-ralink-allow-functions-on-multiple-groups.patch
>> @@ -0,0 +1,98 @@
>> +diff -Naur a/arch/mips/include/asm/mach-ralink/pinmux.h 
>> b/arch/mips/include/asm/mach-ralink/pinmux.h
>> +--- a/arch/mips/include/asm/mach-ralink/pinmux.h2015-11-02 
>> 05:32:57.227437903 -0600
>>  b/arch/mips/include/asm/mach-ralink/pinmux.h2015-11-03 
>> 02:50:33.128049900 -0600
>> +@@ -31,6 +31,7 @@
>> +int *pins;
>> + 
>> +int *groups;
>> ++   int **group_names;
>> +int group_count;
>> + 
>> +int enabled;
>> +diff -Naur a/arch/mips/ralink/rt305x.c b/arch/mips/ralink/rt305x.c
>> +--- a/arch/mips/ralink/rt305x.c 2015-11-02 05:33:44.932237317 -0600
>>  b/arch/mips/ralink/rt305x.c 2015-11-03 02:49:49.255271419 -0600
>> +@@ -23,6 +23,22 @@
>> + 
>> + static struct rt2880_pmx_func i2c_func[] =  { FUNC("i2c", 0, 1, 2) };
>> + static struct rt2880_pmx_func spi_func[] = { FUNC("spi", 0, 3, 4) };
>> ++static struct rt2880_pmx_func uartf_low_func[] = {
>> ++   FUNC

Re: [OpenWrt-Devel] [PATCH] ramips:Allow funcs in multiple groups in pinctrl-rt2880.c for UARTF pin sharing

2015-11-03 Thread Noble Pepper
This should fix the white space issue. I don't understand why it looks
like a forwarding, if you can provide details I'll be glad to fix it.

Thanks for your patience, this is my first attempt at an openwrt patch.

Noble


Existing pinctrl-rt2880.c code only kept track of one pin group that
functions other than gpio may use. Functions in rt305x.c had differing
numbers of pins which caused rt2880_get_group_pins() to sometimes return
incorrect pins. Example: when trying to use "gpio uartf" function pins
7-14 instead of 7-10 may be claimed for uartf preventing using gpio on
pins 11-14. Usage of groups and functions added to rt305x.c is shown in
VOCORE.dtsi. 


Signed-off-by: Noble Pepper 
---
 target/linux/ramips/dts/VOCORE.dtsi|  40 +++
 ...ralink-allow-functions-on-multiple-groups.patch | 117
+
 2 files changed, 138 insertions(+), 19 deletions(-)
 create mode 100644
target/linux/ramips/patches-3.18/0031-pinctrl-ralink-allow-functions-on-multiple-groups.patch

diff --git a/target/linux/ramips/dts/VOCORE.dtsi
b/target/linux/ramips/dts/VOCORE.dtsi
index ff031fa..a5a213f 100644
--- a/target/linux/ramips/dts/VOCORE.dtsi
+++ b/target/linux/ramips/dts/VOCORE.dtsi
@@ -1,3 +1,10 @@
+/ {
+   palmbus@1000 {
+   uartlite@c00 {
+   status = "okay";
+   };
+   };
+};
 /include/ "rt5350.dtsi"
 
 / {
@@ -5,6 +12,9 @@
model = "VoCore";
 
palmbus@1000 {
+   uart@500 {
+   status = "okay";
+   };
gpio1: gpio@660 {
status = "okay";
};
@@ -25,9 +35,15 @@
};
 
pinctrl {
+   uartf_pins: uartf {
+   uartf {
+   ralink,group = "uartf_low";
+   ralink,function = "gpio uartf";
+   };
+   };
state_default: pinctrl0 {
gpio {
-   ralink,group = "jtag", "uartf", "led";
+   ralink,group = "jtag", "led", "uartf_high";
ralink,function = "gpio";
};
};
@@ -64,25 +80,11 @@
};
 
/* UARTF */
-   gpio7 {
-   /* UARTF_RTS_N */
-   gpio-export,name = "gpio7";
+   gpio11 {
+   /* uartf_dtr_n */
+   gpio-export,name = "gpio11";
gpio-export,direction_may_change = <1>;
-   gpios = <&gpio0 7 0>;
-   };
-
-   gpio8 {
-   /* UARTF_TXD */
-   gpio-export,name = "gpio8";
-   gpio-export,direction_may_change = <1>;
-   gpios = <&gpio0 8 0>;
-   };
-
-   gpio9 {
-   /* UARTF_CTS_N */
-   gpio-export,name = "gpio9";
-   gpio-export,direction_may_change = <1>;
-   gpios = <&gpio0 9 0>;
+   gpios = <&gpio0 11 0>;
};
 
gpio12 {
diff --git
a/target/linux/ramips/patches-3.18/0031-pinctrl-ralink-allow-functions-on-multiple-groups.patch
 
b/target/linux/ramips/patches-3.18/0031-pinctrl-ralink-allow-functions-on-multiple-groups.patch
new file mode 100644
index 000..752aa5d
--- /dev/null
+++
b/target/linux/ramips/patches-3.18/0031-pinctrl-ralink-allow-functions-on-multiple-groups.patch
@@ -0,0 +1,116 @@
+diff -Naur a/arch/mips/include/asm/mach-ralink/pinmux.h
b/arch/mips/include/asm/mach-ralink/pinmux.h
+--- a/arch/mips/include/asm/mach-ralink/pinmux.h   2015-11-02
05:32:57.227437903 -0600
 b/arch/mips/include/asm/mach-ralink/pinmux.h   2015-11-03
07:20:57.241011716 -0600
+@@ -25,25 +25,21 @@
+ struct rt2880_pmx_func {
+   const char *name;
+   const char value;
+-
+   int pin_first;
+   int pin_count;
+   int *pins;
+-
+   int *groups;
++  int **group_names;
+   int group_count;
+-
+   int enabled;
+ };
+
+ struct rt2880_pmx_group {
+   const char *name;
+   int enabled;
+-
+   const u32 shift;
+   const char mask;
+   const char gpio;
+-
+   struct rt2880_pmx_func *func;
+   int func_count;
+ };
+diff -Naur a/arch/mips/ralink/rt305x.c b/arch/mips/ralink/rt305x.c
+--- a/arch/mips/ralink/rt305x.c2015-11-02 05:33:44.932237317 -0600
 b/arch/mips/ralink/rt305x.c2015-11-03 02:49:49.255271419 -0600
+@@ -23,6 +23,22 @@
+
+ static struct rt2880_pmx_func i2c_func[] =  { FUNC("i2c", 0, 1, 2) };
+ static struct rt2880_pmx_func spi_func[] = { FUNC("spi", 0, 3, 4) };
++static struct rt2880_pmx_func uartf_low_func[] = {
++  FUNC("pcm uartf", RT305X_GPIO_MODE_PCM_UARTF, 7, 4),
++  FUNC("pcm i2s", RT305X_GPIO_MODE_PCM_I2S, 7, 4),
++

Re: [OpenWrt-Devel] [PATCH] ramips:Allow funcs in multiple groups in pinctrl-rt2880.c for UARTF pin sharing

2015-11-03 Thread John Crispin
Hi,

the patch is white space broken and for some reason this seems to be a
forwarding. could you fix and resend please

John

On 03/11/2015 13:26, Noble Pepper wrote:
> 
> Signed-off-by: Noble Pepper 
> ---
> Existing pinctrl-rt2880.c code only kept track of one pin group that
> functions other than gpio may use. Functions in rt305x.c had differing
> numbers of pins which caused rt2880_get_group_pins() to sometimes return
> incorrect pins. Example: when trying to use "gpio uartf" function pins
> 7-14 instead of 7-10 may be claimed for uartf preventing using gpio on
> pins 11-14. Usage of groups and functions added to rt305x.c is shown in
> VOCORE.dtsi. 
> 
> 
>>  target/linux/ramips/dts/VOCORE.dtsi| 40 -
>>  ...ralink-allow-functions-on-multiple-groups.patch | 98 
>> ++
>>  2 files changed, 119 insertions(+), 19 deletions(-)
>>  create mode 100644 
>> target/linux/ramips/patches-3.18/0031-pinctrl-ralink-allow-functions-on-multiple-groups.patch
>>
>> diff --git a/target/linux/ramips/dts/VOCORE.dtsi 
>> b/target/linux/ramips/dts/VOCORE.dtsi
>> index ff031fa..a5a213f 100644
>> --- a/target/linux/ramips/dts/VOCORE.dtsi
>> +++ b/target/linux/ramips/dts/VOCORE.dtsi
>> @@ -1,3 +1,10 @@
>> +/ {
>> +palmbus@1000 {
>> +uartlite@c00 {
>> +status = "okay";
>> +};
>> +};
>> +};
>>  /include/ "rt5350.dtsi"
>>  
>>  / {
>> @@ -5,6 +12,9 @@
>>  model = "VoCore";
>>  
>>  palmbus@1000 {
>> +uart@500 {
>> +status = "okay";
>> +};
>>  gpio1: gpio@660 {
>>  status = "okay";
>>  };
>> @@ -25,9 +35,15 @@
>>  };
>>  
>>  pinctrl {
>> +uartf_pins: uartf {
>> +uartf {
>> +ralink,group = "uartf_low";
>> +ralink,function = "gpio uartf";
>> +};
>> +};
>>  state_default: pinctrl0 {
>>  gpio {
>> -ralink,group = "jtag", "uartf", "led";
>> +ralink,group = "jtag", "led", "uartf_high";
>>  ralink,function = "gpio";
>>  };
>>  };
>> @@ -64,25 +80,11 @@
>>  };
>>  
>>  /* UARTF */
>> -gpio7 {
>> -/* UARTF_RTS_N */
>> -gpio-export,name = "gpio7";
>> +gpio11 {
>> +/* uartf_dtr_n */
>> +gpio-export,name = "gpio11";
>>  gpio-export,direction_may_change = <1>;
>> -gpios = <&gpio0 7 0>;
>> -};
>> -
>> -gpio8 {
>> -/* UARTF_TXD */
>> -gpio-export,name = "gpio8";
>> -gpio-export,direction_may_change = <1>;
>> -gpios = <&gpio0 8 0>;
>> -};
>> -
>> -gpio9 {
>> -/* UARTF_CTS_N */
>> -gpio-export,name = "gpio9";
>> -gpio-export,direction_may_change = <1>;
>> -gpios = <&gpio0 9 0>;
>> +gpios = <&gpio0 11 0>;
>>  };
>>  
>>  gpio12 {
>> diff --git 
>> a/target/linux/ramips/patches-3.18/0031-pinctrl-ralink-allow-functions-on-multiple-groups.patch
>>  
>> b/target/linux/ramips/patches-3.18/0031-pinctrl-ralink-allow-functions-on-multiple-groups.patch
>> new file mode 100644
>> index 000..1eab406
>> --- /dev/null
>> +++ 
>> b/target/linux/ramips/patches-3.18/0031-pinctrl-ralink-allow-functions-on-multiple-groups.patch
>> @@ -0,0 +1,98 @@
>> +diff -Naur a/arch/mips/include/asm/mach-ralink/pinmux.h 
>> b/arch/mips/include/asm/mach-ralink/pinmux.h
>> +--- a/arch/mips/include/asm/mach-ralink/pinmux.h2015-11-02 
>> 05:32:57.227437903 -0600
>>  b/arch/mips/include/asm/mach-ralink/pinmux.h2015-11-03 
>> 02:50:33.128049900 -0600
>> +@@ -31,6 +31,7 @@
>> +int *pins;
>> + 
>> +int *groups;
>> ++   int **group_names;
>> +int group_count;
>> + 
>> +int enabled;
>> +diff -Naur a/arch/mips/ralink/rt305x.c b/arch/mips/ralink/rt305x.c
>> +--- a/arch/mips/ralink/rt305x.c 2015-11-02 05:33:44.932237317 -0600
>>  b/arch/mips/ralink/rt305x.c 2015-11-03 02:49:49.255271419 -0600
>> +@@ -23,6 +23,22 @@
>> + 
>> + static struct rt2880_pmx_func i2c_func[] =  { FUNC("i2c", 0, 1, 2) };
>> + static struct rt2880_pmx_func spi_func[] = { FUNC("spi", 0, 3, 4) };
>> ++static struct rt2880_pmx_func uartf_low_func[] = {
>> ++   FUNC("pcm uartf", RT305X_GPIO_MODE_PCM_UARTF, 7, 4),
>> ++   FUNC("pcm i2s", RT305X_GPIO_MODE_PCM_I2S, 7, 4),
>> ++   FUNC("uartf i2s", RT305X_GPIO_MODE_I2S_UARTF, 7, 4),
>> ++   FUNC("pcm gpio", RT305X_GPIO_MODE_PCM_GPIO, 7, 4),
>> ++   FUNC("gpio uartf", RT305X_GPIO_MODE_GPIO_UARTF, 7, 4),
>> ++   FUNC("gpio i2s", RT305X

[OpenWrt-Devel] [PATCH] ramips:Allow funcs in multiple groups in pinctrl-rt2880.c for UARTF pin sharing

2015-11-03 Thread Noble Pepper

Signed-off-by: Noble Pepper 
---
Existing pinctrl-rt2880.c code only kept track of one pin group that
functions other than gpio may use. Functions in rt305x.c had differing
numbers of pins which caused rt2880_get_group_pins() to sometimes return
incorrect pins. Example: when trying to use "gpio uartf" function pins
7-14 instead of 7-10 may be claimed for uartf preventing using gpio on
pins 11-14. Usage of groups and functions added to rt305x.c is shown in
VOCORE.dtsi. 


>  target/linux/ramips/dts/VOCORE.dtsi| 40 -
>  ...ralink-allow-functions-on-multiple-groups.patch | 98 
> ++
>  2 files changed, 119 insertions(+), 19 deletions(-)
>  create mode 100644 
> target/linux/ramips/patches-3.18/0031-pinctrl-ralink-allow-functions-on-multiple-groups.patch
> 
> diff --git a/target/linux/ramips/dts/VOCORE.dtsi 
> b/target/linux/ramips/dts/VOCORE.dtsi
> index ff031fa..a5a213f 100644
> --- a/target/linux/ramips/dts/VOCORE.dtsi
> +++ b/target/linux/ramips/dts/VOCORE.dtsi
> @@ -1,3 +1,10 @@
> +/ {
> + palmbus@1000 {
> + uartlite@c00 {
> + status = "okay";
> + };
> + };
> +};
>  /include/ "rt5350.dtsi"
>  
>  / {
> @@ -5,6 +12,9 @@
>   model = "VoCore";
>  
>   palmbus@1000 {
> + uart@500 {
> + status = "okay";
> + };
>   gpio1: gpio@660 {
>   status = "okay";
>   };
> @@ -25,9 +35,15 @@
>   };
>  
>   pinctrl {
> + uartf_pins: uartf {
> + uartf {
> + ralink,group = "uartf_low";
> + ralink,function = "gpio uartf";
> + };
> + };
>   state_default: pinctrl0 {
>   gpio {
> - ralink,group = "jtag", "uartf", "led";
> + ralink,group = "jtag", "led", "uartf_high";
>   ralink,function = "gpio";
>   };
>   };
> @@ -64,25 +80,11 @@
>   };
>  
>   /* UARTF */
> - gpio7 {
> - /* UARTF_RTS_N */
> - gpio-export,name = "gpio7";
> + gpio11 {
> + /* uartf_dtr_n */
> + gpio-export,name = "gpio11";
>   gpio-export,direction_may_change = <1>;
> - gpios = <&gpio0 7 0>;
> - };
> -
> - gpio8 {
> - /* UARTF_TXD */
> - gpio-export,name = "gpio8";
> - gpio-export,direction_may_change = <1>;
> - gpios = <&gpio0 8 0>;
> - };
> -
> - gpio9 {
> - /* UARTF_CTS_N */
> - gpio-export,name = "gpio9";
> - gpio-export,direction_may_change = <1>;
> - gpios = <&gpio0 9 0>;
> + gpios = <&gpio0 11 0>;
>   };
>  
>   gpio12 {
> diff --git 
> a/target/linux/ramips/patches-3.18/0031-pinctrl-ralink-allow-functions-on-multiple-groups.patch
>  
> b/target/linux/ramips/patches-3.18/0031-pinctrl-ralink-allow-functions-on-multiple-groups.patch
> new file mode 100644
> index 000..1eab406
> --- /dev/null
> +++ 
> b/target/linux/ramips/patches-3.18/0031-pinctrl-ralink-allow-functions-on-multiple-groups.patch
> @@ -0,0 +1,98 @@
> +diff -Naur a/arch/mips/include/asm/mach-ralink/pinmux.h 
> b/arch/mips/include/asm/mach-ralink/pinmux.h
> +--- a/arch/mips/include/asm/mach-ralink/pinmux.h 2015-11-02 
> 05:32:57.227437903 -0600
>  b/arch/mips/include/asm/mach-ralink/pinmux.h 2015-11-03 
> 02:50:33.128049900 -0600
> +@@ -31,6 +31,7 @@
> + int *pins;
> + 
> + int *groups;
> ++int **group_names;
> + int group_count;
> + 
> + int enabled;
> +diff -Naur a/arch/mips/ralink/rt305x.c b/arch/mips/ralink/rt305x.c
> +--- a/arch/mips/ralink/rt305x.c  2015-11-02 05:33:44.932237317 -0600
>  b/arch/mips/ralink/rt305x.c  2015-11-03 02:49:49.255271419 -0600
> +@@ -23,6 +23,22 @@
> + 
> + static struct rt2880_pmx_func i2c_func[] =  { FUNC("i2c", 0, 1, 2) };
> + static struct rt2880_pmx_func spi_func[] = { FUNC("spi", 0, 3, 4) };
> ++static struct rt2880_pmx_func uartf_low_func[] = {
> ++FUNC("pcm uartf", RT305X_GPIO_MODE_PCM_UARTF, 7, 4),
> ++FUNC("pcm i2s", RT305X_GPIO_MODE_PCM_I2S, 7, 4),
> ++FUNC("uartf i2s", RT305X_GPIO_MODE_I2S_UARTF, 7, 4),
> ++FUNC("pcm gpio", RT305X_GPIO_MODE_PCM_GPIO, 7, 4),
> ++FUNC("gpio uartf", RT305X_GPIO_MODE_GPIO_UARTF, 7, 4),
> ++FUNC("gpio i2s", RT305X_GPIO_MODE_GPIO_I2S, 7, 4),
> ++};
> ++static struct rt2880_pmx_func uartf_high_func[] = {
> ++FUNC("pcm uartf", RT305X_GPIO_MODE_PCM_UARTF, 11, 4),
> ++FUNC("pcm i2s", RT305X_GPIO_MODE_PCM_I2S, 11, 4),
> ++FUNC("uartf i2s", RT305X_GPIO_MODE_I2S_UARTF,