gpio: Add device driver for GRGPIO cores and support custom accessors with gpio-generic
Subsystems (2)
PATCH 1/1 gpio: Add device driver for GRGPIO cores and support custom accessors with gpio-generic
This driver supports GRGPIO gpio cores available in the GRLIB VHDL IP core library from Aeroflex Gaisler.
This also adds support to gpio-generic for using custom accessor functions. The grgpio driver uses this to use ioread32be and iowrite32be for big endian register accesses.
Reviewed-by Anton Vorontsov <[email protected]>
Signed-off-by Andreas Larsson <[email protected]>
---
Changes since v3:
- Add Reveiwed-by
- Fix pointed out style issues
- Use np->full_name directly instead of kstrdup'ing it as it is a const char*
- Call gpiochip_remove in grgpio_remove
.../devicetree/bindings/gpio/gpio-grgpio.txt | 29 +++ drivers/gpio/Kconfig | 8 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-generic.c | 26 ++- drivers/gpio/gpio-grgpio.c | 253 ++++++++++++++++++++ 5 files changed, 308 insertions(+), 9 deletions(-) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-grgpio.txt create mode 100644 drivers/gpio/gpio-grgpio.c
Documentation/devicetree/bindings/gpio/gpio-grgpio.txt new file +29 -0
@@ -0,0 +1,29 @@ +Aeroflex Gaisler GRGPIO General Purpose I/O cores. + +The GRGPIO GPIO core is available in the GRLIB VHDL IP core library. + +Note: In the ordinary ordinary environment for the GRGPIO core, a Leon SPARC +system, these properties are built from information in the AMBA plug&play. + +Required properties: + +- name : Should be "GAISLER_GPIO" or "01_01a" + +- reg : Address and length of the register set for the device + +- interrupts : Interrupt numbers for this device + +Optional properties: + +- base : The base gpio number for the core. A dynamic base is used if not + present + +- nbits : The number of gpio lines. If not present driver assumes 32 lines. + +- irqmap : An array with an index for each gpio line. An index is either a valid + index into the interrupts property array, or 0xffffffff that indicates + no irq for that line. Driver provides no interrupt support if not + present. + +For further information look in the documentation for the GLIB IP core library: +http://www.gaisler.com/products/grlib/grip.pdf
drivers/gpio/Kconfig +8 -0
@@ -309,6 +309,14 @@ config GPIO_LYNXPOINT driver for GPIO functionality on Intel Lynxpoint PCH chipset Requires ACPI device enumeration code to set up a platform device. +config GPIO_GRGPIO + tristate "Aeroflex Gaisler GRGPIO support" + depends on OF + select GPIO_GENERIC + help + Select this to support Aeroflex Gaisler GRGPIO cores from the GRLIB + VHDL IP core library. + comment "I2C GPIO expanders:" config GPIO_ARIZONA
drivers/gpio/Makefile +1 -0
@@ -26,6 +26,7 @@ obj-$(CONFIG_ARCH_DAVINCI) += gpio-davinci.o obj-$(CONFIG_GPIO_EM) += gpio-em.o obj-$(CONFIG_GPIO_EP93XX) += gpio-ep93xx.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_IT8761E) += gpio-it8761e.o obj-$(CONFIG_GPIO_JANZ_TTL) += gpio-janz-ttl.o
drivers/gpio/gpio-generic.c +17 -9
@@ -251,24 +251,25 @@ static int bgpio_setup_accessors(struct device *dev, struct bgpio_chip *bgc, bool be) { +struct bgpio_chip def;switch (bgc->bits) {case 8 : - bgc->read_reg = bgpio_read8; - bgc->write_reg = bgpio_write8; + def.read_reg = bgpio_read8; + def.write_reg = bgpio_write8;break ;case 16 : - bgc->read_reg = bgpio_read16; - bgc->write_reg = bgpio_write16; + def.read_reg = bgpio_read16; + def.write_reg = bgpio_write16;break ;case 32 : - bgc->read_reg = bgpio_read32; - bgc->write_reg = bgpio_write32; + def.read_reg = bgpio_read32; + def.write_reg = bgpio_write32;break ;#if BITS_PER_LONG >=64 case 64 : - bgc->read_reg = bgpio_read64; - bgc->write_reg = bgpio_write64; + def.read_reg = bgpio_read64; + def.write_reg = bgpio_write64;break ;#endif /* BITS_PER_LONG >= 64 */ default :
@@ -276,7 +277,14 @@ static int bgpio_setup_accessors(struct device *dev,return -EINVAL ; } - bgc->pin2mask = be ? bgpio_pin2mask_be : bgpio_pin2mask; + def.pin2mask = be ? bgpio_pin2mask_be : bgpio_pin2mask; + +if (!bgc->read_reg) + bgc->read_reg = def.read_reg; +if (!bgc->write_reg) + bgc->write_reg = def.write_reg; +if (!bgc->pin2mask) + bgc->pin2mask = def.pin2mask;return 0 ; }
drivers/gpio/gpio-grgpio.c new file +253 -0
253 lines not on this page · raw message
Signature · 1 line
1.7.0.4