[PATCH 0/4] Add support for TPS65219 PMIC on AM64X-SKEVM

This serie adds support for the TPS65219 PMIC available on the E4 revision of the AM64X-SKEVM board.
Neil Armstrong (4): power: add driver for the TPS65219 PMIC regulator: add driver for the TPS65219 BUCK & LDO regulators config: enable TPS65219 for am64x_evm_a53 boards ARM: dts: k3-am642-sk-u-boot: add PMIC node
arch/arm/dts/k3-am642-sk-u-boot.dtsi | 61 +++ configs/am64x_evm_a53_defconfig | 6 + drivers/power/pmic/Kconfig | 6 + drivers/power/pmic/Makefile | 1 + drivers/power/pmic/tps65219.c | 88 +++++ drivers/power/regulator/Kconfig | 9 + drivers/power/regulator/Makefile | 1 + drivers/power/regulator/tps65219_regulator.c | 380 +++++++++++++++++++ include/power/tps65219.h | 46 +++ 9 files changed, 598 insertions(+) create mode 100644 drivers/power/pmic/tps65219.c create mode 100644 drivers/power/regulator/tps65219_regulator.c create mode 100644 include/power/tps65219.h

The TPS65219 I2S PMIC features 3 Buck converters and 4 linear regulators, 2 GPOs, 1 GPIO, and 3 multi-function-pin.
This adds the PMIC driver, loading the regulator sub-nodes.
Signed-off-by: Neil Armstrong narmstrong@baylibre.com --- drivers/power/pmic/Kconfig | 6 +++ drivers/power/pmic/Makefile | 1 + drivers/power/pmic/tps65219.c | 88 +++++++++++++++++++++++++++++++++++ include/power/tps65219.h | 46 ++++++++++++++++++ 4 files changed, 141 insertions(+) create mode 100644 drivers/power/pmic/tps65219.c create mode 100644 include/power/tps65219.h
diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig index 953c92e212..bb3960020d 100644 --- a/drivers/power/pmic/Kconfig +++ b/drivers/power/pmic/Kconfig @@ -367,6 +367,12 @@ config PMIC_TPS65941 The TPS65941 is a PMIC containing a bunch of SMPS & LDOs. This driver binds the pmic children.
+config PMIC_TPS65219 + bool "Enable driver for Texas Instruments TPS65219 PMIC" + depends on DM_PMIC + help + The TPS65219 is a PMIC containing a bunch of SMPS & LDOs. + This driver binds the pmic children. endif
config PMIC_TPS65217 diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile index 584d6e0e78..f73b326255 100644 --- a/drivers/power/pmic/Makefile +++ b/drivers/power/pmic/Makefile @@ -43,3 +43,4 @@ obj-$(CONFIG_POWER_TPS65910) += pmic_tps65910.o obj-$(CONFIG_POWER_HI6553) += pmic_hi6553.o obj-$(CONFIG_POWER_MC34VR500) += pmic_mc34vr500.o obj-$(CONFIG_PMIC_TPS65941) += tps65941.o +obj-$(CONFIG_PMIC_TPS65219) += tps65219.o diff --git a/drivers/power/pmic/tps65219.c b/drivers/power/pmic/tps65219.c new file mode 100644 index 0000000000..9462afee77 --- /dev/null +++ b/drivers/power/pmic/tps65219.c @@ -0,0 +1,88 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2022 BayLibre, SAS + * Author: Neil Armstrong narmstrong@baylibre.com + */ + +#include <common.h> +#include <fdtdec.h> +#include <errno.h> +#include <dm.h> +#include <i2c.h> +#include <log.h> +#include <power/pmic.h> +#include <power/regulator.h> +#include <power/tps65219.h> +#include <dm/device.h> + +static const struct pmic_child_info pmic_children_info[] = { + { .prefix = "ldo", .driver = TPS65219_LDO_DRIVER }, + { .prefix = "buck", .driver = TPS65219_BUCK_DRIVER }, + { }, +}; + +static int tps65219_reg_count(struct udevice *dev) +{ + return 0x41; +} + +static int tps65219_write(struct udevice *dev, uint reg, const uint8_t *buff, + int len) +{ + if (dm_i2c_write(dev, reg, buff, len)) { + pr_err("write error to device: %p register: %#x!\n", dev, reg); + return -EIO; + } + + return 0; +} + +static int tps65219_read(struct udevice *dev, uint reg, uint8_t *buff, int len) +{ + if (dm_i2c_read(dev, reg, buff, len)) { + pr_err("read error from device: %p register: %#x!\n", dev, reg); + return -EIO; + } + + return 0; +} + +static int tps65219_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!\n", __func__, + dev->name); + } + + 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); + + /* Probe all the child devices */ + return dm_scan_fdt_dev(dev); +} + +static struct dm_pmic_ops tps65219_ops = { + .reg_count = tps65219_reg_count, + .read = tps65219_read, + .write = tps65219_write, +}; + +static const struct udevice_id tps65219_ids[] = { + { .compatible = "ti,tps65219" }, + { } +}; + +U_BOOT_DRIVER(pmic_tps65219) = { + .name = "tps65219_pmic", + .id = UCLASS_PMIC, + .of_match = tps65219_ids, + .bind = tps65219_bind, + .ops = &tps65219_ops, +}; diff --git a/include/power/tps65219.h b/include/power/tps65219.h new file mode 100644 index 0000000000..aa81b92266 --- /dev/null +++ b/include/power/tps65219.h @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * (C) Copyright 2022 BayLibre, SAS + * Author: Neil Armstrong narmstrong@baylibre.com + */ + +#ifndef TPS65219_H +#define TPS65219_H + +/* I2C device address for pmic tps65219 */ +#define TPS65219_I2C_ADDR 0x30 +#define TPS65219_LDO_NUM 4 +#define TPS65219_BUCK_NUM 3 + +/* Drivers name */ +#define TPS65219_LDO_DRIVER "tps65219_ldo" +#define TPS65219_BUCK_DRIVER "tps65219_buck" + +#define TPS65219_VOLT_MASK 0x3F +#define TPS65219_BUCK_VOLT_MAX 3400000 + +#define TPS65219_ENABLE_CTRL_REG 0x2 + +#define TPS65219_BUCK1_VOUT_REG 0xa +#define TPS65219_BUCK2_VOUT_REG 0x9 +#define TPS65219_BUCK3_VOUT_REG 0x8 + +#define TPS65219_LDO1_VOUT_REG 0x7 +#define TPS65219_LDO2_VOUT_REG 0x6 + +#define TPS65219_LDO12_BYP_CONFIG 6 + +#define TPS65219_LDO3_VOUT_REG 0x5 +#define TPS65219_LDO4_VOUT_REG 0x4 + +#define TPS65219_LDO12_VOLT_BYP_MIN 1500000 +#define TPS65219_LDO12_VOLT_MIN 600000 +#define TPS65219_LDO12_VOLT_MAX 3400000 +#define TPS65219_LDO12_VOLT_REG_MIN 0 +#define TPS65219_LDO12_VOLT_REG_MAX 0x56 +#define TPS65219_LDO34_VOLT_MIN 1200000 +#define TPS65219_LDO34_VOLT_MAX 3300000 +#define TPS65219_LDO34_VOLT_REG_MIN 0x12 +#define TPS65219_LDO34_VOLT_REG_MAX 0x54 + +#endif /* TPS65219_H */

