gpio: Device tree support for LPC32xx
Subsystems (5)
PATCH v2 1/1 gpio: Device tree support for LPC32xx
This patch adds device tree support for gpio-lpc32xx.c
---
Applies to v3.4-rc1
Changes since last version:
* Documented property #address-cells (always 1)
* Documented property status="disabled"
* Removed gpio-lines property
* Removed #gpio-cells from the parent node
* Support both DT and non-DT to make patch less disruptive and independent from DT switch of mach-lpc32xx
* Use module_platform_driver()
Thanks to Arnd Bergmann and Grant Likely for reviewing!
Documentation/devicetree/bindings/gpio/gpio_lpc32xx.txt | 65 ++++++++++++++++ arch/arm/mach-lpc32xx/include/mach/gpio.h | 9 +- drivers/gpio/gpio-lpc32xx.c | 52 ++++++++++++ 3 files changed, 123 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/gpio/gpio_lpc32xx.txt new file +65 -0
@@ -0,0 +1,65 @@ +NXP LPC32xx SoC GPIO controller + +Required properties: +- compatible: "nxp,lpc32xx-gpio" +- reg: Physical base address and length of the controller's registers. +- #address-cells: Always 1, for indexing of the subnodes (GPIO groups of the + SoC) +- #size-cells: Always 0 + +Required properties of sub-nodes which describe the GPIO groups of LPC32xx: +- gpio-controller: Marks the device node as a GPIO controller. +- #gpio-cells: Should be two. The first cell is the pin number and the + second cell is used to specify optional parameters: + - bit 0 specifies polarity (0 for normal, 1 for inverted) +- reg: Index of the GPIO group + +Optional properties of sub-nodes which describe the GPIO groups of LPC32xx: +- status: Set to "disabled" if you don't use the respective GPIO group + of the LPC32 SoC + +Example: + + gpio: gpio at 40028000 { + compatible = "nxp,lpc32xx-gpio"; + reg = <0x40028000 0x1000>; + /* create a private address space for enumeration */ + #address-cells = <1>; + #size-cells = <0>; + + gpio_p0: gpio-bank at 0 { + gpio-controller; + #gpio-cells = <2>; + reg = <0>; + }; + + gpio_p1: gpio-bank at 1 { + gpio-controller; + #gpio-cells = <2>; + reg = <1>; + }; + + gpio_p2: gpio-bank at 2 { + gpio-controller; + #gpio-cells = <2>; + reg = <2>; + }; + + gpio_p3: gpio-bank at 3 { + gpio-controller; + #gpio-cells = <2>; + reg = <3>; + }; + + gpi_p3: gpio-bank at 4 { + gpio-controller; + #gpio-cells = <2>; + reg = <4>; + }; + + gpo_p3: gpio-bank at 5 { + gpio-controller; + #gpio-cells = <2>; + reg = <5>; + }; + };
arch/arm/mach-lpc32xx/include/mach/gpio.h +8 -1
@@ -1 +1,8 @@ -/* empty */ +#ifndef __MACH_GPIO_H +#define __MACH_GPIO_H + +#include "gpio-lpc32xx.h" + +#define ARCH_NR_GPIOS (LPC32XX_GPO_P3_GRP + LPC32XX_GPO_P3_MAX) + +#endif /* __MACH_GPIO_H */
drivers/gpio/gpio-lpc32xx.c +50 -2
66 lines not on this page · raw message
Quoted 3 lines · Roland Stigge
This patch adds device tree support for
gpio-lpc32xx.cSigned-off-by Roland Stigge <[email protected]>
Just one more comment:
Quoted 5 lines
drivers/gpio/gpio-lpc32xx.c +5
-0+#ifdef CONFIG_OF +static struct of_device_id lpc32xx_gpio_of_match[]__devinitdata = { + { .compatible ="nxp,lpc32xx-gpio" , }, + { }, +};
drivers/gpio/gpio-lpc32xx.c static struct lpc32xx_gpio_chip lpc32xx_ · line 509
Quoted 10 lines
drivers/gpio/gpio-lpc32xx.c +10
-0+#endif + +static struct platform_driver lpc32xx_gpio_driver = { + .driver = { + .name ="lpc32xx-gpio" , + .owner =THIS_MODULE , + .of_match_table = lpc32xx_gpio_of_match, + }, + .probe = lpc32xx_gpio_probe, +};
The #ifdef above is not helpful, it will cause a build error in the of_match_table= assignment. Since the plan for this driver is to be devicetree-only, it would be appropriate to just remove the #ifdef, but adding of_match_ptr() is ok too.
Arnd
Quoted 12 lines · Arnd Bergmann
Quoted 12 lines
drivers/gpio/gpio-lpc32xx.c +12
-0+#ifdef CONFIG_OF +static struct of_device_id lpc32xx_gpio_of_match[]__devinitdata = { + { .compatible ="nxp,lpc32xx-gpio" , }, + { }, +}; +#endif + +static struct platform_driver lpc32xx_gpio_driver = { + .driver = { + .name ="lpc32xx-gpio" , + .owner =THIS_MODULE , + .of_match_table = lpc32xx_gpio_of_match,
Quoted 8 lines
drivers/gpio/gpio-lpc32xx.c static struct lpc32xx_gpio_chip lpc32xx_ · line 509
Quoted 3 lines
drivers/gpio/gpio-lpc32xx.c +3
-0+ }, + .probe = lpc32xx_gpio_probe, +};The #ifdef above is not helpful, it will cause a build error in the of_match_table= assignment. Since the plan for this driver is to be devicetree-only, it would be appropriate to just remove the #ifdef, but adding
of_match_ptr()is ok too.
I think I just forgot the of_match_ptr(). Will post an update with a repo for gpio to pull from.
Thanks for the note!
Roland
Quoted 32 lines · Roland Stigge
This patch adds device tree support for
gpio-lpc32xx.cSigned-off-by Roland Stigge <[email protected]>---
Applies to v3.4-rc1
Changes since last version:
* Documented property #address-cells (always 1)
* Documented property status="disabled"
* Removed gpio-lines property
* Removed #gpio-cells from the parent node
* Support both DT and non-DT to make patch less disruptive and independent from DT switch of mach-lpc32xx
* Usemodule_platform_driver()Thanks to Arnd Bergmann and Grant Likely for reviewing!
Documentation/devicetree/bindings/gpio/gpio_lpc32xx.txt | 65 ++++++++++++++++ arch/arm/mach-lpc32xx/include/mach/gpio.h | 9 +- drivers/gpio/gpio-lpc32xx.c | 52 ++++++++++++ 3 files changed, 123 insertions(+), 3 deletions(-)Documentation/devicetree/bindings/gpio/gpio_lpc32xx.txt new file +5
-0@@ -0,0 +1,65 @@ +NXP LPC32xx SoC GPIO controller + +Required properties: +- compatible: "nxp,lpc32xx-gpio" +- reg: Physical base address and length of the controller's registers.
Documentation/devicetree/bindings/gpio/gpio_lpc32xx.txt line 15
Quoted 10 lines
Documentation/devicetree/bindings/gpio/gpio_lpc32xx.txt new file +10
-0+- #address-cells: Always 1, for indexing of the subnodes (GPIO groups of the + SoC) +- #size-cells: Always 0 + +Required properties of sub-nodes which describe the GPIO groups of LPC32xx: +- gpio-controller: Marks the device node as a GPIO controller. +- #gpio-cells: Should be two. The first cell is the pin number and the + second cell is used to specify optional parameters: + - bit 0 specifies polarity (0 for normal, 1 for inverted) +- reg: Index of the GPIO group
If these are merely contiguous register banks of 32 gpio lines, then established convention is pretty much to only use one node and make the translate function decode bank and bit out of the gpio specifier. There isn't a whole lot of value it having all the sub nodes when there isn't anything significantly different between them.
How is documentation for this gpio controller written? Is it one big number space, or are the gpio numbers split up into banks? You have two choices here for the encoding; either just use #gpio-cells=<2> as done now, or use #gpio-cells=<3> and using cell0 for the bank and cell1 for the bit. You should choose the option that best lines up with how the hardware documents its gpio pins because that will be the most user-friendly.
g.
Quoted 132 lines
Documentation/devicetree/bindings/gpio/gpio_lpc32xx.txt new file +50
-0+ +Optional properties of sub-nodes which describe the GPIO groups of LPC32xx: +- status: Set to "disabled" if you don't use the respective GPIO group + of the LPC32 SoC + +Example: + + gpio: gpio at 40028000 { + compatible = "nxp,lpc32xx-gpio"; + reg = <0x40028000 0x1000>; + /* create a private address space for enumeration */ + #address-cells = <1>; + #size-cells = <0>; + + gpio_p0: gpio-bank at 0 { + gpio-controller; + #gpio-cells = <2>; + reg = <0>; + }; + + gpio_p1: gpio-bank at 1 { + gpio-controller; + #gpio-cells = <2>; + reg = <1>; + }; + + gpio_p2: gpio-bank at 2 { + gpio-controller; + #gpio-cells = <2>; + reg = <2>; + }; + + gpio_p3: gpio-bank at 3 { + gpio-controller; + #gpio-cells = <2>; + reg = <3>; + }; + + gpi_p3: gpio-bank at 4 { + gpio-controller; + #gpio-cells = <2>; + reg = <4>; + }; + + gpo_p3: gpio-bank at 5 { + gpio-controller; + #gpio-cells = <2>; + reg = <5>; + }; + };arch/arm/mach-lpc32xx/include/mach/gpio.h +8
-1@@ -1 +1,8 @@ -/* empty */ +#ifndef __MACH_GPIO_H +#define __MACH_GPIO_H + +#include "gpio-lpc32xx.h" + +#define ARCH_NR_GPIOS (LPC32XX_GPO_P3_GRP + LPC32XX_GPO_P3_MAX) + +#endif /* __MACH_GPIO_H */ drivers/gpio/gpio-lpc32xx.c +50
-2@@ -21,6 +21,9 @@#include <linux/io.h> #include <linux/errno.h> #include <linux/gpio.h> +#include <linux/of_gpio.h> +#include <linux/platform_device.h> +#include <linux/module.h> #include <mach/hardware.h> #include <mach/platform.h> @@ -454,10 +457,55 @@ static struct lpc32xx_gpio_chip lpc32xx_ }, }; +/* Empty now, can be removed later when mach-lpc32xx is finally switched over +* to DT support +*/ void __init lpc32xx_gpio_init (void ) { +} + +static int __devinit lpc32xx_gpio_probe (struct platform_device *pdev) +{ +struct device_node *node;int i; -for (i =0 ; i <ARRAY_SIZE (lpc32xx_gpiochip); i++) -gpiochip_add (&lpc32xx_gpiochip[i].chip); +if (pdev->dev.of_node) { +for_each_child_of_node (pdev->dev.of_node, node) { +if (of_device_is_available (node)) { +u32 index; +struct gpio_chip *chip; +if (of_property_read_u32 (node, +"reg" , &index) <0 ) +continue ; +if (index >=ARRAY_SIZE (lpc32xx_gpiochip)) +continue ; + chip = &lpc32xx_gpiochip[index].chip; + chip->of_node =of_node_get (node); +gpiochip_add (chip); + } + } + }else { +for (i =0 ; i <ARRAY_SIZE (lpc32xx_gpiochip); i++) +gpiochip_add (&lpc32xx_gpiochip[i].chip); + } + +return 0 ; } + +#ifdef CONFIG_OF +static struct of_device_id lpc32xx_gpio_of_match[]__devinitdata = { + { .compatible ="nxp,lpc32xx-gpio" , }, + { }, +}; +#endif + +static struct platform_driver lpc32xx_gpio_driver = { + .driver = { + .name ="lpc32xx-gpio" , + .owner =THIS_MODULE , + .of_match_table = lpc32xx_gpio_of_match, + }, + .probe = lpc32xx_gpio_probe, +}; + +module_platform_driver (lpc32xx_gpio_driver);
Signature · 2 lines
Grant Likely, B.Sc, P.Eng. Secret Lab Technologies,Ltd.
Hi Grant,
thanks for your suggestions about LPC32xx GPIO DT.
Regarding the numbering:
Quoted 11 lines · Grant Likely
Quoted 11 lines
Documentation/devicetree/bindings/gpio/gpio_lpc32xx.txt new file +11
-0+Required properties: +- compatible: "nxp,lpc32xx-gpio" +- reg: Physical base address and length of the controller's registers. +- #address-cells: Always 1, for indexing of the subnodes (GPIO groups of the + SoC) +- #size-cells: Always 0 + +Required properties of sub-nodes which describe the GPIO groups of LPC32xx: +- gpio-controller: Marks the device node as a GPIO controller. +- #gpio-cells: Should be two. The first cell is the pin number and the + second cell is used to specify optional parameters:
Quoted 8 lines
Quoted 2 lines
+ - bit 0 specifies polarity (0 for normal, 1 for inverted) +- reg: Index of the GPIO group
If these are merely contiguous register banks of 32 gpio lines, then established convention is pretty much to only use one node and make the translate function decode bank and bit out of the gpio specifier. There isn't a whole lot of value it having all the sub nodes when there isn't anything significantly different between them.
Please consider how the groups are specified in drivers/gpio/gpio-lpc32xx.c. They each have different numbers of lines and GPIO / GPI / GPO functionality. So they also have different callback sets, and we need to do separate gpiochip_add()s which leads to the separate gpio-bank specifications in the dtsi file. Separate enabling of those banks via OF are a nice by-product.
So I would like to keep it that way.
What do you think?
Thanks in advance,
Roland
Quoted 126 lines
Quoted 125 lines
Documentation/devicetree/bindings/gpio/gpio_lpc32xx.txt new file +43
-0+ gpio: gpio at 40028000 { + compatible = "nxp,lpc32xx-gpio"; + reg = <0x40028000 0x1000>; + /* create a private address space for enumeration */ + #address-cells = <1>; + #size-cells = <0>; + + gpio_p0: gpio-bank at 0 { + gpio-controller; + #gpio-cells = <2>; + reg = <0>; + }; + + gpio_p1: gpio-bank at 1 { + gpio-controller; + #gpio-cells = <2>; + reg = <1>; + }; + + gpio_p2: gpio-bank at 2 { + gpio-controller; + #gpio-cells = <2>; + reg = <2>; + }; + + gpio_p3: gpio-bank at 3 { + gpio-controller; + #gpio-cells = <2>; + reg = <3>; + }; + + gpi_p3: gpio-bank at 4 { + gpio-controller; + #gpio-cells = <2>; + reg = <4>; + }; + + gpo_p3: gpio-bank at 5 { + gpio-controller; + #gpio-cells = <2>; + reg = <5>; + }; + };arch/arm/mach-lpc32xx/include/mach/gpio.h +8
-1@@ -1 +1,8 @@ -/* empty */ +#ifndef __MACH_GPIO_H +#define __MACH_GPIO_H + +#include "gpio-lpc32xx.h" + +#define ARCH_NR_GPIOS (LPC32XX_GPO_P3_GRP + LPC32XX_GPO_P3_MAX) + +#endif /* __MACH_GPIO_H */ drivers/gpio/gpio-lpc32xx.c +50
-2@@ -21,6 +21,9 @@#include <linux/io.h> #include <linux/errno.h> #include <linux/gpio.h> +#include <linux/of_gpio.h> +#include <linux/platform_device.h> +#include <linux/module.h> #include <mach/hardware.h> #include <mach/platform.h> @@ -454,10 +457,55 @@ static struct lpc32xx_gpio_chip lpc32xx_ }, }; +/* Empty now, can be removed later when mach-lpc32xx is finally switched over +* to DT support +*/ void __init lpc32xx_gpio_init (void ) { +} + +static int __devinit lpc32xx_gpio_probe (struct platform_device *pdev) +{ +struct device_node *node;int i; -for (i =0 ; i <ARRAY_SIZE (lpc32xx_gpiochip); i++) -gpiochip_add (&lpc32xx_gpiochip[i].chip); +if (pdev->dev.of_node) { +for_each_child_of_node (pdev->dev.of_node, node) { +if (of_device_is_available (node)) { +u32 index; +struct gpio_chip *chip; +if (of_property_read_u32 (node, +"reg" , &index) <0 ) +continue ; +if (index >=ARRAY_SIZE (lpc32xx_gpiochip)) +continue ; + chip = &lpc32xx_gpiochip[index].chip; + chip->of_node =of_node_get (node); +gpiochip_add (chip); + } + } + }else { +for (i =0 ; i <ARRAY_SIZE (lpc32xx_gpiochip); i++) +gpiochip_add (&lpc32xx_gpiochip[i].chip); + } + +return 0 ; } + +#ifdef CONFIG_OF +static struct of_device_id lpc32xx_gpio_of_match[]__devinitdata = { + { .compatible ="nxp,lpc32xx-gpio" , }, + { }, +}; +#endif + +static struct platform_driver lpc32xx_gpio_driver = { + .driver = { + .name ="lpc32xx-gpio" , + .owner =THIS_MODULE , + .of_match_table = lpc32xx_gpio_of_match, + }, + .probe = lpc32xx_gpio_probe, +}; + +module_platform_driver (lpc32xx_gpio_driver);
Quoted 1 line · Roland Stigge
Hi Grant,
...
Quoted 6 lines
Please consider how the groups are specified in
drivers/gpio/gpio-lpc32xx.c. They each have different numbers of lines and GPIO / GPI / GPO functionality. So they also have different callback sets, and we need to do separate gpiochip_add()s which leads to the separate gpio-bank specifications in the dtsi file. Separate enabling of those banks via OF are a nice by-product.
And BTW: This also corresponds nicely with how the LPC32xx hardware calls its GPIOs, e.g. GPO 3 for GPO #3 in the gpo group.
Thanks for considering,
Roland
Quoted 27 lines · Roland Stigge
Hi Grant,
thanks for your suggestions about LPC32xx GPIO DT.
Regarding the numbering:
Quoted 11 lines · Grant Likely
Quoted 11 lines
Documentation/devicetree/bindings/gpio/gpio_lpc32xx.txt new file +11
-0+Required properties: +- compatible: "nxp,lpc32xx-gpio" +- reg: Physical base address and length of the controller's registers. +- #address-cells: Always 1, for indexing of the subnodes (GPIO groups of the + ?SoC) +- #size-cells: Always 0 + +Required properties of sub-nodes which describe the GPIO groups of LPC32xx: +- gpio-controller: Marks the device node as a GPIO controller. +- #gpio-cells: Should be two. The first cell is the pin number and the + ?second cell is used to specify optional parameters:Quoted 8 lines
Quoted 2 lines
+ ?- bit 0 specifies polarity (0 for normal, 1 for inverted) +- reg: Index of the GPIO group
If these are merely contiguous register banks of 32 gpio lines, then established convention is pretty much to only use one node and make the translate function decode bank and bit out of the gpio specifier. There isn't a whole lot of value it having all the sub nodes when there isn't anything significantly different between them.
Quoted 6 lines
Please consider how the groups are specified in
drivers/gpio/gpio-lpc32xx.c. They each have different numbers of lines and GPIO / GPI / GPO functionality. So they also have different callback sets, and we need to do separate gpiochip_add()s which leads to the separate gpio-bank specifications in the dtsi file. Separate enabling of those banks via OF are a nice by-product.
When you have six banks of 32b registers with sparse, active GPIOs in the banks, is there any advantage to saying bank one has 8 gpios, bank 2 has 14, bank 3 has 2, etc in the gpiochip? Or just just register them as six banks of 32 GPIOs without indicating which are
valid/invalid? Maybe add a way for the DT to indicate the sparse map
of valid GPIOs?
We're introducing a lot of complexity around invalid GPIO numbers that shouldn't matter in a working system.
LPC31xx is even worse. I have 12 banks of sparse GPIOs.
Quoted 141 lines
So I would like to keep it that way.
What do you think?
Thanks in advance,
Roland
Quoted 117 lines
Quoted 117 lines
+ ? ?gpio: gpio at 40028000 {
+ ? ? ? ? ? ?compatible = "nxp,lpc32xx-gpio";
+ ? ? ? ? ? ?reg = <0x400280000x1000>;
+ ? ? ? ? ? ?/* create a private address space for enumeration */
+ ? ? ? ? ? ?#address-cells = <1>;
+ ? ? ? ? ? ?#size-cells = <0>;(quoted diff) +37
-0+ + ? ? ? ? ? ?gpio_p0: gpio-bank at 0 { + ? ? ? ? ? ? ? ? ? ?gpio-controller; + ? ? ? ? ? ? ? ? ? ?#gpio-cells = <2>; + ? ? ? ? ? ? ? ? ? ?reg = <0>; + ? ? ? ? ? ?}; + + ? ? ? ? ? ?gpio_p1: gpio-bank at 1 { + ? ? ? ? ? ? ? ? ? ?gpio-controller; + ? ? ? ? ? ? ? ? ? ?#gpio-cells = <2>; + ? ? ? ? ? ? ? ? ? ?reg = <1>; + ? ? ? ? ? ?}; + + ? ? ? ? ? ?gpio_p2: gpio-bank at 2 { + ? ? ? ? ? ? ? ? ? ?gpio-controller; + ? ? ? ? ? ? ? ? ? ?#gpio-cells = <2>; + ? ? ? ? ? ? ? ? ? ?reg = <2>; + ? ? ? ? ? ?}; + + ? ? ? ? ? ?gpio_p3: gpio-bank at 3 { + ? ? ? ? ? ? ? ? ? ?gpio-controller; + ? ? ? ? ? ? ? ? ? ?#gpio-cells = <2>; + ? ? ? ? ? ? ? ? ? ?reg = <3>; + ? ? ? ? ? ?}; + + ? ? ? ? ? ?gpi_p3: gpio-bank at 4 { + ? ? ? ? ? ? ? ? ? ?gpio-controller; + ? ? ? ? ? ? ? ? ? ?#gpio-cells = <2>; + ? ? ? ? ? ? ? ? ? ?reg = <4>; + ? ? ? ? ? ?}; + + ? ? ? ? ? ?gpo_p3: gpio-bank at 5 { + ? ? ? ? ? ? ? ? ? ?gpio-controller; + ? ? ? ? ? ? ? ? ? ?#gpio-cells = <2>; + ? ? ? ? ? ? ? ? ? ?reg = <5>; + ? ? ? ? ? ?}; + ? ?};arch/arm/mach-lpc32xx/include/mach/gpio.h +8
-1@@ -1 +1,8 @@ -/* empty */ +#ifndef __MACH_GPIO_H +#define __MACH_GPIO_H + +#include "gpio-lpc32xx.h" + +#define ARCH_NR_GPIOS (LPC32XX_GPO_P3_GRP + LPC32XX_GPO_P3_MAX) + +#endif /* __MACH_GPIO_H */ drivers/gpio/gpio-lpc32xx.c +0
-0@@ -21,6 +21,9 @@?#include <
linux/io.h>
?#include <linux/errno.h>
?#include <linux/gpio.h>drivers/gpio/gpio-lpc32xx.c +3
-0+#include <linux/of_gpio.h> +#include <linux/platform_device.h> +#include <linux/module.h> ?#include <
mach/hardware.h>
?#include <mach/platform.h>drivers/gpio/gpio-lpc32xx.c +39
-2@@ -454,10 +457,55 @@ static struct lpc32xx_gpio_chip lpc32xx_ ? ? ?}, ?}; +/* Empty now, can be removed later when mach-lpc32xx is finally switched over +* to DT support +*/ ?void __init lpc32xx_gpio_init(void) ?{ +} + +static int __devinit lpc32xx_gpio_probe (struct platform_device *pdev) +{ + ? ?struct device_node *node; ? ? ?int i; - ? ?for (i = 0; i < ARRAY_SIZE(lpc32xx_gpiochip); i++) - ? ? ? ? ? ?gpiochip_add(&lpc32xx_gpiochip[i].chip); + ? ?if (pdev->dev.of_node) { + ? ? ? ? ? ?for_each_child_of_node(pdev->dev.of_node, node) { + ? ? ? ? ? ? ? ? ? ?if (of_device_is_available(node)) { + ? ? ? ? ? ? ? ? ? ? ? ? ? ?u32 index; + ? ? ? ? ? ? ? ? ? ? ? ? ? ?struct gpio_chip *chip; + ? ? ? ? ? ? ? ? ? ? ? ? ? ?if (of_property_read_u32(node, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "reg", &index) < ?0) + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?continue; + ? ? ? ? ? ? ? ? ? ? ? ? ? ?if (index >= ARRAY_SIZE(lpc32xx_gpiochip)) + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?continue; + ? ? ? ? ? ? ? ? ? ? ? ? ? ?chip = &lpc32xx_gpiochip[index].chip; + ? ? ? ? ? ? ? ? ? ? ? ? ? ?chip->of_node = of_node_get(node); + ? ? ? ? ? ? ? ? ? ? ? ? ? ?gpiochip_add(chip); + ? ? ? ? ? ? ? ? ? ?} + ? ? ? ? ? ?} + ? ?} else { + ? ? ? ? ? ?for (i = 0; i < ARRAY_SIZE(lpc32xx_gpiochip); i++) + ? ? ? ? ? ? ? ? ? ?gpiochip_add(&lpc32xx_gpiochip[i].chip); + ? ?} + + ? ?return 0; ?} + +#ifdef CONFIG_OF +static struct of_device_id lpc32xx_gpio_of_match[]__devinitdata = { + ? ?{ .compatible = "nxp,lpc32xx-gpio", }, + ? ?{ }, +}; +#endif + +static struct platform_driver lpc32xx_gpio_driver = { + ? ?.driver ? ? ? ? = {Quoted 9 lines
drivers/gpio/gpio-lpc32xx.c static struct lpc32xx_gpio_chip lpc32xx_ · line 511
Quoted 8 lines
drivers/gpio/gpio-lpc32xx.c +8
-0+ ? ? ? ? ? ?.name ? = "lpc32xx-gpio", + ? ? ? ? ? ?.owner ?= THIS_MODULE, + ? ? ? ? ? ?.of_match_table = lpc32xx_gpio_of_match, + ? ?}, + ? ?.probe ? ? ? ? ?= lpc32xx_gpio_probe, +}; + +module_platform_driver(lpc32xx_gpio_driver);--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org
More majordomo info at ?http://vger.kernel.org/majordomo-info.html Please read the FAQ at ?http://www.tux.org/lkml/
Signature · 2 lines
Jon Smirl jonsmirl at gmail.com
Quoted 7 lines · jonsmirl at gmail.com
Quoted 6 lines
Please consider how the groups are specified in
drivers/gpio/gpio-lpc32xx.c. They each have different numbers of lines and GPIO / GPI / GPO functionality. So they also have different callback sets, and we need to do separate gpiochip_add()s which leads to the separate gpio-bank specifications in the dtsi file. Separate enabling of those banks via OF are a nice by-product.
Quoted 5 lines
When you have six banks of 32b registers with sparse, active GPIOs in the banks, is there any advantage to saying bank one has 8 gpios, bank 2 has 14, bank 3 has 2, etc in the gpiochip? Or just just register them as six banks of 32 GPIOs without indicating which are valid/invalid?
I think it is a good idea to only register GPIOs that are real when we already have many (~100) instead of registering hundreds of invalid extra ones (that will _always_ be invalid for this very driver).
Also corresponds nicely to the hardware specs when there are banks of odd sizes which can be found registered accordingly in the kernel.
Roland
Quoted 14 lines · Roland Stigge
Quoted 7 lines · jonsmirl at gmail.com
Quoted 6 lines
Please consider how the groups are specified in
drivers/gpio/gpio-lpc32xx.c. They each have different numbers of lines and GPIO / GPI / GPO functionality. So they also have different callback sets, and we need to do separate gpiochip_add()s which leads to the separate gpio-bank specifications in the dtsi file. Separate enabling of those banks via OF are a nice by-product.Quoted 5 lines
When you have six banks of 32b registers with sparse, active GPIOs in the banks, is there any advantage to saying bank one has 8 gpios, bank 2 has 14, bank 3 has 2, etc in the gpiochip? ?Or just just register them as six banks of 32 GPIOs without indicating which are valid/invalid?
Quoted 3 lines
I think it is a good idea to only register GPIOs that are real when we already have many (~100) instead of registering hundreds of invalid extra ones (that will _always_ be invalid for this very driver).
I only want to apply this to identical controller banks. For example the lpc31xx has 12 identical banks of 32 bits. You can program all 384 of these locations identically, but only about 100 locations are actually hooked to real hardware.
We could add something like this to the device tree for gpio-controller:
gpios-valid = <0x1234 0x1234 0x1234 0x1234 0x1234 0x1234 0x1234 0x1234 ...> 12 groups of bits indicating which gpios are valid.
Or we could just ignore the invalid bits. On the lpc31xx they all work, just just don't do anything.
Quoted 3 lines
Also corresponds nicely to the hardware specs when there are banks of odd sizes which can be found registered accordingly in the kernel.
I agree that if the structure of the GPIO banks is irregular they should be different gpiochips.
Quoted 2 lines
Roland
Signature · 2 lines
Jon Smirl jonsmirl at gmail.com