mfd: lp873x: Add lp873x PMIC support
Subsystems (3)
v4 cover mfd: lp873x: Add lp873x PMIC support
The LP873X chip is a power management IC for Portable Navigation Systems
and Tablet Computing devices. It contains the following components:
- Regulators.
- Configurable General Purpose Output Signals(GPO).
PMIC interacts with the main processor through i2c. PMIC has couple of LDOs(Linear Regulators), couple of BUCKs (Step-Down DC-DC Converter Cores) and GPOs(General Purpose Output Signals).
The regulator patch is already queued:
http://marc.info/?l=linux-kernel&m=146298767110771&w=2
Hence posting the remaining patches of the series with the comments fixed on mfd driver.
Chnages in v4:
Added GPO driver support.
Keerthy (3):
Documentation: mfd: LP873X: Add information for the mfd driver
mfd: lp873x: Add lp873x PMIC support
gpio: lp873x: Add support for General Purpose Outputs
Documentation/devicetree/bindings/mfd/lp873x.txt | 59 +++++ drivers/gpio/Kconfig | 10 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-lp873x.c | 188 ++++++++++++++++ drivers/mfd/Kconfig | 14 ++ drivers/mfd/Makefile | 2 + drivers/mfd/lp873x.c | 99 +++++++++ include/linux/mfd/lp873x.h | 264 +++++++++++++++++++++++ 8 files changed, 637 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/lp873x.txt create mode 100644 drivers/gpio/gpio-lp873x.c create mode 100644 drivers/mfd/lp873x.c create mode 100644 include/linux/mfd/lp873x.h
Signature · 1 line
1.9.1
PATCH v4 1/3 Documentation: mfd: LP873X: Add information for the mfd driver
The lp873x series of PMICs have a bunch of regulators and a couple of GPO(General Purpose Outputs).
Add information for the mfd and regulator drivers.
---
Changes in v4:
* Added the GPO properties.
Changes in v3:
* Changed the example node lable to pmic from lp8733.
Documentation/devicetree/bindings/mfd/lp873x.txt | 59 ++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/lp873x.txt
Documentation/devicetree/bindings/mfd/lp873x.txt new file +59 -0
@@ -0,0 +1,59 @@ +TI LP873X MFD driver + +Required properties: + - compatible: "ti,lp8732", "ti,lp8733" + - reg: I2C slave address. + - gpio-controller : Marks the device node as a GPIO Controller. + - #gpio-cells : Should be two. The first cell is the pin number and + the second cell is used to specify flags. + See ../gpio/gpio.txt for more information. + - regulators: : List of child nodes that specify the regulator + initialization data. +Example: + +pmic: lp8733@60 { + compatible = "ti,lp8733"; + reg = <0x60>; + gpio-controller; + #gpio-cells = <2>; + + regulators { + lp8733_buck0: buck0 { + regulator-name = "lp8733-buck0"; + regulator-min-microvolt = <800000>; + regulator-max-microvolt = <1400000>; + regulator-min-microamp = <1500000>; + regulator-max-microamp = <4000000>; + regulator-ramp-delay = <10000>; + regulator-always-on; + regulator-boot-on; + }; + + lp8733_buck1: buck1 { + regulator-name = "lp8733-buck1"; + regulator-min-microvolt = <800000>; + regulator-max-microvolt = <1400000>; + regulator-min-microamp = <1500000>; + regulator-max-microamp = <4000000>; + regulator-ramp-delay = <10000>; + regulator-boot-on; + regulator-always-on; + }; + + lp8733_ldo0: ldo0 { + regulator-name = "lp8733-ldo0"; + regulator-min-microvolt = <800000>; + regulator-max-microvolt = <3000000>; + regulator-boot-on; + regulator-always-on; + }; + + lp8733_ldo1: ldo1 { + regulator-name = "lp8733-ldo1"; + regulator-min-microvolt = <800000>; + regulator-max-microvolt = <3000000>; + regulator-always-on; + regulator-boot-on; + }; + }; +};
Signature · 1 line
1.9.1
PATCH v4 2/3 mfd: lp873x: Add lp873x PMIC support
In reply to KeerthyThe LP873X chip is a power management IC for Portable Navigation Systems
and Tablet Computing devices. It contains the following components:
- Regulators.
- Configurable General Purpose Output Signals(GPO).
PMIC interacts with the main processor through i2c. PMIC has couple of LDOs(Linear Regulators), couple of BUCKs (Step-Down DC-DC Converter Cores) and GPOs(General Purpose Output Signals).
---
Changes in v4:
* Added Author.
* Added the mfd_cell for gpio.
Changes in v3:
* Reordered the probe code.
* Fixed Typo in Kconfig description.
* Removed unused member from struct lp873x.
drivers/mfd/Kconfig | 14 +++ drivers/mfd/Makefile | 2 + drivers/mfd/lp873x.c | 99 +++++++++++++++++ include/linux/mfd/lp873x.h | 264 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 379 insertions(+) create mode 100644 drivers/mfd/lp873x.c create mode 100644 include/linux/mfd/lp873x.h
drivers/mfd/Kconfig +14 -0
@@ -1221,6 +1221,20 @@ config MFD_TPS65217 This driver can also be built as a module. If so, the module will be called tps65217. +config MFD_LP873X + tristate "TI LP873X Power Management IC" + depends on I2C + select MFD_CORE + select REGMAP_I2C + help + If you say yes here then you get support for the LP873X series of + power management integrated circuits(PMIC). + These include voltage regulators, Thermal protection, Configurable + general purpose outputs(GPO) that are used in portable devices. + + This driver can also be built as a module. If so, the module + will be called lp873x. + config MFD_TPS65218 tristate "TI TPS65218 Power Management chips" depends on I2C
drivers/mfd/Makefile +2 -0
@@ -22,6 +22,8 @@ obj-$(CONFIG_HTC_EGPIO) += htc-egpio.o obj-$(CONFIG_HTC_PASIC3) += htc-pasic3.o obj-$(CONFIG_HTC_I2CPLD) += htc-i2cpld.o +obj-$(CONFIG_MFD_LP873X) += lp873x.o + obj-$(CONFIG_MFD_DAVINCI_VOICECODEC) += davinci_voicecodec.o obj-$(CONFIG_MFD_DM355EVM_MSP) += dm355evm_msp.o obj-$(CONFIG_MFD_TI_AM335X_TSCADC) += ti_am335x_tscadc.o
drivers/mfd/lp873x.c new file +99 -0
99 lines not on this page · raw message
include/linux/mfd/lp873x.h new file +264 -0
264 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v4 3/3 gpio: lp873x: Add support for General Purpose Outputs
In reply to KeerthyAdd driver for lp873x PMIC family GPOs. Two GPOs are supported and can be configured in Open-drain output or Push-pull output.
--- drivers/gpio/Kconfig | 10 +++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-lp873x.c | 188 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 199 insertions(+) create mode 100644 drivers/gpio/gpio-lp873x.c
drivers/gpio/Kconfig +10 -0
@@ -871,6 +871,16 @@ config GPIO_LP3943 LP3943 can be used as a GPIO expander which provides up to 16 GPIOs. Open drain outputs are required for this usage. +config GPIO_LP873X + tristate "TI LP873X GPO" + depends on MFD_LP873X + help + This driver supports the GPO on TI Lp873x PMICs. 2 GPOs are present + on LP873X PMICs. + + This driver can also be built as a module. If so, the module will be + called gpio-lp873x. + config GPIO_MAX77620 tristate "GPIO support for PMIC MAX77620 and MAX20024" depends on MFD_MAX77620
drivers/gpio/Makefile +1 -0
@@ -56,6 +56,7 @@ obj-$(CONFIG_GPIO_LOONGSON) += gpio-loongson.o obj-$(CONFIG_GPIO_LP3943) += gpio-lp3943.o obj-$(CONFIG_GPIO_LPC18XX) += gpio-lpc18xx.o obj-$(CONFIG_ARCH_LPC32XX) += gpio-lpc32xx.o +obj-$(CONFIG_GPIO_LP873X) += gpio-lp873x.o obj-$(CONFIG_GPIO_LYNXPOINT) += gpio-lynxpoint.o obj-$(CONFIG_GPIO_MAX730X) += gpio-max730x.o obj-$(CONFIG_GPIO_MAX7300) += gpio-max7300.o
drivers/gpio/gpio-lp873x.c new file +188 -0
188 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH v4 3/3] gpio: lp873x: Add support for General Purpose Outputs
Hi Keerthy
Some minor comment
drivers/gpio/gpio-lp873x.c line 53
Quoted 11 lines
drivers/gpio/gpio-lp873x.c new file +11
-0+static int lp873x_gpio_direction_output (struct gpio_chip *chip, +unsigned int offset,int value) +{ +struct lp873x_gpio *gpio =gpiochip_get_data (chip); + +/* Set the initial value */ +regmap_update_bits (gpio->lp873->regmap,LP873X_REG_GPO_CTRL , +BIT (offset *4 ), value ?BIT (offset *4 ) :0 ); + +return 0 ; +}
Error needs to be return, this function always return 0.
Quoted 35 lines
drivers/gpio/gpio-lp873x.c new file +35
-0+ +static int lp873x_gpio_get (struct gpio_chip *chip,unsigned int offset) +{ +struct lp873x_gpio *gpio =gpiochip_get_data (chip); +int ret, val; + + ret =regmap_read (gpio->lp873->regmap,LP873X_REG_GPO_CTRL , &val); +if (ret <0 ) +return ret; + +return val &BIT (offset *4 ); +} + +static void lp873x_gpio_set (struct gpio_chip *chip,unsigned int offset, +int value) +{ +struct lp873x_gpio *gpio =gpiochip_get_data (chip); + +regmap_update_bits (gpio->lp873->regmap,LP873X_REG_GPO_CTRL , +BIT (offset *4 ), value ?BIT (offset *4 ) :0 ); +} + +static int lp873x_gpio_request (struct gpio_chip *gc,unsigned int offset) +{ +struct lp873x_gpio *gpio =gpiochip_get_data (gc); +int ret; + +switch (offset) { +case 0 : +/* No MUX Set up Needed for GPO */ +break ; +case 1 : +/* Setup the CLKIN_PIN_SEL MUX to GPO2 */ + ret =regmap_update_bits (gpio->lp873->regmap,LP873X_REG_CONFIG , +LP873X_CONFIG_CLKIN_PIN_SEL ,0 );
drivers/gpio/gpio-lp873x.c line 98
Quoted 10 lines
drivers/gpio/gpio-lp873x.c new file +10
-0+if (ret) +return ret; + +break ; +default : +return -EINVAL ; + } + +return 0 ; +}
Error needs to be return, this function always return 0. Only default returns error here which is unlikely condition.
Quoted 12 lines
drivers/gpio/gpio-lp873x.c new file +12
-0+ + +static int lp873x_gpio_set_single_ended (struct gpio_chip *gc, +unsigned int offset, +enum single_ended_mode mode) +{ +struct lp873x_gpio *gpio =gpiochip_get_data (gc); + +switch (mode) { +case LINE_MODE_OPEN_DRAIN : + return regmap_update_bits(gpio->lp873->regmap, + LP873X_REG_GPO_CTRL,
drivers/gpio/gpio-lp873x.c line 120
Quoted 10 lines
drivers/gpio/gpio-lp873x.c new file +10
-0+BIT (offset *4 +2 ), + BIT(offset * 4 + 2)); +case LINE_MODE_PUSH_PULL : +return regmap_update_bits (gpio->lp873->regmap, +LP873X_REG_GPO_CTRL , +BIT (offset *4 +2 ),0 ); +default : +return -ENOTSUPP ; + } +}
Error needs to be return, this function always return 0. Only default returns error here which is unlikely condition.
Regards
Manish Badarkhe
Re: [PATCH v4 3/3] gpio: lp873x: Add support for General Purpose Outputs
Hi Keerthy,
sorry ignore my last two comments in previous mail.
Quoted 4 lines · Manish Badarkhe
Hi Keerthy
Some minor comment
Quoted 11 lines
drivers/gpio/gpio-lp873x.c line 53
Quoted 11 lines
drivers/gpio/gpio-lp873x.c new file +11
-0+static int lp873x_gpio_direction_output (struct gpio_chip *chip, +unsigned int offset,int value) +{ +struct lp873x_gpio *gpio =gpiochip_get_data (chip); + +/* Set the initial value */ +regmap_update_bits (gpio->lp873->regmap,LP873X_REG_GPO_CTRL , +BIT (offset *4 ), value ?BIT (offset *4 ) :0 ); + +return 0 ; +}
Error needs to be return, this function always return 0.
Regards
Manish Badarkhe
Re: [PATCH v4 3/3] gpio: lp873x: Add support for General Purpose Outputs
Quoted 10 lines · Manish Badarkhe
Hi Keerthy,
sorry ignore my last two comments in previous mail.
Quoted 4 lines · Manish Badarkhe
Hi Keerthy
Some minor comment
Quoted 13 lines
Quoted 11 lines
drivers/gpio/gpio-lp873x.c line 53
Quoted 11 lines
drivers/gpio/gpio-lp873x.c new file +11
-0+static int lp873x_gpio_direction_output (struct gpio_chip *chip, +unsigned int offset,int value) +{ +struct lp873x_gpio *gpio =gpiochip_get_data (chip); + +/* Set the initial value */ +regmap_update_bits (gpio->lp873->regmap,LP873X_REG_GPO_CTRL , +BIT (offset *4 ), value ?BIT (offset *4 ) :0 ); + +return 0 ; +}Error needs to be return, this function always return 0.
Yes! I can just do:
return regmap_update_bits(gpio->lp873->regmap, LP873X_REG_GPO_CTRL,
BIT(offset * 4), value ? BIT(offset * 4) : 0);
Quoted 4 lines
Regards
Manish Badarkhe