Эх сурвалжийг харах

regulator: palmas: Disable bypass for ldo1 and ldo2

ldo1 and ldo2 have bypass capability. The regulator framework starts
with assuming that bypass is disabled by default. In this particular
case the bypass OTP is 1. So one cannot disable without first enabling
due to the use count going negative. Hence doing a one time disable at
boot.

Any consumer which wants bypass to be enabled/disabled can use the
bypass_enable/bypass_disable functions to turn on or turn off bypass
subsequently.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Keerthy <j-keerthy@ti.com>
Kishon Vijay Abraham I 7 жил өмнө
parent
commit
2285e18e24

+ 24 - 0
drivers/regulator/palmas-regulator.c

@@ -1021,6 +1021,7 @@ static int tps65917_ldo_registration(struct palmas_pmic *pmic,
 	struct palmas_reg_init *reg_init;
 	struct palmas_regs_info *rinfo;
 	struct regulator_desc *desc;
+	unsigned int reg;
 
 	for (id = ddata->ldo_begin; id < ddata->max_reg; id++) {
 		if (pdata && pdata->reg_init[id])
@@ -1069,6 +1070,29 @@ static int tps65917_ldo_registration(struct palmas_pmic *pmic,
 						TPS65917_LDO1_CTRL_BYPASS_EN;
 				desc->bypass_mask =
 						TPS65917_LDO1_CTRL_BYPASS_EN;
+
+				/*
+				 * OTP Values are set to bypass enable.
+				 * Switch to disable so that use count
+				 * does not go negative while directly
+				 * disabling bypass.
+				 */
+				ret = palmas_ldo_read(pmic->palmas,
+						      rinfo->ctrl_addr, &reg);
+				if (ret) {
+					dev_err(pmic->dev,
+						"Error reading ldo1 reg\n");
+					return ret;
+				}
+				reg &= ~TPS65917_LDO1_CTRL_BYPASS_EN;
+				ret = palmas_ldo_write(pmic->palmas,
+						       rinfo->ctrl_addr, reg);
+				if (ret) {
+					dev_err(pmic->dev,
+						"Error writing ldo1 reg\n");
+					return ret;
+				}
+
 			}
 		} else {
 			desc->n_voltages = 1;