On Wed, Apr 27, 2022 at 01:28:09PM +0200, Neil Armstrong wrote:
The TPS65219 I2S PMIC features 3 Buck converters and 4 linear regulators, 2 GPOs, 1 GPIO, and 3 multi-function-pin.
This adds the PMIC driver, loading the regulator sub-nodes.
Signed-off-by: Neil Armstrong narmstrong@baylibre.com
Applied to u-boot/master, thanks!

On 4/27/22 20:28, Neil Armstrong wrote:
The TPS65219 I2S PMIC features 3 Buck converters and 4 linear regulators, 2 GPOs, 1 GPIO, and 3 multi-function-pin.
This adds the PMIC driver, loading the regulator sub-nodes.
Signed-off-by: Neil Armstrong narmstrong@baylibre.com
drivers/power/pmic/Kconfig | 6 +++ drivers/power/pmic/Makefile | 1 + drivers/power/pmic/tps65219.c | 88 +++++++++++++++++++++++++++++++++++ include/power/tps65219.h | 46 ++++++++++++++++++ 4 files changed, 141 insertions(+) create mode 100644 drivers/power/pmic/tps65219.c create mode 100644 include/power/tps65219.h
diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig index 953c92e212..bb3960020d 100644 --- a/drivers/power/pmic/Kconfig +++ b/drivers/power/pmic/Kconfig @@ -367,6 +367,12 @@ config PMIC_TPS65941 The TPS65941 is a PMIC containing a bunch of SMPS & LDOs. This driver binds the pmic children.
+config PMIC_TPS65219
- bool "Enable driver for Texas Instruments TPS65219 PMIC"
- depends on DM_PMIC
- help
- The TPS65219 is a PMIC containing a bunch of SMPS & LDOs.
- This driver binds the pmic children.
endif
config PMIC_TPS65217 diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile index 584d6e0e78..f73b326255 100644 --- a/drivers/power/pmic/Makefile +++ b/drivers/power/pmic/Makefile @@ -43,3 +43,4 @@ obj-$(CONFIG_POWER_TPS65910) += pmic_tps65910.o obj-$(CONFIG_POWER_HI6553) += pmic_hi6553.o obj-$(CONFIG_POWER_MC34VR500) += pmic_mc34vr500.o obj-$(CONFIG_PMIC_TPS65941) += tps65941.o +obj-$(CONFIG_PMIC_TPS65219) += tps65219.o diff --git a/drivers/power/pmic/tps65219.c b/drivers/power/pmic/tps65219.c new file mode 100644 index 0000000000..9462afee77 --- /dev/null +++ b/drivers/power/pmic/tps65219.c @@ -0,0 +1,88 @@ +// SPDX-License-Identifier: GPL-2.0+ +/*
- (C) Copyright 2022 BayLibre, SAS
- Author: Neil Armstrong narmstrong@baylibre.com
- */
+#include <common.h> +#include <fdtdec.h> +#include <errno.h> +#include <dm.h> +#include <i2c.h> +#include <log.h> +#include <power/pmic.h> +#include <power/regulator.h> +#include <power/tps65219.h> +#include <dm/device.h>
+static const struct pmic_child_info pmic_children_info[] = {
- { .prefix = "ldo", .driver = TPS65219_LDO_DRIVER },
- { .prefix = "buck", .driver = TPS65219_BUCK_DRIVER },
- { },
+};
+static int tps65219_reg_count(struct udevice *dev) +{
- return 0x41;
+}
+static int tps65219_write(struct udevice *dev, uint reg, const uint8_t *buff,
int len)
+{
- if (dm_i2c_write(dev, reg, buff, len)) {
pr_err("write error to device: %p register: %#x!\n", dev, reg);
return -EIO;
- }
- return 0;
+}
+static int tps65219_read(struct udevice *dev, uint reg, uint8_t *buff, int len) +{
- if (dm_i2c_read(dev, reg, buff, len)) {
pr_err("read error from device: %p register: %#x!\n", dev, reg);
return -EIO;
- }
- return 0;
+}
+static int tps65219_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!\n", __func__,
dev->name);
- }
- debug("%s: '%s' - found regulators subnode\n", __func__, dev->name);
Its sequence is strange.
If ofnode_valid is not valid, it should be displayed..
"regulator subnode not found" "found regulator subnode"
It can be confused.
- children = pmic_bind_children(dev, regulators_node, pmic_children_info);
- if (!children)
printf("%s: %s - no child found\n", __func__, dev->name);
Is there any reason to use "printf" ?
Best Regards, Jaehoon Chung
- /* Probe all the child devices */
- return dm_scan_fdt_dev(dev);
+}
+static struct dm_pmic_ops tps65219_ops = {
- .reg_count = tps65219_reg_count,
- .read = tps65219_read,
- .write = tps65219_write,
+};
+static const struct udevice_id tps65219_ids[] = {
- { .compatible = "ti,tps65219" },
- { }
+};
+U_BOOT_DRIVER(pmic_tps65219) = {
- .name = "tps65219_pmic",
- .id = UCLASS_PMIC,
- .of_match = tps65219_ids,
- .bind = tps65219_bind,
- .ops = &tps65219_ops,
+}; diff --git a/include/power/tps65219.h b/include/power/tps65219.h new file mode 100644 index 0000000000..aa81b92266 --- /dev/null +++ b/include/power/tps65219.h @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/*
- (C) Copyright 2022 BayLibre, SAS
- Author: Neil Armstrong narmstrong@baylibre.com
- */
+#ifndef TPS65219_H +#define TPS65219_H
+/* I2C device address for pmic tps65219 */ +#define TPS65219_I2C_ADDR 0x30 +#define TPS65219_LDO_NUM 4 +#define TPS65219_BUCK_NUM 3
+/* Drivers name */ +#define TPS65219_LDO_DRIVER "tps65219_ldo" +#define TPS65219_BUCK_DRIVER "tps65219_buck"
+#define TPS65219_VOLT_MASK 0x3F +#define TPS65219_BUCK_VOLT_MAX 3400000
+#define TPS65219_ENABLE_CTRL_REG 0x2
+#define TPS65219_BUCK1_VOUT_REG 0xa +#define TPS65219_BUCK2_VOUT_REG 0x9 +#define TPS65219_BUCK3_VOUT_REG 0x8
+#define TPS65219_LDO1_VOUT_REG 0x7 +#define TPS65219_LDO2_VOUT_REG 0x6
+#define TPS65219_LDO12_BYP_CONFIG 6
+#define TPS65219_LDO3_VOUT_REG 0x5 +#define TPS65219_LDO4_VOUT_REG 0x4
+#define TPS65219_LDO12_VOLT_BYP_MIN 1500000 +#define TPS65219_LDO12_VOLT_MIN 600000 +#define TPS65219_LDO12_VOLT_MAX 3400000 +#define TPS65219_LDO12_VOLT_REG_MIN 0 +#define TPS65219_LDO12_VOLT_REG_MAX 0x56 +#define TPS65219_LDO34_VOLT_MIN 1200000 +#define TPS65219_LDO34_VOLT_MAX 3300000 +#define TPS65219_LDO34_VOLT_REG_MIN 0x12 +#define TPS65219_LDO34_VOLT_REG_MAX 0x54
+#endif /* TPS65219_H */

