diff mbox series

[v1,1/4] power: pmic: Modify the BUCK1 voltage range

Message ID 20230605094825.160337-2-joy.zou@nxp.com
State Changes Requested
Delegated to: Stefano Babic
Headers show
Series support trimed pca9450 new pmic | expand

Commit Message

Joy Zou June 5, 2023, 9:48 a.m. UTC
The new pmic trimed BUCK1. So need to modify the range.
The default value of Toff_Deb is used to distinguish the old and new pmic.

Signed-off-by: Joy Zou <joy.zou@nxp.com>
---
 drivers/power/regulator/pca9450.c | 29 ++++++++++++++++++++++++++++-
 include/power/pca9450.h           |  2 ++
 2 files changed, 30 insertions(+), 1 deletion(-)

Comments

Joy Zou June 5, 2023, 10:20 a.m. UTC | #1
> -----Original Message-----
> From: Marek Vasut <marex@denx.de>
> Sent: 2023年6月5日 18:07
> To: Joy Zou <joy.zou@nxp.com>; jh80.chung@samsung.com; Peng Fan
> <peng.fan@nxp.com>; Ye Li <ye.li@nxp.com>; Jacky Bai <ping.bai@nxp.com>;
> festevam@denx.de; sbabic@denx.de; heiko.thiery@gmail.com
> Cc: u-boot@lists.denx.de; dl-uboot-imx <uboot-imx@nxp.com>
> Subject: [EXT] Re: [PATCH v1 1/4] power: pmic: Modify the BUCK1 voltage
> range
> 
> Caution: This is an external email. Please take care when clicking links or
> opening attachments. When in doubt, report the message using the 'Report
> this email' button
> 
> 
> On 6/5/23 11:48, Joy Zou wrote:
> > The new pmic trimed BUCK1. So need to modify the range.
> > The default value of Toff_Deb is used to distinguish the old and new pmic.
> 
> [...]
> 
> > +++ b/include/power/pca9450.h
> > @@ -63,6 +63,8 @@ enum {
> >       NXP_CHIP_TYPE_AMOUNT
> >   };
> >
> > +#define PCA9450_REG_PWRCTRL_TOFF_DEB    BIT(5)
> > +
> >   #define PCA9450_DVS_BUCK_RUN_MASK   0x7f
> >   #define PCA9450_LDO12_MASK          0x07
> >   #define PCA9450_LDO34_MASK          0x1f
> 
> Shouldn't there be a new DT compatible, 'nxp,pca9451a' somewhere ?
> Like e.g. in drivers/power/pmic/pca9450.c ?
Hi Marek,
The file drivers/power/pmic/pca9450.c and DT compatible 'nxp,pca9451a' already exists. 
Recently, the BUCK1 of the PMIC pca9451a is trimmed. So need to update.
Thanks!
BR
Joy Zou
diff mbox series

Patch

diff --git a/drivers/power/regulator/pca9450.c b/drivers/power/regulator/pca9450.c
index 7ca20d1f7f..f0b92ca037 100644
--- a/drivers/power/regulator/pca9450.c
+++ b/drivers/power/regulator/pca9450.c
@@ -72,6 +72,10 @@  static struct pca9450_vrange pca9450_buck123_vranges[] = {
 	PCA_RANGE(600000, 12500, 0, 0x7f),
 };
 
