Skip to contentSkip to conversation

gpio: add DT support for memory-mapped GPIOs

PATCH Superseded Christian Lamparter 5 participants 11 messages May 8, 2016 – May 11, 2016

Subsystems (2)

v8 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

v8 cover gpio: add DT support for memory-mapped GPIOs

This patch series adds device tree support for generic memory-mapped GPIOs. The GPIO library already allows drivers and architecture support code to reuse generic code for managing a GPIO chip. Currently, a developer has to create a platform device "basic-mmio-gpio" and attach a bgpio_pdata platform data structure to make use of it. However, for architectures which rely on the device tree to enumerate devices, creating custom platform devices is another extra step that can be avoided by having direct support via a device tree binding.

I initially came across this patch [0] from ?lvaro Fern?ndez Rojas, while looking for an easy way to add support for the GPIO of my WD MyBook Live [1] (APM82181). His generic approach patch allowed me to easily get the GPIO (and the connected LEDs, buttons, gpiohogs) up and running. Even thought, Mr. Fernandez initially developed it for his work on the brcm63xx [2].

The third patch (which can be applied at a later time) moves gpio-clps711x, gpio-ge, gpio-moxart and gpio-ts4800 into gpio-mmio.c. The old driver files and makefile entries have been removed. The Kconfig entries for these drivers are kept for compatibility reasons.

And finally, the most important stat about the series:

	>>> 336 insertions(+), 380 deletions(-) <<<
	It still removes more lines than it adds!

Thanks!

[0] <https://patchwork.ozlabs.org/patch/422121/>
[1] <https://github.com/chunkeey/MBL-openwrt>
[2] <https://wiki.openwrt.org/doc/hardware/soc/soc.broadcom.bcm63xx>

changelog:

v7 -> v8:
- removed ngpio property parser and most flags parsers
- converted clps711x to switch case for GPIO
- retained original Kconfig syms which now select GPIO_GENERIC_PLATFORM

v6 -> v7:
- finally made a PATCH series (based on linux-gpio devel branch)
- added Rob Herring's ACK to the dt bindings
- cc'd clps711x, gpio-ge, moxart and ts4800 authors for driver changes.

v5 -> v6:
- rewrote bindings and driver patch to fit the wd,mbl-gpio
- unified parser code for gpio-ge, gpio-moxart and gpio-ts4800
- fixed gpio chip's base being overwritten with bogus "0"
- fixed compat driver crash when reload gpio-generic.ko module
- dropped already applied patches from the series
- rebased code on linus' devel tree
- moved dt bindings patch to the top of the series

v4 -> v5:
- reverted rename of gpio-mmio.c back to gpio-generic.c
- fixed Andy Shevchenko's comments
- consolidated changes from clps711x, gpio-ge, gpio-moxart and gpio-ts4800 into one patch.

v3 -> v4:
- renamed gpio-generic.c to gpio-mmio.c
- changed compat. string to "linux,gpio-mmio"
- integrated Cirrus clps711x driver
- integrated GE FGPA gpio-ge driver
- integrated MOXA ART GPIO driver
- integrated TS4800 gpio driver
- reshuffled patches, reworded commits, fixed spelling errors, etc.

Christian Lamparter (2):
gpio: dt-bindings: add wd,mbl-gpio bindings
gpio: move clps711x, moxart, ts4800 and gpio-ge into gpio-mmio

?lvaro Fern?ndez Rojas (1):
gpio: mmio: add DT support for memory-mapped GPIOs

 .../devicetree/bindings/gpio/wd,mbl-gpio.txt       |  38 +++
 drivers/gpio/Kconfig                               |  16 +-
 drivers/gpio/Makefile                              |   4 -
 drivers/gpio/gpio-clps711x.c                       |  91 -------
 drivers/gpio/gpio-ge.c                             | 114 --------
 drivers/gpio/gpio-mmio.c                           | 288 ++++++++++++++++++++-
 drivers/gpio/gpio-moxart.c                         |  84 ------
 drivers/gpio/gpio-ts4800.c                         |  81 ------
 8 files changed, 336 insertions(+), 380 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/gpio/wd,mbl-gpio.txt
 delete mode 100644 drivers/gpio/gpio-clps711x.c
 delete mode 100644 drivers/gpio/gpio-ge.c
 delete mode 100644 drivers/gpio/gpio-moxart.c
 delete mode 100644 drivers/gpio/gpio-ts4800.c
Signature · 1 line
2.8.1
#1 lore raw

PATCH v8 1/3 gpio: dt-bindings: add wd,mbl-gpio bindings