The TPS65219 I2S PMIC features 3 Buck converters and 4 linear regulators, 2 GPOs, 1 GPIO, and 3 multi-function-pin.
This adds the driver for the Buck converters & linear regulators.
Signed-off-by: Neil Armstrong narmstrong@baylibre.com --- drivers/power/regulator/Kconfig | 9 + drivers/power/regulator/Makefile | 1 + drivers/power/regulator/tps65219_regulator.c | 380 +++++++++++++++++++ 3 files changed, 390 insertions(+) create mode 100644 drivers/power/regulator/tps65219_regulator.c
diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig index cd253b95f2..9145408b3c 100644 --- a/drivers/power/regulator/Kconfig +++ b/drivers/power/regulator/Kconfig @@ -371,3 +371,12 @@ config DM_REGULATOR_SCMI help Enable this option if you want to support regulators exposed through the SCMI voltage domain protocol by a SCMI server. + +config DM_REGULATOR_TPS65219 + bool "Enable driver for TPS65219 PMIC regulators" + depends on PMIC_TPS65219 + help + This enables implementation of driver-model regulator uclass + features for REGULATOR TPS65219 and the family of TPS65219 PMICs. + TPS65219 series of PMICs have 3 single phase BUCKs & 4 LDOs. + The driver implements get/set api for value and enable. diff --git a/drivers/power/regulator/Makefile b/drivers/power/regulator/Makefile index 4efb32a322..b9883df928 100644 --- a/drivers/power/regulator/Makefile +++ b/drivers/power/regulator/Makefile @@ -32,3 +32,4 @@ obj-$(CONFIG_$(SPL_)DM_REGULATOR_STPMIC1) += stpmic1.o obj-$(CONFIG_DM_REGULATOR_TPS65941) += tps65941_regulator.o obj-$(CONFIG_DM_REGULATOR_SCMI) += scmi_regulator.o obj-$(CONFIG_$(SPL_)DM_REGULATOR_ANATOP) += anatop_regulator.o +obj-$(CONFIG_DM_REGULATOR_TPS65219) += tps65219_regulator.o diff --git a/drivers/power/regulator/tps65219_regulator.c b/drivers/power/regulator/tps65219_regulator.c new file mode 100644 index 0000000000..023cf211fc --- /dev/null +++ b/drivers/power/regulator/tps65219_regulator.c @@ -0,0 +1,380 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2022 BayLibre, SAS + * Author: Neil Armstrong narmstrong@baylibre.com + * + */ + +#include <common.h> +#include <fdtdec.h> +#include <errno.h> +#include <dm.h> +#include <i2c.h> +#include <log.h> +#include <linux/delay.h> +#include <power/pmic.h> +#include <power/regulator.h> +#include <power/tps65219.h> + +static const unsigned int tps65219_buck_vout[TPS65219_BUCK_NUM] = { + [0] = TPS65219_BUCK1_VOUT_REG, + [1] = TPS65219_BUCK2_VOUT_REG, + [2] = TPS65219_BUCK3_VOUT_REG +}; + +static const unsigned int tps65219_ldo_vout[TPS65219_LDO_NUM] = { + [0] = TPS65219_LDO1_VOUT_REG, + [1] = TPS65219_LDO2_VOUT_REG, + [2] = TPS65219_LDO3_VOUT_REG, + [3] = TPS65219_LDO4_VOUT_REG, +}; + +static int tps65219_reg_enable(struct udevice *dev, unsigned int adr, int idx, + int op, bool *enable) +{ + int ret; + + ret = pmic_reg_read(dev->parent, adr); + if (ret < 0) + return ret; + + if (op == PMIC_OP_GET) { + if (ret & BIT(idx)) + *enable = true; + else + *enable = false; + + return 0; + } else if (op == PMIC_OP_SET) { + if (*enable) + ret |= BIT(idx); + else + ret &= ~BIT(idx); + + ret = pmic_reg_write(dev->parent, adr, ret); + if (ret) + return ret; + } + + return 0; +} + +static int tps65219_buck_enable(struct udevice *dev, int op, bool *enable) +{ + unsigned int adr; + struct dm_regulator_uclass_plat *uc_pdata; + int idx; + + idx = dev->driver_data - 1; + uc_pdata = dev_get_uclass_plat(dev); + adr = uc_pdata->ctrl_reg; + + return tps65219_reg_enable(dev, adr, idx, op, enable); +} + +static int tps65219_buck_volt2val(int uV) +{ + if (uV > TPS65219_BUCK_VOLT_MAX) + return -EINVAL; + else if (uV >= 1400000) + return (uV - 1400000) / 100000 + 0x20; + else if (uV >= 600000) + return (uV - 600000) / 25000 + 0x00; + else + return -EINVAL; +} + +static int tps65219_buck_val2volt(int val) +{ + if (val > TPS65219_VOLT_MASK) + return -EINVAL; + else if (val > 0x34) + return TPS65219_BUCK_VOLT_MAX; + else if (val > 0x20) + return 1400000 + (val - 0x20) * 100000; + else if (val >= 0) + return 600000 + val * 25000; + else + return -EINVAL; +} + +static int tps65219_buck_val(struct udevice *dev, int op, int *uV) +{ + unsigned int adr; + int ret, val; + struct dm_regulator_uclass_plat *uc_pdata; + + uc_pdata = dev_get_uclass_plat(dev); + adr = uc_pdata->volt_reg; + + ret = pmic_reg_read(dev->parent, adr); + if (ret < 0) + return ret; + + if (op == PMIC_OP_GET) { + *uV = 0; + + ret &= TPS65219_VOLT_MASK; + ret = tps65219_buck_val2volt(ret); + if (ret < 0) + return ret; + + *uV = ret; + return 0; + } + + val = tps65219_buck_volt2val(*uV); + if (val < 0) + return val; + + ret &= ~TPS65219_VOLT_MASK; + ret |= val; + + ret = pmic_reg_write(dev->parent, adr, ret); + + udelay(100); + + return ret; +} + +static int tps65219_ldo_enable(struct udevice *dev, int op, bool *enable) +{ + unsigned int adr; + struct dm_regulator_uclass_plat *uc_pdata; + int idx; + + idx = TPS65219_BUCK_NUM + (dev->driver_data - 1); + uc_pdata = dev_get_uclass_plat(dev); + adr = uc_pdata->ctrl_reg; + + return tps65219_reg_enable(dev, adr, idx, op, enable); +} + +static int tps65219_ldo_volt2val(int idx, int uV) +{ + int base = TPS65219_LDO12_VOLT_MIN; + int max = TPS65219_LDO12_VOLT_MAX; + + if (idx > 1) { + base = TPS65219_LDO34_VOLT_MIN; + max = TPS65219_LDO34_VOLT_MAX; + } + + if (uV > max) + return -EINVAL; + else if (uV >= base) + return (uV - TPS65219_LDO12_VOLT_MIN) / 50000; + else + return -EINVAL; +} + +static int tps65219_ldo_val2volt(int idx, int val) +{ + int reg_base = TPS65219_LDO12_VOLT_REG_MIN; + int reg_max = TPS65219_LDO12_VOLT_REG_MAX; + int base = TPS65219_LDO12_VOLT_MIN; + int max = TPS65219_LDO12_VOLT_MAX; + + if (idx > 1) { + base = TPS65219_LDO34_VOLT_MIN; + max = TPS65219_LDO34_VOLT_MAX; + reg_base = TPS65219_LDO34_VOLT_REG_MIN; + reg_max = TPS65219_LDO34_VOLT_REG_MAX; + } + + if (val > TPS65219_VOLT_MASK || val < 0) + return -EINVAL; + else if (val >= reg_max) + return max; + else if (val <= reg_base) + return base; + else if (val >= 0) + return TPS65219_LDO12_VOLT_MIN + (50000 * val); + else + return -EINVAL; +} + +static int tps65219_ldo_val(struct udevice *dev, int op, int *uV) +{ + unsigned int adr; + int ret, val; + struct dm_regulator_uclass_plat *uc_pdata; + int idx; + + idx = dev->driver_data - 1; + uc_pdata = dev_get_uclass_plat(dev); + adr = uc_pdata->volt_reg; + + ret = pmic_reg_read(dev->parent, adr); + if (ret < 0) + return ret; + + if (op == PMIC_OP_GET) { + *uV = 0; + + ret &= TPS65219_VOLT_MASK; + ret = tps65219_ldo_val2volt(idx, ret); + if (ret < 0) + return ret; + + *uV = ret; + return 0; + } + + /* LDO1 & LDO2 in BYPASS mode only supports 1.5V max */ + if (idx < 2 && + (ret & BIT(TPS65219_LDO12_BYP_CONFIG)) && + *uV < TPS65219_LDO12_VOLT_BYP_MIN) + return -EINVAL; + + val = tps65219_ldo_volt2val(idx, *uV); + if (val < 0) + return val; + + ret &= ~TPS65219_VOLT_MASK; + ret |= val; + + ret = pmic_reg_write(dev->parent, adr, ret); + + udelay(100); + + return ret; +} + +static int tps65219_ldo_probe(struct udevice *dev) +{ + struct dm_regulator_uclass_plat *uc_pdata; + int idx; + + uc_pdata = dev_get_uclass_plat(dev); + uc_pdata->type = REGULATOR_TYPE_LDO; + + /* idx must be in 1..TPS65219_LDO_NUM */ + idx = dev->driver_data; + if (idx < 1 || idx > TPS65219_LDO_NUM) { + printf("Wrong ID for regulator\n"); + return -EINVAL; + } + + uc_pdata->ctrl_reg = TPS65219_ENABLE_CTRL_REG; + uc_pdata->volt_reg = tps65219_ldo_vout[idx - 1]; + + return 0; +} + +static int tps65219_buck_probe(struct udevice *dev) +{ + struct dm_regulator_uclass_plat *uc_pdata; + int idx; + + uc_pdata = dev_get_uclass_plat(dev); + uc_pdata->type = REGULATOR_TYPE_BUCK; + + /* idx must be in 1..TPS65219_BUCK_NUM */ + idx = dev->driver_data; + if (idx < 1 || idx > TPS65219_BUCK_NUM) { + printf("Wrong ID for regulator\n"); + return -EINVAL; + } + + uc_pdata->ctrl_reg = TPS65219_ENABLE_CTRL_REG; + uc_pdata->volt_reg = tps65219_buck_vout[idx - 1]; + + return 0; +} + +static int ldo_get_value(struct udevice *dev) +{ + int uV; + int ret; + + ret = tps65219_ldo_val(dev, PMIC_OP_GET, &uV); + if (ret) + return ret; + + return uV; +} + +static int ldo_set_value(struct udevice *dev, int uV) +{ + return tps65219_ldo_val(dev, PMIC_OP_SET, &uV); +} + +static int ldo_get_enable(struct udevice *dev) +{ + bool enable = false; + int ret; + + ret = tps65219_ldo_enable(dev, PMIC_OP_GET, &enable); + if (ret) + return ret; + + return enable; +} + +static int ldo_set_enable(struct udevice *dev, bool enable) +{ + return tps65219_ldo_enable(dev, PMIC_OP_SET, &enable); +} + +static int buck_get_value(struct udevice *dev) +{ + int uV; + int ret; + + ret = tps65219_buck_val(dev, PMIC_OP_GET, &uV); + if (ret) + return ret; + + return uV; +} + +static int buck_set_value(struct udevice *dev, int uV) +{ + return tps65219_buck_val(dev, PMIC_OP_SET, &uV); +} + +static int buck_get_enable(struct udevice *dev) +{ + bool enable = false; + int ret; + + ret = tps65219_buck_enable(dev, PMIC_OP_GET, &enable); + if (ret) + return ret; + + return enable; +} + +static int buck_set_enable(struct udevice *dev, bool enable) +{ + return tps65219_buck_enable(dev, PMIC_OP_SET, &enable); +} + +static const struct dm_regulator_ops tps65219_ldo_ops = { + .get_value = ldo_get_value, + .set_value = ldo_set_value, + .get_enable = ldo_get_enable, + .set_enable = ldo_set_enable, +}; + +U_BOOT_DRIVER(tps65219_ldo) = { + .name = TPS65219_LDO_DRIVER, + .id = UCLASS_REGULATOR, + .ops = &tps65219_ldo_ops, + .probe = tps65219_ldo_probe, +}; + +static const struct dm_regulator_ops tps65219_buck_ops = { + .get_value = buck_get_value, + .set_value = buck_set_value, + .get_enable = buck_get_enable, + .set_enable = buck_set_enable, +}; + +U_BOOT_DRIVER(tps65219_buck) = { + .name = TPS65219_BUCK_DRIVER, + .id = UCLASS_REGULATOR, + .ops = &tps65219_buck_ops, + .probe = tps65219_buck_probe, +};

