gpio: add DT support for generic memory-mapped GPIOs
Subsystems (2)
v4 cover gpio: add DT support for generic 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 - ppc464). This generic approach patch allowed me to easily get the GPIO (and the connected LEDs, buttons, gpiohogs, etc.) up and running. Even tought, Mr. Fernandez initially developed it for his work on the brcm63xx [2].
[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>
Currently, the device tree parses for the integrated drivers (gpio-clps711x, gpio-ge, gpio-moxart and gpio-ts4800) are still residing in their original driver .c file. This way, these drivers don't clutter the gpio-generic.c with their own hardware definitions and MODULE_* statements. I hoped this would make the transition from the _probe to the parser less painless but the diff is retty much unreadable. So the next series will consolidate them into gpio-generic.c and then I can drop the gpio-generic -> gpio-mmio change. I think this is now mostly a matter of how to organize things and why not try it just once just so it was tested.
changelog:
v3 -> v4:
- renamed gpio-generic.c to gpio-mmio.c
(The gpio-generic only contains a generic mmio driver, this confuses and angers people!)
- 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.
Thanks! (Please keep me in the CC)
---
Christian Lamparter (6):
gpio: generic: fix GPIO_GENERIC_PLATFORM is set to module case
gpio: rename gpio-generic.c into gpio-mmio.c
gpio: clps711x: integrate cirrus clps711x into gpio-mmio
gpio: ge: integrate GE's FPGA GPIO into gpio-mmio
gpio: moxart: integrate MOXA ART GPIO driver into gpio-mmio
gpio: ts4800: integrate TS4800 into gpio-mmio
?lvaro Fern?ndez Rojas (2):
gpio: generic: add DT support for generic memory-mapped GPIOs
gpio: dt-bindings: add gpio-mmio bindings
.../devicetree/bindings/gpio/gpio-mmio.txt | 73 +++++++++++++++
drivers/gpio/Kconfig | 57 ++++++------
drivers/gpio/Makefile | 11 ++-
drivers/gpio/gpio-clps711x.c | 84 ++++++-----------
drivers/gpio/gpio-ge.c | 101 ++++++---------------
drivers/gpio/gpio-mmio-compat.h | 65 +++++++++++++
drivers/gpio/{gpio-generic.c => gpio-mmio.c} | 101 ++++++++++++++++++++-
drivers/gpio/gpio-moxart.c | 81 +++++------------
drivers/gpio/gpio-ts4800.c | 76 +++++-----------
9 files changed, 376 insertions(+), 273 deletions(-)
create mode 100644 Documentation/devicetree/bindings/gpio/gpio-mmio.txt
create mode 100644 drivers/gpio/gpio-mmio-compat.h
rename drivers/gpio/{gpio-generic.c => gpio-mmio.c} (86%)Signature · 1 line
2.8.1
RFC v4 1/8 gpio: generic: fix GPIO_GENERIC_PLATFORM is set to module case
GPIO_GENERIC_PLATFORM is a tristate. If the module option is selected the resulting gpio-generic.ko will lack most of the module initialzation and probe code.
--- drivers/gpio/gpio-generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-generic.c +1 -1
@@ -549,7 +549,7 @@ int bgpio_init(struct gpio_chip *gc, struct device *dev, }EXPORT_SYMBOL_GPL (bgpio_init); -#ifdef CONFIG_GPIO_GENERIC_PLATFORM +#if IS_ENABLED (CONFIG_GPIO_GENERIC_PLATFORM ) static void __iomem *bgpio_map(struct platform_device *pdev, const char *name,
Signature · 1 line
2.8.1
RFC v4 2/8 gpio: rename gpio-generic.c into gpio-mmio.c
In reply to Christian LamparterThis patch renames the gpio-generic.c into gpio-mmio.c. This is because currently the file only contains code for a memory-mapped GPIO driver. There isn't any support for ioports or other resource type.
---
drivers/gpio/Makefile | 3 +++
drivers/gpio/{gpio-generic.c => gpio-mmio.c} | 0
2 files changed, 3 insertions(+)
rename drivers/gpio/{gpio-generic.c => gpio-mmio.c} (100%)drivers/gpio/Makefile +3 -0
@@ -12,6 +12,9 @@ obj-$(CONFIG_GPIO_ACPI) += gpiolib-acpi.o # Device drivers. Generally keep list sorted alphabetically obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o +# directly supported by gpio-generic +gpio-generic-$(CONFIG_GPIO_GENERIC) += gpio-mmio.o + obj-$(CONFIG_GPIO_104_DIO_48E) += gpio-104-dio-48e.o obj-$(CONFIG_GPIO_104_IDIO_16) += gpio-104-idio-16.o obj-$(CONFIG_GPIO_104_IDI_48) += gpio-104-idi-48.o
drivers/gpio/gpio-mmio.c renamed from drivers/gpio/gpio-generic.c +0 -0
Signature · 1 line
2.8.1
Re: [RFC v4 2/8] gpio: rename gpio-generic.c into gpio-mmio.c
Quoted 6 lines · Christian Lamparter
This patch renames the
gpio-generic.cintogpio-mmio.c. This is because currently the file only contains code for a memory-mapped GPIO driver. There isn't any support for ioports or other resource type.Signed-off-by Christian Lamparter <[email protected]>
Makes perfect sense.
Patch applied.
Yours,
Linus Walleij
RFC v4 3/8 gpio: generic: add DT support for generic memory-mapped GPIOs
In reply to Christian LamparterFrom: ?lvaro Fern?ndez Rojas <[email protected]>
This patch adds support for defining memory-mapped GPIOs which provide a compatible interface for the existing generic-gpio driver.
--- drivers/gpio/Kconfig | 3 ++ drivers/gpio/gpio-mmio-compat.h | 17 ++++++++ drivers/gpio/gpio-mmio.c | 95 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 drivers/gpio/gpio-mmio-compat.h
drivers/gpio/Kconfig +3 -0
@@ -212,6 +212,9 @@ config GPIO_GENERIC_PLATFORM help Say yes here to support basic platform_device memory-mapped GPIO controllers. +if GPIO_GENERIC_PLATFORM +endif + config GPIO_GRGPIO tristate "Aeroflex Gaisler GRGPIO support" depends on OF
drivers/gpio/gpio-mmio-compat.h new file +17 -0
@@ -0,0 +1,17 @@ +#ifndef GPIO_MMIO_COMPAT_H +#define GPIO_MMIO_COMPAT_H + +#include <linux/ioport.h> + +#define ADD (_name, _func) { .compatible = _name, .data = _func } + +#undef ADD + +static inline void set_resource_address (struct resource *res, +resource_size_t start, +resource_size_t len) +{ + res->start = start; + res->end = start + len -1 ; +} +#endif /* GPIO_MMIO_COMPAT_H */
drivers/gpio/gpio-mmio.c +93 -2
121 lines not on this page · raw message
Signature · 1 line
2.8.1
Re: [RFC v4 3/8] gpio: generic: add DT support for generic memory-mapped GPIOs
drivers/gpio/gpio-mmio-compat.h line 16
Quoted 13 lines · Christian Lamparter
From: ?lvaro Fern?ndez Rojas <[email protected]>
This patch adds support for defining memory-mapped GPIOs which provide a compatible interface for the existing generic-gpio driver.
drivers/gpio/gpio-mmio-compat.h new file +7
-0+static inline void set_resource_address (struct resource *res, +resource_size_t start, +resource_size_t len) +{ + res->start = start; + res->end = start + len -1 ; +}
It might make sense to put this in the generic (resource related, e.g. ioport.h) header. There are plenty users of such already and who knows how many will come.
drivers/gpio/gpio-mmio.c o ` ~~~~\___/~~~~ ` controller in FPGA is ,.` · line 65
Quoted 5 lines
#include <
linux/bitops.h>
#include <linux/platform_device.h>
#include <linux/mod_devicetable.h>drivers/gpio/gpio-mmio.c +2
-0+#include <linux/of.h> +#include <linux/of_device.h>
Perhaps + empty line?
Quoted 1 line
+#include "
gpio-mmio-compat.h"
[]
drivers/gpio/gpio-mmio.c static void __iomem *bgpio_map(struct platform_device *pdev, · line 585
Quoted 11 lines
drivers/gpio/gpio-mmio.c +11
-0+#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; + + err =of_property_read_u32 (dev->of_node,"ngpio" , &pdata->ngpio); +if (err && err != -EINVAL ) +return err;
I think check for -EINVAL needs explanation.
Quoted 1 line
+}
[]
drivers/gpio/gpio-mmio.c static int bgpio_pdev_probe(struct platform_device *pdev)
Quoted 5 lines
drivers/gpio/gpio-mmio.c +4
-0+ pdata =bgpio_parse_dt (pdev, &flags); +if (IS_ERR (pdata)) { +return PTR_ERR (pdata); + }else if (!pdata) {
Redundant else
drivers/gpio/gpio-mmio.c MODULE_DEVICE_TABLE(platform, bgpio_id_table); · line 738
Quoted 12 lines
drivers/gpio/gpio-mmio.c +4
-0+ pdata =dev_get_platdata (dev); + flags = pdev->id_entry->driver_data; + } r =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"dat" );if (!r)@@ -646,6 +734,9 @@ MODULE_DEVICE_TABLE(platform, bgpio_id_table);static struct platform_driver bgpio_driver = { .driver = { .name ="basic-mmio-gpio" , +#ifdef CONFIG_OF
Doesn't of_match_ptr do this for you?
Quoted 2 lines
drivers/gpio/gpio-mmio.c +2
-0+ .of_match_table = of_match_ptr(bgpio_of_match), +#endif
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [RFC v4 3/8] gpio: generic: add DT support for generic memory-mapped GPIOs
Quoted 7 lines · Andy Shevchenko
Quoted 5 lines · Christian Lamparter
From: ?lvaro Fern?ndez Rojas <[email protected]>
This patch adds support for defining memory-mapped GPIOs which provide a compatible interface for the existing generic-gpio driver.
Thanks for your comments! I've prepared a new series which I'm going to post tomorrow. I've incorporated most of the remarks, but there's something I have to say about:
Quoted 11 lines
drivers/gpio/gpio-mmio-compat.h line 16
Quoted 7 lines
drivers/gpio/gpio-mmio-compat.h new file +7
-0+static inline void set_resource_address (struct resource *res, +resource_size_t start, +resource_size_t len) +{ + res->start = start; + res->end = start + len -1 ; +}It might make sense to put this in the generic (resource related, e.g.
ioport.h) header. There are plenty users of such already and who knows how many will come.
I looked around and found plenty of code in drivers/ alone doing the same song and dance around it:
acpi/pci_root.c acpi/resource.cbus/mvebu-mbus.ci2c/busses/i2c-i801.cirqchip/irq-mips-gic.cmemory/omap-gpmc.cmfd/janz-cmodio.c mfd/lpc_ich.c mfd/sm501.c mtd/devices/ms02-nv.c nvdimm/namespace_devs.cof/address.cparisc/ccio-dma.c parisc/dino.c parisc/lba_pci.c pci/hotplug/ibmphp_res.c pci/bus.c pci/iov.c pci/setup-res.c pci/setup-bus.c pci/hotplug/ibmphp_res.c pcmcia/rsrc_mgr.c pcmcia/pcmcia_resource.c pnp/manager.cplatform/x86/intel_pmc_ipc.cpinctrl/sh-pfc/core.c
etc...
I think arch/ will have a few more. If anything this will require help from coccinelle and more stuff. For now I'll convert the code to do the same thing as everybody else. And after the "linux,gpio-mmio" has been successfully mainlined I can worry about how to write the perfect set_resource_address or set_resource_range (needs to handle over- and underflows, etc...) and setup the automatic tools to convert the whole tree. So, unless someone else beats me to this, this would be my plan.
Regards,
Christian
RFC v4 4/8 gpio: clps711x: integrate cirrus clps711x into gpio-mmio
In reply to Christian LamparterThis patch integrates the Cirrus' clps711x driver into the gpio-mmio framework.
--- drivers/gpio/Kconfig | 14 +++---- drivers/gpio/Makefile | 2 +- drivers/gpio/gpio-clps711x.c | 84 ++++++++++++++--------------------------- drivers/gpio/gpio-mmio-compat.h | 11 ++++++ drivers/gpio/gpio-mmio.c | 1 + 5 files changed, 48 insertions(+), 64 deletions(-)
drivers/gpio/Kconfig +7 -7
@@ -152,13 +152,6 @@ config GPIO_BRCMSTB help Say yes here to enable GPIO support for Broadcom STB (BCM7XXX) SoCs. -config GPIO_CLPS711X - tristate "CLPS711X GPIO support" - depends on ARCH_CLPS711X || COMPILE_TEST - select GPIO_GENERIC - help - Say yes here to support GPIO on CLPS711X SoCs. - config GPIO_DAVINCI bool "TI Davinci/Keystone GPIO support" default y if ARCH_DAVINCI
@@ -213,6 +206,13 @@ config GPIO_GENERIC_PLATFORM Say yes here to support basic platform_device memory-mapped GPIO controllers. if GPIO_GENERIC_PLATFORM +config GPIO_CLPS711X + bool "CLPS711X GPIO support" + depends on ARCH_CLPS711X || COMPILE_TEST + select GPIO_GENERIC + help + Say yes here to support GPIO on CLPS711X SoCs. + endif config GPIO_GRGPIO
drivers/gpio/Makefile +1 -1
@@ -14,6 +14,7 @@ obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o # directly supported by gpio-generic gpio-generic-$(CONFIG_GPIO_GENERIC) += gpio-mmio.o +gpio-generic-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o obj-$(CONFIG_GPIO_104_DIO_48E) += gpio-104-dio-48e.o obj-$(CONFIG_GPIO_104_IDIO_16) += gpio-104-idio-16.o
@@ -31,7 +32,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
drivers/gpio/gpio-clps711x.c +28 -56
111 lines not on this page · raw message
drivers/gpio/gpio-mmio-compat.h +11 -0
@@ -5,6 +5,17 @@#define ADD (_name, _func) { .compatible = _name, .data = _func } +#if IS_ENABLED (CONFIG_GPIO_CLPS711X ) +int cirrus_clps711x_parse_dt (struct platform_device *pdev, +struct bgpio_pdata *pdata, +unsigned long *flags); + +#define GPIO_CLPS711X_COMPATIBLE \ + ADD("cirrus,clps711x-gpio", cirrus_clps711x_parse_dt), +#else +#define GPIO_CLPS711X_COMPATIBLE +#endif /* CONFIG_GPIO_CLPS711X */ +#undef ADD static inline void set_resource_address(struct resource *res,
drivers/gpio/gpio-mmio.c +1 -0
@@ -608,6 +608,7 @@ static int bgpio_basic_mmio_parse_dt(struct platform_device *pdev,static const struct of_device_id bgpio_of_match[] = {ADD ("linux,gpio-mmio" , bgpio_basic_mmio_parse_dt), + GPIO_CLPS711X_COMPATIBLE { } };
Signature · 1 line
2.8.1
RFC v4 5/8 gpio: ge: integrate GE's FPGA GPIO into gpio-mmio
In reply to Christian LamparterThis patch integrates the gpio-ge driver into the
gpio-mmio framework.
--- drivers/gpio/Kconfig | 24 +++++----- drivers/gpio/Makefile | 2 +- drivers/gpio/gpio-ge.c | 101 ++++++++++++---------------------------- drivers/gpio/gpio-mmio-compat.h | 14 ++++++ drivers/gpio/gpio-mmio.c | 1 + 5 files changed, 57 insertions(+), 85 deletions(-)
drivers/gpio/Kconfig +12 -12
@@ -187,18 +187,6 @@ config GPIO_ETRAXFS help Say yes here to support the GPIO controller on Axis ETRAX FS SoCs. -config GPIO_GE_FPGA - bool "GE FPGA based GPIO" - depends on GE_FPGA - select GPIO_GENERIC - help - Support for common GPIO functionality provided on some GE Single Board - Computers. - - This driver provides basic support (configure as input or output, read - and write pin state) for GPIO implemented in a number of GE single - board computers. - config GPIO_GENERIC_PLATFORM tristate "Generic memory-mapped GPIO controller support (MMIO platform device)" select GPIO_GENERIC
@@ -213,6 +201,18 @@ config GPIO_CLPS711X help Say yes here to support GPIO on CLPS711X SoCs. +config GPIO_GE_FPGA + bool "GE FPGA based GPIO" + depends on GE_FPGA || COMPILE_TEST + select GPIO_GENERIC + help + Support for common GPIO functionality provided on some GE Single Board + Computers. + + This driver provides basic support (configure as input or output, read + and write pin state) for GPIO implemented in a number of GE single + board computers. + endif config GPIO_GRGPIO
drivers/gpio/Makefile +1 -1
@@ -15,6 +15,7 @@ obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o # directly supported by gpio-generic gpio-generic-$(CONFIG_GPIO_GENERIC) += gpio-mmio.o gpio-generic-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o +gpio-generic-$(CONFIG_GPIO_GE_FPGA) += gpio-ge.o obj-$(CONFIG_GPIO_104_DIO_48E) += gpio-104-dio-48e.o obj-$(CONFIG_GPIO_104_IDIO_16) += gpio-104-idio-16.o
@@ -43,7 +44,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
drivers/gpio/gpio-ge.c +29 -72
121 lines not on this page · raw message
drivers/gpio/gpio-mmio-compat.h +14 -0
@@ -16,6 +16,20 @@ int cirrus_clps711x_parse_dt(struct platform_device *pdev,#define GPIO_CLPS711X_COMPATIBLE #endif /* CONFIG_GPIO_CLPS711X */ +#if IS_ENABLED (CONFIG_GPIO_GE_FPGA ) +int ge_parse_dt (struct platform_device *pdev, +struct bgpio_pdata *pdata, +unsigned long *flags); + +#define GPIO_GE_FPGA_COMPATIBLE \ + ADD("ge,imp3a-gpio", ge_parse_dt), \ + ADD("gef,sbc310-gpio", ge_parse_dt), \ + ADD("gef,sbc610-gpio", ge_parse_dt), + +#else +#define GPIO_GE_FPGA_COMPATIBLE +#endif /* CONFIG_CONFIG_GPIO_GE_FPGA */ +#undef ADD static inline void set_resource_address(struct resource *res,
drivers/gpio/gpio-mmio.c +1 -0
@@ -609,6 +609,7 @@ static int bgpio_basic_mmio_parse_dt(struct platform_device *pdev,static const struct of_device_id bgpio_of_match[] = {ADD ("linux,gpio-mmio" , bgpio_basic_mmio_parse_dt), GPIO_CLPS711X_COMPATIBLE + GPIO_GE_FPGA_COMPATIBLE { } };
Signature · 1 line
2.8.1
RFC v4 6/8 gpio: moxart: integrate MOXA ART GPIO driver into gpio-mmio
In reply to Christian LamparterThis patch integrates the GPIO driver for the MOXA ART SoC into the gpio-mmio framework.
--- drivers/gpio/Kconfig | 15 ++++---- drivers/gpio/Makefile | 2 +- drivers/gpio/gpio-mmio-compat.h | 12 ++++++ drivers/gpio/gpio-mmio.c | 1 + drivers/gpio/gpio-moxart.c | 81 +++++++++++------------------------------ 5 files changed, 42 insertions(+), 69 deletions(-)
drivers/gpio/Kconfig +7 -8
@@ -213,6 +213,13 @@ config GPIO_GE_FPGA and write pin state) for GPIO implemented in a number of GE single board computers. +config GPIO_MOXART + bool "MOXART GPIO support" + depends on ARCH_MOXART || COMPILE_TEST + select GPIO_GENERIC + help + Select this option to enable GPIO driver for + MOXA ART SoC devices. endif config GPIO_GRGPIO
@@ -289,14 +296,6 @@ config GPIO_MM_LANTIQ (EBU) found on Lantiq SoCs. The gpios are output only as they are created by attaching a 16bit latch to the bus. -config GPIO_MOXART - bool "MOXART GPIO support" - depends on ARCH_MOXART || COMPILE_TEST - select GPIO_GENERIC - help - Select this option to enable GPIO driver for - MOXA ART SoC devices. - config GPIO_MPC5200 def_bool y depends on PPC_MPC52xx
drivers/gpio/Makefile +1 -1
@@ -16,6 +16,7 @@ obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o gpio-generic-$(CONFIG_GPIO_GENERIC) += gpio-mmio.o gpio-generic-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o gpio-generic-$(CONFIG_GPIO_GE_FPGA) += gpio-ge.o +gpio-generic-$(CONFIG_GPIO_MOXART) += gpio-moxart.o obj-$(CONFIG_GPIO_104_DIO_48E) += gpio-104-dio-48e.o obj-$(CONFIG_GPIO_104_IDIO_16) += gpio-104-idio-16.o
@@ -68,7 +69,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
drivers/gpio/gpio-mmio-compat.h +12 -0
@@ -30,6 +30,18 @@ int ge_parse_dt(struct platform_device *pdev,#define GPIO_GE_FPGA_COMPATIBLE #endif /* CONFIG_CONFIG_GPIO_GE_FPGA */ +#if IS_ENABLED (CONFIG_GPIO_MOXART ) +int moxart_parse_dt (struct platform_device *pdev, +struct bgpio_pdata *pdata, +unsigned long *flags); + +#define GPIO_MOXART_COMPATIBLE \ + ADD("moxa,moxart-gpio", moxart_parse_dt), + +#else +#define GPIO_MOXART_COMPATIBLE +#endif /* CONFIG_GPIO_MOXART */ +#undef ADD static inline void set_resource_address(struct resource *res,
drivers/gpio/gpio-mmio.c +1 -0
@@ -610,6 +610,7 @@ static const struct of_device_id bgpio_of_match[] = {ADD ("linux,gpio-mmio" , bgpio_basic_mmio_parse_dt), GPIO_CLPS711X_COMPATIBLEGPIO_GE_FPGA_COMPATIBLE +GPIO_MOXART_COMPATIBLE { } };
drivers/gpio/gpio-moxart.c +21 -60
96 lines not on this page · raw message
Signature · 1 line
2.8.1
RFC v4 7/8 gpio: ts4800: integrate TS4800 into gpio-mmio
In reply to Christian LamparterThis patch integrates the TS4800 FPGA GPIO driver into the gpio-mmio framework.
--- drivers/gpio/Kconfig | 17 ++++----- drivers/gpio/Makefile | 2 +- drivers/gpio/gpio-mmio-compat.h | 11 ++++++ drivers/gpio/gpio-mmio.c | 1 + drivers/gpio/gpio-ts4800.c | 76 ++++++++++++++--------------------------- 5 files changed, 47 insertions(+), 60 deletions(-)
drivers/gpio/Kconfig +9 -8
@@ -220,6 +220,15 @@ config GPIO_MOXART help Select this option to enable GPIO driver for MOXA ART SoC devices. + +config GPIO_TS4800 + bool "TS-4800 DIO blocks and compatibles" + depends on OF_GPIO + depends on SOC_IMX51 || COMPILE_TEST + select GPIO_GENERIC + help + This driver support TS-4800 FPGA GPIO controllers. + endif config GPIO_GRGPIO
@@ -407,14 +416,6 @@ config GPIO_TEGRA default y depends on ARCH_TEGRA || COMPILE_TEST -config GPIO_TS4800 - tristate "TS-4800 DIO blocks and compatibles" - depends on OF_GPIO - depends on SOC_IMX51 || COMPILE_TEST - select GPIO_GENERIC - help - This driver support TS-4800 FPGA GPIO controllers. - config GPIO_TZ1090 bool "Toumaz Xenif TZ1090 GPIO support" depends on SOC_TZ1090
drivers/gpio/Makefile +1 -1
@@ -17,6 +17,7 @@ gpio-generic-$(CONFIG_GPIO_GENERIC) += gpio-mmio.o gpio-generic-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o gpio-generic-$(CONFIG_GPIO_GE_FPGA) += gpio-ge.o gpio-generic-$(CONFIG_GPIO_MOXART) += gpio-moxart.o +gpio-generic-$(CONFIG_GPIO_TS4800) += gpio-ts4800.o obj-$(CONFIG_GPIO_104_DIO_48E) += gpio-104-dio-48e.o obj-$(CONFIG_GPIO_104_IDIO_16) += gpio-104-idio-16.o
@@ -107,7 +108,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-mmio-compat.h +11 -0
@@ -42,6 +42,17 @@ int moxart_parse_dt(struct platform_device *pdev,#define GPIO_MOXART_COMPATIBLE #endif /* CONFIG_GPIO_MOXART */ +#if IS_ENABLED (CONFIG_GPIO_TS4800 ) +int technologic_ts4800_parse_dt (struct platform_device *pdev, +struct bgpio_pdata *pdata, +unsigned long *flags); + +#define GPIO_TS4800_COMPATIBLE \ + ADD("technologic,ts4800-gpio", technologic_ts4800_parse_dt), +#else +#define GPIO_TS4800_COMPATIBLE +#endif /* CONFIG_GPIO_TS4800 */ +#undef ADD static inline void set_resource_address(struct resource *res,
drivers/gpio/gpio-mmio.c +1 -0
@@ -611,6 +611,7 @@ static const struct of_device_id bgpio_of_match[] = {GPIO_CLPS711X_COMPATIBLE GPIO_GE_FPGA_COMPATIBLEGPIO_MOXART_COMPATIBLE +GPIO_TS4800_COMPATIBLE { } };
drivers/gpio/gpio-ts4800.c +25 -51
99 lines not on this page · raw message
Signature · 1 line
2.8.1
RFC v4 8/8 gpio: dt-bindings: add gpio-mmio bindings
In reply to Christian LamparterFrom: ?lvaro Fern?ndez Rojas <[email protected]>
This patch adds the device tree bindings for the gpio-mmio. The gpio-mmio is already part of a the GPIO generic library.
--- .../devicetree/bindings/gpio/gpio-mmio.txt | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-mmio.txt
Documentation/devicetree/bindings/gpio/gpio-mmio.txt new file +73 -0
@@ -0,0 +1,73 @@ +Bindings for the generic driver for memory-mapped GPIO controllers. + +Required properties: + - compatible: should be "linux,gpio-mmio" + - reg-names: must contain + "dat" - data register + may contain + "set" - data set register + "clr" - data clear register + "dirout" - direction output register + "dirin" - direction input 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 + - gpio-controller: Marks the device node as a gpio controller. + +Optional properties: + - ngpio: specifies the number of gpio mapped in the register. + - big-endian: force big endian register accesses. + - big-endian-byte-order: assign GPIOs in reverse order. + - unreadable-reg-set: data set register is not readable. + - read-output-reg-set: cache value set for reads. + - unreadable-reg-dir: dirout/dirin register is not readable. + - no-output: GPIOs are read-only. + +The GPIO generic library provides support for memory-mapped GPIO +controllers. The configuration is detected by which resources are present. +The simplest form of a GPIO controller that the driver support is just a +single "dat" register, where GPIO state can be read and/or written. +However, the driver supports far more: + - 8/16/32/64 bits registers. The number of GPIOs is automatically + determined by the width of the registers. + - GPIO controllers with clear/set registers. + - GPIO controllers with a single "dat" register. + - Big endian bits/GPIOs ordering. + +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"). + +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. + +Examples: + + /* Configuration for single input/output register + * for eight simple bidirectional GPIOs. + */ + gpio_a_1 { + compatible = "linux,gpio-mmio"; + reg = <0x18000000 0x1>; + reg-names = "dat"; + #gpio-cells = <2>; + gpio-controller; + }; + + /* Configuration for set/clear pair registers with + * 32 output direction register GPIOs. + */ + gpio_b_2 { + compatible = "linux,gpio-mmio"; + reg = <0x18000000 0x4>, <0x18000010 0x4>, + <0x18000004 0x4>, <0x18000008 0x4>; + reg-names = "dat", "set", "clr", "dirout"; + #gpio-cells = <2>; + gpio-controller; + };
Signature · 1 line
2.8.1