This patch adds the device tree bindings for the Western Digital's MyBook Live memory-mapped GPIO controllers.

The gpios will be supported by gpio-mmio code of the GPIO generic library.

---
 .../devicetree/bindings/gpio/wd,mbl-gpio.txt       | 38 ++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/wd,mbl-gpio.txt
Documentation/devicetree/bindings/gpio/wd,mbl-gpio.txt new file +38 -0
new file mode 100644
index 0000000..038c3a6
@@ -0,0 +1,38 @@
+Bindings for the Western Digital's MyBook Live memory-mapped GPIO controllers.
+
+The Western Digital MyBook Live has two memory-mapped GPIO controllers.
+Both GPIO controller only have a single 8-bit data register, where GPIO
+state can be read and/or written.
+
+Required properties:
+	- compatible: should be "wd,mbl-gpio"
+	- reg-names: must contain
+		"dat" - data register
+	- reg: address + size pairs describing the GPIO register sets;
+		order must correspond with the order of entries in reg-names
+	- #gpio-cells: must be set to 2. The first cell is the pin number and
+			the second cell is used to specify the gpio polarity:
+			0 = active high
+			1 = active low
+	- gpio-controller: Marks the device node as a gpio controller.
+
+Optional properties:
+	- no-output: GPIOs are read-only.
+
+Examples:
+	gpio0: gpio0 at e0000000 {
+		compatible = "wd,mbl-gpio";
+		reg-names = "dat";
+		reg = <0xe0000000 0x1>;
+		#gpio-cells = <2>;
+		gpio-controller;
+	};
+
+	gpio1: gpio1 at e0100000 {
+		compatible = "wd,mbl-gpio";
+		reg-names = "dat";
+		reg = <0xe0100000 0x1>;
+		#gpio-cells = <2>;
+		gpio-controller;
+		no-output;
+	};
Signature · 1 line
2.8.1
#2 lore raw

Re: [PATCH v8 1/3] gpio: dt-bindings: add wd,mbl-gpio bindings

Quoted 8 lines · Christian Lamparter

This patch adds the device tree bindings for the Western Digital's MyBook Live memory-mapped GPIO controllers.

The gpios will be supported by gpio-mmio code of the GPIO generic library.

Looks OK to me and Rob has ACKed so patch applied.

Yours,
Linus Walleij

#3 lore raw

PATCH v8 2/3 gpio: mmio: add DT support for memory-mapped GPIOs

In reply to Christian Lamparter

From: ?lvaro Fern?ndez Rojas <[email protected]>

This patch adds support for defining memory-mapped GPIOs which are compatible with the existing gpio-mmio interface. The generic library provides support for many memory-mapped GPIO controllers that are found in various on-board FPGA and ASIC solutions that are used to control board's switches, LEDs, chip-selects, Ethernet/USB PHY power, etc.

