1 // SPDX-License-Identifier: GPL-2.0-only
2 // Copyright (C) 2019 ROHM Semiconductors
3 // bd71828-regulator.c ROHM BD71828GW-DS1 regulator driver
6 #include <linux/delay.h>
8 #include <linux/gpio.h>
9 #include <linux/interrupt.h>
10 #include <linux/kernel.h>
11 #include <linux/mfd/rohm-bd71828.h>
12 #include <linux/module.h>
14 #include <linux/platform_device.h>
15 #include <linux/regmap.h>
16 #include <linux/regulator/driver.h>
17 #include <linux/regulator/machine.h>
18 #include <linux/regulator/of_regulator.h>
25 struct bd71828_regulator_data {
26 struct regulator_desc desc;
27 const struct rohm_dvs_config dvs;
28 const struct reg_init *reg_inits;
32 static const struct reg_init buck1_inits[] = {
34 * DVS Buck voltages can be changed by register values or via GPIO.
35 * Use register accesses by default.
38 .reg = BD71828_REG_PS_CTRL_1,
39 .mask = BD71828_MASK_DVS_BUCK1_CTRL,
40 .val = BD71828_DVS_BUCK1_CTRL_I2C,
44 static const struct reg_init buck2_inits[] = {
46 .reg = BD71828_REG_PS_CTRL_1,
47 .mask = BD71828_MASK_DVS_BUCK2_CTRL,
48 .val = BD71828_DVS_BUCK2_CTRL_I2C,
52 static const struct reg_init buck6_inits[] = {
54 .reg = BD71828_REG_PS_CTRL_1,
55 .mask = BD71828_MASK_DVS_BUCK6_CTRL,
56 .val = BD71828_DVS_BUCK6_CTRL_I2C,
60 static const struct reg_init buck7_inits[] = {
62 .reg = BD71828_REG_PS_CTRL_1,
63 .mask = BD71828_MASK_DVS_BUCK7_CTRL,
64 .val = BD71828_DVS_BUCK7_CTRL_I2C,
68 static const struct linear_range bd71828_buck1267_volts[] = {
69 REGULATOR_LINEAR_RANGE(500000, 0x00, 0xef, 6250),
70 REGULATOR_LINEAR_RANGE(2000000, 0xf0, 0xff, 0),
73 static const struct linear_range bd71828_buck3_volts[] = {
74 REGULATOR_LINEAR_RANGE(1200000, 0x00, 0x0f, 50000),
75 REGULATOR_LINEAR_RANGE(2000000, 0x10, 0x1f, 0),
78 static const struct linear_range bd71828_buck4_volts[] = {
79 REGULATOR_LINEAR_RANGE(1000000, 0x00, 0x1f, 25000),
80 REGULATOR_LINEAR_RANGE(1800000, 0x20, 0x3f, 0),
83 static const struct linear_range bd71828_buck5_volts[] = {
84 REGULATOR_LINEAR_RANGE(2500000, 0x00, 0x0f, 50000),
85 REGULATOR_LINEAR_RANGE(3300000, 0x10, 0x1f, 0),
88 static const struct linear_range bd71828_ldo_volts[] = {
89 REGULATOR_LINEAR_RANGE(800000, 0x00, 0x31, 50000),
90 REGULATOR_LINEAR_RANGE(3300000, 0x32, 0x3f, 0),
93 static int bd71828_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
107 case 10001 ... 20000:
113 "ramp_delay: %d not supported, setting 20mV/uS",
118 * On BD71828 the ramp delay level control reg is at offset +2 to
121 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg + 2,
122 BD71828_MASK_RAMP_DELAY,
123 val << (ffs(BD71828_MASK_RAMP_DELAY) - 1));
126 static int buck_set_hw_dvs_levels(struct device_node *np,
127 const struct regulator_desc *desc,
128 struct regulator_config *cfg)
130 struct bd71828_regulator_data *data;
132 data = container_of(desc, struct bd71828_regulator_data, desc);
134 return rohm_regulator_set_dvs_levels(&data->dvs, np, desc, cfg->regmap);
137 static int ldo6_parse_dt(struct device_node *np,
138 const struct regulator_desc *desc,
139 struct regulator_config *cfg)
144 struct regmap *regmap = cfg->regmap;
145 static const char * const props[] = { "rohm,dvs-run-voltage",
146 "rohm,dvs-idle-voltage",
147 "rohm,dvs-suspend-voltage",
148 "rohm,dvs-lpsr-voltage" };
149 unsigned int mask[] = { BD71828_MASK_RUN_EN, BD71828_MASK_IDLE_EN,
150 BD71828_MASK_SUSP_EN, BD71828_MASK_LPSR_EN };
152 for (i = 0; i < ARRAY_SIZE(props); i++) {
153 ret = of_property_read_u32(np, props[i], &uv);
164 ret = regmap_update_bits(regmap, desc->enable_reg, mask[i], en);
171 static const struct regulator_ops bd71828_buck_ops = {
172 .enable = regulator_enable_regmap,
173 .disable = regulator_disable_regmap,
174 .is_enabled = regulator_is_enabled_regmap,
175 .list_voltage = regulator_list_voltage_linear_range,
176 .set_voltage_sel = regulator_set_voltage_sel_regmap,
177 .get_voltage_sel = regulator_get_voltage_sel_regmap,
180 static const struct regulator_ops bd71828_dvs_buck_ops = {
181 .enable = regulator_enable_regmap,
182 .disable = regulator_disable_regmap,
183 .is_enabled = regulator_is_enabled_regmap,
184 .list_voltage = regulator_list_voltage_linear_range,
185 .set_voltage_sel = regulator_set_voltage_sel_regmap,
186 .get_voltage_sel = regulator_get_voltage_sel_regmap,
187 .set_voltage_time_sel = regulator_set_voltage_time_sel,
188 .set_ramp_delay = bd71828_set_ramp_delay,
191 static const struct regulator_ops bd71828_ldo_ops = {
192 .enable = regulator_enable_regmap,
193 .disable = regulator_disable_regmap,
194 .is_enabled = regulator_is_enabled_regmap,
195 .list_voltage = regulator_list_voltage_linear_range,
196 .set_voltage_sel = regulator_set_voltage_sel_regmap,
197 .get_voltage_sel = regulator_get_voltage_sel_regmap,
200 static const struct regulator_ops bd71828_ldo6_ops = {
201 .enable = regulator_enable_regmap,
202 .disable = regulator_disable_regmap,
203 .is_enabled = regulator_is_enabled_regmap,
206 static const struct bd71828_regulator_data bd71828_rdata[] = {
210 .of_match = of_match_ptr("BUCK1"),
211 .regulators_node = of_match_ptr("regulators"),
213 .ops = &bd71828_dvs_buck_ops,
214 .type = REGULATOR_VOLTAGE,
215 .linear_ranges = bd71828_buck1267_volts,
216 .n_linear_ranges = ARRAY_SIZE(bd71828_buck1267_volts),
217 .n_voltages = BD71828_BUCK1267_VOLTS,
218 .enable_reg = BD71828_REG_BUCK1_EN,
219 .enable_mask = BD71828_MASK_RUN_EN,
220 .vsel_reg = BD71828_REG_BUCK1_VOLT,
221 .vsel_mask = BD71828_MASK_BUCK1267_VOLT,
222 .owner = THIS_MODULE,
223 .of_parse_cb = buck_set_hw_dvs_levels,
226 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
227 ROHM_DVS_LEVEL_SUSPEND |
229 .run_reg = BD71828_REG_BUCK1_VOLT,
230 .run_mask = BD71828_MASK_BUCK1267_VOLT,
231 .idle_reg = BD71828_REG_BUCK1_IDLE_VOLT,
232 .idle_mask = BD71828_MASK_BUCK1267_VOLT,
233 .idle_on_mask = BD71828_MASK_IDLE_EN,
234 .suspend_reg = BD71828_REG_BUCK1_SUSP_VOLT,
235 .suspend_mask = BD71828_MASK_BUCK1267_VOLT,
236 .suspend_on_mask = BD71828_MASK_SUSP_EN,
238 * LPSR voltage is same as SUSPEND voltage. Allow
239 * only enabling/disabling regulator for LPSR state
241 .lpsr_on_mask = BD71828_MASK_LPSR_EN,
243 .reg_inits = buck1_inits,
244 .reg_init_amnt = ARRAY_SIZE(buck1_inits),
249 .of_match = of_match_ptr("BUCK2"),
250 .regulators_node = of_match_ptr("regulators"),
252 .ops = &bd71828_dvs_buck_ops,
253 .type = REGULATOR_VOLTAGE,
254 .linear_ranges = bd71828_buck1267_volts,
255 .n_linear_ranges = ARRAY_SIZE(bd71828_buck1267_volts),
256 .n_voltages = BD71828_BUCK1267_VOLTS,
257 .enable_reg = BD71828_REG_BUCK2_EN,
258 .enable_mask = BD71828_MASK_RUN_EN,
259 .vsel_reg = BD71828_REG_BUCK2_VOLT,
260 .vsel_mask = BD71828_MASK_BUCK1267_VOLT,
261 .owner = THIS_MODULE,
262 .of_parse_cb = buck_set_hw_dvs_levels,
265 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
266 ROHM_DVS_LEVEL_SUSPEND |
268 .run_reg = BD71828_REG_BUCK2_VOLT,
269 .run_mask = BD71828_MASK_BUCK1267_VOLT,
270 .idle_reg = BD71828_REG_BUCK2_IDLE_VOLT,
271 .idle_mask = BD71828_MASK_BUCK1267_VOLT,
272 .idle_on_mask = BD71828_MASK_IDLE_EN,
273 .suspend_reg = BD71828_REG_BUCK2_SUSP_VOLT,
274 .suspend_mask = BD71828_MASK_BUCK1267_VOLT,
275 .suspend_on_mask = BD71828_MASK_SUSP_EN,
276 .lpsr_on_mask = BD71828_MASK_LPSR_EN,
277 .lpsr_reg = BD71828_REG_BUCK2_SUSP_VOLT,
278 .lpsr_mask = BD71828_MASK_BUCK1267_VOLT,
280 .reg_inits = buck2_inits,
281 .reg_init_amnt = ARRAY_SIZE(buck2_inits),
286 .of_match = of_match_ptr("BUCK3"),
287 .regulators_node = of_match_ptr("regulators"),
289 .ops = &bd71828_buck_ops,
290 .type = REGULATOR_VOLTAGE,
291 .linear_ranges = bd71828_buck3_volts,
292 .n_linear_ranges = ARRAY_SIZE(bd71828_buck3_volts),
293 .n_voltages = BD71828_BUCK3_VOLTS,
294 .enable_reg = BD71828_REG_BUCK3_EN,
295 .enable_mask = BD71828_MASK_RUN_EN,
296 .vsel_reg = BD71828_REG_BUCK3_VOLT,
297 .vsel_mask = BD71828_MASK_BUCK3_VOLT,
298 .owner = THIS_MODULE,
299 .of_parse_cb = buck_set_hw_dvs_levels,
303 * BUCK3 only supports single voltage for all states.
304 * voltage can be individually enabled for each state
305 * though => allow setting all states to support
306 * enabling power rail on different states.
308 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
309 ROHM_DVS_LEVEL_SUSPEND |
311 .run_reg = BD71828_REG_BUCK3_VOLT,
312 .run_mask = BD71828_MASK_BUCK3_VOLT,
313 .idle_on_mask = BD71828_MASK_IDLE_EN,
314 .suspend_on_mask = BD71828_MASK_SUSP_EN,
315 .lpsr_on_mask = BD71828_MASK_LPSR_EN,
321 .of_match = of_match_ptr("BUCK4"),
322 .regulators_node = of_match_ptr("regulators"),
324 .ops = &bd71828_buck_ops,
325 .type = REGULATOR_VOLTAGE,
326 .linear_ranges = bd71828_buck4_volts,
327 .n_linear_ranges = ARRAY_SIZE(bd71828_buck4_volts),
328 .n_voltages = BD71828_BUCK4_VOLTS,
329 .enable_reg = BD71828_REG_BUCK4_EN,
330 .enable_mask = BD71828_MASK_RUN_EN,
331 .vsel_reg = BD71828_REG_BUCK4_VOLT,
332 .vsel_mask = BD71828_MASK_BUCK4_VOLT,
333 .owner = THIS_MODULE,
334 .of_parse_cb = buck_set_hw_dvs_levels,
338 * BUCK4 only supports single voltage for all states.
339 * voltage can be individually enabled for each state
340 * though => allow setting all states to support
341 * enabling power rail on different states.
343 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
344 ROHM_DVS_LEVEL_SUSPEND |
346 .run_reg = BD71828_REG_BUCK4_VOLT,
347 .run_mask = BD71828_MASK_BUCK4_VOLT,
348 .idle_on_mask = BD71828_MASK_IDLE_EN,
349 .suspend_on_mask = BD71828_MASK_SUSP_EN,
350 .lpsr_on_mask = BD71828_MASK_LPSR_EN,
356 .of_match = of_match_ptr("BUCK5"),
357 .regulators_node = of_match_ptr("regulators"),
359 .ops = &bd71828_buck_ops,
360 .type = REGULATOR_VOLTAGE,
361 .linear_ranges = bd71828_buck5_volts,
362 .n_linear_ranges = ARRAY_SIZE(bd71828_buck5_volts),
363 .n_voltages = BD71828_BUCK5_VOLTS,
364 .enable_reg = BD71828_REG_BUCK5_EN,
365 .enable_mask = BD71828_MASK_RUN_EN,
366 .vsel_reg = BD71828_REG_BUCK5_VOLT,
367 .vsel_mask = BD71828_MASK_BUCK5_VOLT,
368 .owner = THIS_MODULE,
369 .of_parse_cb = buck_set_hw_dvs_levels,
373 * BUCK5 only supports single voltage for all states.
374 * voltage can be individually enabled for each state
375 * though => allow setting all states to support
376 * enabling power rail on different states.
378 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
379 ROHM_DVS_LEVEL_SUSPEND |
381 .run_reg = BD71828_REG_BUCK5_VOLT,
382 .run_mask = BD71828_MASK_BUCK5_VOLT,
383 .idle_on_mask = BD71828_MASK_IDLE_EN,
384 .suspend_on_mask = BD71828_MASK_SUSP_EN,
385 .lpsr_on_mask = BD71828_MASK_LPSR_EN,
391 .of_match = of_match_ptr("BUCK6"),
392 .regulators_node = of_match_ptr("regulators"),
394 .ops = &bd71828_dvs_buck_ops,
395 .type = REGULATOR_VOLTAGE,
396 .linear_ranges = bd71828_buck1267_volts,
397 .n_linear_ranges = ARRAY_SIZE(bd71828_buck1267_volts),
398 .n_voltages = BD71828_BUCK1267_VOLTS,
399 .enable_reg = BD71828_REG_BUCK6_EN,
400 .enable_mask = BD71828_MASK_RUN_EN,
401 .vsel_reg = BD71828_REG_BUCK6_VOLT,
402 .vsel_mask = BD71828_MASK_BUCK1267_VOLT,
403 .owner = THIS_MODULE,
404 .of_parse_cb = buck_set_hw_dvs_levels,
407 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
408 ROHM_DVS_LEVEL_SUSPEND |
410 .run_reg = BD71828_REG_BUCK6_VOLT,
411 .run_mask = BD71828_MASK_BUCK1267_VOLT,
412 .idle_reg = BD71828_REG_BUCK6_IDLE_VOLT,
413 .idle_mask = BD71828_MASK_BUCK1267_VOLT,
414 .idle_on_mask = BD71828_MASK_IDLE_EN,
415 .suspend_reg = BD71828_REG_BUCK6_SUSP_VOLT,
416 .suspend_mask = BD71828_MASK_BUCK1267_VOLT,
417 .suspend_on_mask = BD71828_MASK_SUSP_EN,
418 .lpsr_on_mask = BD71828_MASK_LPSR_EN,
419 .lpsr_reg = BD71828_REG_BUCK6_SUSP_VOLT,
420 .lpsr_mask = BD71828_MASK_BUCK1267_VOLT,
422 .reg_inits = buck6_inits,
423 .reg_init_amnt = ARRAY_SIZE(buck6_inits),
428 .of_match = of_match_ptr("BUCK7"),
429 .regulators_node = of_match_ptr("regulators"),
431 .ops = &bd71828_dvs_buck_ops,
432 .type = REGULATOR_VOLTAGE,
433 .linear_ranges = bd71828_buck1267_volts,
434 .n_linear_ranges = ARRAY_SIZE(bd71828_buck1267_volts),
435 .n_voltages = BD71828_BUCK1267_VOLTS,
436 .enable_reg = BD71828_REG_BUCK7_EN,
437 .enable_mask = BD71828_MASK_RUN_EN,
438 .vsel_reg = BD71828_REG_BUCK7_VOLT,
439 .vsel_mask = BD71828_MASK_BUCK1267_VOLT,
440 .owner = THIS_MODULE,
441 .of_parse_cb = buck_set_hw_dvs_levels,
444 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
445 ROHM_DVS_LEVEL_SUSPEND |
447 .run_reg = BD71828_REG_BUCK7_VOLT,
448 .run_mask = BD71828_MASK_BUCK1267_VOLT,
449 .idle_reg = BD71828_REG_BUCK7_IDLE_VOLT,
450 .idle_mask = BD71828_MASK_BUCK1267_VOLT,
451 .idle_on_mask = BD71828_MASK_IDLE_EN,
452 .suspend_reg = BD71828_REG_BUCK7_SUSP_VOLT,
453 .suspend_mask = BD71828_MASK_BUCK1267_VOLT,
454 .suspend_on_mask = BD71828_MASK_SUSP_EN,
455 .lpsr_on_mask = BD71828_MASK_LPSR_EN,
456 .lpsr_reg = BD71828_REG_BUCK7_SUSP_VOLT,
457 .lpsr_mask = BD71828_MASK_BUCK1267_VOLT,
459 .reg_inits = buck7_inits,
460 .reg_init_amnt = ARRAY_SIZE(buck7_inits),
465 .of_match = of_match_ptr("LDO1"),
466 .regulators_node = of_match_ptr("regulators"),
468 .ops = &bd71828_ldo_ops,
469 .type = REGULATOR_VOLTAGE,
470 .linear_ranges = bd71828_ldo_volts,
471 .n_linear_ranges = ARRAY_SIZE(bd71828_ldo_volts),
472 .n_voltages = BD71828_LDO_VOLTS,
473 .enable_reg = BD71828_REG_LDO1_EN,
474 .enable_mask = BD71828_MASK_RUN_EN,
475 .vsel_reg = BD71828_REG_LDO1_VOLT,
476 .vsel_mask = BD71828_MASK_LDO_VOLT,
477 .owner = THIS_MODULE,
478 .of_parse_cb = buck_set_hw_dvs_levels,
482 * LDO1 only supports single voltage for all states.
483 * voltage can be individually enabled for each state
484 * though => allow setting all states to support
485 * enabling power rail on different states.
487 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
488 ROHM_DVS_LEVEL_SUSPEND |
490 .run_reg = BD71828_REG_LDO1_VOLT,
491 .run_mask = BD71828_MASK_LDO_VOLT,
492 .idle_on_mask = BD71828_MASK_IDLE_EN,
493 .suspend_on_mask = BD71828_MASK_SUSP_EN,
494 .lpsr_on_mask = BD71828_MASK_LPSR_EN,
499 .of_match = of_match_ptr("LDO2"),
500 .regulators_node = of_match_ptr("regulators"),
502 .ops = &bd71828_ldo_ops,
503 .type = REGULATOR_VOLTAGE,
504 .linear_ranges = bd71828_ldo_volts,
505 .n_linear_ranges = ARRAY_SIZE(bd71828_ldo_volts),
506 .n_voltages = BD71828_LDO_VOLTS,
507 .enable_reg = BD71828_REG_LDO2_EN,
508 .enable_mask = BD71828_MASK_RUN_EN,
509 .vsel_reg = BD71828_REG_LDO2_VOLT,
510 .vsel_mask = BD71828_MASK_LDO_VOLT,
511 .owner = THIS_MODULE,
512 .of_parse_cb = buck_set_hw_dvs_levels,
516 * LDO2 only supports single voltage for all states.
517 * voltage can be individually enabled for each state
518 * though => allow setting all states to support
519 * enabling power rail on different states.
521 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
522 ROHM_DVS_LEVEL_SUSPEND |
524 .run_reg = BD71828_REG_LDO2_VOLT,
525 .run_mask = BD71828_MASK_LDO_VOLT,
526 .idle_on_mask = BD71828_MASK_IDLE_EN,
527 .suspend_on_mask = BD71828_MASK_SUSP_EN,
528 .lpsr_on_mask = BD71828_MASK_LPSR_EN,
533 .of_match = of_match_ptr("LDO3"),
534 .regulators_node = of_match_ptr("regulators"),
536 .ops = &bd71828_ldo_ops,
537 .type = REGULATOR_VOLTAGE,
538 .linear_ranges = bd71828_ldo_volts,
539 .n_linear_ranges = ARRAY_SIZE(bd71828_ldo_volts),
540 .n_voltages = BD71828_LDO_VOLTS,
541 .enable_reg = BD71828_REG_LDO3_EN,
542 .enable_mask = BD71828_MASK_RUN_EN,
543 .vsel_reg = BD71828_REG_LDO3_VOLT,
544 .vsel_mask = BD71828_MASK_LDO_VOLT,
545 .owner = THIS_MODULE,
546 .of_parse_cb = buck_set_hw_dvs_levels,
550 * LDO3 only supports single voltage for all states.
551 * voltage can be individually enabled for each state
552 * though => allow setting all states to support
553 * enabling power rail on different states.
555 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
556 ROHM_DVS_LEVEL_SUSPEND |
558 .run_reg = BD71828_REG_LDO3_VOLT,
559 .run_mask = BD71828_MASK_LDO_VOLT,
560 .idle_on_mask = BD71828_MASK_IDLE_EN,
561 .suspend_on_mask = BD71828_MASK_SUSP_EN,
562 .lpsr_on_mask = BD71828_MASK_LPSR_EN,
568 .of_match = of_match_ptr("LDO4"),
569 .regulators_node = of_match_ptr("regulators"),
571 .ops = &bd71828_ldo_ops,
572 .type = REGULATOR_VOLTAGE,
573 .linear_ranges = bd71828_ldo_volts,
574 .n_linear_ranges = ARRAY_SIZE(bd71828_ldo_volts),
575 .n_voltages = BD71828_LDO_VOLTS,
576 .enable_reg = BD71828_REG_LDO4_EN,
577 .enable_mask = BD71828_MASK_RUN_EN,
578 .vsel_reg = BD71828_REG_LDO4_VOLT,
579 .vsel_mask = BD71828_MASK_LDO_VOLT,
580 .owner = THIS_MODULE,
581 .of_parse_cb = buck_set_hw_dvs_levels,
585 * LDO1 only supports single voltage for all states.
586 * voltage can be individually enabled for each state
587 * though => allow setting all states to support
588 * enabling power rail on different states.
590 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
591 ROHM_DVS_LEVEL_SUSPEND |
593 .run_reg = BD71828_REG_LDO4_VOLT,
594 .run_mask = BD71828_MASK_LDO_VOLT,
595 .idle_on_mask = BD71828_MASK_IDLE_EN,
596 .suspend_on_mask = BD71828_MASK_SUSP_EN,
597 .lpsr_on_mask = BD71828_MASK_LPSR_EN,
602 .of_match = of_match_ptr("LDO5"),
603 .regulators_node = of_match_ptr("regulators"),
605 .ops = &bd71828_ldo_ops,
606 .type = REGULATOR_VOLTAGE,
607 .linear_ranges = bd71828_ldo_volts,
608 .n_linear_ranges = ARRAY_SIZE(bd71828_ldo_volts),
609 .n_voltages = BD71828_LDO_VOLTS,
610 .enable_reg = BD71828_REG_LDO5_EN,
611 .enable_mask = BD71828_MASK_RUN_EN,
612 .vsel_reg = BD71828_REG_LDO5_VOLT,
613 .vsel_mask = BD71828_MASK_LDO_VOLT,
614 .of_parse_cb = buck_set_hw_dvs_levels,
615 .owner = THIS_MODULE,
618 * LDO5 is special. It can choose vsel settings to be configured
619 * from 2 different registers (by GPIO).
621 * This driver supports only configuration where
622 * BD71828_REG_LDO5_VOLT_L is used.
625 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
626 ROHM_DVS_LEVEL_SUSPEND |
628 .run_reg = BD71828_REG_LDO5_VOLT,
629 .run_mask = BD71828_MASK_LDO_VOLT,
630 .idle_on_mask = BD71828_MASK_IDLE_EN,
631 .suspend_on_mask = BD71828_MASK_SUSP_EN,
632 .lpsr_on_mask = BD71828_MASK_LPSR_EN,
638 .of_match = of_match_ptr("LDO6"),
639 .regulators_node = of_match_ptr("regulators"),
641 .ops = &bd71828_ldo6_ops,
642 .type = REGULATOR_VOLTAGE,
643 .fixed_uV = BD71828_LDO_6_VOLTAGE,
645 .enable_reg = BD71828_REG_LDO6_EN,
646 .enable_mask = BD71828_MASK_RUN_EN,
647 .owner = THIS_MODULE,
649 * LDO6 only supports enable/disable for all states.
650 * Voltage for LDO6 is fixed.
652 .of_parse_cb = ldo6_parse_dt,
656 /* SNVS LDO in data-sheet */
658 .of_match = of_match_ptr("LDO7"),
659 .regulators_node = of_match_ptr("regulators"),
660 .id = BD71828_LDO_SNVS,
661 .ops = &bd71828_ldo_ops,
662 .type = REGULATOR_VOLTAGE,
663 .linear_ranges = bd71828_ldo_volts,
664 .n_linear_ranges = ARRAY_SIZE(bd71828_ldo_volts),
665 .n_voltages = BD71828_LDO_VOLTS,
666 .enable_reg = BD71828_REG_LDO7_EN,
667 .enable_mask = BD71828_MASK_RUN_EN,
668 .vsel_reg = BD71828_REG_LDO7_VOLT,
669 .vsel_mask = BD71828_MASK_LDO_VOLT,
670 .owner = THIS_MODULE,
671 .of_parse_cb = buck_set_hw_dvs_levels,
675 * LDO7 only supports single voltage for all states.
676 * voltage can be individually enabled for each state
677 * though => allow setting all states to support
678 * enabling power rail on different states.
680 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
681 ROHM_DVS_LEVEL_SUSPEND |
683 .run_reg = BD71828_REG_LDO7_VOLT,
684 .idle_reg = BD71828_REG_LDO7_VOLT,
685 .suspend_reg = BD71828_REG_LDO7_VOLT,
686 .lpsr_reg = BD71828_REG_LDO7_VOLT,
687 .run_mask = BD71828_MASK_LDO_VOLT,
688 .idle_on_mask = BD71828_MASK_IDLE_EN,
689 .suspend_on_mask = BD71828_MASK_SUSP_EN,
690 .lpsr_on_mask = BD71828_MASK_LPSR_EN,
696 static int bd71828_probe(struct platform_device *pdev)
698 struct rohm_regmap_dev *bd71828;
700 struct regulator_config config = {
701 .dev = pdev->dev.parent,
704 bd71828 = dev_get_drvdata(pdev->dev.parent);
706 dev_err(&pdev->dev, "No MFD driver data\n");
710 config.regmap = bd71828->regmap;
712 for (i = 0; i < ARRAY_SIZE(bd71828_rdata); i++) {
713 struct regulator_dev *rdev;
714 const struct bd71828_regulator_data *rd;
716 rd = &bd71828_rdata[i];
717 rdev = devm_regulator_register(&pdev->dev,
721 "failed to register %s regulator\n",
723 return PTR_ERR(rdev);
725 for (j = 0; j < rd->reg_init_amnt; j++) {
726 ret = regmap_update_bits(bd71828->regmap,
727 rd->reg_inits[j].reg,
728 rd->reg_inits[j].mask,
729 rd->reg_inits[j].val);
732 "regulator %s init failed\n",
741 static struct platform_driver bd71828_regulator = {
743 .name = "bd71828-pmic"
745 .probe = bd71828_probe,
748 module_platform_driver(bd71828_regulator);
750 MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>");
751 MODULE_DESCRIPTION("BD71828 voltage regulator driver");
752 MODULE_LICENSE("GPL");
753 MODULE_ALIAS("platform:bd71828-pmic");