Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / regulator / bd718x7-regulator.c
blob9309765d0450ec8fe9f1eca04f5b638fd8db2e86
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2018 ROHM Semiconductors
3 // bd71837-regulator.c ROHM BD71837MWV/BD71847MWV regulator driver
5 #include <linux/delay.h>
6 #include <linux/err.h>
7 #include <linux/interrupt.h>
8 #include <linux/kernel.h>
9 #include <linux/mfd/rohm-bd718x7.h>
10 #include <linux/module.h>
11 #include <linux/of.h>
12 #include <linux/platform_device.h>
13 #include <linux/regulator/driver.h>
14 #include <linux/regulator/machine.h>
15 #include <linux/regulator/of_regulator.h>
16 #include <linux/slab.h>
18 /* Typical regulator startup times as per data sheet in uS */
19 #define BD71847_BUCK1_STARTUP_TIME 144
20 #define BD71847_BUCK2_STARTUP_TIME 162
21 #define BD71847_BUCK3_STARTUP_TIME 162
22 #define BD71847_BUCK4_STARTUP_TIME 240
23 #define BD71847_BUCK5_STARTUP_TIME 270
24 #define BD71847_BUCK6_STARTUP_TIME 200
25 #define BD71847_LDO1_STARTUP_TIME 440
26 #define BD71847_LDO2_STARTUP_TIME 370
27 #define BD71847_LDO3_STARTUP_TIME 310
28 #define BD71847_LDO4_STARTUP_TIME 400
29 #define BD71847_LDO5_STARTUP_TIME 530
30 #define BD71847_LDO6_STARTUP_TIME 400
32 #define BD71837_BUCK1_STARTUP_TIME 160
33 #define BD71837_BUCK2_STARTUP_TIME 180
34 #define BD71837_BUCK3_STARTUP_TIME 180
35 #define BD71837_BUCK4_STARTUP_TIME 180
36 #define BD71837_BUCK5_STARTUP_TIME 160
37 #define BD71837_BUCK6_STARTUP_TIME 240
38 #define BD71837_BUCK7_STARTUP_TIME 220
39 #define BD71837_BUCK8_STARTUP_TIME 200
40 #define BD71837_LDO1_STARTUP_TIME 440
41 #define BD71837_LDO2_STARTUP_TIME 370
42 #define BD71837_LDO3_STARTUP_TIME 310
43 #define BD71837_LDO4_STARTUP_TIME 400
44 #define BD71837_LDO5_STARTUP_TIME 310
45 #define BD71837_LDO6_STARTUP_TIME 400
46 #define BD71837_LDO7_STARTUP_TIME 530
49 * BD718(37/47/50) have two "enable control modes". ON/OFF can either be
50 * controlled by software - or by PMIC internal HW state machine. Whether
51 * regulator should be under SW or HW control can be defined from device-tree.
52 * Let's provide separate ops for regulators to use depending on the "enable
53 * control mode".
55 #define BD718XX_HWOPNAME(swopname) swopname##_hwcontrol
57 #define BD718XX_OPS(name, _list_voltage, _map_voltage, _set_voltage_sel, \
58 _get_voltage_sel, _set_voltage_time_sel, _set_ramp_delay) \
59 static const struct regulator_ops name = { \
60 .enable = regulator_enable_regmap, \
61 .disable = regulator_disable_regmap, \
62 .is_enabled = regulator_is_enabled_regmap, \
63 .list_voltage = (_list_voltage), \
64 .map_voltage = (_map_voltage), \
65 .set_voltage_sel = (_set_voltage_sel), \
66 .get_voltage_sel = (_get_voltage_sel), \
67 .set_voltage_time_sel = (_set_voltage_time_sel), \
68 .set_ramp_delay = (_set_ramp_delay), \
69 }; \
71 static const struct regulator_ops BD718XX_HWOPNAME(name) = { \
72 .is_enabled = always_enabled_by_hwstate, \
73 .list_voltage = (_list_voltage), \
74 .map_voltage = (_map_voltage), \
75 .set_voltage_sel = (_set_voltage_sel), \
76 .get_voltage_sel = (_get_voltage_sel), \
77 .set_voltage_time_sel = (_set_voltage_time_sel), \
78 .set_ramp_delay = (_set_ramp_delay), \
79 } \
82 * BUCK1/2/3/4
83 * BUCK1RAMPRATE[1:0] BUCK1 DVS ramp rate setting
84 * 00: 10.00mV/usec 10mV 1uS
85 * 01: 5.00mV/usec 10mV 2uS
86 * 10: 2.50mV/usec 10mV 4uS
87 * 11: 1.25mV/usec 10mV 8uS
89 static int bd718xx_buck1234_set_ramp_delay(struct regulator_dev *rdev,
90 int ramp_delay)
92 int id = rdev_get_id(rdev);
93 unsigned int ramp_value;
95 dev_dbg(&rdev->dev, "Buck[%d] Set Ramp = %d\n", id + 1,
96 ramp_delay);
97 switch (ramp_delay) {
98 case 1 ... 1250:
99 ramp_value = BUCK_RAMPRATE_1P25MV;
100 break;
101 case 1251 ... 2500:
102 ramp_value = BUCK_RAMPRATE_2P50MV;
103 break;
104 case 2501 ... 5000:
105 ramp_value = BUCK_RAMPRATE_5P00MV;
106 break;
107 case 5001 ... 10000:
108 ramp_value = BUCK_RAMPRATE_10P00MV;
109 break;
110 default:
111 ramp_value = BUCK_RAMPRATE_10P00MV;
112 dev_err(&rdev->dev,
113 "%s: ramp_delay: %d not supported, setting 10000mV//us\n",
114 rdev->desc->name, ramp_delay);
117 return regmap_update_bits(rdev->regmap, BD718XX_REG_BUCK1_CTRL + id,
118 BUCK_RAMPRATE_MASK, ramp_value << 6);
121 /* These functions are used when regulators are under HW state machine control.
122 * We assume PMIC is in RUN state because SW running and able to query the
123 * status. Most of the regulators have fixed ON or OFF state at RUN/IDLE so for
124 * them we just return a constant. BD71837 BUCK3 and BUCK4 are exceptions as
125 * they support configuring the ON/OFF state for RUN.
127 * Note for next hacker - these PMICs have a register where the HW state can be
128 * read. If assuming RUN appears to be false in your use-case - you can
129 * implement state reading (although that is not going to be atomic) before
130 * returning the enable state.
132 static int always_enabled_by_hwstate(struct regulator_dev *rdev)
134 return 1;
137 static int never_enabled_by_hwstate(struct regulator_dev *rdev)
139 return 0;
142 static int bd71837_get_buck34_enable_hwctrl(struct regulator_dev *rdev)
144 int ret;
145 unsigned int val;
147 ret = regmap_read(rdev->regmap, rdev->desc->enable_reg, &val);
148 if (ret)
149 return ret;
151 return !!(BD718XX_BUCK_RUN_ON & val);
154 * On BD71837 (not on BD71847, BD71850, ...)
155 * Bucks 1 to 4 support DVS. PWM mode is used when voltage is changed.
156 * Bucks 5 to 8 and LDOs can use PFM and must be disabled when voltage
157 * is changed. Hence we return -EBUSY for these if voltage is changed
158 * when BUCK/LDO is enabled.
160 * On BD71847, BD71850, ... The LDO voltage can be changed when LDO is
161 * enabled. But if voltage is increased the LDO power-good monitoring
162 * must be disabled for the duration of changing + 1mS to ensure voltage
163 * has reached the higher level before HW does next under voltage detection
164 * cycle.
166 static int bd71837_set_voltage_sel_restricted(struct regulator_dev *rdev,
167 unsigned int sel)
169 if (rdev->desc->ops->is_enabled(rdev))
170 return -EBUSY;
172 return regulator_set_voltage_sel_regmap(rdev, sel);
175 static void voltage_change_done(struct regulator_dev *rdev, unsigned int sel,
176 unsigned int *mask)
178 int ret;
180 if (*mask) {
182 * Let's allow scheduling as we use I2C anyways. We just need to
183 * guarantee minimum of 1ms sleep - it shouldn't matter if we
184 * exceed it due to the scheduling.
186 msleep(1);
188 * Note for next hacker. The PWRGOOD should not be masked on
189 * BD71847 so we will just unconditionally enable detection
190 * when voltage is set.
191 * If someone want's to disable PWRGOOD he must implement
192 * caching and restoring the old value here. I am not
193 * aware of such use-cases so for the sake of the simplicity
194 * we just always enable PWRGOOD here.
196 ret = regmap_update_bits(rdev->regmap, BD718XX_REG_MVRFLTMASK2,
197 *mask, 0);
198 if (ret)
199 dev_err(&rdev->dev,
200 "Failed to re-enable voltage monitoring (%d)\n",
201 ret);
205 static int voltage_change_prepare(struct regulator_dev *rdev, unsigned int sel,
206 unsigned int *mask)
208 int ret;
210 *mask = 0;
211 if (rdev->desc->ops->is_enabled(rdev)) {
212 int now, new;
214 now = rdev->desc->ops->get_voltage_sel(rdev);
215 if (now < 0)
216 return now;
218 now = rdev->desc->ops->list_voltage(rdev, now);
219 if (now < 0)
220 return now;
222 new = rdev->desc->ops->list_voltage(rdev, sel);
223 if (new < 0)
224 return new;
227 * If we increase LDO voltage when LDO is enabled we need to
228 * disable the power-good detection until voltage has reached
229 * the new level. According to HW colleagues the maximum time
230 * it takes is 1000us. I assume that on systems with light load
231 * this might be less - and we could probably use DT to give
232 * system specific delay value if performance matters.
234 * Well, knowing we use I2C here and can add scheduling delays
235 * I don't think it is worth the hassle and I just add fixed
236 * 1ms sleep here (and allow scheduling). If this turns out to
237 * be a problem we can change it to delay and make the delay
238 * time configurable.
240 if (new > now) {
241 int ldo_offset = rdev->desc->id - BD718XX_LDO1;
243 *mask = BD718XX_LDO1_VRMON80 << ldo_offset;
244 ret = regmap_update_bits(rdev->regmap,
245 BD718XX_REG_MVRFLTMASK2,
246 *mask, *mask);
247 if (ret) {
248 dev_err(&rdev->dev,
249 "Failed to stop voltage monitoring\n");
250 return ret;
255 return 0;
258 static int bd718xx_set_voltage_sel_restricted(struct regulator_dev *rdev,
259 unsigned int sel)
261 int ret;
262 int mask;
264 ret = voltage_change_prepare(rdev, sel, &mask);
265 if (ret)
266 return ret;
268 ret = regulator_set_voltage_sel_regmap(rdev, sel);
269 voltage_change_done(rdev, sel, &mask);
271 return ret;
274 static int bd718xx_set_voltage_sel_pickable_restricted(
275 struct regulator_dev *rdev, unsigned int sel)
277 int ret;
278 int mask;
280 ret = voltage_change_prepare(rdev, sel, &mask);
281 if (ret)
282 return ret;
284 ret = regulator_set_voltage_sel_pickable_regmap(rdev, sel);
285 voltage_change_done(rdev, sel, &mask);
287 return ret;
290 static int bd71837_set_voltage_sel_pickable_restricted(
291 struct regulator_dev *rdev, unsigned int sel)
293 if (rdev->desc->ops->is_enabled(rdev))
294 return -EBUSY;
296 return regulator_set_voltage_sel_pickable_regmap(rdev, sel);
300 * OPS common for BD71847 and BD71850
302 BD718XX_OPS(bd718xx_pickable_range_ldo_ops,
303 regulator_list_voltage_pickable_linear_range, NULL,
304 bd718xx_set_voltage_sel_pickable_restricted,
305 regulator_get_voltage_sel_pickable_regmap, NULL, NULL);
307 /* BD71847 and BD71850 LDO 5 is by default OFF at RUN state */
308 static const struct regulator_ops bd718xx_ldo5_ops_hwstate = {
309 .is_enabled = never_enabled_by_hwstate,
310 .list_voltage = regulator_list_voltage_pickable_linear_range,
311 .set_voltage_sel = bd718xx_set_voltage_sel_pickable_restricted,
312 .get_voltage_sel = regulator_get_voltage_sel_pickable_regmap,
315 BD718XX_OPS(bd718xx_pickable_range_buck_ops,
316 regulator_list_voltage_pickable_linear_range, NULL,
317 regulator_set_voltage_sel_pickable_regmap,
318 regulator_get_voltage_sel_pickable_regmap,
319 regulator_set_voltage_time_sel, NULL);
321 BD718XX_OPS(bd718xx_ldo_regulator_ops, regulator_list_voltage_linear_range,
322 NULL, bd718xx_set_voltage_sel_restricted,
323 regulator_get_voltage_sel_regmap, NULL, NULL);
325 BD718XX_OPS(bd718xx_ldo_regulator_nolinear_ops, regulator_list_voltage_table,
326 NULL, bd718xx_set_voltage_sel_restricted,
327 regulator_get_voltage_sel_regmap, NULL, NULL);
329 BD718XX_OPS(bd718xx_buck_regulator_ops, regulator_list_voltage_linear_range,
330 NULL, regulator_set_voltage_sel_regmap,
331 regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
332 NULL);
334 BD718XX_OPS(bd718xx_buck_regulator_nolinear_ops, regulator_list_voltage_table,
335 regulator_map_voltage_ascend, regulator_set_voltage_sel_regmap,
336 regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
337 NULL);
340 * OPS for BD71837
342 BD718XX_OPS(bd71837_pickable_range_ldo_ops,
343 regulator_list_voltage_pickable_linear_range, NULL,
344 bd71837_set_voltage_sel_pickable_restricted,
345 regulator_get_voltage_sel_pickable_regmap, NULL, NULL);
347 BD718XX_OPS(bd71837_pickable_range_buck_ops,
348 regulator_list_voltage_pickable_linear_range, NULL,
349 bd71837_set_voltage_sel_pickable_restricted,
350 regulator_get_voltage_sel_pickable_regmap,
351 regulator_set_voltage_time_sel, NULL);
353 BD718XX_OPS(bd71837_ldo_regulator_ops, regulator_list_voltage_linear_range,
354 NULL, bd71837_set_voltage_sel_restricted,
355 regulator_get_voltage_sel_regmap, NULL, NULL);
357 BD718XX_OPS(bd71837_ldo_regulator_nolinear_ops, regulator_list_voltage_table,
358 NULL, bd71837_set_voltage_sel_restricted,
359 regulator_get_voltage_sel_regmap, NULL, NULL);
361 BD718XX_OPS(bd71837_buck_regulator_ops, regulator_list_voltage_linear_range,
362 NULL, bd71837_set_voltage_sel_restricted,
363 regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
364 NULL);
366 BD718XX_OPS(bd71837_buck_regulator_nolinear_ops, regulator_list_voltage_table,
367 regulator_map_voltage_ascend, bd718xx_set_voltage_sel_restricted,
368 regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
369 NULL);
371 * BD71837 bucks 3 and 4 support defining their enable/disable state also
372 * when buck enable state is under HW state machine control. In that case the
373 * bit [2] in CTRL register is used to indicate if regulator should be ON.
375 static const struct regulator_ops bd71837_buck34_ops_hwctrl = {
376 .is_enabled = bd71837_get_buck34_enable_hwctrl,
377 .list_voltage = regulator_list_voltage_linear_range,
378 .set_voltage_sel = regulator_set_voltage_sel_regmap,
379 .get_voltage_sel = regulator_get_voltage_sel_regmap,
380 .set_voltage_time_sel = regulator_set_voltage_time_sel,
381 .set_ramp_delay = bd718xx_buck1234_set_ramp_delay,
385 * OPS for all of the ICs - BD718(37/47/50)
387 BD718XX_OPS(bd718xx_dvs_buck_regulator_ops, regulator_list_voltage_linear_range,
388 NULL, regulator_set_voltage_sel_regmap,
389 regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
390 bd718xx_buck1234_set_ramp_delay);
393 * BD71837 BUCK1/2/3/4
394 * BD71847 BUCK1/2
395 * 0.70 to 1.30V (10mV step)
397 static const struct linear_range bd718xx_dvs_buck_volts[] = {
398 REGULATOR_LINEAR_RANGE(700000, 0x00, 0x3C, 10000),
399 REGULATOR_LINEAR_RANGE(1300000, 0x3D, 0x3F, 0),
403 * BD71837 BUCK5
404 * 0.7V to 1.35V (range 0)
405 * and
406 * 0.675 to 1.325 (range 1)
408 static const struct linear_range bd71837_buck5_volts[] = {
409 /* Ranges when VOLT_SEL bit is 0 */
410 REGULATOR_LINEAR_RANGE(700000, 0x00, 0x03, 100000),
411 REGULATOR_LINEAR_RANGE(1050000, 0x04, 0x05, 50000),
412 REGULATOR_LINEAR_RANGE(1200000, 0x06, 0x07, 150000),
413 /* Ranges when VOLT_SEL bit is 1 */
414 REGULATOR_LINEAR_RANGE(675000, 0x0, 0x3, 100000),
415 REGULATOR_LINEAR_RANGE(1025000, 0x4, 0x5, 50000),
416 REGULATOR_LINEAR_RANGE(1175000, 0x6, 0x7, 150000),
420 * Range selector for first 3 linear ranges is 0x0
421 * and 0x1 for last 3 ranges.
423 static const unsigned int bd71837_buck5_volt_range_sel[] = {
424 0x0, 0x0, 0x0, 0x80, 0x80, 0x80
428 * BD71847 BUCK3
430 static const struct linear_range bd71847_buck3_volts[] = {
431 /* Ranges when VOLT_SEL bits are 00 */
432 REGULATOR_LINEAR_RANGE(700000, 0x00, 0x03, 100000),
433 REGULATOR_LINEAR_RANGE(1050000, 0x04, 0x05, 50000),
434 REGULATOR_LINEAR_RANGE(1200000, 0x06, 0x07, 150000),
435 /* Ranges when VOLT_SEL bits are 01 */
436 REGULATOR_LINEAR_RANGE(550000, 0x0, 0x7, 50000),
437 /* Ranges when VOLT_SEL bits are 11 */
438 REGULATOR_LINEAR_RANGE(675000, 0x0, 0x3, 100000),
439 REGULATOR_LINEAR_RANGE(1025000, 0x4, 0x5, 50000),
440 REGULATOR_LINEAR_RANGE(1175000, 0x6, 0x7, 150000),
443 static const unsigned int bd71847_buck3_volt_range_sel[] = {
444 0x0, 0x0, 0x0, 0x40, 0x80, 0x80, 0x80
447 static const struct linear_range bd71847_buck4_volts[] = {
448 REGULATOR_LINEAR_RANGE(3000000, 0x00, 0x03, 100000),
449 REGULATOR_LINEAR_RANGE(2600000, 0x00, 0x03, 100000),
452 static const unsigned int bd71847_buck4_volt_range_sel[] = { 0x0, 0x40 };
455 * BUCK6
456 * 3.0V to 3.3V (step 100mV)
458 static const struct linear_range bd71837_buck6_volts[] = {
459 REGULATOR_LINEAR_RANGE(3000000, 0x00, 0x03, 100000),
463 * BD71837 BUCK7
464 * BD71847 BUCK5
465 * 000 = 1.605V
466 * 001 = 1.695V
467 * 010 = 1.755V
468 * 011 = 1.8V (Initial)
469 * 100 = 1.845V
470 * 101 = 1.905V
471 * 110 = 1.95V
472 * 111 = 1.995V
474 static const unsigned int bd718xx_3rd_nodvs_buck_volts[] = {
475 1605000, 1695000, 1755000, 1800000, 1845000, 1905000, 1950000, 1995000
479 * BUCK8
480 * 0.8V to 1.40V (step 10mV)
482 static const struct linear_range bd718xx_4th_nodvs_buck_volts[] = {
483 REGULATOR_LINEAR_RANGE(800000, 0x00, 0x3C, 10000),
487 * LDO1
488 * 3.0 to 3.3V (100mV step)
490 static const struct linear_range bd718xx_ldo1_volts[] = {
491 REGULATOR_LINEAR_RANGE(3000000, 0x00, 0x03, 100000),
492 REGULATOR_LINEAR_RANGE(1600000, 0x00, 0x03, 100000),
495 static const unsigned int bd718xx_ldo1_volt_range_sel[] = { 0x0, 0x20 };
498 * LDO2
499 * 0.8 or 0.9V
501 static const unsigned int ldo_2_volts[] = {
502 900000, 800000
506 * LDO3
507 * 1.8 to 3.3V (100mV step)
509 static const struct linear_range bd718xx_ldo3_volts[] = {
510 REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
514 * LDO4
515 * 0.9 to 1.8V (100mV step)
517 static const struct linear_range bd718xx_ldo4_volts[] = {
518 REGULATOR_LINEAR_RANGE(900000, 0x00, 0x09, 100000),
522 * LDO5 for BD71837
523 * 1.8 to 3.3V (100mV step)
525 static const struct linear_range bd71837_ldo5_volts[] = {
526 REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
530 * LDO5 for BD71837
531 * 1.8 to 3.3V (100mV step)
533 static const struct linear_range bd71847_ldo5_volts[] = {
534 REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
535 REGULATOR_LINEAR_RANGE(800000, 0x00, 0x0F, 100000),
538 static const unsigned int bd71847_ldo5_volt_range_sel[] = { 0x0, 0x20 };
541 * LDO6
542 * 0.9 to 1.8V (100mV step)
544 static const struct linear_range bd718xx_ldo6_volts[] = {
545 REGULATOR_LINEAR_RANGE(900000, 0x00, 0x09, 100000),
549 * LDO7
550 * 1.8 to 3.3V (100mV step)
552 static const struct linear_range bd71837_ldo7_volts[] = {
553 REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
556 struct reg_init {
557 unsigned int reg;
558 unsigned int mask;
559 unsigned int val;
561 struct bd718xx_regulator_data {
562 struct regulator_desc desc;
563 const struct rohm_dvs_config dvs;
564 const struct reg_init init;
565 const struct reg_init *additional_inits;
566 int additional_init_amnt;
570 * There is a HW quirk in BD71837. The shutdown sequence timings for
571 * bucks/LDOs which are controlled via register interface are changed.
572 * At PMIC poweroff the voltage for BUCK6/7 is cut immediately at the
573 * beginning of shut-down sequence. As bucks 6 and 7 are parent
574 * supplies for LDO5 and LDO6 - this causes LDO5/6 voltage
575 * monitoring to errorneously detect under voltage and force PMIC to
576 * emergency state instead of poweroff. In order to avoid this we
577 * disable voltage monitoring for LDO5 and LDO6
579 static const struct reg_init bd71837_ldo5_inits[] = {
581 .reg = BD718XX_REG_MVRFLTMASK2,
582 .mask = BD718XX_LDO5_VRMON80,
583 .val = BD718XX_LDO5_VRMON80,
587 static const struct reg_init bd71837_ldo6_inits[] = {
589 .reg = BD718XX_REG_MVRFLTMASK2,
590 .mask = BD718XX_LDO6_VRMON80,
591 .val = BD718XX_LDO6_VRMON80,
595 static int buck_set_hw_dvs_levels(struct device_node *np,
596 const struct regulator_desc *desc,
597 struct regulator_config *cfg)
599 struct bd718xx_regulator_data *data;
601 data = container_of(desc, struct bd718xx_regulator_data, desc);
603 return rohm_regulator_set_dvs_levels(&data->dvs, np, desc, cfg->regmap);
606 static const struct regulator_ops *bd71847_swcontrol_ops[] = {
607 &bd718xx_dvs_buck_regulator_ops, &bd718xx_dvs_buck_regulator_ops,
608 &bd718xx_pickable_range_buck_ops, &bd718xx_pickable_range_buck_ops,
609 &bd718xx_buck_regulator_nolinear_ops, &bd718xx_buck_regulator_ops,
610 &bd718xx_pickable_range_ldo_ops, &bd718xx_ldo_regulator_nolinear_ops,
611 &bd718xx_ldo_regulator_ops, &bd718xx_ldo_regulator_ops,
612 &bd718xx_pickable_range_ldo_ops, &bd718xx_ldo_regulator_ops,
615 static const struct regulator_ops *bd71847_hwcontrol_ops[] = {
616 &BD718XX_HWOPNAME(bd718xx_dvs_buck_regulator_ops),
617 &BD718XX_HWOPNAME(bd718xx_dvs_buck_regulator_ops),
618 &BD718XX_HWOPNAME(bd718xx_pickable_range_buck_ops),
619 &BD718XX_HWOPNAME(bd718xx_pickable_range_buck_ops),
620 &BD718XX_HWOPNAME(bd718xx_buck_regulator_nolinear_ops),
621 &BD718XX_HWOPNAME(bd718xx_buck_regulator_ops),
622 &BD718XX_HWOPNAME(bd718xx_pickable_range_ldo_ops),
623 &BD718XX_HWOPNAME(bd718xx_ldo_regulator_nolinear_ops),
624 &BD718XX_HWOPNAME(bd718xx_ldo_regulator_ops),
625 &BD718XX_HWOPNAME(bd718xx_ldo_regulator_ops),
626 &bd718xx_ldo5_ops_hwstate,
627 &BD718XX_HWOPNAME(bd718xx_ldo_regulator_ops),
630 static struct bd718xx_regulator_data bd71847_regulators[] = {
632 .desc = {
633 .name = "buck1",
634 .of_match = of_match_ptr("BUCK1"),
635 .regulators_node = of_match_ptr("regulators"),
636 .id = BD718XX_BUCK1,
637 .type = REGULATOR_VOLTAGE,
638 .n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
639 .linear_ranges = bd718xx_dvs_buck_volts,
640 .n_linear_ranges =
641 ARRAY_SIZE(bd718xx_dvs_buck_volts),
642 .vsel_reg = BD718XX_REG_BUCK1_VOLT_RUN,
643 .vsel_mask = DVS_BUCK_RUN_MASK,
644 .enable_reg = BD718XX_REG_BUCK1_CTRL,
645 .enable_mask = BD718XX_BUCK_EN,
646 .enable_time = BD71847_BUCK1_STARTUP_TIME,
647 .owner = THIS_MODULE,
648 .of_parse_cb = buck_set_hw_dvs_levels,
650 .dvs = {
651 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
652 ROHM_DVS_LEVEL_SUSPEND,
653 .run_reg = BD718XX_REG_BUCK1_VOLT_RUN,
654 .run_mask = DVS_BUCK_RUN_MASK,
655 .idle_reg = BD718XX_REG_BUCK1_VOLT_IDLE,
656 .idle_mask = DVS_BUCK_RUN_MASK,
657 .suspend_reg = BD718XX_REG_BUCK1_VOLT_SUSP,
658 .suspend_mask = DVS_BUCK_RUN_MASK,
660 .init = {
661 .reg = BD718XX_REG_BUCK1_CTRL,
662 .mask = BD718XX_BUCK_SEL,
663 .val = BD718XX_BUCK_SEL,
667 .desc = {
668 .name = "buck2",
669 .of_match = of_match_ptr("BUCK2"),
670 .regulators_node = of_match_ptr("regulators"),
671 .id = BD718XX_BUCK2,
672 .type = REGULATOR_VOLTAGE,
673 .n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
674 .linear_ranges = bd718xx_dvs_buck_volts,
675 .n_linear_ranges = ARRAY_SIZE(bd718xx_dvs_buck_volts),
676 .vsel_reg = BD718XX_REG_BUCK2_VOLT_RUN,
677 .vsel_mask = DVS_BUCK_RUN_MASK,
678 .enable_reg = BD718XX_REG_BUCK2_CTRL,
679 .enable_mask = BD718XX_BUCK_EN,
680 .enable_time = BD71847_BUCK2_STARTUP_TIME,
681 .owner = THIS_MODULE,
682 .of_parse_cb = buck_set_hw_dvs_levels,
684 .dvs = {
685 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE,
686 .run_reg = BD718XX_REG_BUCK2_VOLT_RUN,
687 .run_mask = DVS_BUCK_RUN_MASK,
688 .idle_reg = BD718XX_REG_BUCK2_VOLT_IDLE,
689 .idle_mask = DVS_BUCK_RUN_MASK,
691 .init = {
692 .reg = BD718XX_REG_BUCK2_CTRL,
693 .mask = BD718XX_BUCK_SEL,
694 .val = BD718XX_BUCK_SEL,
698 .desc = {
699 .name = "buck3",
700 .of_match = of_match_ptr("BUCK3"),
701 .regulators_node = of_match_ptr("regulators"),
702 .id = BD718XX_BUCK3,
703 .type = REGULATOR_VOLTAGE,
704 .n_voltages = BD71847_BUCK3_VOLTAGE_NUM,
705 .linear_ranges = bd71847_buck3_volts,
706 .n_linear_ranges =
707 ARRAY_SIZE(bd71847_buck3_volts),
708 .vsel_reg = BD718XX_REG_1ST_NODVS_BUCK_VOLT,
709 .vsel_mask = BD718XX_1ST_NODVS_BUCK_MASK,
710 .vsel_range_reg = BD718XX_REG_1ST_NODVS_BUCK_VOLT,
711 .vsel_range_mask = BD71847_BUCK3_RANGE_MASK,
712 .linear_range_selectors = bd71847_buck3_volt_range_sel,
713 .enable_reg = BD718XX_REG_1ST_NODVS_BUCK_CTRL,
714 .enable_mask = BD718XX_BUCK_EN,
715 .enable_time = BD71847_BUCK3_STARTUP_TIME,
716 .owner = THIS_MODULE,
718 .init = {
719 .reg = BD718XX_REG_1ST_NODVS_BUCK_CTRL,
720 .mask = BD718XX_BUCK_SEL,
721 .val = BD718XX_BUCK_SEL,
725 .desc = {
726 .name = "buck4",
727 .of_match = of_match_ptr("BUCK4"),
728 .regulators_node = of_match_ptr("regulators"),
729 .id = BD718XX_BUCK4,
730 .type = REGULATOR_VOLTAGE,
731 .n_voltages = BD71847_BUCK4_VOLTAGE_NUM,
732 .linear_ranges = bd71847_buck4_volts,
733 .n_linear_ranges =
734 ARRAY_SIZE(bd71847_buck4_volts),
735 .enable_reg = BD718XX_REG_2ND_NODVS_BUCK_CTRL,
736 .vsel_reg = BD718XX_REG_2ND_NODVS_BUCK_VOLT,
737 .vsel_mask = BD71847_BUCK4_MASK,
738 .vsel_range_reg = BD718XX_REG_2ND_NODVS_BUCK_VOLT,
739 .vsel_range_mask = BD71847_BUCK4_RANGE_MASK,
740 .linear_range_selectors = bd71847_buck4_volt_range_sel,
741 .enable_mask = BD718XX_BUCK_EN,
742 .enable_time = BD71847_BUCK4_STARTUP_TIME,
743 .owner = THIS_MODULE,
745 .init = {
746 .reg = BD718XX_REG_2ND_NODVS_BUCK_CTRL,
747 .mask = BD718XX_BUCK_SEL,
748 .val = BD718XX_BUCK_SEL,
752 .desc = {
753 .name = "buck5",
754 .of_match = of_match_ptr("BUCK5"),
755 .regulators_node = of_match_ptr("regulators"),
756 .id = BD718XX_BUCK5,
757 .type = REGULATOR_VOLTAGE,
758 .volt_table = &bd718xx_3rd_nodvs_buck_volts[0],
759 .n_voltages = ARRAY_SIZE(bd718xx_3rd_nodvs_buck_volts),
760 .vsel_reg = BD718XX_REG_3RD_NODVS_BUCK_VOLT,
761 .vsel_mask = BD718XX_3RD_NODVS_BUCK_MASK,
762 .enable_reg = BD718XX_REG_3RD_NODVS_BUCK_CTRL,
763 .enable_mask = BD718XX_BUCK_EN,
764 .enable_time = BD71847_BUCK5_STARTUP_TIME,
765 .owner = THIS_MODULE,
767 .init = {
768 .reg = BD718XX_REG_3RD_NODVS_BUCK_CTRL,
769 .mask = BD718XX_BUCK_SEL,
770 .val = BD718XX_BUCK_SEL,
774 .desc = {
775 .name = "buck6",
776 .of_match = of_match_ptr("BUCK6"),
777 .regulators_node = of_match_ptr("regulators"),
778 .id = BD718XX_BUCK6,
779 .type = REGULATOR_VOLTAGE,
780 .n_voltages = BD718XX_4TH_NODVS_BUCK_VOLTAGE_NUM,
781 .linear_ranges = bd718xx_4th_nodvs_buck_volts,
782 .n_linear_ranges =
783 ARRAY_SIZE(bd718xx_4th_nodvs_buck_volts),
784 .vsel_reg = BD718XX_REG_4TH_NODVS_BUCK_VOLT,
785 .vsel_mask = BD718XX_4TH_NODVS_BUCK_MASK,
786 .enable_reg = BD718XX_REG_4TH_NODVS_BUCK_CTRL,
787 .enable_mask = BD718XX_BUCK_EN,
788 .enable_time = BD71847_BUCK6_STARTUP_TIME,
789 .owner = THIS_MODULE,
791 .init = {
792 .reg = BD718XX_REG_4TH_NODVS_BUCK_CTRL,
793 .mask = BD718XX_BUCK_SEL,
794 .val = BD718XX_BUCK_SEL,
798 .desc = {
799 .name = "ldo1",
800 .of_match = of_match_ptr("LDO1"),
801 .regulators_node = of_match_ptr("regulators"),
802 .id = BD718XX_LDO1,
803 .type = REGULATOR_VOLTAGE,
804 .n_voltages = BD718XX_LDO1_VOLTAGE_NUM,
805 .linear_ranges = bd718xx_ldo1_volts,
806 .n_linear_ranges = ARRAY_SIZE(bd718xx_ldo1_volts),
807 .vsel_reg = BD718XX_REG_LDO1_VOLT,
808 .vsel_mask = BD718XX_LDO1_MASK,
809 .vsel_range_reg = BD718XX_REG_LDO1_VOLT,
810 .vsel_range_mask = BD718XX_LDO1_RANGE_MASK,
811 .linear_range_selectors = bd718xx_ldo1_volt_range_sel,
812 .enable_reg = BD718XX_REG_LDO1_VOLT,
813 .enable_mask = BD718XX_LDO_EN,
814 .enable_time = BD71847_LDO1_STARTUP_TIME,
815 .owner = THIS_MODULE,
817 .init = {
818 .reg = BD718XX_REG_LDO1_VOLT,
819 .mask = BD718XX_LDO_SEL,
820 .val = BD718XX_LDO_SEL,
824 .desc = {
825 .name = "ldo2",
826 .of_match = of_match_ptr("LDO2"),
827 .regulators_node = of_match_ptr("regulators"),
828 .id = BD718XX_LDO2,
829 .type = REGULATOR_VOLTAGE,
830 .volt_table = &ldo_2_volts[0],
831 .vsel_reg = BD718XX_REG_LDO2_VOLT,
832 .vsel_mask = BD718XX_LDO2_MASK,
833 .n_voltages = ARRAY_SIZE(ldo_2_volts),
834 .enable_reg = BD718XX_REG_LDO2_VOLT,
835 .enable_mask = BD718XX_LDO_EN,
836 .enable_time = BD71847_LDO2_STARTUP_TIME,
837 .owner = THIS_MODULE,
839 .init = {
840 .reg = BD718XX_REG_LDO2_VOLT,
841 .mask = BD718XX_LDO_SEL,
842 .val = BD718XX_LDO_SEL,
846 .desc = {
847 .name = "ldo3",
848 .of_match = of_match_ptr("LDO3"),
849 .regulators_node = of_match_ptr("regulators"),
850 .id = BD718XX_LDO3,
851 .type = REGULATOR_VOLTAGE,
852 .n_voltages = BD718XX_LDO3_VOLTAGE_NUM,
853 .linear_ranges = bd718xx_ldo3_volts,
854 .n_linear_ranges = ARRAY_SIZE(bd718xx_ldo3_volts),
855 .vsel_reg = BD718XX_REG_LDO3_VOLT,
856 .vsel_mask = BD718XX_LDO3_MASK,
857 .enable_reg = BD718XX_REG_LDO3_VOLT,
858 .enable_mask = BD718XX_LDO_EN,
859 .enable_time = BD71847_LDO3_STARTUP_TIME,
860 .owner = THIS_MODULE,
862 .init = {
863 .reg = BD718XX_REG_LDO3_VOLT,
864 .mask = BD718XX_LDO_SEL,
865 .val = BD718XX_LDO_SEL,
869 .desc = {
870 .name = "ldo4",
871 .of_match = of_match_ptr("LDO4"),
872 .regulators_node = of_match_ptr("regulators"),
873 .id = BD718XX_LDO4,
874 .type = REGULATOR_VOLTAGE,
875 .n_voltages = BD718XX_LDO4_VOLTAGE_NUM,
876 .linear_ranges = bd718xx_ldo4_volts,
877 .n_linear_ranges = ARRAY_SIZE(bd718xx_ldo4_volts),
878 .vsel_reg = BD718XX_REG_LDO4_VOLT,
879 .vsel_mask = BD718XX_LDO4_MASK,
880 .enable_reg = BD718XX_REG_LDO4_VOLT,
881 .enable_mask = BD718XX_LDO_EN,
882 .enable_time = BD71847_LDO4_STARTUP_TIME,
883 .owner = THIS_MODULE,
885 .init = {
886 .reg = BD718XX_REG_LDO4_VOLT,
887 .mask = BD718XX_LDO_SEL,
888 .val = BD718XX_LDO_SEL,
892 .desc = {
893 .name = "ldo5",
894 .of_match = of_match_ptr("LDO5"),
895 .regulators_node = of_match_ptr("regulators"),
896 .id = BD718XX_LDO5,
897 .type = REGULATOR_VOLTAGE,
898 .n_voltages = BD71847_LDO5_VOLTAGE_NUM,
899 .linear_ranges = bd71847_ldo5_volts,
900 .n_linear_ranges = ARRAY_SIZE(bd71847_ldo5_volts),
901 .vsel_reg = BD718XX_REG_LDO5_VOLT,
902 .vsel_mask = BD71847_LDO5_MASK,
903 .vsel_range_reg = BD718XX_REG_LDO5_VOLT,
904 .vsel_range_mask = BD71847_LDO5_RANGE_MASK,
905 .linear_range_selectors = bd71847_ldo5_volt_range_sel,
906 .enable_reg = BD718XX_REG_LDO5_VOLT,
907 .enable_mask = BD718XX_LDO_EN,
908 .enable_time = BD71847_LDO5_STARTUP_TIME,
909 .owner = THIS_MODULE,
911 .init = {
912 .reg = BD718XX_REG_LDO5_VOLT,
913 .mask = BD718XX_LDO_SEL,
914 .val = BD718XX_LDO_SEL,
918 .desc = {
919 .name = "ldo6",
920 .of_match = of_match_ptr("LDO6"),
921 .regulators_node = of_match_ptr("regulators"),
922 .id = BD718XX_LDO6,
923 .type = REGULATOR_VOLTAGE,
924 .n_voltages = BD718XX_LDO6_VOLTAGE_NUM,
925 .linear_ranges = bd718xx_ldo6_volts,
926 .n_linear_ranges = ARRAY_SIZE(bd718xx_ldo6_volts),
927 /* LDO6 is supplied by buck5 */
928 .supply_name = "buck5",
929 .vsel_reg = BD718XX_REG_LDO6_VOLT,
930 .vsel_mask = BD718XX_LDO6_MASK,
931 .enable_reg = BD718XX_REG_LDO6_VOLT,
932 .enable_mask = BD718XX_LDO_EN,
933 .enable_time = BD71847_LDO6_STARTUP_TIME,
934 .owner = THIS_MODULE,
936 .init = {
937 .reg = BD718XX_REG_LDO6_VOLT,
938 .mask = BD718XX_LDO_SEL,
939 .val = BD718XX_LDO_SEL,
944 static const struct regulator_ops *bd71837_swcontrol_ops[] = {
945 &bd718xx_dvs_buck_regulator_ops, &bd718xx_dvs_buck_regulator_ops,
946 &bd718xx_dvs_buck_regulator_ops, &bd718xx_dvs_buck_regulator_ops,
947 &bd71837_pickable_range_buck_ops, &bd71837_buck_regulator_ops,
948 &bd71837_buck_regulator_nolinear_ops, &bd71837_buck_regulator_ops,
949 &bd71837_pickable_range_ldo_ops, &bd71837_ldo_regulator_nolinear_ops,
950 &bd71837_ldo_regulator_ops, &bd71837_ldo_regulator_ops,
951 &bd71837_ldo_regulator_ops, &bd71837_ldo_regulator_ops,
952 &bd71837_ldo_regulator_ops,
955 static const struct regulator_ops *bd71837_hwcontrol_ops[] = {
956 &BD718XX_HWOPNAME(bd718xx_dvs_buck_regulator_ops),
957 &BD718XX_HWOPNAME(bd718xx_dvs_buck_regulator_ops),
958 &bd71837_buck34_ops_hwctrl, &bd71837_buck34_ops_hwctrl,
959 &BD718XX_HWOPNAME(bd71837_pickable_range_buck_ops),
960 &BD718XX_HWOPNAME(bd71837_buck_regulator_ops),
961 &BD718XX_HWOPNAME(bd71837_buck_regulator_nolinear_ops),
962 &BD718XX_HWOPNAME(bd71837_buck_regulator_ops),
963 &BD718XX_HWOPNAME(bd71837_pickable_range_ldo_ops),
964 &BD718XX_HWOPNAME(bd71837_ldo_regulator_nolinear_ops),
965 &BD718XX_HWOPNAME(bd71837_ldo_regulator_ops),
966 &BD718XX_HWOPNAME(bd71837_ldo_regulator_ops),
967 &BD718XX_HWOPNAME(bd71837_ldo_regulator_ops),
968 &BD718XX_HWOPNAME(bd71837_ldo_regulator_ops),
969 &BD718XX_HWOPNAME(bd71837_ldo_regulator_ops),
972 static struct bd718xx_regulator_data bd71837_regulators[] = {
974 .desc = {
975 .name = "buck1",
976 .of_match = of_match_ptr("BUCK1"),
977 .regulators_node = of_match_ptr("regulators"),
978 .id = BD718XX_BUCK1,
979 .type = REGULATOR_VOLTAGE,
980 .n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
981 .linear_ranges = bd718xx_dvs_buck_volts,
982 .n_linear_ranges = ARRAY_SIZE(bd718xx_dvs_buck_volts),
983 .vsel_reg = BD718XX_REG_BUCK1_VOLT_RUN,
984 .vsel_mask = DVS_BUCK_RUN_MASK,
985 .enable_reg = BD718XX_REG_BUCK1_CTRL,
986 .enable_mask = BD718XX_BUCK_EN,
987 .enable_time = BD71837_BUCK1_STARTUP_TIME,
988 .owner = THIS_MODULE,
989 .of_parse_cb = buck_set_hw_dvs_levels,
991 .dvs = {
992 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
993 ROHM_DVS_LEVEL_SUSPEND,
994 .run_reg = BD718XX_REG_BUCK1_VOLT_RUN,
995 .run_mask = DVS_BUCK_RUN_MASK,
996 .idle_reg = BD718XX_REG_BUCK1_VOLT_IDLE,
997 .idle_mask = DVS_BUCK_RUN_MASK,
998 .suspend_reg = BD718XX_REG_BUCK1_VOLT_SUSP,
999 .suspend_mask = DVS_BUCK_RUN_MASK,
1001 .init = {
1002 .reg = BD718XX_REG_BUCK1_CTRL,
1003 .mask = BD718XX_BUCK_SEL,
1004 .val = BD718XX_BUCK_SEL,
1008 .desc = {
1009 .name = "buck2",
1010 .of_match = of_match_ptr("BUCK2"),
1011 .regulators_node = of_match_ptr("regulators"),
1012 .id = BD718XX_BUCK2,
1013 .type = REGULATOR_VOLTAGE,
1014 .n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
1015 .linear_ranges = bd718xx_dvs_buck_volts,
1016 .n_linear_ranges = ARRAY_SIZE(bd718xx_dvs_buck_volts),
1017 .vsel_reg = BD718XX_REG_BUCK2_VOLT_RUN,
1018 .vsel_mask = DVS_BUCK_RUN_MASK,
1019 .enable_reg = BD718XX_REG_BUCK2_CTRL,
1020 .enable_mask = BD718XX_BUCK_EN,
1021 .enable_time = BD71837_BUCK2_STARTUP_TIME,
1022 .owner = THIS_MODULE,
1023 .of_parse_cb = buck_set_hw_dvs_levels,
1025 .dvs = {
1026 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE,
1027 .run_reg = BD718XX_REG_BUCK2_VOLT_RUN,
1028 .run_mask = DVS_BUCK_RUN_MASK,
1029 .idle_reg = BD718XX_REG_BUCK2_VOLT_IDLE,
1030 .idle_mask = DVS_BUCK_RUN_MASK,
1032 .init = {
1033 .reg = BD718XX_REG_BUCK2_CTRL,
1034 .mask = BD718XX_BUCK_SEL,
1035 .val = BD718XX_BUCK_SEL,
1039 .desc = {
1040 .name = "buck3",
1041 .of_match = of_match_ptr("BUCK3"),
1042 .regulators_node = of_match_ptr("regulators"),
1043 .id = BD718XX_BUCK3,
1044 .type = REGULATOR_VOLTAGE,
1045 .n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
1046 .linear_ranges = bd718xx_dvs_buck_volts,
1047 .n_linear_ranges = ARRAY_SIZE(bd718xx_dvs_buck_volts),
1048 .vsel_reg = BD71837_REG_BUCK3_VOLT_RUN,
1049 .vsel_mask = DVS_BUCK_RUN_MASK,
1050 .enable_reg = BD71837_REG_BUCK3_CTRL,
1051 .enable_mask = BD718XX_BUCK_EN,
1052 .enable_time = BD71837_BUCK3_STARTUP_TIME,
1053 .owner = THIS_MODULE,
1054 .of_parse_cb = buck_set_hw_dvs_levels,
1056 .dvs = {
1057 .level_map = ROHM_DVS_LEVEL_RUN,
1058 .run_reg = BD71837_REG_BUCK3_VOLT_RUN,
1059 .run_mask = DVS_BUCK_RUN_MASK,
1061 .init = {
1062 .reg = BD71837_REG_BUCK3_CTRL,
1063 .mask = BD718XX_BUCK_SEL,
1064 .val = BD718XX_BUCK_SEL,
1068 .desc = {
1069 .name = "buck4",
1070 .of_match = of_match_ptr("BUCK4"),
1071 .regulators_node = of_match_ptr("regulators"),
1072 .id = BD718XX_BUCK4,
1073 .type = REGULATOR_VOLTAGE,
1074 .n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
1075 .linear_ranges = bd718xx_dvs_buck_volts,
1076 .n_linear_ranges = ARRAY_SIZE(bd718xx_dvs_buck_volts),
1077 .vsel_reg = BD71837_REG_BUCK4_VOLT_RUN,
1078 .vsel_mask = DVS_BUCK_RUN_MASK,
1079 .enable_reg = BD71837_REG_BUCK4_CTRL,
1080 .enable_mask = BD718XX_BUCK_EN,
1081 .enable_time = BD71837_BUCK4_STARTUP_TIME,
1082 .owner = THIS_MODULE,
1083 .of_parse_cb = buck_set_hw_dvs_levels,
1085 .dvs = {
1086 .level_map = ROHM_DVS_LEVEL_RUN,
1087 .run_reg = BD71837_REG_BUCK4_VOLT_RUN,
1088 .run_mask = DVS_BUCK_RUN_MASK,
1090 .init = {
1091 .reg = BD71837_REG_BUCK4_CTRL,
1092 .mask = BD718XX_BUCK_SEL,
1093 .val = BD718XX_BUCK_SEL,
1097 .desc = {
1098 .name = "buck5",
1099 .of_match = of_match_ptr("BUCK5"),
1100 .regulators_node = of_match_ptr("regulators"),
1101 .id = BD718XX_BUCK5,
1102 .type = REGULATOR_VOLTAGE,
1103 .n_voltages = BD71837_BUCK5_VOLTAGE_NUM,
1104 .linear_ranges = bd71837_buck5_volts,
1105 .n_linear_ranges =
1106 ARRAY_SIZE(bd71837_buck5_volts),
1107 .vsel_reg = BD718XX_REG_1ST_NODVS_BUCK_VOLT,
1108 .vsel_mask = BD71837_BUCK5_MASK,
1109 .vsel_range_reg = BD718XX_REG_1ST_NODVS_BUCK_VOLT,
1110 .vsel_range_mask = BD71837_BUCK5_RANGE_MASK,
1111 .linear_range_selectors = bd71837_buck5_volt_range_sel,
1112 .enable_reg = BD718XX_REG_1ST_NODVS_BUCK_CTRL,
1113 .enable_mask = BD718XX_BUCK_EN,
1114 .enable_time = BD71837_BUCK5_STARTUP_TIME,
1115 .owner = THIS_MODULE,
1117 .init = {
1118 .reg = BD718XX_REG_1ST_NODVS_BUCK_CTRL,
1119 .mask = BD718XX_BUCK_SEL,
1120 .val = BD718XX_BUCK_SEL,
1124 .desc = {
1125 .name = "buck6",
1126 .of_match = of_match_ptr("BUCK6"),
1127 .regulators_node = of_match_ptr("regulators"),
1128 .id = BD718XX_BUCK6,
1129 .type = REGULATOR_VOLTAGE,
1130 .n_voltages = BD71837_BUCK6_VOLTAGE_NUM,
1131 .linear_ranges = bd71837_buck6_volts,
1132 .n_linear_ranges =
1133 ARRAY_SIZE(bd71837_buck6_volts),
1134 .vsel_reg = BD718XX_REG_2ND_NODVS_BUCK_VOLT,
1135 .vsel_mask = BD71837_BUCK6_MASK,
1136 .enable_reg = BD718XX_REG_2ND_NODVS_BUCK_CTRL,
1137 .enable_mask = BD718XX_BUCK_EN,
1138 .enable_time = BD71837_BUCK6_STARTUP_TIME,
1139 .owner = THIS_MODULE,
1141 .init = {
1142 .reg = BD718XX_REG_2ND_NODVS_BUCK_CTRL,
1143 .mask = BD718XX_BUCK_SEL,
1144 .val = BD718XX_BUCK_SEL,
1148 .desc = {
1149 .name = "buck7",
1150 .of_match = of_match_ptr("BUCK7"),
1151 .regulators_node = of_match_ptr("regulators"),
1152 .id = BD718XX_BUCK7,
1153 .type = REGULATOR_VOLTAGE,
1154 .volt_table = &bd718xx_3rd_nodvs_buck_volts[0],
1155 .n_voltages = ARRAY_SIZE(bd718xx_3rd_nodvs_buck_volts),
1156 .vsel_reg = BD718XX_REG_3RD_NODVS_BUCK_VOLT,
1157 .vsel_mask = BD718XX_3RD_NODVS_BUCK_MASK,
1158 .enable_reg = BD718XX_REG_3RD_NODVS_BUCK_CTRL,
1159 .enable_mask = BD718XX_BUCK_EN,
1160 .enable_time = BD71837_BUCK7_STARTUP_TIME,
1161 .owner = THIS_MODULE,
1163 .init = {
1164 .reg = BD718XX_REG_3RD_NODVS_BUCK_CTRL,
1165 .mask = BD718XX_BUCK_SEL,
1166 .val = BD718XX_BUCK_SEL,
1170 .desc = {
1171 .name = "buck8",
1172 .of_match = of_match_ptr("BUCK8"),
1173 .regulators_node = of_match_ptr("regulators"),
1174 .id = BD718XX_BUCK8,
1175 .type = REGULATOR_VOLTAGE,
1176 .n_voltages = BD718XX_4TH_NODVS_BUCK_VOLTAGE_NUM,
1177 .linear_ranges = bd718xx_4th_nodvs_buck_volts,
1178 .n_linear_ranges =
1179 ARRAY_SIZE(bd718xx_4th_nodvs_buck_volts),
1180 .vsel_reg = BD718XX_REG_4TH_NODVS_BUCK_VOLT,
1181 .vsel_mask = BD718XX_4TH_NODVS_BUCK_MASK,
1182 .enable_reg = BD718XX_REG_4TH_NODVS_BUCK_CTRL,
1183 .enable_mask = BD718XX_BUCK_EN,
1184 .enable_time = BD71837_BUCK8_STARTUP_TIME,
1185 .owner = THIS_MODULE,
1187 .init = {
1188 .reg = BD718XX_REG_4TH_NODVS_BUCK_CTRL,
1189 .mask = BD718XX_BUCK_SEL,
1190 .val = BD718XX_BUCK_SEL,
1194 .desc = {
1195 .name = "ldo1",
1196 .of_match = of_match_ptr("LDO1"),
1197 .regulators_node = of_match_ptr("regulators"),
1198 .id = BD718XX_LDO1,
1199 .type = REGULATOR_VOLTAGE,
1200 .n_voltages = BD718XX_LDO1_VOLTAGE_NUM,
1201 .linear_ranges = bd718xx_ldo1_volts,
1202 .n_linear_ranges = ARRAY_SIZE(bd718xx_ldo1_volts),
1203 .vsel_reg = BD718XX_REG_LDO1_VOLT,
1204 .vsel_mask = BD718XX_LDO1_MASK,
1205 .vsel_range_reg = BD718XX_REG_LDO1_VOLT,
1206 .vsel_range_mask = BD718XX_LDO1_RANGE_MASK,
1207 .linear_range_selectors = bd718xx_ldo1_volt_range_sel,
1208 .enable_reg = BD718XX_REG_LDO1_VOLT,
1209 .enable_mask = BD718XX_LDO_EN,
1210 .enable_time = BD71837_LDO1_STARTUP_TIME,
1211 .owner = THIS_MODULE,
1213 .init = {
1214 .reg = BD718XX_REG_LDO1_VOLT,
1215 .mask = BD718XX_LDO_SEL,
1216 .val = BD718XX_LDO_SEL,
1220 .desc = {
1221 .name = "ldo2",
1222 .of_match = of_match_ptr("LDO2"),
1223 .regulators_node = of_match_ptr("regulators"),
1224 .id = BD718XX_LDO2,
1225 .type = REGULATOR_VOLTAGE,
1226 .volt_table = &ldo_2_volts[0],
1227 .vsel_reg = BD718XX_REG_LDO2_VOLT,
1228 .vsel_mask = BD718XX_LDO2_MASK,
1229 .n_voltages = ARRAY_SIZE(ldo_2_volts),
1230 .enable_reg = BD718XX_REG_LDO2_VOLT,
1231 .enable_mask = BD718XX_LDO_EN,
1232 .enable_time = BD71837_LDO2_STARTUP_TIME,
1233 .owner = THIS_MODULE,
1235 .init = {
1236 .reg = BD718XX_REG_LDO2_VOLT,
1237 .mask = BD718XX_LDO_SEL,
1238 .val = BD718XX_LDO_SEL,
1242 .desc = {
1243 .name = "ldo3",
1244 .of_match = of_match_ptr("LDO3"),
1245 .regulators_node = of_match_ptr("regulators"),
1246 .id = BD718XX_LDO3,
1247 .type = REGULATOR_VOLTAGE,
1248 .n_voltages = BD718XX_LDO3_VOLTAGE_NUM,
1249 .linear_ranges = bd718xx_ldo3_volts,
1250 .n_linear_ranges = ARRAY_SIZE(bd718xx_ldo3_volts),
1251 .vsel_reg = BD718XX_REG_LDO3_VOLT,
1252 .vsel_mask = BD718XX_LDO3_MASK,
1253 .enable_reg = BD718XX_REG_LDO3_VOLT,
1254 .enable_mask = BD718XX_LDO_EN,
1255 .enable_time = BD71837_LDO3_STARTUP_TIME,
1256 .owner = THIS_MODULE,
1258 .init = {
1259 .reg = BD718XX_REG_LDO3_VOLT,
1260 .mask = BD718XX_LDO_SEL,
1261 .val = BD718XX_LDO_SEL,
1265 .desc = {
1266 .name = "ldo4",
1267 .of_match = of_match_ptr("LDO4"),
1268 .regulators_node = of_match_ptr("regulators"),
1269 .id = BD718XX_LDO4,
1270 .type = REGULATOR_VOLTAGE,
1271 .n_voltages = BD718XX_LDO4_VOLTAGE_NUM,
1272 .linear_ranges = bd718xx_ldo4_volts,
1273 .n_linear_ranges = ARRAY_SIZE(bd718xx_ldo4_volts),
1274 .vsel_reg = BD718XX_REG_LDO4_VOLT,
1275 .vsel_mask = BD718XX_LDO4_MASK,
1276 .enable_reg = BD718XX_REG_LDO4_VOLT,
1277 .enable_mask = BD718XX_LDO_EN,
1278 .enable_time = BD71837_LDO4_STARTUP_TIME,
1279 .owner = THIS_MODULE,
1281 .init = {
1282 .reg = BD718XX_REG_LDO4_VOLT,
1283 .mask = BD718XX_LDO_SEL,
1284 .val = BD718XX_LDO_SEL,
1288 .desc = {
1289 .name = "ldo5",
1290 .of_match = of_match_ptr("LDO5"),
1291 .regulators_node = of_match_ptr("regulators"),
1292 .id = BD718XX_LDO5,
1293 .type = REGULATOR_VOLTAGE,
1294 .n_voltages = BD71837_LDO5_VOLTAGE_NUM,
1295 .linear_ranges = bd71837_ldo5_volts,
1296 .n_linear_ranges = ARRAY_SIZE(bd71837_ldo5_volts),
1297 /* LDO5 is supplied by buck6 */
1298 .supply_name = "buck6",
1299 .vsel_reg = BD718XX_REG_LDO5_VOLT,
1300 .vsel_mask = BD71837_LDO5_MASK,
1301 .enable_reg = BD718XX_REG_LDO5_VOLT,
1302 .enable_mask = BD718XX_LDO_EN,
1303 .enable_time = BD71837_LDO5_STARTUP_TIME,
1304 .owner = THIS_MODULE,
1306 .init = {
1307 .reg = BD718XX_REG_LDO5_VOLT,
1308 .mask = BD718XX_LDO_SEL,
1309 .val = BD718XX_LDO_SEL,
1311 .additional_inits = bd71837_ldo5_inits,
1312 .additional_init_amnt = ARRAY_SIZE(bd71837_ldo5_inits),
1315 .desc = {
1316 .name = "ldo6",
1317 .of_match = of_match_ptr("LDO6"),
1318 .regulators_node = of_match_ptr("regulators"),
1319 .id = BD718XX_LDO6,
1320 .type = REGULATOR_VOLTAGE,
1321 .n_voltages = BD718XX_LDO6_VOLTAGE_NUM,
1322 .linear_ranges = bd718xx_ldo6_volts,
1323 .n_linear_ranges = ARRAY_SIZE(bd718xx_ldo6_volts),
1324 /* LDO6 is supplied by buck7 */
1325 .supply_name = "buck7",
1326 .vsel_reg = BD718XX_REG_LDO6_VOLT,
1327 .vsel_mask = BD718XX_LDO6_MASK,
1328 .enable_reg = BD718XX_REG_LDO6_VOLT,
1329 .enable_mask = BD718XX_LDO_EN,
1330 .enable_time = BD71837_LDO6_STARTUP_TIME,
1331 .owner = THIS_MODULE,
1333 .init = {
1334 .reg = BD718XX_REG_LDO6_VOLT,
1335 .mask = BD718XX_LDO_SEL,
1336 .val = BD718XX_LDO_SEL,
1338 .additional_inits = bd71837_ldo6_inits,
1339 .additional_init_amnt = ARRAY_SIZE(bd71837_ldo6_inits),
1342 .desc = {
1343 .name = "ldo7",
1344 .of_match = of_match_ptr("LDO7"),
1345 .regulators_node = of_match_ptr("regulators"),
1346 .id = BD718XX_LDO7,
1347 .type = REGULATOR_VOLTAGE,
1348 .n_voltages = BD71837_LDO7_VOLTAGE_NUM,
1349 .linear_ranges = bd71837_ldo7_volts,
1350 .n_linear_ranges = ARRAY_SIZE(bd71837_ldo7_volts),
1351 .vsel_reg = BD71837_REG_LDO7_VOLT,
1352 .vsel_mask = BD71837_LDO7_MASK,
1353 .enable_reg = BD71837_REG_LDO7_VOLT,
1354 .enable_mask = BD718XX_LDO_EN,
1355 .enable_time = BD71837_LDO7_STARTUP_TIME,
1356 .owner = THIS_MODULE,
1358 .init = {
1359 .reg = BD71837_REG_LDO7_VOLT,
1360 .mask = BD718XX_LDO_SEL,
1361 .val = BD718XX_LDO_SEL,
1366 static void mark_hw_controlled(struct device *dev, struct device_node *np,
1367 struct bd718xx_regulator_data *reg_data,
1368 unsigned int num_reg_data, int *info)
1370 int i;
1372 for (i = 1; i <= num_reg_data; i++) {
1373 if (!of_node_name_eq(np, reg_data[i-1].desc.of_match))
1374 continue;
1376 *info |= 1 << (i - 1);
1377 dev_dbg(dev, "regulator %d runlevel controlled\n", i);
1378 return;
1380 dev_warn(dev, "Bad regulator node\n");
1384 * Setups where regulator (especially the buck8) output voltage is scaled
1385 * by adding external connection where some other regulator output is connected
1386 * to feedback-pin (over suitable resistors) is getting popular amongst users
1387 * of BD71837. (This allows for example scaling down the buck8 voltages to suit
1388 * lover GPU voltages for projects where buck8 is (ab)used to supply power
1389 * for GPU. Additionally some setups do allow DVS for buck8 but as this do
1390 * produce voltage spikes the HW must be evaluated to be able to survive this
1391 * - hence I keep the DVS disabled for non DVS bucks by default. I don't want
1392 * to help you burn your proto board)
1394 * So we allow describing this external connection from DT and scale the
1395 * voltages accordingly. This is what the connection should look like:
1397 * |------------|
1398 * | buck 8 |-------+----->Vout
1399 * | | |
1400 * |------------| |
1401 * | FB pin |
1402 * | |
1403 * +-------+--R2---+
1405 * R1
1407 * V FB-pull-up
1409 * Here the buck output is sifted according to formula:
1411 * Vout_o = Vo - (Vpu - Vo)*R2/R1
1412 * Linear_step = step_orig*(R1+R2)/R1
1414 * where:
1415 * Vout_o is adjusted voltage output at vsel reg value 0
1416 * Vo is original voltage output at vsel reg value 0
1417 * Vpu is the pull-up voltage V FB-pull-up in the picture
1418 * R1 and R2 are resistor values.
1420 * As a real world example for buck8 and a specific GPU:
1421 * VLDO = 1.6V (used as FB-pull-up)
1422 * R1 = 1000ohms
1423 * R2 = 150ohms
1424 * VSEL 0x0 => 0.8V – (VLDO – 0.8) * R2 / R1 = 0.68V
1425 * Linear Step = 10mV * (R1 + R2) / R1 = 11.5mV
1427 static int setup_feedback_loop(struct device *dev, struct device_node *np,
1428 struct bd718xx_regulator_data *reg_data,
1429 unsigned int num_reg_data, int fb_uv)
1431 int i, r1, r2, ret;
1434 * We do adjust the values in the global desc based on DT settings.
1435 * This may not be best approach as it can cause problems if more than
1436 * one PMIC is controlled from same processor. I don't see such use-case
1437 * for BD718x7 now - so we spare some bits.
1439 * If this will point out to be a problem - then we can allocate new
1440 * bd718xx_regulator_data array at probe and just use the global
1441 * array as a template where we copy initial values. Then we can
1442 * use allocated descs for regultor registration and do IC specific
1443 * modifications to this copy while leaving other PMICs untouched. But
1444 * that means allocating new array for each PMIC - and currently I see
1445 * no need for that.
1448 for (i = 0; i < num_reg_data; i++) {
1449 struct regulator_desc *desc = &reg_data[i].desc;
1450 int j;
1452 if (!of_node_name_eq(np, desc->of_match))
1453 continue;
1455 pr_info("Looking at node '%s'\n", desc->of_match);
1457 /* The feedback loop connection does not make sense for LDOs */
1458 if (desc->id >= BD718XX_LDO1)
1459 return -EINVAL;
1461 ret = of_property_read_u32(np, "rohm,feedback-pull-up-r1-ohms",
1462 &r1);
1463 if (ret)
1464 return ret;
1466 if (!r1)
1467 return -EINVAL;
1469 ret = of_property_read_u32(np, "rohm,feedback-pull-up-r2-ohms",
1470 &r2);
1471 if (ret)
1472 return ret;
1474 if (desc->n_linear_ranges && desc->linear_ranges) {
1475 struct linear_range *new;
1477 new = devm_kzalloc(dev, desc->n_linear_ranges *
1478 sizeof(struct linear_range),
1479 GFP_KERNEL);
1480 if (!new)
1481 return -ENOMEM;
1483 for (j = 0; j < desc->n_linear_ranges; j++) {
1484 int min = desc->linear_ranges[j].min;
1485 int step = desc->linear_ranges[j].step;
1487 min -= (fb_uv - min)*r2/r1;
1488 step = step * (r1 + r2);
1489 step /= r1;
1491 new[j].min = min;
1492 new[j].step = step;
1494 dev_dbg(dev, "%s: old range min %d, step %d\n",
1495 desc->name, desc->linear_ranges[j].min,
1496 desc->linear_ranges[j].step);
1497 dev_dbg(dev, "new range min %d, step %d\n", min,
1498 step);
1500 desc->linear_ranges = new;
1502 dev_dbg(dev, "regulator '%s' has FB pull-up configured\n",
1503 desc->name);
1505 return 0;
1508 return -ENODEV;
1511 static int get_special_regulators(struct device *dev,
1512 struct bd718xx_regulator_data *reg_data,
1513 unsigned int num_reg_data, int *info)
1515 int ret;
1516 struct device_node *np;
1517 struct device_node *nproot = dev->of_node;
1518 int uv;
1520 *info = 0;
1522 nproot = of_get_child_by_name(nproot, "regulators");
1523 if (!nproot) {
1524 dev_err(dev, "failed to find regulators node\n");
1525 return -ENODEV;
1527 for_each_child_of_node(nproot, np) {
1528 if (of_property_read_bool(np, "rohm,no-regulator-enable-control"))
1529 mark_hw_controlled(dev, np, reg_data, num_reg_data,
1530 info);
1531 ret = of_property_read_u32(np, "rohm,fb-pull-up-microvolt",
1532 &uv);
1533 if (ret) {
1534 if (ret == -EINVAL)
1535 continue;
1536 else
1537 goto err_out;
1540 ret = setup_feedback_loop(dev, np, reg_data, num_reg_data, uv);
1541 if (ret)
1542 goto err_out;
1545 of_node_put(nproot);
1546 return 0;
1548 err_out:
1549 of_node_put(np);
1550 of_node_put(nproot);
1552 return ret;
1555 static int bd718xx_probe(struct platform_device *pdev)
1557 struct bd718xx *mfd;
1558 struct regulator_config config = { 0 };
1559 int i, j, err, omit_enable;
1560 bool use_snvs;
1561 struct bd718xx_regulator_data *reg_data;
1562 unsigned int num_reg_data;
1563 enum rohm_chip_type chip = platform_get_device_id(pdev)->driver_data;
1564 const struct regulator_ops **swops, **hwops;
1566 mfd = dev_get_drvdata(pdev->dev.parent);
1567 if (!mfd) {
1568 dev_err(&pdev->dev, "No MFD driver data\n");
1569 err = -EINVAL;
1570 goto err;
1573 switch (chip) {
1574 case ROHM_CHIP_TYPE_BD71837:
1575 reg_data = bd71837_regulators;
1576 num_reg_data = ARRAY_SIZE(bd71837_regulators);
1577 swops = &bd71837_swcontrol_ops[0];
1578 hwops = &bd71837_hwcontrol_ops[0];
1579 break;
1580 case ROHM_CHIP_TYPE_BD71847:
1581 reg_data = bd71847_regulators;
1582 num_reg_data = ARRAY_SIZE(bd71847_regulators);
1583 swops = &bd71847_swcontrol_ops[0];
1584 hwops = &bd71847_hwcontrol_ops[0];
1585 break;
1586 default:
1587 dev_err(&pdev->dev, "Unsupported chip type\n");
1588 err = -EINVAL;
1589 goto err;
1592 /* Register LOCK release */
1593 err = regmap_update_bits(mfd->chip.regmap, BD718XX_REG_REGLOCK,
1594 (REGLOCK_PWRSEQ | REGLOCK_VREG), 0);
1595 if (err) {
1596 dev_err(&pdev->dev, "Failed to unlock PMIC (%d)\n", err);
1597 goto err;
1598 } else {
1599 dev_dbg(&pdev->dev, "Unlocked lock register 0x%x\n",
1600 BD718XX_REG_REGLOCK);
1603 use_snvs = of_property_read_bool(pdev->dev.parent->of_node,
1604 "rohm,reset-snvs-powered");
1607 * Change the next stage from poweroff to be READY instead of SNVS
1608 * for all reset types because OTP loading at READY will clear SEL
1609 * bit allowing HW defaults for power rails to be used
1611 if (!use_snvs) {
1612 err = regmap_update_bits(mfd->chip.regmap,
1613 BD718XX_REG_TRANS_COND1,
1614 BD718XX_ON_REQ_POWEROFF_MASK |
1615 BD718XX_SWRESET_POWEROFF_MASK |
1616 BD718XX_WDOG_POWEROFF_MASK |
1617 BD718XX_KEY_L_POWEROFF_MASK,
1618 BD718XX_POWOFF_TO_RDY);
1619 if (err) {
1620 dev_err(&pdev->dev, "Failed to change reset target\n");
1621 goto err;
1622 } else {
1623 dev_dbg(&pdev->dev,
1624 "Changed all resets from SVNS to READY\n");
1628 config.dev = pdev->dev.parent;
1629 config.regmap = mfd->chip.regmap;
1631 * There are cases when we want to leave the enable-control for
1632 * the HW state machine and use this driver only for voltage control.
1633 * One special case is when we use PMIC_STBY_REQ line from SoC to PMIC
1634 * in order to set the system to SUSPEND state.
1636 * If regulator is taken under SW control the regulator state will not
1637 * be affected by PMIC state machine - Eg. regulator is likely to stay
1638 * on even in SUSPEND
1640 err = get_special_regulators(pdev->dev.parent, reg_data, num_reg_data,
1641 &omit_enable);
1642 if (err)
1643 return err;
1645 for (i = 0; i < num_reg_data; i++) {
1647 struct regulator_desc *desc;
1648 struct regulator_dev *rdev;
1649 struct bd718xx_regulator_data *r;
1650 int no_enable_control = omit_enable & (1 << i);
1652 r = &reg_data[i];
1653 desc = &r->desc;
1655 if (no_enable_control)
1656 desc->ops = hwops[i];
1657 else
1658 desc->ops = swops[i];
1660 rdev = devm_regulator_register(&pdev->dev, desc, &config);
1661 if (IS_ERR(rdev)) {
1662 dev_err(&pdev->dev,
1663 "failed to register %s regulator\n",
1664 desc->name);
1665 err = PTR_ERR(rdev);
1666 goto err;
1670 * Regulator register gets the regulator constraints and
1671 * applies them (set_machine_constraints). This should have
1672 * turned the control register(s) to correct values and we
1673 * can now switch the control from PMIC state machine to the
1674 * register interface
1676 * At poweroff transition PMIC HW disables EN bit for
1677 * regulators but leaves SEL bit untouched. So if state
1678 * transition from POWEROFF is done to SNVS - then all power
1679 * rails controlled by SW (having SEL bit set) stay disabled
1680 * as EN is cleared. This will result boot failure if any
1681 * crucial systems are powered by these rails. We don't
1682 * enable SW control for crucial regulators if snvs state is
1683 * used
1685 if (!no_enable_control && (!use_snvs ||
1686 !rdev->constraints->always_on ||
1687 !rdev->constraints->boot_on)) {
1688 err = regmap_update_bits(mfd->chip.regmap, r->init.reg,
1689 r->init.mask, r->init.val);
1690 if (err) {
1691 dev_err(&pdev->dev,
1692 "Failed to take control for (%s)\n",
1693 desc->name);
1694 goto err;
1697 for (j = 0; j < r->additional_init_amnt; j++) {
1698 err = regmap_update_bits(mfd->chip.regmap,
1699 r->additional_inits[j].reg,
1700 r->additional_inits[j].mask,
1701 r->additional_inits[j].val);
1702 if (err) {
1703 dev_err(&pdev->dev,
1704 "Buck (%s) initialization failed\n",
1705 desc->name);
1706 goto err;
1711 err:
1712 return err;
1715 static const struct platform_device_id bd718x7_pmic_id[] = {
1716 { "bd71837-pmic", ROHM_CHIP_TYPE_BD71837 },
1717 { "bd71847-pmic", ROHM_CHIP_TYPE_BD71847 },
1718 { },
1720 MODULE_DEVICE_TABLE(platform, bd718x7_pmic_id);
1722 static struct platform_driver bd718xx_regulator = {
1723 .driver = {
1724 .name = "bd718xx-pmic",
1726 .probe = bd718xx_probe,
1727 .id_table = bd718x7_pmic_id,
1730 module_platform_driver(bd718xx_regulator);
1732 MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>");
1733 MODULE_DESCRIPTION("BD71837/BD71847 voltage regulator driver");
1734 MODULE_LICENSE("GPL");
1735 MODULE_ALIAS("platform:bd718xx-pmic");