1 // SPDX-License-Identifier: GPL-2.0-only
3 // Copyright 2014 Embest Technology Co. Ltd. Inc.
4 // bd71815-regulator.c ROHM BD71815 regulator driver
6 // Author: Tony Luo <luofc@embedinfo.com>
8 // Partially rewritten at 2021 by
9 // Matti Vaittinen <matti.vaitinen@fi.rohmeurope.com>
11 #include <linux/kernel.h>
12 #include <linux/module.h>
13 #include <linux/init.h>
14 #include <linux/err.h>
15 #include <linux/platform_device.h>
17 #include <linux/gpio/consumer.h>
18 #include <linux/regulator/driver.h>
19 #include <linux/delay.h>
20 #include <linux/slab.h>
21 #include <linux/gpio.h>
22 #include <linux/mfd/rohm-generic.h>
23 #include <linux/mfd/rohm-bd71815.h>
24 #include <linux/regulator/of_regulator.h>
26 struct bd71815_regulator {
27 struct regulator_desc desc;
28 const struct rohm_dvs_config *dvs;
31 static const int bd7181x_wled_currents[] = {
32 10, 20, 30, 50, 70, 100, 200, 300, 500, 700, 1000, 2000, 3000, 4000,
33 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000,
34 16000, 17000, 18000, 19000, 20000, 21000, 22000, 23000, 24000, 25000,
37 static const struct rohm_dvs_config buck1_dvs = {
38 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_SNVS |
39 ROHM_DVS_LEVEL_SUSPEND | ROHM_DVS_LEVEL_LPSR,
40 .run_reg = BD71815_REG_BUCK1_VOLT_H,
41 .run_mask = BD71815_VOLT_MASK,
42 .run_on_mask = BD71815_BUCK_RUN_ON,
43 .snvs_on_mask = BD71815_BUCK_SNVS_ON,
44 .suspend_reg = BD71815_REG_BUCK1_VOLT_L,
45 .suspend_mask = BD71815_VOLT_MASK,
46 .suspend_on_mask = BD71815_BUCK_SUSP_ON,
47 .lpsr_reg = BD71815_REG_BUCK1_VOLT_L,
48 .lpsr_mask = BD71815_VOLT_MASK,
49 .lpsr_on_mask = BD71815_BUCK_LPSR_ON,
52 static const struct rohm_dvs_config buck2_dvs = {
53 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_SNVS |
54 ROHM_DVS_LEVEL_SUSPEND | ROHM_DVS_LEVEL_LPSR,
55 .run_reg = BD71815_REG_BUCK2_VOLT_H,
56 .run_mask = BD71815_VOLT_MASK,
57 .run_on_mask = BD71815_BUCK_RUN_ON,
58 .snvs_on_mask = BD71815_BUCK_SNVS_ON,
59 .suspend_reg = BD71815_REG_BUCK2_VOLT_L,
60 .suspend_mask = BD71815_VOLT_MASK,
61 .suspend_on_mask = BD71815_BUCK_SUSP_ON,
62 .lpsr_reg = BD71815_REG_BUCK2_VOLT_L,
63 .lpsr_mask = BD71815_VOLT_MASK,
64 .lpsr_on_mask = BD71815_BUCK_LPSR_ON,
67 static const struct rohm_dvs_config buck3_dvs = {
68 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_SNVS |
69 ROHM_DVS_LEVEL_SUSPEND | ROHM_DVS_LEVEL_LPSR,
70 .run_reg = BD71815_REG_BUCK3_VOLT,
71 .run_mask = BD71815_VOLT_MASK,
72 .run_on_mask = BD71815_BUCK_RUN_ON,
73 .snvs_on_mask = BD71815_BUCK_SNVS_ON,
74 .suspend_on_mask = BD71815_BUCK_SUSP_ON,
75 .lpsr_on_mask = BD71815_BUCK_LPSR_ON,
78 static const struct rohm_dvs_config buck4_dvs = {
79 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_SNVS |
80 ROHM_DVS_LEVEL_SUSPEND | ROHM_DVS_LEVEL_LPSR,
81 .run_reg = BD71815_REG_BUCK4_VOLT,
82 .run_mask = BD71815_VOLT_MASK,
83 .run_on_mask = BD71815_BUCK_RUN_ON,
84 .snvs_on_mask = BD71815_BUCK_SNVS_ON,
85 .suspend_on_mask = BD71815_BUCK_SUSP_ON,
86 .lpsr_on_mask = BD71815_BUCK_LPSR_ON,
89 static const struct rohm_dvs_config ldo1_dvs = {
90 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_SNVS |
91 ROHM_DVS_LEVEL_SUSPEND | ROHM_DVS_LEVEL_LPSR,
92 .run_reg = BD71815_REG_LDO_MODE1,
93 .run_mask = BD71815_VOLT_MASK,
94 .run_on_mask = LDO1_RUN_ON,
95 .snvs_on_mask = LDO1_SNVS_ON,
96 .suspend_on_mask = LDO1_SUSP_ON,
97 .lpsr_on_mask = LDO1_LPSR_ON,
100 static const struct rohm_dvs_config ldo2_dvs = {
101 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_SNVS |
102 ROHM_DVS_LEVEL_SUSPEND | ROHM_DVS_LEVEL_LPSR,
103 .run_reg = BD71815_REG_LDO_MODE2,
104 .run_mask = BD71815_VOLT_MASK,
105 .run_on_mask = LDO2_RUN_ON,
106 .snvs_on_mask = LDO2_SNVS_ON,
107 .suspend_on_mask = LDO2_SUSP_ON,
108 .lpsr_on_mask = LDO2_LPSR_ON,
111 static const struct rohm_dvs_config ldo3_dvs = {
112 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_SNVS |
113 ROHM_DVS_LEVEL_SUSPEND | ROHM_DVS_LEVEL_LPSR,
114 .run_reg = BD71815_REG_LDO_MODE2,
115 .run_mask = BD71815_VOLT_MASK,
116 .run_on_mask = LDO3_RUN_ON,
117 .snvs_on_mask = LDO3_SNVS_ON,
118 .suspend_on_mask = LDO3_SUSP_ON,
119 .lpsr_on_mask = LDO3_LPSR_ON,
122 static const struct rohm_dvs_config ldo4_dvs = {
123 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_SNVS |
124 ROHM_DVS_LEVEL_SUSPEND | ROHM_DVS_LEVEL_LPSR,
125 .run_reg = BD71815_REG_LDO_MODE3,
126 .run_mask = BD71815_VOLT_MASK,
127 .run_on_mask = LDO4_RUN_ON,
128 .snvs_on_mask = LDO4_SNVS_ON,
129 .suspend_on_mask = LDO4_SUSP_ON,
130 .lpsr_on_mask = LDO4_LPSR_ON,
133 static const struct rohm_dvs_config ldo5_dvs = {
134 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_SNVS |
135 ROHM_DVS_LEVEL_SUSPEND | ROHM_DVS_LEVEL_LPSR,
136 .run_reg = BD71815_REG_LDO_MODE3,
137 .run_mask = BD71815_VOLT_MASK,
138 .run_on_mask = LDO5_RUN_ON,
139 .snvs_on_mask = LDO5_SNVS_ON,
140 .suspend_on_mask = LDO5_SUSP_ON,
141 .lpsr_on_mask = LDO5_LPSR_ON,
144 static const struct rohm_dvs_config dvref_dvs = {
145 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_SNVS |
146 ROHM_DVS_LEVEL_SUSPEND | ROHM_DVS_LEVEL_LPSR,
147 .run_on_mask = DVREF_RUN_ON,
148 .snvs_on_mask = DVREF_SNVS_ON,
149 .suspend_on_mask = DVREF_SUSP_ON,
150 .lpsr_on_mask = DVREF_LPSR_ON,
153 static const struct rohm_dvs_config ldolpsr_dvs = {
154 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_SNVS |
155 ROHM_DVS_LEVEL_SUSPEND | ROHM_DVS_LEVEL_LPSR,
156 .run_on_mask = DVREF_RUN_ON,
157 .snvs_on_mask = DVREF_SNVS_ON,
158 .suspend_on_mask = DVREF_SUSP_ON,
159 .lpsr_on_mask = DVREF_LPSR_ON,
162 static const struct rohm_dvs_config buck5_dvs = {
163 .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_SNVS |
164 ROHM_DVS_LEVEL_SUSPEND | ROHM_DVS_LEVEL_LPSR,
165 .run_reg = BD71815_REG_BUCK5_VOLT,
166 .run_mask = BD71815_VOLT_MASK,
167 .run_on_mask = BD71815_BUCK_RUN_ON,
168 .snvs_on_mask = BD71815_BUCK_SNVS_ON,
169 .suspend_on_mask = BD71815_BUCK_SUSP_ON,
170 .lpsr_on_mask = BD71815_BUCK_LPSR_ON,
173 static int set_hw_dvs_levels(struct device_node *np,
174 const struct regulator_desc *desc,
175 struct regulator_config *cfg)
177 struct bd71815_regulator *data;
179 data = container_of(desc, struct bd71815_regulator, desc);
180 return rohm_regulator_set_dvs_levels(data->dvs, np, desc, cfg->regmap);
184 * Bucks 1 and 2 have two voltage selection registers where selected
185 * voltage can be set. Which of the registers is used can be either controlled
186 * by a control bit in register - or by HW state. If HW state specific voltages
187 * are given - then we assume HW state based control should be used.
189 * If volatge value is updated to currently selected register - then output
190 * voltage is immediately changed no matter what is set as ramp rate. Thus we
191 * default changing voltage by writing new value to inactive register and
192 * then updating the 'register selection' bit. This naturally only works when
193 * HW state machine is not used to select the voltage.
195 static int buck12_set_hw_dvs_levels(struct device_node *np,
196 const struct regulator_desc *desc,
197 struct regulator_config *cfg)
199 struct bd71815_regulator *data;
202 data = container_of(desc, struct bd71815_regulator, desc);
204 if (of_find_property(np, "rohm,dvs-run-voltage", NULL) ||
205 of_find_property(np, "rohm,dvs-suspend-voltage", NULL) ||
206 of_find_property(np, "rohm,dvs-lpsr-voltage", NULL) ||
207 of_find_property(np, "rohm,dvs-snvs-voltage", NULL)) {
208 ret = regmap_read(cfg->regmap, desc->vsel_reg, &val);
212 if (!(BD71815_BUCK_STBY_DVS & val) &&
213 !(BD71815_BUCK_DVSSEL & val)) {
217 * We are currently using voltage from _L.
218 * We'd better copy it to _H and switch to it to
219 * avoid shutting us down if LPSR or SUSPEND is set to
220 * disabled. _L value is at reg _H + 1
222 ret = regmap_read(cfg->regmap, desc->vsel_reg + 1,
227 ret = regmap_update_bits(cfg->regmap, desc->vsel_reg,
230 val2 | BD71815_BUCK_DVSSEL);
234 ret = rohm_regulator_set_dvs_levels(data->dvs, np, desc,
239 * DVS levels were given => use HW-state machine for voltage
240 * controls. NOTE: AFAIK, This means that if voltage is changed
241 * by SW the ramp-rate is not respected. Should we disable
242 * SW voltage control when the HW state machine is used?
244 ret = regmap_update_bits(cfg->regmap, desc->vsel_reg,
245 BD71815_BUCK_STBY_DVS,
246 BD71815_BUCK_STBY_DVS);
254 * BUCK1RAMPRATE[1:0] BUCK1 DVS ramp rate setting
255 * 00: 10.00mV/usec 10mV 1uS
256 * 01: 5.00mV/usec 10mV 2uS
257 * 10: 2.50mV/usec 10mV 4uS
258 * 11: 1.25mV/usec 10mV 8uS
260 static const unsigned int bd7181x_ramp_table[] = { 1250, 2500, 5000, 10000 };
262 static int bd7181x_led_set_current_limit(struct regulator_dev *rdev,
263 int min_uA, int max_uA)
268 onstatus = regulator_is_enabled_regmap(rdev);
270 ret = regulator_set_current_limit_regmap(rdev, min_uA, max_uA);
274 newstatus = regulator_is_enabled_regmap(rdev);
275 if (onstatus != newstatus) {
277 * HW FIX: spurious led status change detected. Toggle
278 * state as a workaround
281 ret = regulator_enable_regmap(rdev);
283 ret = regulator_disable_regmap(rdev);
286 dev_err(rdev_get_dev(rdev),
287 "failed to revert the LED state (%d)\n",
295 static int bd7181x_buck12_get_voltage_sel(struct regulator_dev *rdev)
297 int rid = rdev_get_id(rdev);
298 int ret, regh, regl, val;
300 regh = BD71815_REG_BUCK1_VOLT_H + rid * 0x2;
301 regl = BD71815_REG_BUCK1_VOLT_L + rid * 0x2;
303 ret = regmap_read(rdev->regmap, regh, &val);
308 * If we use HW state machine based voltage reg selection - then we
309 * return BD71815_REG_BUCK1_VOLT_H which is used at RUN.
310 * Else we do return the BD71815_REG_BUCK1_VOLT_H or
311 * BD71815_REG_BUCK1_VOLT_L depending on which is selected to be used
312 * by BD71815_BUCK_DVSSEL bit
314 if ((!(val & BD71815_BUCK_STBY_DVS)) && (!(val & BD71815_BUCK_DVSSEL)))
315 ret = regmap_read(rdev->regmap, regl, &val);
320 return val & BD71815_VOLT_MASK;
326 static int bd7181x_buck12_set_voltage_sel(struct regulator_dev *rdev,
329 int rid = rdev_get_id(rdev);
330 int ret, val, reg, regh, regl;
332 regh = BD71815_REG_BUCK1_VOLT_H + rid*0x2;
333 regl = BD71815_REG_BUCK1_VOLT_L + rid*0x2;
335 ret = regmap_read(rdev->regmap, regh, &val);
340 * If bucks 1 & 2 are controlled by state machine - then the RUN state
341 * voltage is set to BD71815_REG_BUCK1_VOLT_H. Changing SUSPEND/LPSR
342 * voltages at runtime is not supported by this driver.
344 if (((val & BD71815_BUCK_STBY_DVS))) {
345 return regmap_update_bits(rdev->regmap, regh, BD71815_VOLT_MASK,
348 /* Update new voltage to the register which is not selected now */
349 if (val & BD71815_BUCK_DVSSEL)
354 ret = regmap_update_bits(rdev->regmap, reg, BD71815_VOLT_MASK, sel);
358 /* Select the other DVS register to be used */
359 return regmap_update_bits(rdev->regmap, regh, BD71815_BUCK_DVSSEL,
363 static const struct regulator_ops bd7181x_ldo_regulator_ops = {
364 .enable = regulator_enable_regmap,
365 .disable = regulator_disable_regmap,
366 .is_enabled = regulator_is_enabled_regmap,
367 .list_voltage = regulator_list_voltage_linear,
368 .set_voltage_sel = regulator_set_voltage_sel_regmap,
369 .get_voltage_sel = regulator_get_voltage_sel_regmap,
372 static const struct regulator_ops bd7181x_fixed_regulator_ops = {
373 .enable = regulator_enable_regmap,
374 .disable = regulator_disable_regmap,
375 .is_enabled = regulator_is_enabled_regmap,
376 .list_voltage = regulator_list_voltage_linear,
379 static const struct regulator_ops bd7181x_buck_regulator_ops = {
380 .enable = regulator_enable_regmap,
381 .disable = regulator_disable_regmap,
382 .is_enabled = regulator_is_enabled_regmap,
383 .list_voltage = regulator_list_voltage_linear,
384 .set_voltage_sel = regulator_set_voltage_sel_regmap,
385 .get_voltage_sel = regulator_get_voltage_sel_regmap,
386 .set_voltage_time_sel = regulator_set_voltage_time_sel,
389 static const struct regulator_ops bd7181x_buck12_regulator_ops = {
390 .enable = regulator_enable_regmap,
391 .disable = regulator_disable_regmap,
392 .is_enabled = regulator_is_enabled_regmap,
393 .list_voltage = regulator_list_voltage_linear,
394 .set_voltage_sel = bd7181x_buck12_set_voltage_sel,
395 .get_voltage_sel = bd7181x_buck12_get_voltage_sel,
396 .set_voltage_time_sel = regulator_set_voltage_time_sel,
397 .set_ramp_delay = regulator_set_ramp_delay_regmap,
400 static const struct regulator_ops bd7181x_led_regulator_ops = {
401 .enable = regulator_enable_regmap,
402 .disable = regulator_disable_regmap,
403 .is_enabled = regulator_is_enabled_regmap,
404 .set_current_limit = bd7181x_led_set_current_limit,
405 .get_current_limit = regulator_get_current_limit_regmap,
408 #define BD71815_FIXED_REG(_name, _id, ereg, emsk, voltage, _dvs) \
412 .of_match = of_match_ptr(#_name), \
413 .regulators_node = of_match_ptr("regulators"), \
415 .ops = &bd7181x_fixed_regulator_ops, \
416 .type = REGULATOR_VOLTAGE, \
418 .owner = THIS_MODULE, \
419 .min_uV = (voltage), \
420 .enable_reg = (ereg), \
421 .enable_mask = (emsk), \
422 .of_parse_cb = set_hw_dvs_levels, \
427 #define BD71815_BUCK_REG(_name, _id, vsel, ereg, min, max, step, _dvs) \
431 .of_match = of_match_ptr(#_name), \
432 .regulators_node = of_match_ptr("regulators"), \
433 .n_voltages = ((max) - (min)) / (step) + 1, \
434 .ops = &bd7181x_buck_regulator_ops, \
435 .type = REGULATOR_VOLTAGE, \
437 .owner = THIS_MODULE, \
440 .vsel_reg = (vsel), \
441 .vsel_mask = BD71815_VOLT_MASK, \
442 .enable_reg = (ereg), \
443 .enable_mask = BD71815_BUCK_RUN_ON, \
444 .of_parse_cb = set_hw_dvs_levels, \
449 #define BD71815_BUCK12_REG(_name, _id, vsel, ereg, min, max, step, \
454 .of_match = of_match_ptr(#_name), \
455 .regulators_node = of_match_ptr("regulators"), \
456 .n_voltages = ((max) - (min)) / (step) + 1, \
457 .ops = &bd7181x_buck12_regulator_ops, \
458 .type = REGULATOR_VOLTAGE, \
460 .owner = THIS_MODULE, \
463 .vsel_reg = (vsel), \
464 .vsel_mask = BD71815_VOLT_MASK, \
465 .enable_reg = (ereg), \
466 .enable_mask = BD71815_BUCK_RUN_ON, \
467 .ramp_reg = (ereg), \
468 .ramp_mask = BD71815_BUCK_RAMPRATE_MASK, \
469 .ramp_delay_table = bd7181x_ramp_table, \
470 .n_ramp_values = ARRAY_SIZE(bd7181x_ramp_table),\
471 .of_parse_cb = buck12_set_hw_dvs_levels, \
476 #define BD71815_LED_REG(_name, _id, csel, mask, ereg, emsk, currents) \
480 .of_match = of_match_ptr(#_name), \
481 .regulators_node = of_match_ptr("regulators"), \
482 .n_current_limits = ARRAY_SIZE(currents), \
483 .ops = &bd7181x_led_regulator_ops, \
484 .type = REGULATOR_CURRENT, \
486 .owner = THIS_MODULE, \
487 .curr_table = currents, \
488 .csel_reg = (csel), \
489 .csel_mask = (mask), \
490 .enable_reg = (ereg), \
491 .enable_mask = (emsk), \
495 #define BD71815_LDO_REG(_name, _id, vsel, ereg, emsk, min, max, step, \
500 .of_match = of_match_ptr(#_name), \
501 .regulators_node = of_match_ptr("regulators"), \
502 .n_voltages = ((max) - (min)) / (step) + 1, \
503 .ops = &bd7181x_ldo_regulator_ops, \
504 .type = REGULATOR_VOLTAGE, \
506 .owner = THIS_MODULE, \
509 .vsel_reg = (vsel), \
510 .vsel_mask = BD71815_VOLT_MASK, \
511 .enable_reg = (ereg), \
512 .enable_mask = (emsk), \
513 .of_parse_cb = set_hw_dvs_levels, \
518 static const struct bd71815_regulator bd71815_regulators[] = {
519 BD71815_BUCK12_REG(buck1, BD71815_BUCK1, BD71815_REG_BUCK1_VOLT_H,
520 BD71815_REG_BUCK1_MODE, 800000, 2000000, 25000,
522 BD71815_BUCK12_REG(buck2, BD71815_BUCK2, BD71815_REG_BUCK2_VOLT_H,
523 BD71815_REG_BUCK2_MODE, 800000, 2000000, 25000,
525 BD71815_BUCK_REG(buck3, BD71815_BUCK3, BD71815_REG_BUCK3_VOLT,
526 BD71815_REG_BUCK3_MODE, 1200000, 2700000, 50000,
528 BD71815_BUCK_REG(buck4, BD71815_BUCK4, BD71815_REG_BUCK4_VOLT,
529 BD71815_REG_BUCK4_MODE, 1100000, 1850000, 25000,
531 BD71815_BUCK_REG(buck5, BD71815_BUCK5, BD71815_REG_BUCK5_VOLT,
532 BD71815_REG_BUCK5_MODE, 1800000, 3300000, 50000,
534 BD71815_LDO_REG(ldo1, BD71815_LDO1, BD71815_REG_LDO1_VOLT,
535 BD71815_REG_LDO_MODE1, LDO1_RUN_ON, 800000, 3300000,
537 BD71815_LDO_REG(ldo2, BD71815_LDO2, BD71815_REG_LDO2_VOLT,
538 BD71815_REG_LDO_MODE2, LDO2_RUN_ON, 800000, 3300000,
541 * Let's default LDO3 to be enabled by SW. We can override ops if DT
542 * says LDO3 should be enabled by HW when DCIN is connected.
544 BD71815_LDO_REG(ldo3, BD71815_LDO3, BD71815_REG_LDO3_VOLT,
545 BD71815_REG_LDO_MODE2, LDO3_RUN_ON, 800000, 3300000,
547 BD71815_LDO_REG(ldo4, BD71815_LDO4, BD71815_REG_LDO4_VOLT,
548 BD71815_REG_LDO_MODE3, LDO4_RUN_ON, 800000, 3300000,
550 BD71815_LDO_REG(ldo5, BD71815_LDO5, BD71815_REG_LDO5_VOLT_H,
551 BD71815_REG_LDO_MODE3, LDO5_RUN_ON, 800000, 3300000,
553 BD71815_FIXED_REG(ldodvref, BD71815_LDODVREF, BD71815_REG_LDO_MODE4,
554 DVREF_RUN_ON, 3000000, &dvref_dvs),
555 BD71815_FIXED_REG(ldolpsr, BD71815_LDOLPSR, BD71815_REG_LDO_MODE4,
556 LDO_LPSR_RUN_ON, 1800000, &ldolpsr_dvs),
557 BD71815_LED_REG(wled, BD71815_WLED, BD71815_REG_LED_DIMM, LED_DIMM_MASK,
558 BD71815_REG_LED_CTRL, LED_RUN_ON,
559 bd7181x_wled_currents),
562 static int bd7181x_probe(struct platform_device *pdev)
564 struct regulator_config config = {};
566 struct gpio_desc *ldo4_en;
567 struct regmap *regmap;
569 regmap = dev_get_regmap(pdev->dev.parent, NULL);
571 dev_err(&pdev->dev, "No parent regmap\n");
575 ldo4_en = devm_fwnode_gpiod_get(&pdev->dev,
576 dev_fwnode(pdev->dev.parent),
577 "rohm,vsel", GPIOD_ASIS, "ldo4-en");
578 if (IS_ERR(ldo4_en)) {
579 ret = PTR_ERR(ldo4_en);
585 /* Disable to go to ship-mode */
586 ret = regmap_update_bits(regmap, BD71815_REG_PWRCTRL, RESTARTEN, 0);
590 config.dev = pdev->dev.parent;
591 config.regmap = regmap;
593 for (i = 0; i < BD71815_REGULATOR_CNT; i++) {
594 const struct regulator_desc *desc;
595 struct regulator_dev *rdev;
597 desc = &bd71815_regulators[i].desc;
599 if (i == BD71815_LDO4)
600 config.ena_gpiod = ldo4_en;
602 config.ena_gpiod = NULL;
604 rdev = devm_regulator_register(&pdev->dev, desc, &config);
607 "failed to register %s regulator\n",
609 return PTR_ERR(rdev);
615 static const struct platform_device_id bd7181x_pmic_id[] = {
616 { "bd71815-pmic", ROHM_CHIP_TYPE_BD71815 },
619 MODULE_DEVICE_TABLE(platform, bd7181x_pmic_id);
621 static struct platform_driver bd7181x_regulator = {
623 .name = "bd7181x-pmic",
625 .probe = bd7181x_probe,
626 .id_table = bd7181x_pmic_id,
628 module_platform_driver(bd7181x_regulator);
630 MODULE_AUTHOR("Tony Luo <luofc@embedinfo.com>");
631 MODULE_DESCRIPTION("BD71815 voltage regulator driver");
632 MODULE_LICENSE("GPL v2");
633 MODULE_ALIAS("platform:bd7181x-pmic");