18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Regulator driver for Rockchip RK805/RK808/RK818
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Author: Chris Zhong <zyw@rock-chips.com>
88c2ecf20Sopenharmony_ci * Author: Zhang Qing <zhangqing@rock-chips.com>
98c2ecf20Sopenharmony_ci *
108c2ecf20Sopenharmony_ci * Copyright (C) 2016 PHYTEC Messtechnik GmbH
118c2ecf20Sopenharmony_ci *
128c2ecf20Sopenharmony_ci * Author: Wadim Egorov <w.egorov@phytec.de>
138c2ecf20Sopenharmony_ci */
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include <linux/delay.h>
168c2ecf20Sopenharmony_ci#include <linux/gpio.h>
178c2ecf20Sopenharmony_ci#include <linux/i2c.h>
188c2ecf20Sopenharmony_ci#include <linux/module.h>
198c2ecf20Sopenharmony_ci#include <linux/of_device.h>
208c2ecf20Sopenharmony_ci#include <linux/of_gpio.h>
218c2ecf20Sopenharmony_ci#include <linux/mfd/rk808.h>
228c2ecf20Sopenharmony_ci#include <linux/regulator/driver.h>
238c2ecf20Sopenharmony_ci#include <linux/regulator/of_regulator.h>
248c2ecf20Sopenharmony_ci#include <linux/gpio/consumer.h>
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci/* Field Definitions */
278c2ecf20Sopenharmony_ci#define RK808_BUCK_VSEL_MASK	0x3f
288c2ecf20Sopenharmony_ci#define RK808_BUCK4_VSEL_MASK	0xf
298c2ecf20Sopenharmony_ci#define RK808_LDO_VSEL_MASK	0x1f
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#define RK809_BUCK5_VSEL_MASK		0x7
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#define RK817_LDO_VSEL_MASK		0x7f
348c2ecf20Sopenharmony_ci#define RK817_BOOST_VSEL_MASK		0x7
358c2ecf20Sopenharmony_ci#define RK817_BUCK_VSEL_MASK		0x7f
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#define RK818_BUCK_VSEL_MASK		0x3f
388c2ecf20Sopenharmony_ci#define RK818_BUCK4_VSEL_MASK		0x1f
398c2ecf20Sopenharmony_ci#define RK818_LDO_VSEL_MASK		0x1f
408c2ecf20Sopenharmony_ci#define RK818_LDO3_ON_VSEL_MASK		0xf
418c2ecf20Sopenharmony_ci#define RK818_BOOST_ON_VSEL_MASK	0xe0
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci/* Ramp rate definitions for buck1 / buck2 only */
448c2ecf20Sopenharmony_ci#define RK808_RAMP_RATE_OFFSET		3
458c2ecf20Sopenharmony_ci#define RK808_RAMP_RATE_MASK		(3 << RK808_RAMP_RATE_OFFSET)
468c2ecf20Sopenharmony_ci#define RK808_RAMP_RATE_2MV_PER_US	(0 << RK808_RAMP_RATE_OFFSET)
478c2ecf20Sopenharmony_ci#define RK808_RAMP_RATE_4MV_PER_US	(1 << RK808_RAMP_RATE_OFFSET)
488c2ecf20Sopenharmony_ci#define RK808_RAMP_RATE_6MV_PER_US	(2 << RK808_RAMP_RATE_OFFSET)
498c2ecf20Sopenharmony_ci#define RK808_RAMP_RATE_10MV_PER_US	(3 << RK808_RAMP_RATE_OFFSET)
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci#define RK808_DVS2_POL		BIT(2)
528c2ecf20Sopenharmony_ci#define RK808_DVS1_POL		BIT(1)
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci/* Offset from XXX_ON_VSEL to XXX_SLP_VSEL */
558c2ecf20Sopenharmony_ci#define RK808_SLP_REG_OFFSET 1
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci/* Offset from XXX_ON_VSEL to XXX_DVS_VSEL */
588c2ecf20Sopenharmony_ci#define RK808_DVS_REG_OFFSET 2
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci/* Offset from XXX_EN_REG to SLEEP_SET_OFF_XXX */
618c2ecf20Sopenharmony_ci#define RK808_SLP_SET_OFF_REG_OFFSET 2
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci/* max steps for increase voltage of Buck1/2, equal 100mv*/
648c2ecf20Sopenharmony_ci#define MAX_STEPS_ONE_TIME 8
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci#define ENABLE_MASK(id)			(BIT(id) | BIT(4 + (id)))
678c2ecf20Sopenharmony_ci#define DISABLE_VAL(id)			(BIT(4 + (id)))
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci#define RK817_BOOST_DESC(_id, _match, _supply, _min, _max, _step, _vreg,\
708c2ecf20Sopenharmony_ci	_vmask, _ereg, _emask, _enval, _disval, _etime, m_drop)		\
718c2ecf20Sopenharmony_ci	{							\
728c2ecf20Sopenharmony_ci		.name		= (_match),				\
738c2ecf20Sopenharmony_ci		.supply_name	= (_supply),				\
748c2ecf20Sopenharmony_ci		.of_match	= of_match_ptr(_match),			\
758c2ecf20Sopenharmony_ci		.regulators_node = of_match_ptr("regulators"),		\
768c2ecf20Sopenharmony_ci		.type		= REGULATOR_VOLTAGE,			\
778c2ecf20Sopenharmony_ci		.id		= (_id),				\
788c2ecf20Sopenharmony_ci		.n_voltages	= (((_max) - (_min)) / (_step) + 1),	\
798c2ecf20Sopenharmony_ci		.owner		= THIS_MODULE,				\
808c2ecf20Sopenharmony_ci		.min_uV		= (_min) * 1000,			\
818c2ecf20Sopenharmony_ci		.uV_step	= (_step) * 1000,			\
828c2ecf20Sopenharmony_ci		.vsel_reg	= (_vreg),				\
838c2ecf20Sopenharmony_ci		.vsel_mask	= (_vmask),				\
848c2ecf20Sopenharmony_ci		.enable_reg	= (_ereg),				\
858c2ecf20Sopenharmony_ci		.enable_mask	= (_emask),				\
868c2ecf20Sopenharmony_ci		.enable_val     = (_enval),				\
878c2ecf20Sopenharmony_ci		.disable_val     = (_disval),				\
888c2ecf20Sopenharmony_ci		.enable_time	= (_etime),				\
898c2ecf20Sopenharmony_ci		.min_dropout_uV = (m_drop) * 1000,			\
908c2ecf20Sopenharmony_ci		.ops		= &rk817_boost_ops,			\
918c2ecf20Sopenharmony_ci	}
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci#define RK8XX_DESC_COM(_id, _match, _supply, _min, _max, _step, _vreg,	\
948c2ecf20Sopenharmony_ci	_vmask, _ereg, _emask, _enval, _disval, _etime, _ops)		\
958c2ecf20Sopenharmony_ci	{								\
968c2ecf20Sopenharmony_ci		.name		= (_match),				\
978c2ecf20Sopenharmony_ci		.supply_name	= (_supply),				\
988c2ecf20Sopenharmony_ci		.of_match	= of_match_ptr(_match),			\
998c2ecf20Sopenharmony_ci		.regulators_node = of_match_ptr("regulators"),		\
1008c2ecf20Sopenharmony_ci		.type		= REGULATOR_VOLTAGE,			\
1018c2ecf20Sopenharmony_ci		.id		= (_id),				\
1028c2ecf20Sopenharmony_ci		.n_voltages	= (((_max) - (_min)) / (_step) + 1),	\
1038c2ecf20Sopenharmony_ci		.owner		= THIS_MODULE,				\
1048c2ecf20Sopenharmony_ci		.min_uV		= (_min) * 1000,			\
1058c2ecf20Sopenharmony_ci		.uV_step	= (_step) * 1000,			\
1068c2ecf20Sopenharmony_ci		.vsel_reg	= (_vreg),				\
1078c2ecf20Sopenharmony_ci		.vsel_mask	= (_vmask),				\
1088c2ecf20Sopenharmony_ci		.enable_reg	= (_ereg),				\
1098c2ecf20Sopenharmony_ci		.enable_mask	= (_emask),				\
1108c2ecf20Sopenharmony_ci		.enable_val     = (_enval),				\
1118c2ecf20Sopenharmony_ci		.disable_val     = (_disval),				\
1128c2ecf20Sopenharmony_ci		.enable_time	= (_etime),				\
1138c2ecf20Sopenharmony_ci		.ops		= _ops,			\
1148c2ecf20Sopenharmony_ci	}
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci#define RK805_DESC(_id, _match, _supply, _min, _max, _step, _vreg,	\
1178c2ecf20Sopenharmony_ci	_vmask, _ereg, _emask, _etime)					\
1188c2ecf20Sopenharmony_ci	RK8XX_DESC_COM(_id, _match, _supply, _min, _max, _step, _vreg,	\
1198c2ecf20Sopenharmony_ci	_vmask, _ereg, _emask, 0, 0, _etime, &rk805_reg_ops)
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci#define RK8XX_DESC(_id, _match, _supply, _min, _max, _step, _vreg,	\
1228c2ecf20Sopenharmony_ci	_vmask, _ereg, _emask, _etime)					\
1238c2ecf20Sopenharmony_ci	RK8XX_DESC_COM(_id, _match, _supply, _min, _max, _step, _vreg,	\
1248c2ecf20Sopenharmony_ci	_vmask, _ereg, _emask, 0, 0, _etime, &rk808_reg_ops)
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci#define RK817_DESC(_id, _match, _supply, _min, _max, _step, _vreg,	\
1278c2ecf20Sopenharmony_ci	_vmask, _ereg, _emask, _disval, _etime)				\
1288c2ecf20Sopenharmony_ci	RK8XX_DESC_COM(_id, _match, _supply, _min, _max, _step, _vreg,	\
1298c2ecf20Sopenharmony_ci	_vmask, _ereg, _emask, _emask, _disval, _etime, &rk817_reg_ops)
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci#define RKXX_DESC_SWITCH_COM(_id, _match, _supply, _ereg, _emask,	\
1328c2ecf20Sopenharmony_ci	_enval, _disval, _ops)						\
1338c2ecf20Sopenharmony_ci	{								\
1348c2ecf20Sopenharmony_ci		.name		= (_match),				\
1358c2ecf20Sopenharmony_ci		.supply_name	= (_supply),				\
1368c2ecf20Sopenharmony_ci		.of_match	= of_match_ptr(_match),			\
1378c2ecf20Sopenharmony_ci		.regulators_node = of_match_ptr("regulators"),		\
1388c2ecf20Sopenharmony_ci		.type		= REGULATOR_VOLTAGE,			\
1398c2ecf20Sopenharmony_ci		.id		= (_id),				\
1408c2ecf20Sopenharmony_ci		.enable_reg	= (_ereg),				\
1418c2ecf20Sopenharmony_ci		.enable_mask	= (_emask),				\
1428c2ecf20Sopenharmony_ci		.enable_val     = (_enval),				\
1438c2ecf20Sopenharmony_ci		.disable_val     = (_disval),				\
1448c2ecf20Sopenharmony_ci		.owner		= THIS_MODULE,				\
1458c2ecf20Sopenharmony_ci		.ops		= _ops					\
1468c2ecf20Sopenharmony_ci	}
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci#define RK817_DESC_SWITCH(_id, _match, _supply, _ereg, _emask,		\
1498c2ecf20Sopenharmony_ci	_disval)							\
1508c2ecf20Sopenharmony_ci	RKXX_DESC_SWITCH_COM(_id, _match, _supply, _ereg, _emask,	\
1518c2ecf20Sopenharmony_ci	_emask, _disval, &rk817_switch_ops)
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci#define RK8XX_DESC_SWITCH(_id, _match, _supply, _ereg, _emask)		\
1548c2ecf20Sopenharmony_ci	RKXX_DESC_SWITCH_COM(_id, _match, _supply, _ereg, _emask,	\
1558c2ecf20Sopenharmony_ci	0, 0, &rk808_switch_ops)
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_cistruct rk808_regulator_data {
1588c2ecf20Sopenharmony_ci	struct gpio_desc *dvs_gpio[2];
1598c2ecf20Sopenharmony_ci};
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_cistatic const int rk808_buck_config_regs[] = {
1628c2ecf20Sopenharmony_ci	RK808_BUCK1_CONFIG_REG,
1638c2ecf20Sopenharmony_ci	RK808_BUCK2_CONFIG_REG,
1648c2ecf20Sopenharmony_ci	RK808_BUCK3_CONFIG_REG,
1658c2ecf20Sopenharmony_ci	RK808_BUCK4_CONFIG_REG,
1668c2ecf20Sopenharmony_ci};
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_cistatic const struct linear_range rk808_ldo3_voltage_ranges[] = {
1698c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(800000, 0, 13, 100000),
1708c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(2500000, 15, 15, 0),
1718c2ecf20Sopenharmony_ci};
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ci#define RK809_BUCK5_SEL_CNT		(8)
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_cistatic const struct linear_range rk809_buck5_voltage_ranges[] = {
1768c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1500000, 0, 0, 0),
1778c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1800000, 1, 3, 200000),
1788c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(2800000, 4, 5, 200000),
1798c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(3300000, 6, 7, 300000),
1808c2ecf20Sopenharmony_ci};
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci#define RK817_BUCK1_MIN0 500000
1838c2ecf20Sopenharmony_ci#define RK817_BUCK1_MAX0 1500000
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci#define RK817_BUCK1_MIN1 1600000
1868c2ecf20Sopenharmony_ci#define RK817_BUCK1_MAX1 2400000
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_ci#define RK817_BUCK3_MAX1 3400000
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_ci#define RK817_BUCK1_STP0 12500
1918c2ecf20Sopenharmony_ci#define RK817_BUCK1_STP1 100000
1928c2ecf20Sopenharmony_ci
1938c2ecf20Sopenharmony_ci#define RK817_BUCK1_SEL0 ((RK817_BUCK1_MAX0 - RK817_BUCK1_MIN0) /\
1948c2ecf20Sopenharmony_ci						  RK817_BUCK1_STP0)
1958c2ecf20Sopenharmony_ci#define RK817_BUCK1_SEL1 ((RK817_BUCK1_MAX1 - RK817_BUCK1_MIN1) /\
1968c2ecf20Sopenharmony_ci						  RK817_BUCK1_STP1)
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_ci#define RK817_BUCK3_SEL1 ((RK817_BUCK3_MAX1 - RK817_BUCK1_MIN1) /\
1998c2ecf20Sopenharmony_ci						  RK817_BUCK1_STP1)
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci#define RK817_BUCK1_SEL_CNT (RK817_BUCK1_SEL0 + RK817_BUCK1_SEL1 + 1)
2028c2ecf20Sopenharmony_ci#define RK817_BUCK3_SEL_CNT (RK817_BUCK1_SEL0 + RK817_BUCK3_SEL1 + 1)
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_cistatic const struct linear_range rk817_buck1_voltage_ranges[] = {
2058c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(RK817_BUCK1_MIN0, 0,
2068c2ecf20Sopenharmony_ci			       RK817_BUCK1_SEL0, RK817_BUCK1_STP0),
2078c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(RK817_BUCK1_MIN1, RK817_BUCK1_SEL0 + 1,
2088c2ecf20Sopenharmony_ci			       RK817_BUCK1_SEL_CNT, RK817_BUCK1_STP1),
2098c2ecf20Sopenharmony_ci};
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_cistatic const struct linear_range rk817_buck3_voltage_ranges[] = {
2128c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(RK817_BUCK1_MIN0, 0,
2138c2ecf20Sopenharmony_ci			       RK817_BUCK1_SEL0, RK817_BUCK1_STP0),
2148c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(RK817_BUCK1_MIN1, RK817_BUCK1_SEL0 + 1,
2158c2ecf20Sopenharmony_ci			       RK817_BUCK3_SEL_CNT, RK817_BUCK1_STP1),
2168c2ecf20Sopenharmony_ci};
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_cistatic int rk808_buck1_2_get_voltage_sel_regmap(struct regulator_dev *rdev)
2198c2ecf20Sopenharmony_ci{
2208c2ecf20Sopenharmony_ci	struct rk808_regulator_data *pdata = rdev_get_drvdata(rdev);
2218c2ecf20Sopenharmony_ci	int id = rdev_get_id(rdev);
2228c2ecf20Sopenharmony_ci	struct gpio_desc *gpio = pdata->dvs_gpio[id];
2238c2ecf20Sopenharmony_ci	unsigned int val;
2248c2ecf20Sopenharmony_ci	int ret;
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_ci	if (!gpio || gpiod_get_value(gpio) == 0)
2278c2ecf20Sopenharmony_ci		return regulator_get_voltage_sel_regmap(rdev);
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_ci	ret = regmap_read(rdev->regmap,
2308c2ecf20Sopenharmony_ci			  rdev->desc->vsel_reg + RK808_DVS_REG_OFFSET,
2318c2ecf20Sopenharmony_ci			  &val);
2328c2ecf20Sopenharmony_ci	if (ret != 0)
2338c2ecf20Sopenharmony_ci		return ret;
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_ci	val &= rdev->desc->vsel_mask;
2368c2ecf20Sopenharmony_ci	val >>= ffs(rdev->desc->vsel_mask) - 1;
2378c2ecf20Sopenharmony_ci
2388c2ecf20Sopenharmony_ci	return val;
2398c2ecf20Sopenharmony_ci}
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_cistatic int rk808_buck1_2_i2c_set_voltage_sel(struct regulator_dev *rdev,
2428c2ecf20Sopenharmony_ci					     unsigned sel)
2438c2ecf20Sopenharmony_ci{
2448c2ecf20Sopenharmony_ci	int ret, delta_sel;
2458c2ecf20Sopenharmony_ci	unsigned int old_sel, tmp, val, mask = rdev->desc->vsel_mask;
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_ci	ret = regmap_read(rdev->regmap, rdev->desc->vsel_reg, &val);
2488c2ecf20Sopenharmony_ci	if (ret != 0)
2498c2ecf20Sopenharmony_ci		return ret;
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_ci	tmp = val & ~mask;
2528c2ecf20Sopenharmony_ci	old_sel = val & mask;
2538c2ecf20Sopenharmony_ci	old_sel >>= ffs(mask) - 1;
2548c2ecf20Sopenharmony_ci	delta_sel = sel - old_sel;
2558c2ecf20Sopenharmony_ci
2568c2ecf20Sopenharmony_ci	/*
2578c2ecf20Sopenharmony_ci	 * If directly modify the register to change the voltage, we will face
2588c2ecf20Sopenharmony_ci	 * the risk of overshoot. Put it into a multi-step, can effectively
2598c2ecf20Sopenharmony_ci	 * avoid this problem, a step is 100mv here.
2608c2ecf20Sopenharmony_ci	 */
2618c2ecf20Sopenharmony_ci	while (delta_sel > MAX_STEPS_ONE_TIME) {
2628c2ecf20Sopenharmony_ci		old_sel += MAX_STEPS_ONE_TIME;
2638c2ecf20Sopenharmony_ci		val = old_sel << (ffs(mask) - 1);
2648c2ecf20Sopenharmony_ci		val |= tmp;
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ci		/*
2678c2ecf20Sopenharmony_ci		 * i2c is 400kHz (2.5us per bit) and we must transmit _at least_
2688c2ecf20Sopenharmony_ci		 * 3 bytes (24 bits) plus start and stop so 26 bits.  So we've
2698c2ecf20Sopenharmony_ci		 * got more than 65 us between each voltage change and thus
2708c2ecf20Sopenharmony_ci		 * won't ramp faster than ~1500 uV / us.
2718c2ecf20Sopenharmony_ci		 */
2728c2ecf20Sopenharmony_ci		ret = regmap_write(rdev->regmap, rdev->desc->vsel_reg, val);
2738c2ecf20Sopenharmony_ci		delta_sel = sel - old_sel;
2748c2ecf20Sopenharmony_ci	}
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci	sel <<= ffs(mask) - 1;
2778c2ecf20Sopenharmony_ci	val = tmp | sel;
2788c2ecf20Sopenharmony_ci	ret = regmap_write(rdev->regmap, rdev->desc->vsel_reg, val);
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ci	/*
2818c2ecf20Sopenharmony_ci	 * When we change the voltage register directly, the ramp rate is about
2828c2ecf20Sopenharmony_ci	 * 100000uv/us, wait 1us to make sure the target voltage to be stable,
2838c2ecf20Sopenharmony_ci	 * so we needn't wait extra time after that.
2848c2ecf20Sopenharmony_ci	 */
2858c2ecf20Sopenharmony_ci	udelay(1);
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_ci	return ret;
2888c2ecf20Sopenharmony_ci}
2898c2ecf20Sopenharmony_ci
2908c2ecf20Sopenharmony_cistatic int rk808_buck1_2_set_voltage_sel(struct regulator_dev *rdev,
2918c2ecf20Sopenharmony_ci					 unsigned sel)
2928c2ecf20Sopenharmony_ci{
2938c2ecf20Sopenharmony_ci	struct rk808_regulator_data *pdata = rdev_get_drvdata(rdev);
2948c2ecf20Sopenharmony_ci	int id = rdev_get_id(rdev);
2958c2ecf20Sopenharmony_ci	struct gpio_desc *gpio = pdata->dvs_gpio[id];
2968c2ecf20Sopenharmony_ci	unsigned int reg = rdev->desc->vsel_reg;
2978c2ecf20Sopenharmony_ci	unsigned old_sel;
2988c2ecf20Sopenharmony_ci	int ret, gpio_level;
2998c2ecf20Sopenharmony_ci
3008c2ecf20Sopenharmony_ci	if (!gpio)
3018c2ecf20Sopenharmony_ci		return rk808_buck1_2_i2c_set_voltage_sel(rdev, sel);
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_ci	gpio_level = gpiod_get_value(gpio);
3048c2ecf20Sopenharmony_ci	if (gpio_level == 0) {
3058c2ecf20Sopenharmony_ci		reg += RK808_DVS_REG_OFFSET;
3068c2ecf20Sopenharmony_ci		ret = regmap_read(rdev->regmap, rdev->desc->vsel_reg, &old_sel);
3078c2ecf20Sopenharmony_ci	} else {
3088c2ecf20Sopenharmony_ci		ret = regmap_read(rdev->regmap,
3098c2ecf20Sopenharmony_ci				  reg + RK808_DVS_REG_OFFSET,
3108c2ecf20Sopenharmony_ci				  &old_sel);
3118c2ecf20Sopenharmony_ci	}
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci	if (ret != 0)
3148c2ecf20Sopenharmony_ci		return ret;
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_ci	sel <<= ffs(rdev->desc->vsel_mask) - 1;
3178c2ecf20Sopenharmony_ci	sel |= old_sel & ~rdev->desc->vsel_mask;
3188c2ecf20Sopenharmony_ci
3198c2ecf20Sopenharmony_ci	ret = regmap_write(rdev->regmap, reg, sel);
3208c2ecf20Sopenharmony_ci	if (ret)
3218c2ecf20Sopenharmony_ci		return ret;
3228c2ecf20Sopenharmony_ci
3238c2ecf20Sopenharmony_ci	gpiod_set_value(gpio, !gpio_level);
3248c2ecf20Sopenharmony_ci
3258c2ecf20Sopenharmony_ci	return ret;
3268c2ecf20Sopenharmony_ci}
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_cistatic int rk808_buck1_2_set_voltage_time_sel(struct regulator_dev *rdev,
3298c2ecf20Sopenharmony_ci				       unsigned int old_selector,
3308c2ecf20Sopenharmony_ci				       unsigned int new_selector)
3318c2ecf20Sopenharmony_ci{
3328c2ecf20Sopenharmony_ci	struct rk808_regulator_data *pdata = rdev_get_drvdata(rdev);
3338c2ecf20Sopenharmony_ci	int id = rdev_get_id(rdev);
3348c2ecf20Sopenharmony_ci	struct gpio_desc *gpio = pdata->dvs_gpio[id];
3358c2ecf20Sopenharmony_ci
3368c2ecf20Sopenharmony_ci	/* if there is no dvs1/2 pin, we don't need wait extra time here. */
3378c2ecf20Sopenharmony_ci	if (!gpio)
3388c2ecf20Sopenharmony_ci		return 0;
3398c2ecf20Sopenharmony_ci
3408c2ecf20Sopenharmony_ci	return regulator_set_voltage_time_sel(rdev, old_selector, new_selector);
3418c2ecf20Sopenharmony_ci}
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_cistatic int rk808_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
3448c2ecf20Sopenharmony_ci{
3458c2ecf20Sopenharmony_ci	unsigned int ramp_value = RK808_RAMP_RATE_10MV_PER_US;
3468c2ecf20Sopenharmony_ci	unsigned int reg = rk808_buck_config_regs[rdev_get_id(rdev)];
3478c2ecf20Sopenharmony_ci
3488c2ecf20Sopenharmony_ci	switch (ramp_delay) {
3498c2ecf20Sopenharmony_ci	case 1 ... 2000:
3508c2ecf20Sopenharmony_ci		ramp_value = RK808_RAMP_RATE_2MV_PER_US;
3518c2ecf20Sopenharmony_ci		break;
3528c2ecf20Sopenharmony_ci	case 2001 ... 4000:
3538c2ecf20Sopenharmony_ci		ramp_value = RK808_RAMP_RATE_4MV_PER_US;
3548c2ecf20Sopenharmony_ci		break;
3558c2ecf20Sopenharmony_ci	case 4001 ... 6000:
3568c2ecf20Sopenharmony_ci		ramp_value = RK808_RAMP_RATE_6MV_PER_US;
3578c2ecf20Sopenharmony_ci		break;
3588c2ecf20Sopenharmony_ci	case 6001 ... 10000:
3598c2ecf20Sopenharmony_ci		break;
3608c2ecf20Sopenharmony_ci	default:
3618c2ecf20Sopenharmony_ci		pr_warn("%s ramp_delay: %d not supported, setting 10000\n",
3628c2ecf20Sopenharmony_ci			rdev->desc->name, ramp_delay);
3638c2ecf20Sopenharmony_ci	}
3648c2ecf20Sopenharmony_ci
3658c2ecf20Sopenharmony_ci	return regmap_update_bits(rdev->regmap, reg,
3668c2ecf20Sopenharmony_ci				  RK808_RAMP_RATE_MASK, ramp_value);
3678c2ecf20Sopenharmony_ci}
3688c2ecf20Sopenharmony_ci
3698c2ecf20Sopenharmony_ci/*
3708c2ecf20Sopenharmony_ci * RK817 RK809
3718c2ecf20Sopenharmony_ci */
3728c2ecf20Sopenharmony_cistatic int rk817_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
3738c2ecf20Sopenharmony_ci{
3748c2ecf20Sopenharmony_ci	unsigned int ramp_value = RK817_RAMP_RATE_25MV_PER_US;
3758c2ecf20Sopenharmony_ci	unsigned int reg = RK817_BUCK_CONFIG_REG(rdev_get_id(rdev));
3768c2ecf20Sopenharmony_ci
3778c2ecf20Sopenharmony_ci	switch (ramp_delay) {
3788c2ecf20Sopenharmony_ci	case 0 ... 3000:
3798c2ecf20Sopenharmony_ci		ramp_value = RK817_RAMP_RATE_3MV_PER_US;
3808c2ecf20Sopenharmony_ci		break;
3818c2ecf20Sopenharmony_ci	case 3001 ... 6300:
3828c2ecf20Sopenharmony_ci		ramp_value = RK817_RAMP_RATE_6_3MV_PER_US;
3838c2ecf20Sopenharmony_ci		break;
3848c2ecf20Sopenharmony_ci	case 6301 ... 12500:
3858c2ecf20Sopenharmony_ci		ramp_value = RK817_RAMP_RATE_12_5MV_PER_US;
3868c2ecf20Sopenharmony_ci		break;
3878c2ecf20Sopenharmony_ci	case 12501 ... 25000:
3888c2ecf20Sopenharmony_ci		break;
3898c2ecf20Sopenharmony_ci	default:
3908c2ecf20Sopenharmony_ci		dev_warn(&rdev->dev,
3918c2ecf20Sopenharmony_ci			 "%s ramp_delay: %d not supported, setting 25000\n",
3928c2ecf20Sopenharmony_ci			 rdev->desc->name, ramp_delay);
3938c2ecf20Sopenharmony_ci	}
3948c2ecf20Sopenharmony_ci
3958c2ecf20Sopenharmony_ci	return regmap_update_bits(rdev->regmap, reg,
3968c2ecf20Sopenharmony_ci				  RK817_RAMP_RATE_MASK, ramp_value);
3978c2ecf20Sopenharmony_ci}
3988c2ecf20Sopenharmony_ci
3998c2ecf20Sopenharmony_cistatic int rk808_set_suspend_voltage(struct regulator_dev *rdev, int uv)
4008c2ecf20Sopenharmony_ci{
4018c2ecf20Sopenharmony_ci	unsigned int reg;
4028c2ecf20Sopenharmony_ci	int sel = regulator_map_voltage_linear(rdev, uv, uv);
4038c2ecf20Sopenharmony_ci
4048c2ecf20Sopenharmony_ci	if (sel < 0)
4058c2ecf20Sopenharmony_ci		return -EINVAL;
4068c2ecf20Sopenharmony_ci
4078c2ecf20Sopenharmony_ci	reg = rdev->desc->vsel_reg + RK808_SLP_REG_OFFSET;
4088c2ecf20Sopenharmony_ci
4098c2ecf20Sopenharmony_ci	return regmap_update_bits(rdev->regmap, reg,
4108c2ecf20Sopenharmony_ci				  rdev->desc->vsel_mask,
4118c2ecf20Sopenharmony_ci				  sel);
4128c2ecf20Sopenharmony_ci}
4138c2ecf20Sopenharmony_ci
4148c2ecf20Sopenharmony_cistatic int rk808_set_suspend_voltage_range(struct regulator_dev *rdev, int uv)
4158c2ecf20Sopenharmony_ci{
4168c2ecf20Sopenharmony_ci	unsigned int reg;
4178c2ecf20Sopenharmony_ci	int sel = regulator_map_voltage_linear_range(rdev, uv, uv);
4188c2ecf20Sopenharmony_ci
4198c2ecf20Sopenharmony_ci	if (sel < 0)
4208c2ecf20Sopenharmony_ci		return -EINVAL;
4218c2ecf20Sopenharmony_ci
4228c2ecf20Sopenharmony_ci	reg = rdev->desc->vsel_reg + RK808_SLP_REG_OFFSET;
4238c2ecf20Sopenharmony_ci
4248c2ecf20Sopenharmony_ci	return regmap_update_bits(rdev->regmap, reg,
4258c2ecf20Sopenharmony_ci				  rdev->desc->vsel_mask,
4268c2ecf20Sopenharmony_ci				  sel);
4278c2ecf20Sopenharmony_ci}
4288c2ecf20Sopenharmony_ci
4298c2ecf20Sopenharmony_cistatic int rk805_set_suspend_enable(struct regulator_dev *rdev)
4308c2ecf20Sopenharmony_ci{
4318c2ecf20Sopenharmony_ci	unsigned int reg;
4328c2ecf20Sopenharmony_ci
4338c2ecf20Sopenharmony_ci	reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET;
4348c2ecf20Sopenharmony_ci
4358c2ecf20Sopenharmony_ci	return regmap_update_bits(rdev->regmap, reg,
4368c2ecf20Sopenharmony_ci				  rdev->desc->enable_mask,
4378c2ecf20Sopenharmony_ci				  rdev->desc->enable_mask);
4388c2ecf20Sopenharmony_ci}
4398c2ecf20Sopenharmony_ci
4408c2ecf20Sopenharmony_cistatic int rk805_set_suspend_disable(struct regulator_dev *rdev)
4418c2ecf20Sopenharmony_ci{
4428c2ecf20Sopenharmony_ci	unsigned int reg;
4438c2ecf20Sopenharmony_ci
4448c2ecf20Sopenharmony_ci	reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET;
4458c2ecf20Sopenharmony_ci
4468c2ecf20Sopenharmony_ci	return regmap_update_bits(rdev->regmap, reg,
4478c2ecf20Sopenharmony_ci				  rdev->desc->enable_mask,
4488c2ecf20Sopenharmony_ci				  0);
4498c2ecf20Sopenharmony_ci}
4508c2ecf20Sopenharmony_ci
4518c2ecf20Sopenharmony_cistatic int rk808_set_suspend_enable(struct regulator_dev *rdev)
4528c2ecf20Sopenharmony_ci{
4538c2ecf20Sopenharmony_ci	unsigned int reg;
4548c2ecf20Sopenharmony_ci
4558c2ecf20Sopenharmony_ci	reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET;
4568c2ecf20Sopenharmony_ci
4578c2ecf20Sopenharmony_ci	return regmap_update_bits(rdev->regmap, reg,
4588c2ecf20Sopenharmony_ci				  rdev->desc->enable_mask,
4598c2ecf20Sopenharmony_ci				  0);
4608c2ecf20Sopenharmony_ci}
4618c2ecf20Sopenharmony_ci
4628c2ecf20Sopenharmony_cistatic int rk808_set_suspend_disable(struct regulator_dev *rdev)
4638c2ecf20Sopenharmony_ci{
4648c2ecf20Sopenharmony_ci	unsigned int reg;
4658c2ecf20Sopenharmony_ci
4668c2ecf20Sopenharmony_ci	reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET;
4678c2ecf20Sopenharmony_ci
4688c2ecf20Sopenharmony_ci	return regmap_update_bits(rdev->regmap, reg,
4698c2ecf20Sopenharmony_ci				  rdev->desc->enable_mask,
4708c2ecf20Sopenharmony_ci				  rdev->desc->enable_mask);
4718c2ecf20Sopenharmony_ci}
4728c2ecf20Sopenharmony_ci
4738c2ecf20Sopenharmony_cistatic int rk817_set_suspend_enable_ctrl(struct regulator_dev *rdev,
4748c2ecf20Sopenharmony_ci					 unsigned int en)
4758c2ecf20Sopenharmony_ci{
4768c2ecf20Sopenharmony_ci	unsigned int reg;
4778c2ecf20Sopenharmony_ci	int id = rdev_get_id(rdev);
4788c2ecf20Sopenharmony_ci	unsigned int id_slp, msk, val;
4798c2ecf20Sopenharmony_ci
4808c2ecf20Sopenharmony_ci	if (id >= RK817_ID_DCDC1 && id <= RK817_ID_DCDC4)
4818c2ecf20Sopenharmony_ci		id_slp = id;
4828c2ecf20Sopenharmony_ci	else if (id >= RK817_ID_LDO1 && id <= RK817_ID_LDO8)
4838c2ecf20Sopenharmony_ci		id_slp = 8 + (id - RK817_ID_LDO1);
4848c2ecf20Sopenharmony_ci	else if (id >= RK817_ID_LDO9 && id <= RK809_ID_SW2)
4858c2ecf20Sopenharmony_ci		id_slp = 4 + (id - RK817_ID_LDO9);
4868c2ecf20Sopenharmony_ci	else
4878c2ecf20Sopenharmony_ci		return -EINVAL;
4888c2ecf20Sopenharmony_ci
4898c2ecf20Sopenharmony_ci	reg = RK817_POWER_SLP_EN_REG(id_slp / 8);
4908c2ecf20Sopenharmony_ci
4918c2ecf20Sopenharmony_ci	msk = BIT(id_slp % 8);
4928c2ecf20Sopenharmony_ci	if (en)
4938c2ecf20Sopenharmony_ci		val = msk;
4948c2ecf20Sopenharmony_ci	else
4958c2ecf20Sopenharmony_ci		val = 0;
4968c2ecf20Sopenharmony_ci
4978c2ecf20Sopenharmony_ci	return regmap_update_bits(rdev->regmap, reg, msk, val);
4988c2ecf20Sopenharmony_ci}
4998c2ecf20Sopenharmony_ci
5008c2ecf20Sopenharmony_cistatic int rk817_set_suspend_enable(struct regulator_dev *rdev)
5018c2ecf20Sopenharmony_ci{
5028c2ecf20Sopenharmony_ci	return rk817_set_suspend_enable_ctrl(rdev, 1);
5038c2ecf20Sopenharmony_ci}
5048c2ecf20Sopenharmony_ci
5058c2ecf20Sopenharmony_cistatic int rk817_set_suspend_disable(struct regulator_dev *rdev)
5068c2ecf20Sopenharmony_ci{
5078c2ecf20Sopenharmony_ci	return rk817_set_suspend_enable_ctrl(rdev, 0);
5088c2ecf20Sopenharmony_ci}
5098c2ecf20Sopenharmony_ci
5108c2ecf20Sopenharmony_cistatic int rk8xx_set_suspend_mode(struct regulator_dev *rdev, unsigned int mode)
5118c2ecf20Sopenharmony_ci{
5128c2ecf20Sopenharmony_ci	unsigned int reg;
5138c2ecf20Sopenharmony_ci
5148c2ecf20Sopenharmony_ci	reg = rdev->desc->vsel_reg + RK808_SLP_REG_OFFSET;
5158c2ecf20Sopenharmony_ci
5168c2ecf20Sopenharmony_ci	switch (mode) {
5178c2ecf20Sopenharmony_ci	case REGULATOR_MODE_FAST:
5188c2ecf20Sopenharmony_ci		return regmap_update_bits(rdev->regmap, reg,
5198c2ecf20Sopenharmony_ci					  PWM_MODE_MSK, FPWM_MODE);
5208c2ecf20Sopenharmony_ci	case REGULATOR_MODE_NORMAL:
5218c2ecf20Sopenharmony_ci		return regmap_update_bits(rdev->regmap, reg,
5228c2ecf20Sopenharmony_ci					  PWM_MODE_MSK, AUTO_PWM_MODE);
5238c2ecf20Sopenharmony_ci	default:
5248c2ecf20Sopenharmony_ci		dev_err(&rdev->dev, "do not support this mode\n");
5258c2ecf20Sopenharmony_ci		return -EINVAL;
5268c2ecf20Sopenharmony_ci	}
5278c2ecf20Sopenharmony_ci
5288c2ecf20Sopenharmony_ci	return 0;
5298c2ecf20Sopenharmony_ci}
5308c2ecf20Sopenharmony_ci
5318c2ecf20Sopenharmony_cistatic int rk8xx_set_mode(struct regulator_dev *rdev, unsigned int mode)
5328c2ecf20Sopenharmony_ci{
5338c2ecf20Sopenharmony_ci	switch (mode) {
5348c2ecf20Sopenharmony_ci	case REGULATOR_MODE_FAST:
5358c2ecf20Sopenharmony_ci		return regmap_update_bits(rdev->regmap, rdev->desc->vsel_reg,
5368c2ecf20Sopenharmony_ci					  PWM_MODE_MSK, FPWM_MODE);
5378c2ecf20Sopenharmony_ci	case REGULATOR_MODE_NORMAL:
5388c2ecf20Sopenharmony_ci		return regmap_update_bits(rdev->regmap, rdev->desc->vsel_reg,
5398c2ecf20Sopenharmony_ci					  PWM_MODE_MSK, AUTO_PWM_MODE);
5408c2ecf20Sopenharmony_ci	default:
5418c2ecf20Sopenharmony_ci		dev_err(&rdev->dev, "do not support this mode\n");
5428c2ecf20Sopenharmony_ci		return -EINVAL;
5438c2ecf20Sopenharmony_ci	}
5448c2ecf20Sopenharmony_ci
5458c2ecf20Sopenharmony_ci	return 0;
5468c2ecf20Sopenharmony_ci}
5478c2ecf20Sopenharmony_ci
5488c2ecf20Sopenharmony_cistatic unsigned int rk8xx_get_mode(struct regulator_dev *rdev)
5498c2ecf20Sopenharmony_ci{
5508c2ecf20Sopenharmony_ci	unsigned int val;
5518c2ecf20Sopenharmony_ci	int err;
5528c2ecf20Sopenharmony_ci
5538c2ecf20Sopenharmony_ci	err = regmap_read(rdev->regmap, rdev->desc->vsel_reg, &val);
5548c2ecf20Sopenharmony_ci	if (err)
5558c2ecf20Sopenharmony_ci		return err;
5568c2ecf20Sopenharmony_ci
5578c2ecf20Sopenharmony_ci	if (val & FPWM_MODE)
5588c2ecf20Sopenharmony_ci		return REGULATOR_MODE_FAST;
5598c2ecf20Sopenharmony_ci	else
5608c2ecf20Sopenharmony_ci		return REGULATOR_MODE_NORMAL;
5618c2ecf20Sopenharmony_ci}
5628c2ecf20Sopenharmony_ci
5638c2ecf20Sopenharmony_cistatic int rk8xx_is_enabled_wmsk_regmap(struct regulator_dev *rdev)
5648c2ecf20Sopenharmony_ci{
5658c2ecf20Sopenharmony_ci	unsigned int val;
5668c2ecf20Sopenharmony_ci	int ret;
5678c2ecf20Sopenharmony_ci
5688c2ecf20Sopenharmony_ci	ret = regmap_read(rdev->regmap, rdev->desc->enable_reg, &val);
5698c2ecf20Sopenharmony_ci	if (ret != 0)
5708c2ecf20Sopenharmony_ci		return ret;
5718c2ecf20Sopenharmony_ci
5728c2ecf20Sopenharmony_ci	/* add write mask bit */
5738c2ecf20Sopenharmony_ci	val |= (rdev->desc->enable_mask & 0xf0);
5748c2ecf20Sopenharmony_ci	val &= rdev->desc->enable_mask;
5758c2ecf20Sopenharmony_ci
5768c2ecf20Sopenharmony_ci	if (rdev->desc->enable_is_inverted) {
5778c2ecf20Sopenharmony_ci		if (rdev->desc->enable_val)
5788c2ecf20Sopenharmony_ci			return val != rdev->desc->enable_val;
5798c2ecf20Sopenharmony_ci		return (val == 0);
5808c2ecf20Sopenharmony_ci	}
5818c2ecf20Sopenharmony_ci	if (rdev->desc->enable_val)
5828c2ecf20Sopenharmony_ci		return val == rdev->desc->enable_val;
5838c2ecf20Sopenharmony_ci	return val != 0;
5848c2ecf20Sopenharmony_ci}
5858c2ecf20Sopenharmony_ci
5868c2ecf20Sopenharmony_cistatic unsigned int rk8xx_regulator_of_map_mode(unsigned int mode)
5878c2ecf20Sopenharmony_ci{
5888c2ecf20Sopenharmony_ci	switch (mode) {
5898c2ecf20Sopenharmony_ci	case 1:
5908c2ecf20Sopenharmony_ci		return REGULATOR_MODE_FAST;
5918c2ecf20Sopenharmony_ci	case 2:
5928c2ecf20Sopenharmony_ci		return REGULATOR_MODE_NORMAL;
5938c2ecf20Sopenharmony_ci	default:
5948c2ecf20Sopenharmony_ci		return REGULATOR_MODE_INVALID;
5958c2ecf20Sopenharmony_ci	}
5968c2ecf20Sopenharmony_ci}
5978c2ecf20Sopenharmony_ci
5988c2ecf20Sopenharmony_cistatic const struct regulator_ops rk805_reg_ops = {
5998c2ecf20Sopenharmony_ci	.list_voltage           = regulator_list_voltage_linear,
6008c2ecf20Sopenharmony_ci	.map_voltage            = regulator_map_voltage_linear,
6018c2ecf20Sopenharmony_ci	.get_voltage_sel        = regulator_get_voltage_sel_regmap,
6028c2ecf20Sopenharmony_ci	.set_voltage_sel        = regulator_set_voltage_sel_regmap,
6038c2ecf20Sopenharmony_ci	.enable                 = regulator_enable_regmap,
6048c2ecf20Sopenharmony_ci	.disable                = regulator_disable_regmap,
6058c2ecf20Sopenharmony_ci	.is_enabled             = regulator_is_enabled_regmap,
6068c2ecf20Sopenharmony_ci	.set_suspend_voltage    = rk808_set_suspend_voltage,
6078c2ecf20Sopenharmony_ci	.set_suspend_enable     = rk805_set_suspend_enable,
6088c2ecf20Sopenharmony_ci	.set_suspend_disable    = rk805_set_suspend_disable,
6098c2ecf20Sopenharmony_ci};
6108c2ecf20Sopenharmony_ci
6118c2ecf20Sopenharmony_cistatic const struct regulator_ops rk805_switch_ops = {
6128c2ecf20Sopenharmony_ci	.enable                 = regulator_enable_regmap,
6138c2ecf20Sopenharmony_ci	.disable                = regulator_disable_regmap,
6148c2ecf20Sopenharmony_ci	.is_enabled             = regulator_is_enabled_regmap,
6158c2ecf20Sopenharmony_ci	.set_suspend_enable     = rk805_set_suspend_enable,
6168c2ecf20Sopenharmony_ci	.set_suspend_disable    = rk805_set_suspend_disable,
6178c2ecf20Sopenharmony_ci};
6188c2ecf20Sopenharmony_ci
6198c2ecf20Sopenharmony_cistatic const struct regulator_ops rk808_buck1_2_ops = {
6208c2ecf20Sopenharmony_ci	.list_voltage		= regulator_list_voltage_linear,
6218c2ecf20Sopenharmony_ci	.map_voltage		= regulator_map_voltage_linear,
6228c2ecf20Sopenharmony_ci	.get_voltage_sel	= rk808_buck1_2_get_voltage_sel_regmap,
6238c2ecf20Sopenharmony_ci	.set_voltage_sel	= rk808_buck1_2_set_voltage_sel,
6248c2ecf20Sopenharmony_ci	.set_voltage_time_sel	= rk808_buck1_2_set_voltage_time_sel,
6258c2ecf20Sopenharmony_ci	.enable			= regulator_enable_regmap,
6268c2ecf20Sopenharmony_ci	.disable		= regulator_disable_regmap,
6278c2ecf20Sopenharmony_ci	.is_enabled		= regulator_is_enabled_regmap,
6288c2ecf20Sopenharmony_ci	.set_ramp_delay		= rk808_set_ramp_delay,
6298c2ecf20Sopenharmony_ci	.set_suspend_voltage	= rk808_set_suspend_voltage,
6308c2ecf20Sopenharmony_ci	.set_suspend_enable	= rk808_set_suspend_enable,
6318c2ecf20Sopenharmony_ci	.set_suspend_disable	= rk808_set_suspend_disable,
6328c2ecf20Sopenharmony_ci};
6338c2ecf20Sopenharmony_ci
6348c2ecf20Sopenharmony_cistatic const struct regulator_ops rk808_reg_ops = {
6358c2ecf20Sopenharmony_ci	.list_voltage		= regulator_list_voltage_linear,
6368c2ecf20Sopenharmony_ci	.map_voltage		= regulator_map_voltage_linear,
6378c2ecf20Sopenharmony_ci	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
6388c2ecf20Sopenharmony_ci	.set_voltage_sel	= regulator_set_voltage_sel_regmap,
6398c2ecf20Sopenharmony_ci	.enable			= regulator_enable_regmap,
6408c2ecf20Sopenharmony_ci	.disable		= regulator_disable_regmap,
6418c2ecf20Sopenharmony_ci	.is_enabled		= regulator_is_enabled_regmap,
6428c2ecf20Sopenharmony_ci	.set_suspend_voltage	= rk808_set_suspend_voltage,
6438c2ecf20Sopenharmony_ci	.set_suspend_enable	= rk808_set_suspend_enable,
6448c2ecf20Sopenharmony_ci	.set_suspend_disable	= rk808_set_suspend_disable,
6458c2ecf20Sopenharmony_ci};
6468c2ecf20Sopenharmony_ci
6478c2ecf20Sopenharmony_cistatic const struct regulator_ops rk808_reg_ops_ranges = {
6488c2ecf20Sopenharmony_ci	.list_voltage		= regulator_list_voltage_linear_range,
6498c2ecf20Sopenharmony_ci	.map_voltage		= regulator_map_voltage_linear_range,
6508c2ecf20Sopenharmony_ci	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
6518c2ecf20Sopenharmony_ci	.set_voltage_sel	= regulator_set_voltage_sel_regmap,
6528c2ecf20Sopenharmony_ci	.enable			= regulator_enable_regmap,
6538c2ecf20Sopenharmony_ci	.disable		= regulator_disable_regmap,
6548c2ecf20Sopenharmony_ci	.is_enabled		= regulator_is_enabled_regmap,
6558c2ecf20Sopenharmony_ci	.set_suspend_voltage	= rk808_set_suspend_voltage_range,
6568c2ecf20Sopenharmony_ci	.set_suspend_enable	= rk808_set_suspend_enable,
6578c2ecf20Sopenharmony_ci	.set_suspend_disable	= rk808_set_suspend_disable,
6588c2ecf20Sopenharmony_ci};
6598c2ecf20Sopenharmony_ci
6608c2ecf20Sopenharmony_cistatic const struct regulator_ops rk808_switch_ops = {
6618c2ecf20Sopenharmony_ci	.enable			= regulator_enable_regmap,
6628c2ecf20Sopenharmony_ci	.disable		= regulator_disable_regmap,
6638c2ecf20Sopenharmony_ci	.is_enabled		= regulator_is_enabled_regmap,
6648c2ecf20Sopenharmony_ci	.set_suspend_enable	= rk808_set_suspend_enable,
6658c2ecf20Sopenharmony_ci	.set_suspend_disable	= rk808_set_suspend_disable,
6668c2ecf20Sopenharmony_ci};
6678c2ecf20Sopenharmony_ci
6688c2ecf20Sopenharmony_cistatic const struct linear_range rk805_buck_1_2_voltage_ranges[] = {
6698c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(712500, 0, 59, 12500),
6708c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1800000, 60, 62, 200000),
6718c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(2300000, 63, 63, 0),
6728c2ecf20Sopenharmony_ci};
6738c2ecf20Sopenharmony_ci
6748c2ecf20Sopenharmony_cistatic const struct regulator_ops rk809_buck5_ops_range = {
6758c2ecf20Sopenharmony_ci	.list_voltage		= regulator_list_voltage_linear_range,
6768c2ecf20Sopenharmony_ci	.map_voltage		= regulator_map_voltage_linear_range,
6778c2ecf20Sopenharmony_ci	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
6788c2ecf20Sopenharmony_ci	.set_voltage_sel	= regulator_set_voltage_sel_regmap,
6798c2ecf20Sopenharmony_ci	.set_voltage_time_sel	= regulator_set_voltage_time_sel,
6808c2ecf20Sopenharmony_ci	.enable			= regulator_enable_regmap,
6818c2ecf20Sopenharmony_ci	.disable		= regulator_disable_regmap,
6828c2ecf20Sopenharmony_ci	.is_enabled		= rk8xx_is_enabled_wmsk_regmap,
6838c2ecf20Sopenharmony_ci	.set_suspend_voltage	= rk808_set_suspend_voltage_range,
6848c2ecf20Sopenharmony_ci	.set_suspend_enable	= rk817_set_suspend_enable,
6858c2ecf20Sopenharmony_ci	.set_suspend_disable	= rk817_set_suspend_disable,
6868c2ecf20Sopenharmony_ci};
6878c2ecf20Sopenharmony_ci
6888c2ecf20Sopenharmony_cistatic const struct regulator_ops rk817_reg_ops = {
6898c2ecf20Sopenharmony_ci	.list_voltage		= regulator_list_voltage_linear,
6908c2ecf20Sopenharmony_ci	.map_voltage		= regulator_map_voltage_linear,
6918c2ecf20Sopenharmony_ci	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
6928c2ecf20Sopenharmony_ci	.set_voltage_sel	= regulator_set_voltage_sel_regmap,
6938c2ecf20Sopenharmony_ci	.enable			= regulator_enable_regmap,
6948c2ecf20Sopenharmony_ci	.disable		= regulator_disable_regmap,
6958c2ecf20Sopenharmony_ci	.is_enabled		= rk8xx_is_enabled_wmsk_regmap,
6968c2ecf20Sopenharmony_ci	.set_suspend_voltage	= rk808_set_suspend_voltage,
6978c2ecf20Sopenharmony_ci	.set_suspend_enable	= rk817_set_suspend_enable,
6988c2ecf20Sopenharmony_ci	.set_suspend_disable	= rk817_set_suspend_disable,
6998c2ecf20Sopenharmony_ci};
7008c2ecf20Sopenharmony_ci
7018c2ecf20Sopenharmony_cistatic const struct regulator_ops rk817_boost_ops = {
7028c2ecf20Sopenharmony_ci	.list_voltage		= regulator_list_voltage_linear,
7038c2ecf20Sopenharmony_ci	.map_voltage		= regulator_map_voltage_linear,
7048c2ecf20Sopenharmony_ci	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
7058c2ecf20Sopenharmony_ci	.set_voltage_sel	= regulator_set_voltage_sel_regmap,
7068c2ecf20Sopenharmony_ci	.enable			= regulator_enable_regmap,
7078c2ecf20Sopenharmony_ci	.disable		= regulator_disable_regmap,
7088c2ecf20Sopenharmony_ci	.is_enabled		= rk8xx_is_enabled_wmsk_regmap,
7098c2ecf20Sopenharmony_ci	.set_suspend_enable	= rk817_set_suspend_enable,
7108c2ecf20Sopenharmony_ci	.set_suspend_disable	= rk817_set_suspend_disable,
7118c2ecf20Sopenharmony_ci};
7128c2ecf20Sopenharmony_ci
7138c2ecf20Sopenharmony_cistatic const struct regulator_ops rk817_buck_ops_range = {
7148c2ecf20Sopenharmony_ci	.list_voltage		= regulator_list_voltage_linear_range,
7158c2ecf20Sopenharmony_ci	.map_voltage		= regulator_map_voltage_linear_range,
7168c2ecf20Sopenharmony_ci	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
7178c2ecf20Sopenharmony_ci	.set_voltage_sel	= regulator_set_voltage_sel_regmap,
7188c2ecf20Sopenharmony_ci	.set_voltage_time_sel	= regulator_set_voltage_time_sel,
7198c2ecf20Sopenharmony_ci	.enable			= regulator_enable_regmap,
7208c2ecf20Sopenharmony_ci	.disable		= regulator_disable_regmap,
7218c2ecf20Sopenharmony_ci	.is_enabled		= rk8xx_is_enabled_wmsk_regmap,
7228c2ecf20Sopenharmony_ci	.set_mode		= rk8xx_set_mode,
7238c2ecf20Sopenharmony_ci	.get_mode		= rk8xx_get_mode,
7248c2ecf20Sopenharmony_ci	.set_suspend_mode	= rk8xx_set_suspend_mode,
7258c2ecf20Sopenharmony_ci	.set_ramp_delay		= rk817_set_ramp_delay,
7268c2ecf20Sopenharmony_ci	.set_suspend_voltage	= rk808_set_suspend_voltage_range,
7278c2ecf20Sopenharmony_ci	.set_suspend_enable	= rk817_set_suspend_enable,
7288c2ecf20Sopenharmony_ci	.set_suspend_disable	= rk817_set_suspend_disable,
7298c2ecf20Sopenharmony_ci};
7308c2ecf20Sopenharmony_ci
7318c2ecf20Sopenharmony_cistatic const struct regulator_ops rk817_switch_ops = {
7328c2ecf20Sopenharmony_ci	.enable			= regulator_enable_regmap,
7338c2ecf20Sopenharmony_ci	.disable		= regulator_disable_regmap,
7348c2ecf20Sopenharmony_ci	.is_enabled		= rk8xx_is_enabled_wmsk_regmap,
7358c2ecf20Sopenharmony_ci	.set_suspend_enable	= rk817_set_suspend_enable,
7368c2ecf20Sopenharmony_ci	.set_suspend_disable	= rk817_set_suspend_disable,
7378c2ecf20Sopenharmony_ci};
7388c2ecf20Sopenharmony_ci
7398c2ecf20Sopenharmony_cistatic const struct regulator_desc rk805_reg[] = {
7408c2ecf20Sopenharmony_ci	{
7418c2ecf20Sopenharmony_ci		.name = "DCDC_REG1",
7428c2ecf20Sopenharmony_ci		.supply_name = "vcc1",
7438c2ecf20Sopenharmony_ci		.of_match = of_match_ptr("DCDC_REG1"),
7448c2ecf20Sopenharmony_ci		.regulators_node = of_match_ptr("regulators"),
7458c2ecf20Sopenharmony_ci		.id = RK805_ID_DCDC1,
7468c2ecf20Sopenharmony_ci		.ops = &rk808_reg_ops_ranges,
7478c2ecf20Sopenharmony_ci		.type = REGULATOR_VOLTAGE,
7488c2ecf20Sopenharmony_ci		.n_voltages = 64,
7498c2ecf20Sopenharmony_ci		.linear_ranges = rk805_buck_1_2_voltage_ranges,
7508c2ecf20Sopenharmony_ci		.n_linear_ranges = ARRAY_SIZE(rk805_buck_1_2_voltage_ranges),
7518c2ecf20Sopenharmony_ci		.vsel_reg = RK805_BUCK1_ON_VSEL_REG,
7528c2ecf20Sopenharmony_ci		.vsel_mask = RK818_BUCK_VSEL_MASK,
7538c2ecf20Sopenharmony_ci		.enable_reg = RK805_DCDC_EN_REG,
7548c2ecf20Sopenharmony_ci		.enable_mask = BIT(0),
7558c2ecf20Sopenharmony_ci		.owner = THIS_MODULE,
7568c2ecf20Sopenharmony_ci	}, {
7578c2ecf20Sopenharmony_ci		.name = "DCDC_REG2",
7588c2ecf20Sopenharmony_ci		.supply_name = "vcc2",
7598c2ecf20Sopenharmony_ci		.of_match = of_match_ptr("DCDC_REG2"),
7608c2ecf20Sopenharmony_ci		.regulators_node = of_match_ptr("regulators"),
7618c2ecf20Sopenharmony_ci		.id = RK805_ID_DCDC2,
7628c2ecf20Sopenharmony_ci		.ops = &rk808_reg_ops_ranges,
7638c2ecf20Sopenharmony_ci		.type = REGULATOR_VOLTAGE,
7648c2ecf20Sopenharmony_ci		.n_voltages = 64,
7658c2ecf20Sopenharmony_ci		.linear_ranges = rk805_buck_1_2_voltage_ranges,
7668c2ecf20Sopenharmony_ci		.n_linear_ranges = ARRAY_SIZE(rk805_buck_1_2_voltage_ranges),
7678c2ecf20Sopenharmony_ci		.vsel_reg = RK805_BUCK2_ON_VSEL_REG,
7688c2ecf20Sopenharmony_ci		.vsel_mask = RK818_BUCK_VSEL_MASK,
7698c2ecf20Sopenharmony_ci		.enable_reg = RK805_DCDC_EN_REG,
7708c2ecf20Sopenharmony_ci		.enable_mask = BIT(1),
7718c2ecf20Sopenharmony_ci		.owner = THIS_MODULE,
7728c2ecf20Sopenharmony_ci	}, {
7738c2ecf20Sopenharmony_ci		.name = "DCDC_REG3",
7748c2ecf20Sopenharmony_ci		.supply_name = "vcc3",
7758c2ecf20Sopenharmony_ci		.of_match = of_match_ptr("DCDC_REG3"),
7768c2ecf20Sopenharmony_ci		.regulators_node = of_match_ptr("regulators"),
7778c2ecf20Sopenharmony_ci		.id = RK805_ID_DCDC3,
7788c2ecf20Sopenharmony_ci		.ops = &rk805_switch_ops,
7798c2ecf20Sopenharmony_ci		.type = REGULATOR_VOLTAGE,
7808c2ecf20Sopenharmony_ci		.n_voltages = 1,
7818c2ecf20Sopenharmony_ci		.enable_reg = RK805_DCDC_EN_REG,
7828c2ecf20Sopenharmony_ci		.enable_mask = BIT(2),
7838c2ecf20Sopenharmony_ci		.owner = THIS_MODULE,
7848c2ecf20Sopenharmony_ci	},
7858c2ecf20Sopenharmony_ci
7868c2ecf20Sopenharmony_ci	RK805_DESC(RK805_ID_DCDC4, "DCDC_REG4", "vcc4", 800, 3400, 100,
7878c2ecf20Sopenharmony_ci		RK805_BUCK4_ON_VSEL_REG, RK818_BUCK4_VSEL_MASK,
7888c2ecf20Sopenharmony_ci		RK805_DCDC_EN_REG, BIT(3), 0),
7898c2ecf20Sopenharmony_ci
7908c2ecf20Sopenharmony_ci	RK805_DESC(RK805_ID_LDO1, "LDO_REG1", "vcc5", 800, 3400, 100,
7918c2ecf20Sopenharmony_ci		RK805_LDO1_ON_VSEL_REG, RK818_LDO_VSEL_MASK, RK805_LDO_EN_REG,
7928c2ecf20Sopenharmony_ci		BIT(0), 400),
7938c2ecf20Sopenharmony_ci	RK805_DESC(RK805_ID_LDO2, "LDO_REG2", "vcc5", 800, 3400, 100,
7948c2ecf20Sopenharmony_ci		RK805_LDO2_ON_VSEL_REG, RK818_LDO_VSEL_MASK, RK805_LDO_EN_REG,
7958c2ecf20Sopenharmony_ci		BIT(1), 400),
7968c2ecf20Sopenharmony_ci	RK805_DESC(RK805_ID_LDO3, "LDO_REG3", "vcc6", 800, 3400, 100,
7978c2ecf20Sopenharmony_ci		RK805_LDO3_ON_VSEL_REG, RK818_LDO_VSEL_MASK, RK805_LDO_EN_REG,
7988c2ecf20Sopenharmony_ci		BIT(2), 400),
7998c2ecf20Sopenharmony_ci};
8008c2ecf20Sopenharmony_ci
8018c2ecf20Sopenharmony_cistatic const struct regulator_desc rk808_reg[] = {
8028c2ecf20Sopenharmony_ci	{
8038c2ecf20Sopenharmony_ci		.name = "DCDC_REG1",
8048c2ecf20Sopenharmony_ci		.supply_name = "vcc1",
8058c2ecf20Sopenharmony_ci		.of_match = of_match_ptr("DCDC_REG1"),
8068c2ecf20Sopenharmony_ci		.regulators_node = of_match_ptr("regulators"),
8078c2ecf20Sopenharmony_ci		.id = RK808_ID_DCDC1,
8088c2ecf20Sopenharmony_ci		.ops = &rk808_buck1_2_ops,
8098c2ecf20Sopenharmony_ci		.type = REGULATOR_VOLTAGE,
8108c2ecf20Sopenharmony_ci		.min_uV = 712500,
8118c2ecf20Sopenharmony_ci		.uV_step = 12500,
8128c2ecf20Sopenharmony_ci		.n_voltages = 64,
8138c2ecf20Sopenharmony_ci		.vsel_reg = RK808_BUCK1_ON_VSEL_REG,
8148c2ecf20Sopenharmony_ci		.vsel_mask = RK808_BUCK_VSEL_MASK,
8158c2ecf20Sopenharmony_ci		.enable_reg = RK808_DCDC_EN_REG,
8168c2ecf20Sopenharmony_ci		.enable_mask = BIT(0),
8178c2ecf20Sopenharmony_ci		.owner = THIS_MODULE,
8188c2ecf20Sopenharmony_ci	}, {
8198c2ecf20Sopenharmony_ci		.name = "DCDC_REG2",
8208c2ecf20Sopenharmony_ci		.supply_name = "vcc2",
8218c2ecf20Sopenharmony_ci		.of_match = of_match_ptr("DCDC_REG2"),
8228c2ecf20Sopenharmony_ci		.regulators_node = of_match_ptr("regulators"),
8238c2ecf20Sopenharmony_ci		.id = RK808_ID_DCDC2,
8248c2ecf20Sopenharmony_ci		.ops = &rk808_buck1_2_ops,
8258c2ecf20Sopenharmony_ci		.type = REGULATOR_VOLTAGE,
8268c2ecf20Sopenharmony_ci		.min_uV = 712500,
8278c2ecf20Sopenharmony_ci		.uV_step = 12500,
8288c2ecf20Sopenharmony_ci		.n_voltages = 64,
8298c2ecf20Sopenharmony_ci		.vsel_reg = RK808_BUCK2_ON_VSEL_REG,
8308c2ecf20Sopenharmony_ci		.vsel_mask = RK808_BUCK_VSEL_MASK,
8318c2ecf20Sopenharmony_ci		.enable_reg = RK808_DCDC_EN_REG,
8328c2ecf20Sopenharmony_ci		.enable_mask = BIT(1),
8338c2ecf20Sopenharmony_ci		.owner = THIS_MODULE,
8348c2ecf20Sopenharmony_ci	}, {
8358c2ecf20Sopenharmony_ci		.name = "DCDC_REG3",
8368c2ecf20Sopenharmony_ci		.supply_name = "vcc3",
8378c2ecf20Sopenharmony_ci		.of_match = of_match_ptr("DCDC_REG3"),
8388c2ecf20Sopenharmony_ci		.regulators_node = of_match_ptr("regulators"),
8398c2ecf20Sopenharmony_ci		.id = RK808_ID_DCDC3,
8408c2ecf20Sopenharmony_ci		.ops = &rk808_switch_ops,
8418c2ecf20Sopenharmony_ci		.type = REGULATOR_VOLTAGE,
8428c2ecf20Sopenharmony_ci		.n_voltages = 1,
8438c2ecf20Sopenharmony_ci		.enable_reg = RK808_DCDC_EN_REG,
8448c2ecf20Sopenharmony_ci		.enable_mask = BIT(2),
8458c2ecf20Sopenharmony_ci		.owner = THIS_MODULE,
8468c2ecf20Sopenharmony_ci	},
8478c2ecf20Sopenharmony_ci	RK8XX_DESC(RK808_ID_DCDC4, "DCDC_REG4", "vcc4", 1800, 3300, 100,
8488c2ecf20Sopenharmony_ci		RK808_BUCK4_ON_VSEL_REG, RK808_BUCK4_VSEL_MASK,
8498c2ecf20Sopenharmony_ci		RK808_DCDC_EN_REG, BIT(3), 0),
8508c2ecf20Sopenharmony_ci	RK8XX_DESC(RK808_ID_LDO1, "LDO_REG1", "vcc6", 1800, 3400, 100,
8518c2ecf20Sopenharmony_ci		RK808_LDO1_ON_VSEL_REG, RK808_LDO_VSEL_MASK, RK808_LDO_EN_REG,
8528c2ecf20Sopenharmony_ci		BIT(0), 400),
8538c2ecf20Sopenharmony_ci	RK8XX_DESC(RK808_ID_LDO2, "LDO_REG2", "vcc6", 1800, 3400, 100,
8548c2ecf20Sopenharmony_ci		RK808_LDO2_ON_VSEL_REG, RK808_LDO_VSEL_MASK, RK808_LDO_EN_REG,
8558c2ecf20Sopenharmony_ci		BIT(1), 400),
8568c2ecf20Sopenharmony_ci	{
8578c2ecf20Sopenharmony_ci		.name = "LDO_REG3",
8588c2ecf20Sopenharmony_ci		.supply_name = "vcc7",
8598c2ecf20Sopenharmony_ci		.of_match = of_match_ptr("LDO_REG3"),
8608c2ecf20Sopenharmony_ci		.regulators_node = of_match_ptr("regulators"),
8618c2ecf20Sopenharmony_ci		.id = RK808_ID_LDO3,
8628c2ecf20Sopenharmony_ci		.ops = &rk808_reg_ops_ranges,
8638c2ecf20Sopenharmony_ci		.type = REGULATOR_VOLTAGE,
8648c2ecf20Sopenharmony_ci		.n_voltages = 16,
8658c2ecf20Sopenharmony_ci		.linear_ranges = rk808_ldo3_voltage_ranges,
8668c2ecf20Sopenharmony_ci		.n_linear_ranges = ARRAY_SIZE(rk808_ldo3_voltage_ranges),
8678c2ecf20Sopenharmony_ci		.vsel_reg = RK808_LDO3_ON_VSEL_REG,
8688c2ecf20Sopenharmony_ci		.vsel_mask = RK808_BUCK4_VSEL_MASK,
8698c2ecf20Sopenharmony_ci		.enable_reg = RK808_LDO_EN_REG,
8708c2ecf20Sopenharmony_ci		.enable_mask = BIT(2),
8718c2ecf20Sopenharmony_ci		.enable_time = 400,
8728c2ecf20Sopenharmony_ci		.owner = THIS_MODULE,
8738c2ecf20Sopenharmony_ci	},
8748c2ecf20Sopenharmony_ci	RK8XX_DESC(RK808_ID_LDO4, "LDO_REG4", "vcc9", 1800, 3400, 100,
8758c2ecf20Sopenharmony_ci		RK808_LDO4_ON_VSEL_REG, RK808_LDO_VSEL_MASK, RK808_LDO_EN_REG,
8768c2ecf20Sopenharmony_ci		BIT(3), 400),
8778c2ecf20Sopenharmony_ci	RK8XX_DESC(RK808_ID_LDO5, "LDO_REG5", "vcc9", 1800, 3400, 100,
8788c2ecf20Sopenharmony_ci		RK808_LDO5_ON_VSEL_REG, RK808_LDO_VSEL_MASK, RK808_LDO_EN_REG,
8798c2ecf20Sopenharmony_ci		BIT(4), 400),
8808c2ecf20Sopenharmony_ci	RK8XX_DESC(RK808_ID_LDO6, "LDO_REG6", "vcc10", 800, 2500, 100,
8818c2ecf20Sopenharmony_ci		RK808_LDO6_ON_VSEL_REG, RK808_LDO_VSEL_MASK, RK808_LDO_EN_REG,
8828c2ecf20Sopenharmony_ci		BIT(5), 400),
8838c2ecf20Sopenharmony_ci	RK8XX_DESC(RK808_ID_LDO7, "LDO_REG7", "vcc7", 800, 2500, 100,
8848c2ecf20Sopenharmony_ci		RK808_LDO7_ON_VSEL_REG, RK808_LDO_VSEL_MASK, RK808_LDO_EN_REG,
8858c2ecf20Sopenharmony_ci		BIT(6), 400),
8868c2ecf20Sopenharmony_ci	RK8XX_DESC(RK808_ID_LDO8, "LDO_REG8", "vcc11", 1800, 3400, 100,
8878c2ecf20Sopenharmony_ci		RK808_LDO8_ON_VSEL_REG, RK808_LDO_VSEL_MASK, RK808_LDO_EN_REG,
8888c2ecf20Sopenharmony_ci		BIT(7), 400),
8898c2ecf20Sopenharmony_ci	RK8XX_DESC_SWITCH(RK808_ID_SWITCH1, "SWITCH_REG1", "vcc8",
8908c2ecf20Sopenharmony_ci		RK808_DCDC_EN_REG, BIT(5)),
8918c2ecf20Sopenharmony_ci	RK8XX_DESC_SWITCH(RK808_ID_SWITCH2, "SWITCH_REG2", "vcc12",
8928c2ecf20Sopenharmony_ci		RK808_DCDC_EN_REG, BIT(6)),
8938c2ecf20Sopenharmony_ci};
8948c2ecf20Sopenharmony_ci
8958c2ecf20Sopenharmony_cistatic const struct regulator_desc rk809_reg[] = {
8968c2ecf20Sopenharmony_ci	{
8978c2ecf20Sopenharmony_ci		.name = "DCDC_REG1",
8988c2ecf20Sopenharmony_ci		.supply_name = "vcc1",
8998c2ecf20Sopenharmony_ci		.of_match = of_match_ptr("DCDC_REG1"),
9008c2ecf20Sopenharmony_ci		.regulators_node = of_match_ptr("regulators"),
9018c2ecf20Sopenharmony_ci		.id = RK817_ID_DCDC1,
9028c2ecf20Sopenharmony_ci		.ops = &rk817_buck_ops_range,
9038c2ecf20Sopenharmony_ci		.type = REGULATOR_VOLTAGE,
9048c2ecf20Sopenharmony_ci		.n_voltages = RK817_BUCK1_SEL_CNT + 1,
9058c2ecf20Sopenharmony_ci		.linear_ranges = rk817_buck1_voltage_ranges,
9068c2ecf20Sopenharmony_ci		.n_linear_ranges = ARRAY_SIZE(rk817_buck1_voltage_ranges),
9078c2ecf20Sopenharmony_ci		.vsel_reg = RK817_BUCK1_ON_VSEL_REG,
9088c2ecf20Sopenharmony_ci		.vsel_mask = RK817_BUCK_VSEL_MASK,
9098c2ecf20Sopenharmony_ci		.enable_reg = RK817_POWER_EN_REG(0),
9108c2ecf20Sopenharmony_ci		.enable_mask = ENABLE_MASK(RK817_ID_DCDC1),
9118c2ecf20Sopenharmony_ci		.enable_val = ENABLE_MASK(RK817_ID_DCDC1),
9128c2ecf20Sopenharmony_ci		.disable_val = DISABLE_VAL(RK817_ID_DCDC1),
9138c2ecf20Sopenharmony_ci		.of_map_mode = rk8xx_regulator_of_map_mode,
9148c2ecf20Sopenharmony_ci		.owner = THIS_MODULE,
9158c2ecf20Sopenharmony_ci	}, {
9168c2ecf20Sopenharmony_ci		.name = "DCDC_REG2",
9178c2ecf20Sopenharmony_ci		.supply_name = "vcc2",
9188c2ecf20Sopenharmony_ci		.of_match = of_match_ptr("DCDC_REG2"),
9198c2ecf20Sopenharmony_ci		.regulators_node = of_match_ptr("regulators"),
9208c2ecf20Sopenharmony_ci		.id = RK817_ID_DCDC2,
9218c2ecf20Sopenharmony_ci		.ops = &rk817_buck_ops_range,
9228c2ecf20Sopenharmony_ci		.type = REGULATOR_VOLTAGE,
9238c2ecf20Sopenharmony_ci		.n_voltages = RK817_BUCK1_SEL_CNT + 1,
9248c2ecf20Sopenharmony_ci		.linear_ranges = rk817_buck1_voltage_ranges,
9258c2ecf20Sopenharmony_ci		.n_linear_ranges = ARRAY_SIZE(rk817_buck1_voltage_ranges),
9268c2ecf20Sopenharmony_ci		.vsel_reg = RK817_BUCK2_ON_VSEL_REG,
9278c2ecf20Sopenharmony_ci		.vsel_mask = RK817_BUCK_VSEL_MASK,
9288c2ecf20Sopenharmony_ci		.enable_reg = RK817_POWER_EN_REG(0),
9298c2ecf20Sopenharmony_ci		.enable_mask = ENABLE_MASK(RK817_ID_DCDC2),
9308c2ecf20Sopenharmony_ci		.enable_val = ENABLE_MASK(RK817_ID_DCDC2),
9318c2ecf20Sopenharmony_ci		.disable_val = DISABLE_VAL(RK817_ID_DCDC2),
9328c2ecf20Sopenharmony_ci		.of_map_mode = rk8xx_regulator_of_map_mode,
9338c2ecf20Sopenharmony_ci		.owner = THIS_MODULE,
9348c2ecf20Sopenharmony_ci	}, {
9358c2ecf20Sopenharmony_ci		.name = "DCDC_REG3",
9368c2ecf20Sopenharmony_ci		.supply_name = "vcc3",
9378c2ecf20Sopenharmony_ci		.of_match = of_match_ptr("DCDC_REG3"),
9388c2ecf20Sopenharmony_ci		.regulators_node = of_match_ptr("regulators"),
9398c2ecf20Sopenharmony_ci		.id = RK817_ID_DCDC3,
9408c2ecf20Sopenharmony_ci		.ops = &rk817_buck_ops_range,
9418c2ecf20Sopenharmony_ci		.type = REGULATOR_VOLTAGE,
9428c2ecf20Sopenharmony_ci		.n_voltages = RK817_BUCK1_SEL_CNT + 1,
9438c2ecf20Sopenharmony_ci		.linear_ranges = rk817_buck1_voltage_ranges,
9448c2ecf20Sopenharmony_ci		.n_linear_ranges = ARRAY_SIZE(rk817_buck1_voltage_ranges),
9458c2ecf20Sopenharmony_ci		.vsel_reg = RK817_BUCK3_ON_VSEL_REG,
9468c2ecf20Sopenharmony_ci		.vsel_mask = RK817_BUCK_VSEL_MASK,
9478c2ecf20Sopenharmony_ci		.enable_reg = RK817_POWER_EN_REG(0),
9488c2ecf20Sopenharmony_ci		.enable_mask = ENABLE_MASK(RK817_ID_DCDC3),
9498c2ecf20Sopenharmony_ci		.enable_val = ENABLE_MASK(RK817_ID_DCDC3),
9508c2ecf20Sopenharmony_ci		.disable_val = DISABLE_VAL(RK817_ID_DCDC3),
9518c2ecf20Sopenharmony_ci		.of_map_mode = rk8xx_regulator_of_map_mode,
9528c2ecf20Sopenharmony_ci		.owner = THIS_MODULE,
9538c2ecf20Sopenharmony_ci	}, {
9548c2ecf20Sopenharmony_ci		.name = "DCDC_REG4",
9558c2ecf20Sopenharmony_ci		.supply_name = "vcc4",
9568c2ecf20Sopenharmony_ci		.of_match = of_match_ptr("DCDC_REG4"),
9578c2ecf20Sopenharmony_ci		.regulators_node = of_match_ptr("regulators"),
9588c2ecf20Sopenharmony_ci		.id = RK817_ID_DCDC4,
9598c2ecf20Sopenharmony_ci		.ops = &rk817_buck_ops_range,
9608c2ecf20Sopenharmony_ci		.type = REGULATOR_VOLTAGE,
9618c2ecf20Sopenharmony_ci		.n_voltages = RK817_BUCK3_SEL_CNT + 1,
9628c2ecf20Sopenharmony_ci		.linear_ranges = rk817_buck3_voltage_ranges,
9638c2ecf20Sopenharmony_ci		.n_linear_ranges = ARRAY_SIZE(rk817_buck3_voltage_ranges),
9648c2ecf20Sopenharmony_ci		.vsel_reg = RK817_BUCK4_ON_VSEL_REG,
9658c2ecf20Sopenharmony_ci		.vsel_mask = RK817_BUCK_VSEL_MASK,
9668c2ecf20Sopenharmony_ci		.enable_reg = RK817_POWER_EN_REG(0),
9678c2ecf20Sopenharmony_ci		.enable_mask = ENABLE_MASK(RK817_ID_DCDC4),
9688c2ecf20Sopenharmony_ci		.enable_val = ENABLE_MASK(RK817_ID_DCDC4),
9698c2ecf20Sopenharmony_ci		.disable_val = DISABLE_VAL(RK817_ID_DCDC4),
9708c2ecf20Sopenharmony_ci		.of_map_mode = rk8xx_regulator_of_map_mode,
9718c2ecf20Sopenharmony_ci		.owner = THIS_MODULE,
9728c2ecf20Sopenharmony_ci	},
9738c2ecf20Sopenharmony_ci	{
9748c2ecf20Sopenharmony_ci		.name = "DCDC_REG5",
9758c2ecf20Sopenharmony_ci		.supply_name = "vcc9",
9768c2ecf20Sopenharmony_ci		.of_match = of_match_ptr("DCDC_REG5"),
9778c2ecf20Sopenharmony_ci		.regulators_node = of_match_ptr("regulators"),
9788c2ecf20Sopenharmony_ci		.id = RK809_ID_DCDC5,
9798c2ecf20Sopenharmony_ci		.ops = &rk809_buck5_ops_range,
9808c2ecf20Sopenharmony_ci		.type = REGULATOR_VOLTAGE,
9818c2ecf20Sopenharmony_ci		.n_voltages = RK809_BUCK5_SEL_CNT,
9828c2ecf20Sopenharmony_ci		.linear_ranges = rk809_buck5_voltage_ranges,
9838c2ecf20Sopenharmony_ci		.n_linear_ranges = ARRAY_SIZE(rk809_buck5_voltage_ranges),
9848c2ecf20Sopenharmony_ci		.vsel_reg = RK809_BUCK5_CONFIG(0),
9858c2ecf20Sopenharmony_ci		.vsel_mask = RK809_BUCK5_VSEL_MASK,
9868c2ecf20Sopenharmony_ci		.enable_reg = RK817_POWER_EN_REG(3),
9878c2ecf20Sopenharmony_ci		.enable_mask = ENABLE_MASK(1),
9888c2ecf20Sopenharmony_ci		.enable_val = ENABLE_MASK(1),
9898c2ecf20Sopenharmony_ci		.disable_val = DISABLE_VAL(1),
9908c2ecf20Sopenharmony_ci		.of_map_mode = rk8xx_regulator_of_map_mode,
9918c2ecf20Sopenharmony_ci		.owner = THIS_MODULE,
9928c2ecf20Sopenharmony_ci	},
9938c2ecf20Sopenharmony_ci	RK817_DESC(RK817_ID_LDO1, "LDO_REG1", "vcc5", 600, 3400, 25,
9948c2ecf20Sopenharmony_ci		   RK817_LDO_ON_VSEL_REG(0), RK817_LDO_VSEL_MASK,
9958c2ecf20Sopenharmony_ci		   RK817_POWER_EN_REG(1), ENABLE_MASK(0),
9968c2ecf20Sopenharmony_ci		   DISABLE_VAL(0), 400),
9978c2ecf20Sopenharmony_ci	RK817_DESC(RK817_ID_LDO2, "LDO_REG2", "vcc5", 600, 3400, 25,
9988c2ecf20Sopenharmony_ci		   RK817_LDO_ON_VSEL_REG(1), RK817_LDO_VSEL_MASK,
9998c2ecf20Sopenharmony_ci		   RK817_POWER_EN_REG(1), ENABLE_MASK(1),
10008c2ecf20Sopenharmony_ci		   DISABLE_VAL(1), 400),
10018c2ecf20Sopenharmony_ci	RK817_DESC(RK817_ID_LDO3, "LDO_REG3", "vcc5", 600, 3400, 25,
10028c2ecf20Sopenharmony_ci		   RK817_LDO_ON_VSEL_REG(2), RK817_LDO_VSEL_MASK,
10038c2ecf20Sopenharmony_ci		   RK817_POWER_EN_REG(1), ENABLE_MASK(2),
10048c2ecf20Sopenharmony_ci		   DISABLE_VAL(2), 400),
10058c2ecf20Sopenharmony_ci	RK817_DESC(RK817_ID_LDO4, "LDO_REG4", "vcc6", 600, 3400, 25,
10068c2ecf20Sopenharmony_ci		   RK817_LDO_ON_VSEL_REG(3), RK817_LDO_VSEL_MASK,
10078c2ecf20Sopenharmony_ci		   RK817_POWER_EN_REG(1), ENABLE_MASK(3),
10088c2ecf20Sopenharmony_ci		   DISABLE_VAL(3), 400),
10098c2ecf20Sopenharmony_ci	RK817_DESC(RK817_ID_LDO5, "LDO_REG5", "vcc6", 600, 3400, 25,
10108c2ecf20Sopenharmony_ci		   RK817_LDO_ON_VSEL_REG(4), RK817_LDO_VSEL_MASK,
10118c2ecf20Sopenharmony_ci		   RK817_POWER_EN_REG(2), ENABLE_MASK(0),
10128c2ecf20Sopenharmony_ci		   DISABLE_VAL(0), 400),
10138c2ecf20Sopenharmony_ci	RK817_DESC(RK817_ID_LDO6, "LDO_REG6", "vcc6", 600, 3400, 25,
10148c2ecf20Sopenharmony_ci		   RK817_LDO_ON_VSEL_REG(5), RK817_LDO_VSEL_MASK,
10158c2ecf20Sopenharmony_ci		   RK817_POWER_EN_REG(2), ENABLE_MASK(1),
10168c2ecf20Sopenharmony_ci		   DISABLE_VAL(1), 400),
10178c2ecf20Sopenharmony_ci	RK817_DESC(RK817_ID_LDO7, "LDO_REG7", "vcc7", 600, 3400, 25,
10188c2ecf20Sopenharmony_ci		   RK817_LDO_ON_VSEL_REG(6), RK817_LDO_VSEL_MASK,
10198c2ecf20Sopenharmony_ci		   RK817_POWER_EN_REG(2), ENABLE_MASK(2),
10208c2ecf20Sopenharmony_ci		   DISABLE_VAL(2), 400),
10218c2ecf20Sopenharmony_ci	RK817_DESC(RK817_ID_LDO8, "LDO_REG8", "vcc7", 600, 3400, 25,
10228c2ecf20Sopenharmony_ci		   RK817_LDO_ON_VSEL_REG(7), RK817_LDO_VSEL_MASK,
10238c2ecf20Sopenharmony_ci		   RK817_POWER_EN_REG(2), ENABLE_MASK(3),
10248c2ecf20Sopenharmony_ci		   DISABLE_VAL(3), 400),
10258c2ecf20Sopenharmony_ci	RK817_DESC(RK817_ID_LDO9, "LDO_REG9", "vcc7", 600, 3400, 25,
10268c2ecf20Sopenharmony_ci		   RK817_LDO_ON_VSEL_REG(8), RK817_LDO_VSEL_MASK,
10278c2ecf20Sopenharmony_ci		   RK817_POWER_EN_REG(3), ENABLE_MASK(0),
10288c2ecf20Sopenharmony_ci		   DISABLE_VAL(0), 400),
10298c2ecf20Sopenharmony_ci	RK817_DESC_SWITCH(RK809_ID_SW1, "SWITCH_REG1", "vcc9",
10308c2ecf20Sopenharmony_ci			  RK817_POWER_EN_REG(3), ENABLE_MASK(2),
10318c2ecf20Sopenharmony_ci			  DISABLE_VAL(2)),
10328c2ecf20Sopenharmony_ci	RK817_DESC_SWITCH(RK809_ID_SW2, "SWITCH_REG2", "vcc8",
10338c2ecf20Sopenharmony_ci			  RK817_POWER_EN_REG(3), ENABLE_MASK(3),
10348c2ecf20Sopenharmony_ci			  DISABLE_VAL(3)),
10358c2ecf20Sopenharmony_ci};
10368c2ecf20Sopenharmony_ci
10378c2ecf20Sopenharmony_cistatic const struct regulator_desc rk817_reg[] = {
10388c2ecf20Sopenharmony_ci	{
10398c2ecf20Sopenharmony_ci		.name = "DCDC_REG1",
10408c2ecf20Sopenharmony_ci		.supply_name = "vcc1",
10418c2ecf20Sopenharmony_ci		.of_match = of_match_ptr("DCDC_REG1"),
10428c2ecf20Sopenharmony_ci		.regulators_node = of_match_ptr("regulators"),
10438c2ecf20Sopenharmony_ci		.id = RK817_ID_DCDC1,
10448c2ecf20Sopenharmony_ci		.ops = &rk817_buck_ops_range,
10458c2ecf20Sopenharmony_ci		.type = REGULATOR_VOLTAGE,
10468c2ecf20Sopenharmony_ci		.n_voltages = RK817_BUCK1_SEL_CNT + 1,
10478c2ecf20Sopenharmony_ci		.linear_ranges = rk817_buck1_voltage_ranges,
10488c2ecf20Sopenharmony_ci		.n_linear_ranges = ARRAY_SIZE(rk817_buck1_voltage_ranges),
10498c2ecf20Sopenharmony_ci		.vsel_reg = RK817_BUCK1_ON_VSEL_REG,
10508c2ecf20Sopenharmony_ci		.vsel_mask = RK817_BUCK_VSEL_MASK,
10518c2ecf20Sopenharmony_ci		.enable_reg = RK817_POWER_EN_REG(0),
10528c2ecf20Sopenharmony_ci		.enable_mask = ENABLE_MASK(RK817_ID_DCDC1),
10538c2ecf20Sopenharmony_ci		.enable_val = ENABLE_MASK(RK817_ID_DCDC1),
10548c2ecf20Sopenharmony_ci		.disable_val = DISABLE_VAL(RK817_ID_DCDC1),
10558c2ecf20Sopenharmony_ci		.of_map_mode = rk8xx_regulator_of_map_mode,
10568c2ecf20Sopenharmony_ci		.owner = THIS_MODULE,
10578c2ecf20Sopenharmony_ci	}, {
10588c2ecf20Sopenharmony_ci		.name = "DCDC_REG2",
10598c2ecf20Sopenharmony_ci		.supply_name = "vcc2",
10608c2ecf20Sopenharmony_ci		.of_match = of_match_ptr("DCDC_REG2"),
10618c2ecf20Sopenharmony_ci		.regulators_node = of_match_ptr("regulators"),
10628c2ecf20Sopenharmony_ci		.id = RK817_ID_DCDC2,
10638c2ecf20Sopenharmony_ci		.ops = &rk817_buck_ops_range,
10648c2ecf20Sopenharmony_ci		.type = REGULATOR_VOLTAGE,
10658c2ecf20Sopenharmony_ci		.n_voltages = RK817_BUCK1_SEL_CNT + 1,
10668c2ecf20Sopenharmony_ci		.linear_ranges = rk817_buck1_voltage_ranges,
10678c2ecf20Sopenharmony_ci		.n_linear_ranges = ARRAY_SIZE(rk817_buck1_voltage_ranges),
10688c2ecf20Sopenharmony_ci		.vsel_reg = RK817_BUCK2_ON_VSEL_REG,
10698c2ecf20Sopenharmony_ci		.vsel_mask = RK817_BUCK_VSEL_MASK,
10708c2ecf20Sopenharmony_ci		.enable_reg = RK817_POWER_EN_REG(0),
10718c2ecf20Sopenharmony_ci		.enable_mask = ENABLE_MASK(RK817_ID_DCDC2),
10728c2ecf20Sopenharmony_ci		.enable_val = ENABLE_MASK(RK817_ID_DCDC2),
10738c2ecf20Sopenharmony_ci		.disable_val = DISABLE_VAL(RK817_ID_DCDC2),
10748c2ecf20Sopenharmony_ci		.of_map_mode = rk8xx_regulator_of_map_mode,
10758c2ecf20Sopenharmony_ci		.owner = THIS_MODULE,
10768c2ecf20Sopenharmony_ci	}, {
10778c2ecf20Sopenharmony_ci		.name = "DCDC_REG3",
10788c2ecf20Sopenharmony_ci		.supply_name = "vcc3",
10798c2ecf20Sopenharmony_ci		.of_match = of_match_ptr("DCDC_REG3"),
10808c2ecf20Sopenharmony_ci		.regulators_node = of_match_ptr("regulators"),
10818c2ecf20Sopenharmony_ci		.id = RK817_ID_DCDC3,
10828c2ecf20Sopenharmony_ci		.ops = &rk817_buck_ops_range,
10838c2ecf20Sopenharmony_ci		.type = REGULATOR_VOLTAGE,
10848c2ecf20Sopenharmony_ci		.n_voltages = RK817_BUCK1_SEL_CNT + 1,
10858c2ecf20Sopenharmony_ci		.linear_ranges = rk817_buck1_voltage_ranges,
10868c2ecf20Sopenharmony_ci		.n_linear_ranges = ARRAY_SIZE(rk817_buck1_voltage_ranges),
10878c2ecf20Sopenharmony_ci		.vsel_reg = RK817_BUCK3_ON_VSEL_REG,
10888c2ecf20Sopenharmony_ci		.vsel_mask = RK817_BUCK_VSEL_MASK,
10898c2ecf20Sopenharmony_ci		.enable_reg = RK817_POWER_EN_REG(0),
10908c2ecf20Sopenharmony_ci		.enable_mask = ENABLE_MASK(RK817_ID_DCDC3),
10918c2ecf20Sopenharmony_ci		.enable_val = ENABLE_MASK(RK817_ID_DCDC3),
10928c2ecf20Sopenharmony_ci		.disable_val = DISABLE_VAL(RK817_ID_DCDC3),
10938c2ecf20Sopenharmony_ci		.of_map_mode = rk8xx_regulator_of_map_mode,
10948c2ecf20Sopenharmony_ci		.owner = THIS_MODULE,
10958c2ecf20Sopenharmony_ci	}, {
10968c2ecf20Sopenharmony_ci		.name = "DCDC_REG4",
10978c2ecf20Sopenharmony_ci		.supply_name = "vcc4",
10988c2ecf20Sopenharmony_ci		.of_match = of_match_ptr("DCDC_REG4"),
10998c2ecf20Sopenharmony_ci		.regulators_node = of_match_ptr("regulators"),
11008c2ecf20Sopenharmony_ci		.id = RK817_ID_DCDC4,
11018c2ecf20Sopenharmony_ci		.ops = &rk817_buck_ops_range,
11028c2ecf20Sopenharmony_ci		.type = REGULATOR_VOLTAGE,
11038c2ecf20Sopenharmony_ci		.n_voltages = RK817_BUCK3_SEL_CNT + 1,
11048c2ecf20Sopenharmony_ci		.linear_ranges = rk817_buck3_voltage_ranges,
11058c2ecf20Sopenharmony_ci		.n_linear_ranges = ARRAY_SIZE(rk817_buck3_voltage_ranges),
11068c2ecf20Sopenharmony_ci		.vsel_reg = RK817_BUCK4_ON_VSEL_REG,
11078c2ecf20Sopenharmony_ci		.vsel_mask = RK817_BUCK_VSEL_MASK,
11088c2ecf20Sopenharmony_ci		.enable_reg = RK817_POWER_EN_REG(0),
11098c2ecf20Sopenharmony_ci		.enable_mask = ENABLE_MASK(RK817_ID_DCDC4),
11108c2ecf20Sopenharmony_ci		.enable_val = ENABLE_MASK(RK817_ID_DCDC4),
11118c2ecf20Sopenharmony_ci		.disable_val = DISABLE_VAL(RK817_ID_DCDC4),
11128c2ecf20Sopenharmony_ci		.of_map_mode = rk8xx_regulator_of_map_mode,
11138c2ecf20Sopenharmony_ci		.owner = THIS_MODULE,
11148c2ecf20Sopenharmony_ci	},
11158c2ecf20Sopenharmony_ci	RK817_DESC(RK817_ID_LDO1, "LDO_REG1", "vcc5", 600, 3400, 25,
11168c2ecf20Sopenharmony_ci		   RK817_LDO_ON_VSEL_REG(0), RK817_LDO_VSEL_MASK,
11178c2ecf20Sopenharmony_ci		   RK817_POWER_EN_REG(1), ENABLE_MASK(0),
11188c2ecf20Sopenharmony_ci		   DISABLE_VAL(0), 400),
11198c2ecf20Sopenharmony_ci	RK817_DESC(RK817_ID_LDO2, "LDO_REG2", "vcc5", 600, 3400, 25,
11208c2ecf20Sopenharmony_ci		   RK817_LDO_ON_VSEL_REG(1), RK817_LDO_VSEL_MASK,
11218c2ecf20Sopenharmony_ci		   RK817_POWER_EN_REG(1), ENABLE_MASK(1),
11228c2ecf20Sopenharmony_ci		   DISABLE_VAL(1), 400),
11238c2ecf20Sopenharmony_ci	RK817_DESC(RK817_ID_LDO3, "LDO_REG3", "vcc5", 600, 3400, 25,
11248c2ecf20Sopenharmony_ci		   RK817_LDO_ON_VSEL_REG(2), RK817_LDO_VSEL_MASK,
11258c2ecf20Sopenharmony_ci		   RK817_POWER_EN_REG(1), ENABLE_MASK(2),
11268c2ecf20Sopenharmony_ci		   DISABLE_VAL(2), 400),
11278c2ecf20Sopenharmony_ci	RK817_DESC(RK817_ID_LDO4, "LDO_REG4", "vcc6", 600, 3400, 25,
11288c2ecf20Sopenharmony_ci		   RK817_LDO_ON_VSEL_REG(3), RK817_LDO_VSEL_MASK,
11298c2ecf20Sopenharmony_ci		   RK817_POWER_EN_REG(1), ENABLE_MASK(3),
11308c2ecf20Sopenharmony_ci		   DISABLE_VAL(3), 400),
11318c2ecf20Sopenharmony_ci	RK817_DESC(RK817_ID_LDO5, "LDO_REG5", "vcc6", 600, 3400, 25,
11328c2ecf20Sopenharmony_ci		   RK817_LDO_ON_VSEL_REG(4), RK817_LDO_VSEL_MASK,
11338c2ecf20Sopenharmony_ci		   RK817_POWER_EN_REG(2), ENABLE_MASK(0),
11348c2ecf20Sopenharmony_ci		   DISABLE_VAL(0), 400),
11358c2ecf20Sopenharmony_ci	RK817_DESC(RK817_ID_LDO6, "LDO_REG6", "vcc6", 600, 3400, 25,
11368c2ecf20Sopenharmony_ci		   RK817_LDO_ON_VSEL_REG(5), RK817_LDO_VSEL_MASK,
11378c2ecf20Sopenharmony_ci		   RK817_POWER_EN_REG(2), ENABLE_MASK(1),
11388c2ecf20Sopenharmony_ci		   DISABLE_VAL(1), 400),
11398c2ecf20Sopenharmony_ci	RK817_DESC(RK817_ID_LDO7, "LDO_REG7", "vcc7", 600, 3400, 25,
11408c2ecf20Sopenharmony_ci		   RK817_LDO_ON_VSEL_REG(6), RK817_LDO_VSEL_MASK,
11418c2ecf20Sopenharmony_ci		   RK817_POWER_EN_REG(2), ENABLE_MASK(2),
11428c2ecf20Sopenharmony_ci		   DISABLE_VAL(2), 400),
11438c2ecf20Sopenharmony_ci	RK817_DESC(RK817_ID_LDO8, "LDO_REG8", "vcc7", 600, 3400, 25,
11448c2ecf20Sopenharmony_ci		   RK817_LDO_ON_VSEL_REG(7), RK817_LDO_VSEL_MASK,
11458c2ecf20Sopenharmony_ci		   RK817_POWER_EN_REG(2), ENABLE_MASK(3),
11468c2ecf20Sopenharmony_ci		   DISABLE_VAL(3), 400),
11478c2ecf20Sopenharmony_ci	RK817_DESC(RK817_ID_LDO9, "LDO_REG9", "vcc7", 600, 3400, 25,
11488c2ecf20Sopenharmony_ci		   RK817_LDO_ON_VSEL_REG(8), RK817_LDO_VSEL_MASK,
11498c2ecf20Sopenharmony_ci		   RK817_POWER_EN_REG(3), ENABLE_MASK(0),
11508c2ecf20Sopenharmony_ci		   DISABLE_VAL(0), 400),
11518c2ecf20Sopenharmony_ci	RK817_BOOST_DESC(RK817_ID_BOOST, "BOOST", "vcc8", 4700, 5400, 100,
11528c2ecf20Sopenharmony_ci			 RK817_BOOST_OTG_CFG, RK817_BOOST_VSEL_MASK,
11538c2ecf20Sopenharmony_ci			 RK817_POWER_EN_REG(3), ENABLE_MASK(1), ENABLE_MASK(1),
11548c2ecf20Sopenharmony_ci		   DISABLE_VAL(1), 400, 3500 - 5400),
11558c2ecf20Sopenharmony_ci	RK817_DESC_SWITCH(RK817_ID_BOOST_OTG_SW, "OTG_SWITCH", "vcc9",
11568c2ecf20Sopenharmony_ci			  RK817_POWER_EN_REG(3), ENABLE_MASK(2),
11578c2ecf20Sopenharmony_ci			  DISABLE_VAL(2)),
11588c2ecf20Sopenharmony_ci};
11598c2ecf20Sopenharmony_ci
11608c2ecf20Sopenharmony_cistatic const struct regulator_desc rk818_reg[] = {
11618c2ecf20Sopenharmony_ci	{
11628c2ecf20Sopenharmony_ci		.name = "DCDC_REG1",
11638c2ecf20Sopenharmony_ci		.supply_name = "vcc1",
11648c2ecf20Sopenharmony_ci		.of_match = of_match_ptr("DCDC_REG1"),
11658c2ecf20Sopenharmony_ci		.regulators_node = of_match_ptr("regulators"),
11668c2ecf20Sopenharmony_ci		.id = RK818_ID_DCDC1,
11678c2ecf20Sopenharmony_ci		.ops = &rk808_reg_ops,
11688c2ecf20Sopenharmony_ci		.type = REGULATOR_VOLTAGE,
11698c2ecf20Sopenharmony_ci		.min_uV = 712500,
11708c2ecf20Sopenharmony_ci		.uV_step = 12500,
11718c2ecf20Sopenharmony_ci		.n_voltages = 64,
11728c2ecf20Sopenharmony_ci		.vsel_reg = RK818_BUCK1_ON_VSEL_REG,
11738c2ecf20Sopenharmony_ci		.vsel_mask = RK818_BUCK_VSEL_MASK,
11748c2ecf20Sopenharmony_ci		.enable_reg = RK818_DCDC_EN_REG,
11758c2ecf20Sopenharmony_ci		.enable_mask = BIT(0),
11768c2ecf20Sopenharmony_ci		.owner = THIS_MODULE,
11778c2ecf20Sopenharmony_ci	}, {
11788c2ecf20Sopenharmony_ci		.name = "DCDC_REG2",
11798c2ecf20Sopenharmony_ci		.supply_name = "vcc2",
11808c2ecf20Sopenharmony_ci		.of_match = of_match_ptr("DCDC_REG2"),
11818c2ecf20Sopenharmony_ci		.regulators_node = of_match_ptr("regulators"),
11828c2ecf20Sopenharmony_ci		.id = RK818_ID_DCDC2,
11838c2ecf20Sopenharmony_ci		.ops = &rk808_reg_ops,
11848c2ecf20Sopenharmony_ci		.type = REGULATOR_VOLTAGE,
11858c2ecf20Sopenharmony_ci		.min_uV = 712500,
11868c2ecf20Sopenharmony_ci		.uV_step = 12500,
11878c2ecf20Sopenharmony_ci		.n_voltages = 64,
11888c2ecf20Sopenharmony_ci		.vsel_reg = RK818_BUCK2_ON_VSEL_REG,
11898c2ecf20Sopenharmony_ci		.vsel_mask = RK818_BUCK_VSEL_MASK,
11908c2ecf20Sopenharmony_ci		.enable_reg = RK818_DCDC_EN_REG,
11918c2ecf20Sopenharmony_ci		.enable_mask = BIT(1),
11928c2ecf20Sopenharmony_ci		.owner = THIS_MODULE,
11938c2ecf20Sopenharmony_ci	}, {
11948c2ecf20Sopenharmony_ci		.name = "DCDC_REG3",
11958c2ecf20Sopenharmony_ci		.supply_name = "vcc3",
11968c2ecf20Sopenharmony_ci		.of_match = of_match_ptr("DCDC_REG3"),
11978c2ecf20Sopenharmony_ci		.regulators_node = of_match_ptr("regulators"),
11988c2ecf20Sopenharmony_ci		.id = RK818_ID_DCDC3,
11998c2ecf20Sopenharmony_ci		.ops = &rk808_switch_ops,
12008c2ecf20Sopenharmony_ci		.type = REGULATOR_VOLTAGE,
12018c2ecf20Sopenharmony_ci		.n_voltages = 1,
12028c2ecf20Sopenharmony_ci		.enable_reg = RK818_DCDC_EN_REG,
12038c2ecf20Sopenharmony_ci		.enable_mask = BIT(2),
12048c2ecf20Sopenharmony_ci		.owner = THIS_MODULE,
12058c2ecf20Sopenharmony_ci	},
12068c2ecf20Sopenharmony_ci	RK8XX_DESC(RK818_ID_DCDC4, "DCDC_REG4", "vcc4", 1800, 3600, 100,
12078c2ecf20Sopenharmony_ci		RK818_BUCK4_ON_VSEL_REG, RK818_BUCK4_VSEL_MASK,
12088c2ecf20Sopenharmony_ci		RK818_DCDC_EN_REG, BIT(3), 0),
12098c2ecf20Sopenharmony_ci	RK8XX_DESC(RK818_ID_BOOST, "DCDC_BOOST", "boost", 4700, 5400, 100,
12108c2ecf20Sopenharmony_ci		RK818_BOOST_LDO9_ON_VSEL_REG, RK818_BOOST_ON_VSEL_MASK,
12118c2ecf20Sopenharmony_ci		RK818_DCDC_EN_REG, BIT(4), 0),
12128c2ecf20Sopenharmony_ci	RK8XX_DESC(RK818_ID_LDO1, "LDO_REG1", "vcc6", 1800, 3400, 100,
12138c2ecf20Sopenharmony_ci		RK818_LDO1_ON_VSEL_REG, RK818_LDO_VSEL_MASK, RK818_LDO_EN_REG,
12148c2ecf20Sopenharmony_ci		BIT(0), 400),
12158c2ecf20Sopenharmony_ci	RK8XX_DESC(RK818_ID_LDO2, "LDO_REG2", "vcc6", 1800, 3400, 100,
12168c2ecf20Sopenharmony_ci		RK818_LDO2_ON_VSEL_REG, RK818_LDO_VSEL_MASK, RK818_LDO_EN_REG,
12178c2ecf20Sopenharmony_ci		BIT(1), 400),
12188c2ecf20Sopenharmony_ci	{
12198c2ecf20Sopenharmony_ci		.name = "LDO_REG3",
12208c2ecf20Sopenharmony_ci		.supply_name = "vcc7",
12218c2ecf20Sopenharmony_ci		.of_match = of_match_ptr("LDO_REG3"),
12228c2ecf20Sopenharmony_ci		.regulators_node = of_match_ptr("regulators"),
12238c2ecf20Sopenharmony_ci		.id = RK818_ID_LDO3,
12248c2ecf20Sopenharmony_ci		.ops = &rk808_reg_ops_ranges,
12258c2ecf20Sopenharmony_ci		.type = REGULATOR_VOLTAGE,
12268c2ecf20Sopenharmony_ci		.n_voltages = 16,
12278c2ecf20Sopenharmony_ci		.linear_ranges = rk808_ldo3_voltage_ranges,
12288c2ecf20Sopenharmony_ci		.n_linear_ranges = ARRAY_SIZE(rk808_ldo3_voltage_ranges),
12298c2ecf20Sopenharmony_ci		.vsel_reg = RK818_LDO3_ON_VSEL_REG,
12308c2ecf20Sopenharmony_ci		.vsel_mask = RK818_LDO3_ON_VSEL_MASK,
12318c2ecf20Sopenharmony_ci		.enable_reg = RK818_LDO_EN_REG,
12328c2ecf20Sopenharmony_ci		.enable_mask = BIT(2),
12338c2ecf20Sopenharmony_ci		.enable_time = 400,
12348c2ecf20Sopenharmony_ci		.owner = THIS_MODULE,
12358c2ecf20Sopenharmony_ci	},
12368c2ecf20Sopenharmony_ci	RK8XX_DESC(RK818_ID_LDO4, "LDO_REG4", "vcc8", 1800, 3400, 100,
12378c2ecf20Sopenharmony_ci		RK818_LDO4_ON_VSEL_REG, RK818_LDO_VSEL_MASK, RK818_LDO_EN_REG,
12388c2ecf20Sopenharmony_ci		BIT(3), 400),
12398c2ecf20Sopenharmony_ci	RK8XX_DESC(RK818_ID_LDO5, "LDO_REG5", "vcc7", 1800, 3400, 100,
12408c2ecf20Sopenharmony_ci		RK818_LDO5_ON_VSEL_REG, RK818_LDO_VSEL_MASK, RK818_LDO_EN_REG,
12418c2ecf20Sopenharmony_ci		BIT(4), 400),
12428c2ecf20Sopenharmony_ci	RK8XX_DESC(RK818_ID_LDO6, "LDO_REG6", "vcc8", 800, 2500, 100,
12438c2ecf20Sopenharmony_ci		RK818_LDO6_ON_VSEL_REG, RK818_LDO_VSEL_MASK, RK818_LDO_EN_REG,
12448c2ecf20Sopenharmony_ci		BIT(5), 400),
12458c2ecf20Sopenharmony_ci	RK8XX_DESC(RK818_ID_LDO7, "LDO_REG7", "vcc7", 800, 2500, 100,
12468c2ecf20Sopenharmony_ci		RK818_LDO7_ON_VSEL_REG, RK818_LDO_VSEL_MASK, RK818_LDO_EN_REG,
12478c2ecf20Sopenharmony_ci		BIT(6), 400),
12488c2ecf20Sopenharmony_ci	RK8XX_DESC(RK818_ID_LDO8, "LDO_REG8", "vcc8", 1800, 3400, 100,
12498c2ecf20Sopenharmony_ci		RK818_LDO8_ON_VSEL_REG, RK818_LDO_VSEL_MASK, RK818_LDO_EN_REG,
12508c2ecf20Sopenharmony_ci		BIT(7), 400),
12518c2ecf20Sopenharmony_ci	RK8XX_DESC(RK818_ID_LDO9, "LDO_REG9", "vcc9", 1800, 3400, 100,
12528c2ecf20Sopenharmony_ci		RK818_BOOST_LDO9_ON_VSEL_REG, RK818_LDO_VSEL_MASK,
12538c2ecf20Sopenharmony_ci		RK818_DCDC_EN_REG, BIT(5), 400),
12548c2ecf20Sopenharmony_ci	RK8XX_DESC_SWITCH(RK818_ID_SWITCH, "SWITCH_REG", "vcc9",
12558c2ecf20Sopenharmony_ci		RK818_DCDC_EN_REG, BIT(6)),
12568c2ecf20Sopenharmony_ci	RK8XX_DESC_SWITCH(RK818_ID_HDMI_SWITCH, "HDMI_SWITCH", "h_5v",
12578c2ecf20Sopenharmony_ci		RK818_H5V_EN_REG, BIT(0)),
12588c2ecf20Sopenharmony_ci	RK8XX_DESC_SWITCH(RK818_ID_OTG_SWITCH, "OTG_SWITCH", "usb",
12598c2ecf20Sopenharmony_ci		RK818_DCDC_EN_REG, BIT(7)),
12608c2ecf20Sopenharmony_ci};
12618c2ecf20Sopenharmony_ci
12628c2ecf20Sopenharmony_cistatic int rk808_regulator_dt_parse_pdata(struct device *dev,
12638c2ecf20Sopenharmony_ci				   struct device *client_dev,
12648c2ecf20Sopenharmony_ci				   struct regmap *map,
12658c2ecf20Sopenharmony_ci				   struct rk808_regulator_data *pdata)
12668c2ecf20Sopenharmony_ci{
12678c2ecf20Sopenharmony_ci	struct device_node *np;
12688c2ecf20Sopenharmony_ci	int tmp, ret = 0, i;
12698c2ecf20Sopenharmony_ci
12708c2ecf20Sopenharmony_ci	np = of_get_child_by_name(client_dev->of_node, "regulators");
12718c2ecf20Sopenharmony_ci	if (!np)
12728c2ecf20Sopenharmony_ci		return -ENXIO;
12738c2ecf20Sopenharmony_ci
12748c2ecf20Sopenharmony_ci	for (i = 0; i < ARRAY_SIZE(pdata->dvs_gpio); i++) {
12758c2ecf20Sopenharmony_ci		pdata->dvs_gpio[i] =
12768c2ecf20Sopenharmony_ci			devm_gpiod_get_index_optional(client_dev, "dvs", i,
12778c2ecf20Sopenharmony_ci						      GPIOD_OUT_LOW);
12788c2ecf20Sopenharmony_ci		if (IS_ERR(pdata->dvs_gpio[i])) {
12798c2ecf20Sopenharmony_ci			ret = PTR_ERR(pdata->dvs_gpio[i]);
12808c2ecf20Sopenharmony_ci			dev_err(dev, "failed to get dvs%d gpio (%d)\n", i, ret);
12818c2ecf20Sopenharmony_ci			goto dt_parse_end;
12828c2ecf20Sopenharmony_ci		}
12838c2ecf20Sopenharmony_ci
12848c2ecf20Sopenharmony_ci		if (!pdata->dvs_gpio[i]) {
12858c2ecf20Sopenharmony_ci			dev_info(dev, "there is no dvs%d gpio\n", i);
12868c2ecf20Sopenharmony_ci			continue;
12878c2ecf20Sopenharmony_ci		}
12888c2ecf20Sopenharmony_ci
12898c2ecf20Sopenharmony_ci		tmp = i ? RK808_DVS2_POL : RK808_DVS1_POL;
12908c2ecf20Sopenharmony_ci		ret = regmap_update_bits(map, RK808_IO_POL_REG, tmp,
12918c2ecf20Sopenharmony_ci				gpiod_is_active_low(pdata->dvs_gpio[i]) ?
12928c2ecf20Sopenharmony_ci				0 : tmp);
12938c2ecf20Sopenharmony_ci	}
12948c2ecf20Sopenharmony_ci
12958c2ecf20Sopenharmony_cidt_parse_end:
12968c2ecf20Sopenharmony_ci	of_node_put(np);
12978c2ecf20Sopenharmony_ci	return ret;
12988c2ecf20Sopenharmony_ci}
12998c2ecf20Sopenharmony_ci
13008c2ecf20Sopenharmony_cistatic int rk808_regulator_probe(struct platform_device *pdev)
13018c2ecf20Sopenharmony_ci{
13028c2ecf20Sopenharmony_ci	struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent);
13038c2ecf20Sopenharmony_ci	struct i2c_client *client = rk808->i2c;
13048c2ecf20Sopenharmony_ci	struct regulator_config config = {};
13058c2ecf20Sopenharmony_ci	struct regulator_dev *rk808_rdev;
13068c2ecf20Sopenharmony_ci	struct rk808_regulator_data *pdata;
13078c2ecf20Sopenharmony_ci	const struct regulator_desc *regulators;
13088c2ecf20Sopenharmony_ci	int ret, i, nregulators;
13098c2ecf20Sopenharmony_ci
13108c2ecf20Sopenharmony_ci	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
13118c2ecf20Sopenharmony_ci	if (!pdata)
13128c2ecf20Sopenharmony_ci		return -ENOMEM;
13138c2ecf20Sopenharmony_ci
13148c2ecf20Sopenharmony_ci	ret = rk808_regulator_dt_parse_pdata(&pdev->dev, &client->dev,
13158c2ecf20Sopenharmony_ci					     rk808->regmap, pdata);
13168c2ecf20Sopenharmony_ci	if (ret < 0)
13178c2ecf20Sopenharmony_ci		return ret;
13188c2ecf20Sopenharmony_ci
13198c2ecf20Sopenharmony_ci	platform_set_drvdata(pdev, pdata);
13208c2ecf20Sopenharmony_ci
13218c2ecf20Sopenharmony_ci	switch (rk808->variant) {
13228c2ecf20Sopenharmony_ci	case RK805_ID:
13238c2ecf20Sopenharmony_ci		regulators = rk805_reg;
13248c2ecf20Sopenharmony_ci		nregulators = RK805_NUM_REGULATORS;
13258c2ecf20Sopenharmony_ci		break;
13268c2ecf20Sopenharmony_ci	case RK808_ID:
13278c2ecf20Sopenharmony_ci		regulators = rk808_reg;
13288c2ecf20Sopenharmony_ci		nregulators = RK808_NUM_REGULATORS;
13298c2ecf20Sopenharmony_ci		break;
13308c2ecf20Sopenharmony_ci	case RK809_ID:
13318c2ecf20Sopenharmony_ci		regulators = rk809_reg;
13328c2ecf20Sopenharmony_ci		nregulators = RK809_NUM_REGULATORS;
13338c2ecf20Sopenharmony_ci		break;
13348c2ecf20Sopenharmony_ci	case RK817_ID:
13358c2ecf20Sopenharmony_ci		regulators = rk817_reg;
13368c2ecf20Sopenharmony_ci		nregulators = RK817_NUM_REGULATORS;
13378c2ecf20Sopenharmony_ci		break;
13388c2ecf20Sopenharmony_ci	case RK818_ID:
13398c2ecf20Sopenharmony_ci		regulators = rk818_reg;
13408c2ecf20Sopenharmony_ci		nregulators = RK818_NUM_REGULATORS;
13418c2ecf20Sopenharmony_ci		break;
13428c2ecf20Sopenharmony_ci	default:
13438c2ecf20Sopenharmony_ci		dev_err(&client->dev, "unsupported RK8XX ID %lu\n",
13448c2ecf20Sopenharmony_ci			rk808->variant);
13458c2ecf20Sopenharmony_ci		return -EINVAL;
13468c2ecf20Sopenharmony_ci	}
13478c2ecf20Sopenharmony_ci
13488c2ecf20Sopenharmony_ci	config.dev = &client->dev;
13498c2ecf20Sopenharmony_ci	config.driver_data = pdata;
13508c2ecf20Sopenharmony_ci	config.regmap = rk808->regmap;
13518c2ecf20Sopenharmony_ci
13528c2ecf20Sopenharmony_ci	/* Instantiate the regulators */
13538c2ecf20Sopenharmony_ci	for (i = 0; i < nregulators; i++) {
13548c2ecf20Sopenharmony_ci		rk808_rdev = devm_regulator_register(&pdev->dev,
13558c2ecf20Sopenharmony_ci						     &regulators[i], &config);
13568c2ecf20Sopenharmony_ci		if (IS_ERR(rk808_rdev)) {
13578c2ecf20Sopenharmony_ci			dev_err(&client->dev,
13588c2ecf20Sopenharmony_ci				"failed to register %d regulator\n", i);
13598c2ecf20Sopenharmony_ci			return PTR_ERR(rk808_rdev);
13608c2ecf20Sopenharmony_ci		}
13618c2ecf20Sopenharmony_ci	}
13628c2ecf20Sopenharmony_ci
13638c2ecf20Sopenharmony_ci	return 0;
13648c2ecf20Sopenharmony_ci}
13658c2ecf20Sopenharmony_ci
13668c2ecf20Sopenharmony_cistatic struct platform_driver rk808_regulator_driver = {
13678c2ecf20Sopenharmony_ci	.probe = rk808_regulator_probe,
13688c2ecf20Sopenharmony_ci	.driver = {
13698c2ecf20Sopenharmony_ci		.name = "rk808-regulator"
13708c2ecf20Sopenharmony_ci	},
13718c2ecf20Sopenharmony_ci};
13728c2ecf20Sopenharmony_ci
13738c2ecf20Sopenharmony_cimodule_platform_driver(rk808_regulator_driver);
13748c2ecf20Sopenharmony_ci
13758c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("regulator driver for the RK805/RK808/RK818 series PMICs");
13768c2ecf20Sopenharmony_ciMODULE_AUTHOR("Tony xie <tony.xie@rock-chips.com>");
13778c2ecf20Sopenharmony_ciMODULE_AUTHOR("Chris Zhong <zyw@rock-chips.com>");
13788c2ecf20Sopenharmony_ciMODULE_AUTHOR("Zhang Qing <zhangqing@rock-chips.com>");
13798c2ecf20Sopenharmony_ciMODULE_AUTHOR("Wadim Egorov <w.egorov@phytec.de>");
13808c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL");
13818c2ecf20Sopenharmony_ciMODULE_ALIAS("platform:rk808-regulator");
1382