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