Skip to contentSkip to conversation

Add support for TPS65219 PMIC on AM64X-SKEVM

PATCH In review Neil Armstrong 3 participants 10 messages Apr 27, 2022 – May 16, 2022 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

cover 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
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/4 power: add driver for the TPS65219 PMIC

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.

---
 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
drivers/power/pmic/Kconfig +6 -0
index 953c92e212..bb3960020d 100644
@@ -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
drivers/power/pmic/Makefile +1 -0
index 584d6e0e78..f73b326255 100644
@@ -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
drivers/power/pmic/tps65219.c new file +88 -0

88 lines not on this page · raw message

include/power/tps65219.h new file +46 -0

46 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH 1/4] power: add driver for the TPS65219 PMIC

Quoted 6 lines · Neil Armstrong

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.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#3 lore raw

Re: [PATCH 1/4] power: add driver for the TPS65219 PMIC

In reply to Neil Armstrong
Quoted 98 lines · Neil Armstrong

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.

---
 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
drivers/power/pmic/Kconfig +6 -0
index 953c92e212..bb3960020d 100644
@@ -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
drivers/power/pmic/Makefile +1 -0
index 584d6e0e78..f73b326255 100644
@@ -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
drivers/power/pmic/tps65219.c new file +51 -0
new file mode 100644
index 0000000000..9462afee77
@@ -0,0 +1,88 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2022 BayLibre, SAS
+ * Author: Neil Armstrong <[email protected]>
+ */
+
+#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)
+{

drivers/power/pmic/tps65219.c line 61

Quoted 10 lines
drivers/power/pmic/tps65219.c new file +10 -0
+	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.

drivers/power/pmic/tps65219.c line 65

Quoted 4 lines
drivers/power/pmic/tps65219.c new file +4 -0
+
+	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

Quoted 75 lines
drivers/power/pmic/tps65219.c new file +23 -0
+
+	/* 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,
+};
include/power/tps65219.h new file +46 -0
new file mode 100644
index 0000000000..aa81b92266
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2022 BayLibre, SAS
+ * Author: Neil Armstrong <[email protected]>
+ */
+
+#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 */
#4 lore raw

PATCH 2/4 regulator: add driver for the TPS65219 BUCK & LDO regulators

In reply to Neil Armstrong

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.

---
 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
drivers/power/regulator/Kconfig +9 -0
index cd253b95f2..9145408b3c 100644
@@ -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.
drivers/power/regulator/Makefile +1 -0
index 4efb32a322..b9883df928 100644
@@ -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
drivers/power/regulator/tps65219_regulator.c new file +380 -0

380 lines not on this page · raw message

Signature · 1 line
2.25.1
#5 lore raw

Re: [PATCH 2/4] regulator: add driver for the TPS65219 BUCK & LDO regulators

Quoted 6 lines · Neil Armstrong

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.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#6 lore raw

PATCH 3/4 config: enable TPS65219 for am64x_evm_a53 boards

In reply to Neil Armstrong

The E4 revision of the AM64 SKEVM embeds a TPS65219 PMIC, this enables the necessary options to load and control the PMIC regulators.

---
 configs/am64x_evm_a53_defconfig | 6 ++++++
 1 file changed, 6 insertions(+)
configs/am64x_evm_a53_defconfig +6 -0
index 4149921afe..2863eea3c4 100644
@@ -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
Signature · 1 line
2.25.1
#7 lore raw

Re: [PATCH 3/4] config: enable TPS65219 for am64x_evm_a53 boards

Quoted 5 lines · Neil Armstrong

The E4 revision of the AM64 SKEVM embeds a TPS65219 PMIC, this enables the necessary options to load and control the PMIC regulators.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#8 lore raw

PATCH 4/4 ARM: dts: k3-am642-sk-u-boot: add PMIC node

In reply to Neil Armstrong

The E4 revision of the AM64 SKEVM embeds a TPS65219 PMIC, this adds the PMIC node with the required regulators voltages.

---
 arch/arm/dts/k3-am642-sk-u-boot.dtsi | 61 ++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)
arch/arm/dts/k3-am642-sk-u-boot.dtsi +61 -0
index afe5baba8c..6504228136 100644
@@ -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 {
Signature · 1 line
2.25.1
#9 lore raw

Re: [PATCH 4/4] ARM: dts: k3-am642-sk-u-boot: add PMIC node

Quoted 4 lines · Neil Armstrong

The E4 revision of the AM64 SKEVM embeds a TPS65219 PMIC, this adds the PMIC node with the required regulators voltages.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom