LP3943 MFD driver for a GPIO expander and a PWM generator
Subsystems (4)
v5 cover LP3943 MFD driver for a GPIO expander and a PWM generator
LP3943 is an integrated device capable of driving 16 output channels. It can be used for GPIO expander and PWM generators. LP3493 registers are controlled via the I2C interface.
This patch-set consists of four parts - MFD, GPIO, PWM and documents.
Update from v4 to v5:
Add Thierry's ACK for the PWM driver and the DT documentation
Milo Kim (4):
mfd: add LP3943 MFD driver
gpio: add LP3943 I2C GPIO expander driver
pwm: add LP3943 PWM driver
Documentation: add LP3943 DT bindings and document
.../devicetree/bindings/gpio/gpio-lp3943.txt | 37 +++ Documentation/devicetree/bindings/mfd/lp3943.txt | 33 ++ .../devicetree/bindings/pwm/pwm-lp3943.txt | 58 ++++ drivers/gpio/Kconfig | 8 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-lp3943.c | 242 +++++++++++++++ drivers/mfd/Kconfig | 11 + drivers/mfd/Makefile | 1 + drivers/mfd/lp3943.c | 167 +++++++++++ drivers/pwm/Kconfig | 10 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-lp3943.c | 314 ++++++++++++++++++++ include/linux/mfd/lp3943.h | 114 +++++++ 13 files changed, 997 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-lp3943.txt create mode 100644 Documentation/devicetree/bindings/mfd/lp3943.txt create mode 100644 Documentation/devicetree/bindings/pwm/pwm-lp3943.txt create mode 100644 drivers/gpio/gpio-lp3943.c create mode 100644 drivers/mfd/lp3943.c create mode 100644 drivers/pwm/pwm-lp3943.c create mode 100644 include/linux/mfd/lp3943.h
Signature · 1 line
1.7.10.4
PATCH RESEND v5 1/4 mfd: add LP3943 MFD driver
LP3943 has 16 output pins which can be used as GPIO expander and PWM generator.
* Regmap I2C interface for R/W LP3943 registers
* Atomic operations for output pin assignment
The driver should check whether requested pin is available or not. If the pin is already used, pin request returns as a failure. A driver data, 'pin_used' is checked when gpio_request() and pwm_request() are called. If the pin is available, then pin_used is set. And it is cleared when gpio_free() and pwm_free().
* Device tree support
Compatible strings for GPIO and PWM driver.
LP3943 platform data is PWM related, so parsing the device tree is implemented in the PWM driver.
---
* Patch v5
Same as v4
* Patch v4
Driver description was moved from the documentation in patch v3.
* Patch v3
Now, output pin number is exactly matched with enum value of ' lp3943_pwm_output'.
Use dev_get_platdata() helper function in probe(). Use module_i2c_driver() for initcall.
* Patch v2
Handle atomic operations for output pin assignment.
drivers/mfd/Kconfig | 11 +++ drivers/mfd/Makefile | 1 + drivers/mfd/lp3943.c | 167 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/lp3943.h | 114 ++++++++++++++++++++++++++++++ 4 files changed, 293 insertions(+) create mode 100644 drivers/mfd/lp3943.c create mode 100644 include/linux/mfd/lp3943.h
drivers/mfd/Kconfig +11 -0
@@ -725,6 +725,17 @@ config MFD_DM355EVM_MSP boards. MSP430 firmware manages resets and power sequencing, inputs from buttons and the IR remote, LEDs, an RTC, and more. +config MFD_LP3943 + tristate "TI/National Semiconductor LP3943 MFD Driver" + depends on I2C + select MFD_CORE + select REGMAP_I2C + help + Support for the TI/National Semiconductor LP3943. + This driver consists of GPIO and PWM drivers. + With these functionalities, it can be used for LED string control or + general usage such like a GPIO controller and a PWM controller. + config MFD_LP8788 bool "TI LP8788 Power Management Unit Driver" depends on I2C=y
drivers/mfd/Makefile +1 -0
@@ -102,6 +102,7 @@ obj-$(CONFIG_PMIC_DA9052) += da9052-core.o obj-$(CONFIG_MFD_DA9052_SPI) += da9052-spi.o obj-$(CONFIG_MFD_DA9052_I2C) += da9052-i2c.o +obj-$(CONFIG_MFD_LP3943) += lp3943.o obj-$(CONFIG_MFD_LP8788) += lp8788.o lp8788-irq.o da9055-objs := da9055-core.o da9055-i2c.o
drivers/mfd/lp3943.c new file +167 -0
167 lines not on this page · raw message
include/linux/mfd/lp3943.h new file +114 -0
114 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH RESEND v5 2/4 gpio: add LP3943 I2C GPIO expander driver
In reply to Milo KimThis 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 v5 and 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
@@ -368,6 +368,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
@@ -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 · 1 line
1.7.10.4
PATCH RESEND v5 3/4 pwm: add LP3943 PWM driver
In reply to Milo KimThis is the other of the LP3943 MFD driver. LP3943 can be used as a PWM generator, up to 2 channels.
* Two PWM generators supported
* Supported PWM operations
request, free, config, enable and disable
* Pin assignment
A driver data, 'pin_used' is checked when a PWM is requested. If the output pin is already assigned, then returns as failure. If the pin is available, 'pin_used' is set.
When the PWM 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 v5
Add Thierry's acknowledgement.
* Patch v4
No update, same as v3.
* Patch v3
Manual polarity not supported any more.
Add encapsulation functions for accessing internal data structure. Use pwm_set_chip_data() and pwm_get_chip_data().
And other code fixes based on Thierry's feedback.
drivers/pwm/Kconfig | 10 ++ drivers/pwm/Makefile | 1 + drivers/pwm/pwm-lp3943.c | 314 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 325 insertions(+) create mode 100644 drivers/pwm/pwm-lp3943.c
drivers/pwm/Kconfig +10 -0
@@ -81,6 +81,16 @@ config PWM_JZ4740 To compile this driver as a module, choose M here: the module will be called pwm-jz4740. +config PWM_LP3943 + tristate "TI/National Semiconductor LP3943 PWM support" + depends on MFD_LP3943 + help + Generic PWM framework driver for LP3943 which supports two PWM + channels. + + To compile this driver as a module, choose M here: the module + will be called pwm-lp3943. + config PWM_LPC32XX tristate "LPC32XX PWM support" depends on ARCH_LPC32XX
drivers/pwm/Makefile +1 -0
@@ -5,6 +5,7 @@ obj-$(CONFIG_PWM_ATMEL_TCB) += pwm-atmel-tcb.o obj-$(CONFIG_PWM_BFIN) += pwm-bfin.o obj-$(CONFIG_PWM_IMX) += pwm-imx.o obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o +obj-$(CONFIG_PWM_LP3943) += pwm-lp3943.o obj-$(CONFIG_PWM_LPC32XX) += pwm-lpc32xx.o obj-$(CONFIG_PWM_MXS) += pwm-mxs.o obj-$(CONFIG_PWM_PCA9685) += pwm-pca9685.o
drivers/pwm/pwm-lp3943.c new file +314 -0
314 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH RESEND v5 4/4 Documentation: add LP3943 DT bindings and document
In reply to Milo KimBindings for LP3943 MFD, GPIO and PWM controller are added.
--- .../devicetree/bindings/gpio/gpio-lp3943.txt | 37 +++++++++++++ Documentation/devicetree/bindings/mfd/lp3943.txt | 33 +++++++++++ .../devicetree/bindings/pwm/pwm-lp3943.txt | 58 ++++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-lp3943.txt create mode 100644 Documentation/devicetree/bindings/mfd/lp3943.txt create mode 100644 Documentation/devicetree/bindings/pwm/pwm-lp3943.txt
Documentation/devicetree/bindings/gpio/gpio-lp3943.txt new file +37 -0
@@ -0,0 +1,37 @@ +TI/National Semiconductor LP3943 GPIO controller + +Required properties: + - compatible: "ti,lp3943-gpio" + - gpio-controller: Marks the device node as a GPIO controller. + - #gpio-cells: Should be 2. See gpio.txt in this directory for a + description of the cells format. + +Example: +Simple LED controls with LP3943 GPIO controller + +&i2c4 { + lp3943@60 { + compatible = "ti,lp3943"; + reg = <0x60>; + + gpioex: gpio { + compatible = "ti,lp3943-gpio"; + gpio-controller; + #gpio-cells = <2>; + }; + }; +}; + +leds { + compatible = "gpio-leds"; + indicator1 { + label = "indi1"; + gpios = <&gpioex 9 GPIO_ACTIVE_LOW>; + }; + + indicator2 { + label = "indi2"; + gpios = <&gpioex 10 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; +};
Documentation/devicetree/bindings/mfd/lp3943.txt new file +33 -0
@@ -0,0 +1,33 @@ +TI/National Semiconductor LP3943 MFD driver + +Required properties: + - compatible: "ti,lp3943" + - reg: I2C slave address. From 0x60 to 0x67. + +LP3943 consists of two sub-devices, lp3943-gpio and lp3943-pwm. + +For the LP3943 GPIO properties please refer to: +Documentation/devicetree/bindings/gpio/gpio-lp3943.txt + +For the LP3943 PWM properties please refer to: +Documentation/devicetree/bindings/pwm/pwm-lp3943.txt + +Example: + +lp3943@60 { + compatible = "ti,lp3943"; + reg = <0x60>; + + gpioex: gpio { + compatible = "ti,lp3943-gpio"; + gpio-controller; + #gpio-cells = <2>; + }; + + pwm3943: pwm { + compatible = "ti,lp3943-pwm"; + #pwm-cells = <2>; + ti,pwm0 = <8 9 10>; + ti,pwm1 = <15>; + }; +};
Documentation/devicetree/bindings/pwm/pwm-lp3943.txt new file +58 -0
58 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Quoted 28 lines · Milo Kim
LP3943 is an integrated device capable of driving 16 output channels. It can be used for GPIO expander and PWM generators. LP3493 registers are controlled via the I2C interface.
This patch-set consists of four parts - MFD, GPIO, PWM and documents.
Update from v4 to v5:
Add Thierry's ACK for the PWM driver and the DT documentationMilo Kim (4):
mfd: add LP3943 MFD driver
gpio: add LP3943 I2C GPIO expander driver
pwm: add LP3943 PWM driver
Documentation: add LP3943 DT bindings and document.../devicetree/bindings/gpio/gpio-lp3943.txt | 37 +++ Documentation/devicetree/bindings/mfd/lp3943.txt | 33 ++ .../devicetree/bindings/pwm/pwm-lp3943.txt | 58 ++++ drivers/gpio/Kconfig | 8 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-lp3943.c | 242 +++++++++++++++ drivers/mfd/Kconfig | 11 + drivers/mfd/Makefile | 1 + drivers/mfd/lp3943.c | 167 +++++++++++ drivers/pwm/Kconfig | 10 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-lp3943.c | 314 ++++++++++++++++++++ include/linux/mfd/lp3943.h | 114 +++++++
Quoted 8 lines
13 files changed, 997 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-lp3943.txt create mode 100644 Documentation/devicetree/bindings/mfd/lp3943.txt create mode 100644 Documentation/devicetree/bindings/pwm/pwm-lp3943.txt create mode 100644 drivers/gpio/gpio-lp3943.c create mode 100644 drivers/mfd/lp3943.c create mode 100644 drivers/pwm/pwm-lp3943.c create mode 100644 include/linux/mfd/lp3943.h
Patch-set applied, thanks Milo.
Signature · 8 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog -- 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