Re: [PATCH] gpio: Add generic driver for simple memory mapped controllers

Previous thread: [PATCH] lglock: make lg_lock_global() actually lock globally by Jonathan Corbet on Wednesday, August 25, 2010 - 12:28 pm. (16 messages)

Next thread: [PATCH] [RFC] isofs: work-around for Rock Ridge+Joliet CDs with empty ISO root directory by Ondrej Zary on Wednesday, August 25, 2010 - 12:48 pm. (1 message)
From: Anton Vorontsov
Date: Wednesday, August 25, 2010 - 12:42 pm

The simple memory mapped GPIO controllers may be found in various
onboard FPGAs that are used to control board's switches, LEDs,
chip-selects, Ethernet/USB PHY power, etc.

Usually these controllers do not privide any means of pin setup
(in/out/open drain).

The driver provides:
- Support for 8/16/32/64 bits registers;
- Support for GPIO controllers with clear/set registers;
- Support for GPIO controllers with a single "data" register;
- Support for big endian bits/GPIOs ordering (mostly used on PowerPC).

Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
---
 drivers/gpio/Kconfig          |    5 +
 drivers/gpio/Makefile         |    1 +
 drivers/gpio/simple_mm_gpio.c |  243 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 249 insertions(+), 0 deletions(-)
 create mode 100644 drivers/gpio/simple_mm_gpio.c

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index f623953..a145063 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -82,6 +82,11 @@ config GPIO_PL061
 	help
 	  Say yes here to support the PrimeCell PL061 GPIO device
 
+config GPIO_SIMPLE_MM
+	tristate "Simple memory mapped GPIO controllers support"
+	help
+	  Say yes here to support simple memory mapped GPIO controllers.
+
 config GPIO_XILINX
 	bool "Xilinx GPIO support"
 	depends on PPC_OF || MICROBLAZE
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index a69e060..bfd43bb 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -20,6 +20,7 @@ obj-$(CONFIG_GPIO_MCP23S08)	+= mcp23s08.o
 obj-$(CONFIG_GPIO_PCA953X)	+= pca953x.o
 obj-$(CONFIG_GPIO_PCF857X)	+= pcf857x.o
 obj-$(CONFIG_GPIO_PL061)	+= pl061.o
+obj-$(CONFIG_GPIO_SIMPLE_MM)	+= simple_mm_gpio.o
 obj-$(CONFIG_GPIO_TC35892)	+= tc35892-gpio.o
 obj-$(CONFIG_GPIO_TIMBERDALE)	+= timbgpio.o
 obj-$(CONFIG_GPIO_TWL4030)	+= twl4030-gpio.o
diff --git a/drivers/gpio/simple_mm_gpio.c b/drivers/gpio/simple_mm_gpio.c
new file mode 100644
index 0000000..028dce8
--- /dev/null
+++ ...
From: Anton Vorontsov
Date: Wednesday, August 25, 2010 - 10:17 pm

I know at least two completely different platforms that
might reuse this driver.

One is PowerPC with ~10 different boards, and another is
an ARM board.

On PowerPC we use arch/powerpc/sysdev/simple_gpio.c, but
the new driver is much more generic, and is aimed to
replace the PowerPC specific one. So it is 'generic' in
this exact sense.

I also think that it is impractical to name the driver
after the particular FPGA IP codename, or even depend
on 'FPGA' word at all (as the GPIOs might be in ASIC

Well, good. They don't have to use this driver. The driver
is for 'simple' GPIOs, just as the driver name states. I.e.
just a 'data' register or data + set + clr. The name
'simple', IMHO, perfectly matches the purpose of that
driver, no?

If you don't like the word 'generic' in the email subject
(the word does not appear anywhere else), I can remove it,
but I don't see why the name 'simple' doesn't work for
this driver.

Thanks!

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2
--

From: Mark Brown
Date: Thursday, August 26, 2010 - 11:38 am

I'd suggest naming these resources rather than grabbing by number,
that'll make it easier to plumb the machine driver side in since you
don't have to remember which number corresponds to which function.
--

Previous thread: [PATCH] lglock: make lg_lock_global() actually lock globally by Jonathan Corbet on Wednesday, August 25, 2010 - 12:28 pm. (16 messages)

Next thread: [PATCH] [RFC] isofs: work-around for Rock Ridge+Joliet CDs with empty ISO root directory by Ondrej Zary on Wednesday, August 25, 2010 - 12:48 pm. (1 message)