For setting GPIO's there are three configurations:
1. single input/output register resource (named "dat"),
2. set/clear pair (named "set" and "clr"),
3. single output register resource and single input resource ("set" and dat").

The configuration is detected by which resources are present. For the single output register, this drives a 1 by setting a bit and a zero by clearing a bit. For the set clr pair, this drives a 1 by setting a bit in the set register and clears it by setting a bit in the clear register. The configuration is detected by which resources are present.

For setting the GPIO direction, there are three configurations:
a. simple bidirectional GPIOs that requires no configuration. b. an output direction register (named "dirout")
where a 1 bit indicates the GPIO is an output.
c. an input direction register (named "dirin")
where a 1 bit indicates the GPIO is an input.

The first user for this binding is "wd,mbl-gpio".

---
 drivers/gpio/gpio-mmio.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 74 insertions(+), 2 deletions(-)
drivers/gpio/gpio-mmio.c +74 -2
index 6c1cb3b..4b7b74c 100644
@@ -61,6 +61,8 @@ o        `                     ~~~~\___/~~~~    ` controller in FPGA is ,.`
 #include <linux/bitops.h>
 #include <linux/platform_device.h>
 #include <linux/mod_devicetable.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
 
 static void bgpio_write8(void __iomem *reg, unsigned long data)
 {
@@ -569,6 +571,66 @@ static void __iomem *bgpio_map(struct platform_device *pdev,
 	return devm_ioremap_resource(&pdev->dev, r);
 }
 
+#ifdef CONFIG_OF
+static int bgpio_basic_mmio_parse_dt(struct platform_device *pdev,
+				     struct bgpio_pdata *pdata,
+				     unsigned long *flags)
+{
+	struct device *dev = &pdev->dev;
+	int err;
+
+	pdata->base = -1;
+
+	if (of_property_read_bool(dev->of_node, "no-output"))
+		*flags |= BGPIOF_NO_OUTPUT;
+
+	return 0;
+}
+
+#define ADD(_name, _func) { .compatible = _name, .data = _func }
+
+static const struct of_device_id bgpio_of_match[] = {
+	ADD("wd,mbl-gpio", bgpio_basic_mmio_parse_dt),
+	{ }
+};
+#undef ADD
+MODULE_DEVICE_TABLE(of, bgpio_of_match);
+
+static struct bgpio_pdata *bgpio_parse_dt(struct platform_device *pdev,
+					  unsigned long *flags)
+{
+	const int (*parse_dt)(struct platform_device *,
+			      struct bgpio_pdata *, unsigned long *);
+	const struct device_node *node = pdev->dev.of_node;
+	const struct of_device_id *of_id;
+	struct bgpio_pdata *pdata;
+	int err = -ENODEV;
+
+	of_id = of_match_node(bgpio_of_match, node);
+	if (!of_id)
+		return NULL;
+
+	pdata = devm_kzalloc(&pdev->dev, sizeof(struct bgpio_pdata),
+			     GFP_KERNEL);
+	if (!pdata)
+		return ERR_PTR(-ENOMEM);
+
+	parse_dt = (const void *)of_id->data;
+	if (parse_dt)
+		err = parse_dt(pdev, pdata, flags);
+	if (err)
+		return ERR_PTR(err);
+
+	return pdata;
+}
+#else
+static struct bgpio_pdata *bgpio_parse_dt(struct platform_device *pdev,
+					  unsigned long *flags)
+{
+	return NULL;
+}
+#endif /* CONFIG_OF */
+
 static int bgpio_pdev_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -579,10 +641,19 @@ static int bgpio_pdev_probe(struct platform_device *pdev)
 	void __iomem *dirout;
 	void __iomem *dirin;
 	unsigned long sz;
-	unsigned long flags = pdev->id_entry->driver_data;
+	unsigned long flags = 0;
 	int err;
 	struct gpio_chip *gc;
-	struct bgpio_pdata *pdata = dev_get_platdata(dev);
+	struct bgpio_pdata *pdata;
+
+	pdata = bgpio_parse_dt(pdev, &flags);
+	if (IS_ERR(pdata))
+		return PTR_ERR(pdata);
+
+	if (!pdata) {
+		pdata = dev_get_platdata(dev);
+		flags = pdev->id_entry->driver_data;
+	}
 
 	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dat");
 	if (!r)
@@ -646,6 +717,7 @@ MODULE_DEVICE_TABLE(platform, bgpio_id_table);
 static struct platform_driver bgpio_driver = {
 	.driver = {
 		.name = "basic-mmio-gpio",
+		.of_match_table = of_match_ptr(bgpio_of_match),
 	},
 	.id_table = bgpio_id_table,
 	.probe = bgpio_pdev_probe,
Signature · 1 line
2.8.1
#4 lore raw

Re: [PATCH v8 2/3] gpio: mmio: add DT support for memory-mapped GPIOs

Hi Christian,

Quoted 29 lines · Christian Lamparter

From: ?lvaro Fern?ndez Rojas <[email protected]>

This patch adds support for defining memory-mapped GPIOs which are compatible with the existing gpio-mmio interface. The generic library provides support for many memory-mapped GPIO controllers that are found in various on-board FPGA and ASIC solutions that are used to control board's switches, LEDs, chip-selects, Ethernet/USB PHY power, etc.

For setting GPIO's there are three configurations:
1. single input/output register resource (named "dat"),
2. set/clear pair (named "set" and "clr"),
3. single output register resource and single input resource ("set" and dat").

The configuration is detected by which resources are present. For the single output register, this drives a 1 by setting a bit and a zero by clearing a bit. For the set clr pair, this drives a 1 by setting a bit in the set register and clears it by setting a bit in the clear register. The configuration is detected by which resources are present.

For setting the GPIO direction, there are three configurations:
a. simple bidirectional GPIOs that requires no configuration. b. an output direction register (named "dirout")
where a 1 bit indicates the GPIO is an output.
c. an input direction register (named "dirin")
where a 1 bit indicates the GPIO is an input.

Quoted 7 lines

The first user for this binding is "wd,mbl-gpio".

---

+#define ADD(_name, _func) { .compatible = _name, .data = _func }

I don't see the point in having a macro for such a simple data structure, but since this v8 and Linus hasn't complained I guess it's fine.

Using a macro here makes it impossible to grep for 'compatible'. Doing 'git grep compatible drivers/gpio/' is sometimes very useful to see which hardware the driver actually supports.

Quoted 17 lines
drivers/gpio/gpio-mmio.c +17 -0
+static const struct of_device_id bgpio_of_match[] = {
+       ADD("wd,mbl-gpio", bgpio_basic_mmio_parse_dt),
+       { }
+};
+#undef ADD
+MODULE_DEVICE_TABLE(of, bgpio_of_match);
+
+static struct bgpio_pdata *bgpio_parse_dt(struct platform_device *pdev,
+                                         unsigned long *flags)
+{
+       const int (*parse_dt)(struct platform_device *,
+                             struct bgpio_pdata *, unsigned long *);
+       const struct device_node *node = pdev->dev.of_node;
+       const struct of_device_id *of_id;
+       struct bgpio_pdata *pdata;
+       int err = -ENODEV;
+

drivers/gpio/gpio-mmio.c static void __iomem *bgpio_map(struct platform_device *pdev, · line 618

Quoted 10 lines
drivers/gpio/gpio-mmio.c +10 -0
+       of_id = of_match_node(bgpio_of_match, node);
+       if (!of_id)
+               return NULL;
+
+       pdata = devm_kzalloc(&pdev->dev, sizeof(struct bgpio_pdata),
+                            GFP_KERNEL);
+       if (!pdata)
+               return ERR_PTR(-ENOMEM);
+
+       parse_dt = (const void *)of_id->data;

You can retrieve OF match data using of_device_get_match_data(). Saves you a couple of lines and better explains what your doing.

drivers/gpio/gpio-mmio.c static void __iomem *bgpio_map(struct platform_device *pdev, · line 625

Quoted 7 lines
drivers/gpio/gpio-mmio.c +7 -0
+       if (parse_dt)
+               err = parse_dt(pdev, pdata, flags);
+       if (err)
+               return ERR_PTR(err);
+
+       return pdata;
+}

regards,
Joachim Eastwood

#5 lore raw

Re: [PATCH v8 2/3] gpio: mmio: add DT support for memory-mapped GPIOs

Quoted 9 lines · Joachim Eastwood
Quoted 1 line

+#define ADD(_name, _func) { .compatible = _name, .data = _func }

I don't see the point in having a macro for such a simple data structure, but since this v8 and Linus hasn't complained I guess it's fine.

Using a macro here makes it impossible to grep for 'compatible'. Doing 'git grep compatible drivers/gpio/' is sometimes very useful to see which hardware the driver actually supports.

Ok. I'll definitely picking it up. I'll wait until Tuesday/Wednesday for more comments and then release a new series.

Quoted 10 lines
Quoted 10 lines
drivers/gpio/gpio-mmio.c +10 -0
+static const struct of_device_id bgpio_of_match[] = {
+       ADD("wd,mbl-gpio", bgpio_basic_mmio_parse_dt),
+       { }
+};
+#undef ADD
+MODULE_DEVICE_TABLE(of, bgpio_of_match);
+
+static struct bgpio_pdata *bgpio_parse_dt(struct platform_device *pdev,
+                                         unsigned long *flags)
+{

[...]

Quoted 3 lines
Quoted 3 lines
drivers/gpio/gpio-mmio.c +3 -0
+       of_id = of_match_node(bgpio_of_match, node);
+       if (!of_id)
+               return NULL;

[...]

Quoted 2 lines

You can retrieve OF match data using of_device_get_match_data(). Saves you a couple of lines and better explains what your doing.

Yes thanks that's useful too since I don't need the of_id variable anymore.

Both improvements save a total of 8 lines. so it's 328 insertions(+) vs 380 deletions(-).

Regards,
Christian

#6 lore raw

Re: [PATCH v8 2/3] gpio: mmio: add DT support for memory-mapped GPIOs

In reply to Christian Lamparter
Quoted 4 lines · Christian Lamparter

From: ?lvaro Fern?ndez Rojas <[email protected]>

This patch adds support for defining memory-mapped GPIOs which are compatible with the existing gpio-mmio interface.

Overall very nice, just waiting for the next version.

Quoted 1 line

The first user for this binding is "wd,mbl-gpio".

And that binding defines that we have a register named "dat".

Quoted 1 line

+ if (of_property_read_bool(dev->of_node, "no-output"))

And then this too.

Do we want these generic MMIO bindings (dat, no-output) in a special document like Documentation/devicetree/bindings/gpio/gpio-mmio.txt?

Going forward?

This patch set mainly deals with refactorings, but in the long run we want to slim things down a bit and use standard bindings I think.

Yours,
Linus Walleij

#7 lore raw

Re: [PATCH v8 2/3] gpio: mmio: add DT support for memory-mapped GPIOs

Quoted 9 lines · Linus Walleij
Quoted 4 lines · Christian Lamparter

From: ?lvaro Fern?ndez Rojas <[email protected]>

This patch adds support for defining memory-mapped GPIOs which are compatible with the existing gpio-mmio interface.

Overall very nice, just waiting for the next version.

K, will deliver. I noticed that you sent a mail in which you stated that you applied the dt binding already. Can you update your devel branch on git.kernel.org's linux-gpio? Then, I'll simply rebase my series and sent the remaining two patches.
(unless you tell me otherwise).

Quoted 3 lines
Quoted 1 line

The first user for this binding is "wd,mbl-gpio".

And that binding defines that we have a register named "dat".

Yeah, I had to remove all non wd related bits. But since this series was posted (over and over :D) on a public mailing-list the original "generic" linux-mmio binding is available for everybody to perusal[0] and study. I think what we can make would be something like a devicetree template out of it. This way people can remove unused flags and regnames for their compatible device tree binding. (But first: need to finish that ppc-gpio.txt).

Quoted 9 lines
Quoted 1 line

+ if (of_property_read_bool(dev->of_node, "no-output"))

And then this too.

Do we want these generic MMIO bindings (dat, no-output) in a special document like Documentation/devicetree/bindings/gpio/gpio-mmio.txt?

Going forward?

Ah, I was thinking about Documentation/gpio... Since there's no way it would go in the devicetree/bindings without having a compatible? (And there's technically none). As far as I know the problem here is not that it would be impossible to do that (updating a .dts file is "easy"...), but updating .dtb to a tiny flash-rom on the device might not be. So we have to make every effort to preserve compatibility for those devices (and old/incomplete/broken dtbs) as long as the device is supported.

About adding new device:
This will work in the following way:
1. new drives will need to supply their hardware-specific devicetree binding file to the dt maintainers (This "vendor,device.txt" file will be like the wd,mbl-gpio.txt - but modified for the hardware (this is where the template would be handy)

2. Make a one-liner patch which adds a compatible string to gpio-mmio.c's bgpio_of_match table:

+ { .compatible = "vendor,device", .data = bgpio_basic_mmio_parse_dt },

(Of course, not having parses for the "ngpio" property and the flags like big-endian, reg-output-reg,set, unreadable-reg-dir, ... properties from the get-go is sad, these can add back once a driver/binding needs it).

I think brcm63xx will be following shortly. So we can test the procedure.

Quoted 3 lines

This patch set mainly deals with refactorings, but in the long run we want to slim things down a bit and use standard bindings I think.

Well, to do that, I think we need to collect enough devices to make it a real "class" of devices first.

Regards,
Christian

[0] <https://lkml.org/lkml/2016/4/28/921>

#8 lore raw

Re: [PATCH v8 2/3] gpio: mmio: add DT support for memory-mapped GPIOs

Hello everyone,

First of all thanks Christian for persisting in adding generic device tree support for memory-mapped gpios.

For the brcm63xx case we could probably do something like this:
https://gist.github.com/Noltari/fd34aedafd427d25467697ec6799d15a
Notice that I'm doing something similar to what's already done for non device tree with basic-mmio-gpio vs basic-mmio-gpio-be:
https://github.com/torvalds/linux/blob/master/drivers/gpio/gpio-generic.c#L634

P.S: excuse me for not using an interleaved reply, but I'm sending this from my phone :)

Regards,
Álvaro.

Quoted 75 lines · El 10 may 2016 21:55 +0200, Christian Lamparter<[email protected]>…
Quoted 9 lines · Linus Walleij
Quoted 4 lines · Christian Lamparter

From: Álvaro Fernández Rojas<[email protected]

This patch adds support for defining memory-mapped GPIOs which are compatible with the existing gpio-mmio interface.

Overall very nice, just waiting for the next version.

K, will deliver. I noticed that you sent a mail in which you stated that you applied the dt binding already. Can you update your devel branch on git.kernel.org's linux-gpio? Then, I'll simply rebase my series and sent the remaining two patches.
(unless you tell me otherwise).

Quoted 3 lines
Quoted 1 line

The first user for this binding is "wd,mbl-gpio".

And that binding defines that we have a register named "dat".

Yeah, I had to remove all non wd related bits. But since this series was posted (over and over :D) on a public mailing-list the original "generic" linux-mmio binding is available for everybody to perusal[0] and study. I think what we can make would be something like a devicetree template out of it. This way people can remove unused flags and regnames for their compatible device tree binding. (But first: need to finish that ppc-gpio.txt).

Quoted 9 lines
Quoted 1 line

+ if (of_property_read_bool(dev->of_node, "no-output"))

And then this too.

Do we want these generic MMIO bindings (dat, no-output) in a special document like Documentation/devicetree/bindings/gpio/gpio-mmio.txt?

Going forward?

Ah, I was thinking about Documentation/gpio... Since there's no way it would go in the devicetree/bindings without having a compatible? (And there's technically none). As far as I know the problem here is not that it would be impossible to do that (updating a .dts file is "easy"...), but updating .dtb to a tiny flash-rom on the device might not be. So we have to make every effort to preserve compatibility for those devices (and old/incomplete/broken dtbs) as long as the device is supported.

About adding new device:
This will work in the following way:
1. new drives will need to supply their hardware-specific devicetree binding file to the dt maintainers (This "vendor,device.txt" file will be like the wd,mbl-gpio.txt - but modified for the hardware (this is where the template would be handy)

2. Make a one-liner patch which adds a compatible string to gpio-mmio.c's bgpio_of_match table:

+ { .compatible = "vendor,device", .data = bgpio_basic_mmio_parse_dt },

(Of course, not having parses for the "ngpio" property and the flags like big-endian, reg-output-reg,set, unreadable-reg-dir, ... properties from the get-go is sad, these can add back once a driver/binding needs it).

I think brcm63xx will be following shortly. So we can test the procedure.

Quoted 3 lines

This patch set mainly deals with refactorings, but in the long run we want to slim things down a bit and use standard bindings I think.

Well, to do that, I think we need to collect enough devices to make it a real "class" of devices first.

Regards,
Christian

[0]<https://lkml.org/lkml/2016/4/28/921

#9 lore raw

PATCH v8 3/3 gpio: move clps711x, moxart, ts4800 and gpio-ge into gpio-mmio

In reply to Christian Lamparter

This patch integrates the GPIO drivers for the following boards, SoCs, etc. into gpio-mmio:
- CLPS711X SoCs
- MOXA ART SoC
- TS-4800 FPGA DIO blocks and compatibles
- GPIO controllers found on some GE Single Board Computers

Cc Alexander Shiyan <[email protected]>
Cc Julien Grossholtz <[email protected]>
Cc Martyn Welch <[email protected]>
Cc Jonas Jensen <[email protected]>
---
 drivers/gpio/Kconfig         |  16 +++-
 drivers/gpio/Makefile        |   4 -
 drivers/gpio/gpio-clps711x.c |  91 -------------------
 drivers/gpio/gpio-ge.c       | 114 -----------------------
 drivers/gpio/gpio-mmio.c     | 212 +++++++++++++++++++++++++++++++++++++++++++
 drivers/gpio/gpio-moxart.c   |  84 -----------------
 drivers/gpio/gpio-ts4800.c   |  81 -----------------
 7 files changed, 224 insertions(+), 378 deletions(-)
 delete mode 100644 drivers/gpio/gpio-clps711x.c
 delete mode 100644 drivers/gpio/gpio-ge.c
 delete mode 100644 drivers/gpio/gpio-moxart.c
 delete mode 100644 drivers/gpio/gpio-ts4800.c
drivers/gpio/Kconfig +12 -4
index a68d838..e4d1065 100644
@@ -154,7 +154,7 @@ config GPIO_BRCMSTB
 config GPIO_CLPS711X
 	tristate "CLPS711X GPIO support"
 	depends on ARCH_CLPS711X || COMPILE_TEST
-	select GPIO_GENERIC
+	select GPIO_GENERIC_PLATFORM
 	help
 	  Say yes here to support GPIO on CLPS711X SoCs.
 
@@ -196,7 +196,7 @@ config GPIO_ETRAXFS
 config GPIO_GE_FPGA
 	bool "GE FPGA based GPIO"
 	depends on GE_FPGA
-	select GPIO_GENERIC
+	select GPIO_GENERIC_PLATFORM
 	help
 	  Support for common GPIO functionality provided on some GE Single Board
 	  Computers.
@@ -209,6 +209,14 @@ config GPIO_GENERIC_PLATFORM
 	tristate "Generic memory-mapped GPIO controller support (MMIO platform device)"
 	select GPIO_GENERIC
 	help
+	  Select this to support many generic memory-mapped GPIO controllers.
+
+	  This driver also includes support for the following GPIOs:
+	    CLPS711X SoCs
+	    MOXA ART SoC
+	    TS-4800 FPGA DIO blocks and compatibles.
+	    GPIOs found on some GE Single Board Computers.
+
 	  Say yes here to support basic platform_device memory-mapped GPIO controllers.
 
 config GPIO_GRGPIO
@@ -288,7 +296,7 @@ config GPIO_MM_LANTIQ
 config GPIO_MOXART
 	bool "MOXART GPIO support"
 	depends on ARCH_MOXART || COMPILE_TEST
-	select GPIO_GENERIC
+	select GPIO_GENERIC_PLATFORM
 	help
 	  Select this option to enable GPIO driver for
 	  MOXA ART SoC devices.
@@ -408,7 +416,7 @@ config GPIO_TS4800
 	tristate "TS-4800 DIO blocks and compatibles"
 	depends on OF_GPIO
 	depends on SOC_IMX51 || COMPILE_TEST
-	select GPIO_GENERIC
+	select GPIO_GENERIC_PLATFORM
 	help
 	  This driver support TS-4800 FPGA GPIO controllers.
 
drivers/gpio/Makefile +0 -4
index 991598e..d8d63ae 100644
@@ -31,7 +31,6 @@ obj-$(CONFIG_GPIO_ATH79)	+= gpio-ath79.o
 obj-$(CONFIG_GPIO_BCM_KONA)	+= gpio-bcm-kona.o
 obj-$(CONFIG_GPIO_BRCMSTB)	+= gpio-brcmstb.o
 obj-$(CONFIG_GPIO_BT8XX)	+= gpio-bt8xx.o
-obj-$(CONFIG_GPIO_CLPS711X)	+= gpio-clps711x.o
 obj-$(CONFIG_GPIO_CS5535)	+= gpio-cs5535.o
 obj-$(CONFIG_GPIO_CRYSTAL_COVE)	+= gpio-crystalcove.o
 obj-$(CONFIG_GPIO_DA9052)	+= gpio-da9052.o
@@ -43,7 +42,6 @@ obj-$(CONFIG_GPIO_EM)		+= gpio-em.o
 obj-$(CONFIG_GPIO_EP93XX)	+= gpio-ep93xx.o
 obj-$(CONFIG_GPIO_ETRAXFS)	+= gpio-etraxfs.o
 obj-$(CONFIG_GPIO_F7188X)	+= gpio-f7188x.o
-obj-$(CONFIG_GPIO_GE_FPGA)	+= gpio-ge.o
 obj-$(CONFIG_GPIO_GRGPIO)	+= gpio-grgpio.o
 obj-$(CONFIG_GPIO_ICH)		+= gpio-ich.o
 obj-$(CONFIG_GPIO_IOP)		+= gpio-iop.o
@@ -68,7 +66,6 @@ obj-$(CONFIG_GPIO_MC9S08DZ60)	+= gpio-mc9s08dz60.o
 obj-$(CONFIG_GPIO_MCP23S08)	+= gpio-mcp23s08.o
 obj-$(CONFIG_GPIO_ML_IOH)	+= gpio-ml-ioh.o
 obj-$(CONFIG_GPIO_MM_LANTIQ)	+= gpio-mm-lantiq.o
-obj-$(CONFIG_GPIO_MOXART)	+= gpio-moxart.o
 obj-$(CONFIG_GPIO_MPC5200)	+= gpio-mpc5200.o
 obj-$(CONFIG_GPIO_MPC8XXX)	+= gpio-mpc8xxx.o
 obj-$(CONFIG_GPIO_MSIC)		+= gpio-msic.o
@@ -107,7 +104,6 @@ obj-$(CONFIG_GPIO_TPS65218)	+= gpio-tps65218.o
 obj-$(CONFIG_GPIO_TPS6586X)	+= gpio-tps6586x.o
 obj-$(CONFIG_GPIO_TPS65910)	+= gpio-tps65910.o
 obj-$(CONFIG_GPIO_TPS65912)	+= gpio-tps65912.o
-obj-$(CONFIG_GPIO_TS4800)	+= gpio-ts4800.o
 obj-$(CONFIG_GPIO_TS5500)	+= gpio-ts5500.o
 obj-$(CONFIG_GPIO_TWL4030)	+= gpio-twl4030.o
 obj-$(CONFIG_GPIO_TWL6040)	+= gpio-twl6040.o
drivers/gpio/gpio-clps711x.c deleted +0 -91

91 lines not on this page · raw message

drivers/gpio/gpio-ge.c deleted +0 -114

114 lines not on this page · raw message

drivers/gpio/gpio-mmio.c +212 -0

222 lines not on this page · raw message

drivers/gpio/gpio-moxart.c deleted +0 -84

84 lines not on this page · raw message

drivers/gpio/gpio-ts4800.c deleted +0 -81

81 lines not on this page · raw message

Signature · 1 line
2.8.1
Reviewed-by on the v8 series
#10 lore raw
In reply to Christian Lamparter
Quoted 25 lines · Christian Lamparter

This patch series adds device tree support for generic memory-mapped GPIOs. The GPIO library already allows drivers and architecture support code to reuse generic code for managing a GPIO chip. Currently, a developer has to create a platform device "basic-mmio-gpio" and attach a bgpio_pdata platform data structure to make use of it. However, for architectures which rely on the device tree to enumerate devices, creating custom platform devices is another extra step that can be avoided by having direct support via a device tree binding.

I initially came across this patch [0] from ?lvaro Fern?ndez Rojas, while looking for an easy way to add support for the GPIO of my WD MyBook Live [1] (APM82181). His generic approach patch allowed me to easily get the GPIO (and the connected LEDs, buttons, gpiohogs) up and running. Even thought, Mr. Fernandez initially developed it for his work on the brcm63xx [2].

The third patch (which can be applied at a later time) moves gpio-clps711x, gpio-ge, gpio-moxart and gpio-ts4800 into gpio-mmio.c. The old driver files and makefile entries have been removed. The Kconfig entries for these drivers are kept for compatibility reasons.

And finally, the most important stat about the series:
>>> 336 insertions(+), 380 deletions(-) <<< It still removes more lines than it adds!

Quoted 6 lines

Thanks!

[0] <https://patchwork.ozlabs.org/patch/422121/>
[1] <https://github.com/chunkeey/MBL-openwrt>
[2] <https://wiki.openwrt.org/doc/hardware/soc/soc.broadcom.bcm63xx>

FWIW:

Quoted 62 lines

changelog:

v7 -> v8:
- removed ngpio property parser and most flags parsers
- converted clps711x to switch case for GPIO
- retained original Kconfig syms which now select GPIO_GENERIC_PLATFORM

v6 -> v7:
- finally made a PATCH series (based on linux-gpio devel branch)
- added Rob Herring's ACK to the dt bindings
- cc'd clps711x, gpio-ge, moxart and ts4800 authors for driver changes.

v5 -> v6:
- rewrote bindings and driver patch to fit the wd,mbl-gpio
- unified parser code for gpio-ge, gpio-moxart and gpio-ts4800
- fixed gpio chip's base being overwritten with bogus "0"
- fixed compat driver crash when reload gpio-generic.ko module
- dropped already applied patches from the series
- rebased code on linus' devel tree
- moved dt bindings patch to the top of the series

v4 -> v5:
- reverted rename of gpio-mmio.c back to gpio-generic.c
- fixed Andy Shevchenko's comments
- consolidated changes from clps711x, gpio-ge, gpio-moxart and gpio-ts4800 into one patch.

v3 -> v4:
- renamed gpio-generic.c to gpio-mmio.c
- changed compat. string to "linux,gpio-mmio"
- integrated Cirrus clps711x driver
- integrated GE FGPA gpio-ge driver
- integrated MOXA ART GPIO driver
- integrated TS4800 gpio driver
- reshuffled patches, reworded commits, fixed spelling errors, etc.

Christian Lamparter (2):
gpio: dt-bindings: add wd,mbl-gpio bindings
gpio: move clps711x, moxart, ts4800 and gpio-ge into gpio-mmio

?lvaro Fern?ndez Rojas (1):
gpio: mmio: add DT support for memory-mapped GPIOs

 .../devicetree/bindings/gpio/wd,mbl-gpio.txt       |  38 +++
 drivers/gpio/Kconfig                               |  16 +-
 drivers/gpio/Makefile                              |   4 -
 drivers/gpio/gpio-clps711x.c                       |  91 -------
 drivers/gpio/gpio-ge.c                             | 114 --------
 drivers/gpio/gpio-mmio.c                           | 288 ++++++++++++++++++++-
 drivers/gpio/gpio-moxart.c                         |  84 ------
 drivers/gpio/gpio-ts4800.c                         |  81 ------
 8 files changed, 336 insertions(+), 380 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/gpio/wd,mbl-gpio.txt
 delete mode 100644 drivers/gpio/gpio-clps711x.c
 delete mode 100644 drivers/gpio/gpio-ge.c
 delete mode 100644 drivers/gpio/gpio-moxart.c
 delete mode 100644 drivers/gpio/gpio-ts4800.c

--
2.8.1

Signature · 2 lines
With Best Regards,
Andy Shevchenko