]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
regulator: palmas: disable bypass when the LDO is enabled
authorJean-Jacques Hiblot <jjhiblot@ti.com>
Wed, 12 Jul 2017 09:42:47 +0000 (11:42 +0200)
committerJaehoon Chung <jh80.chung@samsung.com>
Tue, 1 Aug 2017 02:58:01 +0000 (11:58 +0900)
Some LDOs have a bypass capability. Make sure that the bypass is disabled
when is the LDO is enabled (otherwise the voltage can't be changed).

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Keerthy <j-keerthy@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
drivers/power/regulator/palmas_regulator.c
include/power/palmas.h

index 99614b0c58fb60cbc15ff98ce3ab3bc04148595d..24a797723632d81be5a468647b6746bc1b2704bb 100644 (file)
@@ -163,6 +163,38 @@ static int palmas_smps_val(struct udevice *dev, int op, int *uV)
        return pmic_reg_write(dev->parent, adr, ret);
 }
 
+static int palmas_ldo_bypass_enable(struct udevice *dev, bool enabled)
+{
+       int type = dev_get_driver_data(dev_get_parent(dev));
+       struct dm_regulator_uclass_platdata *p;
+       unsigned int adr;
+       int reg;
+
+       if (type == TPS65917) {
+               /* bypass available only on LDO1 and LDO2 */
+               if (dev->driver_data > 2)
+                       return -ENOTSUPP;
+       } else if (type == TPS659038) {
+               /* bypass available only on LDO9 */
+               if (dev->driver_data != 9)
+                       return -ENOTSUPP;
+       }
+
+       p = dev_get_uclass_platdata(dev);
+       adr = p->ctrl_reg;
+
+       reg = pmic_reg_read(dev->parent, adr);
+       if (reg < 0)
+               return reg;
+
+       if (enabled)
+               reg |= PALMAS_LDO_BYPASS_EN;
+       else
+               reg &= ~PALMAS_LDO_BYPASS_EN;
+
+       return pmic_reg_write(dev->parent, adr, reg);
+}
+
 static int palmas_ldo_enable(struct udevice *dev, int op, bool *enable)
 {
        int ret;
@@ -194,6 +226,10 @@ static int palmas_ldo_enable(struct udevice *dev, int op, bool *enable)
                ret = pmic_reg_write(dev->parent, adr, ret);
                if (ret)
                        return ret;
+
+               ret = palmas_ldo_bypass_enable(dev, false);
+               if (ret && (ret != -ENOTSUPP))
+                       return ret;
        }
 
        return 0;
index bad5a354d31e856f569eb0f1b5f76f3217817a22..df5f15c5bd672e8c11e18a2a703c0eded21a370a 100644 (file)
@@ -23,3 +23,4 @@
 #define PALMAS_LDO_VOLT_MAX     3300000
 #define PALMAS_LDO_MODE_MASK   0x1
 #define PALMAS_LDO_STATUS_MASK 0x10
+#define PALMAS_LDO_BYPASS_EN   0x40