Merge remote-tracking branch 'regulator/for-5.11' into regulator-next
authorMark Brown <broonie@kernel.org>
Fri, 11 Dec 2020 17:48:32 +0000 (17:48 +0000)
committerMark Brown <broonie@kernel.org>
Fri, 11 Dec 2020 17:48:32 +0000 (17:48 +0000)
drivers/regulator/Kconfig
drivers/regulator/axp20x-regulator.c
drivers/regulator/core.c
drivers/regulator/pfuze100-regulator.c
drivers/regulator/ti-abb-regulator.c

index cb9333d4c0fd8c48cbba9fb167f3c532f6c038b5..53fa84f4d1e197f837e23029c0672c1a87171fcb 100644 (file)
@@ -880,7 +880,7 @@ config REGULATOR_QCOM_RPM
 
 config REGULATOR_QCOM_RPMH
        tristate "Qualcomm Technologies, Inc. RPMh regulator driver"
-       depends on QCOM_RPMH || COMPILE_TEST
+       depends on QCOM_RPMH || (QCOM_RPMH=n && COMPILE_TEST)
        help
          This driver supports control of PMIC regulators via the RPMh hardware
          block found on Qualcomm Technologies Inc. SoCs.  RPMh regulator
index cd1224182ad7435cdbcd60f174376516e2ac969f..90cb8445f721679b6d577d2ab71254a1226938d3 100644 (file)
@@ -594,7 +594,7 @@ static const struct regulator_desc axp22x_regulators[] = {
                 AXP22X_DLDO1_V_OUT, AXP22X_DLDO1_V_OUT_MASK,
                 AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO1_MASK),
        AXP_DESC(AXP22X, DLDO2, "dldo2", "dldoin", 700, 3300, 100,
-                AXP22X_DLDO2_V_OUT, AXP22X_PWR_OUT_DLDO2_MASK,
+                AXP22X_DLDO2_V_OUT, AXP22X_DLDO2_V_OUT_MASK,
                 AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO2_MASK),
        AXP_DESC(AXP22X, DLDO3, "dldo3", "dldoin", 700, 3300, 100,
                 AXP22X_DLDO3_V_OUT, AXP22X_DLDO3_V_OUT_MASK,
index 2d5d5f3bac6243d7ff9ad02a63e22fa513acf655..ca03d8e70bd1359f586e82aaa75878ecf58f75c7 100644 (file)
@@ -1315,7 +1315,6 @@ static int _regulator_do_enable(struct regulator_dev *rdev);
 /**
  * set_machine_constraints - sets regulator constraints
  * @rdev: regulator source
- * @constraints: constraints to apply
  *
  * Allows platform initialisation code to define and constrain
  * regulator circuits e.g. valid voltage/current ranges, etc.  NOTE:
@@ -1323,21 +1322,11 @@ static int _regulator_do_enable(struct regulator_dev *rdev);
  * regulator operations to proceed i.e. set_voltage, set_current_limit,
  * set_mode.
  */
-static int set_machine_constraints(struct regulator_dev *rdev,
-       const struct regulation_constraints *constraints)
+static int set_machine_constraints(struct regulator_dev *rdev)
 {
        int ret = 0;
        const struct regulator_ops *ops = rdev->desc->ops;
 
-       if (constraints)
-               rdev->constraints = kmemdup(constraints, sizeof(*constraints),
-                                           GFP_KERNEL);
-       else
-               rdev->constraints = kzalloc(sizeof(*constraints),
-                                           GFP_KERNEL);
-       if (!rdev->constraints)
-               return -ENOMEM;
-
        ret = machine_constraints_voltage(rdev, rdev->constraints);
        if (ret != 0)
                return ret;
@@ -1852,6 +1841,15 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
                }
        }
 
