Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge remote-tracking branches 'regulator/topic/mt6397', 'regulator/topic/of', 'regulator/topic/pfuze100', 'regulator/topic/pwm' and 'regulator/topic/qcom-smd' into regulator-next

+135 -32
+6 -1
Documentation/devicetree/bindings/regulator/pwm-regulator.txt
··· 38 38 in Voltage Table Mode. If no voltage-table is provided, then the device will 39 39 be used in Continuous Voltage Mode. 40 40 41 + Optional properties: 42 + -------------------- 43 + - enable-gpios: GPIO to use to enable/disable the regulator 44 + 41 45 Any property defined as part of the core regulator binding can also be used. 42 46 (See: ../regulator/regulator.txt) 43 47 44 - Continuous Voltage Example: 48 + Continuous Voltage With Enable GPIO Example: 45 49 pwm_regulator { 46 50 compatible = "pwm-regulator; 47 51 pwms = <&pwm1 0 8448 0>; 52 + enable-gpios = <&gpio0 23 GPIO_ACTIVE_HIGH>; 48 53 regulator-min-microvolt = <1016000>; 49 54 regulator-max-microvolt = <1114000>; 50 55 regulator-name = "vdd_logic";
+2 -2
drivers/regulator/Kconfig
··· 552 552 on PCF50633 553 553 554 554 config REGULATOR_PFUZE100 555 - tristate "Freescale PFUZE100/PFUZE200 regulator driver" 555 + tristate "Freescale PFUZE100/200/3000 regulator driver" 556 556 depends on I2C 557 557 select REGMAP_I2C 558 558 help 559 559 Say y here to support the regulators found on the Freescale 560 - PFUZE100/PFUZE200 PMIC. 560 + PFUZE100/200/3000 PMIC. 561 561 562 562 config REGULATOR_PV88060 563 563 tristate "Powerventure Semiconductor PV88060 regulator"
+83 -12
drivers/regulator/mt6397-regulator.c
··· 23 23 #include <linux/regulator/mt6397-regulator.h> 24 24 #include <linux/regulator/of_regulator.h> 25 25 26 + #define MT6397_BUCK_MODE_AUTO 0 27 + #define MT6397_BUCK_MODE_FORCE_PWM 1 28 + 26 29 /* 27 30 * MT6397 regulators' information 28 31 * ··· 41 38 u32 vselon_reg; 42 39 u32 vselctrl_reg; 43 40 u32 vselctrl_mask; 41 + u32 modeset_reg; 42 + u32 modeset_mask; 43 + u32 modeset_shift; 44 44 }; 45 45 46 46 #define MT6397_BUCK(match, vreg, min, max, step, volt_ranges, enreg, \ 47 - vosel, vosel_mask, voselon, vosel_ctrl) \ 47 + vosel, vosel_mask, voselon, vosel_ctrl, _modeset_reg, \ 48 + _modeset_shift) \ 48 49 [MT6397_ID_##vreg] = { \ 49 50 .desc = { \ 50 51 .name = #vreg, \ ··· 69 62 .vselon_reg = voselon, \ 70 63 .vselctrl_reg = vosel_ctrl, \ 71 64 .vselctrl_mask = BIT(1), \ 65 + .modeset_reg = _modeset_reg, \ 66 + .modeset_mask = BIT(_modeset_shift), \ 67 + .modeset_shift = _modeset_shift \ 72 68 } 73 69 74 70 #define MT6397_LDO(match, vreg, ldo_volt_table, enreg, enbit, vosel, \ ··· 155 145 1300000, 1500000, 1800000, 2000000, 2500000, 2800000, 3000000, 3300000, 156 146 }; 157 147 148 + static int mt6397_regulator_set_mode(struct regulator_dev *rdev, 149 + unsigned int mode) 150 + { 151 + struct mt6397_regulator_info *info = rdev_get_drvdata(rdev); 152 + int ret, val; 153 + 154 + switch (mode) { 155 + case REGULATOR_MODE_FAST: 156 + val = MT6397_BUCK_MODE_FORCE_PWM; 157 + break; 158 + case REGULATOR_MODE_NORMAL: 159 + val = MT6397_BUCK_MODE_AUTO; 160 + break; 161 + default: 162 + ret = -EINVAL; 163 + goto err_mode; 164 + } 165 + 166 + dev_dbg(&rdev->dev, "mt6397 buck set_mode %#x, %#x, %#x, %#x\n", 167 + info->modeset_reg, info->modeset_mask, 168 + info->modeset_shift, val); 169 + 170 + val <<= info->modeset_shift; 171 + ret = regmap_update_bits(rdev->regmap, info->modeset_reg, 172 + info->modeset_mask, val); 173 + err_mode: 174 + if (ret != 0) { 175 + dev_err(&rdev->dev, 176 + "Failed to set mt6397 buck mode: %d\n", ret); 177 + return ret; 178 + } 179 + 180 + return 0; 181 + } 182 + 183 + static unsigned int mt6397_regulator_get_mode(struct regulator_dev *rdev) 184 + { 185 + struct mt6397_regulator_info *info = rdev_get_drvdata(rdev); 186 + int ret, regval; 187 + 188 + ret = regmap_read(rdev->regmap, info->modeset_reg, &regval); 189 + if (ret != 0) { 190 + dev_err(&rdev->dev, 191 + "Failed to get mt6397 buck mode: %d\n", ret); 192 + return ret; 193 + } 194 + 195 + switch ((regval & info->modeset_mask) >> info->modeset_shift) { 196 + case MT6397_BUCK_MODE_AUTO: 197 + return REGULATOR_MODE_NORMAL; 198 + case MT6397_BUCK_MODE_FORCE_PWM: 199 + return REGULATOR_MODE_FAST; 200 + default: 201 + return -EINVAL; 202 + } 203 + } 204 + 158 205 static int mt6397_get_status(struct regulator_dev *rdev) 159 206 { 160 207 int ret; ··· 227 160 return (regval & info->qi) ? REGULATOR_STATUS_ON : REGULATOR_STATUS_OFF; 228 161 } 229 162 230 - static struct regulator_ops mt6397_volt_range_ops = { 163 + static const struct regulator_ops mt6397_volt_range_ops = { 231 164 .list_voltage = regulator_list_voltage_linear_range, 232 165 .map_voltage = regulator_map_voltage_linear_range, 233 166 .set_voltage_sel = regulator_set_voltage_sel_regmap, ··· 237 170 .disable = regulator_disable_regmap, 238 171 .is_enabled = regulator_is_enabled_regmap, 239 172 .get_status = mt6397_get_status, 173 + .set_mode = mt6397_regulator_set_mode, 174 + .get_mode = mt6397_regulator_get_mode, 240 175 }; 241 176 242 - static struct regulator_ops mt6397_volt_table_ops = { 177 + static const struct regulator_ops mt6397_volt_table_ops = { 243 178 .list_voltage = regulator_list_voltage_table, 244 179 .map_voltage = regulator_map_voltage_iterate, 245 180 .set_voltage_sel = regulator_set_voltage_sel_regmap, ··· 253 184 .get_status = mt6397_get_status, 254 185 }; 255 186 256 - static struct regulator_ops mt6397_volt_fixed_ops = { 187 + static const struct regulator_ops mt6397_volt_fixed_ops = { 257 188 .list_voltage = regulator_list_voltage_linear, 258 189 .enable = regulator_enable_regmap, 259 190 .disable = regulator_disable_regmap, ··· 265 196 static struct mt6397_regulator_info mt6397_regulators[] = { 266 197 MT6397_BUCK("buck_vpca15", VPCA15, 700000, 1493750, 6250, 267 198 buck_volt_range1, MT6397_VCA15_CON7, MT6397_VCA15_CON9, 0x7f, 268 - MT6397_VCA15_CON10, MT6397_VCA15_CON5), 199 + MT6397_VCA15_CON10, MT6397_VCA15_CON5, MT6397_VCA15_CON2, 11), 269 200 MT6397_BUCK("buck_vpca7", VPCA7, 700000, 1493750, 6250, 270 201 buck_volt_range1, MT6397_VPCA7_CON7, MT6397_VPCA7_CON9, 0x7f, 271 - MT6397_VPCA7_CON10, MT6397_VPCA7_CON5), 202 + MT6397_VPCA7_CON10, MT6397_VPCA7_CON5, MT6397_VPCA7_CON2, 8), 272 203 MT6397_BUCK("buck_vsramca15", VSRAMCA15, 700000, 1493750, 6250, 273 204 buck_volt_range1, MT6397_VSRMCA15_CON7, MT6397_VSRMCA15_CON9, 274 - 0x7f, MT6397_VSRMCA15_CON10, MT6397_VSRMCA15_CON5), 205 + 0x7f, MT6397_VSRMCA15_CON10, MT6397_VSRMCA15_CON5, 206 + MT6397_VSRMCA15_CON2, 8), 275 207 MT6397_BUCK("buck_vsramca7", VSRAMCA7, 700000, 1493750, 6250, 276 208 buck_volt_range1, MT6397_VSRMCA7_CON7, MT6397_VSRMCA7_CON9, 277 - 0x7f, MT6397_VSRMCA7_CON10, MT6397_VSRMCA7_CON5), 209 + 0x7f, MT6397_VSRMCA7_CON10, MT6397_VSRMCA7_CON5, 210 + MT6397_VSRMCA7_CON2, 8), 278 211 MT6397_BUCK("buck_vcore", VCORE, 700000, 1493750, 6250, 279 212 buck_volt_range1, MT6397_VCORE_CON7, MT6397_VCORE_CON9, 0x7f, 280 - MT6397_VCORE_CON10, MT6397_VCORE_CON5), 213 + MT6397_VCORE_CON10, MT6397_VCORE_CON5, MT6397_VCORE_CON2, 8), 281 214 MT6397_BUCK("buck_vgpu", VGPU, 700000, 1493750, 6250, buck_volt_range1, 282 215 MT6397_VGPU_CON7, MT6397_VGPU_CON9, 0x7f, 283 - MT6397_VGPU_CON10, MT6397_VGPU_CON5), 216 + MT6397_VGPU_CON10, MT6397_VGPU_CON5, MT6397_VGPU_CON2, 8), 284 217 MT6397_BUCK("buck_vdrm", VDRM, 800000, 1593750, 6250, buck_volt_range2, 285 218 MT6397_VDRM_CON7, MT6397_VDRM_CON9, 0x7f, 286 - MT6397_VDRM_CON10, MT6397_VDRM_CON5), 219 + MT6397_VDRM_CON10, MT6397_VDRM_CON5, MT6397_VDRM_CON2, 8), 287 220 MT6397_BUCK("buck_vio18", VIO18, 1500000, 2120000, 20000, 288 221 buck_volt_range3, MT6397_VIO18_CON7, MT6397_VIO18_CON9, 0x1f, 289 - MT6397_VIO18_CON10, MT6397_VIO18_CON5), 222 + MT6397_VIO18_CON10, MT6397_VIO18_CON5, MT6397_VIO18_CON2, 8), 290 223 MT6397_REG_FIXED("ldo_vtcxo", VTCXO, MT6397_ANALDO_CON0, 10, 2800000), 291 224 MT6397_REG_FIXED("ldo_va28", VA28, MT6397_ANALDO_CON1, 14, 2800000), 292 225 MT6397_LDO("ldo_vcama", VCAMA, ldo_volt_table1,
+3
drivers/regulator/of_regulator.c
··· 163 163 "regulator-suspend-microvolt", &pval)) 164 164 suspend_state->uV = pval; 165 165 166 + if (i == PM_SUSPEND_MEM) 167 + constraints->initial_state = PM_SUSPEND_MEM; 168 + 166 169 of_node_put(suspend_np); 167 170 suspend_state = NULL; 168 171 suspend_np = NULL;
+7 -8
drivers/regulator/pfuze100-regulator.c
··· 70 70 struct device *dev; 71 71 struct pfuze_regulator regulator_descs[PFUZE100_MAX_REGULATOR]; 72 72 struct regulator_dev *regulators[PFUZE100_MAX_REGULATOR]; 73 + struct pfuze_regulator *pfuze_regulators; 73 74 }; 74 75 75 76 static const int pfuze100_swbst[] = { ··· 335 334 PFUZE100_VGEN_REG(PFUZE3000, VLDO4, PFUZE100_VGEN6VOL, 1800000, 3300000, 100000), 336 335 }; 337 336 338 - static struct pfuze_regulator *pfuze_regulators; 339 - 340 337 #ifdef CONFIG_OF 341 338 /* PFUZE100 */ 342 339 static struct of_regulator_match pfuze100_matches[] = { ··· 562 563 /* use the right regulators after identify the right device */ 563 564 switch (pfuze_chip->chip_id) { 564 565 case PFUZE3000: 565 - pfuze_regulators = pfuze3000_regulators; 566 + pfuze_chip->pfuze_regulators = pfuze3000_regulators; 566 567 regulator_num = ARRAY_SIZE(pfuze3000_regulators); 567 568 sw_check_start = PFUZE3000_SW2; 568 569 sw_check_end = PFUZE3000_SW2; 569 570 sw_hi = 1 << 3; 570 571 break; 571 572 case PFUZE200: 572 - pfuze_regulators = pfuze200_regulators; 573 + pfuze_chip->pfuze_regulators = pfuze200_regulators; 573 574 regulator_num = ARRAY_SIZE(pfuze200_regulators); 574 575 sw_check_start = PFUZE200_SW2; 575 576 sw_check_end = PFUZE200_SW3B; 576 577 break; 577 578 case PFUZE100: 578 579 default: 579 - pfuze_regulators = pfuze100_regulators; 580 + pfuze_chip->pfuze_regulators = pfuze100_regulators; 580 581 regulator_num = ARRAY_SIZE(pfuze100_regulators); 581 582 sw_check_start = PFUZE100_SW2; 582 583 sw_check_end = PFUZE100_SW4; ··· 586 587 (pfuze_chip->chip_id == PFUZE100) ? "100" : 587 588 ((pfuze_chip->chip_id == PFUZE200) ? "200" : "3000")); 588 589 589 - memcpy(pfuze_chip->regulator_descs, pfuze_regulators, 590 + memcpy(pfuze_chip->regulator_descs, pfuze_chip->pfuze_regulators, 590 591 sizeof(pfuze_chip->regulator_descs)); 591 592 592 593 ret = pfuze_parse_regulators_dt(pfuze_chip); ··· 630 631 devm_regulator_register(&client->dev, desc, &config); 631 632 if (IS_ERR(pfuze_chip->regulators[i])) { 632 633 dev_err(&client->dev, "register regulator%s failed\n", 633 - pfuze_regulators[i].desc.name); 634 + pfuze_chip->pfuze_regulators[i].desc.name); 634 635 return PTR_ERR(pfuze_chip->regulators[i]); 635 636 } 636 637 } ··· 649 650 module_i2c_driver(pfuze_driver); 650 651 651 652 MODULE_AUTHOR("Robin Gong <b38343@freescale.com>"); 652 - MODULE_DESCRIPTION("Regulator Driver for Freescale PFUZE100/PFUZE200 PMIC"); 653 + MODULE_DESCRIPTION("Regulator Driver for Freescale PFUZE100/200/3000 PMIC"); 653 654 MODULE_LICENSE("GPL v2");
+33 -7
drivers/regulator/pwm-regulator.c
··· 20 20 #include <linux/of.h> 21 21 #include <linux/of_device.h> 22 22 #include <linux/pwm.h> 23 + #include <linux/gpio/consumer.h> 23 24 24 25 struct pwm_regulator_data { 25 26 /* Shared */ ··· 39 38 40 39 /* Continuous voltage */ 41 40 int volt_uV; 41 + 42 + /* Enable GPIO */ 43 + struct gpio_desc *enb_gpio; 42 44 }; 43 45 44 46 struct pwm_voltages { ··· 98 94 { 99 95 struct pwm_regulator_data *drvdata = rdev_get_drvdata(dev); 100 96 97 + if (drvdata->enb_gpio) 98 + gpiod_set_value_cansleep(drvdata->enb_gpio, 1); 99 + 101 100 return pwm_enable(drvdata->pwm); 102 101 } 103 102 ··· 110 103 111 104 pwm_disable(drvdata->pwm); 112 105 106 + if (drvdata->enb_gpio) 107 + gpiod_set_value_cansleep(drvdata->enb_gpio, 0); 108 + 113 109 return 0; 114 110 } 115 111 116 112 static int pwm_regulator_is_enabled(struct regulator_dev *dev) 117 113 { 118 114 struct pwm_regulator_data *drvdata = rdev_get_drvdata(dev); 115 + 116 + if (drvdata->enb_gpio && !gpiod_get_value_cansleep(drvdata->enb_gpio)) 117 + return false; 119 118 120 119 return pwm_is_enabled(drvdata->pwm); 121 120 } ··· 145 132 unsigned int duty_pulse; 146 133 u64 req_period; 147 134 u32 rem; 135 + int old_uV = pwm_regulator_get_voltage(rdev); 148 136 int ret; 149 137 150 138 pwm_get_args(drvdata->pwm, &pargs); ··· 173 159 return ret; 174 160 } 175 161 176 - ret = pwm_enable(drvdata->pwm); 177 - if (ret) { 178 - dev_err(&rdev->dev, "Failed to enable PWM: %d\n", ret); 179 - return ret; 180 - } 181 162 drvdata->volt_uV = min_uV; 182 163 183 - /* Delay required by PWM regulator to settle to the new voltage */ 184 - usleep_range(ramp_delay, ramp_delay + 1000); 164 + if ((ramp_delay == 0) || !pwm_regulator_is_enabled(rdev)) 165 + return 0; 166 + 167 + /* Ramp delay is in uV/uS. Adjust to uS and delay */ 168 + ramp_delay = DIV_ROUND_UP(abs(min_uV - old_uV), ramp_delay); 169 + usleep_range(ramp_delay, ramp_delay + DIV_ROUND_UP(ramp_delay, 10)); 185 170 186 171 return 0; 187 172 } ··· 266 253 struct regulator_dev *regulator; 267 254 struct regulator_config config = { }; 268 255 struct device_node *np = pdev->dev.of_node; 256 + enum gpiod_flags gpio_flags; 269 257 int ret; 270 258 271 259 if (!np) { ··· 301 287 if (IS_ERR(drvdata->pwm)) { 302 288 ret = PTR_ERR(drvdata->pwm); 303 289 dev_err(&pdev->dev, "Failed to get PWM: %d\n", ret); 290 + return ret; 291 + } 292 + 293 + if (init_data->constraints.boot_on || init_data->constraints.always_on) 294 + gpio_flags = GPIOD_OUT_HIGH; 295 + else 296 + gpio_flags = GPIOD_OUT_LOW; 297 + drvdata->enb_gpio = devm_gpiod_get_optional(&pdev->dev, "enable", 298 + gpio_flags); 299 + if (IS_ERR(drvdata->enb_gpio)) { 300 + ret = PTR_ERR(drvdata->enb_gpio); 301 + dev_err(&pdev->dev, "Failed to get enable GPIO: %d\n", ret); 304 302 return ret; 305 303 } 306 304
+1 -2
drivers/regulator/qcom_smd-regulator.c
··· 152 152 .enable = rpm_reg_enable, 153 153 .disable = rpm_reg_disable, 154 154 .is_enabled = rpm_reg_is_enabled, 155 - .list_voltage = regulator_list_voltage_linear_range, 156 155 157 156 .get_voltage = rpm_reg_get_voltage, 158 157 .set_voltage = rpm_reg_set_voltage, ··· 211 212 static const struct regulator_desc pm8x41_hfsmps = { 212 213 .linear_ranges = (struct regulator_linear_range[]) { 213 214 REGULATOR_LINEAR_RANGE( 375000, 0, 95, 12500), 214 - REGULATOR_LINEAR_RANGE(1550000, 96, 158, 25000), 215 + REGULATOR_LINEAR_RANGE(1575000, 96, 158, 25000), 215 216 }, 216 217 .n_linear_ranges = 2, 217 218 .n_voltages = 159,