Merge remote-tracking branches 'regulator/topic/settle', 'regulator/topic/tps65910...
authorMark Brown <broonie@kernel.org>
Mon, 3 Jul 2017 15:52:21 +0000 (16:52 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 3 Jul 2017 15:52:21 +0000 (16:52 +0100)
Documentation/devicetree/bindings/mfd/tps65910.txt
Documentation/devicetree/bindings/regulator/regulator.txt
drivers/mfd/tps65910.c
drivers/regulator/core.c
drivers/regulator/of_regulator.c
drivers/regulator/palmas-regulator.c
drivers/regulator/tps65910-regulator.c
include/linux/mfd/palmas.h
include/linux/mfd/tps65910.h
include/linux/regulator/machine.h

index 38833e63a59f901f79578f3ec7bba01227ec770d..8af1202b381dca44786a8bb5c5a8ef4bfaf81776 100644 (file)
@@ -61,6 +61,10 @@ Optional properties:
   There should be 9 entries here, one for each gpio.
 - ti,system-power-controller: Telling whether or not this pmic is controlling
   the system power.
+- ti,sleep-enable: Enable SLEEP state.
+- ti,sleep-keep-therm: Keep thermal monitoring on in sleep state.
+- ti,sleep-keep-ck32k: Keep the 32KHz clock output on in sleep state.
+- ti,sleep-keep-hsclk: Keep high speed internal clock on in sleep state.
 
 Regulator Optional properties:
 - ti,regulator-ext-sleep-control: enable external sleep
index d18edb075e1c746debc19bf4f9bf7325aef0ecef..378f6dc8b8bd102b64cbf477aa203c41115d9b00 100644 (file)
@@ -24,6 +24,14 @@ Optional properties:
 - regulator-settling-time-us: Settling time, in microseconds, for voltage
   change if regulator have the constant time for any level voltage change.
   This is useful when regulator have exponential voltage change.
+- regulator-settling-time-up-us: Settling time, in microseconds, for voltage
+  increase if the regulator needs a constant time to settle after voltage
+  increases of any level. This is useful for regulators with exponential
+  voltage changes.
+- regulator-settling-time-down-us: Settling time, in microseconds, for voltage
+  decrease if the regulator needs a constant time to settle after voltage
+  decreases of any level. This is useful for regulators with exponential
+  voltage changes.
 - regulator-soft-start: Enable soft start so that voltage ramps slowly
 - regulator-state-mem sub-root node for Suspend-to-RAM mode
   : suspend to memory, the device goes to sleep, but all data stored in memory,
index 11cab1582f2f223316ec4ec5337dce863908b609..8263605f6d2fa2b76eb36b4f1589eb5dba6b8b0b 100644 (file)
@@ -328,11 +328,7 @@ static int tps65910_sleepinit(struct tps65910 *tps65910,
                goto err_sleep_init;
        }
 
-       /* Return if there is no sleep keepon data. */
-       if (!pmic_pdata->slp_keepon)
-               return 0;
-
-       if (pmic_pdata->slp_keepon->therm_keepon) {
+       if (pmic_pdata->slp_keepon.therm_keepon) {
                ret = tps65910_reg_set_bits(tps65910,
                                TPS65910_SLEEP_KEEP_RES_ON,
                                SLEEP_KEEP_RES_ON_THERM_KEEPON_MASK);
@@ -342,7 +338,7 @@ static int tps65910_sleepinit(struct tps65910 *tps65910,
                }
        }
 
-       if (pmic_pdata->slp_keepon->clkout32k_keepon) {
+       if (pmic_pdata->slp_keepon.clkout32k_keepon) {
                ret = tps65910_reg_set_bits(tps65910,
                                TPS65910_SLEEP_KEEP_RES_ON,
                                SLEEP_KEEP_RES_ON_CLKOUT32K_KEEPON_MASK);
@@ -352,7 +348,7 @@ static int tps65910_sleepinit(struct tps65910 *tps65910,
                }
        }
 
-       if (pmic_pdata->slp_keepon->i2chs_keepon) {
+       if (pmic_pdata->slp_keepon.i2chs_keepon) {
                ret = tps65910_reg_set_bits(tps65910,
                                TPS65910_SLEEP_KEEP_RES_ON,
                                SLEEP_KEEP_RES_ON_I2CHS_KEEPON_MASK);
@@ -415,6 +411,18 @@ static struct tps65910_board *tps65910_parse_dt(struct i2c_client *client,
        prop = of_property_read_bool(np, "ti,en-ck32k-xtal");
        board_info->en_ck32k_xtal = prop;
 
+       prop = of_property_read_bool(np, "ti,sleep-enable");
+       board_info->en_dev_slp = prop;
+
+       prop = of_property_read_bool(np, "ti,sleep-keep-therm");
+       board_info->slp_keepon.therm_keepon = prop;
+
+       prop = of_property_read_bool(np, "ti,sleep-keep-ck32k");
+       board_info->slp_keepon.clkout32k_keepon = prop;
+
+       prop = of_property_read_bool(np, "ti,sleep-keep-hsclk");
+       board_info->slp_keepon.i2chs_keepon = prop;
+
        board_info->irq = client->irq;
        board_info->irq_base = -1;
        board_info->pm_off = of_property_read_bool(np,
index e9f74331fc697d86b723e1a69379d636c9fe9162..e567fa54980b6df80c3ef4757aa57086986eca68 100644 (file)
@@ -2767,6 +2767,12 @@ static int _regulator_set_voltage_time(struct regulator_dev *rdev,
                ramp_delay = rdev->desc->ramp_delay;
        else if (rdev->constraints->settling_time)
                return rdev->constraints->settling_time;
+       else if (rdev->constraints->settling_time_up &&
+                (new_uV > old_uV))
+               return rdev->constraints->settling_time_up;
+       else if (rdev->constraints->settling_time_down &&
+                (new_uV < old_uV))
+               return rdev->constraints->settling_time_down;
 
        if (ramp_delay == 0) {
                rdev_dbg(rdev, "ramp_delay not set\n");
index 09d677d5d3f02b6dea295c8379df2cc03d8e8577..96bf75458da5101ada4321609635933ed715f338 100644 (file)
@@ -90,6 +90,25 @@ static void of_get_regulation_constraints(struct device_node *np,
        if (!ret)
                constraints->settling_time = pval;
 
+       ret = of_property_read_u32(np, "regulator-settling-time-up-us", &pval);
+       if (!ret)
+               constraints->settling_time_up = pval;
+       if (constraints->settling_time_up && constraints->settling_time) {
+               pr_warn("%s: ambiguous configuration for settling time, ignoring 'regulator-settling-time-up-us'\n",
+                       np->name);
+               constraints->settling_time_up = 0;
+       }
+
+       ret = of_property_read_u32(np, "regulator-settling-time-down-us",
+                                  &pval);
+       if (!ret)
+               constraints->settling_time_down = pval;
+       if (constraints->settling_time_down && constraints->settling_time) {
+               pr_warn("%s: ambiguous configuration for settling time, ignoring 'regulator-settling-time-down-us'\n",
+                       np->name);
+               constraints->settling_time_down = 0;
+       }
+
        ret = of_property_read_u32(np, "regulator-enable-ramp-delay", &pval);
        if (!ret)
                constraints->enable_time = pval;
index 34d4a62283d7107d9cc43e8de26b4aebf3647b77..bb5ab7d78895b817a9d42e03e6bd890d6b99e33e 100644 (file)
@@ -263,6 +263,13 @@ static struct palmas_regs_info tps65917_regs_info[] = {
                .ctrl_addr      = TPS65917_SMPS5_CTRL,
                .sleep_id       = TPS65917_EXTERNAL_REQSTR_ID_SMPS5,
        },
+       {
+               .name           = "SMPS12",
+               .sname          = "smps1-in",
+               .vsel_addr      = TPS65917_SMPS1_VOLTAGE,
+               .ctrl_addr      = TPS65917_SMPS1_CTRL,
+               .sleep_id       = TPS65917_EXTERNAL_REQSTR_ID_SMPS12,
+       },
        {
                .name           = "LDO1",
                .sname          = "ldo1-in",
@@ -367,6 +374,7 @@ static struct palmas_sleep_requestor_info tps65917_sleep_req_info[] = {
        EXTERNAL_REQUESTOR_TPS65917(SMPS3, 1, 2),
        EXTERNAL_REQUESTOR_TPS65917(SMPS4, 1, 3),
        EXTERNAL_REQUESTOR_TPS65917(SMPS5, 1, 4),
+       EXTERNAL_REQUESTOR_TPS65917(SMPS12, 1, 5),
        EXTERNAL_REQUESTOR_TPS65917(LDO1, 2, 0),
        EXTERNAL_REQUESTOR_TPS65917(LDO2, 2, 1),
        EXTERNAL_REQUESTOR_TPS65917(LDO3, 2, 2),
@@ -1305,7 +1313,8 @@ static int tps65917_smps_registration(struct palmas_pmic *pmic,
                 */
                desc = &pmic->desc[id];
                desc->n_linear_ranges = 3;
-               if ((id == TPS65917_REG_SMPS2) && pmic->smps12)
+               if ((id == TPS65917_REG_SMPS2 || id == TPS65917_REG_SMPS1) &&
+                   pmic->smps12)
                        continue;
 
                /* Initialise sleep/init values from platform data */
@@ -1427,6 +1436,7 @@ static struct of_regulator_match tps65917_matches[] = {
        { .name = "smps3", },
        { .name = "smps4", },
        { .name = "smps5", },
+       { .name = "smps12",},
        { .name = "ldo1", },
        { .name = "ldo2", },
        { .name = "ldo3", },
@@ -1455,7 +1465,7 @@ static struct palmas_pmic_driver_data palmas_ddata = {
 
 static struct palmas_pmic_driver_data tps65917_ddata = {
        .smps_start = TPS65917_REG_SMPS1,
-       .smps_end = TPS65917_REG_SMPS5,
+       .smps_end = TPS65917_REG_SMPS12,
        .ldo_begin = TPS65917_REG_LDO1,
        .ldo_end = TPS65917_REG_LDO5,
        .max_reg = TPS65917_NUM_REGS,
@@ -1643,8 +1653,10 @@ static int palmas_regulators_probe(struct platform_device *pdev)
        if (ret)
                return ret;
 
-       if (reg & PALMAS_SMPS_CTRL_SMPS12_SMPS123_EN)
+       if (reg & PALMAS_SMPS_CTRL_SMPS12_SMPS123_EN) {
                pmic->smps123 = 1;
+               pmic->smps12 = 1;
+       }
 
        if (reg & PALMAS_SMPS_CTRL_SMPS45_SMPS457_EN)
                pmic->smps457 = 1;
index 696116ebdf50a5b853ba847b9ef55604ed3423ae..81672a58fcc234f381a40c3b43eda132a6dd96a5 100644 (file)
@@ -1107,6 +1107,7 @@ static int tps65910_probe(struct platform_device *pdev)
 
        switch (tps65910_chip_id(tps65910)) {
        case TPS65910:
+               BUILD_BUG_ON(TPS65910_NUM_REGS < ARRAY_SIZE(tps65910_regs));
                pmic->get_ctrl_reg = &tps65910_get_ctrl_register;
                pmic->num_regulators = ARRAY_SIZE(tps65910_regs);
                pmic->ext_sleep_control = tps65910_ext_sleep_control;
@@ -1119,6 +1120,7 @@ static int tps65910_probe(struct platform_device *pdev)
                                        DCDCCTRL_DCDCCKSYNC_MASK);
                break;
        case TPS65911:
+               BUILD_BUG_ON(TPS65910_NUM_REGS < ARRAY_SIZE(tps65911_regs));
                pmic->get_ctrl_reg = &tps65911_get_ctrl_register;
                pmic->num_regulators = ARRAY_SIZE(tps65911_regs);
                pmic->ext_sleep_control = tps65911_ext_sleep_control;
@@ -1144,8 +1146,7 @@ static int tps65910_probe(struct platform_device *pdev)
        if (!pmic->rdev)
                return -ENOMEM;
 
-       for (i = 0; i < pmic->num_regulators && i < TPS65910_NUM_REGS;
-                       i++, info++) {
+       for (i = 0; i < pmic->num_regulators; i++, info++) {
                /* Register the regulators */
                pmic->info[i] = info;
 
index 5c9a1d44c125a98f679838b36e2be21fbd7fd3a2..6dec4382630311fc74ff2eb026707a87f96beace 100644 (file)
@@ -250,6 +250,7 @@ enum tps65917_regulators {
        TPS65917_REG_SMPS3,
        TPS65917_REG_SMPS4,
        TPS65917_REG_SMPS5,
+       TPS65917_REG_SMPS12,
        /* LDO regulators */
        TPS65917_REG_LDO1,
        TPS65917_REG_LDO2,
@@ -317,6 +318,7 @@ enum tps65917_external_requestor_id {
        TPS65917_EXTERNAL_REQSTR_ID_SMPS3,
        TPS65917_EXTERNAL_REQSTR_ID_SMPS4,
        TPS65917_EXTERNAL_REQSTR_ID_SMPS5,
+       TPS65917_EXTERNAL_REQSTR_ID_SMPS12,
        TPS65917_EXTERNAL_REQSTR_ID_LDO1,
        TPS65917_EXTERNAL_REQSTR_ID_LDO2,
        TPS65917_EXTERNAL_REQSTR_ID_LDO3,
index ffb21e79204d6a1e91acfe414c264261ab4a115c..deffdcd0236f9cb686f1c278c44ad6946c8d206b 100644 (file)
@@ -879,7 +879,7 @@ struct tps65910_board {
        bool en_ck32k_xtal;
        bool en_dev_slp;
        bool pm_off;
-       struct tps65910_sleep_keepon_data *slp_keepon;
+       struct tps65910_sleep_keepon_data slp_keepon;
        bool en_gpio_sleep[TPS6591X_MAX_NUM_GPIO];
        unsigned long regulator_ext_sleep_control[TPS65910_NUM_REGS];
        struct regulator_init_data *tps65910_pmic_init_data[TPS65910_NUM_REGS];
index 117699d1f7df4f72491bd65eccec39a160acf646..9cd4fef37203cbdc8fc76a07a1d81334acc789d3 100644 (file)
@@ -110,6 +110,10 @@ struct regulator_state {
  * @ramp_delay: Time to settle down after voltage change (unit: uV/us)
  * @settling_time: Time to settle down after voltage change when voltage
  *                change is non-linear (unit: microseconds).
+ * @settling_time_up: Time to settle down after voltage increase when voltage
+ *                   change is non-linear (unit: microseconds).
+ * @settling_time_down : Time to settle down after voltage decrease when
+ *                      voltage change is non-linear (unit: microseconds).
  * @active_discharge: Enable/disable active discharge. The enum
  *                   regulator_active_discharge values are used for
  *                   initialisation.
@@ -152,6 +156,8 @@ struct regulation_constraints {
 
        unsigned int ramp_delay;
        unsigned int settling_time;
+       unsigned int settling_time_up;
+       unsigned int settling_time_down;
        unsigned int enable_time;
 
        unsigned int active_discharge;