diff options
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/s5m8767.c | 37 | ||||
-rw-r--r-- | drivers/regulator/tps65090-regulator.c | 214 | ||||
-rw-r--r-- | drivers/regulator/tps65217-regulator.c | 4 | ||||
-rw-r--r-- | drivers/regulator/tps65218-regulator.c | 37 |
4 files changed, 222 insertions, 70 deletions
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index 92f19a005dc3..c79af943a5c0 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c | |||
@@ -28,7 +28,6 @@ struct s5m8767_info { | |||
28 | struct device *dev; | 28 | struct device *dev; |
29 | struct sec_pmic_dev *iodev; | 29 | struct sec_pmic_dev *iodev; |
30 | int num_regulators; | 30 | int num_regulators; |
31 | struct regulator_dev **rdev; | ||
32 | struct sec_opmode_data *opmode; | 31 | struct sec_opmode_data *opmode; |
33 | 32 | ||
34 | int ramp_delay; | 33 | int ramp_delay; |
@@ -529,16 +528,6 @@ static int s5m8767_pmic_dt_parse_ds_gpio(struct sec_pmic_dev *iodev, | |||
529 | return 0; | 528 | return 0; |
530 | } | 529 | } |
531 | 530 | ||
532 | static void s5m8767_pmic_dt_parse_ext_control_gpio(struct sec_pmic_dev *iodev, | ||
533 | struct sec_regulator_data *rdata, | ||
534 | struct device_node *reg_np) | ||
535 | { | ||
536 | rdata->ext_control_gpio = of_get_named_gpio(reg_np, | ||
537 | "s5m8767,pmic-ext-control-gpios", 0); | ||
538 | if (!gpio_is_valid(rdata->ext_control_gpio)) | ||
539 | rdata->ext_control_gpio = 0; | ||
540 | } | ||
541 | |||
542 | static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, | 531 | static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, |
543 | struct sec_platform_data *pdata) | 532 | struct sec_platform_data *pdata) |
544 | { | 533 | { |
@@ -587,7 +576,8 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, | |||
587 | continue; | 576 | continue; |
588 | } | 577 | } |
589 | 578 | ||
590 | s5m8767_pmic_dt_parse_ext_control_gpio(iodev, rdata, reg_np); | 579 | rdata->ext_control_gpio = of_get_named_gpio(reg_np, |
580 | "s5m8767,pmic-ext-control-gpios", 0); | ||
591 | 581 | ||
592 | rdata->id = i; | 582 | rdata->id = i; |
593 | rdata->initdata = of_get_regulator_init_data( | 583 | rdata->initdata = of_get_regulator_init_data( |
@@ -695,7 +685,6 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) | |||
695 | struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); | 685 | struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); |
696 | struct sec_platform_data *pdata = iodev->pdata; | 686 | struct sec_platform_data *pdata = iodev->pdata; |
697 | struct regulator_config config = { }; | 687 | struct regulator_config config = { }; |
698 | struct regulator_dev **rdev; | ||
699 | struct s5m8767_info *s5m8767; | 688 | struct s5m8767_info *s5m8767; |
700 | int i, ret, size, buck_init; | 689 | int i, ret, size, buck_init; |
701 | 690 | ||
@@ -737,11 +726,7 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) | |||
737 | return -ENOMEM; | 726 | return -ENOMEM; |
738 | 727 | ||
739 | size = sizeof(struct regulator_dev *) * (S5M8767_REG_MAX - 2); | 728 | size = sizeof(struct regulator_dev *) * (S5M8767_REG_MAX - 2); |
740 | s5m8767->rdev = devm_kzalloc(&pdev->dev, size, GFP_KERNEL); | ||
741 | if (!s5m8767->rdev) | ||
742 | return -ENOMEM; | ||
743 | 729 | ||
744 | rdev = s5m8767->rdev; | ||
745 | s5m8767->dev = &pdev->dev; | 730 | s5m8767->dev = &pdev->dev; |
746 | s5m8767->iodev = iodev; | 731 | s5m8767->iodev = iodev; |
747 | s5m8767->num_regulators = pdata->num_regulators; | 732 | s5m8767->num_regulators = pdata->num_regulators; |
@@ -938,6 +923,7 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) | |||
938 | const struct sec_voltage_desc *desc; | 923 | const struct sec_voltage_desc *desc; |
939 | int id = pdata->regulators[i].id; | 924 | int id = pdata->regulators[i].id; |
940 | int enable_reg, enable_val; | 925 | int enable_reg, enable_val; |
926 | struct regulator_dev *rdev; | ||
941 | 927 | ||
942 | desc = reg_voltage_map[id]; | 928 | desc = reg_voltage_map[id]; |
943 | if (desc) { | 929 | if (desc) { |
@@ -964,26 +950,27 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) | |||
964 | config.driver_data = s5m8767; | 950 | config.driver_data = s5m8767; |
965 | config.regmap = iodev->regmap_pmic; | 951 | config.regmap = iodev->regmap_pmic; |
966 | config.of_node = pdata->regulators[i].reg_node; | 952 | config.of_node = pdata->regulators[i].reg_node; |
967 | config.ena_gpio = config.ena_gpio_flags = 0; | 953 | config.ena_gpio = -EINVAL; |
968 | if (pdata->regulators[i].ext_control_gpio) | 954 | config.ena_gpio_flags = 0; |
955 | if (gpio_is_valid(pdata->regulators[i].ext_control_gpio)) | ||
969 | s5m8767_regulator_config_ext_control(s5m8767, | 956 | s5m8767_regulator_config_ext_control(s5m8767, |
970 | &pdata->regulators[i], &config); | 957 | &pdata->regulators[i], &config); |
971 | 958 | ||
972 | rdev[i] = devm_regulator_register(&pdev->dev, ®ulators[id], | 959 | rdev = devm_regulator_register(&pdev->dev, ®ulators[id], |
973 | &config); | 960 | &config); |
974 | if (IS_ERR(rdev[i])) { | 961 | if (IS_ERR(rdev)) { |
975 | ret = PTR_ERR(rdev[i]); | 962 | ret = PTR_ERR(rdev); |
976 | dev_err(s5m8767->dev, "regulator init failed for %d\n", | 963 | dev_err(s5m8767->dev, "regulator init failed for %d\n", |
977 | id); | 964 | id); |
978 | return ret; | 965 | return ret; |
979 | } | 966 | } |
980 | 967 | ||
981 | if (pdata->regulators[i].ext_control_gpio) { | 968 | if (gpio_is_valid(pdata->regulators[i].ext_control_gpio)) { |
982 | ret = s5m8767_enable_ext_control(s5m8767, rdev[i]); | 969 | ret = s5m8767_enable_ext_control(s5m8767, rdev); |
983 | if (ret < 0) { | 970 | if (ret < 0) { |
984 | dev_err(s5m8767->dev, | 971 | dev_err(s5m8767->dev, |
985 | "failed to enable gpio control over %s: %d\n", | 972 | "failed to enable gpio control over %s: %d\n", |
986 | rdev[i]->desc->name, ret); | 973 | rdev->desc->name, ret); |
987 | return ret; | 974 | return ret; |
988 | } | 975 | } |
989 | } | 976 | } |
diff --git a/drivers/regulator/tps65090-regulator.c b/drivers/regulator/tps65090-regulator.c index 2e92ef68574d..2064b3fd45f7 100644 --- a/drivers/regulator/tps65090-regulator.c +++ b/drivers/regulator/tps65090-regulator.c | |||
@@ -17,6 +17,7 @@ | |||
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/module.h> | 19 | #include <linux/module.h> |
20 | #include <linux/delay.h> | ||
20 | #include <linux/init.h> | 21 | #include <linux/init.h> |
21 | #include <linux/gpio.h> | 22 | #include <linux/gpio.h> |
22 | #include <linux/of_gpio.h> | 23 | #include <linux/of_gpio.h> |
@@ -28,49 +29,216 @@ | |||
28 | #include <linux/regulator/of_regulator.h> | 29 | #include <linux/regulator/of_regulator.h> |
29 | #include <linux/mfd/tps65090.h> | 30 | #include <linux/mfd/tps65090.h> |
30 | 31 | ||
32 | #define MAX_CTRL_READ_TRIES 5 | ||
33 | #define MAX_FET_ENABLE_TRIES 1000 | ||
34 | |||
35 | #define CTRL_EN_BIT 0 /* Regulator enable bit, active high */ | ||
36 | #define CTRL_WT_BIT 2 /* Regulator wait time 0 bit */ | ||
37 | #define CTRL_PG_BIT 4 /* Regulator power good bit, 1=good */ | ||
38 | #define CTRL_TO_BIT 7 /* Regulator timeout bit, 1=wait */ | ||
39 | |||
40 | #define MAX_OVERCURRENT_WAIT 3 /* Overcurrent wait must be <= this */ | ||
41 | |||
42 | /** | ||
43 | * struct tps65090_regulator - Per-regulator data for a tps65090 regulator | ||
44 | * | ||
45 | * @dev: Pointer to our device. | ||
46 | * @desc: The struct regulator_desc for the regulator. | ||
47 | * @rdev: The struct regulator_dev for the regulator. | ||
48 | * @overcurrent_wait_valid: True if overcurrent_wait is valid. | ||
49 | * @overcurrent_wait: For FETs, the value to put in the WTFET bitfield. | ||
50 | */ | ||
51 | |||
31 | struct tps65090_regulator { | 52 | struct tps65090_regulator { |
32 | struct device *dev; | 53 | struct device *dev; |
33 | struct regulator_desc *desc; | 54 | struct regulator_desc *desc; |
34 | struct regulator_dev *rdev; | 55 | struct regulator_dev *rdev; |
56 | bool overcurrent_wait_valid; | ||
57 | int overcurrent_wait; | ||
35 | }; | 58 | }; |
36 | 59 | ||
37 | static struct regulator_ops tps65090_ext_control_ops = { | 60 | static struct regulator_ops tps65090_ext_control_ops = { |
38 | }; | 61 | }; |
39 | 62 | ||
40 | static struct regulator_ops tps65090_reg_contol_ops = { | 63 | /** |
64 | * tps65090_reg_set_overcurrent_wait - Setup overcurrent wait | ||
65 | * | ||
66 | * This will set the overcurrent wait time based on what's in the regulator | ||
67 | * info. | ||
68 | * | ||
69 | * @ri: Overall regulator data | ||
70 | * @rdev: Regulator device | ||
71 | * | ||
72 | * Return: 0 if no error, non-zero if there was an error writing the register. | ||
73 | */ | ||
74 | static int tps65090_reg_set_overcurrent_wait(struct tps65090_regulator *ri, | ||
75 | struct regulator_dev *rdev) | ||
76 | { | ||
77 | int ret; | ||
78 | |||
79 | ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, | ||
80 | MAX_OVERCURRENT_WAIT << CTRL_WT_BIT, | ||
81 | ri->overcurrent_wait << CTRL_WT_BIT); | ||
82 | if (ret) { | ||
83 | dev_err(&rdev->dev, "Error updating overcurrent wait %#x\n", | ||
84 | rdev->desc->enable_reg); | ||
85 | } | ||
86 | |||
87 | return ret; | ||
88 | } | ||
89 | |||
90 | /** | ||
91 | * tps65090_try_enable_fet - Try to enable a FET | ||
92 | * | ||
93 | * @rdev: Regulator device | ||
94 | * | ||
95 | * Return: 0 if ok, -ENOTRECOVERABLE if the FET power good bit did not get | ||
96 | * set, or some other -ve value if another error occurred (e.g. i2c error) | ||
97 | */ | ||
98 | static int tps65090_try_enable_fet(struct regulator_dev *rdev) | ||
99 | { | ||
100 | unsigned int control; | ||
101 | int ret, i; | ||
102 | |||
103 | ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, | ||
104 | rdev->desc->enable_mask, | ||
105 | rdev->desc->enable_mask); | ||
106 | if (ret < 0) { | ||
107 | dev_err(&rdev->dev, "Error in updating reg %#x\n", | ||
108 | rdev->desc->enable_reg); | ||
109 | return ret; | ||
110 | } | ||
111 | |||
112 | for (i = 0; i < MAX_CTRL_READ_TRIES; i++) { | ||
113 | ret = regmap_read(rdev->regmap, rdev->desc->enable_reg, | ||
114 | &control); | ||
115 | if (ret < 0) | ||
116 | return ret; | ||
117 | |||
118 | if (!(control & BIT(CTRL_TO_BIT))) | ||
119 | break; | ||
120 | |||
121 | usleep_range(1000, 1500); | ||
122 | } | ||
123 | if (!(control & BIT(CTRL_PG_BIT))) | ||
124 | return -ENOTRECOVERABLE; | ||
125 | |||
126 | return 0; | ||
127 | } | ||
128 | |||
129 | /** | ||
130 | * tps65090_fet_enable - Enable a FET, trying a few times if it fails | ||
131 | * | ||
132 | * Some versions of the tps65090 have issues when turning on the FETs. | ||
133 | * This function goes through several steps to ensure the best chance of the | ||
134 | * FET going on. Specifically: | ||
135 | * - We'll make sure that we bump the "overcurrent wait" to the maximum, which | ||
136 | * increases the chances that we'll turn on properly. | ||
137 | * - We'll retry turning the FET on multiple times (turning off in between). | ||
138 | * | ||
139 | * @rdev: Regulator device | ||
140 | * | ||
141 | * Return: 0 if ok, non-zero if it fails. | ||
142 | */ | ||
143 | static int tps65090_fet_enable(struct regulator_dev *rdev) | ||
144 | { | ||
145 | int ret, tries; | ||
146 | |||
147 | /* | ||
148 | * Try enabling multiple times until we succeed since sometimes the | ||
149 | * first try times out. | ||
150 | */ | ||
151 | tries = 0; | ||
152 | while (true) { | ||
153 | ret = tps65090_try_enable_fet(rdev); | ||
154 | if (!ret) | ||
155 | break; | ||
156 | if (ret != -ENOTRECOVERABLE || tries == MAX_FET_ENABLE_TRIES) | ||
157 | goto err; | ||
158 | |||
159 | /* Try turning the FET off (and then on again) */ | ||
160 | ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, | ||
161 | rdev->desc->enable_mask, 0); | ||
162 | if (ret) | ||
163 | goto err; | ||
164 | |||
165 | tries++; | ||
166 | } | ||
167 | |||
168 | if (tries) | ||
169 | dev_warn(&rdev->dev, "reg %#x enable ok after %d tries\n", | ||
170 | rdev->desc->enable_reg, tries); | ||
171 | |||
172 | return 0; | ||
173 | err: | ||
174 | dev_warn(&rdev->dev, "reg %#x enable failed\n", rdev->desc->enable_reg); | ||
175 | WARN_ON(1); | ||
176 | |||
177 | return ret; | ||
178 | } | ||
179 | |||
180 | static struct regulator_ops tps65090_reg_control_ops = { | ||
41 | .enable = regulator_enable_regmap, | 181 | .enable = regulator_enable_regmap, |
42 | .disable = regulator_disable_regmap, | 182 | .disable = regulator_disable_regmap, |
43 | .is_enabled = regulator_is_enabled_regmap, | 183 | .is_enabled = regulator_is_enabled_regmap, |
44 | }; | 184 | }; |
45 | 185 | ||
186 | static struct regulator_ops tps65090_fet_control_ops = { | ||
187 | .enable = tps65090_fet_enable, | ||
188 | .disable = regulator_disable_regmap, | ||
189 | .is_enabled = regulator_is_enabled_regmap, | ||
190 | }; | ||
191 | |||
46 | static struct regulator_ops tps65090_ldo_ops = { | 192 | static struct regulator_ops tps65090_ldo_ops = { |
47 | }; | 193 | }; |
48 | 194 | ||
49 | #define tps65090_REG_DESC(_id, _sname, _en_reg, _ops) \ | 195 | #define tps65090_REG_DESC(_id, _sname, _en_reg, _en_bits, _ops) \ |
50 | { \ | 196 | { \ |
51 | .name = "TPS65090_RAILS"#_id, \ | 197 | .name = "TPS65090_RAILS"#_id, \ |
52 | .supply_name = _sname, \ | 198 | .supply_name = _sname, \ |
53 | .id = TPS65090_REGULATOR_##_id, \ | 199 | .id = TPS65090_REGULATOR_##_id, \ |
54 | .ops = &_ops, \ | 200 | .ops = &_ops, \ |
55 | .enable_reg = _en_reg, \ | 201 | .enable_reg = _en_reg, \ |
56 | .enable_mask = BIT(0), \ | 202 | .enable_val = _en_bits, \ |
203 | .enable_mask = _en_bits, \ | ||
57 | .type = REGULATOR_VOLTAGE, \ | 204 | .type = REGULATOR_VOLTAGE, \ |
58 | .owner = THIS_MODULE, \ | 205 | .owner = THIS_MODULE, \ |
59 | } | 206 | } |
60 | 207 | ||
61 | static struct regulator_desc tps65090_regulator_desc[] = { | 208 | static struct regulator_desc tps65090_regulator_desc[] = { |
62 | tps65090_REG_DESC(DCDC1, "vsys1", 0x0C, tps65090_reg_contol_ops), | 209 | tps65090_REG_DESC(DCDC1, "vsys1", 0x0C, BIT(CTRL_EN_BIT), |
63 | tps65090_REG_DESC(DCDC2, "vsys2", 0x0D, tps65090_reg_contol_ops), | 210 | tps65090_reg_control_ops), |
64 | tps65090_REG_DESC(DCDC3, "vsys3", 0x0E, tps65090_reg_contol_ops), | 211 | tps65090_REG_DESC(DCDC2, "vsys2", 0x0D, BIT(CTRL_EN_BIT), |
65 | tps65090_REG_DESC(FET1, "infet1", 0x0F, tps65090_reg_contol_ops), | 212 | tps65090_reg_control_ops), |
66 | tps65090_REG_DESC(FET2, "infet2", 0x10, tps65090_reg_contol_ops), | 213 | tps65090_REG_DESC(DCDC3, "vsys3", 0x0E, BIT(CTRL_EN_BIT), |
67 | tps65090_REG_DESC(FET3, "infet3", 0x11, tps65090_reg_contol_ops), | 214 | tps65090_reg_control_ops), |
68 | tps65090_REG_DESC(FET4, "infet4", 0x12, tps65090_reg_contol_ops), | 215 | |
69 | tps65090_REG_DESC(FET5, "infet5", 0x13, tps65090_reg_contol_ops), | 216 | tps65090_REG_DESC(FET1, "infet1", 0x0F, |
70 | tps65090_REG_DESC(FET6, "infet6", 0x14, tps65090_reg_contol_ops), | 217 | BIT(CTRL_EN_BIT) | BIT(CTRL_PG_BIT), |
71 | tps65090_REG_DESC(FET7, "infet7", 0x15, tps65090_reg_contol_ops), | 218 | tps65090_fet_control_ops), |
72 | tps65090_REG_DESC(LDO1, "vsys-l1", 0, tps65090_ldo_ops), | 219 | tps65090_REG_DESC(FET2, "infet2", 0x10, |
73 | tps65090_REG_DESC(LDO2, "vsys-l2", 0, tps65090_ldo_ops), | 220 | BIT(CTRL_EN_BIT) | BIT(CTRL_PG_BIT), |
221 | tps65090_fet_control_ops), | ||
222 | tps65090_REG_DESC(FET3, "infet3", 0x11, | ||
223 | BIT(CTRL_EN_BIT) | BIT(CTRL_PG_BIT), | ||
224 | tps65090_fet_control_ops), | ||
225 | tps65090_REG_DESC(FET4, "infet4", 0x12, | ||
226 | BIT(CTRL_EN_BIT) | BIT(CTRL_PG_BIT), | ||
227 | tps65090_fet_control_ops), | ||
228 | tps65090_REG_DESC(FET5, "infet5", 0x13, | ||
229 | BIT(CTRL_EN_BIT) | BIT(CTRL_PG_BIT), | ||
230 | tps65090_fet_control_ops), | ||
231 | tps65090_REG_DESC(FET6, "infet6", 0x14, | ||
232 | BIT(CTRL_EN_BIT) | BIT(CTRL_PG_BIT), | ||
233 | tps65090_fet_control_ops), | ||
234 | tps65090_REG_DESC(FET7, "infet7", 0x15, | ||
235 | BIT(CTRL_EN_BIT) | BIT(CTRL_PG_BIT), | ||
236 | tps65090_fet_control_ops), | ||
237 | |||
238 | tps65090_REG_DESC(LDO1, "vsys-l1", 0, 0, | ||
239 | tps65090_ldo_ops), | ||
240 | tps65090_REG_DESC(LDO2, "vsys-l2", 0, 0, | ||
241 | tps65090_ldo_ops), | ||
74 | }; | 242 | }; |
75 | 243 | ||
76 | static inline bool is_dcdc(int id) | 244 | static inline bool is_dcdc(int id) |
@@ -209,6 +377,11 @@ static struct tps65090_platform_data *tps65090_parse_dt_reg_data( | |||
209 | rpdata->gpio = of_get_named_gpio(np, | 377 | rpdata->gpio = of_get_named_gpio(np, |
210 | "dcdc-ext-control-gpios", 0); | 378 | "dcdc-ext-control-gpios", 0); |
211 | 379 | ||
380 | if (of_property_read_u32(tps65090_matches[idx].of_node, | ||
381 | "ti,overcurrent-wait", | ||
382 | &rpdata->overcurrent_wait) == 0) | ||
383 | rpdata->overcurrent_wait_valid = true; | ||
384 | |||
212 | tps65090_pdata->reg_pdata[idx] = rpdata; | 385 | tps65090_pdata->reg_pdata[idx] = rpdata; |
213 | } | 386 | } |
214 | return tps65090_pdata; | 387 | return tps65090_pdata; |
@@ -258,6 +431,11 @@ static int tps65090_regulator_probe(struct platform_device *pdev) | |||
258 | ri = &pmic[num]; | 431 | ri = &pmic[num]; |
259 | ri->dev = &pdev->dev; | 432 | ri->dev = &pdev->dev; |
260 | ri->desc = &tps65090_regulator_desc[num]; | 433 | ri->desc = &tps65090_regulator_desc[num]; |
434 | if (tps_pdata) { | ||
435 | ri->overcurrent_wait_valid = | ||
436 | tps_pdata->overcurrent_wait_valid; | ||
437 | ri->overcurrent_wait = tps_pdata->overcurrent_wait; | ||
438 | } | ||
261 | 439 | ||
262 | /* | 440 | /* |
263 | * TPS5090 DCDC support the control from external digital input. | 441 | * TPS5090 DCDC support the control from external digital input. |
@@ -299,6 +477,12 @@ static int tps65090_regulator_probe(struct platform_device *pdev) | |||
299 | } | 477 | } |
300 | ri->rdev = rdev; | 478 | ri->rdev = rdev; |
301 | 479 | ||
480 | if (ri->overcurrent_wait_valid) { | ||
481 | ret = tps65090_reg_set_overcurrent_wait(ri, rdev); | ||
482 | if (ret < 0) | ||
483 | return ret; | ||
484 | } | ||
485 | |||
302 | /* Enable external control if it is require */ | 486 | /* Enable external control if it is require */ |
303 | if (tps_pdata && is_dcdc(num) && tps_pdata->reg_init_data && | 487 | if (tps_pdata && is_dcdc(num) && tps_pdata->reg_init_data && |
304 | tps_pdata->enable_ext_control) { | 488 | tps_pdata->enable_ext_control) { |
diff --git a/drivers/regulator/tps65217-regulator.c b/drivers/regulator/tps65217-regulator.c index 10b78d2b766a..f7ed20a5a8b9 100644 --- a/drivers/regulator/tps65217-regulator.c +++ b/drivers/regulator/tps65217-regulator.c | |||
@@ -134,6 +134,7 @@ static struct regulator_ops tps65217_pmic_ldo1_ops = { | |||
134 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | 134 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
135 | .set_voltage_sel = tps65217_pmic_set_voltage_sel, | 135 | .set_voltage_sel = tps65217_pmic_set_voltage_sel, |
136 | .list_voltage = regulator_list_voltage_table, | 136 | .list_voltage = regulator_list_voltage_table, |
137 | .map_voltage = regulator_map_voltage_ascend, | ||
137 | }; | 138 | }; |
138 | 139 | ||
139 | static const struct regulator_desc regulators[] = { | 140 | static const struct regulator_desc regulators[] = { |
@@ -257,9 +258,6 @@ static int tps65217_regulator_probe(struct platform_device *pdev) | |||
257 | pdev->name); | 258 | pdev->name); |
258 | return PTR_ERR(rdev); | 259 | return PTR_ERR(rdev); |
259 | } | 260 | } |
260 | |||
261 | /* Save regulator for cleanup */ | ||
262 | tps->rdev[i] = rdev; | ||
263 | } | 261 | } |
264 | return 0; | 262 | return 0; |
265 | } | 263 | } |
diff --git a/drivers/regulator/tps65218-regulator.c b/drivers/regulator/tps65218-regulator.c index cec72fa71d1d..69b4b7750410 100644 --- a/drivers/regulator/tps65218-regulator.c +++ b/drivers/regulator/tps65218-regulator.c | |||
@@ -27,12 +27,10 @@ | |||
27 | #include <linux/regulator/machine.h> | 27 | #include <linux/regulator/machine.h> |
28 | #include <linux/mfd/tps65218.h> | 28 | #include <linux/mfd/tps65218.h> |
29 | 29 | ||
30 | static unsigned int tps65218_ramp_delay = 4000; | ||
31 | |||
32 | enum tps65218_regulators { DCDC1, DCDC2, DCDC3, DCDC4, DCDC5, DCDC6, LDO1 }; | 30 | enum tps65218_regulators { DCDC1, DCDC2, DCDC3, DCDC4, DCDC5, DCDC6, LDO1 }; |
33 | 31 | ||
34 | #define TPS65218_REGULATOR(_name, _id, _ops, _n, _vr, _vm, _er, _em, _t, \ | 32 | #define TPS65218_REGULATOR(_name, _id, _ops, _n, _vr, _vm, _er, _em, _t, \ |
35 | _lr, _nlr) \ | 33 | _lr, _nlr, _delay) \ |
36 | { \ | 34 | { \ |
37 | .name = _name, \ | 35 | .name = _name, \ |
38 | .id = _id, \ | 36 | .id = _id, \ |
@@ -47,6 +45,7 @@ enum tps65218_regulators { DCDC1, DCDC2, DCDC3, DCDC4, DCDC5, DCDC6, LDO1 }; | |||
47 | .volt_table = _t, \ | 45 | .volt_table = _t, \ |
48 | .linear_ranges = _lr, \ | 46 | .linear_ranges = _lr, \ |
49 | .n_linear_ranges = _nlr, \ | 47 | .n_linear_ranges = _nlr, \ |
48 | .ramp_delay = _delay, \ | ||
50 | } \ | 49 | } \ |
51 | 50 | ||
52 | #define TPS65218_INFO(_id, _nm, _min, _max) \ | 51 | #define TPS65218_INFO(_id, _nm, _min, _max) \ |
@@ -152,22 +151,6 @@ static int tps65218_pmic_disable(struct regulator_dev *dev) | |||
152 | dev->desc->enable_mask, TPS65218_PROTECT_L1); | 151 | dev->desc->enable_mask, TPS65218_PROTECT_L1); |
153 | } | 152 | } |
154 | 153 | ||
155 | static int tps65218_set_voltage_time_sel(struct regulator_dev *rdev, | ||
156 | unsigned int old_selector, unsigned int new_selector) | ||
157 | { | ||
158 | int old_uv, new_uv; | ||
159 | |||
160 | old_uv = regulator_list_voltage_linear_range(rdev, old_selector); | ||
161 | if (old_uv < 0) | ||
162 | return old_uv; | ||
163 | |||
164 | new_uv = regulator_list_voltage_linear_range(rdev, new_selector); | ||
165 | if (new_uv < 0) | ||
166 | return new_uv; | ||
167 | |||
168 | return DIV_ROUND_UP(abs(old_uv - new_uv), tps65218_ramp_delay); | ||
169 | } | ||
170 | |||
171 | /* Operations permitted on DCDC1, DCDC2 */ | 154 | /* Operations permitted on DCDC1, DCDC2 */ |
172 | static struct regulator_ops tps65218_dcdc12_ops = { | 155 | static struct regulator_ops tps65218_dcdc12_ops = { |
173 | .is_enabled = regulator_is_enabled_regmap, | 156 | .is_enabled = regulator_is_enabled_regmap, |
@@ -177,7 +160,7 @@ static struct regulator_ops tps65218_dcdc12_ops = { | |||
177 | .set_voltage_sel = tps65218_pmic_set_voltage_sel, | 160 | .set_voltage_sel = tps65218_pmic_set_voltage_sel, |
178 | .list_voltage = regulator_list_voltage_linear_range, | 161 | .list_voltage = regulator_list_voltage_linear_range, |
179 | .map_voltage = regulator_map_voltage_linear_range, | 162 | .map_voltage = regulator_map_voltage_linear_range, |
180 | .set_voltage_time_sel = tps65218_set_voltage_time_sel, | 163 | .set_voltage_time_sel = regulator_set_voltage_time_sel, |
181 | }; | 164 | }; |
182 | 165 | ||
183 | /* Operations permitted on DCDC3, DCDC4 and LDO1 */ | 166 | /* Operations permitted on DCDC3, DCDC4 and LDO1 */ |
@@ -203,33 +186,33 @@ static const struct regulator_desc regulators[] = { | |||
203 | TPS65218_REG_CONTROL_DCDC1, | 186 | TPS65218_REG_CONTROL_DCDC1, |
204 | TPS65218_CONTROL_DCDC1_MASK, | 187 | TPS65218_CONTROL_DCDC1_MASK, |
205 | TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC1_EN, NULL, | 188 | TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC1_EN, NULL, |
206 | dcdc1_dcdc2_ranges, 2), | 189 | dcdc1_dcdc2_ranges, 2, 4000), |
207 | TPS65218_REGULATOR("DCDC2", TPS65218_DCDC_2, tps65218_dcdc12_ops, 64, | 190 | TPS65218_REGULATOR("DCDC2", TPS65218_DCDC_2, tps65218_dcdc12_ops, 64, |
208 | TPS65218_REG_CONTROL_DCDC2, | 191 | TPS65218_REG_CONTROL_DCDC2, |
209 | TPS65218_CONTROL_DCDC2_MASK, | 192 | TPS65218_CONTROL_DCDC2_MASK, |
210 | TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC2_EN, NULL, | 193 | TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC2_EN, NULL, |
211 | dcdc1_dcdc2_ranges, 2), | 194 | dcdc1_dcdc2_ranges, 2, 4000), |
212 | TPS65218_REGULATOR("DCDC3", TPS65218_DCDC_3, tps65218_ldo1_dcdc34_ops, | 195 | TPS65218_REGULATOR("DCDC3", TPS65218_DCDC_3, tps65218_ldo1_dcdc34_ops, |
213 | 64, TPS65218_REG_CONTROL_DCDC3, | 196 | 64, TPS65218_REG_CONTROL_DCDC3, |
214 | TPS65218_CONTROL_DCDC3_MASK, TPS65218_REG_ENABLE1, | 197 | TPS65218_CONTROL_DCDC3_MASK, TPS65218_REG_ENABLE1, |
215 | TPS65218_ENABLE1_DC3_EN, NULL, | 198 | TPS65218_ENABLE1_DC3_EN, NULL, |
216 | ldo1_dcdc3_ranges, 2), | 199 | ldo1_dcdc3_ranges, 2, 0), |
217 | TPS65218_REGULATOR("DCDC4", TPS65218_DCDC_4, tps65218_ldo1_dcdc34_ops, | 200 | TPS65218_REGULATOR("DCDC4", TPS65218_DCDC_4, tps65218_ldo1_dcdc34_ops, |
218 | 53, TPS65218_REG_CONTROL_DCDC4, | 201 | 53, TPS65218_REG_CONTROL_DCDC4, |
219 | TPS65218_CONTROL_DCDC4_MASK, | 202 | TPS65218_CONTROL_DCDC4_MASK, |
220 | TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC4_EN, NULL, | 203 | TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC4_EN, NULL, |
221 | dcdc4_ranges, 2), | 204 | dcdc4_ranges, 2, 0), |
222 | TPS65218_REGULATOR("DCDC5", TPS65218_DCDC_5, tps65218_dcdc56_pmic_ops, | 205 | TPS65218_REGULATOR("DCDC5", TPS65218_DCDC_5, tps65218_dcdc56_pmic_ops, |
223 | 1, -1, -1, TPS65218_REG_ENABLE1, | 206 | 1, -1, -1, TPS65218_REG_ENABLE1, |
224 | TPS65218_ENABLE1_DC5_EN, NULL, NULL, 0), | 207 | TPS65218_ENABLE1_DC5_EN, NULL, NULL, 0, 0), |
225 | TPS65218_REGULATOR("DCDC6", TPS65218_DCDC_6, tps65218_dcdc56_pmic_ops, | 208 | TPS65218_REGULATOR("DCDC6", TPS65218_DCDC_6, tps65218_dcdc56_pmic_ops, |
226 | 1, -1, -1, TPS65218_REG_ENABLE1, | 209 | 1, -1, -1, TPS65218_REG_ENABLE1, |
227 | TPS65218_ENABLE1_DC6_EN, NULL, NULL, 0), | 210 | TPS65218_ENABLE1_DC6_EN, NULL, NULL, 0, 0), |
228 | TPS65218_REGULATOR("LDO1", TPS65218_LDO_1, tps65218_ldo1_dcdc34_ops, 64, | 211 | TPS65218_REGULATOR("LDO1", TPS65218_LDO_1, tps65218_ldo1_dcdc34_ops, 64, |
229 | TPS65218_REG_CONTROL_DCDC4, | 212 | TPS65218_REG_CONTROL_DCDC4, |
230 | TPS65218_CONTROL_LDO1_MASK, TPS65218_REG_ENABLE2, | 213 | TPS65218_CONTROL_LDO1_MASK, TPS65218_REG_ENABLE2, |
231 | TPS65218_ENABLE2_LDO1_EN, NULL, ldo1_dcdc3_ranges, | 214 | TPS65218_ENABLE2_LDO1_EN, NULL, ldo1_dcdc3_ranges, |
232 | 2), | 215 | 2, 0), |
233 | }; | 216 | }; |
234 | 217 | ||
235 | static int tps65218_regulator_probe(struct platform_device *pdev) | 218 | static int tps65218_regulator_probe(struct platform_device *pdev) |