xref: /linux/drivers/regulator/bd71828-regulator.c (revision df34ecc52526480a1a4bb78bc75bfb009c6076a4)
1 // SPDX-License-Identifier: GPL-2.0-only
2 // Copyright (C) 2019 ROHM Semiconductors
3 // bd71828-regulator.c ROHM BD71828GW-DS1 regulator driver
4 //
5 
6 #include <linux/cleanup.h>
7 #include <linux/delay.h>
8 #include <linux/err.h>
9 #include <linux/interrupt.h>
10 #include <linux/kernel.h>
11 #include <linux/mfd/rohm-bd71828.h>
12 #include <linux/mfd/rohm-bd72720.h>
13 #include <linux/module.h>
14 #include <linux/of.h>
15 #include <linux/platform_device.h>
16 #include <linux/regmap.h>
17 #include <linux/regulator/driver.h>
18 #include <linux/regulator/machine.h>
19 #include <linux/regulator/of_regulator.h>
20 
21 #define BD72720_MASK_LDON_HEAD GENMASK(2, 0)
22 struct reg_init {
23 	unsigned int reg;
24 	unsigned int mask;
25 	unsigned int val;
26 };
27 struct bd71828_regulator_data {
28 	struct regulator_desc desc;
29 	const struct rohm_dvs_config dvs;
30 	const struct reg_init *reg_inits;
31 	int reg_init_amnt;
32 };
33 
34 static const struct reg_init bd71828_buck1_inits[] = {
35 	/*
36 	 * DVS Buck voltages can be changed by register values or via GPIO.
37 	 * Use register accesses by default.
38 	 */
39 	{
40 		.reg = BD71828_REG_PS_CTRL_1,
41 		.mask = BD71828_MASK_DVS_BUCK1_CTRL,
42 		.val = BD71828_DVS_BUCK1_CTRL_I2C,
43 	},
44 };
45 
46 static const struct reg_init bd71828_buck2_inits[] = {
47 	{
48 		.reg = BD71828_REG_PS_CTRL_1,
49 		.mask = BD71828_MASK_DVS_BUCK2_CTRL,
50 		.val = BD71828_DVS_BUCK2_CTRL_I2C,
51 	},
52 };
53 
54 static const struct reg_init bd71828_buck6_inits[] = {
55 	{
56 		.reg = BD71828_REG_PS_CTRL_1,
57 		.mask = BD71828_MASK_DVS_BUCK6_CTRL,
58 		.val = BD71828_DVS_BUCK6_CTRL_I2C,
59 	},
60 };
61 
62 static const struct reg_init bd71828_buck7_inits[] = {
63 	{
64 		.reg = BD71828_REG_PS_CTRL_1,
65 		.mask = BD71828_MASK_DVS_BUCK7_CTRL,
66 		.val = BD71828_DVS_BUCK7_CTRL_I2C,
67 	},
68 };
69 
70 #define BD72720_MASK_DVS_BUCK1_CTRL BIT(4)
71 #define BD72720_MASK_DVS_LDO1_CTRL BIT(5)
72 
73 static const struct reg_init bd72720_buck1_inits[] = {
74 	{
75 		.reg = BD72720_REG_PS_CTRL_2,
76 		.mask = BD72720_MASK_DVS_BUCK1_CTRL,
77 		.val = 0, /* Disable "run-level" control */
78 	},
79 };
80 
81 static const struct reg_init bd72720_ldo1_inits[] = {
82 	{
83 		.reg = BD72720_REG_PS_CTRL_2,
84 		.mask = BD72720_MASK_DVS_LDO1_CTRL,
85 		.val = 0, /* Disable "run-level" control */
86 	},
87 };
88 
89 /* BD71828 Buck voltages */
90 static const struct linear_range bd71828_buck1267_volts[] = {
91 	REGULATOR_LINEAR_RANGE(500000, 0x00, 0xef, 6250),
92 	REGULATOR_LINEAR_RANGE(2000000, 0xf0, 0xff, 0),
93 };
94 
95 static const struct linear_range bd71828_buck3_volts[] = {
96 	REGULATOR_LINEAR_RANGE(1200000, 0x00, 0x0f, 50000),
97 	REGULATOR_LINEAR_RANGE(2000000, 0x10, 0x1f, 0),
98 };
99 
100 static const struct linear_range bd71828_buck4_volts[] = {
101 	REGULATOR_LINEAR_RANGE(1000000, 0x00, 0x1f, 25000),
102 	REGULATOR_LINEAR_RANGE(1800000, 0x20, 0x3f, 0),
103 };
104 
105 static const struct linear_range bd71828_buck5_volts[] = {
106 	REGULATOR_LINEAR_RANGE(2500000, 0x00, 0x0f, 50000),
107 	REGULATOR_LINEAR_RANGE(3300000, 0x10, 0x1f, 0),
108 };
109 
110 /* BD71828 LDO voltages */
111 static const struct linear_range bd71828_ldo_volts[] = {
112 	REGULATOR_LINEAR_RANGE(800000, 0x00, 0x31, 50000),
113 	REGULATOR_LINEAR_RANGE(3300000, 0x32, 0x3f, 0),
114 };
115 
116 /* BD72720 Buck voltages */
117 static const struct linear_range bd72720_buck1234_volts[] = {
118 	REGULATOR_LINEAR_RANGE(500000, 0x00, 0xc0, 6250),
119 	REGULATOR_LINEAR_RANGE(1700000, 0xc1, 0xff, 0),
120 };
121 
122 static const struct linear_range bd72720_buck589_volts[] = {
123 	REGULATOR_LINEAR_RANGE(500000, 0x00, 0x78, 10000),
124 	REGULATOR_LINEAR_RANGE(1700000, 0x79, 0xff, 0),
125 };
126 
127 static const struct linear_range bd72720_buck67_volts[] = {
128 	REGULATOR_LINEAR_RANGE(1500000, 0x00, 0xb4, 10000),
129 	REGULATOR_LINEAR_RANGE(3300000, 0xb5, 0xff, 0),
130 };
131 
132 /*
133  * The BUCK10 on BD72720 has two modes of operation, depending on a LDON_HEAD
134  * setting. When LDON_HEAD is 0x0, the behaviour is as with other bucks, eg.
135  * voltage can be set to a values indicated below using the VSEL register.
136  *
137  * However, when LDON_HEAD is set to 0x1 ... 0x7, BUCK 10 voltage is, according
138  * to the data-sheet, "automatically adjusted following LDON_HEAD setting and
139  * clamped to BUCK10_VID setting".
140  *
141  * Again, reading the data-sheet shows a "typical connection" where the BUCK10
142  * is used to supply the LDOs 1-4. My assumption is that in practice, this
143  * means that the BUCK10 voltage will be adjusted based on the maximum output
144  * of the LDO 1-4 (to minimize power loss). This makes sense.
145  *
146  * Auto-adjusting regulators aren't something I really like to model in the
147  * driver though - and, if the auto-adjustment works as intended, then there
148  * should really be no need to software to care about the buck10 voltages.
149  * If enable/disable control is still needed, we can implement buck10 as a
150  * regulator with only the enable/disable ops - and device-tree can be used
151  * to model the supply-relations. I believe this could allow the regulator
152  * framework to automagically disable the BUCK10 if all LDOs that are being
153  * supplied by it are disabled.
154  */
155 static const struct linear_range bd72720_buck10_volts[] = {
156 	REGULATOR_LINEAR_RANGE(500000, 0x00, 0xc0, 6250),
157 	REGULATOR_LINEAR_RANGE(1700000, 0xc1, 0xff, 0),
158 };
159 
160 /* BD72720 LDO voltages */
161 static const struct linear_range bd72720_ldo1234_volts[] = {
162 	REGULATOR_LINEAR_RANGE(500000, 0x00, 0x50, 6250),
163 	REGULATOR_LINEAR_RANGE(1000000, 0x51, 0x7f, 0),
164 };
165 
166 static const struct linear_range bd72720_ldo57891011_volts[] = {
167 	REGULATOR_LINEAR_RANGE(750000, 0x00, 0xff, 10000),
168 };
169 
170 static const struct linear_range bd72720_ldo6_volts[] = {
171 	REGULATOR_LINEAR_RANGE(600000, 0x00, 0x78, 10000),
172 	REGULATOR_LINEAR_RANGE(1800000, 0x79, 0x7f, 0),
173 };
174 
175 static const unsigned int bd71828_ramp_delay[] = { 2500, 5000, 10000, 20000 };
176 
177 /*
178  * BD72720 supports setting both the ramp-up and ramp-down values
179  * separately. Do we need to support ramp-down setting?
180  */
181 static const unsigned int bd72720_ramp_delay[] = { 5000, 7500, 10000, 12500 };
182 
183 static int buck_set_hw_dvs_levels(struct device_node *np,
184 				  const struct regulator_desc *desc,
185 				  struct regulator_config *cfg)
186 {
187 	const struct bd71828_regulator_data *data;
188 
189 	data = container_of_const(desc, struct bd71828_regulator_data, desc);
190 
191 	return rohm_regulator_set_dvs_levels(&data->dvs, np, desc, cfg->regmap);
192 }
193 
194 static int bd71828_ldo6_parse_dt(struct device_node *np,
195 				 const struct regulator_desc *desc,
196 				 struct regulator_config *cfg)
197 {
198 	int ret, i;
199 	uint32_t uv = 0;
200 	unsigned int en;
201 	struct regmap *regmap = cfg->regmap;
202 	static const char * const props[] = { "rohm,dvs-run-voltage",
203 					      "rohm,dvs-idle-voltage",
204 					      "rohm,dvs-suspend-voltage",
205 					      "rohm,dvs-lpsr-voltage" };
206 	unsigned int mask[] = { BD71828_MASK_RUN_EN, BD71828_MASK_IDLE_EN,
207 			       BD71828_MASK_SUSP_EN, BD71828_MASK_LPSR_EN };
208 
209 	for (i = 0; i < ARRAY_SIZE(props); i++) {
210 		ret = of_property_read_u32(np, props[i], &uv);
211 		if (ret) {
212 			if (ret != -EINVAL)
213 				return ret;
214 			continue;
215 		}
216 		if (uv)
217 			en = 0xffffffff;
218 		else
219 			en = 0;
220 
221 		ret = regmap_update_bits(regmap, desc->enable_reg, mask[i], en);
222 		if (ret)
223 			return ret;
224 	}
225 	return 0;
226 }
227 
228 static const struct regulator_ops bd71828_buck_ops = {
229 	.enable = regulator_enable_regmap,
230 	.disable = regulator_disable_regmap,
231 	.is_enabled = regulator_is_enabled_regmap,
232 	.list_voltage = regulator_list_voltage_linear_range,
233 	.set_voltage_sel = regulator_set_voltage_sel_regmap,
234 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
235 };
236 
237 static const struct regulator_ops bd71828_dvs_buck_ops = {
238 	.enable = regulator_enable_regmap,
239 	.disable = regulator_disable_regmap,
240 	.is_enabled = regulator_is_enabled_regmap,
241 	.list_voltage = regulator_list_voltage_linear_range,
242 	.set_voltage_sel = regulator_set_voltage_sel_regmap,
243 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
244 	.set_voltage_time_sel = regulator_set_voltage_time_sel,
245 	.set_ramp_delay = regulator_set_ramp_delay_regmap,
246 };
247 
248 static const struct regulator_ops bd71828_ldo_ops = {
249 	.enable = regulator_enable_regmap,
250 	.disable = regulator_disable_regmap,
251 	.is_enabled = regulator_is_enabled_regmap,
252 	.list_voltage = regulator_list_voltage_linear_range,
253 	.set_voltage_sel = regulator_set_voltage_sel_regmap,
254 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
255 };
256 
257 static const struct regulator_ops bd71828_ldo6_ops = {
258 	.enable = regulator_enable_regmap,
259 	.disable = regulator_disable_regmap,
260 	.is_enabled = regulator_is_enabled_regmap,
261 };
262 
263 static const struct regulator_ops bd72720_regulator_ops = {
264 	.enable = regulator_enable_regmap,
265 	.disable = regulator_disable_regmap,
266 	.is_enabled = regulator_is_enabled_regmap,
267 	.list_voltage = regulator_list_voltage_linear_range,
268 	.set_voltage_sel = regulator_set_voltage_sel_regmap,
269 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
270 	.set_voltage_time_sel = regulator_set_voltage_time_sel,
271 	.set_ramp_delay = regulator_set_ramp_delay_regmap,
272 };
273 
274 static const struct regulator_ops bd72720_buck10_ldon_head_op = {
275 	.enable = regulator_enable_regmap,
276 	.disable = regulator_disable_regmap,
277 	.is_enabled = regulator_is_enabled_regmap,
278 	.set_ramp_delay = regulator_set_ramp_delay_regmap,
279 };
280 
281 static const struct bd71828_regulator_data bd71828_rdata[] = {
282 	{
283 		.desc = {
284 			.name = "buck1",
285 			.of_match = of_match_ptr("BUCK1"),
286 			.regulators_node = of_match_ptr("regulators"),
287 			.id = BD71828_BUCK1,
288 			.ops = &bd71828_dvs_buck_ops,
289 			.type = REGULATOR_VOLTAGE,
290 			.linear_ranges = bd71828_buck1267_volts,
291 			.n_linear_ranges = ARRAY_SIZE(bd71828_buck1267_volts),
292 			.n_voltages = BD71828_BUCK1267_VOLTS,
293 			.enable_reg = BD71828_REG_BUCK1_EN,
294 			.enable_mask = BD71828_MASK_RUN_EN,
295 			.vsel_reg = BD71828_REG_BUCK1_VOLT,
296 			.vsel_mask = BD71828_MASK_BUCK1267_VOLT,
297 			.ramp_delay_table = bd71828_ramp_delay,
298 			.n_ramp_values = ARRAY_SIZE(bd71828_ramp_delay),
299 			.ramp_reg = BD71828_REG_BUCK1_MODE,
300 			.ramp_mask = BD71828_MASK_RAMP_DELAY,
301 			.owner = THIS_MODULE,
302 			.of_parse_cb = buck_set_hw_dvs_levels,
303 		},
304 		.dvs = {
305 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
306 				     ROHM_DVS_LEVEL_SUSPEND |
307 				     ROHM_DVS_LEVEL_LPSR,
308 			.run_reg = BD71828_REG_BUCK1_VOLT,
309 			.run_mask = BD71828_MASK_BUCK1267_VOLT,
310 			.idle_reg = BD71828_REG_BUCK1_IDLE_VOLT,
311 			.idle_mask = BD71828_MASK_BUCK1267_VOLT,
312 			.idle_on_mask = BD71828_MASK_IDLE_EN,
313 			.suspend_reg = BD71828_REG_BUCK1_SUSP_VOLT,
314 			.suspend_mask = BD71828_MASK_BUCK1267_VOLT,
315 			.suspend_on_mask = BD71828_MASK_SUSP_EN,
316 			/*
317 			 * LPSR voltage is same as SUSPEND voltage. Allow
318 			 * only enabling/disabling regulator for LPSR state
319 			 */
320 			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
321 		},
322 		.reg_inits = bd71828_buck1_inits,
323 		.reg_init_amnt = ARRAY_SIZE(bd71828_buck1_inits),
324 	},
325 	{
326 		.desc = {
327 			.name = "buck2",
328 			.of_match = of_match_ptr("BUCK2"),
329 			.regulators_node = of_match_ptr("regulators"),
330 			.id = BD71828_BUCK2,
331 			.ops = &bd71828_dvs_buck_ops,
332 			.type = REGULATOR_VOLTAGE,
333 			.linear_ranges = bd71828_buck1267_volts,
334 			.n_linear_ranges = ARRAY_SIZE(bd71828_buck1267_volts),
335 			.n_voltages = BD71828_BUCK1267_VOLTS,
336 			.enable_reg = BD71828_REG_BUCK2_EN,
337 			.enable_mask = BD71828_MASK_RUN_EN,
338 			.vsel_reg = BD71828_REG_BUCK2_VOLT,
339 			.vsel_mask = BD71828_MASK_BUCK1267_VOLT,
340 			.ramp_delay_table = bd71828_ramp_delay,
341 			.n_ramp_values = ARRAY_SIZE(bd71828_ramp_delay),
342 			.ramp_reg = BD71828_REG_BUCK2_MODE,
343 			.ramp_mask = BD71828_MASK_RAMP_DELAY,
344 			.owner = THIS_MODULE,
345 			.of_parse_cb = buck_set_hw_dvs_levels,
346 		},
347 		.dvs = {
348 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
349 				     ROHM_DVS_LEVEL_SUSPEND |
350 				     ROHM_DVS_LEVEL_LPSR,
351 			.run_reg = BD71828_REG_BUCK2_VOLT,
352 			.run_mask = BD71828_MASK_BUCK1267_VOLT,
353 			.idle_reg = BD71828_REG_BUCK2_IDLE_VOLT,
354 			.idle_mask = BD71828_MASK_BUCK1267_VOLT,
355 			.idle_on_mask = BD71828_MASK_IDLE_EN,
356 			.suspend_reg = BD71828_REG_BUCK2_SUSP_VOLT,
357 			.suspend_mask = BD71828_MASK_BUCK1267_VOLT,
358 			.suspend_on_mask = BD71828_MASK_SUSP_EN,
359 			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
360 			.lpsr_reg = BD71828_REG_BUCK2_SUSP_VOLT,
361 			.lpsr_mask = BD71828_MASK_BUCK1267_VOLT,
362 		},
363 		.reg_inits = bd71828_buck2_inits,
364 		.reg_init_amnt = ARRAY_SIZE(bd71828_buck2_inits),
365 	},
366 	{
367 		.desc = {
368 			.name = "buck3",
369 			.of_match = of_match_ptr("BUCK3"),
370 			.regulators_node = of_match_ptr("regulators"),
371 			.id = BD71828_BUCK3,
372 			.ops = &bd71828_buck_ops,
373 			.type = REGULATOR_VOLTAGE,
374 			.linear_ranges = bd71828_buck3_volts,
375 			.n_linear_ranges = ARRAY_SIZE(bd71828_buck3_volts),
376 			.n_voltages = BD71828_BUCK3_VOLTS,
377 			.enable_reg = BD71828_REG_BUCK3_EN,
378 			.enable_mask = BD71828_MASK_RUN_EN,
379 			.vsel_reg = BD71828_REG_BUCK3_VOLT,
380 			.vsel_mask = BD71828_MASK_BUCK3_VOLT,
381 			.owner = THIS_MODULE,
382 			.of_parse_cb = buck_set_hw_dvs_levels,
383 		},
384 		.dvs = {
385 			/*
386 			 * BUCK3 only supports single voltage for all states.
387 			 * voltage can be individually enabled for each state
388 			 * though => allow setting all states to support
389 			 * enabling power rail on different states.
390 			 */
391 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
392 				     ROHM_DVS_LEVEL_SUSPEND |
393 				     ROHM_DVS_LEVEL_LPSR,
394 			.run_reg = BD71828_REG_BUCK3_VOLT,
395 			.run_mask = BD71828_MASK_BUCK3_VOLT,
396 			.idle_on_mask = BD71828_MASK_IDLE_EN,
397 			.suspend_on_mask = BD71828_MASK_SUSP_EN,
398 			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
399 		},
400 	},
401 	{
402 		.desc = {
403 			.name = "buck4",
404 			.of_match = of_match_ptr("BUCK4"),
405 			.regulators_node = of_match_ptr("regulators"),
406 			.id = BD71828_BUCK4,
407 			.ops = &bd71828_buck_ops,
408 			.type = REGULATOR_VOLTAGE,
409 			.linear_ranges = bd71828_buck4_volts,
410 			.n_linear_ranges = ARRAY_SIZE(bd71828_buck4_volts),
411 			.n_voltages = BD71828_BUCK4_VOLTS,
412 			.enable_reg = BD71828_REG_BUCK4_EN,
413 			.enable_mask = BD71828_MASK_RUN_EN,
414 			.vsel_reg = BD71828_REG_BUCK4_VOLT,
415 			.vsel_mask = BD71828_MASK_BUCK4_VOLT,
416 			.owner = THIS_MODULE,
417 			.of_parse_cb = buck_set_hw_dvs_levels,
418 		},
419 		.dvs = {
420 			/*
421 			 * BUCK4 only supports single voltage for all states.
422 			 * voltage can be individually enabled for each state
423 			 * though => allow setting all states to support
424 			 * enabling power rail on different states.
425 			 */
426 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
427 				     ROHM_DVS_LEVEL_SUSPEND |
428 				     ROHM_DVS_LEVEL_LPSR,
429 			.run_reg = BD71828_REG_BUCK4_VOLT,
430 			.run_mask = BD71828_MASK_BUCK4_VOLT,
431 			.idle_on_mask = BD71828_MASK_IDLE_EN,
432 			.suspend_on_mask = BD71828_MASK_SUSP_EN,
433 			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
434 		},
435 	},
436 	{
437 		.desc = {
438 			.name = "buck5",
439 			.of_match = of_match_ptr("BUCK5"),
440 			.regulators_node = of_match_ptr("regulators"),
441 			.id = BD71828_BUCK5,
442 			.ops = &bd71828_buck_ops,
443 			.type = REGULATOR_VOLTAGE,
444 			.linear_ranges = bd71828_buck5_volts,
445 			.n_linear_ranges = ARRAY_SIZE(bd71828_buck5_volts),
446 			.n_voltages = BD71828_BUCK5_VOLTS,
447 			.enable_reg = BD71828_REG_BUCK5_EN,
448 			.enable_mask = BD71828_MASK_RUN_EN,
449 			.vsel_reg = BD71828_REG_BUCK5_VOLT,
450 			.vsel_mask = BD71828_MASK_BUCK5_VOLT,
451 			.owner = THIS_MODULE,
452 			.of_parse_cb = buck_set_hw_dvs_levels,
453 		},
454 		.dvs = {
455 			/*
456 			 * BUCK5 only supports single voltage for all states.
457 			 * voltage can be individually enabled for each state
458 			 * though => allow setting all states to support
459 			 * enabling power rail on different states.
460 			 */
461 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
462 				     ROHM_DVS_LEVEL_SUSPEND |
463 				     ROHM_DVS_LEVEL_LPSR,
464 			.run_reg = BD71828_REG_BUCK5_VOLT,
465 			.run_mask = BD71828_MASK_BUCK5_VOLT,
466 			.idle_on_mask = BD71828_MASK_IDLE_EN,
467 			.suspend_on_mask = BD71828_MASK_SUSP_EN,
468 			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
469 		},
470 	},
471 	{
472 		.desc = {
473 			.name = "buck6",
474 			.of_match = of_match_ptr("BUCK6"),
475 			.regulators_node = of_match_ptr("regulators"),
476 			.id = BD71828_BUCK6,
477 			.ops = &bd71828_dvs_buck_ops,
478 			.type = REGULATOR_VOLTAGE,
479 			.linear_ranges = bd71828_buck1267_volts,
480 			.n_linear_ranges = ARRAY_SIZE(bd71828_buck1267_volts),
481 			.n_voltages = BD71828_BUCK1267_VOLTS,
482 			.enable_reg = BD71828_REG_BUCK6_EN,
483 			.enable_mask = BD71828_MASK_RUN_EN,
484 			.vsel_reg = BD71828_REG_BUCK6_VOLT,
485 			.vsel_mask = BD71828_MASK_BUCK1267_VOLT,
486 			.ramp_delay_table = bd71828_ramp_delay,
487 			.n_ramp_values = ARRAY_SIZE(bd71828_ramp_delay),
488 			.ramp_reg = BD71828_REG_BUCK6_MODE,
489 			.ramp_mask = BD71828_MASK_RAMP_DELAY,
490 			.owner = THIS_MODULE,
491 			.of_parse_cb = buck_set_hw_dvs_levels,
492 		},
493 		.dvs = {
494 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
495 				     ROHM_DVS_LEVEL_SUSPEND |
496 				     ROHM_DVS_LEVEL_LPSR,
497 			.run_reg = BD71828_REG_BUCK6_VOLT,
498 			.run_mask = BD71828_MASK_BUCK1267_VOLT,
499 			.idle_reg = BD71828_REG_BUCK6_IDLE_VOLT,
500 			.idle_mask = BD71828_MASK_BUCK1267_VOLT,
501 			.idle_on_mask = BD71828_MASK_IDLE_EN,
502 			.suspend_reg = BD71828_REG_BUCK6_SUSP_VOLT,
503 			.suspend_mask = BD71828_MASK_BUCK1267_VOLT,
504 			.suspend_on_mask = BD71828_MASK_SUSP_EN,
505 			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
506 			.lpsr_reg = BD71828_REG_BUCK6_SUSP_VOLT,
507 			.lpsr_mask = BD71828_MASK_BUCK1267_VOLT,
508 		},
509 		.reg_inits = bd71828_buck6_inits,
510 		.reg_init_amnt = ARRAY_SIZE(bd71828_buck6_inits),
511 	},
512 	{
513 		.desc = {
514 			.name = "buck7",
515 			.of_match = of_match_ptr("BUCK7"),
516 			.regulators_node = of_match_ptr("regulators"),
517 			.id = BD71828_BUCK7,
518 			.ops = &bd71828_dvs_buck_ops,
519 			.type = REGULATOR_VOLTAGE,
520 			.linear_ranges = bd71828_buck1267_volts,
521 			.n_linear_ranges = ARRAY_SIZE(bd71828_buck1267_volts),
522 			.n_voltages = BD71828_BUCK1267_VOLTS,
523 			.enable_reg = BD71828_REG_BUCK7_EN,
524 			.enable_mask = BD71828_MASK_RUN_EN,
525 			.vsel_reg = BD71828_REG_BUCK7_VOLT,
526 			.vsel_mask = BD71828_MASK_BUCK1267_VOLT,
527 			.ramp_delay_table = bd71828_ramp_delay,
528 			.n_ramp_values = ARRAY_SIZE(bd71828_ramp_delay),
529 			.ramp_reg = BD71828_REG_BUCK7_MODE,
530 			.ramp_mask = BD71828_MASK_RAMP_DELAY,
531 			.owner = THIS_MODULE,
532 			.of_parse_cb = buck_set_hw_dvs_levels,
533 		},
534 		.dvs = {
535 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
536 				     ROHM_DVS_LEVEL_SUSPEND |
537 				     ROHM_DVS_LEVEL_LPSR,
538 			.run_reg = BD71828_REG_BUCK7_VOLT,
539 			.run_mask = BD71828_MASK_BUCK1267_VOLT,
540 			.idle_reg = BD71828_REG_BUCK7_IDLE_VOLT,
541 			.idle_mask = BD71828_MASK_BUCK1267_VOLT,
542 			.idle_on_mask = BD71828_MASK_IDLE_EN,
543 			.suspend_reg = BD71828_REG_BUCK7_SUSP_VOLT,
544 			.suspend_mask = BD71828_MASK_BUCK1267_VOLT,
545 			.suspend_on_mask = BD71828_MASK_SUSP_EN,
546 			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
547 			.lpsr_reg = BD71828_REG_BUCK7_SUSP_VOLT,
548 			.lpsr_mask = BD71828_MASK_BUCK1267_VOLT,
549 		},
550 		.reg_inits = bd71828_buck7_inits,
551 		.reg_init_amnt = ARRAY_SIZE(bd71828_buck7_inits),
552 	},
553 	{
554 		.desc = {
555 			.name = "ldo1",
556 			.of_match = of_match_ptr("LDO1"),
557 			.regulators_node = of_match_ptr("regulators"),
558 			.id = BD71828_LDO1,
559 			.ops = &bd71828_ldo_ops,
560 			.type = REGULATOR_VOLTAGE,
561 			.linear_ranges = bd71828_ldo_volts,
562 			.n_linear_ranges = ARRAY_SIZE(bd71828_ldo_volts),
563 			.n_voltages = BD71828_LDO_VOLTS,
564 			.enable_reg = BD71828_REG_LDO1_EN,
565 			.enable_mask = BD71828_MASK_RUN_EN,
566 			.vsel_reg = BD71828_REG_LDO1_VOLT,
567 			.vsel_mask = BD71828_MASK_LDO_VOLT,
568 			.owner = THIS_MODULE,
569 			.of_parse_cb = buck_set_hw_dvs_levels,
570 		},
571 		.dvs = {
572 			/*
573 			 * LDO1 only supports single voltage for all states.
574 			 * voltage can be individually enabled for each state
575 			 * though => allow setting all states to support
576 			 * enabling power rail on different states.
577 			 */
578 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
579 				     ROHM_DVS_LEVEL_SUSPEND |
580 				     ROHM_DVS_LEVEL_LPSR,
581 			.run_reg = BD71828_REG_LDO1_VOLT,
582 			.run_mask = BD71828_MASK_LDO_VOLT,
583 			.idle_on_mask = BD71828_MASK_IDLE_EN,
584 			.suspend_on_mask = BD71828_MASK_SUSP_EN,
585 			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
586 		},
587 	}, {
588 		.desc = {
589 			.name = "ldo2",
590 			.of_match = of_match_ptr("LDO2"),
591 			.regulators_node = of_match_ptr("regulators"),
592 			.id = BD71828_LDO2,
593 			.ops = &bd71828_ldo_ops,
594 			.type = REGULATOR_VOLTAGE,
595 			.linear_ranges = bd71828_ldo_volts,
596 			.n_linear_ranges = ARRAY_SIZE(bd71828_ldo_volts),
597 			.n_voltages = BD71828_LDO_VOLTS,
598 			.enable_reg = BD71828_REG_LDO2_EN,
599 			.enable_mask = BD71828_MASK_RUN_EN,
600 			.vsel_reg = BD71828_REG_LDO2_VOLT,
601 			.vsel_mask = BD71828_MASK_LDO_VOLT,
602 			.owner = THIS_MODULE,
603 			.of_parse_cb = buck_set_hw_dvs_levels,
604 		},
605 		.dvs = {
606 			/*
607 			 * LDO2 only supports single voltage for all states.
608 			 * voltage can be individually enabled for each state
609 			 * though => allow setting all states to support
610 			 * enabling power rail on different states.
611 			 */
612 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
613 				     ROHM_DVS_LEVEL_SUSPEND |
614 				     ROHM_DVS_LEVEL_LPSR,
615 			.run_reg = BD71828_REG_LDO2_VOLT,
616 			.run_mask = BD71828_MASK_LDO_VOLT,
617 			.idle_on_mask = BD71828_MASK_IDLE_EN,
618 			.suspend_on_mask = BD71828_MASK_SUSP_EN,
619 			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
620 		},
621 	}, {
622 		.desc = {
623 			.name = "ldo3",
624 			.of_match = of_match_ptr("LDO3"),
625 			.regulators_node = of_match_ptr("regulators"),
626 			.id = BD71828_LDO3,
627 			.ops = &bd71828_ldo_ops,
628 			.type = REGULATOR_VOLTAGE,
629 			.linear_ranges = bd71828_ldo_volts,
630 			.n_linear_ranges = ARRAY_SIZE(bd71828_ldo_volts),
631 			.n_voltages = BD71828_LDO_VOLTS,
632 			.enable_reg = BD71828_REG_LDO3_EN,
633 			.enable_mask = BD71828_MASK_RUN_EN,
634 			.vsel_reg = BD71828_REG_LDO3_VOLT,
635 			.vsel_mask = BD71828_MASK_LDO_VOLT,
636 			.owner = THIS_MODULE,
637 			.of_parse_cb = buck_set_hw_dvs_levels,
638 		},
639 		.dvs = {
640 			/*
641 			 * LDO3 only supports single voltage for all states.
642 			 * voltage can be individually enabled for each state
643 			 * though => allow setting all states to support
644 			 * enabling power rail on different states.
645 			 */
646 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
647 				     ROHM_DVS_LEVEL_SUSPEND |
648 				     ROHM_DVS_LEVEL_LPSR,
649 			.run_reg = BD71828_REG_LDO3_VOLT,
650 			.run_mask = BD71828_MASK_LDO_VOLT,
651 			.idle_on_mask = BD71828_MASK_IDLE_EN,
652 			.suspend_on_mask = BD71828_MASK_SUSP_EN,
653 			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
654 		},
655 
656 	}, {
657 		.desc = {
658 			.name = "ldo4",
659 			.of_match = of_match_ptr("LDO4"),
660 			.regulators_node = of_match_ptr("regulators"),
661 			.id = BD71828_LDO4,
662 			.ops = &bd71828_ldo_ops,
663 			.type = REGULATOR_VOLTAGE,
664 			.linear_ranges = bd71828_ldo_volts,
665 			.n_linear_ranges = ARRAY_SIZE(bd71828_ldo_volts),
666 			.n_voltages = BD71828_LDO_VOLTS,
667 			.enable_reg = BD71828_REG_LDO4_EN,
668 			.enable_mask = BD71828_MASK_RUN_EN,
669 			.vsel_reg = BD71828_REG_LDO4_VOLT,
670 			.vsel_mask = BD71828_MASK_LDO_VOLT,
671 			.owner = THIS_MODULE,
672 			.of_parse_cb = buck_set_hw_dvs_levels,
673 		},
674 		.dvs = {
675 			/*
676 			 * LDO1 only supports single voltage for all states.
677 			 * voltage can be individually enabled for each state
678 			 * though => allow setting all states to support
679 			 * enabling power rail on different states.
680 			 */
681 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
682 				     ROHM_DVS_LEVEL_SUSPEND |
683 				     ROHM_DVS_LEVEL_LPSR,
684 			.run_reg = BD71828_REG_LDO4_VOLT,
685 			.run_mask = BD71828_MASK_LDO_VOLT,
686 			.idle_on_mask = BD71828_MASK_IDLE_EN,
687 			.suspend_on_mask = BD71828_MASK_SUSP_EN,
688 			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
689 		},
690 	}, {
691 		.desc = {
692 			.name = "ldo5",
693 			.of_match = of_match_ptr("LDO5"),
694 			.regulators_node = of_match_ptr("regulators"),
695 			.id = BD71828_LDO5,
696 			.ops = &bd71828_ldo_ops,
697 			.type = REGULATOR_VOLTAGE,
698 			.linear_ranges = bd71828_ldo_volts,
699 			.n_linear_ranges = ARRAY_SIZE(bd71828_ldo_volts),
700 			.n_voltages = BD71828_LDO_VOLTS,
701 			.enable_reg = BD71828_REG_LDO5_EN,
702 			.enable_mask = BD71828_MASK_RUN_EN,
703 			.vsel_reg = BD71828_REG_LDO5_VOLT,
704 			.vsel_mask = BD71828_MASK_LDO_VOLT,
705 			.of_parse_cb = buck_set_hw_dvs_levels,
706 			.owner = THIS_MODULE,
707 		},
708 		/*
709 		 * LDO5 is special. It can choose vsel settings to be configured
710 		 * from 2 different registers (by GPIO).
711 		 *
712 		 * This driver supports only configuration where
713 		 * BD71828_REG_LDO5_VOLT_L is used.
714 		 */
715 		.dvs = {
716 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
717 				     ROHM_DVS_LEVEL_SUSPEND |
718 				     ROHM_DVS_LEVEL_LPSR,
719 			.run_reg = BD71828_REG_LDO5_VOLT,
720 			.run_mask = BD71828_MASK_LDO_VOLT,
721 			.idle_on_mask = BD71828_MASK_IDLE_EN,
722 			.suspend_on_mask = BD71828_MASK_SUSP_EN,
723 			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
724 		},
725 
726 	}, {
727 		.desc = {
728 			.name = "ldo6",
729 			.of_match = of_match_ptr("LDO6"),
730 			.regulators_node = of_match_ptr("regulators"),
731 			.id = BD71828_LDO6,
732 			.ops = &bd71828_ldo6_ops,
733 			.type = REGULATOR_VOLTAGE,
734 			.fixed_uV = BD71828_LDO_6_VOLTAGE,
735 			.n_voltages = 1,
736 			.enable_reg = BD71828_REG_LDO6_EN,
737 			.enable_mask = BD71828_MASK_RUN_EN,
738 			.owner = THIS_MODULE,
739 			/*
740 			 * LDO6 only supports enable/disable for all states.
741 			 * Voltage for LDO6 is fixed.
742 			 */
743 			.of_parse_cb = bd71828_ldo6_parse_dt,
744 		},
745 	}, {
746 		.desc = {
747 			/* SNVS LDO in data-sheet */
748 			.name = "ldo7",
749 			.of_match = of_match_ptr("LDO7"),
750 			.regulators_node = of_match_ptr("regulators"),
751 			.id = BD71828_LDO_SNVS,
752 			.ops = &bd71828_ldo_ops,
753 			.type = REGULATOR_VOLTAGE,
754 			.linear_ranges = bd71828_ldo_volts,
755 			.n_linear_ranges = ARRAY_SIZE(bd71828_ldo_volts),
756 			.n_voltages = BD71828_LDO_VOLTS,
757 			.enable_reg = BD71828_REG_LDO7_EN,
758 			.enable_mask = BD71828_MASK_RUN_EN,
759 			.vsel_reg = BD71828_REG_LDO7_VOLT,
760 			.vsel_mask = BD71828_MASK_LDO_VOLT,
761 			.owner = THIS_MODULE,
762 			.of_parse_cb = buck_set_hw_dvs_levels,
763 		},
764 		.dvs = {
765 			/*
766 			 * LDO7 only supports single voltage for all states.
767 			 * voltage can be individually enabled for each state
768 			 * though => allow setting all states to support
769 			 * enabling power rail on different states.
770 			 */
771 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
772 				     ROHM_DVS_LEVEL_SUSPEND |
773 				     ROHM_DVS_LEVEL_LPSR,
774 			.run_reg = BD71828_REG_LDO7_VOLT,
775 			.idle_reg = BD71828_REG_LDO7_VOLT,
776 			.suspend_reg = BD71828_REG_LDO7_VOLT,
777 			.lpsr_reg = BD71828_REG_LDO7_VOLT,
778 			.run_mask = BD71828_MASK_LDO_VOLT,
779 			.idle_on_mask = BD71828_MASK_IDLE_EN,
780 			.suspend_on_mask = BD71828_MASK_SUSP_EN,
781 			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
782 		},
783 
784 	},
785 };
786 
787 #define BD72720_BUCK10_DESC_INDEX 9
788 #define BD72720_NUM_BUCK_VOLTS 0x100
789 #define BD72720_NUM_LDO_VOLTS 0x100
790 #define BD72720_NUM_LDO12346_VOLTS 0x80
791 
792 static const struct bd71828_regulator_data bd72720_rdata[] = {
793 	{
794 		.desc = {
795 			.name = "buck1",
796 			.of_match = of_match_ptr("buck1"),
797 			.regulators_node = of_match_ptr("regulators"),
798 			.id = BD72720_BUCK1,
799 			.type = REGULATOR_VOLTAGE,
800 
801 			/*
802 			 * The BD72720 BUCK1 and LDO1 support GPIO toggled
803 			 * sub-RUN states called RUN0, RUN1, RUN2 and RUN3.
804 			 * The "operating mode" (sub-RUN states or normal)
805 			 * can be changed by a register.
806 			 *
807 			 * When the sub-RUN states are used, the voltage and
808 			 * enable state depend on a state specific
809 			 * configuration. The voltage and enable configuration
810 			 * for BUCK1 and LDO1 can be defined for each sub-RUN
811 			 * state using BD72720_REG_[BUCK,LDO]1_VSEL_R[0,1,2,3]
812 			 * voltage selection registers and the bits
813 			 * BD72720_MASK_RUN_[0,1,2,3]_EN in the enable registers.
814 			 * The PMIC will change both the BUCK1 and LDO1 voltages
815 			 * to the states defined in these registers when
816 			 * "DVS GPIOs" are toggled.
817 			 *
818 			 * If RUN 0 .. RUN 4 states are to be used, the normal
819 			 * voltage configuration mechanisms do not apply
820 			 * and we should overwrite the ops and ignore the
821 			 * voltage setting/getting registers which are setup
822 			 * here. This is not supported for now. If you need
823 			 * this functionality, you may try merging functionality
824 			 * from a downstream driver:
825 			 * https://rohmsemiconductor.github.io/Linux-Kernel-PMIC-Drivers/BD72720/
826 			 */
827 			.ops = &bd72720_regulator_ops,
828 			.linear_ranges = bd72720_buck1234_volts,
829 			.n_linear_ranges = ARRAY_SIZE(bd72720_buck1234_volts),
830 			.n_voltages = BD72720_NUM_BUCK_VOLTS,
831 			.enable_reg = BD72720_REG_BUCK1_ON,
832 			.enable_mask = BD72720_MASK_RUN_B_EN,
833 			.vsel_reg = BD72720_REG_BUCK1_VSEL_RB,
834 			.vsel_mask = BD72720_MASK_BUCK_VSEL,
835 
836 			.ramp_delay_table = bd72720_ramp_delay,
837 			.n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay),
838 			.ramp_reg = BD72720_REG_BUCK1_MODE,
839 			.ramp_mask = BD72720_MASK_RAMP_UP_DELAY,
840 			.owner = THIS_MODULE,
841 			.of_parse_cb = buck_set_hw_dvs_levels,
842 		},
843 		.dvs = {
844 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
845 				     ROHM_DVS_LEVEL_SUSPEND |
846 				     ROHM_DVS_LEVEL_LPSR, /* Deep idle in data-sheet */
847 			.run_reg = BD72720_REG_BUCK1_VSEL_RB,
848 			.run_mask = BD72720_MASK_BUCK_VSEL,
849 			.idle_reg = BD72720_REG_BUCK1_VSEL_I,
850 			.idle_mask = BD72720_MASK_BUCK_VSEL,
851 			.idle_on_mask = BD72720_MASK_IDLE_EN,
852 			.suspend_reg = BD72720_REG_BUCK1_VSEL_S,
853 			.suspend_mask = BD72720_MASK_BUCK_VSEL,
854 			.suspend_on_mask = BD72720_MASK_SUSPEND_EN,
855 			.lpsr_reg = BD72720_REG_BUCK1_VSEL_DI,
856 			.lpsr_mask = BD72720_MASK_BUCK_VSEL,
857 			.lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN,
858 		},
859 		.reg_inits = bd72720_buck1_inits,
860 		.reg_init_amnt = ARRAY_SIZE(bd72720_buck1_inits),
861 	}, {
862 		.desc = {
863 			.name = "buck2",
864 			.of_match = of_match_ptr("buck2"),
865 			.regulators_node = of_match_ptr("regulators"),
866 			.id = BD72720_BUCK2,
867 			.type = REGULATOR_VOLTAGE,
868 			.ops = &bd72720_regulator_ops,
869 			.linear_ranges = bd72720_buck1234_volts,
870 			.n_linear_ranges = ARRAY_SIZE(bd72720_buck1234_volts),
871 			.n_voltages = BD72720_NUM_BUCK_VOLTS,
872 			.enable_reg = BD72720_REG_BUCK2_ON,
873 			.enable_mask = BD72720_MASK_RUN_B_EN,
874 			.vsel_reg = BD72720_REG_BUCK2_VSEL_R,
875 			.vsel_mask = BD72720_MASK_BUCK_VSEL,
876 
877 			.ramp_delay_table = bd72720_ramp_delay,
878 			.n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay),
879 			.ramp_reg = BD72720_REG_BUCK2_MODE,
880 			.ramp_mask = BD72720_MASK_RAMP_UP_DELAY,
881 			.owner = THIS_MODULE,
882 			.of_parse_cb = buck_set_hw_dvs_levels,
883 		},
884 		.dvs = {
885 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
886 				     ROHM_DVS_LEVEL_SUSPEND |
887 				     ROHM_DVS_LEVEL_LPSR,
888 			.run_reg = BD72720_REG_BUCK2_VSEL_R,
889 			.run_mask = BD72720_MASK_BUCK_VSEL,
890 			.idle_reg = BD72720_REG_BUCK2_VSEL_I,
891 			.idle_mask = BD72720_MASK_BUCK_VSEL,
892 			.idle_on_mask = BD72720_MASK_IDLE_EN,
893 			.suspend_reg = BD72720_REG_BUCK2_VSEL_S,
894 			.suspend_mask = BD72720_MASK_BUCK_VSEL,
895 			.suspend_on_mask = BD72720_MASK_SUSPEND_EN,
896 			.lpsr_reg = BD72720_REG_BUCK2_VSEL_DI,
897 			.lpsr_mask = BD72720_MASK_BUCK_VSEL,
898 			.lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN,
899 		},
900 	}, {
901 		.desc = {
902 			.name = "buck3",
903 			.of_match = of_match_ptr("buck3"),
904 			.regulators_node = of_match_ptr("regulators"),
905 			.id = BD72720_BUCK3,
906 			.type = REGULATOR_VOLTAGE,
907 			.ops = &bd72720_regulator_ops,
908 			.linear_ranges = bd72720_buck1234_volts,
909 			.n_linear_ranges = ARRAY_SIZE(bd72720_buck1234_volts),
910 			.n_voltages = BD72720_NUM_BUCK_VOLTS,
911 			.enable_reg = BD72720_REG_BUCK3_ON,
912 			.enable_mask = BD72720_MASK_RUN_B_EN,
913 			.vsel_reg = BD72720_REG_BUCK3_VSEL_R,
914 			.vsel_mask = BD72720_MASK_BUCK_VSEL,
915 
916 			.ramp_delay_table = bd72720_ramp_delay,
917 			.n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay),
918 			.ramp_reg = BD72720_REG_BUCK3_MODE,
919 			.ramp_mask = BD72720_MASK_RAMP_UP_DELAY,
920 			.owner = THIS_MODULE,
921 			.of_parse_cb = buck_set_hw_dvs_levels,
922 		},
923 		.dvs = {
924 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
925 				     ROHM_DVS_LEVEL_SUSPEND |
926 				     ROHM_DVS_LEVEL_LPSR,
927 			.run_reg = BD72720_REG_BUCK3_VSEL_R,
928 			.run_mask = BD72720_MASK_BUCK_VSEL,
929 			.idle_reg = BD72720_REG_BUCK3_VSEL_I,
930 			.idle_mask = BD72720_MASK_BUCK_VSEL,
931 			.idle_on_mask = BD72720_MASK_IDLE_EN,
932 			.suspend_reg = BD72720_REG_BUCK3_VSEL_S,
933 			.suspend_mask = BD72720_MASK_BUCK_VSEL,
934 			.suspend_on_mask = BD72720_MASK_SUSPEND_EN,
935 			.lpsr_reg = BD72720_REG_BUCK3_VSEL_DI,
936 			.lpsr_mask = BD72720_MASK_BUCK_VSEL,
937 			.lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN,
938 		},
939 	}, {
940 		.desc = {
941 			.name = "buck4",
942 			.of_match = of_match_ptr("buck4"),
943 			.regulators_node = of_match_ptr("regulators"),
944 			.id = BD72720_BUCK4,
945 			.type = REGULATOR_VOLTAGE,
946 			.ops = &bd72720_regulator_ops,
947 			.linear_ranges = bd72720_buck1234_volts,
948 			.n_linear_ranges = ARRAY_SIZE(bd72720_buck1234_volts),
949 			.n_voltages = BD72720_NUM_BUCK_VOLTS,
950 			.enable_reg = BD72720_REG_BUCK4_ON,
951 			.enable_mask = BD72720_MASK_RUN_B_EN,
952 			.vsel_reg = BD72720_REG_BUCK4_VSEL_R,
953 			.vsel_mask = BD72720_MASK_BUCK_VSEL,
954 
955 			.ramp_delay_table = bd72720_ramp_delay,
956 			.n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay),
957 			.ramp_reg = BD72720_REG_BUCK4_MODE,
958 			.ramp_mask = BD72720_MASK_RAMP_UP_DELAY,
959 			.owner = THIS_MODULE,
960 			.of_parse_cb = buck_set_hw_dvs_levels,
961 		},
962 		.dvs = {
963 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
964 				     ROHM_DVS_LEVEL_SUSPEND |
965 				     ROHM_DVS_LEVEL_LPSR,
966 			.run_reg = BD72720_REG_BUCK4_VSEL_R,
967 			.run_mask = BD72720_MASK_BUCK_VSEL,
968 			.idle_reg = BD72720_REG_BUCK4_VSEL_I,
969 			.idle_mask = BD72720_MASK_BUCK_VSEL,
970 			.idle_on_mask = BD72720_MASK_IDLE_EN,
971 			.suspend_reg = BD72720_REG_BUCK4_VSEL_S,
972 			.suspend_mask = BD72720_MASK_BUCK_VSEL,
973 			.suspend_on_mask = BD72720_MASK_SUSPEND_EN,
974 			.lpsr_reg = BD72720_REG_BUCK4_VSEL_DI,
975 			.lpsr_mask = BD72720_MASK_BUCK_VSEL,
976 			.lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN,
977 		},
978 	}, {
979 		.desc = {
980 			.name = "buck5",
981 			.of_match = of_match_ptr("buck5"),
982 			.regulators_node = of_match_ptr("regulators"),
983 			.id = BD72720_BUCK5,
984 			.type = REGULATOR_VOLTAGE,
985 			.ops = &bd72720_regulator_ops,
986 			.linear_ranges = bd72720_buck589_volts,
987 			.n_linear_ranges = ARRAY_SIZE(bd72720_buck589_volts),
988 			.n_voltages = BD72720_NUM_BUCK_VOLTS,
989 			.enable_reg = BD72720_REG_BUCK5_ON,
990 			.enable_mask = BD72720_MASK_RUN_B_EN,
991 			.vsel_reg = BD72720_REG_BUCK5_VSEL,
992 			.vsel_mask = BD72720_MASK_BUCK_VSEL,
993 
994 			.ramp_delay_table = bd72720_ramp_delay,
995 			.n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay),
996 			.ramp_reg = BD72720_REG_BUCK5_MODE,
997 			.ramp_mask = BD72720_MASK_RAMP_UP_DELAY,
998 			.owner = THIS_MODULE,
999 			.of_parse_cb = buck_set_hw_dvs_levels,
1000 		},
1001 		.dvs = {
1002 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
1003 				     ROHM_DVS_LEVEL_SUSPEND |
1004 				     ROHM_DVS_LEVEL_LPSR,
1005 			.run_reg = BD72720_REG_BUCK5_VSEL,
1006 			.run_mask = BD72720_MASK_BUCK_VSEL,
1007 			.idle_on_mask = BD72720_MASK_IDLE_EN,
1008 			.suspend_on_mask = BD72720_MASK_SUSPEND_EN,
1009 			.lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN,
1010 		},
1011 	}, {
1012 		.desc = {
1013 			.name = "buck6",
1014 			.of_match = of_match_ptr("buck6"),
1015 			.regulators_node = of_match_ptr("regulators"),
1016 			.id = BD72720_BUCK6,
1017 			.type = REGULATOR_VOLTAGE,
1018 			.ops = &bd72720_regulator_ops,
1019 			.linear_ranges = bd72720_buck67_volts,
1020 			.n_linear_ranges = ARRAY_SIZE(bd72720_buck67_volts),
1021 			.n_voltages = BD72720_NUM_BUCK_VOLTS,
1022 			.enable_reg = BD72720_REG_BUCK6_ON,
1023 			.enable_mask = BD72720_MASK_RUN_B_EN,
1024 			.vsel_reg = BD72720_REG_BUCK6_VSEL,
1025 			.vsel_mask = BD72720_MASK_BUCK_VSEL,
1026 
1027 			.ramp_delay_table = bd72720_ramp_delay,
1028 			.n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay),
1029 			.ramp_reg = BD72720_REG_BUCK6_MODE,
1030 			.ramp_mask = BD72720_MASK_RAMP_UP_DELAY,
1031 			.owner = THIS_MODULE,
1032 			.of_parse_cb = buck_set_hw_dvs_levels,
1033 		},
1034 		.dvs = {
1035 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
1036 				     ROHM_DVS_LEVEL_SUSPEND |
1037 				     ROHM_DVS_LEVEL_LPSR,
1038 			.run_reg = BD72720_REG_BUCK6_VSEL,
1039 			.run_mask = BD72720_MASK_BUCK_VSEL,
1040 			.idle_on_mask = BD72720_MASK_IDLE_EN,
1041 			.suspend_on_mask = BD72720_MASK_SUSPEND_EN,
1042 			.lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN,
1043 		},
1044 	}, {
1045 		.desc = {
1046 			.name = "buck7",
1047 			.of_match = of_match_ptr("buck7"),
1048 			.regulators_node = of_match_ptr("regulators"),
1049 			.id = BD72720_BUCK7,
1050 			.type = REGULATOR_VOLTAGE,
1051 			.ops = &bd72720_regulator_ops,
1052 			.linear_ranges = bd72720_buck67_volts,
1053 			.n_linear_ranges = ARRAY_SIZE(bd72720_buck67_volts),
1054 			.n_voltages = BD72720_NUM_BUCK_VOLTS,
1055 			.enable_reg = BD72720_REG_BUCK7_ON,
1056 			.enable_mask = BD72720_MASK_RUN_B_EN,
1057 			.vsel_reg = BD72720_REG_BUCK7_VSEL,
1058 			.vsel_mask = BD72720_MASK_BUCK_VSEL,
1059 
1060 			.ramp_delay_table = bd72720_ramp_delay,
1061 			.n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay),
1062 			.ramp_reg = BD72720_REG_BUCK7_MODE,
1063 			.ramp_mask = BD72720_MASK_RAMP_UP_DELAY,
1064 			.owner = THIS_MODULE,
1065 			.of_parse_cb = buck_set_hw_dvs_levels,
1066 		},
1067 		.dvs = {
1068 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
1069 				     ROHM_DVS_LEVEL_SUSPEND |
1070 				     ROHM_DVS_LEVEL_LPSR,
1071 			.run_reg = BD72720_REG_BUCK7_VSEL,
1072 			.run_mask = BD72720_MASK_BUCK_VSEL,
1073 			.idle_on_mask = BD72720_MASK_IDLE_EN,
1074 			.suspend_on_mask = BD72720_MASK_SUSPEND_EN,
1075 			.lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN,
1076 		},
1077 	}, {
1078 		.desc = {
1079 			.name = "buck8",
1080 			.of_match = of_match_ptr("buck8"),
1081 			.regulators_node = of_match_ptr("regulators"),
1082 			.id = BD72720_BUCK8,
1083 			.type = REGULATOR_VOLTAGE,
1084 			.ops = &bd72720_regulator_ops,
1085 			.linear_ranges = bd72720_buck589_volts,
1086 			.n_linear_ranges = ARRAY_SIZE(bd72720_buck589_volts),
1087 			.n_voltages = BD72720_NUM_BUCK_VOLTS,
1088 			.enable_reg = BD72720_REG_BUCK8_ON,
1089 			.enable_mask = BD72720_MASK_RUN_B_EN,
1090 			.vsel_reg = BD72720_REG_BUCK8_VSEL,
1091 			.vsel_mask = BD72720_MASK_BUCK_VSEL,
1092 
1093 			.ramp_delay_table = bd72720_ramp_delay,
1094 			.n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay),
1095 			.ramp_reg = BD72720_REG_BUCK8_MODE,
1096 			.ramp_mask = BD72720_MASK_RAMP_UP_DELAY,
1097 			.owner = THIS_MODULE,
1098 			.of_parse_cb = buck_set_hw_dvs_levels,
1099 		},
1100 		.dvs = {
1101 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
1102 				     ROHM_DVS_LEVEL_SUSPEND |
1103 				     ROHM_DVS_LEVEL_LPSR,
1104 			.run_reg = BD72720_REG_BUCK8_VSEL,
1105 			.run_mask = BD72720_MASK_BUCK_VSEL,
1106 			.idle_on_mask = BD72720_MASK_IDLE_EN,
1107 			.suspend_on_mask = BD72720_MASK_SUSPEND_EN,
1108 			.lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN,
1109 		},
1110 	}, {
1111 		.desc = {
1112 			.name = "buck9",
1113 			.of_match = of_match_ptr("buck9"),
1114 			.regulators_node = of_match_ptr("regulators"),
1115 			.id = BD72720_BUCK9,
1116 			.type = REGULATOR_VOLTAGE,
1117 			.ops = &bd72720_regulator_ops,
1118 			.linear_ranges = bd72720_buck589_volts,
1119 			.n_linear_ranges = ARRAY_SIZE(bd72720_buck589_volts),
1120 			.n_voltages = BD72720_NUM_BUCK_VOLTS,
1121 			.enable_reg = BD72720_REG_BUCK9_ON,
1122 			.enable_mask = BD72720_MASK_RUN_B_EN,
1123 			.vsel_reg = BD72720_REG_BUCK9_VSEL,
1124 			.vsel_mask = BD72720_MASK_BUCK_VSEL,
1125 
1126 			.ramp_delay_table = bd72720_ramp_delay,
1127 			.n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay),
1128 			.ramp_reg = BD72720_REG_BUCK9_MODE,
1129 			.ramp_mask = BD72720_MASK_RAMP_UP_DELAY,
1130 			.owner = THIS_MODULE,
1131 			.of_parse_cb = buck_set_hw_dvs_levels,
1132 		},
1133 		.dvs = {
1134 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
1135 				     ROHM_DVS_LEVEL_SUSPEND |
1136 				     ROHM_DVS_LEVEL_LPSR,
1137 			.run_reg = BD72720_REG_BUCK9_VSEL,
1138 			.run_mask = BD72720_MASK_BUCK_VSEL,
1139 			.idle_on_mask = BD72720_MASK_IDLE_EN,
1140 			.suspend_on_mask = BD72720_MASK_SUSPEND_EN,
1141 			.lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN,
1142 		},
1143 	}, {
1144 		.desc = {
1145 			.name = "buck10",
1146 			.of_match = of_match_ptr("buck10"),
1147 			.regulators_node = of_match_ptr("regulators"),
1148 			.id = BD72720_BUCK10,
1149 			.type = REGULATOR_VOLTAGE,
1150 			.ops = &bd72720_regulator_ops,
1151 			.linear_ranges = bd72720_buck10_volts,
1152 			.n_linear_ranges = ARRAY_SIZE(bd72720_buck10_volts),
1153 			.n_voltages = BD72720_NUM_BUCK_VOLTS,
1154 			.enable_reg = BD72720_REG_BUCK10_ON,
1155 			.enable_mask = BD72720_MASK_RUN_B_EN,
1156 			.vsel_reg = BD72720_REG_BUCK10_VSEL,
1157 			.vsel_mask = BD72720_MASK_BUCK_VSEL,
1158 
1159 			.ramp_delay_table = bd72720_ramp_delay,
1160 			.n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay),
1161 			.ramp_reg = BD72720_REG_BUCK10_MODE,
1162 			.ramp_mask = BD72720_MASK_RAMP_UP_DELAY,
1163 			.owner = THIS_MODULE,
1164 			.of_parse_cb = buck_set_hw_dvs_levels,
1165 		},
1166 		.dvs = {
1167 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
1168 				     ROHM_DVS_LEVEL_SUSPEND |
1169 				     ROHM_DVS_LEVEL_LPSR,
1170 			.run_reg = BD72720_REG_BUCK10_VSEL,
1171 			.run_mask = BD72720_MASK_BUCK_VSEL,
1172 			.idle_on_mask = BD72720_MASK_IDLE_EN,
1173 			.suspend_on_mask = BD72720_MASK_SUSPEND_EN,
1174 			.lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN,
1175 		},
1176 	}, {
1177 		.desc = {
1178 			.name = "ldo1",
1179 			.of_match = of_match_ptr("ldo1"),
1180 			.regulators_node = of_match_ptr("regulators"),
1181 			.id = BD72720_LDO1,
1182 			.type = REGULATOR_VOLTAGE,
1183 			.ops = &bd72720_regulator_ops,
1184 			.linear_ranges = bd72720_ldo1234_volts,
1185 			.n_linear_ranges = ARRAY_SIZE(bd72720_ldo1234_volts),
1186 			.n_voltages = BD72720_NUM_LDO12346_VOLTS,
1187 			.enable_reg = BD72720_REG_LDO1_ON,
1188 			.enable_mask = BD72720_MASK_RUN_B_EN,
1189 			.vsel_reg = BD72720_REG_LDO1_VSEL_RB,
1190 			.vsel_mask = BD72720_MASK_LDO12346_VSEL,
1191 
1192 			.ramp_delay_table = bd72720_ramp_delay,
1193 			.n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay),
1194 			.ramp_reg = BD72720_REG_LDO1_MODE1,
1195 			.ramp_mask = BD72720_MASK_RAMP_UP_DELAY,
1196 			.owner = THIS_MODULE,
1197 			.of_parse_cb = buck_set_hw_dvs_levels,
1198 		},
1199 		.dvs = {
1200 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
1201 				     ROHM_DVS_LEVEL_SUSPEND |
1202 				     ROHM_DVS_LEVEL_LPSR,
1203 			.run_reg = BD72720_REG_LDO1_VSEL_RB,
1204 			.run_mask = BD72720_MASK_LDO12346_VSEL,
1205 			.idle_reg = BD72720_REG_LDO1_VSEL_I,
1206 			.idle_mask = BD72720_MASK_LDO12346_VSEL,
1207 			.idle_on_mask = BD72720_MASK_IDLE_EN,
1208 			.suspend_reg = BD72720_REG_LDO1_VSEL_S,
1209 			.suspend_mask = BD72720_MASK_LDO12346_VSEL,
1210 			.suspend_on_mask = BD72720_MASK_SUSPEND_EN,
1211 			.lpsr_reg = BD72720_REG_LDO1_VSEL_DI,
1212 			.lpsr_mask = BD72720_MASK_LDO12346_VSEL,
1213 			.lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN,
1214 		},
1215 		.reg_inits = bd72720_ldo1_inits,
1216 		.reg_init_amnt = ARRAY_SIZE(bd72720_ldo1_inits),
1217 	}, {
1218 		.desc = {
1219 			.name = "ldo2",
1220 			.of_match = of_match_ptr("ldo2"),
1221 			.regulators_node = of_match_ptr("regulators"),
1222 			.id = BD72720_LDO2,
1223 			.type = REGULATOR_VOLTAGE,
1224 			.ops = &bd72720_regulator_ops,
1225 			.linear_ranges = bd72720_ldo1234_volts,
1226 			.n_linear_ranges = ARRAY_SIZE(bd72720_ldo1234_volts),
1227 			.n_voltages = BD72720_NUM_LDO12346_VOLTS,
1228 			.enable_reg = BD72720_REG_LDO2_ON,
1229 			.enable_mask = BD72720_MASK_RUN_B_EN,
1230 			.vsel_reg = BD72720_REG_LDO2_VSEL_R,
1231 			.vsel_mask = BD72720_MASK_LDO12346_VSEL,
1232 
1233 			.ramp_delay_table = bd72720_ramp_delay,
1234 			.n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay),
1235 			.ramp_reg = BD72720_REG_LDO2_MODE,
1236 			.ramp_mask = BD72720_MASK_RAMP_UP_DELAY,
1237 			.owner = THIS_MODULE,
1238 			.of_parse_cb = buck_set_hw_dvs_levels,
1239 		},
1240 		.dvs = {
1241 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
1242 				     ROHM_DVS_LEVEL_SUSPEND |
1243 				     ROHM_DVS_LEVEL_LPSR,
1244 			.run_reg = BD72720_REG_LDO2_VSEL_R,
1245 			.run_mask = BD72720_MASK_LDO12346_VSEL,
1246 			.idle_reg = BD72720_REG_LDO2_VSEL_I,
1247 			.idle_mask = BD72720_MASK_LDO12346_VSEL,
1248 			.idle_on_mask = BD72720_MASK_IDLE_EN,
1249 			.suspend_reg = BD72720_REG_LDO2_VSEL_S,
1250 			.suspend_mask = BD72720_MASK_LDO12346_VSEL,
1251 			.suspend_on_mask = BD72720_MASK_SUSPEND_EN,
1252 			.lpsr_reg = BD72720_REG_LDO2_VSEL_DI,
1253 			.lpsr_mask = BD72720_MASK_LDO12346_VSEL,
1254 			.lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN,
1255 		},
1256 	}, {
1257 		.desc = {
1258 			.name = "ldo3",
1259 			.of_match = of_match_ptr("ldo3"),
1260 			.regulators_node = of_match_ptr("regulators"),
1261 			.id = BD72720_LDO3,
1262 			.type = REGULATOR_VOLTAGE,
1263 			.ops = &bd72720_regulator_ops,
1264 			.linear_ranges = bd72720_ldo1234_volts,
1265 			.n_linear_ranges = ARRAY_SIZE(bd72720_ldo1234_volts),
1266 			.n_voltages = BD72720_NUM_LDO12346_VOLTS,
1267 			.enable_reg = BD72720_REG_LDO3_ON,
1268 			.enable_mask = BD72720_MASK_RUN_B_EN,
1269 			.vsel_reg = BD72720_REG_LDO3_VSEL_R,
1270 			.vsel_mask = BD72720_MASK_LDO12346_VSEL,
1271 
1272 			.ramp_delay_table = bd72720_ramp_delay,
1273 			.n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay),
1274 			.ramp_reg = BD72720_REG_LDO3_MODE,
1275 			.ramp_mask = BD72720_MASK_RAMP_UP_DELAY,
1276 			.owner = THIS_MODULE,
1277 			.of_parse_cb = buck_set_hw_dvs_levels,
1278 		},
1279 		.dvs = {
1280 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
1281 				     ROHM_DVS_LEVEL_SUSPEND |
1282 				     ROHM_DVS_LEVEL_LPSR,
1283 			.run_reg = BD72720_REG_LDO3_VSEL_R,
1284 			.run_mask = BD72720_MASK_LDO12346_VSEL,
1285 			.idle_reg = BD72720_REG_LDO3_VSEL_I,
1286 			.idle_mask = BD72720_MASK_LDO12346_VSEL,
1287 			.idle_on_mask = BD72720_MASK_IDLE_EN,
1288 			.suspend_reg = BD72720_REG_LDO3_VSEL_S,
1289 			.suspend_mask = BD72720_MASK_LDO12346_VSEL,
1290 			.suspend_on_mask = BD72720_MASK_SUSPEND_EN,
1291 			.lpsr_reg = BD72720_REG_LDO3_VSEL_DI,
1292 			.lpsr_mask = BD72720_MASK_LDO12346_VSEL,
1293 			.lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN,
1294 		},
1295 	}, {
1296 		.desc = {
1297 			.name = "ldo4",
1298 			.of_match = of_match_ptr("ldo4"),
1299 			.regulators_node = of_match_ptr("regulators"),
1300 			.id = BD72720_LDO4,
1301 			.type = REGULATOR_VOLTAGE,
1302 			.ops = &bd72720_regulator_ops,
1303 			.linear_ranges = bd72720_ldo1234_volts,
1304 			.n_linear_ranges = ARRAY_SIZE(bd72720_ldo1234_volts),
1305 			.n_voltages = BD72720_NUM_LDO12346_VOLTS,
1306 			.enable_reg = BD72720_REG_LDO4_ON,
1307 			.enable_mask = BD72720_MASK_RUN_B_EN,
1308 			.vsel_reg = BD72720_REG_LDO4_VSEL_R,
1309 			.vsel_mask = BD72720_MASK_LDO12346_VSEL,
1310 
1311 			.ramp_delay_table = bd72720_ramp_delay,
1312 			.n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay),
1313 			.ramp_reg = BD72720_REG_LDO4_MODE,
1314 			.ramp_mask = BD72720_MASK_RAMP_UP_DELAY,
1315 			.owner = THIS_MODULE,
1316 			.of_parse_cb = buck_set_hw_dvs_levels,
1317 		},
1318 		.dvs = {
1319 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
1320 				     ROHM_DVS_LEVEL_SUSPEND |
1321 				     ROHM_DVS_LEVEL_LPSR,
1322 			.run_reg = BD72720_REG_LDO4_VSEL_R,
1323 			.run_mask = BD72720_MASK_LDO12346_VSEL,
1324 			.idle_reg = BD72720_REG_LDO4_VSEL_I,
1325 			.idle_mask = BD72720_MASK_LDO12346_VSEL,
1326 			.idle_on_mask = BD72720_MASK_IDLE_EN,
1327 			.suspend_reg = BD72720_REG_LDO4_VSEL_S,
1328 			.suspend_mask = BD72720_MASK_LDO12346_VSEL,
1329 			.suspend_on_mask = BD72720_MASK_SUSPEND_EN,
1330 			.lpsr_reg = BD72720_REG_LDO4_VSEL_DI,
1331 			.lpsr_mask = BD72720_MASK_LDO12346_VSEL,
1332 			.lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN,
1333 		},
1334 	}, {
1335 		.desc = {
1336 			.name = "ldo5",
1337 			.of_match = of_match_ptr("ldo5"),
1338 			.regulators_node = of_match_ptr("regulators"),
1339 			.id = BD72720_LDO5,
1340 			.type = REGULATOR_VOLTAGE,
1341 			.ops = &bd72720_regulator_ops,
1342 			.linear_ranges = bd72720_ldo57891011_volts,
1343 			.n_linear_ranges = ARRAY_SIZE(bd72720_ldo57891011_volts),
1344 			.n_voltages = BD72720_NUM_LDO_VOLTS,
1345 			.enable_reg = BD72720_REG_LDO5_ON,
1346 			.enable_mask = BD72720_MASK_RUN_B_EN,
1347 			.vsel_reg = BD72720_REG_LDO5_VSEL,
1348 			.vsel_mask = BD72720_MASK_LDO_VSEL,
1349 
1350 			.ramp_delay_table = bd72720_ramp_delay,
1351 			.n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay),
1352 			.ramp_reg = BD72720_REG_LDO5_MODE,
1353 			.ramp_mask = BD72720_MASK_RAMP_UP_DELAY,
1354 			.owner = THIS_MODULE,
1355 			.of_parse_cb = buck_set_hw_dvs_levels,
1356 		},
1357 		.dvs = {
1358 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
1359 				     ROHM_DVS_LEVEL_SUSPEND |
1360 				     ROHM_DVS_LEVEL_LPSR,
1361 			.run_reg = BD72720_REG_LDO5_VSEL,
1362 			.run_mask = BD72720_MASK_LDO_VSEL,
1363 			.idle_on_mask = BD72720_MASK_IDLE_EN,
1364 			.suspend_on_mask = BD72720_MASK_SUSPEND_EN,
1365 			.lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN,
1366 		},
1367 	}, {
1368 		.desc = {
1369 			.name = "ldo6",
1370 			.of_match = of_match_ptr("ldo6"),
1371 			.regulators_node = of_match_ptr("regulators"),
1372 			.id = BD72720_LDO6,
1373 			.type = REGULATOR_VOLTAGE,
1374 			.ops = &bd72720_regulator_ops,
1375 			.linear_ranges = bd72720_ldo6_volts,
1376 			.n_linear_ranges = ARRAY_SIZE(bd72720_ldo6_volts),
1377 			.n_voltages = BD72720_NUM_LDO12346_VOLTS,
1378 			.enable_reg = BD72720_REG_LDO6_ON,
1379 			.enable_mask = BD72720_MASK_RUN_B_EN,
1380 			.vsel_reg = BD72720_REG_LDO6_VSEL,
1381 			.vsel_mask = BD72720_MASK_LDO12346_VSEL,
1382 
1383 			.ramp_delay_table = bd72720_ramp_delay,
1384 			.n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay),
1385 			.ramp_reg = BD72720_REG_LDO6_MODE,
1386 			.ramp_mask = BD72720_MASK_RAMP_UP_DELAY,
1387 			.owner = THIS_MODULE,
1388 			.of_parse_cb = buck_set_hw_dvs_levels,
1389 		},
1390 		.dvs = {
1391 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
1392 				     ROHM_DVS_LEVEL_SUSPEND |
1393 				     ROHM_DVS_LEVEL_LPSR,
1394 			.run_reg = BD72720_REG_LDO6_VSEL,
1395 			.run_mask = BD72720_MASK_LDO12346_VSEL,
1396 			.idle_on_mask = BD72720_MASK_IDLE_EN,
1397 			.suspend_on_mask = BD72720_MASK_SUSPEND_EN,
1398 			.lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN,
1399 		},
1400 	}, {
1401 		.desc = {
1402 			.name = "ldo7",
1403 			.of_match = of_match_ptr("ldo7"),
1404 			.regulators_node = of_match_ptr("regulators"),
1405 			.id = BD72720_LDO7,
1406 			.type = REGULATOR_VOLTAGE,
1407 			.ops = &bd72720_regulator_ops,
1408 			.linear_ranges = bd72720_ldo57891011_volts,
1409 			.n_linear_ranges = ARRAY_SIZE(bd72720_ldo57891011_volts),
1410 			.n_voltages = BD72720_NUM_LDO_VOLTS,
1411 			.enable_reg = BD72720_REG_LDO7_ON,
1412 			.enable_mask = BD72720_MASK_RUN_B_EN,
1413 			.vsel_reg = BD72720_REG_LDO7_VSEL,
1414 			.vsel_mask = BD72720_MASK_LDO_VSEL,
1415 
1416 			.ramp_delay_table = bd72720_ramp_delay,
1417 			.n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay),
1418 			.ramp_reg = BD72720_REG_LDO7_MODE,
1419 			.ramp_mask = BD72720_MASK_RAMP_UP_DELAY,
1420 			.owner = THIS_MODULE,
1421 			.of_parse_cb = buck_set_hw_dvs_levels,
1422 		},
1423 		.dvs = {
1424 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
1425 				     ROHM_DVS_LEVEL_SUSPEND |
1426 				     ROHM_DVS_LEVEL_LPSR,
1427 			.run_reg = BD72720_REG_LDO7_VSEL,
1428 			.run_mask = BD72720_MASK_LDO_VSEL,
1429 			.idle_on_mask = BD72720_MASK_IDLE_EN,
1430 			.suspend_on_mask = BD72720_MASK_SUSPEND_EN,
1431 			.lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN,
1432 		},
1433 	}, {
1434 		.desc = {
1435 			.name = "ldo8",
1436 			.of_match = of_match_ptr("ldo8"),
1437 			.regulators_node = of_match_ptr("regulators"),
1438 			.id = BD72720_LDO8,
1439 			.type = REGULATOR_VOLTAGE,
1440 			.ops = &bd72720_regulator_ops,
1441 			.linear_ranges = bd72720_ldo57891011_volts,
1442 			.n_linear_ranges = ARRAY_SIZE(bd72720_ldo57891011_volts),
1443 			.n_voltages = BD72720_NUM_LDO_VOLTS,
1444 			.enable_reg = BD72720_REG_LDO8_ON,
1445 			.enable_mask = BD72720_MASK_RUN_B_EN,
1446 			.vsel_reg = BD72720_REG_LDO8_VSEL,
1447 			.vsel_mask = BD72720_MASK_LDO_VSEL,
1448 
1449 			.ramp_delay_table = bd72720_ramp_delay,
1450 			.n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay),
1451 			.ramp_reg = BD72720_REG_LDO8_MODE,
1452 			.ramp_mask = BD72720_MASK_RAMP_UP_DELAY,
1453 			.owner = THIS_MODULE,
1454 			.of_parse_cb = buck_set_hw_dvs_levels,
1455 		},
1456 		.dvs = {
1457 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
1458 				     ROHM_DVS_LEVEL_SUSPEND |
1459 				     ROHM_DVS_LEVEL_LPSR,
1460 			.run_reg = BD72720_REG_LDO8_VSEL,
1461 			.run_mask = BD72720_MASK_LDO_VSEL,
1462 			.idle_on_mask = BD72720_MASK_IDLE_EN,
1463 			.suspend_on_mask = BD72720_MASK_SUSPEND_EN,
1464 			.lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN,
1465 		},
1466 	}, {
1467 		.desc = {
1468 			.name = "ldo9",
1469 			.of_match = of_match_ptr("ldo9"),
1470 			.regulators_node = of_match_ptr("regulators"),
1471 			.id = BD72720_LDO9,
1472 			.type = REGULATOR_VOLTAGE,
1473 			.ops = &bd72720_regulator_ops,
1474 			.linear_ranges = bd72720_ldo57891011_volts,
1475 			.n_linear_ranges = ARRAY_SIZE(bd72720_ldo57891011_volts),
1476 			.n_voltages = BD72720_NUM_LDO_VOLTS,
1477 			.enable_reg = BD72720_REG_LDO9_ON,
1478 			.enable_mask = BD72720_MASK_RUN_B_EN,
1479 			.vsel_reg = BD72720_REG_LDO9_VSEL,
1480 			.vsel_mask = BD72720_MASK_LDO_VSEL,
1481 
1482 			.ramp_delay_table = bd72720_ramp_delay,
1483 			.n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay),
1484 			.ramp_reg = BD72720_REG_LDO9_MODE,
1485 			.ramp_mask = BD72720_MASK_RAMP_UP_DELAY,
1486 			.owner = THIS_MODULE,
1487 			.of_parse_cb = buck_set_hw_dvs_levels,
1488 		},
1489 		.dvs = {
1490 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
1491 				     ROHM_DVS_LEVEL_SUSPEND |
1492 				     ROHM_DVS_LEVEL_LPSR,
1493 			.run_reg = BD72720_REG_LDO9_VSEL,
1494 			.run_mask = BD72720_MASK_LDO_VSEL,
1495 			.idle_on_mask = BD72720_MASK_IDLE_EN,
1496 			.suspend_on_mask = BD72720_MASK_SUSPEND_EN,
1497 			.lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN,
1498 		},
1499 	}, {
1500 		.desc = {
1501 			.name = "ldo10",
1502 			.of_match = of_match_ptr("ldo10"),
1503 			.regulators_node = of_match_ptr("regulators"),
1504 			.id = BD72720_LDO10,
1505 			.type = REGULATOR_VOLTAGE,
1506 			.ops = &bd72720_regulator_ops,
1507 			.linear_ranges = bd72720_ldo57891011_volts,
1508 			.n_linear_ranges = ARRAY_SIZE(bd72720_ldo57891011_volts),
1509 			.n_voltages = BD72720_NUM_LDO_VOLTS,
1510 			.enable_reg = BD72720_REG_LDO10_ON,
1511 			.enable_mask = BD72720_MASK_RUN_B_EN,
1512 			.vsel_reg = BD72720_REG_LDO10_VSEL,
1513 			.vsel_mask = BD72720_MASK_LDO_VSEL,
1514 
1515 			.ramp_delay_table = bd72720_ramp_delay,
1516 			.n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay),
1517 			.ramp_reg = BD72720_REG_LDO10_MODE,
1518 			.ramp_mask = BD72720_MASK_RAMP_UP_DELAY,
1519 			.owner = THIS_MODULE,
1520 			.of_parse_cb = buck_set_hw_dvs_levels,
1521 		},
1522 		.dvs = {
1523 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
1524 				     ROHM_DVS_LEVEL_SUSPEND |
1525 				     ROHM_DVS_LEVEL_LPSR,
1526 			.run_reg = BD72720_REG_LDO10_VSEL,
1527 			.run_mask = BD72720_MASK_LDO_VSEL,
1528 			.idle_on_mask = BD72720_MASK_IDLE_EN,
1529 			.suspend_on_mask = BD72720_MASK_SUSPEND_EN,
1530 			.lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN,
1531 		},
1532 	}, {
1533 		.desc = {
1534 			.name = "ldo11",
1535 			.of_match = of_match_ptr("ldo11"),
1536 			.regulators_node = of_match_ptr("regulators"),
1537 			.id = BD72720_LDO11,
1538 			.type = REGULATOR_VOLTAGE,
1539 			.ops = &bd72720_regulator_ops,
1540 			.linear_ranges = bd72720_ldo57891011_volts,
1541 			.n_linear_ranges = ARRAY_SIZE(bd72720_ldo57891011_volts),
1542 			.n_voltages = BD72720_NUM_LDO_VOLTS,
1543 			.enable_reg = BD72720_REG_LDO11_ON,
1544 			.enable_mask = BD72720_MASK_RUN_B_EN,
1545 			.vsel_reg = BD72720_REG_LDO11_VSEL,
1546 			.vsel_mask = BD72720_MASK_LDO_VSEL,
1547 
1548 			.ramp_delay_table = bd72720_ramp_delay,
1549 			.n_ramp_values = ARRAY_SIZE(bd72720_ramp_delay),
1550 			.ramp_reg = BD72720_REG_LDO11_MODE,
1551 			.ramp_mask = BD72720_MASK_RAMP_UP_DELAY,
1552 			.owner = THIS_MODULE,
1553 			.of_parse_cb = buck_set_hw_dvs_levels,
1554 		},
1555 		.dvs = {
1556 			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
1557 				     ROHM_DVS_LEVEL_SUSPEND |
1558 				     ROHM_DVS_LEVEL_LPSR,
1559 			.run_reg = BD72720_REG_LDO11_VSEL,
1560 			.run_mask = BD72720_MASK_LDO_VSEL,
1561 			.idle_on_mask = BD72720_MASK_IDLE_EN,
1562 			.suspend_on_mask = BD72720_MASK_SUSPEND_EN,
1563 			.lpsr_on_mask = BD72720_MASK_DEEP_IDLE_EN,
1564 		},
1565 	},
1566 };
1567 
1568 static int bd72720_buck10_ldon_head_mode(struct device *dev,
1569 					 struct device_node *npreg,
1570 					 struct regmap *regmap,
1571 					 struct regulator_desc *buck10_desc)
1572 {
1573 	struct device_node *np __free(device_node) =
1574 		of_get_child_by_name(npreg, "buck10");
1575 	uint32_t ldon_head;
1576 	int ldon_val;
1577 	int ret;
1578 
1579 	if (!np) {
1580 		dev_err(dev, "failed to find buck10 regulator node\n");
1581 		return -ENODEV;
1582 	}
1583 
1584 	ret = of_property_read_u32(np, "rohm,ldon-head-microvolt", &ldon_head);
1585 	if (ret == -EINVAL)
1586 		return 0;
1587 	if (ret)
1588 		return ret;
1589 
1590 	/*
1591 	 * LDON_HEAD mode means the BUCK10 is used to supply LDOs 1-4 and
1592 	 * the BUCK 10 voltage is automatically set to follow LDO 1-4
1593 	 * settings. Thus the BUCK10 should not allow voltage [g/s]etting.
1594 	 */
1595 	buck10_desc->ops = &bd72720_buck10_ldon_head_op;
1596 
1597 	ldon_val = ldon_head / 50000 + 1;
1598 	if (ldon_head > 300000) {
1599 		dev_warn(dev, "Unsupported LDON_HEAD, clamping to 300 mV\n");
1600 		ldon_val = 7;
1601 	}
1602 
1603 	return regmap_update_bits(regmap, BD72720_REG_LDO1_MODE2,
1604 				  BD72720_MASK_LDON_HEAD, ldon_val);
1605 }
1606 
1607 static int bd72720_dt_parse(struct device *dev,
1608 			    struct regulator_desc *buck10_desc,
1609 			    struct regmap *regmap)
1610 {
1611 	struct device_node *nproot __free(device_node) =
1612 		of_get_child_by_name(dev->parent->of_node, "regulators");
1613 
1614 	if (!nproot) {
1615 		dev_err(dev, "failed to find regulators node\n");
1616 		return -ENODEV;
1617 	}
1618 
1619 	return bd72720_buck10_ldon_head_mode(dev, nproot, regmap, buck10_desc);
1620 }
1621 
1622 static int bd71828_probe(struct platform_device *pdev)
1623 {
1624 	int i, j, ret, num_regulators;
1625 	struct regulator_config config = {
1626 		.dev = pdev->dev.parent,
1627 	};
1628 	enum rohm_chip_type chip = platform_get_device_id(pdev)->driver_data;
1629 	struct bd71828_regulator_data *rdata;
1630 
1631 	config.regmap = dev_get_regmap(pdev->dev.parent, NULL);
1632 	if (!config.regmap)
1633 		return -ENODEV;
1634 
1635 	switch (chip) {
1636 	case ROHM_CHIP_TYPE_BD72720:
1637 		rdata = devm_kmemdup(&pdev->dev, bd72720_rdata,
1638 				     sizeof(bd72720_rdata), GFP_KERNEL);
1639 		if (!rdata)
1640 			return -ENOMEM;
1641 
1642 		ret = bd72720_dt_parse(&pdev->dev, &rdata[BD72720_BUCK10_DESC_INDEX].desc,
1643 				       config.regmap);
1644 		if (ret)
1645 			return ret;
1646 
1647 		num_regulators = ARRAY_SIZE(bd72720_rdata);
1648 		break;
1649 
1650 	case ROHM_CHIP_TYPE_BD71828:
1651 		rdata = devm_kmemdup(&pdev->dev, bd71828_rdata,
1652 				     sizeof(bd71828_rdata), GFP_KERNEL);
1653 		if (!rdata)
1654 			return -ENOMEM;
1655 
1656 		num_regulators = ARRAY_SIZE(bd71828_rdata);
1657 
1658 		break;
1659 	default:
1660 		return dev_err_probe(&pdev->dev, -EINVAL,
1661 				     "Unsupported device\n");
1662 	}
1663 
1664 	for (i = 0; i < num_regulators; i++) {
1665 		struct regulator_dev *rdev;
1666 		struct bd71828_regulator_data *rd;
1667 
1668 		rd = &rdata[i];
1669 
1670 		config.driver_data = rd;
1671 		rdev = devm_regulator_register(&pdev->dev,
1672 					       &rd->desc, &config);
1673 		if (IS_ERR(rdev))
1674 			return dev_err_probe(&pdev->dev, PTR_ERR(rdev),
1675 					     "failed to register %s regulator\n",
1676 					     rd->desc.name);
1677 
1678 		for (j = 0; j < rd->reg_init_amnt; j++) {
1679 			ret = regmap_update_bits(config.regmap,
1680 						 rd->reg_inits[j].reg,
1681 						 rd->reg_inits[j].mask,
1682 						 rd->reg_inits[j].val);
1683 			if (ret)
1684 				return dev_err_probe(&pdev->dev, ret,
1685 						     "regulator %s init failed\n",
1686 						     rd->desc.name);
1687 		}
1688 	}
1689 	return 0;
1690 }
1691 
1692 static const struct platform_device_id bd71828_pmic_id[] = {
1693 	{ .name = "bd71828-pmic", .driver_data = ROHM_CHIP_TYPE_BD71828 },
1694 	{ .name = "bd72720-pmic", .driver_data = ROHM_CHIP_TYPE_BD72720 },
1695 	{ }
1696 };
1697 MODULE_DEVICE_TABLE(platform, bd71828_pmic_id);
1698 
1699 static struct platform_driver bd71828_regulator = {
1700 	.driver = {
1701 		.name = "bd71828-pmic",
1702 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
1703 	},
1704 	.probe = bd71828_probe,
1705 	.id_table = bd71828_pmic_id,
1706 };
1707 
1708 module_platform_driver(bd71828_regulator);
1709 
1710 MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>");
1711 MODULE_DESCRIPTION("BD71828 voltage regulator driver");
1712 MODULE_LICENSE("GPL");
1713