On Wed, Apr 27, 2022 at 01:28:10PM +0200, Neil Armstrong wrote:
The TPS65219 I2S PMIC features 3 Buck converters and 4 linear regulators, 2 GPOs, 1 GPIO, and 3 multi-function-pin.
This adds the driver for the Buck converters & linear regulators.
Signed-off-by: Neil Armstrong narmstrong@baylibre.com
Applied to u-boot/master, thanks!

The E4 revision of the AM64 SKEVM embeds a TPS65219 PMIC, this enables the necessary options to load and control the PMIC regulators.
Signed-off-by: Neil Armstrong narmstrong@baylibre.com --- configs/am64x_evm_a53_defconfig | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/configs/am64x_evm_a53_defconfig b/configs/am64x_evm_a53_defconfig index 4149921afe..2863eea3c4 100644 --- a/configs/am64x_evm_a53_defconfig +++ b/configs/am64x_evm_a53_defconfig @@ -61,6 +61,8 @@ CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y CONFIG_CMD_USB=y CONFIG_CMD_TIME=y +CONFIG_CMD_PMIC=y +CONFIG_CMD_REGULATOR=y CONFIG_OF_CONTROL=y CONFIG_SPL_OF_CONTROL=y CONFIG_OF_LIST="k3-am642-evm k3-am642-sk" @@ -121,6 +123,10 @@ CONFIG_PINCTRL_SINGLE=y CONFIG_POWER_DOMAIN=y CONFIG_TI_SCI_POWER_DOMAIN=y CONFIG_K3_SYSTEM_CONTROLLER=y +CONFIG_DM_PMIC=y +CONFIG_PMIC_TPS65219=y +CONFIG_DM_REGULATOR=y +CONFIG_DM_REGULATOR_TPS65219=y CONFIG_REMOTEPROC_TI_K3_ARM64=y CONFIG_DM_RESET=y CONFIG_RESET_TI_SCI=y

