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/cleanup.h>
6 #include <linux/delay.h>
8 #include <linux/interrupt.h>
9 #include <linux/kernel.h>
10 #include <linux/mfd/rohm-bd718x7.h>
11 #include <linux/module.h>
13 #include <linux/platform_device.h>
14 #include <linux/regulator/driver.h>
15 #include <linux/regulator/machine.h>
16 #include <linux/regulator/of_regulator.h>
17 #include <linux/slab.h>
19 /* Typical regulator startup times as per data sheet in uS */
20 #define BD71847_BUCK1_STARTUP_TIME 144
21 #define BD71847_BUCK2_STARTUP_TIME 162
22 #define BD71847_BUCK3_STARTUP_TIME 162
23 #define BD71847_BUCK4_STARTUP_TIME 240
24 #define BD71847_BUCK5_STARTUP_TIME 270
25 #define BD71847_BUCK6_STARTUP_TIME 200
26 #define BD71847_LDO1_STARTUP_TIME 440
27 #define BD71847_LDO2_STARTUP_TIME 370
28 #define BD71847_LDO3_STARTUP_TIME 310
29 #define BD71847_LDO4_STARTUP_TIME 400
30 #define BD71847_LDO5_STARTUP_TIME 530
31 #define BD71847_LDO6_STARTUP_TIME 400
33 #define BD71837_BUCK1_STARTUP_TIME 160
34 #define BD71837_BUCK2_STARTUP_TIME 180
35 #define BD71837_BUCK3_STARTUP_TIME 180
36 #define BD71837_BUCK4_STARTUP_TIME 180
37 #define BD71837_BUCK5_STARTUP_TIME 160
38 #define BD71837_BUCK6_STARTUP_TIME 240
39 #define BD71837_BUCK7_STARTUP_TIME 220
40 #define BD71837_BUCK8_STARTUP_TIME 200
41 #define BD71837_LDO1_STARTUP_TIME 440
42 #define BD71837_LDO2_STARTUP_TIME 370
43 #define BD71837_LDO3_STARTUP_TIME 310
44 #define BD71837_LDO4_STARTUP_TIME 400
45 #define BD71837_LDO5_STARTUP_TIME 310
46 #define BD71837_LDO6_STARTUP_TIME 400
47 #define BD71837_LDO7_STARTUP_TIME 530
50 * BD718(37/47/50) have two "enable control modes". ON/OFF can either be
51 * controlled by software - or by PMIC internal HW state machine. Whether
52 * regulator should be under SW or HW control can be defined from device-tree.
53 * Let's provide separate ops for regulators to use depending on the "enable
56 #define BD718XX_HWOPNAME(swopname) swopname##_hwcontrol
58 #define BD718XX_OPS(name, _list_voltage, _map_voltage, _set_voltage_sel, \
59 _get_voltage_sel, _set_voltage_time_sel, _set_ramp_delay, \
61 static const struct regulator_ops name = { \
62 .enable = regulator_enable_regmap, \
63 .disable = regulator_disable_regmap, \
64 .is_enabled = regulator_is_enabled_regmap, \
65 .list_voltage = (_list_voltage), \
66 .map_voltage = (_map_voltage), \
67 .set_voltage_sel = (_set_voltage_sel), \
68 .get_voltage_sel = (_get_voltage_sel), \
69 .set_voltage_time_sel = (_set_voltage_time_sel), \
70 .set_ramp_delay = (_set_ramp_delay), \
71 .set_under_voltage_protection = (_set_uvp), \
72 .set_over_voltage_protection = (_set_ovp), \
75 static const struct regulator_ops BD718XX_HWOPNAME(name) = { \
76 .is_enabled = always_enabled_by_hwstate, \
77 .list_voltage = (_list_voltage), \
78 .map_voltage = (_map_voltage), \
79 .set_voltage_sel = (_set_voltage_sel), \
80 .get_voltage_sel = (_get_voltage_sel), \
81 .set_voltage_time_sel = (_set_voltage_time_sel), \
82 .set_ramp_delay = (_set_ramp_delay), \
83 .set_under_voltage_protection = (_set_uvp), \
84 .set_over_voltage_protection = (_set_ovp), \
89 * BUCK1RAMPRATE[1:0] BUCK1 DVS ramp rate setting
90 * 00: 10.00mV/usec 10mV 1uS
91 * 01: 5.00mV/usec 10mV 2uS
92 * 10: 2.50mV/usec 10mV 4uS
93 * 11: 1.25mV/usec 10mV 8uS
95 static const unsigned int bd718xx_ramp_delay
[] = { 10000, 5000, 2500, 1250 };
97 /* These functions are used when regulators are under HW state machine control.
98 * We assume PMIC is in RUN state because SW running and able to query the
99 * status. Most of the regulators have fixed ON or OFF state at RUN/IDLE so for
100 * them we just return a constant. BD71837 BUCK3 and BUCK4 are exceptions as
101 * they support configuring the ON/OFF state for RUN.
103 * Note for next hacker - these PMICs have a register where the HW state can be
104 * read. If assuming RUN appears to be false in your use-case - you can
105 * implement state reading (although that is not going to be atomic) before
106 * returning the enable state.
108 static int always_enabled_by_hwstate(struct regulator_dev
*rdev
)
113 static int never_enabled_by_hwstate(struct regulator_dev
*rdev
)
118 static int bd71837_get_buck34_enable_hwctrl(struct regulator_dev
*rdev
)
123 ret
= regmap_read(rdev
->regmap
, rdev
->desc
->enable_reg
, &val
);
127 return !!(BD718XX_BUCK_RUN_ON
& val
);
130 static void voltage_change_done(struct regulator_dev
*rdev
, unsigned int sel
,
137 * Let's allow scheduling as we use I2C anyways. We just need to
138 * guarantee minimum of 1ms sleep - it shouldn't matter if we
139 * exceed it due to the scheduling.
143 ret
= regmap_clear_bits(rdev
->regmap
, BD718XX_REG_MVRFLTMASK2
,
147 "Failed to re-enable voltage monitoring (%d)\n",
152 static int voltage_change_prepare(struct regulator_dev
*rdev
, unsigned int sel
,
158 if (rdev
->desc
->ops
->is_enabled(rdev
)) {
161 now
= rdev
->desc
->ops
->get_voltage_sel(rdev
);
165 now
= rdev
->desc
->ops
->list_voltage(rdev
, now
);
169 new = rdev
->desc
->ops
->list_voltage(rdev
, sel
);
174 * If we increase LDO voltage when LDO is enabled we need to
175 * disable the power-good detection until voltage has reached
176 * the new level. According to HW colleagues the maximum time
177 * it takes is 1000us. I assume that on systems with light load
178 * this might be less - and we could probably use DT to give
179 * system specific delay value if performance matters.
181 * Well, knowing we use I2C here and can add scheduling delays
182 * I don't think it is worth the hassle and I just add fixed
183 * 1ms sleep here (and allow scheduling). If this turns out to
184 * be a problem we can change it to delay and make the delay
190 int ldo_offset
= rdev
->desc
->id
- BD718XX_LDO1
;
192 prot_bit
= BD718XX_LDO1_VRMON80
<< ldo_offset
;
193 ret
= regmap_read(rdev
->regmap
, BD718XX_REG_MVRFLTMASK2
,
197 "Failed to read voltage monitoring state\n");
201 if (!(tmp
& prot_bit
)) {
202 /* We disable protection if it was enabled... */
203 ret
= regmap_set_bits(rdev
->regmap
,
204 BD718XX_REG_MVRFLTMASK2
,
206 /* ...and we also want to re-enable it */
211 "Failed to stop voltage monitoring\n");
220 static int bd718xx_set_voltage_sel_restricted(struct regulator_dev
*rdev
,
226 ret
= voltage_change_prepare(rdev
, sel
, &mask
);
230 ret
= regulator_set_voltage_sel_regmap(rdev
, sel
);
231 voltage_change_done(rdev
, sel
, &mask
);
236 static int bd718xx_set_voltage_sel_pickable_restricted(
237 struct regulator_dev
*rdev
, unsigned int sel
)
242 ret
= voltage_change_prepare(rdev
, sel
, &mask
);
246 ret
= regulator_set_voltage_sel_pickable_regmap(rdev
, sel
);
247 voltage_change_done(rdev
, sel
, &mask
);
252 static int bd71837_set_voltage_sel_pickable_restricted(
253 struct regulator_dev
*rdev
, unsigned int sel
)
255 if (rdev
->desc
->ops
->is_enabled(rdev
))
258 return regulator_set_voltage_sel_pickable_regmap(rdev
, sel
);
262 * BD71837 BUCK1/2/3/4
264 * 0.70 to 1.30V (10mV step)
266 static const struct linear_range bd718xx_dvs_buck_volts
[] = {
267 REGULATOR_LINEAR_RANGE(700000, 0x00, 0x3C, 10000),
268 REGULATOR_LINEAR_RANGE(1300000, 0x3D, 0x3F, 0),
273 * 0.7V to 1.35V (range 0)
275 * 0.675 to 1.325 (range 1)
277 static const struct linear_range bd71837_buck5_volts
[] = {
278 /* Ranges when VOLT_SEL bit is 0 */
279 REGULATOR_LINEAR_RANGE(700000, 0x00, 0x03, 100000),
280 REGULATOR_LINEAR_RANGE(1050000, 0x04, 0x05, 50000),
281 REGULATOR_LINEAR_RANGE(1200000, 0x06, 0x07, 150000),
282 /* Ranges when VOLT_SEL bit is 1 */
283 REGULATOR_LINEAR_RANGE(675000, 0x0, 0x3, 100000),
284 REGULATOR_LINEAR_RANGE(1025000, 0x4, 0x5, 50000),
285 REGULATOR_LINEAR_RANGE(1175000, 0x6, 0x7, 150000),
289 * Range selector for first 3 linear ranges is 0x0
290 * and 0x1 for last 3 ranges.
292 static const unsigned int bd71837_buck5_volt_range_sel
[] = {
293 0x0, 0x0, 0x0, 0x1, 0x1, 0x1
299 static const struct linear_range bd71847_buck3_volts
[] = {
300 /* Ranges when VOLT_SEL bits are 00 */
301 REGULATOR_LINEAR_RANGE(700000, 0x00, 0x03, 100000),
302 REGULATOR_LINEAR_RANGE(1050000, 0x04, 0x05, 50000),
303 REGULATOR_LINEAR_RANGE(1200000, 0x06, 0x07, 150000),
304 /* Ranges when VOLT_SEL bits are 01 */
305 REGULATOR_LINEAR_RANGE(550000, 0x0, 0x7, 50000),
306 /* Ranges when VOLT_SEL bits are 11 */
307 REGULATOR_LINEAR_RANGE(675000, 0x0, 0x3, 100000),
308 REGULATOR_LINEAR_RANGE(1025000, 0x4, 0x5, 50000),
309 REGULATOR_LINEAR_RANGE(1175000, 0x6, 0x7, 150000),
312 static const unsigned int bd71847_buck3_volt_range_sel
[] = {
313 0x0, 0x0, 0x0, 0x1, 0x2, 0x2, 0x2
316 static const struct linear_range bd71847_buck4_volts
[] = {
317 REGULATOR_LINEAR_RANGE(3000000, 0x00, 0x03, 100000),
318 REGULATOR_LINEAR_RANGE(2600000, 0x00, 0x03, 100000),
321 static const unsigned int bd71847_buck4_volt_range_sel
[] = { 0x0, 0x1 };
325 * 3.0V to 3.3V (step 100mV)
327 static const struct linear_range bd71837_buck6_volts
[] = {
328 REGULATOR_LINEAR_RANGE(3000000, 0x00, 0x03, 100000),
337 * 011 = 1.8V (Initial)
343 static const unsigned int bd718xx_3rd_nodvs_buck_volts
[] = {
344 1605000, 1695000, 1755000, 1800000, 1845000, 1905000, 1950000, 1995000
349 * 0.8V to 1.40V (step 10mV)
351 static const struct linear_range bd718xx_4th_nodvs_buck_volts
[] = {
352 REGULATOR_LINEAR_RANGE(800000, 0x00, 0x3C, 10000),
357 * 3.0 to 3.3V (100mV step)
359 static const struct linear_range bd718xx_ldo1_volts
[] = {
360 REGULATOR_LINEAR_RANGE(3000000, 0x00, 0x03, 100000),
361 REGULATOR_LINEAR_RANGE(1600000, 0x00, 0x03, 100000),
364 static const unsigned int bd718xx_ldo1_volt_range_sel
[] = { 0x0, 0x1 };
370 static const unsigned int ldo_2_volts
[] = {
376 * 1.8 to 3.3V (100mV step)
378 static const struct linear_range bd718xx_ldo3_volts
[] = {
379 REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
384 * 0.9 to 1.8V (100mV step)
386 static const struct linear_range bd718xx_ldo4_volts
[] = {
387 REGULATOR_LINEAR_RANGE(900000, 0x00, 0x09, 100000),
392 * 1.8 to 3.3V (100mV step)
394 static const struct linear_range bd71837_ldo5_volts
[] = {
395 REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
400 * 1.8 to 3.3V (100mV step)
402 static const struct linear_range bd71847_ldo5_volts
[] = {
403 REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
404 REGULATOR_LINEAR_RANGE(800000, 0x00, 0x0F, 100000),
407 static const unsigned int bd71847_ldo5_volt_range_sel
[] = { 0x0, 0x1 };
411 * 0.9 to 1.8V (100mV step)
413 static const struct linear_range bd718xx_ldo6_volts
[] = {
414 REGULATOR_LINEAR_RANGE(900000, 0x00, 0x09, 100000),
419 * 1.8 to 3.3V (100mV step)
421 static const struct linear_range bd71837_ldo7_volts
[] = {
422 REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
430 struct bd718xx_regulator_data
{
431 struct regulator_desc desc
;
432 const struct rohm_dvs_config dvs
;
433 const struct reg_init init
;
434 const struct reg_init
*additional_inits
;
435 int additional_init_amnt
;
438 static int bd718x7_xvp_sanity_check(struct regulator_dev
*rdev
, int lim_uV
,
442 * BD71837/47/50 ... (ICs supported by this driver) do not provide
443 * warnings, only protection
445 if (severity
!= REGULATOR_SEVERITY_PROT
) {
447 "Unsupported Under Voltage protection level\n");
452 * And protection limit is not changeable. It can only be enabled
461 static int bd718x7_set_ldo_uvp(struct regulator_dev
*rdev
, int lim_uV
,
462 int severity
, bool enable
)
464 int ldo_offset
= rdev
->desc
->id
- BD718XX_LDO1
;
467 ret
= bd718x7_xvp_sanity_check(rdev
, lim_uV
, severity
);
471 prot_bit
= BD718XX_LDO1_VRMON80
<< ldo_offset
;
474 return regmap_clear_bits(rdev
->regmap
, BD718XX_REG_MVRFLTMASK2
,
477 return regmap_set_bits(rdev
->regmap
, BD718XX_REG_MVRFLTMASK2
,
481 static int bd718x7_get_buck_prot_reg(int id
, int *reg
)
484 if (id
> BD718XX_BUCK8
) {
485 WARN_ON(id
> BD718XX_BUCK8
);
489 if (id
> BD718XX_BUCK4
)
490 *reg
= BD718XX_REG_MVRFLTMASK0
;
492 *reg
= BD718XX_REG_MVRFLTMASK1
;
497 static int bd718x7_get_buck_ovp_info(int id
, int *reg
, int *bit
)
501 ret
= bd718x7_get_buck_prot_reg(id
, reg
);
505 *bit
= BIT((id
% 4) * 2 + 1);
510 static int bd718x7_get_buck_uvp_info(int id
, int *reg
, int *bit
)
514 ret
= bd718x7_get_buck_prot_reg(id
, reg
);
518 *bit
= BIT((id
% 4) * 2);
523 static int bd718x7_set_buck_uvp(struct regulator_dev
*rdev
, int lim_uV
,
524 int severity
, bool enable
)
528 ret
= bd718x7_xvp_sanity_check(rdev
, lim_uV
, severity
);
532 ret
= bd718x7_get_buck_uvp_info(rdev
->desc
->id
, ®
, &bit
);
537 return regmap_clear_bits(rdev
->regmap
, reg
, bit
);
539 return regmap_set_bits(rdev
->regmap
, reg
, bit
);
543 static int bd718x7_set_buck_ovp(struct regulator_dev
*rdev
, int lim_uV
,
549 ret
= bd718x7_xvp_sanity_check(rdev
, lim_uV
, severity
);
553 ret
= bd718x7_get_buck_ovp_info(rdev
->desc
->id
, ®
, &bit
);
558 return regmap_clear_bits(rdev
->regmap
, reg
, bit
);
560 return regmap_set_bits(rdev
->regmap
, reg
, bit
);
564 * OPS common for BD71847 and BD71850
566 BD718XX_OPS(bd718xx_pickable_range_ldo_ops
,
567 regulator_list_voltage_pickable_linear_range
, NULL
,
568 bd718xx_set_voltage_sel_pickable_restricted
,
569 regulator_get_voltage_sel_pickable_regmap
, NULL
, NULL
,
570 bd718x7_set_ldo_uvp
, NULL
);
572 /* BD71847 and BD71850 LDO 5 is by default OFF at RUN state */
573 static const struct regulator_ops bd718xx_ldo5_ops_hwstate
= {
574 .is_enabled
= never_enabled_by_hwstate
,
575 .list_voltage
= regulator_list_voltage_pickable_linear_range
,
576 .set_voltage_sel
= bd718xx_set_voltage_sel_pickable_restricted
,
577 .get_voltage_sel
= regulator_get_voltage_sel_pickable_regmap
,
578 .set_under_voltage_protection
= bd718x7_set_ldo_uvp
,
581 BD718XX_OPS(bd718xx_pickable_range_buck_ops
,
582 regulator_list_voltage_pickable_linear_range
, NULL
,
583 regulator_set_voltage_sel_pickable_regmap
,
584 regulator_get_voltage_sel_pickable_regmap
,
585 regulator_set_voltage_time_sel
, NULL
, bd718x7_set_buck_uvp
,
586 bd718x7_set_buck_ovp
);
588 BD718XX_OPS(bd718xx_ldo_regulator_ops
, regulator_list_voltage_linear_range
,
589 NULL
, bd718xx_set_voltage_sel_restricted
,
590 regulator_get_voltage_sel_regmap
, NULL
, NULL
, bd718x7_set_ldo_uvp
,
593 BD718XX_OPS(bd718xx_ldo_regulator_nolinear_ops
, regulator_list_voltage_table
,
594 NULL
, bd718xx_set_voltage_sel_restricted
,
595 regulator_get_voltage_sel_regmap
, NULL
, NULL
, bd718x7_set_ldo_uvp
,
598 BD718XX_OPS(bd718xx_buck_regulator_ops
, regulator_list_voltage_linear_range
,
599 NULL
, regulator_set_voltage_sel_regmap
,
600 regulator_get_voltage_sel_regmap
, regulator_set_voltage_time_sel
,
601 NULL
, bd718x7_set_buck_uvp
, bd718x7_set_buck_ovp
);
603 BD718XX_OPS(bd718xx_buck_regulator_nolinear_ops
, regulator_list_voltage_table
,
604 regulator_map_voltage_ascend
, regulator_set_voltage_sel_regmap
,
605 regulator_get_voltage_sel_regmap
, regulator_set_voltage_time_sel
,
606 NULL
, bd718x7_set_buck_uvp
, bd718x7_set_buck_ovp
);
611 BD718XX_OPS(bd71837_pickable_range_ldo_ops
,
612 regulator_list_voltage_pickable_linear_range
, NULL
,
613 bd71837_set_voltage_sel_pickable_restricted
,
614 regulator_get_voltage_sel_pickable_regmap
, NULL
, NULL
,
615 bd718x7_set_ldo_uvp
, NULL
);
617 BD718XX_OPS(bd71837_pickable_range_buck_ops
,
618 regulator_list_voltage_pickable_linear_range
, NULL
,
619 bd71837_set_voltage_sel_pickable_restricted
,
620 regulator_get_voltage_sel_pickable_regmap
,
621 regulator_set_voltage_time_sel
, NULL
, bd718x7_set_buck_uvp
,
622 bd718x7_set_buck_ovp
);
624 BD718XX_OPS(bd71837_ldo_regulator_ops
, regulator_list_voltage_linear_range
,
625 NULL
, rohm_regulator_set_voltage_sel_restricted
,
626 regulator_get_voltage_sel_regmap
, NULL
, NULL
, bd718x7_set_ldo_uvp
,
629 BD718XX_OPS(bd71837_ldo_regulator_nolinear_ops
, regulator_list_voltage_table
,
630 NULL
, rohm_regulator_set_voltage_sel_restricted
,
631 regulator_get_voltage_sel_regmap
, NULL
, NULL
, bd718x7_set_ldo_uvp
,
634 BD718XX_OPS(bd71837_buck_regulator_ops
, regulator_list_voltage_linear_range
,
635 NULL
, rohm_regulator_set_voltage_sel_restricted
,
636 regulator_get_voltage_sel_regmap
, regulator_set_voltage_time_sel
,
637 NULL
, bd718x7_set_buck_uvp
, bd718x7_set_buck_ovp
);
639 BD718XX_OPS(bd71837_buck_regulator_nolinear_ops
, regulator_list_voltage_table
,
640 regulator_map_voltage_ascend
, rohm_regulator_set_voltage_sel_restricted
,
641 regulator_get_voltage_sel_regmap
, regulator_set_voltage_time_sel
,
642 NULL
, bd718x7_set_buck_uvp
, bd718x7_set_buck_ovp
);
644 * BD71837 bucks 3 and 4 support defining their enable/disable state also
645 * when buck enable state is under HW state machine control. In that case the
646 * bit [2] in CTRL register is used to indicate if regulator should be ON.
648 static const struct regulator_ops bd71837_buck34_ops_hwctrl
= {
649 .is_enabled
= bd71837_get_buck34_enable_hwctrl
,
650 .list_voltage
= regulator_list_voltage_linear_range
,
651 .set_voltage_sel
= regulator_set_voltage_sel_regmap
,
652 .get_voltage_sel
= regulator_get_voltage_sel_regmap
,
653 .set_voltage_time_sel
= regulator_set_voltage_time_sel
,
654 .set_ramp_delay
= regulator_set_ramp_delay_regmap
,
655 .set_under_voltage_protection
= bd718x7_set_buck_uvp
,
656 .set_over_voltage_protection
= bd718x7_set_buck_ovp
,
660 * OPS for all of the ICs - BD718(37/47/50)
662 BD718XX_OPS(bd718xx_dvs_buck_regulator_ops
, regulator_list_voltage_linear_range
,
663 NULL
, regulator_set_voltage_sel_regmap
,
664 regulator_get_voltage_sel_regmap
, regulator_set_voltage_time_sel
,
665 regulator_set_ramp_delay_regmap
, bd718x7_set_buck_uvp
,
666 bd718x7_set_buck_ovp
);
671 * There is a HW quirk in BD71837. The shutdown sequence timings for
672 * bucks/LDOs which are controlled via register interface are changed.
673 * At PMIC poweroff the voltage for BUCK6/7 is cut immediately at the
674 * beginning of shut-down sequence. As bucks 6 and 7 are parent
675 * supplies for LDO5 and LDO6 - this causes LDO5/6 voltage
676 * monitoring to errorneously detect under voltage and force PMIC to
677 * emergency state instead of poweroff. In order to avoid this we
678 * disable voltage monitoring for LDO5 and LDO6
680 static const struct reg_init bd71837_ldo5_inits
[] = {
682 .reg
= BD718XX_REG_MVRFLTMASK2
,
683 .mask
= BD718XX_LDO5_VRMON80
,
684 .val
= BD718XX_LDO5_VRMON80
,
688 static const struct reg_init bd71837_ldo6_inits
[] = {
690 .reg
= BD718XX_REG_MVRFLTMASK2
,
691 .mask
= BD718XX_LDO6_VRMON80
,
692 .val
= BD718XX_LDO6_VRMON80
,
696 static int buck_set_hw_dvs_levels(struct device_node
*np
,
697 const struct regulator_desc
*desc
,
698 struct regulator_config
*cfg
)
700 struct bd718xx_regulator_data
*data
;
702 data
= container_of(desc
, struct bd718xx_regulator_data
, desc
);
704 return rohm_regulator_set_dvs_levels(&data
->dvs
, np
, desc
, cfg
->regmap
);
707 static const struct regulator_ops
*bd71847_swcontrol_ops
[] = {
708 &bd718xx_dvs_buck_regulator_ops
, &bd718xx_dvs_buck_regulator_ops
,
709 &bd718xx_pickable_range_buck_ops
, &bd718xx_pickable_range_buck_ops
,
710 &bd718xx_buck_regulator_nolinear_ops
, &bd718xx_buck_regulator_ops
,
711 &bd718xx_pickable_range_ldo_ops
, &bd718xx_ldo_regulator_nolinear_ops
,
712 &bd718xx_ldo_regulator_ops
, &bd718xx_ldo_regulator_ops
,
713 &bd718xx_pickable_range_ldo_ops
, &bd718xx_ldo_regulator_ops
,
716 static const struct regulator_ops
*bd71847_hwcontrol_ops
[] = {
717 &BD718XX_HWOPNAME(bd718xx_dvs_buck_regulator_ops
),
718 &BD718XX_HWOPNAME(bd718xx_dvs_buck_regulator_ops
),
719 &BD718XX_HWOPNAME(bd718xx_pickable_range_buck_ops
),
720 &BD718XX_HWOPNAME(bd718xx_pickable_range_buck_ops
),
721 &BD718XX_HWOPNAME(bd718xx_buck_regulator_nolinear_ops
),
722 &BD718XX_HWOPNAME(bd718xx_buck_regulator_ops
),
723 &BD718XX_HWOPNAME(bd718xx_pickable_range_ldo_ops
),
724 &BD718XX_HWOPNAME(bd718xx_ldo_regulator_nolinear_ops
),
725 &BD718XX_HWOPNAME(bd718xx_ldo_regulator_ops
),
726 &BD718XX_HWOPNAME(bd718xx_ldo_regulator_ops
),
727 &bd718xx_ldo5_ops_hwstate
,
728 &BD718XX_HWOPNAME(bd718xx_ldo_regulator_ops
),
731 static struct bd718xx_regulator_data bd71847_regulators
[] = {
735 .of_match
= of_match_ptr("BUCK1"),
736 .regulators_node
= of_match_ptr("regulators"),
738 .type
= REGULATOR_VOLTAGE
,
739 .n_voltages
= BD718XX_DVS_BUCK_VOLTAGE_NUM
,
740 .linear_ranges
= bd718xx_dvs_buck_volts
,
742 ARRAY_SIZE(bd718xx_dvs_buck_volts
),
743 .vsel_reg
= BD718XX_REG_BUCK1_VOLT_RUN
,
744 .vsel_mask
= DVS_BUCK_RUN_MASK
,
745 .enable_reg
= BD718XX_REG_BUCK1_CTRL
,
746 .enable_mask
= BD718XX_BUCK_EN
,
747 .enable_time
= BD71847_BUCK1_STARTUP_TIME
,
748 .owner
= THIS_MODULE
,
749 .ramp_delay_table
= bd718xx_ramp_delay
,
750 .n_ramp_values
= ARRAY_SIZE(bd718xx_ramp_delay
),
751 .ramp_reg
= BD718XX_REG_BUCK1_CTRL
,
752 .ramp_mask
= BUCK_RAMPRATE_MASK
,
753 .of_parse_cb
= buck_set_hw_dvs_levels
,
756 .level_map
= ROHM_DVS_LEVEL_RUN
| ROHM_DVS_LEVEL_IDLE
|
757 ROHM_DVS_LEVEL_SUSPEND
,
758 .run_reg
= BD718XX_REG_BUCK1_VOLT_RUN
,
759 .run_mask
= DVS_BUCK_RUN_MASK
,
760 .idle_reg
= BD718XX_REG_BUCK1_VOLT_IDLE
,
761 .idle_mask
= DVS_BUCK_RUN_MASK
,
762 .suspend_reg
= BD718XX_REG_BUCK1_VOLT_SUSP
,
763 .suspend_mask
= DVS_BUCK_RUN_MASK
,
766 .reg
= BD718XX_REG_BUCK1_CTRL
,
767 .mask
= BD718XX_BUCK_SEL
,
768 .val
= BD718XX_BUCK_SEL
,
774 .of_match
= of_match_ptr("BUCK2"),
775 .regulators_node
= of_match_ptr("regulators"),
777 .type
= REGULATOR_VOLTAGE
,
778 .n_voltages
= BD718XX_DVS_BUCK_VOLTAGE_NUM
,
779 .linear_ranges
= bd718xx_dvs_buck_volts
,
780 .n_linear_ranges
= ARRAY_SIZE(bd718xx_dvs_buck_volts
),
781 .vsel_reg
= BD718XX_REG_BUCK2_VOLT_RUN
,
782 .vsel_mask
= DVS_BUCK_RUN_MASK
,
783 .enable_reg
= BD718XX_REG_BUCK2_CTRL
,
784 .enable_mask
= BD718XX_BUCK_EN
,
785 .enable_time
= BD71847_BUCK2_STARTUP_TIME
,
786 .ramp_delay_table
= bd718xx_ramp_delay
,
787 .n_ramp_values
= ARRAY_SIZE(bd718xx_ramp_delay
),
788 .ramp_reg
= BD718XX_REG_BUCK2_CTRL
,
789 .ramp_mask
= BUCK_RAMPRATE_MASK
,
790 .owner
= THIS_MODULE
,
791 .of_parse_cb
= buck_set_hw_dvs_levels
,
794 .level_map
= ROHM_DVS_LEVEL_RUN
| ROHM_DVS_LEVEL_IDLE
,
795 .run_reg
= BD718XX_REG_BUCK2_VOLT_RUN
,
796 .run_mask
= DVS_BUCK_RUN_MASK
,
797 .idle_reg
= BD718XX_REG_BUCK2_VOLT_IDLE
,
798 .idle_mask
= DVS_BUCK_RUN_MASK
,
801 .reg
= BD718XX_REG_BUCK2_CTRL
,
802 .mask
= BD718XX_BUCK_SEL
,
803 .val
= BD718XX_BUCK_SEL
,
809 .of_match
= of_match_ptr("BUCK3"),
810 .regulators_node
= of_match_ptr("regulators"),
812 .type
= REGULATOR_VOLTAGE
,
813 .n_voltages
= BD71847_BUCK3_VOLTAGE_NUM
,
814 .linear_ranges
= bd71847_buck3_volts
,
816 ARRAY_SIZE(bd71847_buck3_volts
),
817 .vsel_reg
= BD718XX_REG_1ST_NODVS_BUCK_VOLT
,
818 .vsel_mask
= BD718XX_1ST_NODVS_BUCK_MASK
,
819 .vsel_range_reg
= BD718XX_REG_1ST_NODVS_BUCK_VOLT
,
820 .vsel_range_mask
= BD71847_BUCK3_RANGE_MASK
,
821 .linear_range_selectors_bitfield
= bd71847_buck3_volt_range_sel
,
822 .enable_reg
= BD718XX_REG_1ST_NODVS_BUCK_CTRL
,
823 .enable_mask
= BD718XX_BUCK_EN
,
824 .enable_time
= BD71847_BUCK3_STARTUP_TIME
,
825 .owner
= THIS_MODULE
,
828 .reg
= BD718XX_REG_1ST_NODVS_BUCK_CTRL
,
829 .mask
= BD718XX_BUCK_SEL
,
830 .val
= BD718XX_BUCK_SEL
,
836 .of_match
= of_match_ptr("BUCK4"),
837 .regulators_node
= of_match_ptr("regulators"),
839 .type
= REGULATOR_VOLTAGE
,
840 .n_voltages
= BD71847_BUCK4_VOLTAGE_NUM
,
841 .linear_ranges
= bd71847_buck4_volts
,
843 ARRAY_SIZE(bd71847_buck4_volts
),
844 .enable_reg
= BD718XX_REG_2ND_NODVS_BUCK_CTRL
,
845 .vsel_reg
= BD718XX_REG_2ND_NODVS_BUCK_VOLT
,
846 .vsel_mask
= BD71847_BUCK4_MASK
,
847 .vsel_range_reg
= BD718XX_REG_2ND_NODVS_BUCK_VOLT
,
848 .vsel_range_mask
= BD71847_BUCK4_RANGE_MASK
,
849 .linear_range_selectors_bitfield
= bd71847_buck4_volt_range_sel
,
850 .enable_mask
= BD718XX_BUCK_EN
,
851 .enable_time
= BD71847_BUCK4_STARTUP_TIME
,
852 .owner
= THIS_MODULE
,
855 .reg
= BD718XX_REG_2ND_NODVS_BUCK_CTRL
,
856 .mask
= BD718XX_BUCK_SEL
,
857 .val
= BD718XX_BUCK_SEL
,
863 .of_match
= of_match_ptr("BUCK5"),
864 .regulators_node
= of_match_ptr("regulators"),
866 .type
= REGULATOR_VOLTAGE
,
867 .volt_table
= &bd718xx_3rd_nodvs_buck_volts
[0],
868 .n_voltages
= ARRAY_SIZE(bd718xx_3rd_nodvs_buck_volts
),
869 .vsel_reg
= BD718XX_REG_3RD_NODVS_BUCK_VOLT
,
870 .vsel_mask
= BD718XX_3RD_NODVS_BUCK_MASK
,
871 .enable_reg
= BD718XX_REG_3RD_NODVS_BUCK_CTRL
,
872 .enable_mask
= BD718XX_BUCK_EN
,
873 .enable_time
= BD71847_BUCK5_STARTUP_TIME
,
874 .owner
= THIS_MODULE
,
877 .reg
= BD718XX_REG_3RD_NODVS_BUCK_CTRL
,
878 .mask
= BD718XX_BUCK_SEL
,
879 .val
= BD718XX_BUCK_SEL
,
885 .of_match
= of_match_ptr("BUCK6"),
886 .regulators_node
= of_match_ptr("regulators"),
888 .type
= REGULATOR_VOLTAGE
,
889 .n_voltages
= BD718XX_4TH_NODVS_BUCK_VOLTAGE_NUM
,
890 .linear_ranges
= bd718xx_4th_nodvs_buck_volts
,
892 ARRAY_SIZE(bd718xx_4th_nodvs_buck_volts
),
893 .vsel_reg
= BD718XX_REG_4TH_NODVS_BUCK_VOLT
,
894 .vsel_mask
= BD718XX_4TH_NODVS_BUCK_MASK
,
895 .enable_reg
= BD718XX_REG_4TH_NODVS_BUCK_CTRL
,
896 .enable_mask
= BD718XX_BUCK_EN
,
897 .enable_time
= BD71847_BUCK6_STARTUP_TIME
,
898 .owner
= THIS_MODULE
,
901 .reg
= BD718XX_REG_4TH_NODVS_BUCK_CTRL
,
902 .mask
= BD718XX_BUCK_SEL
,
903 .val
= BD718XX_BUCK_SEL
,
909 .of_match
= of_match_ptr("LDO1"),
910 .regulators_node
= of_match_ptr("regulators"),
912 .type
= REGULATOR_VOLTAGE
,
913 .n_voltages
= BD718XX_LDO1_VOLTAGE_NUM
,
914 .linear_ranges
= bd718xx_ldo1_volts
,
915 .n_linear_ranges
= ARRAY_SIZE(bd718xx_ldo1_volts
),
916 .vsel_reg
= BD718XX_REG_LDO1_VOLT
,
917 .vsel_mask
= BD718XX_LDO1_MASK
,
918 .vsel_range_reg
= BD718XX_REG_LDO1_VOLT
,
919 .vsel_range_mask
= BD718XX_LDO1_RANGE_MASK
,
920 .linear_range_selectors_bitfield
= bd718xx_ldo1_volt_range_sel
,
921 .enable_reg
= BD718XX_REG_LDO1_VOLT
,
922 .enable_mask
= BD718XX_LDO_EN
,
923 .enable_time
= BD71847_LDO1_STARTUP_TIME
,
924 .owner
= THIS_MODULE
,
927 .reg
= BD718XX_REG_LDO1_VOLT
,
928 .mask
= BD718XX_LDO_SEL
,
929 .val
= BD718XX_LDO_SEL
,
935 .of_match
= of_match_ptr("LDO2"),
936 .regulators_node
= of_match_ptr("regulators"),
938 .type
= REGULATOR_VOLTAGE
,
939 .volt_table
= &ldo_2_volts
[0],
940 .vsel_reg
= BD718XX_REG_LDO2_VOLT
,
941 .vsel_mask
= BD718XX_LDO2_MASK
,
942 .n_voltages
= ARRAY_SIZE(ldo_2_volts
),
943 .enable_reg
= BD718XX_REG_LDO2_VOLT
,
944 .enable_mask
= BD718XX_LDO_EN
,
945 .enable_time
= BD71847_LDO2_STARTUP_TIME
,
946 .owner
= THIS_MODULE
,
949 .reg
= BD718XX_REG_LDO2_VOLT
,
950 .mask
= BD718XX_LDO_SEL
,
951 .val
= BD718XX_LDO_SEL
,
957 .of_match
= of_match_ptr("LDO3"),
958 .regulators_node
= of_match_ptr("regulators"),
960 .type
= REGULATOR_VOLTAGE
,
961 .n_voltages
= BD718XX_LDO3_VOLTAGE_NUM
,
962 .linear_ranges
= bd718xx_ldo3_volts
,
963 .n_linear_ranges
= ARRAY_SIZE(bd718xx_ldo3_volts
),
964 .vsel_reg
= BD718XX_REG_LDO3_VOLT
,
965 .vsel_mask
= BD718XX_LDO3_MASK
,
966 .enable_reg
= BD718XX_REG_LDO3_VOLT
,
967 .enable_mask
= BD718XX_LDO_EN
,
968 .enable_time
= BD71847_LDO3_STARTUP_TIME
,
969 .owner
= THIS_MODULE
,
972 .reg
= BD718XX_REG_LDO3_VOLT
,
973 .mask
= BD718XX_LDO_SEL
,
974 .val
= BD718XX_LDO_SEL
,
980 .of_match
= of_match_ptr("LDO4"),
981 .regulators_node
= of_match_ptr("regulators"),
983 .type
= REGULATOR_VOLTAGE
,
984 .n_voltages
= BD718XX_LDO4_VOLTAGE_NUM
,
985 .linear_ranges
= bd718xx_ldo4_volts
,
986 .n_linear_ranges
= ARRAY_SIZE(bd718xx_ldo4_volts
),
987 .vsel_reg
= BD718XX_REG_LDO4_VOLT
,
988 .vsel_mask
= BD718XX_LDO4_MASK
,
989 .enable_reg
= BD718XX_REG_LDO4_VOLT
,
990 .enable_mask
= BD718XX_LDO_EN
,
991 .enable_time
= BD71847_LDO4_STARTUP_TIME
,
992 .owner
= THIS_MODULE
,
995 .reg
= BD718XX_REG_LDO4_VOLT
,
996 .mask
= BD718XX_LDO_SEL
,
997 .val
= BD718XX_LDO_SEL
,
1003 .of_match
= of_match_ptr("LDO5"),
1004 .regulators_node
= of_match_ptr("regulators"),
1006 .type
= REGULATOR_VOLTAGE
,
1007 .n_voltages
= BD71847_LDO5_VOLTAGE_NUM
,
1008 .linear_ranges
= bd71847_ldo5_volts
,
1009 .n_linear_ranges
= ARRAY_SIZE(bd71847_ldo5_volts
),
1010 .vsel_reg
= BD718XX_REG_LDO5_VOLT
,
1011 .vsel_mask
= BD71847_LDO5_MASK
,
1012 .vsel_range_reg
= BD718XX_REG_LDO5_VOLT
,
1013 .vsel_range_mask
= BD71847_LDO5_RANGE_MASK
,
1014 .linear_range_selectors_bitfield
= bd71847_ldo5_volt_range_sel
,
1015 .enable_reg
= BD718XX_REG_LDO5_VOLT
,
1016 .enable_mask
= BD718XX_LDO_EN
,
1017 .enable_time
= BD71847_LDO5_STARTUP_TIME
,
1018 .owner
= THIS_MODULE
,
1021 .reg
= BD718XX_REG_LDO5_VOLT
,
1022 .mask
= BD718XX_LDO_SEL
,
1023 .val
= BD718XX_LDO_SEL
,
1029 .of_match
= of_match_ptr("LDO6"),
1030 .regulators_node
= of_match_ptr("regulators"),
1032 .type
= REGULATOR_VOLTAGE
,
1033 .n_voltages
= BD718XX_LDO6_VOLTAGE_NUM
,
1034 .linear_ranges
= bd718xx_ldo6_volts
,
1035 .n_linear_ranges
= ARRAY_SIZE(bd718xx_ldo6_volts
),
1036 /* LDO6 is supplied by buck5 */
1037 .supply_name
= "buck5",
1038 .vsel_reg
= BD718XX_REG_LDO6_VOLT
,
1039 .vsel_mask
= BD718XX_LDO6_MASK
,
1040 .enable_reg
= BD718XX_REG_LDO6_VOLT
,
1041 .enable_mask
= BD718XX_LDO_EN
,
1042 .enable_time
= BD71847_LDO6_STARTUP_TIME
,
1043 .owner
= THIS_MODULE
,
1046 .reg
= BD718XX_REG_LDO6_VOLT
,
1047 .mask
= BD718XX_LDO_SEL
,
1048 .val
= BD718XX_LDO_SEL
,
1053 static const struct regulator_ops
*bd71837_swcontrol_ops
[] = {
1054 &bd718xx_dvs_buck_regulator_ops
, &bd718xx_dvs_buck_regulator_ops
,
1055 &bd718xx_dvs_buck_regulator_ops
, &bd718xx_dvs_buck_regulator_ops
,
1056 &bd71837_pickable_range_buck_ops
, &bd71837_buck_regulator_ops
,
1057 &bd71837_buck_regulator_nolinear_ops
, &bd71837_buck_regulator_ops
,
1058 &bd71837_pickable_range_ldo_ops
, &bd71837_ldo_regulator_nolinear_ops
,
1059 &bd71837_ldo_regulator_ops
, &bd71837_ldo_regulator_ops
,
1060 &bd71837_ldo_regulator_ops
, &bd71837_ldo_regulator_ops
,
1061 &bd71837_ldo_regulator_ops
,
1064 static const struct regulator_ops
*bd71837_hwcontrol_ops
[] = {
1065 &BD718XX_HWOPNAME(bd718xx_dvs_buck_regulator_ops
),
1066 &BD718XX_HWOPNAME(bd718xx_dvs_buck_regulator_ops
),
1067 &bd71837_buck34_ops_hwctrl
, &bd71837_buck34_ops_hwctrl
,
1068 &BD718XX_HWOPNAME(bd71837_pickable_range_buck_ops
),
1069 &BD718XX_HWOPNAME(bd71837_buck_regulator_ops
),
1070 &BD718XX_HWOPNAME(bd71837_buck_regulator_nolinear_ops
),
1071 &BD718XX_HWOPNAME(bd71837_buck_regulator_ops
),
1072 &BD718XX_HWOPNAME(bd71837_pickable_range_ldo_ops
),
1073 &BD718XX_HWOPNAME(bd71837_ldo_regulator_nolinear_ops
),
1074 &BD718XX_HWOPNAME(bd71837_ldo_regulator_ops
),
1075 &BD718XX_HWOPNAME(bd71837_ldo_regulator_ops
),
1076 &BD718XX_HWOPNAME(bd71837_ldo_regulator_ops
),
1077 &BD718XX_HWOPNAME(bd71837_ldo_regulator_ops
),
1078 &BD718XX_HWOPNAME(bd71837_ldo_regulator_ops
),
1081 static struct bd718xx_regulator_data bd71837_regulators
[] = {
1085 .of_match
= of_match_ptr("BUCK1"),
1086 .regulators_node
= of_match_ptr("regulators"),
1087 .id
= BD718XX_BUCK1
,
1088 .type
= REGULATOR_VOLTAGE
,
1089 .n_voltages
= BD718XX_DVS_BUCK_VOLTAGE_NUM
,
1090 .linear_ranges
= bd718xx_dvs_buck_volts
,
1091 .n_linear_ranges
= ARRAY_SIZE(bd718xx_dvs_buck_volts
),
1092 .vsel_reg
= BD718XX_REG_BUCK1_VOLT_RUN
,
1093 .vsel_mask
= DVS_BUCK_RUN_MASK
,
1094 .enable_reg
= BD718XX_REG_BUCK1_CTRL
,
1095 .enable_mask
= BD718XX_BUCK_EN
,
1096 .enable_time
= BD71837_BUCK1_STARTUP_TIME
,
1097 .ramp_delay_table
= bd718xx_ramp_delay
,
1098 .n_ramp_values
= ARRAY_SIZE(bd718xx_ramp_delay
),
1099 .ramp_reg
= BD718XX_REG_BUCK1_CTRL
,
1100 .ramp_mask
= BUCK_RAMPRATE_MASK
,
1101 .owner
= THIS_MODULE
,
1102 .of_parse_cb
= buck_set_hw_dvs_levels
,
1105 .level_map
= ROHM_DVS_LEVEL_RUN
| ROHM_DVS_LEVEL_IDLE
|
1106 ROHM_DVS_LEVEL_SUSPEND
,
1107 .run_reg
= BD718XX_REG_BUCK1_VOLT_RUN
,
1108 .run_mask
= DVS_BUCK_RUN_MASK
,
1109 .idle_reg
= BD718XX_REG_BUCK1_VOLT_IDLE
,
1110 .idle_mask
= DVS_BUCK_RUN_MASK
,
1111 .suspend_reg
= BD718XX_REG_BUCK1_VOLT_SUSP
,
1112 .suspend_mask
= DVS_BUCK_RUN_MASK
,
1115 .reg
= BD718XX_REG_BUCK1_CTRL
,
1116 .mask
= BD718XX_BUCK_SEL
,
1117 .val
= BD718XX_BUCK_SEL
,
1123 .of_match
= of_match_ptr("BUCK2"),
1124 .regulators_node
= of_match_ptr("regulators"),
1125 .id
= BD718XX_BUCK2
,
1126 .type
= REGULATOR_VOLTAGE
,
1127 .n_voltages
= BD718XX_DVS_BUCK_VOLTAGE_NUM
,
1128 .linear_ranges
= bd718xx_dvs_buck_volts
,
1129 .n_linear_ranges
= ARRAY_SIZE(bd718xx_dvs_buck_volts
),
1130 .vsel_reg
= BD718XX_REG_BUCK2_VOLT_RUN
,
1131 .vsel_mask
= DVS_BUCK_RUN_MASK
,
1132 .enable_reg
= BD718XX_REG_BUCK2_CTRL
,
1133 .enable_mask
= BD718XX_BUCK_EN
,
1134 .enable_time
= BD71837_BUCK2_STARTUP_TIME
,
1135 .ramp_delay_table
= bd718xx_ramp_delay
,
1136 .n_ramp_values
= ARRAY_SIZE(bd718xx_ramp_delay
),
1137 .ramp_reg
= BD718XX_REG_BUCK2_CTRL
,
1138 .ramp_mask
= BUCK_RAMPRATE_MASK
,
1139 .owner
= THIS_MODULE
,
1140 .of_parse_cb
= buck_set_hw_dvs_levels
,
1143 .level_map
= ROHM_DVS_LEVEL_RUN
| ROHM_DVS_LEVEL_IDLE
,
1144 .run_reg
= BD718XX_REG_BUCK2_VOLT_RUN
,
1145 .run_mask
= DVS_BUCK_RUN_MASK
,
1146 .idle_reg
= BD718XX_REG_BUCK2_VOLT_IDLE
,
1147 .idle_mask
= DVS_BUCK_RUN_MASK
,
1150 .reg
= BD718XX_REG_BUCK2_CTRL
,
1151 .mask
= BD718XX_BUCK_SEL
,
1152 .val
= BD718XX_BUCK_SEL
,
1158 .of_match
= of_match_ptr("BUCK3"),
1159 .regulators_node
= of_match_ptr("regulators"),
1160 .id
= BD718XX_BUCK3
,
1161 .type
= REGULATOR_VOLTAGE
,
1162 .n_voltages
= BD718XX_DVS_BUCK_VOLTAGE_NUM
,
1163 .linear_ranges
= bd718xx_dvs_buck_volts
,
1164 .n_linear_ranges
= ARRAY_SIZE(bd718xx_dvs_buck_volts
),
1165 .vsel_reg
= BD71837_REG_BUCK3_VOLT_RUN
,
1166 .vsel_mask
= DVS_BUCK_RUN_MASK
,
1167 .enable_reg
= BD71837_REG_BUCK3_CTRL
,
1168 .enable_mask
= BD718XX_BUCK_EN
,
1169 .enable_time
= BD71837_BUCK3_STARTUP_TIME
,
1170 .ramp_delay_table
= bd718xx_ramp_delay
,
1171 .n_ramp_values
= ARRAY_SIZE(bd718xx_ramp_delay
),
1172 .ramp_reg
= BD71837_REG_BUCK3_CTRL
,
1173 .ramp_mask
= BUCK_RAMPRATE_MASK
,
1174 .owner
= THIS_MODULE
,
1175 .of_parse_cb
= buck_set_hw_dvs_levels
,
1178 .level_map
= ROHM_DVS_LEVEL_RUN
,
1179 .run_reg
= BD71837_REG_BUCK3_VOLT_RUN
,
1180 .run_mask
= DVS_BUCK_RUN_MASK
,
1183 .reg
= BD71837_REG_BUCK3_CTRL
,
1184 .mask
= BD718XX_BUCK_SEL
,
1185 .val
= BD718XX_BUCK_SEL
,
1191 .of_match
= of_match_ptr("BUCK4"),
1192 .regulators_node
= of_match_ptr("regulators"),
1193 .id
= BD718XX_BUCK4
,
1194 .type
= REGULATOR_VOLTAGE
,
1195 .n_voltages
= BD718XX_DVS_BUCK_VOLTAGE_NUM
,
1196 .linear_ranges
= bd718xx_dvs_buck_volts
,
1197 .n_linear_ranges
= ARRAY_SIZE(bd718xx_dvs_buck_volts
),
1198 .vsel_reg
= BD71837_REG_BUCK4_VOLT_RUN
,
1199 .vsel_mask
= DVS_BUCK_RUN_MASK
,
1200 .enable_reg
= BD71837_REG_BUCK4_CTRL
,
1201 .enable_mask
= BD718XX_BUCK_EN
,
1202 .enable_time
= BD71837_BUCK4_STARTUP_TIME
,
1203 .ramp_delay_table
= bd718xx_ramp_delay
,
1204 .n_ramp_values
= ARRAY_SIZE(bd718xx_ramp_delay
),
1205 .ramp_reg
= BD71837_REG_BUCK4_CTRL
,
1206 .ramp_mask
= BUCK_RAMPRATE_MASK
,
1207 .owner
= THIS_MODULE
,
1208 .of_parse_cb
= buck_set_hw_dvs_levels
,
1211 .level_map
= ROHM_DVS_LEVEL_RUN
,
1212 .run_reg
= BD71837_REG_BUCK4_VOLT_RUN
,
1213 .run_mask
= DVS_BUCK_RUN_MASK
,
1216 .reg
= BD71837_REG_BUCK4_CTRL
,
1217 .mask
= BD718XX_BUCK_SEL
,
1218 .val
= BD718XX_BUCK_SEL
,
1224 .of_match
= of_match_ptr("BUCK5"),
1225 .regulators_node
= of_match_ptr("regulators"),
1226 .id
= BD718XX_BUCK5
,
1227 .type
= REGULATOR_VOLTAGE
,
1228 .n_voltages
= BD71837_BUCK5_VOLTAGE_NUM
,
1229 .linear_ranges
= bd71837_buck5_volts
,
1231 ARRAY_SIZE(bd71837_buck5_volts
),
1232 .vsel_reg
= BD718XX_REG_1ST_NODVS_BUCK_VOLT
,
1233 .vsel_mask
= BD71837_BUCK5_MASK
,
1234 .vsel_range_reg
= BD718XX_REG_1ST_NODVS_BUCK_VOLT
,
1235 .vsel_range_mask
= BD71837_BUCK5_RANGE_MASK
,
1236 .linear_range_selectors_bitfield
= bd71837_buck5_volt_range_sel
,
1237 .enable_reg
= BD718XX_REG_1ST_NODVS_BUCK_CTRL
,
1238 .enable_mask
= BD718XX_BUCK_EN
,
1239 .enable_time
= BD71837_BUCK5_STARTUP_TIME
,
1240 .owner
= THIS_MODULE
,
1243 .reg
= BD718XX_REG_1ST_NODVS_BUCK_CTRL
,
1244 .mask
= BD718XX_BUCK_SEL
,
1245 .val
= BD718XX_BUCK_SEL
,
1251 .of_match
= of_match_ptr("BUCK6"),
1252 .regulators_node
= of_match_ptr("regulators"),
1253 .id
= BD718XX_BUCK6
,
1254 .type
= REGULATOR_VOLTAGE
,
1255 .n_voltages
= BD71837_BUCK6_VOLTAGE_NUM
,
1256 .linear_ranges
= bd71837_buck6_volts
,
1258 ARRAY_SIZE(bd71837_buck6_volts
),
1259 .vsel_reg
= BD718XX_REG_2ND_NODVS_BUCK_VOLT
,
1260 .vsel_mask
= BD71837_BUCK6_MASK
,
1261 .enable_reg
= BD718XX_REG_2ND_NODVS_BUCK_CTRL
,
1262 .enable_mask
= BD718XX_BUCK_EN
,
1263 .enable_time
= BD71837_BUCK6_STARTUP_TIME
,
1264 .owner
= THIS_MODULE
,
1267 .reg
= BD718XX_REG_2ND_NODVS_BUCK_CTRL
,
1268 .mask
= BD718XX_BUCK_SEL
,
1269 .val
= BD718XX_BUCK_SEL
,
1275 .of_match
= of_match_ptr("BUCK7"),
1276 .regulators_node
= of_match_ptr("regulators"),
1277 .id
= BD718XX_BUCK7
,
1278 .type
= REGULATOR_VOLTAGE
,
1279 .volt_table
= &bd718xx_3rd_nodvs_buck_volts
[0],
1280 .n_voltages
= ARRAY_SIZE(bd718xx_3rd_nodvs_buck_volts
),
1281 .vsel_reg
= BD718XX_REG_3RD_NODVS_BUCK_VOLT
,
1282 .vsel_mask
= BD718XX_3RD_NODVS_BUCK_MASK
,
1283 .enable_reg
= BD718XX_REG_3RD_NODVS_BUCK_CTRL
,
1284 .enable_mask
= BD718XX_BUCK_EN
,
1285 .enable_time
= BD71837_BUCK7_STARTUP_TIME
,
1286 .owner
= THIS_MODULE
,
1289 .reg
= BD718XX_REG_3RD_NODVS_BUCK_CTRL
,
1290 .mask
= BD718XX_BUCK_SEL
,
1291 .val
= BD718XX_BUCK_SEL
,
1297 .of_match
= of_match_ptr("BUCK8"),
1298 .regulators_node
= of_match_ptr("regulators"),
1299 .id
= BD718XX_BUCK8
,
1300 .type
= REGULATOR_VOLTAGE
,
1301 .n_voltages
= BD718XX_4TH_NODVS_BUCK_VOLTAGE_NUM
,
1302 .linear_ranges
= bd718xx_4th_nodvs_buck_volts
,
1304 ARRAY_SIZE(bd718xx_4th_nodvs_buck_volts
),
1305 .vsel_reg
= BD718XX_REG_4TH_NODVS_BUCK_VOLT
,
1306 .vsel_mask
= BD718XX_4TH_NODVS_BUCK_MASK
,
1307 .enable_reg
= BD718XX_REG_4TH_NODVS_BUCK_CTRL
,
1308 .enable_mask
= BD718XX_BUCK_EN
,
1309 .enable_time
= BD71837_BUCK8_STARTUP_TIME
,
1310 .owner
= THIS_MODULE
,
1313 .reg
= BD718XX_REG_4TH_NODVS_BUCK_CTRL
,
1314 .mask
= BD718XX_BUCK_SEL
,
1315 .val
= BD718XX_BUCK_SEL
,
1321 .of_match
= of_match_ptr("LDO1"),
1322 .regulators_node
= of_match_ptr("regulators"),
1324 .type
= REGULATOR_VOLTAGE
,
1325 .n_voltages
= BD718XX_LDO1_VOLTAGE_NUM
,
1326 .linear_ranges
= bd718xx_ldo1_volts
,
1327 .n_linear_ranges
= ARRAY_SIZE(bd718xx_ldo1_volts
),
1328 .vsel_reg
= BD718XX_REG_LDO1_VOLT
,
1329 .vsel_mask
= BD718XX_LDO1_MASK
,
1330 .vsel_range_reg
= BD718XX_REG_LDO1_VOLT
,
1331 .vsel_range_mask
= BD718XX_LDO1_RANGE_MASK
,
1332 .linear_range_selectors_bitfield
= bd718xx_ldo1_volt_range_sel
,
1333 .enable_reg
= BD718XX_REG_LDO1_VOLT
,
1334 .enable_mask
= BD718XX_LDO_EN
,
1335 .enable_time
= BD71837_LDO1_STARTUP_TIME
,
1336 .owner
= THIS_MODULE
,
1339 .reg
= BD718XX_REG_LDO1_VOLT
,
1340 .mask
= BD718XX_LDO_SEL
,
1341 .val
= BD718XX_LDO_SEL
,
1347 .of_match
= of_match_ptr("LDO2"),
1348 .regulators_node
= of_match_ptr("regulators"),
1350 .type
= REGULATOR_VOLTAGE
,
1351 .volt_table
= &ldo_2_volts
[0],
1352 .vsel_reg
= BD718XX_REG_LDO2_VOLT
,
1353 .vsel_mask
= BD718XX_LDO2_MASK
,
1354 .n_voltages
= ARRAY_SIZE(ldo_2_volts
),
1355 .enable_reg
= BD718XX_REG_LDO2_VOLT
,
1356 .enable_mask
= BD718XX_LDO_EN
,
1357 .enable_time
= BD71837_LDO2_STARTUP_TIME
,
1358 .owner
= THIS_MODULE
,
1361 .reg
= BD718XX_REG_LDO2_VOLT
,
1362 .mask
= BD718XX_LDO_SEL
,
1363 .val
= BD718XX_LDO_SEL
,
1369 .of_match
= of_match_ptr("LDO3"),
1370 .regulators_node
= of_match_ptr("regulators"),
1372 .type
= REGULATOR_VOLTAGE
,
1373 .n_voltages
= BD718XX_LDO3_VOLTAGE_NUM
,
1374 .linear_ranges
= bd718xx_ldo3_volts
,
1375 .n_linear_ranges
= ARRAY_SIZE(bd718xx_ldo3_volts
),
1376 .vsel_reg
= BD718XX_REG_LDO3_VOLT
,
1377 .vsel_mask
= BD718XX_LDO3_MASK
,
1378 .enable_reg
= BD718XX_REG_LDO3_VOLT
,
1379 .enable_mask
= BD718XX_LDO_EN
,
1380 .enable_time
= BD71837_LDO3_STARTUP_TIME
,
1381 .owner
= THIS_MODULE
,
1384 .reg
= BD718XX_REG_LDO3_VOLT
,
1385 .mask
= BD718XX_LDO_SEL
,
1386 .val
= BD718XX_LDO_SEL
,
1392 .of_match
= of_match_ptr("LDO4"),
1393 .regulators_node
= of_match_ptr("regulators"),
1395 .type
= REGULATOR_VOLTAGE
,
1396 .n_voltages
= BD718XX_LDO4_VOLTAGE_NUM
,
1397 .linear_ranges
= bd718xx_ldo4_volts
,
1398 .n_linear_ranges
= ARRAY_SIZE(bd718xx_ldo4_volts
),
1399 .vsel_reg
= BD718XX_REG_LDO4_VOLT
,
1400 .vsel_mask
= BD718XX_LDO4_MASK
,
1401 .enable_reg
= BD718XX_REG_LDO4_VOLT
,
1402 .enable_mask
= BD718XX_LDO_EN
,
1403 .enable_time
= BD71837_LDO4_STARTUP_TIME
,
1404 .owner
= THIS_MODULE
,
1407 .reg
= BD718XX_REG_LDO4_VOLT
,
1408 .mask
= BD718XX_LDO_SEL
,
1409 .val
= BD718XX_LDO_SEL
,
1415 .of_match
= of_match_ptr("LDO5"),
1416 .regulators_node
= of_match_ptr("regulators"),
1418 .type
= REGULATOR_VOLTAGE
,
1419 .n_voltages
= BD71837_LDO5_VOLTAGE_NUM
,
1420 .linear_ranges
= bd71837_ldo5_volts
,
1421 .n_linear_ranges
= ARRAY_SIZE(bd71837_ldo5_volts
),
1422 /* LDO5 is supplied by buck6 */
1423 .supply_name
= "buck6",
1424 .vsel_reg
= BD718XX_REG_LDO5_VOLT
,
1425 .vsel_mask
= BD71837_LDO5_MASK
,
1426 .enable_reg
= BD718XX_REG_LDO5_VOLT
,
1427 .enable_mask
= BD718XX_LDO_EN
,
1428 .enable_time
= BD71837_LDO5_STARTUP_TIME
,
1429 .owner
= THIS_MODULE
,
1432 .reg
= BD718XX_REG_LDO5_VOLT
,
1433 .mask
= BD718XX_LDO_SEL
,
1434 .val
= BD718XX_LDO_SEL
,
1436 .additional_inits
= bd71837_ldo5_inits
,
1437 .additional_init_amnt
= ARRAY_SIZE(bd71837_ldo5_inits
),
1442 .of_match
= of_match_ptr("LDO6"),
1443 .regulators_node
= of_match_ptr("regulators"),
1445 .type
= REGULATOR_VOLTAGE
,
1446 .n_voltages
= BD718XX_LDO6_VOLTAGE_NUM
,
1447 .linear_ranges
= bd718xx_ldo6_volts
,
1448 .n_linear_ranges
= ARRAY_SIZE(bd718xx_ldo6_volts
),
1449 /* LDO6 is supplied by buck7 */
1450 .supply_name
= "buck7",
1451 .vsel_reg
= BD718XX_REG_LDO6_VOLT
,
1452 .vsel_mask
= BD718XX_LDO6_MASK
,
1453 .enable_reg
= BD718XX_REG_LDO6_VOLT
,
1454 .enable_mask
= BD718XX_LDO_EN
,
1455 .enable_time
= BD71837_LDO6_STARTUP_TIME
,
1456 .owner
= THIS_MODULE
,
1459 .reg
= BD718XX_REG_LDO6_VOLT
,
1460 .mask
= BD718XX_LDO_SEL
,
1461 .val
= BD718XX_LDO_SEL
,
1463 .additional_inits
= bd71837_ldo6_inits
,
1464 .additional_init_amnt
= ARRAY_SIZE(bd71837_ldo6_inits
),
1469 .of_match
= of_match_ptr("LDO7"),
1470 .regulators_node
= of_match_ptr("regulators"),
1472 .type
= REGULATOR_VOLTAGE
,
1473 .n_voltages
= BD71837_LDO7_VOLTAGE_NUM
,
1474 .linear_ranges
= bd71837_ldo7_volts
,
1475 .n_linear_ranges
= ARRAY_SIZE(bd71837_ldo7_volts
),
1476 .vsel_reg
= BD71837_REG_LDO7_VOLT
,
1477 .vsel_mask
= BD71837_LDO7_MASK
,
1478 .enable_reg
= BD71837_REG_LDO7_VOLT
,
1479 .enable_mask
= BD718XX_LDO_EN
,
1480 .enable_time
= BD71837_LDO7_STARTUP_TIME
,
1481 .owner
= THIS_MODULE
,
1484 .reg
= BD71837_REG_LDO7_VOLT
,
1485 .mask
= BD718XX_LDO_SEL
,
1486 .val
= BD718XX_LDO_SEL
,
1491 static void mark_hw_controlled(struct device
*dev
, struct device_node
*np
,
1492 struct bd718xx_regulator_data
*reg_data
,
1493 unsigned int num_reg_data
, int *info
)
1497 for (i
= 1; i
<= num_reg_data
; i
++) {
1498 if (!of_node_name_eq(np
, reg_data
[i
-1].desc
.of_match
))
1501 *info
|= 1 << (i
- 1);
1502 dev_dbg(dev
, "regulator %d runlevel controlled\n", i
);
1505 dev_warn(dev
, "Bad regulator node\n");
1509 * Setups where regulator (especially the buck8) output voltage is scaled
1510 * by adding external connection where some other regulator output is connected
1511 * to feedback-pin (over suitable resistors) is getting popular amongst users
1512 * of BD71837. (This allows for example scaling down the buck8 voltages to suit
1513 * lover GPU voltages for projects where buck8 is (ab)used to supply power
1514 * for GPU. Additionally some setups do allow DVS for buck8 but as this do
1515 * produce voltage spikes the HW must be evaluated to be able to survive this
1516 * - hence I keep the DVS disabled for non DVS bucks by default. I don't want
1517 * to help you burn your proto board)
1519 * So we allow describing this external connection from DT and scale the
1520 * voltages accordingly. This is what the connection should look like:
1523 * | buck 8 |-------+----->Vout
1534 * Here the buck output is sifted according to formula:
1536 * Vout_o = Vo - (Vpu - Vo)*R2/R1
1537 * Linear_step = step_orig*(R1+R2)/R1
1540 * Vout_o is adjusted voltage output at vsel reg value 0
1541 * Vo is original voltage output at vsel reg value 0
1542 * Vpu is the pull-up voltage V FB-pull-up in the picture
1543 * R1 and R2 are resistor values.
1545 * As a real world example for buck8 and a specific GPU:
1546 * VLDO = 1.6V (used as FB-pull-up)
1549 * VSEL 0x0 => 0.8V – (VLDO – 0.8) * R2 / R1 = 0.68V
1550 * Linear Step = 10mV * (R1 + R2) / R1 = 11.5mV
1552 static int setup_feedback_loop(struct device
*dev
, struct device_node
*np
,
1553 struct bd718xx_regulator_data
*reg_data
,
1554 unsigned int num_reg_data
, int fb_uv
)
1559 * We do adjust the values in the global desc based on DT settings.
1560 * This may not be best approach as it can cause problems if more than
1561 * one PMIC is controlled from same processor. I don't see such use-case
1562 * for BD718x7 now - so we spare some bits.
1564 * If this will point out to be a problem - then we can allocate new
1565 * bd718xx_regulator_data array at probe and just use the global
1566 * array as a template where we copy initial values. Then we can
1567 * use allocated descs for regultor registration and do IC specific
1568 * modifications to this copy while leaving other PMICs untouched. But
1569 * that means allocating new array for each PMIC - and currently I see
1573 for (i
= 0; i
< num_reg_data
; i
++) {
1574 struct regulator_desc
*desc
= ®_data
[i
].desc
;
1577 if (!of_node_name_eq(np
, desc
->of_match
))
1580 /* The feedback loop connection does not make sense for LDOs */
1581 if (desc
->id
>= BD718XX_LDO1
)
1584 ret
= of_property_read_u32(np
, "rohm,feedback-pull-up-r1-ohms",
1592 ret
= of_property_read_u32(np
, "rohm,feedback-pull-up-r2-ohms",
1597 if (desc
->n_linear_ranges
&& desc
->linear_ranges
) {
1598 struct linear_range
*new;
1600 new = devm_kzalloc(dev
, desc
->n_linear_ranges
*
1601 sizeof(struct linear_range
),
1606 for (j
= 0; j
< desc
->n_linear_ranges
; j
++) {
1607 int min
= desc
->linear_ranges
[j
].min
;
1608 int step
= desc
->linear_ranges
[j
].step
;
1610 min
-= (fb_uv
- min
)*r2
/r1
;
1611 step
= step
* (r1
+ r2
);
1617 dev_dbg(dev
, "%s: old range min %d, step %d\n",
1618 desc
->name
, desc
->linear_ranges
[j
].min
,
1619 desc
->linear_ranges
[j
].step
);
1620 dev_dbg(dev
, "new range min %d, step %d\n", min
,
1623 desc
->linear_ranges
= new;
1625 dev_dbg(dev
, "regulator '%s' has FB pull-up configured\n",
1634 static int get_special_regulators(struct device
*dev
,
1635 struct bd718xx_regulator_data
*reg_data
,
1636 unsigned int num_reg_data
, int *info
)
1643 struct device_node
*nproot
__free(device_node
) = of_get_child_by_name(dev
->of_node
,
1646 dev_err(dev
, "failed to find regulators node\n");
1649 for_each_child_of_node_scoped(nproot
, np
) {
1650 if (of_property_read_bool(np
, "rohm,no-regulator-enable-control"))
1651 mark_hw_controlled(dev
, np
, reg_data
, num_reg_data
,
1653 ret
= of_property_read_u32(np
, "rohm,fb-pull-up-microvolt",
1662 ret
= setup_feedback_loop(dev
, np
, reg_data
, num_reg_data
, uv
);
1670 static int bd718xx_probe(struct platform_device
*pdev
)
1672 struct regmap
*regmap
;
1673 struct regulator_config config
= { 0 };
1674 int i
, j
, err
, omit_enable
;
1676 struct bd718xx_regulator_data
*reg_data
;
1677 unsigned int num_reg_data
;
1678 enum rohm_chip_type chip
= platform_get_device_id(pdev
)->driver_data
;
1679 const struct regulator_ops
**swops
, **hwops
;
1681 regmap
= dev_get_regmap(pdev
->dev
.parent
, NULL
);
1683 dev_err(&pdev
->dev
, "No MFD driver data\n");
1688 case ROHM_CHIP_TYPE_BD71837
:
1689 reg_data
= bd71837_regulators
;
1690 num_reg_data
= ARRAY_SIZE(bd71837_regulators
);
1691 swops
= &bd71837_swcontrol_ops
[0];
1692 hwops
= &bd71837_hwcontrol_ops
[0];
1694 case ROHM_CHIP_TYPE_BD71847
:
1695 reg_data
= bd71847_regulators
;
1696 num_reg_data
= ARRAY_SIZE(bd71847_regulators
);
1697 swops
= &bd71847_swcontrol_ops
[0];
1698 hwops
= &bd71847_hwcontrol_ops
[0];
1701 dev_err(&pdev
->dev
, "Unsupported chip type\n");
1705 /* Register LOCK release */
1706 err
= regmap_update_bits(regmap
, BD718XX_REG_REGLOCK
,
1707 (REGLOCK_PWRSEQ
| REGLOCK_VREG
), 0);
1709 return dev_err_probe(&pdev
->dev
, err
, "Failed to unlock PMIC\n");
1711 dev_dbg(&pdev
->dev
, "Unlocked lock register 0x%x\n",
1712 BD718XX_REG_REGLOCK
);
1714 use_snvs
= of_property_read_bool(pdev
->dev
.parent
->of_node
,
1715 "rohm,reset-snvs-powered");
1718 * Change the next stage from poweroff to be READY instead of SNVS
1719 * for all reset types because OTP loading at READY will clear SEL
1720 * bit allowing HW defaults for power rails to be used
1723 err
= regmap_update_bits(regmap
, BD718XX_REG_TRANS_COND1
,
1724 BD718XX_ON_REQ_POWEROFF_MASK
|
1725 BD718XX_SWRESET_POWEROFF_MASK
|
1726 BD718XX_WDOG_POWEROFF_MASK
|
1727 BD718XX_KEY_L_POWEROFF_MASK
,
1728 BD718XX_POWOFF_TO_RDY
);
1730 return dev_err_probe(&pdev
->dev
, err
,
1731 "Failed to change reset target\n");
1733 dev_dbg(&pdev
->dev
, "Changed all resets from SVNS to READY\n");
1736 config
.dev
= pdev
->dev
.parent
;
1737 config
.regmap
= regmap
;
1739 * There are cases when we want to leave the enable-control for
1740 * the HW state machine and use this driver only for voltage control.
1741 * One special case is when we use PMIC_STBY_REQ line from SoC to PMIC
1742 * in order to set the system to SUSPEND state.
1744 * If regulator is taken under SW control the regulator state will not
1745 * be affected by PMIC state machine - Eg. regulator is likely to stay
1746 * on even in SUSPEND
1748 err
= get_special_regulators(pdev
->dev
.parent
, reg_data
, num_reg_data
,
1753 for (i
= 0; i
< num_reg_data
; i
++) {
1755 struct regulator_desc
*desc
;
1756 struct regulator_dev
*rdev
;
1757 struct bd718xx_regulator_data
*r
;
1758 int no_enable_control
= omit_enable
& (1 << i
);
1763 if (no_enable_control
)
1764 desc
->ops
= hwops
[i
];
1766 desc
->ops
= swops
[i
];
1768 rdev
= devm_regulator_register(&pdev
->dev
, desc
, &config
);
1770 return dev_err_probe(&pdev
->dev
, PTR_ERR(rdev
),
1771 "failed to register %s regulator\n",
1775 * Regulator register gets the regulator constraints and
1776 * applies them (set_machine_constraints). This should have
1777 * turned the control register(s) to correct values and we
1778 * can now switch the control from PMIC state machine to the
1779 * register interface
1781 * At poweroff transition PMIC HW disables EN bit for
1782 * regulators but leaves SEL bit untouched. So if state
1783 * transition from POWEROFF is done to SNVS - then all power
1784 * rails controlled by SW (having SEL bit set) stay disabled
1785 * as EN is cleared. This will result boot failure if any
1786 * crucial systems are powered by these rails. We don't
1787 * enable SW control for crucial regulators if snvs state is
1790 if (!no_enable_control
&& (!use_snvs
||
1791 !rdev
->constraints
->always_on
||
1792 !rdev
->constraints
->boot_on
)) {
1793 err
= regmap_update_bits(regmap
, r
->init
.reg
,
1794 r
->init
.mask
, r
->init
.val
);
1796 return dev_err_probe(&pdev
->dev
, err
,
1797 "Failed to take control for (%s)\n",
1800 for (j
= 0; j
< r
->additional_init_amnt
; j
++) {
1801 err
= regmap_update_bits(regmap
,
1802 r
->additional_inits
[j
].reg
,
1803 r
->additional_inits
[j
].mask
,
1804 r
->additional_inits
[j
].val
);
1806 return dev_err_probe(&pdev
->dev
, err
,
1807 "Buck (%s) initialization failed\n",
1815 static const struct platform_device_id bd718x7_pmic_id
[] = {
1816 { "bd71837-pmic", ROHM_CHIP_TYPE_BD71837
},
1817 { "bd71847-pmic", ROHM_CHIP_TYPE_BD71847
},
1820 MODULE_DEVICE_TABLE(platform
, bd718x7_pmic_id
);
1822 static struct platform_driver bd718xx_regulator
= {
1824 .name
= "bd718xx-pmic",
1825 .probe_type
= PROBE_PREFER_ASYNCHRONOUS
,
1827 .probe
= bd718xx_probe
,
1828 .id_table
= bd718x7_pmic_id
,
1831 module_platform_driver(bd718xx_regulator
);
1833 MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>");
1834 MODULE_DESCRIPTION("BD71837/BD71847 voltage regulator driver");
1835 MODULE_LICENSE("GPL");
1836 MODULE_ALIAS("platform:bd718xx-pmic");