+       if (r == rdev) {
+               dev_err(dev, "Supply for %s (%s) resolved to itself\n",
+                       rdev->desc->name, rdev->supply_name);
+               if (!have_full_constraints())
+                       return -EINVAL;
+               r = dummy_regulator_rdev;
+               get_device(&r->dev);
+       }
+
        /*
         * If the supply's parent device is not the same as the
         * regulator's parent device, then ensure the parent device
@@ -5156,7 +5154,6 @@ struct regulator_dev *
 regulator_register(const struct regulator_desc *regulator_desc,
                   const struct regulator_config *cfg)
 {
-       const struct regulation_constraints *constraints = NULL;
        const struct regulator_init_data *init_data;
        struct regulator_config *config = NULL;
        static atomic_t regulator_no = ATOMIC_INIT(-1);
@@ -5295,14 +5292,23 @@ regulator_register(const struct regulator_desc *regulator_desc,
 
        /* set regulator constraints */
        if (init_data)
-               constraints = &init_data->constraints;
+               rdev->constraints = kmemdup(&init_data->constraints,
+                                           sizeof(*rdev->constraints),
+                                           GFP_KERNEL);
+       else
+               rdev->constraints = kzalloc(sizeof(*rdev->constraints),
+                                           GFP_KERNEL);
+       if (!rdev->constraints) {
+               ret = -ENOMEM;
+               goto wash;
+       }
 
        if (init_data && init_data->supply_regulator)
                rdev->supply_name = init_data->supply_regulator;
        else if (regulator_desc->supply_name)
                rdev->supply_name = regulator_desc->supply_name;
 
-       ret = set_machine_constraints(rdev, constraints);
+       ret = set_machine_constraints(rdev);
        if (ret == -EPROBE_DEFER) {
                /* Regulator might be in bypass mode and so needs its supply
                 * to set the constraints */
@@ -5313,7 +5319,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
                         rdev->supply_name);
                ret = regulator_resolve_supply(rdev);
                if (!ret)
-                       ret = set_machine_constraints(rdev, constraints);
+                       ret = set_machine_constraints(rdev);
                else
                        rdev_dbg(rdev, "unable to resolve supply early: %pe\n",
                                 ERR_PTR(ret));
index 09bab0b45f906f53540494654a81498dec7070e4..d60d7d1b7fa25e117b6e05851a3f63b618481de5 100644 (file)
@@ -805,11 +805,14 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
                 * the switched regulator till yet.
                 */
                if (pfuze_chip->flags & PFUZE_FLAG_DISABLE_SW) {
-                       if (pfuze_chip->regulator_descs[i].sw_reg) {
-                               desc->ops = &pfuze100_sw_disable_regulator_ops;
-                               desc->enable_val = 0x8;
-                               desc->disable_val = 0x0;
-                               desc->enable_time = 500;
+                       if (pfuze_chip->chip_id == PFUZE100 ||
+                               pfuze_chip->chip_id == PFUZE200) {
+                               if (pfuze_chip->regulator_descs[i].sw_reg) {
+                                       desc->ops = &pfuze100_sw_disable_regulator_ops;
+                                       desc->enable_val = 0x8;
+                                       desc->disable_val = 0x0;
+                                       desc->enable_time = 500;
+                               }
                        }
                }
 
index 3e60bff76194801a252529f9338f5df4824a36ef..9f0a4d50cead4091f448aacf564e59d968f7048d 100644 (file)
@@ -342,8 +342,17 @@ static int ti_abb_set_voltage_sel(struct regulator_dev *rdev, unsigned sel)
                return ret;
        }
 
-       /* If data is exactly the same, then just update index, no change */
        info = &abb->info[sel];
+       /*
+        * When Linux kernel is starting up, we are'nt sure of the
+        * Bias configuration that bootloader has configured.
+        * So, we get to know the actual setting the first time
+        * we are asked to transition.
+        */
+       if (abb->current_info_idx == -EINVAL)
+               goto just_set_abb;
+
+       /* If data is exactly the same, then just update index, no change */
        oinfo = &abb->info[abb->current_info_idx];
        if (!memcmp(info, oinfo, sizeof(*info))) {
                dev_dbg(dev, "%s: Same data new idx=%d, old idx=%d\n", __func__,
@@ -351,6 +360,7 @@ static int ti_abb_set_voltage_sel(struct regulator_dev *rdev, unsigned sel)
                goto out;
        }
 
+just_set_abb:
        ret = ti_abb_set_opp(rdev, abb, info);
 
 out: