power: pmic: Add support for LP87565 family of PMICs
v2 cover power: pmic: Add support for LP87565 family of PMICs
The series adds support for LP87565 family of PMICs. Implements functions to configure regulators. Enable/Disable Get/Set voltages of regulators.
Keerthy (2):
power: pmic: lp87565: Add the basic pmic support
power: regulator: lp87565: add regulator support
drivers/power/pmic/Kconfig | 7 + drivers/power/pmic/Makefile | 1 + drivers/power/pmic/lp87565.c | 85 ++++++++++++ drivers/power/regulator/Kconfig | 10 ++ drivers/power/regulator/Makefile | 1 + drivers/power/regulator/lp87565_regulator.c | 199 ++++++++++++++++++++++++++++ include/power/lp87565.h | 12 ++ 7 files changed, 315 insertions(+) create mode 100644 drivers/power/pmic/lp87565.c create mode 100644 drivers/power/regulator/lp87565_regulator.c create mode 100644 include/power/lp87565.h
Signature · 1 line
1.9.1
PATCH v2 1/2 power: pmic: lp87565: Add the basic pmic support
Add support to bind the regulators/child nodes with the pmic.
---
Changes in v2:
* Used dev_read_subnode function to fetch the regulators node.
drivers/power/pmic/Kconfig | 7 ++++ drivers/power/pmic/Makefile | 1 + drivers/power/pmic/lp87565.c | 85 ++++++++++++++++++++++++++++++++++++++++++++ include/power/lp87565.h | 12 +++++++ 4 files changed, 105 insertions(+) create mode 100644 drivers/power/pmic/lp87565.c create mode 100644 include/power/lp87565.h
drivers/power/pmic/Kconfig +7 -0
@@ -188,6 +188,13 @@ config PMIC_LP873X The LP873X is a PMIC containing couple of LDOs and couple of SMPS. This driver binds the pmic children. +config PMIC_LP87565 + bool "Enable driver for Texas Instruments LP87565 PMIC" + depends on DM_PMIC + ---help--- + The LP87565 is a PMIC containing a bunch of SMPS. + This driver binds the pmic children. + config POWER_MC34VR500 bool "Enable driver for Freescale MC34VR500 PMIC" ---help---
drivers/power/pmic/Makefile +1 -0
@@ -21,6 +21,7 @@ obj-$(CONFIG_PMIC_TPS65090) += tps65090.o obj-$(CONFIG_PMIC_S5M8767) += s5m8767.o obj-$(CONFIG_$(SPL_)PMIC_PALMAS) += palmas.o obj-$(CONFIG_$(SPL_)PMIC_LP873X) += lp873x.o +obj-$(CONFIG_$(SPL_)PMIC_LP87565) += lp87565.o obj-$(CONFIG_POWER_LTC3676) += pmic_ltc3676.o obj-$(CONFIG_POWER_MAX77696) += pmic_max77696.o
drivers/power/pmic/lp87565.c new file +85 -0
85 lines not on this page · raw message
include/power/lp87565.h new file +12 -0
@@ -0,0 +1,12 @@ +#define LP87565 0x0 +#define LP87565_Q1 0x1 + +#define LP87565_BUCK_NUM 6 + +/* Drivers name */ +#define LP87565_BUCK_DRIVER "lp87565_buck" + +#define LP87565_BUCK_VOLT_MASK 0xFF +#define LP87565_BUCK_VOLT_MAX_HEX 0xFF +#define LP87565_BUCK_VOLT_MAX 3360000 +#define LP87565_BUCK_MODE_MASK 0x80
Signature · 1 line
1.9.1
PATCH v2 1/2 power: pmic: lp87565: Add the basic pmic support
Hi Keerthy,
Quoted 71 lines · Keerthy
Add support to bind the regulators/child nodes with the pmic.
Signed-off-by Keerthy <[email protected]>---
Changes in v2:
* Used
dev_read_subnodefunction to fetch the regulators node.drivers/power/pmic/Kconfig | 7 ++++ drivers/power/pmic/Makefile | 1 + drivers/power/pmic/lp87565.c | 85 ++++++++++++++++++++++++++++++++++++++++++++ include/power/lp87565.h | 12 +++++++ 4 files changed, 105 insertions(+) create mode 100644 drivers/power/pmic/lp87565.c create mode 100644 include/power/lp87565.hdrivers/power/pmic/Kconfig +7
-0@@ -188,6 +188,13 @@ config PMIC_LP873X The LP873X is a PMIC containing couple of LDOs and couple of SMPS. This driver binds the pmic children. +config PMIC_LP87565 + bool "Enable driver for Texas Instruments LP87565 PMIC" + depends on DM_PMIC + ---help--- + The LP87565 is a PMIC containing a bunch of SMPS. + This driver binds the pmic children. + config POWER_MC34VR500 bool "Enable driver for Freescale MC34VR500 PMIC" ---help---drivers/power/pmic/Makefile +1
-0@@ -21,6 +21,7 @@ obj-$(CONFIG_PMIC_TPS65090) += tps65090.o obj-$(CONFIG_PMIC_S5M8767) += s5m8767.o obj-$(CONFIG_$(SPL_)PMIC_PALMAS) += palmas.o obj-$(CONFIG_$(SPL_)PMIC_LP873X) += lp873x.o +obj-$(CONFIG_$(SPL_)PMIC_LP87565) += lp87565.o obj-$(CONFIG_POWER_LTC3676) += pmic_ltc3676.o obj-$(CONFIG_POWER_MAX77696) += pmic_max77696.odrivers/power/pmic/lp87565.c new file +18
-0@@ -0,0 +1,85 @@ +/* +* (C) Copyright 2017 Texas Instruments Incorporated, <www.ti.com> +* Keerthy <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <fdtdec.h> +#include <errno.h> +#include <dm.h> +#include <i2c.h> +#include <power/pmic.h> +#include <power/regulator.h> +#include <power/lp87565.h> +#include <dm/device.h> + +DECLARE_GLOBAL_DATA_PTR ;
drivers/power/pmic/lp87565.c line 28
Quoted 10 lines
drivers/power/pmic/lp87565.c new file +10
-0+ +static const struct pmic_child_info pmic_children_info[] = { + { .prefix ="buck" , .driver =LP87565_BUCK_DRIVER }, + { }, +}; + +static int lp87565_write (struct udevice *dev,uint reg,const uint8_t *buff, +int len) +{ +if (dm_i2c_write (dev, reg, buff, len)) {
I think you referred to the other file.. :)
dm_i2c_write() can be returned the other error number..
I think the below code is better than now..I will modify the other files like below
ret = dm_i2c_read()
if (ret)
error();
return ret;
Quoted 76 lines
drivers/power/pmic/lp87565.c new file +57
-0+error ("write error to device: %p register: %#x!" , dev, reg); +return -EIO ; + } + +return 0 ; +} + +static int lp87565_read (struct udevice *dev,uint reg,uint8_t *buff,int len) +{ +if (dm_i2c_read (dev, reg, buff, len)) { +error ("read error from device: %p register: %#x!" , dev, reg); +return -EIO ; + } + +return 0 ; +} + +static int lp87565_bind (struct udevice *dev) +{ +ofnode regulators_node; +int children; + + regulators_node =dev_read_subnode (dev,"regulators" ); +if (!ofnode_valid (regulators_node)) { +debug ("%s: %s regulators subnode not found!" , __func__, + dev->name); +return -ENXIO ; + } + +debug ("%s: '%s' - found regulators subnode\n" , __func__, dev->name); + + children =pmic_bind_children (dev, regulators_node, pmic_children_info); +if (!children) +printf ("%s: %s - no child found\n" , __func__, dev->name); + +/* Always return success for this device */ +return 0 ; +} + +static struct dm_pmic_ops lp87565_ops = { + .read = lp87565_read, + .write = lp87565_write, +}; + +static const struct udevice_id lp87565_ids[] = { + { .compatible ="ti,lp87565" , .data =LP87565 }, + { .compatible ="ti,lp87565-q1" , .data =LP87565_Q1 }, + { } +}; + +U_BOOT_DRIVER (pmic_lp87565) = { + .name ="lp87565_pmic" , + .id =UCLASS_PMIC , + .of_match = lp87565_ids, + .bind = lp87565_bind, + .ops = &lp87565_ops, +};include/power/lp87565.h new file +12
-0@@ -0,0 +1,12 @@ +#define LP87565 0x0 +#define LP87565_Q1 0x1 + +#define LP87565_BUCK_NUM 6 + +/* Drivers name */ +#define LP87565_BUCK_DRIVER "lp87565_buck" + +#define LP87565_BUCK_VOLT_MASK 0xFF +#define LP87565_BUCK_VOLT_MAX_HEX 0xFF +#define LP87565_BUCK_VOLT_MAX 3360000 +#define LP87565_BUCK_MODE_MASK 0x80
PATCH v2 1/2 power: pmic: lp87565: Add the basic pmic support
Quoted 88 lines · Jaehoon Chung
Hi Keerthy,
Quoted 71 lines · Keerthy
Add support to bind the regulators/child nodes with the pmic.
Signed-off-by Keerthy <[email protected]>---
Changes in v2:
* Used
dev_read_subnodefunction to fetch the regulators node.drivers/power/pmic/Kconfig | 7 ++++ drivers/power/pmic/Makefile | 1 + drivers/power/pmic/lp87565.c | 85 ++++++++++++++++++++++++++++++++++++++++++++ include/power/lp87565.h | 12 +++++++ 4 files changed, 105 insertions(+) create mode 100644 drivers/power/pmic/lp87565.c create mode 100644 include/power/lp87565.hdrivers/power/pmic/Kconfig +7
-0@@ -188,6 +188,13 @@ config PMIC_LP873X The LP873X is a PMIC containing couple of LDOs and couple of SMPS. This driver binds the pmic children. +config PMIC_LP87565 + bool "Enable driver for Texas Instruments LP87565 PMIC" + depends on DM_PMIC + ---help--- + The LP87565 is a PMIC containing a bunch of SMPS. + This driver binds the pmic children. + config POWER_MC34VR500 bool "Enable driver for Freescale MC34VR500 PMIC" ---help---drivers/power/pmic/Makefile +1
-0@@ -21,6 +21,7 @@ obj-$(CONFIG_PMIC_TPS65090) += tps65090.o obj-$(CONFIG_PMIC_S5M8767) += s5m8767.o obj-$(CONFIG_$(SPL_)PMIC_PALMAS) += palmas.o obj-$(CONFIG_$(SPL_)PMIC_LP873X) += lp873x.o +obj-$(CONFIG_$(SPL_)PMIC_LP87565) += lp87565.o obj-$(CONFIG_POWER_LTC3676) += pmic_ltc3676.o obj-$(CONFIG_POWER_MAX77696) += pmic_max77696.odrivers/power/pmic/lp87565.c new file +18
-0@@ -0,0 +1,85 @@ +/* +* (C) Copyright 2017 Texas Instruments Incorporated, <www.ti.com> +* Keerthy <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <fdtdec.h> +#include <errno.h> +#include <dm.h> +#include <i2c.h> +#include <power/pmic.h> +#include <power/regulator.h> +#include <power/lp87565.h> +#include <dm/device.h> + +DECLARE_GLOBAL_DATA_PTR ;drivers/power/pmic/lp87565.c line 28
Quoted 10 lines
drivers/power/pmic/lp87565.c new file +10
-0+ +static const struct pmic_child_info pmic_children_info[] = { + { .prefix ="buck" , .driver =LP87565_BUCK_DRIVER }, + { }, +}; + +static int lp87565_write (struct udevice *dev,uint reg,const uint8_t *buff, +int len) +{ +if (dm_i2c_write (dev, reg, buff, len)) {I think you referred to the other file.. :)
Quoted 8 lines
dm_i2c_write()can be returned the other error number..
I think the below code is better than now..I will modify the other files like belowret =
dm_i2c_read()
if (ret)error();return ret;
Jaehoon,
yes makes sense. So both dm_i2c_write and dm_i2c_read can return different values. I will change like how you have suggested and post v3.
Thanks,
Keerthy
Quoted 78 lines
Quoted 77 lines
drivers/power/pmic/lp87565.c new file +57
-0+error ("write error to device: %p register: %#x!" , dev, reg); +return -EIO ; + } + +return 0 ; +} + +static int lp87565_read (struct udevice *dev,uint reg,uint8_t *buff,int len) +{ +if (dm_i2c_read (dev, reg, buff, len)) { +error ("read error from device: %p register: %#x!" , dev, reg); +return -EIO ; + } + +return 0 ; +} + +static int lp87565_bind (struct udevice *dev) +{ +ofnode regulators_node; +int children; + + regulators_node =dev_read_subnode (dev,"regulators" ); +if (!ofnode_valid (regulators_node)) { +debug ("%s: %s regulators subnode not found!" , __func__, + dev->name); +return -ENXIO ; + } + +debug ("%s: '%s' - found regulators subnode\n" , __func__, dev->name); + + children =pmic_bind_children (dev, regulators_node, pmic_children_info); +if (!children) +printf ("%s: %s - no child found\n" , __func__, dev->name); + +/* Always return success for this device */ +return 0 ; +} + +static struct dm_pmic_ops lp87565_ops = { + .read = lp87565_read, + .write = lp87565_write, +}; + +static const struct udevice_id lp87565_ids[] = { + { .compatible ="ti,lp87565" , .data =LP87565 }, + { .compatible ="ti,lp87565-q1" , .data =LP87565_Q1 }, + { } +}; + +U_BOOT_DRIVER (pmic_lp87565) = { + .name ="lp87565_pmic" , + .id =UCLASS_PMIC , + .of_match = lp87565_ids, + .bind = lp87565_bind, + .ops = &lp87565_ops, +};include/power/lp87565.h new file +12
-0@@ -0,0 +1,12 @@ +#define LP87565 0x0 +#define LP87565_Q1 0x1 + +#define LP87565_BUCK_NUM 6 + +/* Drivers name */ +#define LP87565_BUCK_DRIVER "lp87565_buck" + +#define LP87565_BUCK_VOLT_MASK 0xFF +#define LP87565_BUCK_VOLT_MAX_HEX 0xFF +#define LP87565_BUCK_VOLT_MAX 3360000 +#define LP87565_BUCK_MODE_MASK 0x80
PATCH v2 2/2 power: regulator: lp87565: add regulator support
In reply to KeerthyThe driver provides regulator set/get voltage enable/disable functions for lp87565 family of PMICs.
---
Changes in v2:
* updated Kconfig description.
* Used -EINVAL instead of hardcoded -1.
* removed couple of unwanted braces.
* Changed volt2hex to volt2val and hex2volt to val2volt.
drivers/power/regulator/Kconfig | 10 ++ drivers/power/regulator/Makefile | 1 + drivers/power/regulator/lp87565_regulator.c | 199 ++++++++++++++++++++++++++++ 3 files changed, 210 insertions(+) create mode 100644 drivers/power/regulator/lp87565_regulator.c
drivers/power/regulator/Kconfig +10 -0
@@ -149,3 +149,13 @@ config DM_REGULATOR_LP873X This enables implementation of driver-model regulator uclass features for REGULATOR LP873X and the family of LP873X PMICs. The driver implements get/set api for: value and enable. + +config DM_REGULATOR_LP87565 + bool "Enable driver for LP87565 PMIC regulators" + depends on PMIC_LP87565 + ---help--- + This enables implementation of driver-model regulator uclass + features for REGULATOR LP87565 and the family of LP87565 PMICs. + LP87565 series of PMICs have 4 single phase BUCKs that can also + be configured in multi phase modes. The driver implements + get/set api for value and enable.
drivers/power/regulator/Makefile +1 -0
@@ -18,3 +18,4 @@ obj-$(CONFIG_DM_REGULATOR_SANDBOX) += sandbox.o obj-$(CONFIG_REGULATOR_TPS65090) += tps65090_regulator.o obj-$(CONFIG_$(SPL_)DM_REGULATOR_PALMAS) += palmas_regulator.o obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP873X) += lp873x_regulator.o +obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP87565) += lp87565_regulator.o
drivers/power/regulator/lp87565_regulator.c new file +199 -0
199 lines not on this page · raw message
Signature · 1 line
1.9.1