On Wed, Apr 27, 2022 at 01:28:11PM +0200, Neil Armstrong wrote:
The E4 revision of the AM64 SKEVM embeds a TPS65219 PMIC, this enables the necessary options to load and control the PMIC regulators.
Signed-off-by: Neil Armstrong narmstrong@baylibre.com
Applied to u-boot/master, thanks!

The E4 revision of the AM64 SKEVM embeds a TPS65219 PMIC, this adds the PMIC node with the required regulators voltages.
Signed-off-by: Neil Armstrong narmstrong@baylibre.com --- arch/arm/dts/k3-am642-sk-u-boot.dtsi | 61 ++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+)
diff --git a/arch/arm/dts/k3-am642-sk-u-boot.dtsi b/arch/arm/dts/k3-am642-sk-u-boot.dtsi index afe5baba8c..6504228136 100644 --- a/arch/arm/dts/k3-am642-sk-u-boot.dtsi +++ b/arch/arm/dts/k3-am642-sk-u-boot.dtsi @@ -48,6 +48,67 @@ pinctrl-names = "default"; pinctrl-0 = <&main_i2c0_pins_default>; clock-frequency = <400000>; + + tps65219: pmic@30 { + compatible = "ti,tps65219"; + reg = <0x30>; + + regulators { + buck1_reg: buck1 { + regulator-name = "VDD_CORE"; + regulator-min-microvolt = <750000>; + regulator-max-microvolt = <750000>; + regulator-boot-on; + regulator-always-on; + }; + + buck2_reg: buck2 { + regulator-name = "VCC1V8"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-boot-on; + regulator-always-on; + }; + + buck3_reg: buck3 { + regulator-name = "VDD_LPDDR4"; + regulator-min-microvolt = <1100000>; + regulator-max-microvolt = <1100000>; + regulator-boot-on; + regulator-always-on; + }; + + ldo1_reg: ldo1 { + regulator-name = "VDDSHV_SD_IO_PMIC"; + regulator-min-microvolt = <33000000>; + regulator-max-microvolt = <33000000>; + }; + + ldo2_reg: ldo2 { + regulator-name = "VDDAR_CORE"; + regulator-min-microvolt = <850000>; + regulator-max-microvolt = <850000>; + regulator-boot-on; + regulator-always-on; + }; + + ldo3_reg: ldo3 { + regulator-name = "VDDA_1V8"; + regulator-min-microvolt = <18000000>; + regulator-max-microvolt = <18000000>; + regulator-boot-on; + regulator-always-on; + }; + + ldo4_reg: ldo4 { + regulator-name = "VDD_PHY_2V5"; + regulator-min-microvolt = <25000000>; + regulator-max-microvolt = <25000000>; + regulator-boot-on; + regulator-always-on; + }; + }; + }; };
&main_uart0 {

On Wed, Apr 27, 2022 at 01:28:12PM +0200, Neil Armstrong wrote:
The E4 revision of the AM64 SKEVM embeds a TPS65219 PMIC, this adds the PMIC node with the required regulators voltages.
Signed-off-by: Neil Armstrong narmstrong@baylibre.com
Applied to u-boot/master, thanks!
participants (3)
-
Jaehoon Chung
-
Neil Armstrong
-
Tom Rini