Pinctrl: SPEAr: Add support for plgpio driver
Subsystems (6)
v2 cover Pinctrl: SPEAr: Add support for plgpio driver
Hi Linus,
This patchset has an interesting history. It was first started by me. After i left ST Shiraz took over and now i am back again :)
The idea of this series is to add plgpio support for SPEAr. PLGPIO's are pads which can be configured as GPIO and so it is closely bound to pinctrl framework.
Some of these are sent earlier and Acked-by you. So, they will retain that. The main bottleneck is still:
gpiolib: provide provision for gpiolib to register pin range
I have tried to fix most of your comments. Please see if they are fixed.
This is rebased over:
http://www.spinics.net/lists/arm-kernel/msg203465.html
--
viresh
Shiraz Hashim (1):
gpiolib: provide provision for gpiolib to register pin range
Viresh Kumar (4):
Revert "pinctrl: remove pinctrl_remove_gpio_range"
pinctrl: SPEAr: Add plgpio driver
pinctrl: SPEAr: Add gpio ranges support
ARM: SPEAr: Add plgpio node in device tree dtsi files
Documentation/devicetree/bindings/gpio/gpio.txt | 36 ++ Documentation/gpio.txt | 26 + Documentation/pinctrl.txt | 3 + arch/arm/boot/dts/spear1310-evb.dts | 4 + arch/arm/boot/dts/spear1310.dtsi | 27 + arch/arm/boot/dts/spear1340-evb.dts | 4 + arch/arm/boot/dts/spear1340.dtsi | 26 + arch/arm/boot/dts/spear310.dtsi | 22 +- arch/arm/boot/dts/spear320-evb.dts | 4 + arch/arm/boot/dts/spear320.dtsi | 23 +- drivers/gpio/gpiolib-of.c | 56 ++ drivers/gpio/gpiolib.c | 43 ++ drivers/pinctrl/core.c | 27 + drivers/pinctrl/devicetree.c | 13 + drivers/pinctrl/spear/Kconfig | 11 + drivers/pinctrl/spear/Makefile | 1 + drivers/pinctrl/spear/pinctrl-plgpio.c | 746 ++++++++++++++++++++++++ drivers/pinctrl/spear/pinctrl-spear.c | 107 +++- drivers/pinctrl/spear/pinctrl-spear.h | 46 ++ drivers/pinctrl/spear/pinctrl-spear1310.c | 264 +++++++++ drivers/pinctrl/spear/pinctrl-spear300.c | 2 + drivers/pinctrl/spear/pinctrl-spear310.c | 2 + drivers/pinctrl/spear/pinctrl-spear320.c | 2 + drivers/pinctrl/spear/pinctrl-spear3xx.c | 37 ++ include/asm-generic/gpio.h | 25 + include/linux/gpio.h | 3 + include/linux/pinctrl/pinctrl.h | 19 + 27 files changed, 1560 insertions(+), 19 deletions(-) create mode 100644 drivers/pinctrl/spear/pinctrl-plgpio.c
Signature · 1 line
1.7.12.rc2.18.g61b472e
PATCH v2 1/5 Revert "pinctrl: remove pinctrl_remove_gpio_range"
This reverts earlier commit which removed pinctrl_remove_gpio_range(), because at that time there aren't any more users of that routine. It was removed as the removal of ranges was done in unregister of pinctrl.
But because we are registering stuff from gpiolib now, we may remove and insert a gpio module multiple times. So, we need that again.
---
This is V1 actually. Because it is part of this series, it is marked V2.
drivers/pinctrl/core.c | 14 ++++++++++++++ include/linux/pinctrl/pinctrl.h | 2 ++ 2 files changed, 16 insertions(+)
drivers/pinctrl/core.c +14 -0
@@ -346,6 +346,20 @@ void pinctrl_add_gpio_ranges(struct pinctrl_dev *pctldev,EXPORT_SYMBOL_GPL (pinctrl_add_gpio_ranges);/** +* pinctrl_remove_gpio_range() - remove a range of GPIOs fro a pin controller +* @pctldev: pin controller device to remove the range from +* @range: the GPIO range to remove +*/ +void pinctrl_remove_gpio_range (struct pinctrl_dev *pctldev, +struct pinctrl_gpio_range *range) +{ +mutex_lock (&pinctrl_mutex); +list_del (&range->node); +mutex_unlock (&pinctrl_mutex); +} +EXPORT_SYMBOL_GPL (pinctrl_remove_gpio_range); + +/** * pinctrl_get_group_selector() - returns the group selector for a group * @pctldev: the pin controller handling the group * @pin_group: the pin group to look up
include/linux/pinctrl/pinctrl.h +2 -0
@@ -134,6 +134,8 @@ extern void pinctrl_add_gpio_range(struct pinctrl_dev *pctldev,extern void pinctrl_add_gpio_ranges (struct pinctrl_dev *pctldev,struct pinctrl_gpio_range *ranges,unsigned nranges); +extern void pinctrl_remove_gpio_range (struct pinctrl_dev *pctldev, +struct pinctrl_gpio_range *range);extern const char *pinctrl_dev_get_name (struct pinctrl_dev *pctldev);extern void *pinctrl_dev_get_drvdata (struct pinctrl_dev *pctldev);#else
Signature · 1 line
1.7.12.rc2.18.g61b472e
PATCH RESEND v2 2/5 gpiolib: provide provision for gpiolib to register pin range
In reply to Viresh KumarFrom: Shiraz Hashim <[email protected]>
pinctrl subsystem needs gpio chip base to prepare set of gpio pin ranges, which a given pinctrl driver can handle. This is important to handle pinctrl gpio request calls in order to program a given pin properly for gpio operation.
As gpio base is allocated dynamically during gpiochip registration, presently there exists no clean way to pass this information to the pinctrl subsystem.
After few discussions from [1], it was concluded that may be gpio controller reporting the pin range it supports, is a better way than pinctrl subsystem directly registering it.
[1] http://comments.gmane.org/gmane.linux.ports.arm.kernel/184816
---V1->V2:
------
- Add non-DT routines to register gpio ranges
- Update Documentation/gpio.txt
- Update Documentation/pinctrl.txt to mark older way as DEPRECATED
- of_gpiochip_add_pin_range() rearranged a bit
- use devm_kzalloc() instead of kzalloc()
- few other minor fixes
Documentation/devicetree/bindings/gpio/gpio.txt | 36 ++++++++++++++++ Documentation/gpio.txt | 26 ++++++++++++ Documentation/pinctrl.txt | 3 ++ drivers/gpio/gpiolib-of.c | 56 +++++++++++++++++++++++++ drivers/gpio/gpiolib.c | 43 +++++++++++++++++++ drivers/pinctrl/core.c | 13 ++++++ drivers/pinctrl/devicetree.c | 13 ++++++ include/asm-generic/gpio.h | 25 +++++++++++ include/linux/gpio.h | 3 ++ include/linux/pinctrl/pinctrl.h | 17 ++++++++ 10 files changed, 235 insertions(+)
Documentation/devicetree/bindings/gpio/gpio.txt +36 -0
@@ -75,4 +75,40 @@ Example of two SOC GPIO banks defined as gpio-controller nodes: gpio-controller; }; +2.1) gpio-controller and pinctrl subsystem +------------------------------------------ +gpio-controller on a SOC might be tightly coupled with the pinctrl +subsystem, in the sense that the pins can be used by other functions +together with optional gpio feature. + +While the pin allocation is totally managed by the pin ctrl subsystem, +gpio (under gpiolib) is still maintained by gpio drivers. It may happen +that different pin ranges in a SoC is managed by different gpio drivers. + +This makes it logical to let gpio drivers announce their pin ranges to +the pin ctrl subsystem and call 'pinctrl_request_gpio' in order to +request the corresponding pin before any gpio usage. + +For this, the gpio controller can use a pinctrl phandle and pins to +announce the pinrange to the pin ctrl subsystem. For example, + + qe_pio_e: gpio-controller at 1460 { + #gpio-cells = <2>; + compatible = "fsl,qe-pario-bank-e", "fsl,qe-pario-bank"; + reg = <0x1460 0x18>; + gpio-controller; + gpio-ranges = <&pinctrl1 20 10>, <&pinctrl2 50 20>; + + } + +where, + &pinctrl1 and &pinctrl2 is the phandle to the pinctrl DT node. + + Next values specify the base pin and number of pins for the range + handled by 'qe_pio_e' gpio. In the given example from base pin 20 to + pin 29 under pinctrl1 and pin 50 to pin 69 under pinctrl2 is handled + by this gpio controller. + +The pinctrl node must have "#gpio-range-cells" property to show number of +arguments to pass with phandle from gpio controllers node.
Documentation/gpio.txt +26 -0
@@ -439,6 +439,32 @@ slower clock delays the rising edge of SCK, and the I2C master adjusts its signaling rate accordingly. +gpio-controller and pinctrl subsystem +------------------------------------------ + +gpio-controller on a SOC might be tightly coupled with the pinctrl +subsystem, in the sense that the pins can be used by other functions +together with optional gpio feature. + +While the pin allocation is totally managed by the pin ctrl subsystem, +gpio (under gpiolib) is still maintained by gpio drivers. It may happen +that different pin ranges in a SoC is managed by different gpio drivers. + +This makes it logical to let gpio drivers announce their pin ranges to +the pin ctrl subsystem and call 'pinctrl_request_gpio' in order to +request the corresponding pin before any gpio usage. + +For this, the gpio controller can register its pin range with pinctrl subsystem. +There are two ways of doing it currently with or without DT. + +For with DT support refer to Documentation/devicetree/bindings/gpio/gpio.txt. + +For non-DT support, user can call gpiochip_add_pin_range() with appropriate +parameters to register a range of gpio pins with a pinctrl driver. For this +exact name string of pinctrl device has to be passed as one of the argument to +this routine. + + What do these conventions omit? =============================== One of the biggest things these conventions omit is pin multiplexing, since
Documentation/pinctrl.txt +3 -0
@@ -364,6 +364,9 @@ will get an pin number into its handled number range. Further it is also passed the range ID value, so that the pin controller knows which range it should deal with. +Calling pinctrl_add_gpio_range from pinctrl driver is DEPRECATED. Please see +section 2.1 of Documentation/devicetree/bindings/gpio/gpio.txt on how to bind +pinctrl and gpio drivers. PINMUX interfaces =================
drivers/gpio/gpiolib-of.c +56 -0
79 lines not on this page · raw message
drivers/gpio/gpiolib.c +43 -0
55 lines not on this page · raw message
drivers/pinctrl/core.c +13 -0
@@ -345,6 +345,19 @@ void pinctrl_add_gpio_ranges(struct pinctrl_dev *pctldev, }EXPORT_SYMBOL_GPL (pinctrl_add_gpio_ranges); +struct pinctrl_dev *find_pinctrl_and_add_gpio_range (const char *devname, +struct pinctrl_gpio_range *range) +{ +struct pinctrl_dev *pctldev =get_pinctrl_dev_from_devname (devname); + +if (!pctldev) +return NULL ; + +pinctrl_add_gpio_range (pctldev, range); +return pctldev; +} +EXPORT_SYMBOL_GPL (find_pinctrl_and_add_gpio_range); +/** * pinctrl_remove_gpio_range() - remove a range of GPIOs fro a pin controller * @pctldev: pin controller device to remove the range from
drivers/pinctrl/devicetree.c +13 -0
@@ -106,6 +106,19 @@ static struct pinctrl_dev *find_pinctrl_by_of_node(struct device_node *np)return NULL ; } +struct pinctrl_dev *of_pinctrl_add_gpio_range (struct device_node *np, +struct pinctrl_gpio_range *range) +{ +struct pinctrl_dev *pctldev; + + pctldev =find_pinctrl_by_of_node (np); +if (!pctldev) +return NULL ; + +pinctrl_add_gpio_range (pctldev, range); +return pctldev; +} +static int dt_to_map_one_config (struct pinctrl *p,const char *statename,struct device_node *np_config) {
include/asm-generic/gpio.h +25 -0
@@ -5,6 +5,7 @@#include <linux/types.h> #include <linux/errno.h> #include <linux/of.h> +#include <linux/pinctrl/pinctrl.h> #ifdef CONFIG_GPIOLIB
@@ -47,6 +48,21 @@ struct seq_file;struct module ;struct device_node ; +#ifdef CONFIG_PINCTRL +/** +* struct gpio_pin_range - pin range controlled by a gpio chip +* @head: list for maintaining set of pin ranges, used internally +* @pctldev: pinctrl device which handles corresponding pins +* @range: actual range of pins controlled by a gpio controller +*/ + +struct gpio_pin_range { +struct list_head node; +struct pinctrl_dev *pctldev; +struct pinctrl_gpio_range range; +}; +#endif +/** * struct gpio_chip - abstract a GPIO controller * @label: for diagnostics
@@ -134,6 +150,15 @@ struct gpio_chip {int (*of_xlate)(struct gpio_chip *gc,const struct of_phandle_args *gpiospec,u32 *flags);#endif +#ifdef CONFIG_PINCTRL +/* +* If CONFIG_PINCTRL is enabled, then gpio controllers can optionally +* describe the actual pin range which they serve in an SoC. This +* information would be used by pinctrl subsystem to configure +* corresponding pins for gpio usage. +*/ +struct list_head pin_ranges; +#endif }; extern const char *gpiochip_is_requested(struct gpio_chip *chip,
include/linux/gpio.h +3 -0
@@ -231,6 +231,9 @@ static inline int irq_to_gpio(unsigned irq)return -EINVAL ; } +void gpiochip_add_pin_range (struct gpio_chip *chip,const char *pinctl_name, +unsigned int pin_base,unsigned int npins); +void gpiochip_remove_pin_ranges (struct gpio_chip *chip);#endif #endif /* __LINUX_GPIO_H */
include/linux/pinctrl/pinctrl.h +17 -0
@@ -136,6 +136,23 @@ extern void pinctrl_add_gpio_ranges(struct pinctrl_dev *pctldev, unsigned nranges);extern void pinctrl_remove_gpio_range (struct pinctrl_dev *pctldev,struct pinctrl_gpio_range *range); + +extern struct pinctrl_dev *find_pinctrl_and_add_gpio_range (const char *devname, +struct pinctrl_gpio_range *range); + +#ifdef CONFIG_OF +extern struct pinctrl_dev *of_pinctrl_add_gpio_range (struct device_node *np, +struct pinctrl_gpio_range *range); +#else +static inline +struct pinctrl_dev *of_pinctrl_add_gpio_range (struct device_node *np, +struct pinctrl_gpio_range *range) +{ +return NULL ; +} + +#endif /* CONFIG_OF */ +extern const char *pinctrl_dev_get_name (struct pinctrl_dev *pctldev);extern void *pinctrl_dev_get_drvdata (struct pinctrl_dev *pctldev);#else
Signature · 1 line
1.7.12.rc2.18.g61b472e
PATCH v2 3/5 pinctrl: SPEAr: Add plgpio driver
In reply to Viresh KumarMost of SPEAr SoCs, which support pinctrl, can configure & use pads as gpio. This patch adds plgpio driver for configuring these pads as gpio.
---
Linus,
It was Acked-by you last time it was sent:
http://www.spinics.net/lists/arm-kernel/msg173443.html
drivers/pinctrl/spear/Kconfig | 7 + drivers/pinctrl/spear/Makefile | 1 + drivers/pinctrl/spear/pinctrl-plgpio.c | 746 +++++++++++++++++++++++++++++++++ 3 files changed, 754 insertions(+) create mode 100644 drivers/pinctrl/spear/pinctrl-plgpio.c
drivers/pinctrl/spear/Kconfig +7 -0
@@ -41,4 +41,11 @@ config PINCTRL_SPEAR1340 depends on MACH_SPEAR1340 select PINCTRL_SPEAR +config PINCTRL_SPEAR_PLGPIO + bool "SPEAr SoC PLGPIO Controller" + depends on GPIOLIB && PINCTRL_SPEAR + help + Say yes here to support PLGPIO controller on ST Microelectronics SPEAr + SoCs. + endif
drivers/pinctrl/spear/Makefile +1 -0
@@ -1,5 +1,6 @@ # SPEAr pinmux support +obj-$(CONFIG_PINCTRL_SPEAR_PLGPIO) += pinctrl-plgpio.o obj-$(CONFIG_PINCTRL_SPEAR) += pinctrl-spear.o obj-$(CONFIG_PINCTRL_SPEAR3XX) += pinctrl-spear3xx.o obj-$(CONFIG_PINCTRL_SPEAR300) += pinctrl-spear300.o
drivers/pinctrl/spear/pinctrl-plgpio.c new file +746 -0
746 lines not on this page · raw message
Signature · 1 line
1.7.12.rc2.18.g61b472e
PATCH v2 4/5 pinctrl: SPEAr: Add gpio ranges support
In reply to Viresh KumarMost of SPEAr SoCs, which support pinctrl, can configure & use pads as gpio. This patch gpio enable support for SPEAr pinctrl drivers.
---
It has few differences since the time it was last posted. I kept your Acked-by as the changes aren't that big (I believe). :)
drivers/pinctrl/spear/Kconfig | 4 + drivers/pinctrl/spear/pinctrl-spear.c | 107 ++++++++++-- drivers/pinctrl/spear/pinctrl-spear.h | 46 ++++++ drivers/pinctrl/spear/pinctrl-spear1310.c | 264 ++++++++++++++++++++++++++++++ drivers/pinctrl/spear/pinctrl-spear300.c | 2 + drivers/pinctrl/spear/pinctrl-spear310.c | 2 + drivers/pinctrl/spear/pinctrl-spear320.c | 2 + drivers/pinctrl/spear/pinctrl-spear3xx.c | 37 +++++ 8 files changed, 447 insertions(+), 17 deletions(-)
drivers/pinctrl/spear/Kconfig +4 -0
@@ -25,21 +25,25 @@ config PINCTRL_SPEAR310 bool "ST Microelectronics SPEAr310 SoC pin controller driver" depends on MACH_SPEAR310 select PINCTRL_SPEAR3XX + select PINCTRL_SPEAR_PLGPIO config PINCTRL_SPEAR320 bool "ST Microelectronics SPEAr320 SoC pin controller driver" depends on MACH_SPEAR320 select PINCTRL_SPEAR3XX + select PINCTRL_SPEAR_PLGPIO config PINCTRL_SPEAR1310 bool "ST Microelectronics SPEAr1310 SoC pin controller driver" depends on MACH_SPEAR1310 select PINCTRL_SPEAR + select PINCTRL_SPEAR_PLGPIO config PINCTRL_SPEAR1340 bool "ST Microelectronics SPEAr1340 SoC pin controller driver" depends on MACH_SPEAR1340 select PINCTRL_SPEAR + select PINCTRL_SPEAR_PLGPIO config PINCTRL_SPEAR_PLGPIO bool "SPEAr SoC PLGPIO Controller"
drivers/pinctrl/spear/pinctrl-spear.c +90 -17
149 lines not on this page · raw message
drivers/pinctrl/spear/pinctrl-spear.h +46 -0
76 lines not on this page · raw message
drivers/pinctrl/spear/pinctrl-spear1310.c +264 -0
276 lines not on this page · raw message
drivers/pinctrl/spear/pinctrl-spear300.c +2 -0
@@ -661,6 +661,8 @@ static int __devinit spear300_pinctrl_probe(struct platform_device *pdev) spear3xx_machdata.ngroups =ARRAY_SIZE (spear300_pingroups); spear3xx_machdata.functions = spear300_functions; spear3xx_machdata.nfunctions =ARRAY_SIZE (spear300_functions); + spear3xx_machdata.gpio_pingroups =NULL ; + spear3xx_machdata.ngpio_pingroups =0 ; spear3xx_machdata.modes_supported = true; spear3xx_machdata.pmx_modes = spear300_pmx_modes;
drivers/pinctrl/spear/pinctrl-spear310.c +2 -0
@@ -388,6 +388,8 @@ static int __devinit spear310_pinctrl_probe(struct platform_device *pdev) spear3xx_machdata.nfunctions =ARRAY_SIZE (spear310_functions);pmx_init_addr (&spear3xx_machdata,PMX_CONFIG_REG ); +pmx_init_gpio_pingroup_addr (spear3xx_machdata.gpio_pingroups, + spear3xx_machdata.ngpio_pingroups,PMX_CONFIG_REG ); spear3xx_machdata.modes_supported = false;
drivers/pinctrl/spear/pinctrl-spear320.c +2 -0
@@ -3431,6 +3431,8 @@ static int __devinit spear320_pinctrl_probe(struct platform_device *pdev) spear3xx_machdata.npmx_modes =ARRAY_SIZE (spear320_pmx_modes);pmx_init_addr (&spear3xx_machdata,PMX_CONFIG_REG ); +pmx_init_gpio_pingroup_addr (spear3xx_machdata.gpio_pingroups, + spear3xx_machdata.ngpio_pingroups,PMX_CONFIG_REG ); ret =spear_pinctrl_probe (pdev, &spear3xx_machdata);if (ret)
drivers/pinctrl/spear/pinctrl-spear3xx.c +37 -0
@@ -481,7 +481,44 @@ struct spear_function spear3xx_timer_2_3_function = { .ngroups = ARRAY_SIZE(timer_2_3_grps), }; +/* Define muxreg arrays */ +DEFINE_MUXREG (firda_pins,0 ,PMX_FIRDA_MASK ,0 ); +DEFINE_MUXREG (i2c_pins,0 ,PMX_I2C_MASK ,0 ); +DEFINE_MUXREG (ssp_cs_pins,0 ,PMX_SSP_CS_MASK ,0 ); +DEFINE_MUXREG (ssp_pins,0 ,PMX_SSP_MASK ,0 ); +DEFINE_MUXREG (mii_pins,0 ,PMX_MII_MASK ,0 ); +DEFINE_MUXREG (gpio0_pin0_pins,0 ,PMX_GPIO_PIN0_MASK ,0 ); +DEFINE_MUXREG (gpio0_pin1_pins,0 ,PMX_GPIO_PIN1_MASK ,0 ); +DEFINE_MUXREG (gpio0_pin2_pins,0 ,PMX_GPIO_PIN2_MASK ,0 ); +DEFINE_MUXREG (gpio0_pin3_pins,0 ,PMX_GPIO_PIN3_MASK ,0 ); +DEFINE_MUXREG (gpio0_pin4_pins,0 ,PMX_GPIO_PIN4_MASK ,0 ); +DEFINE_MUXREG (gpio0_pin5_pins,0 ,PMX_GPIO_PIN5_MASK ,0 ); +DEFINE_MUXREG (uart0_ext_pins,0 ,PMX_UART0_MODEM_MASK ,0 ); +DEFINE_MUXREG (uart0_pins,0 ,PMX_UART0_MASK ,0 ); +DEFINE_MUXREG (timer_0_1_pins,0 ,PMX_TIMER_0_1_MASK ,0 ); +DEFINE_MUXREG (timer_2_3_pins,0 ,PMX_TIMER_2_3_MASK ,0 ); + +static struct spear_gpio_pingroup spear3xx_gpio_pingroup[] = { +GPIO_PINGROUP (firda_pins), +GPIO_PINGROUP (i2c_pins), +GPIO_PINGROUP (ssp_cs_pins), +GPIO_PINGROUP (ssp_pins), +GPIO_PINGROUP (mii_pins), +GPIO_PINGROUP (gpio0_pin0_pins), +GPIO_PINGROUP (gpio0_pin1_pins), +GPIO_PINGROUP (gpio0_pin2_pins), +GPIO_PINGROUP (gpio0_pin3_pins), +GPIO_PINGROUP (gpio0_pin4_pins), +GPIO_PINGROUP (gpio0_pin5_pins), +GPIO_PINGROUP (uart0_ext_pins), +GPIO_PINGROUP (uart0_pins), +GPIO_PINGROUP (timer_0_1_pins), +GPIO_PINGROUP (timer_2_3_pins), +}; +struct spear_pinctrl_machdata spear3xx_machdata = { .pins = spear3xx_pins, .npins =ARRAY_SIZE (spear3xx_pins), + .gpio_pingroups = spear3xx_gpio_pingroup, + .ngpio_pingroups =ARRAY_SIZE (spear3xx_gpio_pingroup), };
Signature · 1 line
1.7.12.rc2.18.g61b472e
PATCH v2 5/5 ARM: SPEAr: Add plgpio node in device tree dtsi files
In reply to Viresh KumarThis patch adds plgpio nodes in SPEAr DT files.
--- arch/arm/boot/dts/spear1310-evb.dts | 4 ++++ arch/arm/boot/dts/spear1310.dtsi | 27 +++++++++++++++++++++++++++ arch/arm/boot/dts/spear1340-evb.dts | 4 ++++ arch/arm/boot/dts/spear1340.dtsi | 26 ++++++++++++++++++++++++++ arch/arm/boot/dts/spear310.dtsi | 22 +++++++++++++++++++++- arch/arm/boot/dts/spear320-evb.dts | 4 ++++ arch/arm/boot/dts/spear320.dtsi | 23 ++++++++++++++++++++++- 7 files changed, 108 insertions(+), 2 deletions(-)
arch/arm/boot/dts/spear1310-evb.dts +4 -0
@@ -181,6 +181,10 @@ status = "okay"; }; + gpio at d8400000 { + status = "okay"; + }; + i2c0: i2c at e0280000 { status = "okay"; };
arch/arm/boot/dts/spear1310.dtsi +27 -0
@@ -70,6 +70,12 @@ status = "disabled"; }; + pinmux: pinmux at e0700000 { + compatible = "st,spear1310-pinmux"; + reg = <0xe0700000 0x1000>; + #gpio-range-cells = <2>; + }; + spi1: spi at 5d400000 { compatible = "arm,pl022", "arm,primecell"; reg = <0x5d400000 0x1000>;
@@ -179,6 +185,27 @@ thermal at e07008c4 { st,thermal-flags = <0x7000>; }; + + gpiopinctrl: gpio at d8400000 { + compatible = "st,spear-plgpio"; + reg = <0xd8400000 0x1000>; + interrupts = <0 100 0x4>; + #interrupt-cells = <1>; + interrupt-controller; + gpio-controller; + #gpio-cells = <2>; + gpio-ranges = <&pinmux 0 246>; + status = "disabled"; + + st-plgpio,ngpio = <246>; + st-plgpio,enb-reg = <0xd0>; + st-plgpio,wdata-reg = <0x90>; + st-plgpio,dir-reg = <0xb0>; + st-plgpio,ie-reg = <0x30>; + st-plgpio,rdata-reg = <0x70>; + st-plgpio,mis-reg = <0x10>; + st-plgpio,eit-reg = <0x50>; + }; }; }; };
arch/arm/boot/dts/spear1340-evb.dts +4 -0
@@ -193,6 +193,10 @@ status = "okay"; }; + gpio at e2800000 { + status = "okay"; + }; + i2c0: i2c at e0280000 { status = "okay"; };
arch/arm/boot/dts/spear1340.dtsi +26 -0
@@ -24,6 +24,12 @@ status = "disabled"; }; + pinmux: pinmux at e0700000 { + compatible = "st,spear1340-pinmux"; + reg = <0xe0700000 0x1000>; + #gpio-range-cells = <2>; + }; + spi1: spi at 5d400000 { compatible = "arm,pl022", "arm,primecell"; reg = <0x5d400000 0x1000>;
@@ -51,6 +57,26 @@ thermal at e07008c4 { st,thermal-flags = <0x2a00>; }; + + gpiopinctrl: gpio at e2800000 { + compatible = "st,spear-plgpio"; + reg = <0xe2800000 0x1000>; + interrupts = <0 107 0x4>; + #interrupt-cells = <1>; + interrupt-controller; + gpio-controller; + #gpio-cells = <2>; + gpio-ranges = <&pinmux 0 252>; + status = "disabled"; + + st-plgpio,ngpio = <250>; + st-plgpio,wdata-reg = <0x40>; + st-plgpio,dir-reg = <0x00>; + st-plgpio,ie-reg = <0x80>; + st-plgpio,rdata-reg = <0x20>; + st-plgpio,mis-reg = <0xa0>; + st-plgpio,eit-reg = <0x60>; + }; }; }; };
arch/arm/boot/dts/spear310.dtsi +21 -1
@@ -22,9 +22,10 @@ 0xb0000000 0xb0000000 0x10000000 0xd0000000 0xd0000000 0x30000000>; - pinmux at b4000000 { + pinmux: pinmux at b4000000 { compatible = "st,spear310-pinmux"; reg = <0xb4000000 0x1000>; + #gpio-range-cells = <2>; }; fsmc: flash at 44000000 {
@@ -75,6 +76,25 @@ reg = <0xb2200000 0x1000>; status = "disabled"; }; + + gpiopinctrl: gpio at b4000000 { + compatible = "st,spear-plgpio"; + reg = <0xb4000000 0x1000>; + #interrupt-cells = <1>; + interrupt-controller; + gpio-controller; + #gpio-cells = <2>; + gpio-ranges = <&pinmux 0 102>; + status = "disabled"; + + st-plgpio,ngpio = <102>; + st-plgpio,enb-reg = <0x10>; + st-plgpio,wdata-reg = <0x20>; + st-plgpio,dir-reg = <0x30>; + st-plgpio,ie-reg = <0x50>; + st-plgpio,rdata-reg = <0x40>; + st-plgpio,mis-reg = <0x60>; + }; }; }; };
arch/arm/boot/dts/spear320-evb.dts +4 -0
@@ -164,6 +164,10 @@ status = "okay"; }; + gpio at b3000000 { + status = "okay"; + }; + i2c0: i2c at d0180000 { status = "okay"; };
arch/arm/boot/dts/spear320.dtsi +22 -1
@@ -21,9 +21,10 @@ ranges = <0x40000000 0x40000000 0x80000000 0xd0000000 0xd0000000 0x30000000>; - pinmux at b3000000 { + pinmux: pinmux at b3000000 { compatible = "st,spear320-pinmux"; reg = <0xb3000000 0x1000>; + #gpio-range-cells = <2>; }; clcd at 90000000 {
@@ -90,6 +91,26 @@ reg = <0xa4000000 0x1000>; status = "disabled"; }; + + gpiopinctrl: gpio at b3000000 { + compatible = "st,spear-plgpio"; + reg = <0xb3000000 0x1000>; + #interrupt-cells = <1>; + interrupt-controller; + gpio-controller; + #gpio-cells = <2>; + gpio-ranges = <&pinmux 0 102>; + status = "disabled"; + + st-plgpio,ngpio = <102>; + st-plgpio,enb-reg = <0x24>; + st-plgpio,wdata-reg = <0x34>; + st-plgpio,dir-reg = <0x44>; + st-plgpio,ie-reg = <0x64>; + st-plgpio,rdata-reg = <0x54>; + st-plgpio,mis-reg = <0x84>; + st-plgpio,eit-reg = <0x94>; + }; }; }; };
Signature · 1 line
1.7.12.rc2.18.g61b472e
PATCH RESEND v2 2/5 gpiolib: provide provision for gpiolib to register pin range
In reply to Viresh KumarQuoted 13 lines · Viresh Kumar
From: Shiraz Hashim <[email protected]>
pinctrl subsystem needs gpio chip base to prepare set of gpio pin ranges, which a given pinctrl driver can handle. This is important to handle pinctrl gpio request calls in order to program a given pin properly for gpio operation.
As gpio base is allocated dynamically during gpiochip registration, presently there exists no clean way to pass this information to the pinctrl subsystem.
After few discussions from [1], it was concluded that may be gpio controller reporting the pin range it supports, is a better way than pinctrl subsystem directly registering it.
Quoted 5 lines
[1] http://comments.gmane.org/gmane.linux.ports.arm.kernel/184816
Cc Grant Likely <[email protected]>Signed-off-by Viresh Kumar <[email protected]>Signed-off-by Shiraz Hashim <[email protected]>
Hey thanks for working out the details of this!!
Patch applied, but I was a bit picky about the English in the documentation so I patched it around a little, hope you don't mind (diff below).
I will now try to make the U300 use this new range concep as guinea pig, and that platform is *not* using DT so we'll see for sure if it works :-)
Yours,
Linus Walleij
-gpio-controller and pinctrl subsystem
+GPIO controllers and the pinctrl subsystem
------------------------------------------
-gpio-controller on a SOC might be tightly coupled with the pinctrl +A GPIO controller on a SOC might be tightly coupled with the pinctrl
subsystem, in the sense that the pins can be used by other functions
-together with optional gpio feature.
+together with an optional gpio feature. We have already covered the +case where e.g. a GPIO controller need to reserve a pin or set the +direction of a pin by calling any of:
-While the pin allocation is totally managed by the pin ctrl subsystem, +pinctrl_request_gpio()
+pinctrl_free_gpio()
+pinctrl_gpio_direction_input() +pinctrl_gpio_direction_output()
+
+But how does the pin control subsystem cross-correlate the GPIO +numbers (which are a global business) to a certain pin on a certain +pin controller?
+
+This is done by registering "ranges" of pins, which are essentially +cross-reference tables. These are described in +Documentation/pinctrl.txt
+
+While the pin allocation is totally managed by the pinctrl subsystem,
gpio (under gpiolib) is still maintained by gpio drivers. It may happen that different pin ranges in a SoC is managed by different gpio drivers.
This makes it logical to let gpio drivers announce their pin ranges to
-the pin ctrl subsystem and call 'pinctrl_request_gpio' in order to -request the corresponding pin before any gpio usage.
+the pin ctrl subsystem before it will call 'pinctrl_request_gpio' in order +to request the corresponding pin to be prepared by the pinctrl subsystem +before any gpio usage.
-For this, the gpio controller can register its pin range with pinctrl subsystem -There are two ways of doing it currently with or without DT.
+For this, the gpio controller can register its pin range with pinctrl +subsystem. There are two ways of doing it currently: with or without DT.
For with DT support refer to Documentation/devicetree/bindings/gpio/gpio.txt.
For non-DT support, user can call gpiochip_add_pin_range() with appropriate parameters to register a range of gpio pins with a pinctrl driver. For this
-exact name string of pinctrl device has to be passed as one of the argument to -this routine.
+exact name string of pinctrl device has to be passed as one of the +argument to this routine.
What do these conventions omit?
Linus Walleij
AppliedPATCH v2 1/5 Revert "pinctrl: remove pinctrl_remove_gpio_range"
In reply to Viresh KumarQuoted 8 lines · Viresh Kumar
This reverts earlier commit which removed
pinctrl_remove_gpio_range(), because at that time there aren't any more users of that routine. It was removed as the removal of ranges was done in unregister of pinctrl.But because we are registering stuff from gpiolib now, we may remove and insert a gpio module multiple times. So, we need that again.
Signed-off-by Viresh Kumar <[email protected]>
Applied as prerequisite for patch 2.
Yours,
Linus Walleij
Linus Walleij
AppliedPATCH v2 3/5 pinctrl: SPEAr: Add plgpio driver
In reply to Viresh KumarQuoted 5 lines · Viresh Kumar
Most of SPEAr SoCs, which support pinctrl, can configure & use pads as gpio. This patch adds plgpio driver for configuring these pads as gpio.
Signed-off-by Viresh Kumar <[email protected]>Acked-by Linus Walleij <[email protected]>
Applied.
Yours,
Linus Walleij
PATCH RESEND v2 2/5 gpiolib: provide provision for gpiolib to register pin range
In reply to Linus WalleijQuoted 6 lines · Linus Walleij
Hey thanks for working out the details of this!!
Patch applied, but I was a bit picky about the English in the documentation so I patched it around a little, hope you don't mind (diff below).
No way. Its just perfect. :)
Quoted 3 lines
I will now try to make the U300 use this new range concep as guinea pig, and that platform is *not* using DT so we'll see for sure if it works :-)
Hope it works, as i haven't tested it at all. Don't have any SPEAr board with me :)
Hope this long gpioi chain will end now.
--
viresh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20121106/7918a549/attachment-0001.html>
PATCH v2 4/5 pinctrl: SPEAr: Add gpio ranges support
In reply to Viresh KumarQuoted 9 lines · Viresh Kumar
Most of SPEAr SoCs, which support pinctrl, can configure & use pads as gpio. This patch gpio enable support for SPEAr pinctrl drivers.
Signed-off-by Viresh Kumar <[email protected]>Acked-by Linus Walleij <[email protected]>---
It has few differences since the time it was last posted. I kept your Acked-by as the changes aren't that big (I believe). :)
This does not apply to my devel branch, so I guess it is dependent on some of the stuff I just merged to fixes. I will send the fixes up to Torvalds, then merge fixes to the devel branch so we can proceed with patches 4 and 5, OK?
Yours,
Linus Walleij
PATCH v2 4/5 pinctrl: SPEAr: Add gpio ranges support
Quoted 4 lines · Linus Walleij
This does not apply to my devel branch, so I guess it is dependent on some of the stuff I just merged to fixes. I will send the fixes up to Torvalds, then merge fixes to the devel branch so we can proceed with patches 4 and 5, OK?
When will i learn how to send patches x-(
Yes, they were rebased over fixes.
--
viresh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20121106/060b0d9e/attachment-0001.html>
PATCH v2 4/5 pinctrl: SPEAr: Add gpio ranges support
Quoted 10 lines · Viresh Kumar
Quoted 5 lines · Linus Walleij
This does not apply to my devel branch, so I guess it is dependent on some of the stuff I just merged to fixes. I will send the fixes up to Torvalds, then merge fixes to the devel branch so we can proceed with patches 4 and 5, OK?
When will i learn how to send patches x-(
Yes, they were rebased over fixes.
You are doing everything right, it is perfectly OK to assume fixes to be merged first, and in either way the subsystem maintainer will get some small conflicts, but he (i.e. me) gets to deal with them. I have to do something as well you know ;-)
Yours,
Linus Walleij
PATCH v2 4/5 pinctrl: SPEAr: Add gpio ranges support
In reply to Viresh KumarQuoted 5 lines · Viresh Kumar
Most of SPEAr SoCs, which support pinctrl, can configure & use pads as gpio. This patch gpio enable support for SPEAr pinctrl drivers.
Signed-off-by Viresh Kumar <[email protected]>Acked-by Linus Walleij <[email protected]>
Now, as I have brought in v3.7-rc5, I have applied this patch that depended on the fixes.
Yours,
Linus Walleij
PATCH v2 5/5 ARM: SPEAr: Add plgpio node in device tree dtsi files
In reply to Viresh KumarQuoted 3 lines · Viresh Kumar
This patch adds plgpio nodes in SPEAr DT files.
Signed-off-by Viresh Kumar <[email protected]>
Applied this as well.
Yours,
Linus Walleij