Skip to contentSkip to conversation

gpio: add LP3943 I2C GPIO expander driver

PATCH Superseded Milo Kim 1 participant 1 message Sep 25, 2013

Subsystems (2)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Milo Kim

author
#0 lore raw

PATCH v4 2/4 gpio: add LP3943 I2C GPIO expander driver

This is one of LP3943 MFD driver.
LP3943 is configurable as a GPIO expander, up to 16 GPIOs.

* Application note: how to configure LP3943 as a GPIO expander
http://www.ti.com/lit/an/snva287a/snva287a.pdf

* Supported GPIO controller operations
request, free, direction_input, direction_output, get and set

* GPIO direction register not supported
LP3943 doesn't have the GPIO direction register. It only provides input and output status registers.
So, private data for the direction should be handled manually. This variable is updated whenever the direction is changed and used in 'get' operation.

* Pin assignment
A driver data, 'pin_used' is checked when a GPIO is requested. If the GPIO is already assigned, then returns as failure. If the GPIO is available, 'pin_used' is set.
When the GPIO is not used anymore, then it is cleared. It is defined as unsigned long type for atomic bit operation APIs, but only LSB 16bits are used because LP3943 has 16 outputs.

---
* Patch v4
No update, same as v3

* Patch v3
Use inline function instead of macro(), to_lp3943_gpio().
Add 'lp3943_gpio_set_mode()' and use it in lp3943_gpio_direction_input() and lp3943_gpio_set().
Few code cosmetic applied - indentations.

* Patch v2
Use bitops macros for bit manipulations. Support device tree structure for the GPIO controller. Add request() and free() for the pin assignment.

 drivers/gpio/Kconfig       |    8 ++
 drivers/gpio/Makefile      |    1 +
 drivers/gpio/gpio-lp3943.c |  242 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 251 insertions(+)
 create mode 100644 drivers/gpio/gpio-lp3943.c
drivers/gpio/Kconfig +8 -0
index 349b161..60fb6e7 100644
@@ -360,6 +360,14 @@ config GPIO_ARIZONA
 	help
 	  Support for GPIOs on Wolfson Arizona class devices.
 
+config GPIO_LP3943
+	tristate "TI/National Semiconductor LP3943 GPIO expander"
+	depends on MFD_LP3943
+	help
+	  GPIO driver for LP3943 MFD.
+	  LP3943 can be used as a GPIO expander which provides up to 16 GPIOs.
+	  Open drain outputs are required for this usage.
+
 config GPIO_MAX7300
 	tristate "Maxim MAX7300 GPIO expander"
 	depends on I2C
drivers/gpio/Makefile +1 -0
index 97438bf..d1e2836 100644
@@ -33,6 +33,7 @@ obj-$(CONFIG_GPIO_JANZ_TTL)	+= gpio-janz-ttl.o
 obj-$(CONFIG_GPIO_KEMPLD)	+= gpio-kempld.o
 obj-$(CONFIG_ARCH_KS8695)	+= gpio-ks8695.o
 obj-$(CONFIG_GPIO_LANGWELL)	+= gpio-langwell.o
+obj-$(CONFIG_GPIO_LP3943)	+= gpio-lp3943.o
 obj-$(CONFIG_ARCH_LPC32XX)	+= gpio-lpc32xx.o
 obj-$(CONFIG_GPIO_LYNXPOINT)	+= gpio-lynxpoint.o
 obj-$(CONFIG_GPIO_MAX730X)	+= gpio-max730x.o
drivers/gpio/gpio-lp3943.c new file +242 -0

242 lines not on this page · raw message

Signature · 6 lines
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html