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

John Crispin john at phrozen.org
Tue Nov 3 07:34:40 EST 2015


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 <openwrtmail at noblepepper.com>
> ---
> 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 at 10000000 {
>> +		uartlite at c00 {
>> +    			status = "okay";
>> +		};
>> +	};
>> +};
>>  /include/ "rt5350.dtsi"
>>  
>>  / {
>> @@ -5,6 +12,9 @@
>>  	model = "VoCore";
>>  
>>  	palmbus at 10000000 {
>> +		uart at 500 {
>> +    			status = "okay";
>> +		};
>>  		gpio1: gpio at 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 0000000..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, 11, 4),
>> ++	FUNC("pcm gpio", RT305X_GPIO_MODE_PCM_GPIO, 11, 4),
>> ++	FUNC("gpio uartf", RT305X_GPIO_MODE_GPIO_UARTF, 11, 4),
>> ++	FUNC("gpio i2s", RT305X_GPIO_MODE_GPIO_I2S, 11, 4),
>> ++};
>> + static struct rt2880_pmx_func uartf_func[] = {
>> + 	FUNC("uartf", RT305X_GPIO_MODE_UARTF, 7, 8),
>> + 	FUNC("pcm uartf", RT305X_GPIO_MODE_PCM_UARTF, 7, 8),
>> +@@ -80,6 +96,10 @@
>> + 	GRP("spi", spi_func, 1, RT305X_GPIO_MODE_SPI),
>> + 	GRP("uartf", uartf_func, RT305X_GPIO_MODE_UART0_MASK,
>> + 		RT305X_GPIO_MODE_UART0_SHIFT),
>> ++	GRP("uartf_low", uartf_low_func, RT305X_GPIO_MODE_GPIO_UARTF,
>> ++		RT305X_GPIO_MODE_UART0_SHIFT),
>> ++	GRP("uartf_high", uartf_high_func, RT305X_GPIO_MODE_GPIO_UARTF,
>> ++		RT305X_GPIO_MODE_UART0_SHIFT),
>> + 	GRP("uartlite", uartlite_func, 1, RT305X_GPIO_MODE_UART1),
>> + 	GRP("jtag", jtag_func, 1, RT305X_GPIO_MODE_JTAG),
>> + 	GRP("led", rt5350_led_func, 1, RT5350_GPIO_MODE_PHY_LED),
>> +diff -Naur a/drivers/pinctrl/pinctrl-rt2880.c b/drivers/pinctrl/pinctrl-rt2880.c
>> +--- a/drivers/pinctrl/pinctrl-rt2880.c	2015-11-02 05:34:31.585019384 -0600
>> ++++ b/drivers/pinctrl/pinctrl-rt2880.c	2015-11-03 02:51:30.981079814 -0600
>> +@@ -188,12 +188,8 @@
>> + 				unsigned * const num_groups)
>> + {
>> + 	struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev);
>> +-
>> +-	if (p->func[func]->group_count == 1)
>> +-		*groups = &p->group_names[p->func[func]->groups[0]];
>> +-	else
>> +-		*groups = p->group_names;
>> +-
>> ++	if (p->func[func]->group_count != 0)
>> ++		*groups = p->func[func]->group_names;
>> + 	*num_groups = p->func[func]->group_count;
>> + 
>> + 	return 0;
>> +@@ -319,12 +315,30 @@
>> + 	for (i = 0; i < p->group_count; i++) {
>> + 		for (j = 0; j < p->groups[i].func_count; j++) {
>> + 			f[c] = &p->groups[i].func[j];
>> +-			f[c]->groups = devm_kzalloc(p->dev, sizeof(int), GFP_KERNEL);
>> ++			f[c]->groups = devm_kzalloc(p->dev, sizeof(int) * p->group_count, GFP_KERNEL);
>> ++			if (!f[c]->groups)
>> ++					return -1;
>> ++			f[c]->group_names = devm_kzalloc(p->dev, sizeof(char *) * p->group_count, GFP_KERNEL);
>> ++			if (!f[c]->group_names)
>> ++					return -1;
>> + 			f[c]->groups[0] = i;
>> + 			f[c]->group_count = 1;
>> + 			c++;
>> + 		}
>> + 	}
>> ++	f[0]->group_names = p->group_names;
>> ++	for (c = 1; c < p->func_count; c++) {
>> ++		f[c]->group_count = 0;
>> ++		for (i = 0; i < p->group_count; i++) {
>> ++			for (j = 0; j < p->groups[i].func_count; j++) {
>> ++				if (strcmp(f[c]->name, p->groups[i].func[j].name) == 0) {
>> ++					f[c]->groups[f[c]->group_count] = i;
>> ++					f[c]->group_names[f[c]->group_count] = p->groups[i].name;
>> ++					f[c]->group_count++;
>> ++				}
>> ++			}
>> ++		}
>> ++	}
>> + 	return 0;
>> + }
>> + 
>> -- 
>> 2.1.4
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
> 
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list