regulator: palmas: Disable bypass for ldo1 and ldo2
authorKishon Vijay Abraham I <kishon@ti.com>
Wed, 7 Nov 2018 05:55:14 +0000 (11:25 +0530)
committerTero Kristo <t-kristo@ti.com>
Wed, 7 Nov 2018 07:51:01 +0000 (09:51 +0200)
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>
drivers/regulator/palmas-regulator.c

index bb5ab7d78895b817a9d42e03e6bd890d6b99e33e..c9368a245a58aaeff47e67be1a10dcf6095e20fa 100644 (file)
@@ -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;