+static struct pca9450_vrange pca9450_trim_buck13_vranges[] = {
+	PCA_RANGE(650000, 12500, 0, 0x7f),
+};
+
 static struct pca9450_vrange pca9450_buck456_vranges[] = {
 	PCA_RANGE(600000, 25000, 0, 0x70),
 	PCA_RANGE(3400000, 0, 0x71, 0x7f),
@@ -106,12 +110,18 @@  static struct pca9450_plat pca9450_reg_data[] = {
 	PCA_DATA("BUCK1", PCA9450_BUCK1CTRL, HW_STATE_CONTROL,
 		 PCA9450_BUCK1OUT_DVS0, PCA9450_DVS_BUCK_RUN_MASK,
 		 pca9450_buck123_vranges),
+	PCA_DATA("BUCK1_TRIM", PCA9450_BUCK1CTRL, HW_STATE_CONTROL,
+		 PCA9450_BUCK1OUT_DVS0, PCA9450_DVS_BUCK_RUN_MASK,
+		 pca9450_trim_buck13_vranges),
 	PCA_DATA("BUCK2", PCA9450_BUCK2CTRL, HW_STATE_CONTROL,
 		 PCA9450_BUCK2OUT_DVS0, PCA9450_DVS_BUCK_RUN_MASK,
 		 pca9450_buck123_vranges),
 	PCA_DATA("BUCK3", PCA9450_BUCK3CTRL, HW_STATE_CONTROL,
 		 PCA9450_BUCK3OUT_DVS0, PCA9450_DVS_BUCK_RUN_MASK,
 		 pca9450_buck123_vranges),
+	PCA_DATA("BUCK3_TRIM", PCA9450_BUCK3CTRL, HW_STATE_CONTROL,
+		 PCA9450_BUCK3OUT_DVS0, PCA9450_DVS_BUCK_RUN_MASK,
+		 pca9450_trim_buck13_vranges),
 	/* Bucks 4-6 which do not support dynamic voltage scaling */
 	PCA_DATA("BUCK4", PCA9450_BUCK4CTRL, HW_STATE_CONTROL,
 		 PCA9450_BUCK4OUT, PCA9450_DVS_BUCK_RUN_MASK,
@@ -272,7 +282,9 @@  static int pca9450_set_value(struct udevice *dev, int uvolt)
 static int pca9450_regulator_probe(struct udevice *dev)
 {
 	struct pca9450_plat *plat = dev_get_plat(dev);
-	int i, type;
+	int i, type, ret;
+	unsigned int val;
+	bool pmic_trim = false;
 
 	type = dev_get_driver_data(dev_get_parent(dev));
 
@@ -282,10 +294,25 @@  static int pca9450_regulator_probe(struct udevice *dev)
 		return -EINVAL;
 	}
 
+	ret = pmic_reg_read(dev->parent, PCA9450_PWR_CTRL);
+	if (ret < 0)
+		return ret;
+	else
+		val = ret;
+
+	if (type == NXP_CHIP_TYPE_PCA9451A && (val & PCA9450_REG_PWRCTRL_TOFF_DEB))
+		pmic_trim = true;
+
 	for (i = 0; i < ARRAY_SIZE(pca9450_reg_data); i++) {
 		if (strcmp(dev->name, pca9450_reg_data[i].name))
 			continue;
 
+		if (pmic_trim && (!strcmp(pca9450_reg_data[i].name, "BUCK1") ||
+				  !strcmp(pca9450_reg_data[i].name, "BUCK3"))) {
+			*plat = pca9450_reg_data[i + 1];
+			return 0;
+		}
+
 		/* PCA9450B/PCA9450C uses BUCK1 and BUCK3 in dual-phase */
 		if (type == NXP_CHIP_TYPE_PCA9450BC &&
 		    !strcmp(pca9450_reg_data[i].name, "BUCK3")) {
diff --git a/include/power/pca9450.h b/include/power/pca9450.h
index b8219d535a..8b62f4e5e1 100644
--- a/include/power/pca9450.h
+++ b/include/power/pca9450.h
@@ -63,6 +63,8 @@  enum {
 	NXP_CHIP_TYPE_AMOUNT
 };
 
+#define PCA9450_REG_PWRCTRL_TOFF_DEB    BIT(5)
+
 #define PCA9450_DVS_BUCK_RUN_MASK	0x7f
 #define PCA9450_LDO12_MASK		0x07
 #define PCA9450_LDO34_MASK		0x1f