1 // SPDX-License-Identifier: GPL-2.0-only
3 * Regulator driver for Rockchip RK80x and RK81x PMIC series
5 * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
6 * Copyright (c) 2021 Rockchip Electronics Co., Ltd.
8 * Author: Chris Zhong <zyw@rock-chips.com>
9 * Author: Zhang Qing <zhangqing@rock-chips.com>
10 * Author: Xu Shengfei <xsf@rock-chips.com>
12 * Copyright (C) 2016 PHYTEC Messtechnik GmbH
14 * Author: Wadim Egorov <w.egorov@phytec.de>
17 #include <linux/delay.h>
18 #include <linux/module.h>
20 #include <linux/mfd/rk808.h>
21 #include <linux/platform_device.h>
22 #include <linux/regulator/driver.h>
23 #include <linux/regulator/of_regulator.h>
24 #include <linux/gpio/consumer.h>
26 /* Field definitions */
27 #define RK808_BUCK_VSEL_MASK 0x3f
28 #define RK808_BUCK4_VSEL_MASK 0xf
29 #define RK808_LDO_VSEL_MASK 0x1f
31 #define RK809_BUCK5_VSEL_MASK 0x7
33 #define RK817_LDO_VSEL_MASK 0x7f
34 #define RK817_BOOST_VSEL_MASK 0x7
35 #define RK817_BUCK_VSEL_MASK 0x7f
37 #define RK818_BUCK_VSEL_MASK 0x3f
38 #define RK818_BUCK4_VSEL_MASK 0x1f
39 #define RK818_LDO_VSEL_MASK 0x1f
40 #define RK818_LDO3_ON_VSEL_MASK 0xf
41 #define RK818_BOOST_ON_VSEL_MASK 0xe0
43 #define RK806_DCDC_SLP_REG_OFFSET 0x0A
44 #define RK806_NLDO_SLP_REG_OFFSET 0x05
45 #define RK806_PLDO_SLP_REG_OFFSET 0x06
47 #define RK806_BUCK_SEL_CNT 0xff
48 #define RK806_LDO_SEL_CNT 0xff
50 /* Ramp rate definitions for buck1 / buck2 only */
51 #define RK808_RAMP_RATE_OFFSET 3
52 #define RK808_RAMP_RATE_MASK (3 << RK808_RAMP_RATE_OFFSET)
53 #define RK808_RAMP_RATE_2MV_PER_US (0 << RK808_RAMP_RATE_OFFSET)
54 #define RK808_RAMP_RATE_4MV_PER_US (1 << RK808_RAMP_RATE_OFFSET)
55 #define RK808_RAMP_RATE_6MV_PER_US (2 << RK808_RAMP_RATE_OFFSET)
56 #define RK808_RAMP_RATE_10MV_PER_US (3 << RK808_RAMP_RATE_OFFSET)
58 #define RK808_DVS2_POL BIT(2)
59 #define RK808_DVS1_POL BIT(1)
61 /* Offset from XXX_ON_VSEL to XXX_SLP_VSEL */
62 #define RK808_SLP_REG_OFFSET 1
64 /* Offset from XXX_ON_VSEL to XXX_DVS_VSEL */
65 #define RK808_DVS_REG_OFFSET 2
67 /* Offset from XXX_EN_REG to SLEEP_SET_OFF_XXX */
68 #define RK808_SLP_SET_OFF_REG_OFFSET 2
70 /* max steps for increase voltage of Buck1/2, equal 100mv*/
71 #define MAX_STEPS_ONE_TIME 8
73 #define ENABLE_MASK(id) (BIT(id) | BIT(4 + (id)))
74 #define DISABLE_VAL(id) (BIT(4 + (id)))
76 #define RK817_BOOST_DESC(_id, _match, _supply, _min, _max, _step, _vreg,\
77 _vmask, _ereg, _emask, _enval, _disval, _etime, m_drop) \
80 .supply_name = (_supply), \
81 .of_match = of_match_ptr(_match), \
82 .regulators_node = of_match_ptr("regulators"), \
83 .type = REGULATOR_VOLTAGE, \
85 .n_voltages = (((_max) - (_min)) / (_step) + 1), \
86 .owner = THIS_MODULE, \
87 .min_uV = (_min) * 1000, \
88 .uV_step = (_step) * 1000, \
89 .vsel_reg = (_vreg), \
90 .vsel_mask = (_vmask), \
91 .enable_reg = (_ereg), \
92 .enable_mask = (_emask), \
93 .enable_val = (_enval), \
94 .disable_val = (_disval), \
95 .enable_time = (_etime), \
96 .min_dropout_uV = (m_drop) * 1000, \
97 .ops = &rk817_boost_ops, \
100 #define RK8XX_DESC_COM(_id, _match, _supply, _min, _max, _step, _vreg, \
101 _vmask, _ereg, _emask, _enval, _disval, _etime, _ops) \
104 .supply_name = (_supply), \
105 .of_match = of_match_ptr(_match), \
106 .regulators_node = of_match_ptr("regulators"), \
107 .type = REGULATOR_VOLTAGE, \
109 .n_voltages = (((_max) - (_min)) / (_step) + 1), \
110 .owner = THIS_MODULE, \
111 .min_uV = (_min) * 1000, \
112 .uV_step = (_step) * 1000, \
113 .vsel_reg = (_vreg), \
114 .vsel_mask = (_vmask), \
115 .enable_reg = (_ereg), \
116 .enable_mask = (_emask), \
117 .enable_val = (_enval), \
118 .disable_val = (_disval), \
119 .enable_time = (_etime), \
123 #define RK805_DESC(_id, _match, _supply, _min, _max, _step, _vreg, \
124 _vmask, _ereg, _emask, _etime) \
125 RK8XX_DESC_COM(_id, _match, _supply, _min, _max, _step, _vreg, \
126 _vmask, _ereg, _emask, 0, 0, _etime, &rk805_reg_ops)
128 #define RK806_REGULATOR(_name, _supply_name, _id, _ops,\
129 _n_voltages, _vr, _er, _lr, ctrl_bit,\
133 .supply_name = _supply_name,\
134 .of_match = of_match_ptr(_name),\
135 .regulators_node = of_match_ptr("regulators"),\
138 .type = REGULATOR_VOLTAGE,\
139 .n_voltages = _n_voltages,\
140 .linear_ranges = _lr,\
141 .n_linear_ranges = ARRAY_SIZE(_lr),\
145 .enable_mask = ENABLE_MASK(ctrl_bit),\
146 .enable_val = ENABLE_MASK(ctrl_bit),\
147 .disable_val = DISABLE_VAL(ctrl_bit),\
148 .of_map_mode = rk8xx_regulator_of_map_mode,\
151 .ramp_delay_table = _rt, \
152 .n_ramp_values = ARRAY_SIZE(_rt), \
153 .owner = THIS_MODULE,\
156 #define RK8XX_DESC(_id, _match, _supply, _min, _max, _step, _vreg, \
157 _vmask, _ereg, _emask, _etime) \
158 RK8XX_DESC_COM(_id, _match, _supply, _min, _max, _step, _vreg, \
159 _vmask, _ereg, _emask, 0, 0, _etime, &rk808_reg_ops)
161 #define RK816_DESC(_id, _match, _supply, _min, _max, _step, _vreg, \
162 _vmask, _ereg, _emask, _disval, _etime) \
163 RK8XX_DESC_COM(_id, _match, _supply, _min, _max, _step, _vreg, \
164 _vmask, _ereg, _emask, _emask, _disval, _etime, &rk816_reg_ops)
166 #define RK817_DESC(_id, _match, _supply, _min, _max, _step, _vreg, \
167 _vmask, _ereg, _emask, _disval, _etime) \
168 RK8XX_DESC_COM(_id, _match, _supply, _min, _max, _step, _vreg, \
169 _vmask, _ereg, _emask, _emask, _disval, _etime, &rk817_reg_ops)
171 #define RKXX_DESC_SWITCH_COM(_id, _match, _supply, _ereg, _emask, \
172 _enval, _disval, _ops) \
175 .supply_name = (_supply), \
176 .of_match = of_match_ptr(_match), \
177 .regulators_node = of_match_ptr("regulators"), \
178 .type = REGULATOR_VOLTAGE, \
180 .enable_reg = (_ereg), \
181 .enable_mask = (_emask), \
182 .enable_val = (_enval), \
183 .disable_val = (_disval), \
184 .owner = THIS_MODULE, \
188 #define RK817_DESC_SWITCH(_id, _match, _supply, _ereg, _emask, \
190 RKXX_DESC_SWITCH_COM(_id, _match, _supply, _ereg, _emask, \
191 _emask, _disval, &rk817_switch_ops)
193 #define RK8XX_DESC_SWITCH(_id, _match, _supply, _ereg, _emask) \
194 RKXX_DESC_SWITCH_COM(_id, _match, _supply, _ereg, _emask, \
195 0, 0, &rk808_switch_ops)
197 struct rk8xx_register_bit
{
202 #define RK8XX_REG_BIT(_reg, _bit) \
208 struct rk808_regulator_data
{
209 struct gpio_desc
*dvs_gpio
[2];
212 static const struct linear_range rk808_ldo3_voltage_ranges
[] = {
213 REGULATOR_LINEAR_RANGE(800000, 0, 13, 100000),
214 REGULATOR_LINEAR_RANGE(2500000, 15, 15, 0),
217 #define RK809_BUCK5_SEL_CNT (8)
219 static const struct linear_range rk809_buck5_voltage_ranges
[] = {
220 REGULATOR_LINEAR_RANGE(1500000, 0, 0, 0),
221 REGULATOR_LINEAR_RANGE(1800000, 1, 3, 200000),
222 REGULATOR_LINEAR_RANGE(2800000, 4, 5, 200000),
223 REGULATOR_LINEAR_RANGE(3300000, 6, 7, 300000),
226 #define RK817_BUCK1_MIN0 500000
227 #define RK817_BUCK1_MAX0 1500000
229 #define RK817_BUCK1_MIN1 1600000
230 #define RK817_BUCK1_MAX1 2400000
232 #define RK817_BUCK3_MAX1 3400000
234 #define RK817_BUCK1_STP0 12500
235 #define RK817_BUCK1_STP1 100000
237 #define RK817_BUCK1_SEL0 ((RK817_BUCK1_MAX0 - RK817_BUCK1_MIN0) /\
239 #define RK817_BUCK1_SEL1 ((RK817_BUCK1_MAX1 - RK817_BUCK1_MIN1) /\
242 #define RK817_BUCK3_SEL1 ((RK817_BUCK3_MAX1 - RK817_BUCK1_MIN1) /\
245 #define RK817_BUCK1_SEL_CNT (RK817_BUCK1_SEL0 + RK817_BUCK1_SEL1 + 1)
246 #define RK817_BUCK3_SEL_CNT (RK817_BUCK1_SEL0 + RK817_BUCK3_SEL1 + 1)
248 static const struct linear_range rk817_buck1_voltage_ranges
[] = {
249 REGULATOR_LINEAR_RANGE(RK817_BUCK1_MIN0
, 0,
250 RK817_BUCK1_SEL0
, RK817_BUCK1_STP0
),
251 REGULATOR_LINEAR_RANGE(RK817_BUCK1_MIN1
, RK817_BUCK1_SEL0
+ 1,
252 RK817_BUCK1_SEL_CNT
, RK817_BUCK1_STP1
),
255 static const struct linear_range rk817_buck3_voltage_ranges
[] = {
256 REGULATOR_LINEAR_RANGE(RK817_BUCK1_MIN0
, 0,
257 RK817_BUCK1_SEL0
, RK817_BUCK1_STP0
),
258 REGULATOR_LINEAR_RANGE(RK817_BUCK1_MIN1
, RK817_BUCK1_SEL0
+ 1,
259 RK817_BUCK3_SEL_CNT
, RK817_BUCK1_STP1
),
262 static const unsigned int rk808_buck1_2_ramp_table
[] = {
263 2000, 4000, 6000, 10000
266 /* RK817/RK809/RK816 (buck 1/2 only) */
267 static const unsigned int rk817_buck1_4_ramp_table
[] = {
268 3000, 6300, 12500, 25000
271 static int rk806_set_mode_dcdc(struct regulator_dev
*rdev
, unsigned int mode
)
273 int rid
= rdev_get_id(rdev
);
276 reg
= RK806_POWER_FPWM_EN0
+ rid
/ 8;
280 case REGULATOR_MODE_FAST
:
281 return regmap_update_bits(rdev
->regmap
, reg
,
282 PWM_MODE_MSK
<< ctr_bit
,
283 FPWM_MODE
<< ctr_bit
);
284 case REGULATOR_MODE_NORMAL
:
285 return regmap_update_bits(rdev
->regmap
, reg
,
286 PWM_MODE_MSK
<< ctr_bit
,
287 AUTO_PWM_MODE
<< ctr_bit
);
289 dev_err(rdev_get_dev(rdev
), "mode unsupported: %u\n", mode
);
296 static unsigned int rk806_get_mode_dcdc(struct regulator_dev
*rdev
)
298 int rid
= rdev_get_id(rdev
);
303 reg
= RK806_POWER_FPWM_EN0
+ rid
/ 8;
306 err
= regmap_read(rdev
->regmap
, reg
, &val
);
310 if ((val
>> ctr_bit
) & FPWM_MODE
)
311 return REGULATOR_MODE_FAST
;
313 return REGULATOR_MODE_NORMAL
;
316 static const struct rk8xx_register_bit rk806_dcdc_rate2
[] = {
317 RK8XX_REG_BIT(0xEB, 0),
318 RK8XX_REG_BIT(0xEB, 1),
319 RK8XX_REG_BIT(0xEB, 2),
320 RK8XX_REG_BIT(0xEB, 3),
321 RK8XX_REG_BIT(0xEB, 4),
322 RK8XX_REG_BIT(0xEB, 5),
323 RK8XX_REG_BIT(0xEB, 6),
324 RK8XX_REG_BIT(0xEB, 7),
325 RK8XX_REG_BIT(0xEA, 0),
326 RK8XX_REG_BIT(0xEA, 1),
329 static const unsigned int rk806_ramp_delay_table_dcdc
[] = {
330 50000, 25000, 12500, 6250, 3125, 1560, 961, 390
333 static int rk806_set_ramp_delay_dcdc(struct regulator_dev
*rdev
, int ramp_delay
)
335 int rid
= rdev_get_id(rdev
);
336 int regval
, ramp_value
, ret
;
338 ret
= regulator_find_closest_bigger(ramp_delay
, rdev
->desc
->ramp_delay_table
,
339 rdev
->desc
->n_ramp_values
, &ramp_value
);
341 dev_warn(rdev_get_dev(rdev
),
342 "Can't set ramp-delay %u, setting %u\n", ramp_delay
,
343 rdev
->desc
->ramp_delay_table
[ramp_value
]);
346 regval
= ramp_value
<< (ffs(rdev
->desc
->ramp_mask
) - 1);
348 ret
= regmap_update_bits(rdev
->regmap
, rdev
->desc
->ramp_reg
,
349 rdev
->desc
->ramp_mask
, regval
);
354 * The above is effectively a copy of regulator_set_ramp_delay_regmap(),
355 * but that only stores the lower 2 bits for rk806 DCDC ramp. The MSB must
356 * be stored in a separate register, so this open codes the implementation
357 * to have access to the ramp_value.
360 regval
= (ramp_value
>> 2) & 0x1 ? rk806_dcdc_rate2
[rid
].bit
: 0;
361 return regmap_update_bits(rdev
->regmap
, rk806_dcdc_rate2
[rid
].reg
,
362 rk806_dcdc_rate2
[rid
].bit
,
366 static const unsigned int rk806_ramp_delay_table_ldo
[] = {
367 100000, 50000, 25000, 12500, 6280, 3120, 1900, 780
370 static int rk806_set_suspend_voltage_range(struct regulator_dev
*rdev
, int reg_offset
, int uv
)
372 int sel
= regulator_map_voltage_linear_range(rdev
, uv
, uv
);
378 reg
= rdev
->desc
->vsel_reg
+ reg_offset
;
380 return regmap_update_bits(rdev
->regmap
, reg
, rdev
->desc
->vsel_mask
, sel
);
383 static int rk806_set_suspend_voltage_range_dcdc(struct regulator_dev
*rdev
, int uv
)
385 return rk806_set_suspend_voltage_range(rdev
, RK806_DCDC_SLP_REG_OFFSET
, uv
);
388 static int rk806_set_suspend_voltage_range_nldo(struct regulator_dev
*rdev
, int uv
)
390 return rk806_set_suspend_voltage_range(rdev
, RK806_NLDO_SLP_REG_OFFSET
, uv
);
393 static int rk806_set_suspend_voltage_range_pldo(struct regulator_dev
*rdev
, int uv
)
395 return rk806_set_suspend_voltage_range(rdev
, RK806_PLDO_SLP_REG_OFFSET
, uv
);
398 static int rk808_buck1_2_get_voltage_sel_regmap(struct regulator_dev
*rdev
)
400 struct rk808_regulator_data
*pdata
= rdev_get_drvdata(rdev
);
401 int id
= rdev_get_id(rdev
);
402 struct gpio_desc
*gpio
= pdata
->dvs_gpio
[id
];
406 if (!gpio
|| gpiod_get_value(gpio
) == 0)
407 return regulator_get_voltage_sel_regmap(rdev
);
409 ret
= regmap_read(rdev
->regmap
,
410 rdev
->desc
->vsel_reg
+ RK808_DVS_REG_OFFSET
,
415 val
&= rdev
->desc
->vsel_mask
;
416 val
>>= ffs(rdev
->desc
->vsel_mask
) - 1;
421 static int rk808_buck1_2_i2c_set_voltage_sel(struct regulator_dev
*rdev
,
425 unsigned int old_sel
, tmp
, val
, mask
= rdev
->desc
->vsel_mask
;
427 ret
= regmap_read(rdev
->regmap
, rdev
->desc
->vsel_reg
, &val
);
432 old_sel
= val
& mask
;
433 old_sel
>>= ffs(mask
) - 1;
434 delta_sel
= sel
- old_sel
;
437 * If directly modify the register to change the voltage, we will face
438 * the risk of overshoot. Put it into a multi-step, can effectively
439 * avoid this problem, a step is 100mv here.
441 while (delta_sel
> MAX_STEPS_ONE_TIME
) {
442 old_sel
+= MAX_STEPS_ONE_TIME
;
443 val
= old_sel
<< (ffs(mask
) - 1);
447 * i2c is 400kHz (2.5us per bit) and we must transmit _at least_
448 * 3 bytes (24 bits) plus start and stop so 26 bits. So we've
449 * got more than 65 us between each voltage change and thus
450 * won't ramp faster than ~1500 uV / us.
452 ret
= regmap_write(rdev
->regmap
, rdev
->desc
->vsel_reg
, val
);
453 delta_sel
= sel
- old_sel
;
456 sel
<<= ffs(mask
) - 1;
458 ret
= regmap_write(rdev
->regmap
, rdev
->desc
->vsel_reg
, val
);
461 * When we change the voltage register directly, the ramp rate is about
462 * 100000uv/us, wait 1us to make sure the target voltage to be stable,
463 * so we needn't wait extra time after that.
470 static int rk808_buck1_2_set_voltage_sel(struct regulator_dev
*rdev
,
473 struct rk808_regulator_data
*pdata
= rdev_get_drvdata(rdev
);
474 int id
= rdev_get_id(rdev
);
475 struct gpio_desc
*gpio
= pdata
->dvs_gpio
[id
];
476 unsigned int reg
= rdev
->desc
->vsel_reg
;
481 return rk808_buck1_2_i2c_set_voltage_sel(rdev
, sel
);
483 gpio_level
= gpiod_get_value(gpio
);
484 if (gpio_level
== 0) {
485 reg
+= RK808_DVS_REG_OFFSET
;
486 ret
= regmap_read(rdev
->regmap
, rdev
->desc
->vsel_reg
, &old_sel
);
488 ret
= regmap_read(rdev
->regmap
,
489 reg
+ RK808_DVS_REG_OFFSET
,
496 sel
<<= ffs(rdev
->desc
->vsel_mask
) - 1;
497 sel
|= old_sel
& ~rdev
->desc
->vsel_mask
;
499 ret
= regmap_write(rdev
->regmap
, reg
, sel
);
503 gpiod_set_value(gpio
, !gpio_level
);
508 static int rk808_buck1_2_set_voltage_time_sel(struct regulator_dev
*rdev
,
509 unsigned int old_selector
,
510 unsigned int new_selector
)
512 struct rk808_regulator_data
*pdata
= rdev_get_drvdata(rdev
);
513 int id
= rdev_get_id(rdev
);
514 struct gpio_desc
*gpio
= pdata
->dvs_gpio
[id
];
516 /* if there is no dvs1/2 pin, we don't need wait extra time here. */
520 return regulator_set_voltage_time_sel(rdev
, old_selector
, new_selector
);
523 static int rk808_set_suspend_voltage(struct regulator_dev
*rdev
, int uv
)
526 int sel
= regulator_map_voltage_linear(rdev
, uv
, uv
);
531 reg
= rdev
->desc
->vsel_reg
+ RK808_SLP_REG_OFFSET
;
533 return regmap_update_bits(rdev
->regmap
, reg
,
534 rdev
->desc
->vsel_mask
,
538 static int rk808_set_suspend_voltage_range(struct regulator_dev
*rdev
, int uv
)
541 int sel
= regulator_map_voltage_linear_range(rdev
, uv
, uv
);
547 reg
= rdev
->desc
->vsel_reg
+ RK808_SLP_REG_OFFSET
;
549 ret
= regmap_update_bits(rdev
->regmap
, reg
,
550 rdev
->desc
->vsel_mask
,
555 if (rdev
->desc
->apply_bit
)
556 ret
= regmap_update_bits(rdev
->regmap
, rdev
->desc
->apply_reg
,
557 rdev
->desc
->apply_bit
,
558 rdev
->desc
->apply_bit
);
563 static int rk805_set_suspend_enable(struct regulator_dev
*rdev
)
567 reg
= rdev
->desc
->enable_reg
+ RK808_SLP_SET_OFF_REG_OFFSET
;
569 return regmap_update_bits(rdev
->regmap
, reg
,
570 rdev
->desc
->enable_mask
,
571 rdev
->desc
->enable_mask
);
574 static int rk805_set_suspend_disable(struct regulator_dev
*rdev
)
578 reg
= rdev
->desc
->enable_reg
+ RK808_SLP_SET_OFF_REG_OFFSET
;
580 return regmap_update_bits(rdev
->regmap
, reg
,
581 rdev
->desc
->enable_mask
,
585 static const struct rk8xx_register_bit rk806_suspend_bits
[] = {
586 RK8XX_REG_BIT(RK806_POWER_SLP_EN0
, 0),
587 RK8XX_REG_BIT(RK806_POWER_SLP_EN0
, 1),
588 RK8XX_REG_BIT(RK806_POWER_SLP_EN0
, 2),
589 RK8XX_REG_BIT(RK806_POWER_SLP_EN0
, 3),
590 RK8XX_REG_BIT(RK806_POWER_SLP_EN0
, 4),
591 RK8XX_REG_BIT(RK806_POWER_SLP_EN0
, 5),
592 RK8XX_REG_BIT(RK806_POWER_SLP_EN0
, 6),
593 RK8XX_REG_BIT(RK806_POWER_SLP_EN0
, 7),
594 RK8XX_REG_BIT(RK806_POWER_SLP_EN1
, 6),
595 RK8XX_REG_BIT(RK806_POWER_SLP_EN1
, 7),
596 RK8XX_REG_BIT(RK806_POWER_SLP_EN1
, 0),
597 RK8XX_REG_BIT(RK806_POWER_SLP_EN1
, 1),
598 RK8XX_REG_BIT(RK806_POWER_SLP_EN1
, 2),
599 RK8XX_REG_BIT(RK806_POWER_SLP_EN1
, 3),
600 RK8XX_REG_BIT(RK806_POWER_SLP_EN1
, 4),
601 RK8XX_REG_BIT(RK806_POWER_SLP_EN2
, 1),
602 RK8XX_REG_BIT(RK806_POWER_SLP_EN2
, 2),
603 RK8XX_REG_BIT(RK806_POWER_SLP_EN2
, 3),
604 RK8XX_REG_BIT(RK806_POWER_SLP_EN2
, 4),
605 RK8XX_REG_BIT(RK806_POWER_SLP_EN2
, 5),
606 RK8XX_REG_BIT(RK806_POWER_SLP_EN2
, 0),
609 static int rk806_set_suspend_enable(struct regulator_dev
*rdev
)
611 int rid
= rdev_get_id(rdev
);
613 return regmap_update_bits(rdev
->regmap
, rk806_suspend_bits
[rid
].reg
,
614 rk806_suspend_bits
[rid
].bit
,
615 rk806_suspend_bits
[rid
].bit
);
618 static int rk806_set_suspend_disable(struct regulator_dev
*rdev
)
620 int rid
= rdev_get_id(rdev
);
622 return regmap_update_bits(rdev
->regmap
, rk806_suspend_bits
[rid
].reg
,
623 rk806_suspend_bits
[rid
].bit
, 0);
626 static int rk808_set_suspend_enable(struct regulator_dev
*rdev
)
630 reg
= rdev
->desc
->enable_reg
+ RK808_SLP_SET_OFF_REG_OFFSET
;
632 return regmap_update_bits(rdev
->regmap
, reg
,
633 rdev
->desc
->enable_mask
,
637 static int rk808_set_suspend_disable(struct regulator_dev
*rdev
)
641 reg
= rdev
->desc
->enable_reg
+ RK808_SLP_SET_OFF_REG_OFFSET
;
643 return regmap_update_bits(rdev
->regmap
, reg
,
644 rdev
->desc
->enable_mask
,
645 rdev
->desc
->enable_mask
);
648 static const struct rk8xx_register_bit rk816_suspend_bits
[] = {
649 RK8XX_REG_BIT(RK818_SLEEP_SET_OFF_REG1
, 0),
650 RK8XX_REG_BIT(RK818_SLEEP_SET_OFF_REG1
, 1),
651 RK8XX_REG_BIT(RK818_SLEEP_SET_OFF_REG1
, 2),
652 RK8XX_REG_BIT(RK818_SLEEP_SET_OFF_REG1
, 3),
653 RK8XX_REG_BIT(RK818_SLEEP_SET_OFF_REG2
, 0),
654 RK8XX_REG_BIT(RK818_SLEEP_SET_OFF_REG2
, 1),
655 RK8XX_REG_BIT(RK818_SLEEP_SET_OFF_REG2
, 2),
656 RK8XX_REG_BIT(RK818_SLEEP_SET_OFF_REG2
, 3),
657 RK8XX_REG_BIT(RK818_SLEEP_SET_OFF_REG2
, 4),
658 RK8XX_REG_BIT(RK818_SLEEP_SET_OFF_REG2
, 5),
659 RK8XX_REG_BIT(RK818_SLEEP_SET_OFF_REG1
, 5),
660 RK8XX_REG_BIT(RK818_SLEEP_SET_OFF_REG1
, 6),
663 static int rk816_set_suspend_enable(struct regulator_dev
*rdev
)
665 int rid
= rdev_get_id(rdev
);
667 return regmap_update_bits(rdev
->regmap
, rk816_suspend_bits
[rid
].reg
,
668 rk816_suspend_bits
[rid
].bit
,
669 rk816_suspend_bits
[rid
].bit
);
672 static int rk816_set_suspend_disable(struct regulator_dev
*rdev
)
674 int rid
= rdev_get_id(rdev
);
676 return regmap_update_bits(rdev
->regmap
, rk816_suspend_bits
[rid
].reg
,
677 rk816_suspend_bits
[rid
].bit
, 0);
680 static int rk817_set_suspend_enable_ctrl(struct regulator_dev
*rdev
,
684 int id
= rdev_get_id(rdev
);
685 unsigned int id_slp
, msk
, val
;
687 if (id
>= RK817_ID_DCDC1
&& id
<= RK817_ID_DCDC4
)
689 else if (id
>= RK817_ID_LDO1
&& id
<= RK817_ID_LDO8
)
690 id_slp
= 8 + (id
- RK817_ID_LDO1
);
691 else if (id
>= RK817_ID_LDO9
&& id
<= RK809_ID_SW2
)
692 id_slp
= 4 + (id
- RK817_ID_LDO9
);
696 reg
= RK817_POWER_SLP_EN_REG(id_slp
/ 8);
698 msk
= BIT(id_slp
% 8);
704 return regmap_update_bits(rdev
->regmap
, reg
, msk
, val
);
707 static int rk817_set_suspend_enable(struct regulator_dev
*rdev
)
709 return rk817_set_suspend_enable_ctrl(rdev
, 1);
712 static int rk817_set_suspend_disable(struct regulator_dev
*rdev
)
714 return rk817_set_suspend_enable_ctrl(rdev
, 0);
717 static int rk8xx_set_suspend_mode(struct regulator_dev
*rdev
, unsigned int mode
)
721 reg
= rdev
->desc
->vsel_reg
+ RK808_SLP_REG_OFFSET
;
724 case REGULATOR_MODE_FAST
:
725 return regmap_update_bits(rdev
->regmap
, reg
,
726 PWM_MODE_MSK
, FPWM_MODE
);
727 case REGULATOR_MODE_NORMAL
:
728 return regmap_update_bits(rdev
->regmap
, reg
,
729 PWM_MODE_MSK
, AUTO_PWM_MODE
);
731 dev_err(&rdev
->dev
, "do not support this mode\n");
738 static int rk8xx_set_mode(struct regulator_dev
*rdev
, unsigned int mode
)
741 case REGULATOR_MODE_FAST
:
742 return regmap_update_bits(rdev
->regmap
, rdev
->desc
->vsel_reg
,
743 PWM_MODE_MSK
, FPWM_MODE
);
744 case REGULATOR_MODE_NORMAL
:
745 return regmap_update_bits(rdev
->regmap
, rdev
->desc
->vsel_reg
,
746 PWM_MODE_MSK
, AUTO_PWM_MODE
);
748 dev_err(&rdev
->dev
, "do not support this mode\n");
755 static unsigned int rk8xx_get_mode(struct regulator_dev
*rdev
)
760 err
= regmap_read(rdev
->regmap
, rdev
->desc
->vsel_reg
, &val
);
765 return REGULATOR_MODE_FAST
;
767 return REGULATOR_MODE_NORMAL
;
770 static int rk8xx_is_enabled_wmsk_regmap(struct regulator_dev
*rdev
)
775 ret
= regmap_read(rdev
->regmap
, rdev
->desc
->enable_reg
, &val
);
779 /* add write mask bit */
780 val
|= (rdev
->desc
->enable_mask
& 0xf0);
781 val
&= rdev
->desc
->enable_mask
;
783 if (rdev
->desc
->enable_is_inverted
) {
784 if (rdev
->desc
->enable_val
)
785 return val
!= rdev
->desc
->enable_val
;
788 if (rdev
->desc
->enable_val
)
789 return val
== rdev
->desc
->enable_val
;
793 static unsigned int rk8xx_regulator_of_map_mode(unsigned int mode
)
797 return REGULATOR_MODE_FAST
;
799 return REGULATOR_MODE_NORMAL
;
801 return REGULATOR_MODE_INVALID
;
805 static const struct regulator_ops rk805_reg_ops
= {
806 .list_voltage
= regulator_list_voltage_linear
,
807 .map_voltage
= regulator_map_voltage_linear
,
808 .get_voltage_sel
= regulator_get_voltage_sel_regmap
,
809 .set_voltage_sel
= regulator_set_voltage_sel_regmap
,
810 .enable
= regulator_enable_regmap
,
811 .disable
= regulator_disable_regmap
,
812 .is_enabled
= regulator_is_enabled_regmap
,
813 .set_suspend_voltage
= rk808_set_suspend_voltage
,
814 .set_suspend_enable
= rk805_set_suspend_enable
,
815 .set_suspend_disable
= rk805_set_suspend_disable
,
818 static const struct regulator_ops rk805_switch_ops
= {
819 .enable
= regulator_enable_regmap
,
820 .disable
= regulator_disable_regmap
,
821 .is_enabled
= regulator_is_enabled_regmap
,
822 .set_suspend_enable
= rk805_set_suspend_enable
,
823 .set_suspend_disable
= rk805_set_suspend_disable
,
826 static const struct regulator_ops rk806_ops_dcdc
= {
827 .list_voltage
= regulator_list_voltage_linear_range
,
828 .map_voltage
= regulator_map_voltage_linear_range
,
829 .get_voltage_sel
= regulator_get_voltage_sel_regmap
,
830 .set_voltage_sel
= regulator_set_voltage_sel_regmap
,
831 .set_voltage_time_sel
= regulator_set_voltage_time_sel
,
832 .set_mode
= rk806_set_mode_dcdc
,
833 .get_mode
= rk806_get_mode_dcdc
,
835 .enable
= regulator_enable_regmap
,
836 .disable
= regulator_disable_regmap
,
837 .is_enabled
= rk8xx_is_enabled_wmsk_regmap
,
839 .set_suspend_mode
= rk806_set_mode_dcdc
,
840 .set_ramp_delay
= rk806_set_ramp_delay_dcdc
,
842 .set_suspend_voltage
= rk806_set_suspend_voltage_range_dcdc
,
843 .set_suspend_enable
= rk806_set_suspend_enable
,
844 .set_suspend_disable
= rk806_set_suspend_disable
,
847 static const struct regulator_ops rk806_ops_nldo
= {
848 .list_voltage
= regulator_list_voltage_linear_range
,
849 .map_voltage
= regulator_map_voltage_linear_range
,
850 .get_voltage_sel
= regulator_get_voltage_sel_regmap
,
851 .set_voltage_sel
= regulator_set_voltage_sel_regmap
,
852 .set_voltage_time_sel
= regulator_set_voltage_time_sel
,
854 .enable
= regulator_enable_regmap
,
855 .disable
= regulator_disable_regmap
,
856 .is_enabled
= regulator_is_enabled_regmap
,
858 .set_ramp_delay
= regulator_set_ramp_delay_regmap
,
860 .set_suspend_voltage
= rk806_set_suspend_voltage_range_nldo
,
861 .set_suspend_enable
= rk806_set_suspend_enable
,
862 .set_suspend_disable
= rk806_set_suspend_disable
,
865 static const struct regulator_ops rk806_ops_pldo
= {
866 .list_voltage
= regulator_list_voltage_linear_range
,
867 .map_voltage
= regulator_map_voltage_linear_range
,
869 .get_voltage_sel
= regulator_get_voltage_sel_regmap
,
870 .set_voltage_sel
= regulator_set_voltage_sel_regmap
,
871 .set_voltage_time_sel
= regulator_set_voltage_time_sel
,
873 .enable
= regulator_enable_regmap
,
874 .disable
= regulator_disable_regmap
,
875 .is_enabled
= regulator_is_enabled_regmap
,
877 .set_ramp_delay
= regulator_set_ramp_delay_regmap
,
879 .set_suspend_voltage
= rk806_set_suspend_voltage_range_pldo
,
880 .set_suspend_enable
= rk806_set_suspend_enable
,
881 .set_suspend_disable
= rk806_set_suspend_disable
,
884 static const struct regulator_ops rk808_buck1_2_ops
= {
885 .list_voltage
= regulator_list_voltage_linear
,
886 .map_voltage
= regulator_map_voltage_linear
,
887 .get_voltage_sel
= rk808_buck1_2_get_voltage_sel_regmap
,
888 .set_voltage_sel
= rk808_buck1_2_set_voltage_sel
,
889 .set_voltage_time_sel
= rk808_buck1_2_set_voltage_time_sel
,
890 .enable
= regulator_enable_regmap
,
891 .disable
= regulator_disable_regmap
,
892 .is_enabled
= regulator_is_enabled_regmap
,
893 .set_ramp_delay
= regulator_set_ramp_delay_regmap
,
894 .set_suspend_voltage
= rk808_set_suspend_voltage
,
895 .set_suspend_enable
= rk808_set_suspend_enable
,
896 .set_suspend_disable
= rk808_set_suspend_disable
,
899 static const struct regulator_ops rk808_reg_ops
= {
900 .list_voltage
= regulator_list_voltage_linear
,
901 .map_voltage
= regulator_map_voltage_linear
,
902 .get_voltage_sel
= regulator_get_voltage_sel_regmap
,
903 .set_voltage_sel
= regulator_set_voltage_sel_regmap
,
904 .enable
= regulator_enable_regmap
,
905 .disable
= regulator_disable_regmap
,
906 .is_enabled
= regulator_is_enabled_regmap
,
907 .set_suspend_voltage
= rk808_set_suspend_voltage
,
908 .set_suspend_enable
= rk808_set_suspend_enable
,
909 .set_suspend_disable
= rk808_set_suspend_disable
,
912 static const struct regulator_ops rk808_reg_ops_ranges
= {
913 .list_voltage
= regulator_list_voltage_linear_range
,
914 .map_voltage
= regulator_map_voltage_linear_range
,
915 .get_voltage_sel
= regulator_get_voltage_sel_regmap
,
916 .set_voltage_sel
= regulator_set_voltage_sel_regmap
,
917 .enable
= regulator_enable_regmap
,
918 .disable
= regulator_disable_regmap
,
919 .is_enabled
= regulator_is_enabled_regmap
,
920 .set_suspend_voltage
= rk808_set_suspend_voltage_range
,
921 .set_suspend_enable
= rk808_set_suspend_enable
,
922 .set_suspend_disable
= rk808_set_suspend_disable
,
925 static const struct regulator_ops rk808_switch_ops
= {
926 .enable
= regulator_enable_regmap
,
927 .disable
= regulator_disable_regmap
,
928 .is_enabled
= regulator_is_enabled_regmap
,
929 .set_suspend_enable
= rk808_set_suspend_enable
,
930 .set_suspend_disable
= rk808_set_suspend_disable
,
933 static const struct linear_range rk805_buck_1_2_voltage_ranges
[] = {
934 REGULATOR_LINEAR_RANGE(712500, 0, 59, 12500),
935 REGULATOR_LINEAR_RANGE(1800000, 60, 62, 200000),
936 REGULATOR_LINEAR_RANGE(2300000, 63, 63, 0),
939 static const struct regulator_ops rk809_buck5_ops_range
= {
940 .list_voltage
= regulator_list_voltage_linear_range
,
941 .map_voltage
= regulator_map_voltage_linear_range
,
942 .get_voltage_sel
= regulator_get_voltage_sel_regmap
,
943 .set_voltage_sel
= regulator_set_voltage_sel_regmap
,
944 .set_voltage_time_sel
= regulator_set_voltage_time_sel
,
945 .enable
= regulator_enable_regmap
,
946 .disable
= regulator_disable_regmap
,
947 .is_enabled
= rk8xx_is_enabled_wmsk_regmap
,
948 .set_suspend_voltage
= rk808_set_suspend_voltage_range
,
949 .set_suspend_enable
= rk817_set_suspend_enable
,
950 .set_suspend_disable
= rk817_set_suspend_disable
,
953 static const struct regulator_ops rk816_buck1_2_ops_ranges
= {
954 .list_voltage
= regulator_list_voltage_linear_range
,
955 .map_voltage
= regulator_map_voltage_linear_range
,
956 .get_voltage_sel
= regulator_get_voltage_sel_regmap
,
957 .set_voltage_sel
= regulator_set_voltage_sel_regmap
,
958 .set_voltage_time_sel
= regulator_set_voltage_time_sel
,
959 .enable
= regulator_enable_regmap
,
960 .disable
= regulator_disable_regmap
,
961 .is_enabled
= regulator_is_enabled_regmap
,
962 .set_mode
= rk8xx_set_mode
,
963 .get_mode
= rk8xx_get_mode
,
964 .set_suspend_mode
= rk8xx_set_suspend_mode
,
965 .set_ramp_delay
= regulator_set_ramp_delay_regmap
,
966 .set_suspend_voltage
= rk808_set_suspend_voltage_range
,
967 .set_suspend_enable
= rk816_set_suspend_enable
,
968 .set_suspend_disable
= rk816_set_suspend_disable
,
971 static const struct regulator_ops rk816_buck4_ops_ranges
= {
972 .list_voltage
= regulator_list_voltage_linear_range
,
973 .map_voltage
= regulator_map_voltage_linear_range
,
974 .get_voltage_sel
= regulator_get_voltage_sel_regmap
,
975 .set_voltage_sel
= regulator_set_voltage_sel_regmap
,
976 .set_voltage_time_sel
= regulator_set_voltage_time_sel
,
977 .enable
= regulator_enable_regmap
,
978 .disable
= regulator_disable_regmap
,
979 .is_enabled
= regulator_is_enabled_regmap
,
980 .set_mode
= rk8xx_set_mode
,
981 .get_mode
= rk8xx_get_mode
,
982 .set_suspend_mode
= rk8xx_set_suspend_mode
,
983 .set_suspend_voltage
= rk808_set_suspend_voltage_range
,
984 .set_suspend_enable
= rk816_set_suspend_enable
,
985 .set_suspend_disable
= rk816_set_suspend_disable
,
988 static const struct regulator_ops rk816_reg_ops
= {
989 .list_voltage
= regulator_list_voltage_linear
,
990 .map_voltage
= regulator_map_voltage_linear
,
991 .get_voltage_sel
= regulator_get_voltage_sel_regmap
,
992 .set_voltage_sel
= regulator_set_voltage_sel_regmap
,
993 .enable
= regulator_enable_regmap
,
994 .disable
= regulator_disable_regmap
,
995 .is_enabled
= rk8xx_is_enabled_wmsk_regmap
,
996 .set_suspend_voltage
= rk808_set_suspend_voltage
,
997 .set_suspend_enable
= rk816_set_suspend_enable
,
998 .set_suspend_disable
= rk816_set_suspend_disable
,
1001 static const struct regulator_ops rk817_reg_ops
= {
1002 .list_voltage
= regulator_list_voltage_linear
,
1003 .map_voltage
= regulator_map_voltage_linear
,
1004 .get_voltage_sel
= regulator_get_voltage_sel_regmap
,
1005 .set_voltage_sel
= regulator_set_voltage_sel_regmap
,
1006 .enable
= regulator_enable_regmap
,
1007 .disable
= regulator_disable_regmap
,
1008 .is_enabled
= rk8xx_is_enabled_wmsk_regmap
,
1009 .set_suspend_voltage
= rk808_set_suspend_voltage
,
1010 .set_suspend_enable
= rk817_set_suspend_enable
,
1011 .set_suspend_disable
= rk817_set_suspend_disable
,
1014 static const struct regulator_ops rk817_boost_ops
= {
1015 .list_voltage
= regulator_list_voltage_linear
,
1016 .map_voltage
= regulator_map_voltage_linear
,
1017 .get_voltage_sel
= regulator_get_voltage_sel_regmap
,
1018 .set_voltage_sel
= regulator_set_voltage_sel_regmap
,
1019 .enable
= regulator_enable_regmap
,
1020 .disable
= regulator_disable_regmap
,
1021 .is_enabled
= rk8xx_is_enabled_wmsk_regmap
,
1022 .set_suspend_enable
= rk817_set_suspend_enable
,
1023 .set_suspend_disable
= rk817_set_suspend_disable
,
1026 static const struct regulator_ops rk817_buck_ops_range
= {
1027 .list_voltage
= regulator_list_voltage_linear_range
,
1028 .map_voltage
= regulator_map_voltage_linear_range
,
1029 .get_voltage_sel
= regulator_get_voltage_sel_regmap
,
1030 .set_voltage_sel
= regulator_set_voltage_sel_regmap
,
1031 .set_voltage_time_sel
= regulator_set_voltage_time_sel
,
1032 .enable
= regulator_enable_regmap
,
1033 .disable
= regulator_disable_regmap
,
1034 .is_enabled
= rk8xx_is_enabled_wmsk_regmap
,
1035 .set_mode
= rk8xx_set_mode
,
1036 .get_mode
= rk8xx_get_mode
,
1037 .set_suspend_mode
= rk8xx_set_suspend_mode
,
1038 .set_ramp_delay
= regulator_set_ramp_delay_regmap
,
1039 .set_suspend_voltage
= rk808_set_suspend_voltage_range
,
1040 .set_suspend_enable
= rk817_set_suspend_enable
,
1041 .set_suspend_disable
= rk817_set_suspend_disable
,
1044 static const struct regulator_ops rk817_switch_ops
= {
1045 .enable
= regulator_enable_regmap
,
1046 .disable
= regulator_disable_regmap
,
1047 .is_enabled
= rk8xx_is_enabled_wmsk_regmap
,
1048 .set_suspend_enable
= rk817_set_suspend_enable
,
1049 .set_suspend_disable
= rk817_set_suspend_disable
,
1052 static const struct regulator_desc rk805_reg
[] = {
1054 .name
= "DCDC_REG1",
1055 .supply_name
= "vcc1",
1056 .of_match
= of_match_ptr("DCDC_REG1"),
1057 .regulators_node
= of_match_ptr("regulators"),
1058 .id
= RK805_ID_DCDC1
,
1059 .ops
= &rk808_reg_ops_ranges
,
1060 .type
= REGULATOR_VOLTAGE
,
1062 .linear_ranges
= rk805_buck_1_2_voltage_ranges
,
1063 .n_linear_ranges
= ARRAY_SIZE(rk805_buck_1_2_voltage_ranges
),
1064 .vsel_reg
= RK805_BUCK1_ON_VSEL_REG
,
1065 .vsel_mask
= RK818_BUCK_VSEL_MASK
,
1066 .enable_reg
= RK805_DCDC_EN_REG
,
1067 .enable_mask
= BIT(0),
1068 .owner
= THIS_MODULE
,
1070 .name
= "DCDC_REG2",
1071 .supply_name
= "vcc2",
1072 .of_match
= of_match_ptr("DCDC_REG2"),
1073 .regulators_node
= of_match_ptr("regulators"),
1074 .id
= RK805_ID_DCDC2
,
1075 .ops
= &rk808_reg_ops_ranges
,
1076 .type
= REGULATOR_VOLTAGE
,
1078 .linear_ranges
= rk805_buck_1_2_voltage_ranges
,
1079 .n_linear_ranges
= ARRAY_SIZE(rk805_buck_1_2_voltage_ranges
),
1080 .vsel_reg
= RK805_BUCK2_ON_VSEL_REG
,
1081 .vsel_mask
= RK818_BUCK_VSEL_MASK
,
1082 .enable_reg
= RK805_DCDC_EN_REG
,
1083 .enable_mask
= BIT(1),
1084 .owner
= THIS_MODULE
,
1086 .name
= "DCDC_REG3",
1087 .supply_name
= "vcc3",
1088 .of_match
= of_match_ptr("DCDC_REG3"),
1089 .regulators_node
= of_match_ptr("regulators"),
1090 .id
= RK805_ID_DCDC3
,
1091 .ops
= &rk805_switch_ops
,
1092 .type
= REGULATOR_VOLTAGE
,
1094 .enable_reg
= RK805_DCDC_EN_REG
,
1095 .enable_mask
= BIT(2),
1096 .owner
= THIS_MODULE
,
1099 RK805_DESC(RK805_ID_DCDC4
, "DCDC_REG4", "vcc4", 800, 3400, 100,
1100 RK805_BUCK4_ON_VSEL_REG
, RK818_BUCK4_VSEL_MASK
,
1101 RK805_DCDC_EN_REG
, BIT(3), 0),
1103 RK805_DESC(RK805_ID_LDO1
, "LDO_REG1", "vcc5", 800, 3400, 100,
1104 RK805_LDO1_ON_VSEL_REG
, RK818_LDO_VSEL_MASK
, RK805_LDO_EN_REG
,
1106 RK805_DESC(RK805_ID_LDO2
, "LDO_REG2", "vcc5", 800, 3400, 100,
1107 RK805_LDO2_ON_VSEL_REG
, RK818_LDO_VSEL_MASK
, RK805_LDO_EN_REG
,
1109 RK805_DESC(RK805_ID_LDO3
, "LDO_REG3", "vcc6", 800, 3400, 100,
1110 RK805_LDO3_ON_VSEL_REG
, RK818_LDO_VSEL_MASK
, RK805_LDO_EN_REG
,
1114 static const struct linear_range rk806_buck_voltage_ranges
[] = {
1115 REGULATOR_LINEAR_RANGE(500000, 0, 159, 6250), /* 500mV ~ 1500mV */
1116 REGULATOR_LINEAR_RANGE(1500000, 160, 235, 25000), /* 1500mV ~ 3400mV */
1117 REGULATOR_LINEAR_RANGE(3400000, 236, 255, 0),
1120 static const struct linear_range rk806_ldo_voltage_ranges
[] = {
1121 REGULATOR_LINEAR_RANGE(500000, 0, 231, 12500), /* 500mV ~ 3400mV */
1122 REGULATOR_LINEAR_RANGE(3400000, 232, 255, 0),
1125 static const struct regulator_desc rk806_reg
[] = {
1126 RK806_REGULATOR("dcdc-reg1", "vcc1", RK806_ID_DCDC1
, rk806_ops_dcdc
,
1127 RK806_BUCK_SEL_CNT
, RK806_BUCK1_ON_VSEL
,
1128 RK806_POWER_EN0
, rk806_buck_voltage_ranges
, 0,
1129 RK806_BUCK1_CONFIG
, 0xc0, rk806_ramp_delay_table_dcdc
),
1130 RK806_REGULATOR("dcdc-reg2", "vcc2", RK806_ID_DCDC2
, rk806_ops_dcdc
,
1131 RK806_BUCK_SEL_CNT
, RK806_BUCK2_ON_VSEL
,
1132 RK806_POWER_EN0
, rk806_buck_voltage_ranges
, 1,
1133 RK806_BUCK2_CONFIG
, 0xc0, rk806_ramp_delay_table_dcdc
),
1134 RK806_REGULATOR("dcdc-reg3", "vcc3", RK806_ID_DCDC3
, rk806_ops_dcdc
,
1135 RK806_BUCK_SEL_CNT
, RK806_BUCK3_ON_VSEL
,
1136 RK806_POWER_EN0
, rk806_buck_voltage_ranges
, 2,
1137 RK806_BUCK3_CONFIG
, 0xc0, rk806_ramp_delay_table_dcdc
),
1138 RK806_REGULATOR("dcdc-reg4", "vcc4", RK806_ID_DCDC4
, rk806_ops_dcdc
,
1139 RK806_BUCK_SEL_CNT
, RK806_BUCK4_ON_VSEL
,
1140 RK806_POWER_EN0
, rk806_buck_voltage_ranges
, 3,
1141 RK806_BUCK4_CONFIG
, 0xc0, rk806_ramp_delay_table_dcdc
),
1143 RK806_REGULATOR("dcdc-reg5", "vcc5", RK806_ID_DCDC5
, rk806_ops_dcdc
,
1144 RK806_BUCK_SEL_CNT
, RK806_BUCK5_ON_VSEL
,
1145 RK806_POWER_EN1
, rk806_buck_voltage_ranges
, 0,
1146 RK806_BUCK5_CONFIG
, 0xc0, rk806_ramp_delay_table_dcdc
),
1147 RK806_REGULATOR("dcdc-reg6", "vcc6", RK806_ID_DCDC6
, rk806_ops_dcdc
,
1148 RK806_BUCK_SEL_CNT
, RK806_BUCK6_ON_VSEL
,
1149 RK806_POWER_EN1
, rk806_buck_voltage_ranges
, 1,
1150 RK806_BUCK6_CONFIG
, 0xc0, rk806_ramp_delay_table_dcdc
),
1151 RK806_REGULATOR("dcdc-reg7", "vcc7", RK806_ID_DCDC7
, rk806_ops_dcdc
,
1152 RK806_BUCK_SEL_CNT
, RK806_BUCK7_ON_VSEL
,
1153 RK806_POWER_EN1
, rk806_buck_voltage_ranges
, 2,
1154 RK806_BUCK7_CONFIG
, 0xc0, rk806_ramp_delay_table_dcdc
),
1155 RK806_REGULATOR("dcdc-reg8", "vcc8", RK806_ID_DCDC8
, rk806_ops_dcdc
,
1156 RK806_BUCK_SEL_CNT
, RK806_BUCK8_ON_VSEL
,
1157 RK806_POWER_EN1
, rk806_buck_voltage_ranges
, 3,
1158 RK806_BUCK8_CONFIG
, 0xc0, rk806_ramp_delay_table_dcdc
),
1160 RK806_REGULATOR("dcdc-reg9", "vcc9", RK806_ID_DCDC9
, rk806_ops_dcdc
,
1161 RK806_BUCK_SEL_CNT
, RK806_BUCK9_ON_VSEL
,
1162 RK806_POWER_EN2
, rk806_buck_voltage_ranges
, 0,
1163 RK806_BUCK9_CONFIG
, 0xc0, rk806_ramp_delay_table_dcdc
),
1164 RK806_REGULATOR("dcdc-reg10", "vcc10", RK806_ID_DCDC10
, rk806_ops_dcdc
,
1165 RK806_BUCK_SEL_CNT
, RK806_BUCK10_ON_VSEL
,
1166 RK806_POWER_EN2
, rk806_buck_voltage_ranges
, 1,
1167 RK806_BUCK10_CONFIG
, 0xc0, rk806_ramp_delay_table_dcdc
),
1169 RK806_REGULATOR("nldo-reg1", "vcc13", RK806_ID_NLDO1
, rk806_ops_nldo
,
1170 RK806_LDO_SEL_CNT
, RK806_NLDO1_ON_VSEL
,
1171 RK806_POWER_EN3
, rk806_ldo_voltage_ranges
, 0,
1172 0xEA, 0x38, rk806_ramp_delay_table_ldo
),
1173 RK806_REGULATOR("nldo-reg2", "vcc13", RK806_ID_NLDO2
, rk806_ops_nldo
,
1174 RK806_LDO_SEL_CNT
, RK806_NLDO2_ON_VSEL
,
1175 RK806_POWER_EN3
, rk806_ldo_voltage_ranges
, 1,
1176 0xEA, 0x38, rk806_ramp_delay_table_ldo
),
1177 RK806_REGULATOR("nldo-reg3", "vcc13", RK806_ID_NLDO3
, rk806_ops_nldo
,
1178 RK806_LDO_SEL_CNT
, RK806_NLDO3_ON_VSEL
,
1179 RK806_POWER_EN3
, rk806_ldo_voltage_ranges
, 2,
1180 0xEA, 0x38, rk806_ramp_delay_table_ldo
),
1181 RK806_REGULATOR("nldo-reg4", "vcc14", RK806_ID_NLDO4
, rk806_ops_nldo
,
1182 RK806_LDO_SEL_CNT
, RK806_NLDO4_ON_VSEL
,
1183 RK806_POWER_EN3
, rk806_ldo_voltage_ranges
, 3,
1184 0xEA, 0x38, rk806_ramp_delay_table_ldo
),
1186 RK806_REGULATOR("nldo-reg5", "vcc14", RK806_ID_NLDO5
, rk806_ops_nldo
,
1187 RK806_LDO_SEL_CNT
, RK806_NLDO5_ON_VSEL
,
1188 RK806_POWER_EN5
, rk806_ldo_voltage_ranges
, 2,
1189 0xEA, 0x38, rk806_ramp_delay_table_ldo
),
1191 RK806_REGULATOR("pldo-reg1", "vcc11", RK806_ID_PLDO1
, rk806_ops_pldo
,
1192 RK806_LDO_SEL_CNT
, RK806_PLDO1_ON_VSEL
,
1193 RK806_POWER_EN4
, rk806_ldo_voltage_ranges
, 1,
1194 0xEA, 0x38, rk806_ramp_delay_table_ldo
),
1195 RK806_REGULATOR("pldo-reg2", "vcc11", RK806_ID_PLDO2
, rk806_ops_pldo
,
1196 RK806_LDO_SEL_CNT
, RK806_PLDO2_ON_VSEL
,
1197 RK806_POWER_EN4
, rk806_ldo_voltage_ranges
, 2,
1198 0xEA, 0x38, rk806_ramp_delay_table_ldo
),
1199 RK806_REGULATOR("pldo-reg3", "vcc11", RK806_ID_PLDO3
, rk806_ops_pldo
,
1200 RK806_LDO_SEL_CNT
, RK806_PLDO3_ON_VSEL
,
1201 RK806_POWER_EN4
, rk806_ldo_voltage_ranges
, 3,
1202 0xEA, 0x38, rk806_ramp_delay_table_ldo
),
1204 RK806_REGULATOR("pldo-reg4", "vcc12", RK806_ID_PLDO4
, rk806_ops_pldo
,
1205 RK806_LDO_SEL_CNT
, RK806_PLDO4_ON_VSEL
,
1206 RK806_POWER_EN5
, rk806_ldo_voltage_ranges
, 0,
1207 0xEA, 0x38, rk806_ramp_delay_table_ldo
),
1208 RK806_REGULATOR("pldo-reg5", "vcc12", RK806_ID_PLDO5
, rk806_ops_pldo
,
1209 RK806_LDO_SEL_CNT
, RK806_PLDO5_ON_VSEL
,
1210 RK806_POWER_EN5
, rk806_ldo_voltage_ranges
, 1,
1211 0xEA, 0x38, rk806_ramp_delay_table_ldo
),
1213 RK806_REGULATOR("pldo-reg6", "vcca", RK806_ID_PLDO6
, rk806_ops_pldo
,
1214 RK806_LDO_SEL_CNT
, RK806_PLDO6_ON_VSEL
,
1215 RK806_POWER_EN4
, rk806_ldo_voltage_ranges
, 0,
1216 0xEA, 0x38, rk806_ramp_delay_table_ldo
),
1220 static const struct regulator_desc rk808_reg
[] = {
1222 .name
= "DCDC_REG1",
1223 .supply_name
= "vcc1",
1224 .of_match
= of_match_ptr("DCDC_REG1"),
1225 .regulators_node
= of_match_ptr("regulators"),
1226 .id
= RK808_ID_DCDC1
,
1227 .ops
= &rk808_buck1_2_ops
,
1228 .type
= REGULATOR_VOLTAGE
,
1232 .vsel_reg
= RK808_BUCK1_ON_VSEL_REG
,
1233 .vsel_mask
= RK808_BUCK_VSEL_MASK
,
1234 .enable_reg
= RK808_DCDC_EN_REG
,
1235 .enable_mask
= BIT(0),
1236 .ramp_reg
= RK808_BUCK1_CONFIG_REG
,
1237 .ramp_mask
= RK808_RAMP_RATE_MASK
,
1238 .ramp_delay_table
= rk808_buck1_2_ramp_table
,
1239 .n_ramp_values
= ARRAY_SIZE(rk808_buck1_2_ramp_table
),
1240 .owner
= THIS_MODULE
,
1242 .name
= "DCDC_REG2",
1243 .supply_name
= "vcc2",
1244 .of_match
= of_match_ptr("DCDC_REG2"),
1245 .regulators_node
= of_match_ptr("regulators"),
1246 .id
= RK808_ID_DCDC2
,
1247 .ops
= &rk808_buck1_2_ops
,
1248 .type
= REGULATOR_VOLTAGE
,
1252 .vsel_reg
= RK808_BUCK2_ON_VSEL_REG
,
1253 .vsel_mask
= RK808_BUCK_VSEL_MASK
,
1254 .enable_reg
= RK808_DCDC_EN_REG
,
1255 .enable_mask
= BIT(1),
1256 .ramp_reg
= RK808_BUCK2_CONFIG_REG
,
1257 .ramp_mask
= RK808_RAMP_RATE_MASK
,
1258 .ramp_delay_table
= rk808_buck1_2_ramp_table
,
1259 .n_ramp_values
= ARRAY_SIZE(rk808_buck1_2_ramp_table
),
1260 .owner
= THIS_MODULE
,
1262 .name
= "DCDC_REG3",
1263 .supply_name
= "vcc3",
1264 .of_match
= of_match_ptr("DCDC_REG3"),
1265 .regulators_node
= of_match_ptr("regulators"),
1266 .id
= RK808_ID_DCDC3
,
1267 .ops
= &rk808_switch_ops
,
1268 .type
= REGULATOR_VOLTAGE
,
1270 .enable_reg
= RK808_DCDC_EN_REG
,
1271 .enable_mask
= BIT(2),
1272 .owner
= THIS_MODULE
,
1274 RK8XX_DESC(RK808_ID_DCDC4
, "DCDC_REG4", "vcc4", 1800, 3300, 100,
1275 RK808_BUCK4_ON_VSEL_REG
, RK808_BUCK4_VSEL_MASK
,
1276 RK808_DCDC_EN_REG
, BIT(3), 0),
1277 RK8XX_DESC(RK808_ID_LDO1
, "LDO_REG1", "vcc6", 1800, 3400, 100,
1278 RK808_LDO1_ON_VSEL_REG
, RK808_LDO_VSEL_MASK
, RK808_LDO_EN_REG
,
1280 RK8XX_DESC(RK808_ID_LDO2
, "LDO_REG2", "vcc6", 1800, 3400, 100,
1281 RK808_LDO2_ON_VSEL_REG
, RK808_LDO_VSEL_MASK
, RK808_LDO_EN_REG
,
1285 .supply_name
= "vcc7",
1286 .of_match
= of_match_ptr("LDO_REG3"),
1287 .regulators_node
= of_match_ptr("regulators"),
1288 .id
= RK808_ID_LDO3
,
1289 .ops
= &rk808_reg_ops_ranges
,
1290 .type
= REGULATOR_VOLTAGE
,
1292 .linear_ranges
= rk808_ldo3_voltage_ranges
,
1293 .n_linear_ranges
= ARRAY_SIZE(rk808_ldo3_voltage_ranges
),
1294 .vsel_reg
= RK808_LDO3_ON_VSEL_REG
,
1295 .vsel_mask
= RK808_BUCK4_VSEL_MASK
,
1296 .enable_reg
= RK808_LDO_EN_REG
,
1297 .enable_mask
= BIT(2),
1299 .owner
= THIS_MODULE
,
1301 RK8XX_DESC(RK808_ID_LDO4
, "LDO_REG4", "vcc9", 1800, 3400, 100,
1302 RK808_LDO4_ON_VSEL_REG
, RK808_LDO_VSEL_MASK
, RK808_LDO_EN_REG
,
1304 RK8XX_DESC(RK808_ID_LDO5
, "LDO_REG5", "vcc9", 1800, 3400, 100,
1305 RK808_LDO5_ON_VSEL_REG
, RK808_LDO_VSEL_MASK
, RK808_LDO_EN_REG
,
1307 RK8XX_DESC(RK808_ID_LDO6
, "LDO_REG6", "vcc10", 800, 2500, 100,
1308 RK808_LDO6_ON_VSEL_REG
, RK808_LDO_VSEL_MASK
, RK808_LDO_EN_REG
,
1310 RK8XX_DESC(RK808_ID_LDO7
, "LDO_REG7", "vcc7", 800, 2500, 100,
1311 RK808_LDO7_ON_VSEL_REG
, RK808_LDO_VSEL_MASK
, RK808_LDO_EN_REG
,
1313 RK8XX_DESC(RK808_ID_LDO8
, "LDO_REG8", "vcc11", 1800, 3400, 100,
1314 RK808_LDO8_ON_VSEL_REG
, RK808_LDO_VSEL_MASK
, RK808_LDO_EN_REG
,
1316 RK8XX_DESC_SWITCH(RK808_ID_SWITCH1
, "SWITCH_REG1", "vcc8",
1317 RK808_DCDC_EN_REG
, BIT(5)),
1318 RK8XX_DESC_SWITCH(RK808_ID_SWITCH2
, "SWITCH_REG2", "vcc12",
1319 RK808_DCDC_EN_REG
, BIT(6)),
1322 static const struct regulator_desc rk809_reg
[] = {
1324 .name
= "DCDC_REG1",
1325 .supply_name
= "vcc1",
1326 .of_match
= of_match_ptr("DCDC_REG1"),
1327 .regulators_node
= of_match_ptr("regulators"),
1328 .id
= RK817_ID_DCDC1
,
1329 .ops
= &rk817_buck_ops_range
,
1330 .type
= REGULATOR_VOLTAGE
,
1331 .n_voltages
= RK817_BUCK1_SEL_CNT
+ 1,
1332 .linear_ranges
= rk817_buck1_voltage_ranges
,
1333 .n_linear_ranges
= ARRAY_SIZE(rk817_buck1_voltage_ranges
),
1334 .vsel_reg
= RK817_BUCK1_ON_VSEL_REG
,
1335 .vsel_mask
= RK817_BUCK_VSEL_MASK
,
1336 .enable_reg
= RK817_POWER_EN_REG(0),
1337 .enable_mask
= ENABLE_MASK(RK817_ID_DCDC1
),
1338 .enable_val
= ENABLE_MASK(RK817_ID_DCDC1
),
1339 .disable_val
= DISABLE_VAL(RK817_ID_DCDC1
),
1340 .ramp_reg
= RK817_BUCK_CONFIG_REG(RK817_ID_DCDC1
),
1341 .ramp_mask
= RK817_RAMP_RATE_MASK
,
1342 .ramp_delay_table
= rk817_buck1_4_ramp_table
,
1343 .n_ramp_values
= ARRAY_SIZE(rk817_buck1_4_ramp_table
),
1344 .of_map_mode
= rk8xx_regulator_of_map_mode
,
1345 .owner
= THIS_MODULE
,
1347 .name
= "DCDC_REG2",
1348 .supply_name
= "vcc2",
1349 .of_match
= of_match_ptr("DCDC_REG2"),
1350 .regulators_node
= of_match_ptr("regulators"),
1351 .id
= RK817_ID_DCDC2
,
1352 .ops
= &rk817_buck_ops_range
,
1353 .type
= REGULATOR_VOLTAGE
,
1354 .n_voltages
= RK817_BUCK1_SEL_CNT
+ 1,
1355 .linear_ranges
= rk817_buck1_voltage_ranges
,
1356 .n_linear_ranges
= ARRAY_SIZE(rk817_buck1_voltage_ranges
),
1357 .vsel_reg
= RK817_BUCK2_ON_VSEL_REG
,
1358 .vsel_mask
= RK817_BUCK_VSEL_MASK
,
1359 .enable_reg
= RK817_POWER_EN_REG(0),
1360 .enable_mask
= ENABLE_MASK(RK817_ID_DCDC2
),
1361 .enable_val
= ENABLE_MASK(RK817_ID_DCDC2
),
1362 .disable_val
= DISABLE_VAL(RK817_ID_DCDC2
),
1363 .ramp_reg
= RK817_BUCK_CONFIG_REG(RK817_ID_DCDC2
),
1364 .ramp_mask
= RK817_RAMP_RATE_MASK
,
1365 .ramp_delay_table
= rk817_buck1_4_ramp_table
,
1366 .n_ramp_values
= ARRAY_SIZE(rk817_buck1_4_ramp_table
),
1367 .of_map_mode
= rk8xx_regulator_of_map_mode
,
1368 .owner
= THIS_MODULE
,
1370 .name
= "DCDC_REG3",
1371 .supply_name
= "vcc3",
1372 .of_match
= of_match_ptr("DCDC_REG3"),
1373 .regulators_node
= of_match_ptr("regulators"),
1374 .id
= RK817_ID_DCDC3
,
1375 .ops
= &rk817_buck_ops_range
,
1376 .type
= REGULATOR_VOLTAGE
,
1377 .n_voltages
= RK817_BUCK1_SEL_CNT
+ 1,
1378 .linear_ranges
= rk817_buck1_voltage_ranges
,
1379 .n_linear_ranges
= ARRAY_SIZE(rk817_buck1_voltage_ranges
),
1380 .vsel_reg
= RK817_BUCK3_ON_VSEL_REG
,
1381 .vsel_mask
= RK817_BUCK_VSEL_MASK
,
1382 .apply_reg
= RK817_POWER_CONFIG
,
1383 .apply_bit
= RK817_BUCK3_FB_RES_INTER
,
1384 .enable_reg
= RK817_POWER_EN_REG(0),
1385 .enable_mask
= ENABLE_MASK(RK817_ID_DCDC3
),
1386 .enable_val
= ENABLE_MASK(RK817_ID_DCDC3
),
1387 .disable_val
= DISABLE_VAL(RK817_ID_DCDC3
),
1388 .ramp_reg
= RK817_BUCK_CONFIG_REG(RK817_ID_DCDC3
),
1389 .ramp_mask
= RK817_RAMP_RATE_MASK
,
1390 .ramp_delay_table
= rk817_buck1_4_ramp_table
,
1391 .n_ramp_values
= ARRAY_SIZE(rk817_buck1_4_ramp_table
),
1392 .of_map_mode
= rk8xx_regulator_of_map_mode
,
1393 .owner
= THIS_MODULE
,
1395 .name
= "DCDC_REG4",
1396 .supply_name
= "vcc4",
1397 .of_match
= of_match_ptr("DCDC_REG4"),
1398 .regulators_node
= of_match_ptr("regulators"),
1399 .id
= RK817_ID_DCDC4
,
1400 .ops
= &rk817_buck_ops_range
,
1401 .type
= REGULATOR_VOLTAGE
,
1402 .n_voltages
= RK817_BUCK3_SEL_CNT
+ 1,
1403 .linear_ranges
= rk817_buck3_voltage_ranges
,
1404 .n_linear_ranges
= ARRAY_SIZE(rk817_buck3_voltage_ranges
),
1405 .vsel_reg
= RK817_BUCK4_ON_VSEL_REG
,
1406 .vsel_mask
= RK817_BUCK_VSEL_MASK
,
1407 .enable_reg
= RK817_POWER_EN_REG(0),
1408 .enable_mask
= ENABLE_MASK(RK817_ID_DCDC4
),
1409 .enable_val
= ENABLE_MASK(RK817_ID_DCDC4
),
1410 .disable_val
= DISABLE_VAL(RK817_ID_DCDC4
),
1411 .ramp_reg
= RK817_BUCK_CONFIG_REG(RK817_ID_DCDC4
),
1412 .ramp_mask
= RK817_RAMP_RATE_MASK
,
1413 .ramp_delay_table
= rk817_buck1_4_ramp_table
,
1414 .n_ramp_values
= ARRAY_SIZE(rk817_buck1_4_ramp_table
),
1415 .of_map_mode
= rk8xx_regulator_of_map_mode
,
1416 .owner
= THIS_MODULE
,
1419 .name
= "DCDC_REG5",
1420 .supply_name
= "vcc9",
1421 .of_match
= of_match_ptr("DCDC_REG5"),
1422 .regulators_node
= of_match_ptr("regulators"),
1423 .id
= RK809_ID_DCDC5
,
1424 .ops
= &rk809_buck5_ops_range
,
1425 .type
= REGULATOR_VOLTAGE
,
1426 .n_voltages
= RK809_BUCK5_SEL_CNT
,
1427 .linear_ranges
= rk809_buck5_voltage_ranges
,
1428 .n_linear_ranges
= ARRAY_SIZE(rk809_buck5_voltage_ranges
),
1429 .vsel_reg
= RK809_BUCK5_CONFIG(0),
1430 .vsel_mask
= RK809_BUCK5_VSEL_MASK
,
1431 .enable_reg
= RK817_POWER_EN_REG(3),
1432 .enable_mask
= ENABLE_MASK(1),
1433 .enable_val
= ENABLE_MASK(1),
1434 .disable_val
= DISABLE_VAL(1),
1435 .of_map_mode
= rk8xx_regulator_of_map_mode
,
1436 .owner
= THIS_MODULE
,
1438 RK817_DESC(RK817_ID_LDO1
, "LDO_REG1", "vcc5", 600, 3400, 25,
1439 RK817_LDO_ON_VSEL_REG(0), RK817_LDO_VSEL_MASK
,
1440 RK817_POWER_EN_REG(1), ENABLE_MASK(0),
1441 DISABLE_VAL(0), 400),
1442 RK817_DESC(RK817_ID_LDO2
, "LDO_REG2", "vcc5", 600, 3400, 25,
1443 RK817_LDO_ON_VSEL_REG(1), RK817_LDO_VSEL_MASK
,
1444 RK817_POWER_EN_REG(1), ENABLE_MASK(1),
1445 DISABLE_VAL(1), 400),
1446 RK817_DESC(RK817_ID_LDO3
, "LDO_REG3", "vcc5", 600, 3400, 25,
1447 RK817_LDO_ON_VSEL_REG(2), RK817_LDO_VSEL_MASK
,
1448 RK817_POWER_EN_REG(1), ENABLE_MASK(2),
1449 DISABLE_VAL(2), 400),
1450 RK817_DESC(RK817_ID_LDO4
, "LDO_REG4", "vcc6", 600, 3400, 25,
1451 RK817_LDO_ON_VSEL_REG(3), RK817_LDO_VSEL_MASK
,
1452 RK817_POWER_EN_REG(1), ENABLE_MASK(3),
1453 DISABLE_VAL(3), 400),
1454 RK817_DESC(RK817_ID_LDO5
, "LDO_REG5", "vcc6", 600, 3400, 25,
1455 RK817_LDO_ON_VSEL_REG(4), RK817_LDO_VSEL_MASK
,
1456 RK817_POWER_EN_REG(2), ENABLE_MASK(0),
1457 DISABLE_VAL(0), 400),
1458 RK817_DESC(RK817_ID_LDO6
, "LDO_REG6", "vcc6", 600, 3400, 25,
1459 RK817_LDO_ON_VSEL_REG(5), RK817_LDO_VSEL_MASK
,
1460 RK817_POWER_EN_REG(2), ENABLE_MASK(1),
1461 DISABLE_VAL(1), 400),
1462 RK817_DESC(RK817_ID_LDO7
, "LDO_REG7", "vcc7", 600, 3400, 25,
1463 RK817_LDO_ON_VSEL_REG(6), RK817_LDO_VSEL_MASK
,
1464 RK817_POWER_EN_REG(2), ENABLE_MASK(2),
1465 DISABLE_VAL(2), 400),
1466 RK817_DESC(RK817_ID_LDO8
, "LDO_REG8", "vcc7", 600, 3400, 25,
1467 RK817_LDO_ON_VSEL_REG(7), RK817_LDO_VSEL_MASK
,
1468 RK817_POWER_EN_REG(2), ENABLE_MASK(3),
1469 DISABLE_VAL(3), 400),
1470 RK817_DESC(RK817_ID_LDO9
, "LDO_REG9", "vcc7", 600, 3400, 25,
1471 RK817_LDO_ON_VSEL_REG(8), RK817_LDO_VSEL_MASK
,
1472 RK817_POWER_EN_REG(3), ENABLE_MASK(0),
1473 DISABLE_VAL(0), 400),
1474 RK817_DESC_SWITCH(RK809_ID_SW1
, "SWITCH_REG1", "vcc9",
1475 RK817_POWER_EN_REG(3), ENABLE_MASK(2),
1477 RK817_DESC_SWITCH(RK809_ID_SW2
, "SWITCH_REG2", "vcc8",
1478 RK817_POWER_EN_REG(3), ENABLE_MASK(3),
1482 static const struct linear_range rk816_buck_4_voltage_ranges
[] = {
1483 REGULATOR_LINEAR_RANGE(800000, 0, 26, 100000),
1484 REGULATOR_LINEAR_RANGE(3500000, 27, 31, 0),
1487 static const struct regulator_desc rk816_reg
[] = {
1490 .supply_name
= "vcc1",
1491 .of_match
= of_match_ptr("dcdc1"),
1492 .regulators_node
= of_match_ptr("regulators"),
1493 .id
= RK816_ID_DCDC1
,
1494 .ops
= &rk816_buck1_2_ops_ranges
,
1495 .type
= REGULATOR_VOLTAGE
,
1497 .linear_ranges
= rk805_buck_1_2_voltage_ranges
,
1498 .n_linear_ranges
= ARRAY_SIZE(rk805_buck_1_2_voltage_ranges
),
1499 .vsel_reg
= RK818_BUCK1_ON_VSEL_REG
,
1500 .vsel_mask
= RK818_BUCK_VSEL_MASK
,
1501 .apply_reg
= RK816_DCDC_EN_REG2
,
1502 .apply_bit
= RK816_BUCK_DVS_CONFIRM
,
1503 .enable_reg
= RK816_DCDC_EN_REG1
,
1504 .enable_mask
= BIT(4) | BIT(0),
1505 .enable_val
= BIT(4) | BIT(0),
1506 .disable_val
= BIT(4),
1507 .ramp_reg
= RK818_BUCK1_CONFIG_REG
,
1508 .ramp_mask
= RK808_RAMP_RATE_MASK
,
1509 .ramp_delay_table
= rk817_buck1_4_ramp_table
,
1510 .n_ramp_values
= ARRAY_SIZE(rk817_buck1_4_ramp_table
),
1511 .of_map_mode
= rk8xx_regulator_of_map_mode
,
1512 .owner
= THIS_MODULE
,
1515 .supply_name
= "vcc2",
1516 .of_match
= of_match_ptr("dcdc2"),
1517 .regulators_node
= of_match_ptr("regulators"),
1518 .id
= RK816_ID_DCDC2
,
1519 .ops
= &rk816_buck1_2_ops_ranges
,
1520 .type
= REGULATOR_VOLTAGE
,
1522 .linear_ranges
= rk805_buck_1_2_voltage_ranges
,
1523 .n_linear_ranges
= ARRAY_SIZE(rk805_buck_1_2_voltage_ranges
),
1524 .vsel_reg
= RK818_BUCK2_ON_VSEL_REG
,
1525 .vsel_mask
= RK818_BUCK_VSEL_MASK
,
1526 .apply_reg
= RK816_DCDC_EN_REG2
,
1527 .apply_bit
= RK816_BUCK_DVS_CONFIRM
,
1528 .enable_reg
= RK816_DCDC_EN_REG1
,
1529 .enable_mask
= BIT(5) | BIT(1),
1530 .enable_val
= BIT(5) | BIT(1),
1531 .disable_val
= BIT(5),
1532 .ramp_reg
= RK818_BUCK2_CONFIG_REG
,
1533 .ramp_mask
= RK808_RAMP_RATE_MASK
,
1534 .ramp_delay_table
= rk817_buck1_4_ramp_table
,
1535 .n_ramp_values
= ARRAY_SIZE(rk817_buck1_4_ramp_table
),
1536 .of_map_mode
= rk8xx_regulator_of_map_mode
,
1537 .owner
= THIS_MODULE
,
1540 .supply_name
= "vcc3",
1541 .of_match
= of_match_ptr("dcdc3"),
1542 .regulators_node
= of_match_ptr("regulators"),
1543 .id
= RK816_ID_DCDC3
,
1544 .ops
= &rk808_switch_ops
,
1545 .type
= REGULATOR_VOLTAGE
,
1547 .enable_reg
= RK816_DCDC_EN_REG1
,
1548 .enable_mask
= BIT(6) | BIT(2),
1549 .enable_val
= BIT(6) | BIT(2),
1550 .disable_val
= BIT(6),
1551 .of_map_mode
= rk8xx_regulator_of_map_mode
,
1552 .owner
= THIS_MODULE
,
1555 .supply_name
= "vcc4",
1556 .of_match
= of_match_ptr("dcdc4"),
1557 .regulators_node
= of_match_ptr("regulators"),
1558 .id
= RK816_ID_DCDC4
,
1559 .ops
= &rk816_buck4_ops_ranges
,
1560 .type
= REGULATOR_VOLTAGE
,
1562 .linear_ranges
= rk816_buck_4_voltage_ranges
,
1563 .n_linear_ranges
= ARRAY_SIZE(rk816_buck_4_voltage_ranges
),
1564 .vsel_reg
= RK818_BUCK4_ON_VSEL_REG
,
1565 .vsel_mask
= RK818_BUCK4_VSEL_MASK
,
1566 .enable_reg
= RK816_DCDC_EN_REG1
,
1567 .enable_mask
= BIT(7) | BIT(3),
1568 .enable_val
= BIT(7) | BIT(3),
1569 .disable_val
= BIT(7),
1570 .of_map_mode
= rk8xx_regulator_of_map_mode
,
1571 .owner
= THIS_MODULE
,
1573 RK816_DESC(RK816_ID_LDO1
, "ldo1", "vcc5", 800, 3400, 100,
1574 RK818_LDO1_ON_VSEL_REG
, RK818_LDO_VSEL_MASK
,
1575 RK816_LDO_EN_REG1
, ENABLE_MASK(0), DISABLE_VAL(0), 400),
1576 RK816_DESC(RK816_ID_LDO2
, "ldo2", "vcc5", 800, 3400, 100,
1577 RK818_LDO2_ON_VSEL_REG
, RK818_LDO_VSEL_MASK
,
1578 RK816_LDO_EN_REG1
, ENABLE_MASK(1), DISABLE_VAL(1), 400),
1579 RK816_DESC(RK816_ID_LDO3
, "ldo3", "vcc5", 800, 3400, 100,
1580 RK818_LDO3_ON_VSEL_REG
, RK818_LDO_VSEL_MASK
,
1581 RK816_LDO_EN_REG1
, ENABLE_MASK(2), DISABLE_VAL(2), 400),
1582 RK816_DESC(RK816_ID_LDO4
, "ldo4", "vcc6", 800, 3400, 100,
1583 RK818_LDO4_ON_VSEL_REG
, RK818_LDO_VSEL_MASK
,
1584 RK816_LDO_EN_REG1
, ENABLE_MASK(3), DISABLE_VAL(3), 400),
1585 RK816_DESC(RK816_ID_LDO5
, "ldo5", "vcc6", 800, 3400, 100,
1586 RK818_LDO5_ON_VSEL_REG
, RK818_LDO_VSEL_MASK
,
1587 RK816_LDO_EN_REG2
, ENABLE_MASK(0), DISABLE_VAL(0), 400),
1588 RK816_DESC(RK816_ID_LDO6
, "ldo6", "vcc6", 800, 3400, 100,
1589 RK818_LDO6_ON_VSEL_REG
, RK818_LDO_VSEL_MASK
,
1590 RK816_LDO_EN_REG2
, ENABLE_MASK(1), DISABLE_VAL(1), 400),
1593 static const struct regulator_desc rk817_reg
[] = {
1595 .name
= "DCDC_REG1",
1596 .supply_name
= "vcc1",
1597 .of_match
= of_match_ptr("DCDC_REG1"),
1598 .regulators_node
= of_match_ptr("regulators"),
1599 .id
= RK817_ID_DCDC1
,
1600 .ops
= &rk817_buck_ops_range
,
1601 .type
= REGULATOR_VOLTAGE
,
1602 .n_voltages
= RK817_BUCK1_SEL_CNT
+ 1,
1603 .linear_ranges
= rk817_buck1_voltage_ranges
,
1604 .n_linear_ranges
= ARRAY_SIZE(rk817_buck1_voltage_ranges
),
1605 .vsel_reg
= RK817_BUCK1_ON_VSEL_REG
,
1606 .vsel_mask
= RK817_BUCK_VSEL_MASK
,
1607 .enable_reg
= RK817_POWER_EN_REG(0),
1608 .enable_mask
= ENABLE_MASK(RK817_ID_DCDC1
),
1609 .enable_val
= ENABLE_MASK(RK817_ID_DCDC1
),
1610 .disable_val
= DISABLE_VAL(RK817_ID_DCDC1
),
1611 .ramp_reg
= RK817_BUCK_CONFIG_REG(RK817_ID_DCDC1
),
1612 .ramp_mask
= RK817_RAMP_RATE_MASK
,
1613 .ramp_delay_table
= rk817_buck1_4_ramp_table
,
1614 .n_ramp_values
= ARRAY_SIZE(rk817_buck1_4_ramp_table
),
1615 .of_map_mode
= rk8xx_regulator_of_map_mode
,
1616 .owner
= THIS_MODULE
,
1618 .name
= "DCDC_REG2",
1619 .supply_name
= "vcc2",
1620 .of_match
= of_match_ptr("DCDC_REG2"),
1621 .regulators_node
= of_match_ptr("regulators"),
1622 .id
= RK817_ID_DCDC2
,
1623 .ops
= &rk817_buck_ops_range
,
1624 .type
= REGULATOR_VOLTAGE
,
1625 .n_voltages
= RK817_BUCK1_SEL_CNT
+ 1,
1626 .linear_ranges
= rk817_buck1_voltage_ranges
,
1627 .n_linear_ranges
= ARRAY_SIZE(rk817_buck1_voltage_ranges
),
1628 .vsel_reg
= RK817_BUCK2_ON_VSEL_REG
,
1629 .vsel_mask
= RK817_BUCK_VSEL_MASK
,
1630 .enable_reg
= RK817_POWER_EN_REG(0),
1631 .enable_mask
= ENABLE_MASK(RK817_ID_DCDC2
),
1632 .enable_val
= ENABLE_MASK(RK817_ID_DCDC2
),
1633 .disable_val
= DISABLE_VAL(RK817_ID_DCDC2
),
1634 .ramp_reg
= RK817_BUCK_CONFIG_REG(RK817_ID_DCDC2
),
1635 .ramp_mask
= RK817_RAMP_RATE_MASK
,
1636 .ramp_delay_table
= rk817_buck1_4_ramp_table
,
1637 .n_ramp_values
= ARRAY_SIZE(rk817_buck1_4_ramp_table
),
1638 .of_map_mode
= rk8xx_regulator_of_map_mode
,
1639 .owner
= THIS_MODULE
,
1641 .name
= "DCDC_REG3",
1642 .supply_name
= "vcc3",
1643 .of_match
= of_match_ptr("DCDC_REG3"),
1644 .regulators_node
= of_match_ptr("regulators"),
1645 .id
= RK817_ID_DCDC3
,
1646 .ops
= &rk817_buck_ops_range
,
1647 .type
= REGULATOR_VOLTAGE
,
1648 .n_voltages
= RK817_BUCK1_SEL_CNT
+ 1,
1649 .linear_ranges
= rk817_buck1_voltage_ranges
,
1650 .n_linear_ranges
= ARRAY_SIZE(rk817_buck1_voltage_ranges
),
1651 .vsel_reg
= RK817_BUCK3_ON_VSEL_REG
,
1652 .vsel_mask
= RK817_BUCK_VSEL_MASK
,
1653 .enable_reg
= RK817_POWER_EN_REG(0),
1654 .enable_mask
= ENABLE_MASK(RK817_ID_DCDC3
),
1655 .enable_val
= ENABLE_MASK(RK817_ID_DCDC3
),
1656 .disable_val
= DISABLE_VAL(RK817_ID_DCDC3
),
1657 .ramp_reg
= RK817_BUCK_CONFIG_REG(RK817_ID_DCDC3
),
1658 .ramp_mask
= RK817_RAMP_RATE_MASK
,
1659 .ramp_delay_table
= rk817_buck1_4_ramp_table
,
1660 .n_ramp_values
= ARRAY_SIZE(rk817_buck1_4_ramp_table
),
1661 .of_map_mode
= rk8xx_regulator_of_map_mode
,
1662 .owner
= THIS_MODULE
,
1664 .name
= "DCDC_REG4",
1665 .supply_name
= "vcc4",
1666 .of_match
= of_match_ptr("DCDC_REG4"),
1667 .regulators_node
= of_match_ptr("regulators"),
1668 .id
= RK817_ID_DCDC4
,
1669 .ops
= &rk817_buck_ops_range
,
1670 .type
= REGULATOR_VOLTAGE
,
1671 .n_voltages
= RK817_BUCK3_SEL_CNT
+ 1,
1672 .linear_ranges
= rk817_buck3_voltage_ranges
,
1673 .n_linear_ranges
= ARRAY_SIZE(rk817_buck3_voltage_ranges
),
1674 .vsel_reg
= RK817_BUCK4_ON_VSEL_REG
,
1675 .vsel_mask
= RK817_BUCK_VSEL_MASK
,
1676 .enable_reg
= RK817_POWER_EN_REG(0),
1677 .enable_mask
= ENABLE_MASK(RK817_ID_DCDC4
),
1678 .enable_val
= ENABLE_MASK(RK817_ID_DCDC4
),
1679 .disable_val
= DISABLE_VAL(RK817_ID_DCDC4
),
1680 .ramp_reg
= RK817_BUCK_CONFIG_REG(RK817_ID_DCDC4
),
1681 .ramp_mask
= RK817_RAMP_RATE_MASK
,
1682 .ramp_delay_table
= rk817_buck1_4_ramp_table
,
1683 .n_ramp_values
= ARRAY_SIZE(rk817_buck1_4_ramp_table
),
1684 .of_map_mode
= rk8xx_regulator_of_map_mode
,
1685 .owner
= THIS_MODULE
,
1687 RK817_DESC(RK817_ID_LDO1
, "LDO_REG1", "vcc5", 600, 3400, 25,
1688 RK817_LDO_ON_VSEL_REG(0), RK817_LDO_VSEL_MASK
,
1689 RK817_POWER_EN_REG(1), ENABLE_MASK(0),
1690 DISABLE_VAL(0), 400),
1691 RK817_DESC(RK817_ID_LDO2
, "LDO_REG2", "vcc5", 600, 3400, 25,
1692 RK817_LDO_ON_VSEL_REG(1), RK817_LDO_VSEL_MASK
,
1693 RK817_POWER_EN_REG(1), ENABLE_MASK(1),
1694 DISABLE_VAL(1), 400),
1695 RK817_DESC(RK817_ID_LDO3
, "LDO_REG3", "vcc5", 600, 3400, 25,
1696 RK817_LDO_ON_VSEL_REG(2), RK817_LDO_VSEL_MASK
,
1697 RK817_POWER_EN_REG(1), ENABLE_MASK(2),
1698 DISABLE_VAL(2), 400),
1699 RK817_DESC(RK817_ID_LDO4
, "LDO_REG4", "vcc6", 600, 3400, 25,
1700 RK817_LDO_ON_VSEL_REG(3), RK817_LDO_VSEL_MASK
,
1701 RK817_POWER_EN_REG(1), ENABLE_MASK(3),
1702 DISABLE_VAL(3), 400),
1703 RK817_DESC(RK817_ID_LDO5
, "LDO_REG5", "vcc6", 600, 3400, 25,
1704 RK817_LDO_ON_VSEL_REG(4), RK817_LDO_VSEL_MASK
,
1705 RK817_POWER_EN_REG(2), ENABLE_MASK(0),
1706 DISABLE_VAL(0), 400),
1707 RK817_DESC(RK817_ID_LDO6
, "LDO_REG6", "vcc6", 600, 3400, 25,
1708 RK817_LDO_ON_VSEL_REG(5), RK817_LDO_VSEL_MASK
,
1709 RK817_POWER_EN_REG(2), ENABLE_MASK(1),
1710 DISABLE_VAL(1), 400),
1711 RK817_DESC(RK817_ID_LDO7
, "LDO_REG7", "vcc7", 600, 3400, 25,
1712 RK817_LDO_ON_VSEL_REG(6), RK817_LDO_VSEL_MASK
,
1713 RK817_POWER_EN_REG(2), ENABLE_MASK(2),
1714 DISABLE_VAL(2), 400),
1715 RK817_DESC(RK817_ID_LDO8
, "LDO_REG8", "vcc7", 600, 3400, 25,
1716 RK817_LDO_ON_VSEL_REG(7), RK817_LDO_VSEL_MASK
,
1717 RK817_POWER_EN_REG(2), ENABLE_MASK(3),
1718 DISABLE_VAL(3), 400),
1719 RK817_DESC(RK817_ID_LDO9
, "LDO_REG9", "vcc7", 600, 3400, 25,
1720 RK817_LDO_ON_VSEL_REG(8), RK817_LDO_VSEL_MASK
,
1721 RK817_POWER_EN_REG(3), ENABLE_MASK(0),
1722 DISABLE_VAL(0), 400),
1723 RK817_BOOST_DESC(RK817_ID_BOOST
, "BOOST", "vcc8", 4700, 5400, 100,
1724 RK817_BOOST_OTG_CFG
, RK817_BOOST_VSEL_MASK
,
1725 RK817_POWER_EN_REG(3), ENABLE_MASK(1), ENABLE_MASK(1),
1726 DISABLE_VAL(1), 400, 3500 - 5400),
1727 RK817_DESC_SWITCH(RK817_ID_BOOST_OTG_SW
, "OTG_SWITCH", "vcc9",
1728 RK817_POWER_EN_REG(3), ENABLE_MASK(2),
1732 static const struct regulator_desc rk818_reg
[] = {
1734 .name
= "DCDC_REG1",
1735 .supply_name
= "vcc1",
1736 .of_match
= of_match_ptr("DCDC_REG1"),
1737 .regulators_node
= of_match_ptr("regulators"),
1738 .id
= RK818_ID_DCDC1
,
1739 .ops
= &rk808_reg_ops
,
1740 .type
= REGULATOR_VOLTAGE
,
1744 .vsel_reg
= RK818_BUCK1_ON_VSEL_REG
,
1745 .vsel_mask
= RK818_BUCK_VSEL_MASK
,
1746 .enable_reg
= RK818_DCDC_EN_REG
,
1747 .enable_mask
= BIT(0),
1748 .owner
= THIS_MODULE
,
1750 .name
= "DCDC_REG2",
1751 .supply_name
= "vcc2",
1752 .of_match
= of_match_ptr("DCDC_REG2"),
1753 .regulators_node
= of_match_ptr("regulators"),
1754 .id
= RK818_ID_DCDC2
,
1755 .ops
= &rk808_reg_ops
,
1756 .type
= REGULATOR_VOLTAGE
,
1760 .vsel_reg
= RK818_BUCK2_ON_VSEL_REG
,
1761 .vsel_mask
= RK818_BUCK_VSEL_MASK
,
1762 .enable_reg
= RK818_DCDC_EN_REG
,
1763 .enable_mask
= BIT(1),
1764 .owner
= THIS_MODULE
,
1766 .name
= "DCDC_REG3",
1767 .supply_name
= "vcc3",
1768 .of_match
= of_match_ptr("DCDC_REG3"),
1769 .regulators_node
= of_match_ptr("regulators"),
1770 .id
= RK818_ID_DCDC3
,
1771 .ops
= &rk808_switch_ops
,
1772 .type
= REGULATOR_VOLTAGE
,
1774 .enable_reg
= RK818_DCDC_EN_REG
,
1775 .enable_mask
= BIT(2),
1776 .owner
= THIS_MODULE
,
1778 RK8XX_DESC(RK818_ID_DCDC4
, "DCDC_REG4", "vcc4", 1800, 3600, 100,
1779 RK818_BUCK4_ON_VSEL_REG
, RK818_BUCK4_VSEL_MASK
,
1780 RK818_DCDC_EN_REG
, BIT(3), 0),
1781 RK8XX_DESC(RK818_ID_BOOST
, "DCDC_BOOST", "boost", 4700, 5400, 100,
1782 RK818_BOOST_LDO9_ON_VSEL_REG
, RK818_BOOST_ON_VSEL_MASK
,
1783 RK818_DCDC_EN_REG
, BIT(4), 0),
1784 RK8XX_DESC(RK818_ID_LDO1
, "LDO_REG1", "vcc6", 1800, 3400, 100,
1785 RK818_LDO1_ON_VSEL_REG
, RK818_LDO_VSEL_MASK
, RK818_LDO_EN_REG
,
1787 RK8XX_DESC(RK818_ID_LDO2
, "LDO_REG2", "vcc6", 1800, 3400, 100,
1788 RK818_LDO2_ON_VSEL_REG
, RK818_LDO_VSEL_MASK
, RK818_LDO_EN_REG
,
1792 .supply_name
= "vcc7",
1793 .of_match
= of_match_ptr("LDO_REG3"),
1794 .regulators_node
= of_match_ptr("regulators"),
1795 .id
= RK818_ID_LDO3
,
1796 .ops
= &rk808_reg_ops_ranges
,
1797 .type
= REGULATOR_VOLTAGE
,
1799 .linear_ranges
= rk808_ldo3_voltage_ranges
,
1800 .n_linear_ranges
= ARRAY_SIZE(rk808_ldo3_voltage_ranges
),
1801 .vsel_reg
= RK818_LDO3_ON_VSEL_REG
,
1802 .vsel_mask
= RK818_LDO3_ON_VSEL_MASK
,
1803 .enable_reg
= RK818_LDO_EN_REG
,
1804 .enable_mask
= BIT(2),
1806 .owner
= THIS_MODULE
,
1808 RK8XX_DESC(RK818_ID_LDO4
, "LDO_REG4", "vcc8", 1800, 3400, 100,
1809 RK818_LDO4_ON_VSEL_REG
, RK818_LDO_VSEL_MASK
, RK818_LDO_EN_REG
,
1811 RK8XX_DESC(RK818_ID_LDO5
, "LDO_REG5", "vcc7", 1800, 3400, 100,
1812 RK818_LDO5_ON_VSEL_REG
, RK818_LDO_VSEL_MASK
, RK818_LDO_EN_REG
,
1814 RK8XX_DESC(RK818_ID_LDO6
, "LDO_REG6", "vcc8", 800, 2500, 100,
1815 RK818_LDO6_ON_VSEL_REG
, RK818_LDO_VSEL_MASK
, RK818_LDO_EN_REG
,
1817 RK8XX_DESC(RK818_ID_LDO7
, "LDO_REG7", "vcc7", 800, 2500, 100,
1818 RK818_LDO7_ON_VSEL_REG
, RK818_LDO_VSEL_MASK
, RK818_LDO_EN_REG
,
1820 RK8XX_DESC(RK818_ID_LDO8
, "LDO_REG8", "vcc8", 1800, 3400, 100,
1821 RK818_LDO8_ON_VSEL_REG
, RK818_LDO_VSEL_MASK
, RK818_LDO_EN_REG
,
1823 RK8XX_DESC(RK818_ID_LDO9
, "LDO_REG9", "vcc9", 1800, 3400, 100,
1824 RK818_BOOST_LDO9_ON_VSEL_REG
, RK818_LDO_VSEL_MASK
,
1825 RK818_DCDC_EN_REG
, BIT(5), 400),
1826 RK8XX_DESC_SWITCH(RK818_ID_SWITCH
, "SWITCH_REG", "vcc9",
1827 RK818_DCDC_EN_REG
, BIT(6)),
1828 RK8XX_DESC_SWITCH(RK818_ID_HDMI_SWITCH
, "HDMI_SWITCH", "h_5v",
1829 RK818_H5V_EN_REG
, BIT(0)),
1830 RK8XX_DESC_SWITCH(RK818_ID_OTG_SWITCH
, "OTG_SWITCH", "usb",
1831 RK818_DCDC_EN_REG
, BIT(7)),
1834 static int rk808_regulator_dt_parse_pdata(struct device
*dev
, struct regmap
*map
,
1835 struct rk808_regulator_data
*pdata
)
1837 struct device_node
*np
;
1838 int tmp
, ret
= 0, i
;
1840 np
= of_get_child_by_name(dev
->of_node
, "regulators");
1844 for (i
= 0; i
< ARRAY_SIZE(pdata
->dvs_gpio
); i
++) {
1845 pdata
->dvs_gpio
[i
] =
1846 devm_gpiod_get_index_optional(dev
, "dvs", i
, GPIOD_OUT_LOW
);
1847 if (IS_ERR(pdata
->dvs_gpio
[i
])) {
1848 ret
= dev_err_probe(dev
, PTR_ERR(pdata
->dvs_gpio
[i
]),
1849 "failed to get dvs%d gpio\n", i
);
1853 if (!pdata
->dvs_gpio
[i
]) {
1854 dev_dbg(dev
, "there is no dvs%d gpio\n", i
);
1858 tmp
= i
? RK808_DVS2_POL
: RK808_DVS1_POL
;
1859 ret
= regmap_update_bits(map
, RK808_IO_POL_REG
, tmp
,
1860 gpiod_is_active_low(pdata
->dvs_gpio
[i
]) ? 0 : tmp
);
1868 static int rk808_regulator_probe(struct platform_device
*pdev
)
1870 struct rk808
*rk808
= dev_get_drvdata(pdev
->dev
.parent
);
1871 struct regulator_config config
= {};
1872 struct regulator_dev
*rk808_rdev
;
1873 struct rk808_regulator_data
*pdata
;
1874 const struct regulator_desc
*regulators
;
1875 struct regmap
*regmap
;
1876 int ret
, i
, nregulators
;
1878 pdev
->dev
.of_node
= pdev
->dev
.parent
->of_node
;
1879 pdev
->dev
.of_node_reused
= true;
1881 regmap
= dev_get_regmap(pdev
->dev
.parent
, NULL
);
1885 pdata
= devm_kzalloc(&pdev
->dev
, sizeof(*pdata
), GFP_KERNEL
);
1889 switch (rk808
->variant
) {
1891 regulators
= rk805_reg
;
1892 nregulators
= RK805_NUM_REGULATORS
;
1895 regulators
= rk806_reg
;
1896 nregulators
= ARRAY_SIZE(rk806_reg
);
1899 /* DVS0/1 GPIOs are supported on the RK808 only */
1900 ret
= rk808_regulator_dt_parse_pdata(&pdev
->dev
, regmap
, pdata
);
1904 regulators
= rk808_reg
;
1905 nregulators
= RK808_NUM_REGULATORS
;
1908 regulators
= rk809_reg
;
1909 nregulators
= RK809_NUM_REGULATORS
;
1912 regulators
= rk816_reg
;
1913 nregulators
= ARRAY_SIZE(rk816_reg
);
1916 regulators
= rk817_reg
;
1917 nregulators
= RK817_NUM_REGULATORS
;
1920 regulators
= rk818_reg
;
1921 nregulators
= RK818_NUM_REGULATORS
;
1924 return dev_err_probe(&pdev
->dev
, -EINVAL
,
1925 "unsupported RK8xx ID %lu\n", rk808
->variant
);
1928 platform_set_drvdata(pdev
, pdata
);
1930 config
.dev
= &pdev
->dev
;
1931 config
.driver_data
= pdata
;
1932 config
.regmap
= regmap
;
1934 /* Instantiate the regulators */
1935 for (i
= 0; i
< nregulators
; i
++) {
1936 rk808_rdev
= devm_regulator_register(&pdev
->dev
,
1937 ®ulators
[i
], &config
);
1938 if (IS_ERR(rk808_rdev
))
1939 return dev_err_probe(&pdev
->dev
, PTR_ERR(rk808_rdev
),
1940 "failed to register %d regulator\n", i
);
1946 static struct platform_driver rk808_regulator_driver
= {
1947 .probe
= rk808_regulator_probe
,
1949 .name
= "rk808-regulator",
1950 .probe_type
= PROBE_FORCE_SYNCHRONOUS
,
1954 module_platform_driver(rk808_regulator_driver
);
1956 MODULE_DESCRIPTION("Rockchip RK80x/RK81x PMIC series regulator driver");
1957 MODULE_AUTHOR("Tony xie <tony.xie@rock-chips.com>");
1958 MODULE_AUTHOR("Chris Zhong <zyw@rock-chips.com>");
1959 MODULE_AUTHOR("Zhang Qing <zhangqing@rock-chips.com>");
1960 MODULE_AUTHOR("Wadim Egorov <w.egorov@phytec.de>");
1961 MODULE_AUTHOR("Xu Shengfei <xsf@rock-chips.com>");
1962 MODULE_LICENSE("GPL");
1963 MODULE_ALIAS("platform:rk808-regulator");