4 * Copyright (c) 2012-2014 Samsung Electronics Co., Ltd
5 * http://www.samsung.com
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
19 #include <linux/bug.h>
20 #include <linux/err.h>
21 #include <linux/gpio.h>
22 #include <linux/slab.h>
23 #include <linux/module.h>
25 #include <linux/regmap.h>
26 #include <linux/platform_device.h>
27 #include <linux/regulator/driver.h>
28 #include <linux/regulator/machine.h>
29 #include <linux/regulator/of_regulator.h>
30 #include <linux/of_gpio.h>
31 #include <linux/mfd/samsung/core.h>
32 #include <linux/mfd/samsung/s2mps11.h>
33 #include <linux/mfd/samsung/s2mps13.h>
34 #include <linux/mfd/samsung/s2mps14.h>
35 #include <linux/mfd/samsung/s2mpu02.h>
37 /* The highest number of possible regulators for supported devices. */
38 #define S2MPS_REGULATOR_MAX S2MPS13_REGULATOR_MAX
40 unsigned int rdev_num;
48 enum sec_device_type dev_type;
51 * One bit for each S2MPS13/S2MPS14/S2MPU02 regulator whether
52 * the suspend mode was enabled.
54 DECLARE_BITMAP(suspend_state, S2MPS_REGULATOR_MAX);
56 /* Array of size rdev_num with GPIO-s for external sleep control */
57 int *ext_control_gpio;
60 static int get_ramp_delay(int ramp_delay)
62 unsigned char cnt = 0;
67 ramp_delay = ramp_delay >> 1;
79 static int s2mps11_regulator_set_voltage_time_sel(struct regulator_dev *rdev,
80 unsigned int old_selector,
81 unsigned int new_selector)
83 struct s2mps11_info *s2mps11 = rdev_get_drvdata(rdev);
84 unsigned int ramp_delay = 0;
85 int old_volt, new_volt;
87 switch (rdev_get_id(rdev)) {
89 ramp_delay = s2mps11->ramp_delay2;
93 ramp_delay = s2mps11->ramp_delay34;
96 ramp_delay = s2mps11->ramp_delay5;
100 ramp_delay = s2mps11->ramp_delay16;
105 ramp_delay = s2mps11->ramp_delay7810;
108 ramp_delay = s2mps11->ramp_delay9;
112 ramp_delay = rdev->desc->ramp_delay;
114 old_volt = rdev->desc->min_uV + (rdev->desc->uV_step * old_selector);
115 new_volt = rdev->desc->min_uV + (rdev->desc->uV_step * new_selector);
117 return DIV_ROUND_UP(abs(new_volt - old_volt), ramp_delay);
120 static int s2mps11_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
122 struct s2mps11_info *s2mps11 = rdev_get_drvdata(rdev);
123 unsigned int ramp_val, ramp_shift, ramp_reg = S2MPS11_REG_RAMP_BUCK;
124 unsigned int ramp_enable = 1, enable_shift = 0;
127 switch (rdev_get_id(rdev)) {
129 if (ramp_delay > s2mps11->ramp_delay16)
130 s2mps11->ramp_delay16 = ramp_delay;
132 ramp_delay = s2mps11->ramp_delay16;
134 ramp_shift = S2MPS11_BUCK16_RAMP_SHIFT;
137 enable_shift = S2MPS11_BUCK2_RAMP_EN_SHIFT;
143 s2mps11->ramp_delay2 = ramp_delay;
144 ramp_shift = S2MPS11_BUCK2_RAMP_SHIFT;
145 ramp_reg = S2MPS11_REG_RAMP;
148 enable_shift = S2MPS11_BUCK3_RAMP_EN_SHIFT;
154 if (ramp_delay > s2mps11->ramp_delay34)
155 s2mps11->ramp_delay34 = ramp_delay;
157 ramp_delay = s2mps11->ramp_delay34;
159 ramp_shift = S2MPS11_BUCK34_RAMP_SHIFT;
160 ramp_reg = S2MPS11_REG_RAMP;
163 enable_shift = S2MPS11_BUCK4_RAMP_EN_SHIFT;
169 if (ramp_delay > s2mps11->ramp_delay34)
170 s2mps11->ramp_delay34 = ramp_delay;
172 ramp_delay = s2mps11->ramp_delay34;
174 ramp_shift = S2MPS11_BUCK34_RAMP_SHIFT;
175 ramp_reg = S2MPS11_REG_RAMP;
178 s2mps11->ramp_delay5 = ramp_delay;
179 ramp_shift = S2MPS11_BUCK5_RAMP_SHIFT;
182 enable_shift = S2MPS11_BUCK6_RAMP_EN_SHIFT;
188 if (ramp_delay > s2mps11->ramp_delay16)
189 s2mps11->ramp_delay16 = ramp_delay;
191 ramp_delay = s2mps11->ramp_delay16;
193 ramp_shift = S2MPS11_BUCK16_RAMP_SHIFT;
198 if (ramp_delay > s2mps11->ramp_delay7810)
199 s2mps11->ramp_delay7810 = ramp_delay;
201 ramp_delay = s2mps11->ramp_delay7810;
203 ramp_shift = S2MPS11_BUCK7810_RAMP_SHIFT;
206 s2mps11->ramp_delay9 = ramp_delay;
207 ramp_shift = S2MPS11_BUCK9_RAMP_SHIFT;
216 /* Ramp delay can be enabled/disabled only for buck[2346] */
217 if ((rdev_get_id(rdev) >= S2MPS11_BUCK2 &&
218 rdev_get_id(rdev) <= S2MPS11_BUCK4) ||
219 rdev_get_id(rdev) == S2MPS11_BUCK6) {
220 ret = regmap_update_bits(rdev->regmap, S2MPS11_REG_RAMP,
221 1 << enable_shift, 1 << enable_shift);
223 dev_err(&rdev->dev, "failed to enable ramp rate\n");
228 ramp_val = get_ramp_delay(ramp_delay);
230 return regmap_update_bits(rdev->regmap, ramp_reg, 0x3 << ramp_shift,
231 ramp_val << ramp_shift);
234 return regmap_update_bits(rdev->regmap, S2MPS11_REG_RAMP,
235 1 << enable_shift, 0);
238 static struct regulator_ops s2mps11_ldo_ops = {
239 .list_voltage = regulator_list_voltage_linear,
240 .map_voltage = regulator_map_voltage_linear,
241 .is_enabled = regulator_is_enabled_regmap,
242 .enable = regulator_enable_regmap,
243 .disable = regulator_disable_regmap,
244 .get_voltage_sel = regulator_get_voltage_sel_regmap,
245 .set_voltage_sel = regulator_set_voltage_sel_regmap,
246 .set_voltage_time_sel = regulator_set_voltage_time_sel,
249 static struct regulator_ops s2mps11_buck_ops = {
250 .list_voltage = regulator_list_voltage_linear,
251 .map_voltage = regulator_map_voltage_linear,
252 .is_enabled = regulator_is_enabled_regmap,
253 .enable = regulator_enable_regmap,
254 .disable = regulator_disable_regmap,
255 .get_voltage_sel = regulator_get_voltage_sel_regmap,
256 .set_voltage_sel = regulator_set_voltage_sel_regmap,
257 .set_voltage_time_sel = s2mps11_regulator_set_voltage_time_sel,
258 .set_ramp_delay = s2mps11_set_ramp_delay,
261 #define regulator_desc_s2mps11_ldo(num, step) { \
263 .id = S2MPS11_LDO##num, \
264 .ops = &s2mps11_ldo_ops, \
265 .type = REGULATOR_VOLTAGE, \
266 .owner = THIS_MODULE, \
267 .min_uV = MIN_800_MV, \
269 .n_voltages = S2MPS11_LDO_N_VOLTAGES, \
270 .vsel_reg = S2MPS11_REG_L1CTRL + num - 1, \
271 .vsel_mask = S2MPS11_LDO_VSEL_MASK, \
272 .enable_reg = S2MPS11_REG_L1CTRL + num - 1, \
273 .enable_mask = S2MPS11_ENABLE_MASK \
276 #define regulator_desc_s2mps11_buck1_4(num) { \
277 .name = "BUCK"#num, \
278 .id = S2MPS11_BUCK##num, \
279 .ops = &s2mps11_buck_ops, \
280 .type = REGULATOR_VOLTAGE, \
281 .owner = THIS_MODULE, \
282 .min_uV = MIN_600_MV, \
283 .uV_step = STEP_6_25_MV, \
284 .n_voltages = S2MPS11_BUCK_N_VOLTAGES, \
285 .ramp_delay = S2MPS11_RAMP_DELAY, \
286 .vsel_reg = S2MPS11_REG_B1CTRL2 + (num - 1) * 2, \
287 .vsel_mask = S2MPS11_BUCK_VSEL_MASK, \
288 .enable_reg = S2MPS11_REG_B1CTRL1 + (num - 1) * 2, \
289 .enable_mask = S2MPS11_ENABLE_MASK \
292 #define regulator_desc_s2mps11_buck5 { \
294 .id = S2MPS11_BUCK5, \
295 .ops = &s2mps11_buck_ops, \
296 .type = REGULATOR_VOLTAGE, \
297 .owner = THIS_MODULE, \
298 .min_uV = MIN_600_MV, \
299 .uV_step = STEP_6_25_MV, \
300 .n_voltages = S2MPS11_BUCK_N_VOLTAGES, \
301 .ramp_delay = S2MPS11_RAMP_DELAY, \
302 .vsel_reg = S2MPS11_REG_B5CTRL2, \
303 .vsel_mask = S2MPS11_BUCK_VSEL_MASK, \
304 .enable_reg = S2MPS11_REG_B5CTRL1, \
305 .enable_mask = S2MPS11_ENABLE_MASK \
308 #define regulator_desc_s2mps11_buck67810(num, min, step) { \
309 .name = "BUCK"#num, \
310 .id = S2MPS11_BUCK##num, \
311 .ops = &s2mps11_buck_ops, \
312 .type = REGULATOR_VOLTAGE, \
313 .owner = THIS_MODULE, \
316 .n_voltages = S2MPS11_BUCK_N_VOLTAGES, \
317 .ramp_delay = S2MPS11_RAMP_DELAY, \
318 .vsel_reg = S2MPS11_REG_B6CTRL2 + (num - 6) * 2, \
319 .vsel_mask = S2MPS11_BUCK_VSEL_MASK, \
320 .enable_reg = S2MPS11_REG_B6CTRL1 + (num - 6) * 2, \
321 .enable_mask = S2MPS11_ENABLE_MASK \
324 #define regulator_desc_s2mps11_buck9 { \
326 .id = S2MPS11_BUCK9, \
327 .ops = &s2mps11_buck_ops, \
328 .type = REGULATOR_VOLTAGE, \
329 .owner = THIS_MODULE, \
330 .min_uV = MIN_3000_MV, \
331 .uV_step = STEP_25_MV, \
332 .n_voltages = S2MPS11_BUCK9_N_VOLTAGES, \
333 .ramp_delay = S2MPS11_RAMP_DELAY, \
334 .vsel_reg = S2MPS11_REG_B9CTRL2, \
335 .vsel_mask = S2MPS11_BUCK9_VSEL_MASK, \
336 .enable_reg = S2MPS11_REG_B9CTRL1, \
337 .enable_mask = S2MPS11_ENABLE_MASK \
340 static const struct regulator_desc s2mps11_regulators[] = {
341 regulator_desc_s2mps11_ldo(1, STEP_25_MV),
342 regulator_desc_s2mps11_ldo(2, STEP_50_MV),
343 regulator_desc_s2mps11_ldo(3, STEP_50_MV),
344 regulator_desc_s2mps11_ldo(4, STEP_50_MV),
345 regulator_desc_s2mps11_ldo(5, STEP_50_MV),
346 regulator_desc_s2mps11_ldo(6, STEP_25_MV),
347 regulator_desc_s2mps11_ldo(7, STEP_50_MV),
348 regulator_desc_s2mps11_ldo(8, STEP_50_MV),
349 regulator_desc_s2mps11_ldo(9, STEP_50_MV),
350 regulator_desc_s2mps11_ldo(10, STEP_50_MV),
351 regulator_desc_s2mps11_ldo(11, STEP_25_MV),
352 regulator_desc_s2mps11_ldo(12, STEP_50_MV),
353 regulator_desc_s2mps11_ldo(13, STEP_50_MV),
354 regulator_desc_s2mps11_ldo(14, STEP_50_MV),
355 regulator_desc_s2mps11_ldo(15, STEP_50_MV),
356 regulator_desc_s2mps11_ldo(16, STEP_50_MV),
357 regulator_desc_s2mps11_ldo(17, STEP_50_MV),
358 regulator_desc_s2mps11_ldo(18, STEP_50_MV),
359 regulator_desc_s2mps11_ldo(19, STEP_50_MV),
360 regulator_desc_s2mps11_ldo(20, STEP_50_MV),
361 regulator_desc_s2mps11_ldo(21, STEP_50_MV),
362 regulator_desc_s2mps11_ldo(22, STEP_25_MV),
363 regulator_desc_s2mps11_ldo(23, STEP_25_MV),
364 regulator_desc_s2mps11_ldo(24, STEP_50_MV),
365 regulator_desc_s2mps11_ldo(25, STEP_50_MV),
366 regulator_desc_s2mps11_ldo(26, STEP_50_MV),
367 regulator_desc_s2mps11_ldo(27, STEP_25_MV),
368 regulator_desc_s2mps11_ldo(28, STEP_50_MV),
369 regulator_desc_s2mps11_ldo(29, STEP_50_MV),
370 regulator_desc_s2mps11_ldo(30, STEP_50_MV),
371 regulator_desc_s2mps11_ldo(31, STEP_50_MV),
372 regulator_desc_s2mps11_ldo(32, STEP_50_MV),
373 regulator_desc_s2mps11_ldo(33, STEP_50_MV),
374 regulator_desc_s2mps11_ldo(34, STEP_50_MV),
375 regulator_desc_s2mps11_ldo(35, STEP_50_MV),
376 regulator_desc_s2mps11_ldo(36, STEP_50_MV),
377 regulator_desc_s2mps11_ldo(37, STEP_50_MV),
378 regulator_desc_s2mps11_ldo(38, STEP_50_MV),
379 regulator_desc_s2mps11_buck1_4(1),
380 regulator_desc_s2mps11_buck1_4(2),
381 regulator_desc_s2mps11_buck1_4(3),
382 regulator_desc_s2mps11_buck1_4(4),
383 regulator_desc_s2mps11_buck5,
384 regulator_desc_s2mps11_buck67810(6, MIN_600_MV, STEP_6_25_MV),
385 regulator_desc_s2mps11_buck67810(7, MIN_600_MV, STEP_6_25_MV),
386 regulator_desc_s2mps11_buck67810(8, MIN_600_MV, STEP_6_25_MV),
387 regulator_desc_s2mps11_buck9,
388 regulator_desc_s2mps11_buck67810(10, MIN_750_MV, STEP_12_5_MV),
391 static struct regulator_ops s2mps14_reg_ops;
393 #define regulator_desc_s2mps13_ldo(num, min, step, min_sel) { \
395 .id = S2MPS13_LDO##num, \
396 .ops = &s2mps14_reg_ops, \
397 .type = REGULATOR_VOLTAGE, \
398 .owner = THIS_MODULE, \
401 .linear_min_sel = min_sel, \
402 .n_voltages = S2MPS14_LDO_N_VOLTAGES, \
403 .vsel_reg = S2MPS13_REG_L1CTRL + num - 1, \
404 .vsel_mask = S2MPS14_LDO_VSEL_MASK, \
405 .enable_reg = S2MPS13_REG_L1CTRL + num - 1, \
406 .enable_mask = S2MPS14_ENABLE_MASK \
409 #define regulator_desc_s2mps13_buck(num, min, step, min_sel) { \
410 .name = "BUCK"#num, \
411 .id = S2MPS13_BUCK##num, \
412 .ops = &s2mps14_reg_ops, \
413 .type = REGULATOR_VOLTAGE, \
414 .owner = THIS_MODULE, \
417 .linear_min_sel = min_sel, \
418 .n_voltages = S2MPS14_BUCK_N_VOLTAGES, \
419 .ramp_delay = S2MPS13_BUCK_RAMP_DELAY, \
420 .vsel_reg = S2MPS13_REG_B1OUT + (num - 1) * 2, \
421 .vsel_mask = S2MPS14_BUCK_VSEL_MASK, \
422 .enable_reg = S2MPS13_REG_B1CTRL + (num - 1) * 2, \
423 .enable_mask = S2MPS14_ENABLE_MASK \
426 #define regulator_desc_s2mps13_buck7(num, min, step, min_sel) { \
427 .name = "BUCK"#num, \
428 .id = S2MPS13_BUCK##num, \
429 .ops = &s2mps14_reg_ops, \
430 .type = REGULATOR_VOLTAGE, \
431 .owner = THIS_MODULE, \
434 .linear_min_sel = min_sel, \
435 .n_voltages = S2MPS14_BUCK_N_VOLTAGES, \
436 .ramp_delay = S2MPS13_BUCK_RAMP_DELAY, \
437 .vsel_reg = S2MPS13_REG_B1OUT + (num) * 2 - 1, \
438 .vsel_mask = S2MPS14_BUCK_VSEL_MASK, \
439 .enable_reg = S2MPS13_REG_B1CTRL + (num - 1) * 2, \
440 .enable_mask = S2MPS14_ENABLE_MASK \
443 #define regulator_desc_s2mps13_buck8_10(num, min, step, min_sel) { \
444 .name = "BUCK"#num, \
445 .id = S2MPS13_BUCK##num, \
446 .ops = &s2mps14_reg_ops, \
447 .type = REGULATOR_VOLTAGE, \
448 .owner = THIS_MODULE, \
451 .linear_min_sel = min_sel, \
452 .n_voltages = S2MPS14_BUCK_N_VOLTAGES, \
453 .ramp_delay = S2MPS13_BUCK_RAMP_DELAY, \
454 .vsel_reg = S2MPS13_REG_B1OUT + (num) * 2 - 1, \
455 .vsel_mask = S2MPS14_BUCK_VSEL_MASK, \
456 .enable_reg = S2MPS13_REG_B1CTRL + (num) * 2 - 1, \
457 .enable_mask = S2MPS14_ENABLE_MASK \
460 static const struct regulator_desc s2mps13_regulators[] = {
461 regulator_desc_s2mps13_ldo(1, MIN_800_MV, STEP_12_5_MV, 0x00),
462 regulator_desc_s2mps13_ldo(2, MIN_1400_MV, STEP_50_MV, 0x0C),
463 regulator_desc_s2mps13_ldo(3, MIN_1000_MV, STEP_25_MV, 0x08),
464 regulator_desc_s2mps13_ldo(4, MIN_800_MV, STEP_12_5_MV, 0x00),
465 regulator_desc_s2mps13_ldo(5, MIN_800_MV, STEP_12_5_MV, 0x00),
466 regulator_desc_s2mps13_ldo(6, MIN_800_MV, STEP_12_5_MV, 0x00),
467 regulator_desc_s2mps13_ldo(7, MIN_1000_MV, STEP_25_MV, 0x08),
468 regulator_desc_s2mps13_ldo(8, MIN_1000_MV, STEP_25_MV, 0x08),
469 regulator_desc_s2mps13_ldo(9, MIN_1000_MV, STEP_25_MV, 0x08),
470 regulator_desc_s2mps13_ldo(10, MIN_1400_MV, STEP_50_MV, 0x0C),
471 regulator_desc_s2mps13_ldo(11, MIN_800_MV, STEP_25_MV, 0x10),
472 regulator_desc_s2mps13_ldo(12, MIN_800_MV, STEP_25_MV, 0x10),
473 regulator_desc_s2mps13_ldo(13, MIN_800_MV, STEP_25_MV, 0x10),
474 regulator_desc_s2mps13_ldo(14, MIN_800_MV, STEP_12_5_MV, 0x00),
475 regulator_desc_s2mps13_ldo(15, MIN_800_MV, STEP_12_5_MV, 0x00),
476 regulator_desc_s2mps13_ldo(16, MIN_1400_MV, STEP_50_MV, 0x0C),
477 regulator_desc_s2mps13_ldo(17, MIN_1400_MV, STEP_50_MV, 0x0C),
478 regulator_desc_s2mps13_ldo(18, MIN_1000_MV, STEP_25_MV, 0x08),
479 regulator_desc_s2mps13_ldo(19, MIN_1000_MV, STEP_25_MV, 0x08),
480 regulator_desc_s2mps13_ldo(20, MIN_1400_MV, STEP_50_MV, 0x0C),
481 regulator_desc_s2mps13_ldo(21, MIN_1000_MV, STEP_25_MV, 0x08),
482 regulator_desc_s2mps13_ldo(22, MIN_1000_MV, STEP_25_MV, 0x08),
483 regulator_desc_s2mps13_ldo(23, MIN_800_MV, STEP_12_5_MV, 0x00),
484 regulator_desc_s2mps13_ldo(24, MIN_800_MV, STEP_12_5_MV, 0x00),
485 regulator_desc_s2mps13_ldo(25, MIN_1400_MV, STEP_50_MV, 0x0C),
486 regulator_desc_s2mps13_ldo(26, MIN_1400_MV, STEP_50_MV, 0x0C),
487 regulator_desc_s2mps13_ldo(27, MIN_1400_MV, STEP_50_MV, 0x0C),
488 regulator_desc_s2mps13_ldo(28, MIN_1000_MV, STEP_25_MV, 0x08),
489 regulator_desc_s2mps13_ldo(29, MIN_1400_MV, STEP_50_MV, 0x0C),
490 regulator_desc_s2mps13_ldo(30, MIN_1400_MV, STEP_50_MV, 0x0C),
491 regulator_desc_s2mps13_ldo(31, MIN_1000_MV, STEP_25_MV, 0x08),
492 regulator_desc_s2mps13_ldo(32, MIN_1000_MV, STEP_25_MV, 0x08),
493 regulator_desc_s2mps13_ldo(33, MIN_1400_MV, STEP_50_MV, 0x0C),
494 regulator_desc_s2mps13_ldo(34, MIN_1000_MV, STEP_25_MV, 0x08),
495 regulator_desc_s2mps13_ldo(35, MIN_1400_MV, STEP_50_MV, 0x0C),
496 regulator_desc_s2mps13_ldo(36, MIN_800_MV, STEP_12_5_MV, 0x00),
497 regulator_desc_s2mps13_ldo(37, MIN_1000_MV, STEP_25_MV, 0x08),
498 regulator_desc_s2mps13_ldo(38, MIN_1400_MV, STEP_50_MV, 0x0C),
499 regulator_desc_s2mps13_ldo(39, MIN_1000_MV, STEP_25_MV, 0x08),
500 regulator_desc_s2mps13_ldo(40, MIN_1400_MV, STEP_50_MV, 0x0C),
501 regulator_desc_s2mps13_buck(1, MIN_500_MV, STEP_6_25_MV, 0x10),
502 regulator_desc_s2mps13_buck(2, MIN_500_MV, STEP_6_25_MV, 0x10),
503 regulator_desc_s2mps13_buck(3, MIN_500_MV, STEP_6_25_MV, 0x10),
504 regulator_desc_s2mps13_buck(4, MIN_500_MV, STEP_6_25_MV, 0x10),
505 regulator_desc_s2mps13_buck(5, MIN_500_MV, STEP_6_25_MV, 0x10),
506 regulator_desc_s2mps13_buck(6, MIN_500_MV, STEP_6_25_MV, 0x10),
507 regulator_desc_s2mps13_buck7(7, MIN_500_MV, STEP_6_25_MV, 0x10),
508 regulator_desc_s2mps13_buck8_10(8, MIN_1000_MV, STEP_12_5_MV, 0x20),
509 regulator_desc_s2mps13_buck8_10(9, MIN_1000_MV, STEP_12_5_MV, 0x20),
510 regulator_desc_s2mps13_buck8_10(10, MIN_500_MV, STEP_6_25_MV, 0x10),
513 static int s2mps14_regulator_enable(struct regulator_dev *rdev)
515 struct s2mps11_info *s2mps11 = rdev_get_drvdata(rdev);
518 switch (s2mps11->dev_type) {
521 if (test_bit(rdev_get_id(rdev), s2mps11->suspend_state))
522 val = S2MPS14_ENABLE_SUSPEND;
523 else if (gpio_is_valid(s2mps11->ext_control_gpio[rdev_get_id(rdev)]))
524 val = S2MPS14_ENABLE_EXT_CONTROL;
526 val = rdev->desc->enable_mask;
529 if (test_bit(rdev_get_id(rdev), s2mps11->suspend_state))
530 val = S2MPU02_ENABLE_SUSPEND;
532 val = rdev->desc->enable_mask;
538 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
539 rdev->desc->enable_mask, val);
542 static int s2mps14_regulator_set_suspend_disable(struct regulator_dev *rdev)
545 unsigned int val, state;
546 struct s2mps11_info *s2mps11 = rdev_get_drvdata(rdev);
547 int rdev_id = rdev_get_id(rdev);
549 /* Below LDO should be always on or does not support suspend mode. */
550 switch (s2mps11->dev_type) {
557 state = S2MPS14_ENABLE_SUSPEND;
568 state = S2MPU02_DISABLE_SUSPEND;
571 state = S2MPU02_ENABLE_SUSPEND;
579 ret = regmap_read(rdev->regmap, rdev->desc->enable_reg, &val);
583 set_bit(rdev_get_id(rdev), s2mps11->suspend_state);
585 * Don't enable suspend mode if regulator is already disabled because
586 * this would effectively for a short time turn on the regulator after
588 * However we still want to toggle the suspend_state bit for regulator
589 * in case if it got enabled before suspending the system.
591 if (!(val & rdev->desc->enable_mask))
594 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
595 rdev->desc->enable_mask, state);
598 static struct regulator_ops s2mps14_reg_ops = {
599 .list_voltage = regulator_list_voltage_linear,
600 .map_voltage = regulator_map_voltage_linear,
601 .is_enabled = regulator_is_enabled_regmap,
602 .enable = s2mps14_regulator_enable,
603 .disable = regulator_disable_regmap,
604 .get_voltage_sel = regulator_get_voltage_sel_regmap,
605 .set_voltage_sel = regulator_set_voltage_sel_regmap,
606 .set_voltage_time_sel = regulator_set_voltage_time_sel,
607 .set_suspend_disable = s2mps14_regulator_set_suspend_disable,
610 #define regulator_desc_s2mps14_ldo(num, min, step) { \
612 .id = S2MPS14_LDO##num, \
613 .ops = &s2mps14_reg_ops, \
614 .type = REGULATOR_VOLTAGE, \
615 .owner = THIS_MODULE, \
618 .n_voltages = S2MPS14_LDO_N_VOLTAGES, \
619 .vsel_reg = S2MPS14_REG_L1CTRL + num - 1, \
620 .vsel_mask = S2MPS14_LDO_VSEL_MASK, \
621 .enable_reg = S2MPS14_REG_L1CTRL + num - 1, \
622 .enable_mask = S2MPS14_ENABLE_MASK \
625 #define regulator_desc_s2mps14_buck(num, min, step, min_sel) { \
626 .name = "BUCK"#num, \
627 .id = S2MPS14_BUCK##num, \
628 .ops = &s2mps14_reg_ops, \
629 .type = REGULATOR_VOLTAGE, \
630 .owner = THIS_MODULE, \
633 .n_voltages = S2MPS14_BUCK_N_VOLTAGES, \
634 .linear_min_sel = min_sel, \
635 .ramp_delay = S2MPS14_BUCK_RAMP_DELAY, \
636 .vsel_reg = S2MPS14_REG_B1CTRL2 + (num - 1) * 2, \
637 .vsel_mask = S2MPS14_BUCK_VSEL_MASK, \
638 .enable_reg = S2MPS14_REG_B1CTRL1 + (num - 1) * 2, \
639 .enable_mask = S2MPS14_ENABLE_MASK \
642 static const struct regulator_desc s2mps14_regulators[] = {
643 regulator_desc_s2mps14_ldo(1, MIN_800_MV, STEP_12_5_MV),
644 regulator_desc_s2mps14_ldo(2, MIN_800_MV, STEP_12_5_MV),
645 regulator_desc_s2mps14_ldo(3, MIN_800_MV, STEP_25_MV),
646 regulator_desc_s2mps14_ldo(4, MIN_800_MV, STEP_25_MV),
647 regulator_desc_s2mps14_ldo(5, MIN_800_MV, STEP_12_5_MV),
648 regulator_desc_s2mps14_ldo(6, MIN_800_MV, STEP_12_5_MV),
649 regulator_desc_s2mps14_ldo(7, MIN_800_MV, STEP_25_MV),
650 regulator_desc_s2mps14_ldo(8, MIN_1800_MV, STEP_25_MV),
651 regulator_desc_s2mps14_ldo(9, MIN_800_MV, STEP_12_5_MV),
652 regulator_desc_s2mps14_ldo(10, MIN_800_MV, STEP_12_5_MV),
653 regulator_desc_s2mps14_ldo(11, MIN_800_MV, STEP_25_MV),
654 regulator_desc_s2mps14_ldo(12, MIN_1800_MV, STEP_25_MV),
655 regulator_desc_s2mps14_ldo(13, MIN_1800_MV, STEP_25_MV),
656 regulator_desc_s2mps14_ldo(14, MIN_1800_MV, STEP_25_MV),
657 regulator_desc_s2mps14_ldo(15, MIN_1800_MV, STEP_25_MV),
658 regulator_desc_s2mps14_ldo(16, MIN_1800_MV, STEP_25_MV),
659 regulator_desc_s2mps14_ldo(17, MIN_1800_MV, STEP_25_MV),
660 regulator_desc_s2mps14_ldo(18, MIN_1800_MV, STEP_25_MV),
661 regulator_desc_s2mps14_ldo(19, MIN_800_MV, STEP_25_MV),
662 regulator_desc_s2mps14_ldo(20, MIN_800_MV, STEP_25_MV),
663 regulator_desc_s2mps14_ldo(21, MIN_800_MV, STEP_25_MV),
664 regulator_desc_s2mps14_ldo(22, MIN_800_MV, STEP_12_5_MV),
665 regulator_desc_s2mps14_ldo(23, MIN_800_MV, STEP_25_MV),
666 regulator_desc_s2mps14_ldo(24, MIN_1800_MV, STEP_25_MV),
667 regulator_desc_s2mps14_ldo(25, MIN_1800_MV, STEP_25_MV),
668 regulator_desc_s2mps14_buck(1, MIN_600_MV, STEP_6_25_MV,
669 S2MPS14_BUCK1235_START_SEL),
670 regulator_desc_s2mps14_buck(2, MIN_600_MV, STEP_6_25_MV,
671 S2MPS14_BUCK1235_START_SEL),
672 regulator_desc_s2mps14_buck(3, MIN_600_MV, STEP_6_25_MV,
673 S2MPS14_BUCK1235_START_SEL),
674 regulator_desc_s2mps14_buck(4, MIN_1400_MV, STEP_12_5_MV,
675 S2MPS14_BUCK4_START_SEL),
676 regulator_desc_s2mps14_buck(5, MIN_600_MV, STEP_6_25_MV,
677 S2MPS14_BUCK1235_START_SEL),
680 static int s2mps14_pmic_enable_ext_control(struct s2mps11_info *s2mps11,
681 struct regulator_dev *rdev)
683 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
684 rdev->desc->enable_mask, S2MPS14_ENABLE_EXT_CONTROL);
687 static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev,
688 struct of_regulator_match *rdata, struct s2mps11_info *s2mps11)
690 int *gpio = s2mps11->ext_control_gpio;
692 unsigned int valid_regulators[3] = { S2MPS14_LDO10, S2MPS14_LDO11,
695 for (i = 0; i < ARRAY_SIZE(valid_regulators); i++) {
696 unsigned int reg = valid_regulators[i];
698 if (!rdata[reg].init_data || !rdata[reg].of_node)
701 gpio[reg] = of_get_named_gpio(rdata[reg].of_node,
702 "samsung,ext-control-gpios", 0);
703 if (gpio_is_valid(gpio[reg]))
704 dev_dbg(&pdev->dev, "Using GPIO %d for ext-control over %d/%s\n",
705 gpio[reg], reg, rdata[reg].name);
709 static int s2mps11_pmic_dt_parse(struct platform_device *pdev,
710 struct of_regulator_match *rdata, struct s2mps11_info *s2mps11)
712 struct device_node *reg_np;
714 reg_np = of_get_child_by_name(pdev->dev.parent->of_node, "regulators");
716 dev_err(&pdev->dev, "could not find regulators sub-node\n");
720 of_regulator_match(&pdev->dev, reg_np, rdata, s2mps11->rdev_num);
721 if (s2mps11->dev_type == S2MPS14X)
722 s2mps14_pmic_dt_parse_ext_control_gpio(pdev, rdata, s2mps11);
729 static int s2mpu02_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
731 unsigned int ramp_val, ramp_shift, ramp_reg;
733 switch (rdev_get_id(rdev)) {
735 ramp_shift = S2MPU02_BUCK1_RAMP_SHIFT;
738 ramp_shift = S2MPU02_BUCK2_RAMP_SHIFT;
741 ramp_shift = S2MPU02_BUCK3_RAMP_SHIFT;
744 ramp_shift = S2MPU02_BUCK4_RAMP_SHIFT;
749 ramp_reg = S2MPU02_REG_RAMP1;
750 ramp_val = get_ramp_delay(ramp_delay);
752 return regmap_update_bits(rdev->regmap, ramp_reg,
753 S2MPU02_BUCK1234_RAMP_MASK << ramp_shift,
754 ramp_val << ramp_shift);
757 static struct regulator_ops s2mpu02_ldo_ops = {
758 .list_voltage = regulator_list_voltage_linear,
759 .map_voltage = regulator_map_voltage_linear,
760 .is_enabled = regulator_is_enabled_regmap,
761 .enable = s2mps14_regulator_enable,
762 .disable = regulator_disable_regmap,
763 .get_voltage_sel = regulator_get_voltage_sel_regmap,
764 .set_voltage_sel = regulator_set_voltage_sel_regmap,
765 .set_voltage_time_sel = regulator_set_voltage_time_sel,
766 .set_suspend_disable = s2mps14_regulator_set_suspend_disable,
769 static struct regulator_ops s2mpu02_buck_ops = {
770 .list_voltage = regulator_list_voltage_linear,
771 .map_voltage = regulator_map_voltage_linear,
772 .is_enabled = regulator_is_enabled_regmap,
773 .enable = s2mps14_regulator_enable,
774 .disable = regulator_disable_regmap,
775 .get_voltage_sel = regulator_get_voltage_sel_regmap,
776 .set_voltage_sel = regulator_set_voltage_sel_regmap,
777 .set_voltage_time_sel = regulator_set_voltage_time_sel,
778 .set_suspend_disable = s2mps14_regulator_set_suspend_disable,
779 .set_ramp_delay = s2mpu02_set_ramp_delay,
782 #define regulator_desc_s2mpu02_ldo1(num) { \
784 .id = S2MPU02_LDO##num, \
785 .ops = &s2mpu02_ldo_ops, \
786 .type = REGULATOR_VOLTAGE, \
787 .owner = THIS_MODULE, \
788 .min_uV = S2MPU02_LDO_MIN_900MV, \
789 .uV_step = S2MPU02_LDO_STEP_12_5MV, \
790 .linear_min_sel = S2MPU02_LDO_GROUP1_START_SEL, \
791 .n_voltages = S2MPU02_LDO_N_VOLTAGES, \
792 .vsel_reg = S2MPU02_REG_L1CTRL, \
793 .vsel_mask = S2MPU02_LDO_VSEL_MASK, \
794 .enable_reg = S2MPU02_REG_L1CTRL, \
795 .enable_mask = S2MPU02_ENABLE_MASK \
797 #define regulator_desc_s2mpu02_ldo2(num) { \
799 .id = S2MPU02_LDO##num, \
800 .ops = &s2mpu02_ldo_ops, \
801 .type = REGULATOR_VOLTAGE, \
802 .owner = THIS_MODULE, \
803 .min_uV = S2MPU02_LDO_MIN_1050MV, \
804 .uV_step = S2MPU02_LDO_STEP_25MV, \
805 .linear_min_sel = S2MPU02_LDO_GROUP2_START_SEL, \
806 .n_voltages = S2MPU02_LDO_N_VOLTAGES, \
807 .vsel_reg = S2MPU02_REG_L2CTRL1, \
808 .vsel_mask = S2MPU02_LDO_VSEL_MASK, \
809 .enable_reg = S2MPU02_REG_L2CTRL1, \
810 .enable_mask = S2MPU02_ENABLE_MASK \
812 #define regulator_desc_s2mpu02_ldo3(num) { \
814 .id = S2MPU02_LDO##num, \
815 .ops = &s2mpu02_ldo_ops, \
816 .type = REGULATOR_VOLTAGE, \
817 .owner = THIS_MODULE, \
818 .min_uV = S2MPU02_LDO_MIN_900MV, \
819 .uV_step = S2MPU02_LDO_STEP_12_5MV, \
820 .linear_min_sel = S2MPU02_LDO_GROUP1_START_SEL, \
821 .n_voltages = S2MPU02_LDO_N_VOLTAGES, \
822 .vsel_reg = S2MPU02_REG_L3CTRL + num - 3, \
823 .vsel_mask = S2MPU02_LDO_VSEL_MASK, \
824 .enable_reg = S2MPU02_REG_L3CTRL + num - 3, \
825 .enable_mask = S2MPU02_ENABLE_MASK \
827 #define regulator_desc_s2mpu02_ldo4(num) { \
829 .id = S2MPU02_LDO##num, \
830 .ops = &s2mpu02_ldo_ops, \
831 .type = REGULATOR_VOLTAGE, \
832 .owner = THIS_MODULE, \
833 .min_uV = S2MPU02_LDO_MIN_1050MV, \
834 .uV_step = S2MPU02_LDO_STEP_25MV, \
835 .linear_min_sel = S2MPU02_LDO_GROUP2_START_SEL, \
836 .n_voltages = S2MPU02_LDO_N_VOLTAGES, \
837 .vsel_reg = S2MPU02_REG_L3CTRL + num - 3, \
838 .vsel_mask = S2MPU02_LDO_VSEL_MASK, \
839 .enable_reg = S2MPU02_REG_L3CTRL + num - 3, \
840 .enable_mask = S2MPU02_ENABLE_MASK \
842 #define regulator_desc_s2mpu02_ldo5(num) { \
844 .id = S2MPU02_LDO##num, \
845 .ops = &s2mpu02_ldo_ops, \
846 .type = REGULATOR_VOLTAGE, \
847 .owner = THIS_MODULE, \
848 .min_uV = S2MPU02_LDO_MIN_1600MV, \
849 .uV_step = S2MPU02_LDO_STEP_50MV, \
850 .linear_min_sel = S2MPU02_LDO_GROUP3_START_SEL, \
851 .n_voltages = S2MPU02_LDO_N_VOLTAGES, \
852 .vsel_reg = S2MPU02_REG_L3CTRL + num - 3, \
853 .vsel_mask = S2MPU02_LDO_VSEL_MASK, \
854 .enable_reg = S2MPU02_REG_L3CTRL + num - 3, \
855 .enable_mask = S2MPU02_ENABLE_MASK \
858 #define regulator_desc_s2mpu02_buck1234(num) { \
859 .name = "BUCK"#num, \
860 .id = S2MPU02_BUCK##num, \
861 .ops = &s2mpu02_buck_ops, \
862 .type = REGULATOR_VOLTAGE, \
863 .owner = THIS_MODULE, \
864 .min_uV = S2MPU02_BUCK1234_MIN_600MV, \
865 .uV_step = S2MPU02_BUCK1234_STEP_6_25MV, \
866 .n_voltages = S2MPU02_BUCK_N_VOLTAGES, \
867 .linear_min_sel = S2MPU02_BUCK1234_START_SEL, \
868 .ramp_delay = S2MPU02_BUCK_RAMP_DELAY, \
869 .vsel_reg = S2MPU02_REG_B1CTRL2 + (num - 1) * 2, \
870 .vsel_mask = S2MPU02_BUCK_VSEL_MASK, \
871 .enable_reg = S2MPU02_REG_B1CTRL1 + (num - 1) * 2, \
872 .enable_mask = S2MPU02_ENABLE_MASK \
874 #define regulator_desc_s2mpu02_buck5(num) { \
875 .name = "BUCK"#num, \
876 .id = S2MPU02_BUCK##num, \
877 .ops = &s2mpu02_ldo_ops, \
878 .type = REGULATOR_VOLTAGE, \
879 .owner = THIS_MODULE, \
880 .min_uV = S2MPU02_BUCK5_MIN_1081_25MV, \
881 .uV_step = S2MPU02_BUCK5_STEP_6_25MV, \
882 .n_voltages = S2MPU02_BUCK_N_VOLTAGES, \
883 .linear_min_sel = S2MPU02_BUCK5_START_SEL, \
884 .ramp_delay = S2MPU02_BUCK_RAMP_DELAY, \
885 .vsel_reg = S2MPU02_REG_B5CTRL2, \
886 .vsel_mask = S2MPU02_BUCK_VSEL_MASK, \
887 .enable_reg = S2MPU02_REG_B5CTRL1, \
888 .enable_mask = S2MPU02_ENABLE_MASK \
890 #define regulator_desc_s2mpu02_buck6(num) { \
891 .name = "BUCK"#num, \
892 .id = S2MPU02_BUCK##num, \
893 .ops = &s2mpu02_ldo_ops, \
894 .type = REGULATOR_VOLTAGE, \
895 .owner = THIS_MODULE, \
896 .min_uV = S2MPU02_BUCK6_MIN_1700MV, \
897 .uV_step = S2MPU02_BUCK6_STEP_2_50MV, \
898 .n_voltages = S2MPU02_BUCK_N_VOLTAGES, \
899 .linear_min_sel = S2MPU02_BUCK6_START_SEL, \
900 .ramp_delay = S2MPU02_BUCK_RAMP_DELAY, \
901 .vsel_reg = S2MPU02_REG_B6CTRL2, \
902 .vsel_mask = S2MPU02_BUCK_VSEL_MASK, \
903 .enable_reg = S2MPU02_REG_B6CTRL1, \
904 .enable_mask = S2MPU02_ENABLE_MASK \
906 #define regulator_desc_s2mpu02_buck7(num) { \
907 .name = "BUCK"#num, \
908 .id = S2MPU02_BUCK##num, \
909 .ops = &s2mpu02_ldo_ops, \
910 .type = REGULATOR_VOLTAGE, \
911 .owner = THIS_MODULE, \
912 .min_uV = S2MPU02_BUCK7_MIN_900MV, \
913 .uV_step = S2MPU02_BUCK7_STEP_6_25MV, \
914 .n_voltages = S2MPU02_BUCK_N_VOLTAGES, \
915 .linear_min_sel = S2MPU02_BUCK7_START_SEL, \
916 .ramp_delay = S2MPU02_BUCK_RAMP_DELAY, \
917 .vsel_reg = S2MPU02_REG_B7CTRL2, \
918 .vsel_mask = S2MPU02_BUCK_VSEL_MASK, \
919 .enable_reg = S2MPU02_REG_B7CTRL1, \
920 .enable_mask = S2MPU02_ENABLE_MASK \
923 static const struct regulator_desc s2mpu02_regulators[] = {
924 regulator_desc_s2mpu02_ldo1(1),
925 regulator_desc_s2mpu02_ldo2(2),
926 regulator_desc_s2mpu02_ldo4(3),
927 regulator_desc_s2mpu02_ldo5(4),
928 regulator_desc_s2mpu02_ldo4(5),
929 regulator_desc_s2mpu02_ldo3(6),
930 regulator_desc_s2mpu02_ldo3(7),
931 regulator_desc_s2mpu02_ldo4(8),
932 regulator_desc_s2mpu02_ldo5(9),
933 regulator_desc_s2mpu02_ldo3(10),
934 regulator_desc_s2mpu02_ldo4(11),
935 regulator_desc_s2mpu02_ldo5(12),
936 regulator_desc_s2mpu02_ldo5(13),
937 regulator_desc_s2mpu02_ldo5(14),
938 regulator_desc_s2mpu02_ldo5(15),
939 regulator_desc_s2mpu02_ldo5(16),
940 regulator_desc_s2mpu02_ldo4(17),
941 regulator_desc_s2mpu02_ldo5(18),
942 regulator_desc_s2mpu02_ldo3(19),
943 regulator_desc_s2mpu02_ldo4(20),
944 regulator_desc_s2mpu02_ldo5(21),
945 regulator_desc_s2mpu02_ldo5(22),
946 regulator_desc_s2mpu02_ldo5(23),
947 regulator_desc_s2mpu02_ldo4(24),
948 regulator_desc_s2mpu02_ldo5(25),
949 regulator_desc_s2mpu02_ldo4(26),
950 regulator_desc_s2mpu02_ldo5(27),
951 regulator_desc_s2mpu02_ldo5(28),
952 regulator_desc_s2mpu02_buck1234(1),
953 regulator_desc_s2mpu02_buck1234(2),
954 regulator_desc_s2mpu02_buck1234(3),
955 regulator_desc_s2mpu02_buck1234(4),
956 regulator_desc_s2mpu02_buck5(5),
957 regulator_desc_s2mpu02_buck6(6),
958 regulator_desc_s2mpu02_buck7(7),
961 static int s2mps11_pmic_probe(struct platform_device *pdev)
963 struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
964 struct sec_platform_data *pdata = NULL;
965 struct of_regulator_match *rdata = NULL;
966 struct regulator_config config = { };
967 struct s2mps11_info *s2mps11;
969 const struct regulator_desc *regulators;
971 s2mps11 = devm_kzalloc(&pdev->dev, sizeof(struct s2mps11_info),
976 s2mps11->dev_type = platform_get_device_id(pdev)->driver_data;
977 switch (s2mps11->dev_type) {
979 s2mps11->rdev_num = ARRAY_SIZE(s2mps11_regulators);
980 regulators = s2mps11_regulators;
981 BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num);
984 s2mps11->rdev_num = ARRAY_SIZE(s2mps13_regulators);
985 regulators = s2mps13_regulators;
986 BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num);
989 s2mps11->rdev_num = ARRAY_SIZE(s2mps14_regulators);
990 regulators = s2mps14_regulators;
991 BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num);
994 s2mps11->rdev_num = ARRAY_SIZE(s2mpu02_regulators);
995 regulators = s2mpu02_regulators;
996 BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num);
999 dev_err(&pdev->dev, "Invalid device type: %u\n",
1004 s2mps11->ext_control_gpio = devm_kmalloc(&pdev->dev,
1005 sizeof(*s2mps11->ext_control_gpio) * s2mps11->rdev_num,
1007 if (!s2mps11->ext_control_gpio)
1010 * 0 is a valid GPIO so initialize all GPIO-s to negative value
1011 * to indicate that external control won't be used for this regulator.
1013 for (i = 0; i < s2mps11->rdev_num; i++)
1014 s2mps11->ext_control_gpio[i] = -EINVAL;
1016 if (!iodev->dev->of_node) {
1018 pdata = iodev->pdata;
1021 dev_err(pdev->dev.parent,
1022 "Platform data or DT node not supplied\n");
1027 rdata = kzalloc(sizeof(*rdata) * s2mps11->rdev_num, GFP_KERNEL);
1031 for (i = 0; i < s2mps11->rdev_num; i++)
1032 rdata[i].name = regulators[i].name;
1034 ret = s2mps11_pmic_dt_parse(pdev, rdata, s2mps11);
1039 platform_set_drvdata(pdev, s2mps11);
1041 config.dev = &pdev->dev;
1042 config.regmap = iodev->regmap_pmic;
1043 config.driver_data = s2mps11;
1044 config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH;
1045 config.ena_gpio_initialized = true;
1046 for (i = 0; i < s2mps11->rdev_num; i++) {
1047 struct regulator_dev *regulator;
1050 config.init_data = pdata->regulators[i].initdata;
1051 config.of_node = pdata->regulators[i].reg_node;
1053 config.init_data = rdata[i].init_data;
1054 config.of_node = rdata[i].of_node;
1056 config.ena_gpio = s2mps11->ext_control_gpio[i];
1058 regulator = devm_regulator_register(&pdev->dev,
1059 ®ulators[i], &config);
1060 if (IS_ERR(regulator)) {
1061 ret = PTR_ERR(regulator);
1062 dev_err(&pdev->dev, "regulator init failed for %d\n",
1067 if (gpio_is_valid(s2mps11->ext_control_gpio[i])) {
1068 ret = s2mps14_pmic_enable_ext_control(s2mps11,
1072 "failed to enable GPIO control over %s: %d\n",
1073 regulator->desc->name, ret);
1085 static const struct platform_device_id s2mps11_pmic_id[] = {
1086 { "s2mps11-pmic", S2MPS11X},
1087 { "s2mps13-pmic", S2MPS13X},
1088 { "s2mps14-pmic", S2MPS14X},
1089 { "s2mpu02-pmic", S2MPU02},
1092 MODULE_DEVICE_TABLE(platform, s2mps11_pmic_id);
1094 static struct platform_driver s2mps11_pmic_driver = {
1096 .name = "s2mps11-pmic",
1098 .probe = s2mps11_pmic_probe,
1099 .id_table = s2mps11_pmic_id,
1102 static int __init s2mps11_pmic_init(void)
1104 return platform_driver_register(&s2mps11_pmic_driver);
1106 subsys_initcall(s2mps11_pmic_init);
1108 static void __exit s2mps11_pmic_exit(void)
1110 platform_driver_unregister(&s2mps11_pmic_driver);
1112 module_exit(s2mps11_pmic_exit);
1114 /* Module information */
1115 MODULE_AUTHOR("Sangbeom Kim <sbkim73@samsung.com>");
1116 MODULE_DESCRIPTION("SAMSUNG S2MPS11/S2MPS14/S2MPU02 Regulator Driver");
1117 MODULE_LICENSE("GPL");