18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci// Copyright (C) 2019 ROHM Semiconductors
38c2ecf20Sopenharmony_ci// bd71828-regulator.c ROHM BD71828GW-DS1 regulator driver
48c2ecf20Sopenharmony_ci//
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#include <linux/delay.h>
78c2ecf20Sopenharmony_ci#include <linux/err.h>
88c2ecf20Sopenharmony_ci#include <linux/gpio.h>
98c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
108c2ecf20Sopenharmony_ci#include <linux/kernel.h>
118c2ecf20Sopenharmony_ci#include <linux/mfd/rohm-bd71828.h>
128c2ecf20Sopenharmony_ci#include <linux/module.h>
138c2ecf20Sopenharmony_ci#include <linux/of.h>
148c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
158c2ecf20Sopenharmony_ci#include <linux/regmap.h>
168c2ecf20Sopenharmony_ci#include <linux/regulator/driver.h>
178c2ecf20Sopenharmony_ci#include <linux/regulator/machine.h>
188c2ecf20Sopenharmony_ci#include <linux/regulator/of_regulator.h>
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_cistruct reg_init {
218c2ecf20Sopenharmony_ci	unsigned int reg;
228c2ecf20Sopenharmony_ci	unsigned int mask;
238c2ecf20Sopenharmony_ci	unsigned int val;
248c2ecf20Sopenharmony_ci};
258c2ecf20Sopenharmony_cistruct bd71828_regulator_data {
268c2ecf20Sopenharmony_ci	struct regulator_desc desc;
278c2ecf20Sopenharmony_ci	const struct rohm_dvs_config dvs;
288c2ecf20Sopenharmony_ci	const struct reg_init *reg_inits;
298c2ecf20Sopenharmony_ci	int reg_init_amnt;
308c2ecf20Sopenharmony_ci};
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_cistatic const struct reg_init buck1_inits[] = {
338c2ecf20Sopenharmony_ci	/*
348c2ecf20Sopenharmony_ci	 * DVS Buck voltages can be changed by register values or via GPIO.
358c2ecf20Sopenharmony_ci	 * Use register accesses by default.
368c2ecf20Sopenharmony_ci	 */
378c2ecf20Sopenharmony_ci	{
388c2ecf20Sopenharmony_ci		.reg = BD71828_REG_PS_CTRL_1,
398c2ecf20Sopenharmony_ci		.mask = BD71828_MASK_DVS_BUCK1_CTRL,
408c2ecf20Sopenharmony_ci		.val = BD71828_DVS_BUCK1_CTRL_I2C,
418c2ecf20Sopenharmony_ci	},
428c2ecf20Sopenharmony_ci};
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_cistatic const struct reg_init buck2_inits[] = {
458c2ecf20Sopenharmony_ci	{
468c2ecf20Sopenharmony_ci		.reg = BD71828_REG_PS_CTRL_1,
478c2ecf20Sopenharmony_ci		.mask = BD71828_MASK_DVS_BUCK2_CTRL,
488c2ecf20Sopenharmony_ci		.val = BD71828_DVS_BUCK2_CTRL_I2C,
498c2ecf20Sopenharmony_ci	},
508c2ecf20Sopenharmony_ci};
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_cistatic const struct reg_init buck6_inits[] = {
538c2ecf20Sopenharmony_ci	{
548c2ecf20Sopenharmony_ci		.reg = BD71828_REG_PS_CTRL_1,
558c2ecf20Sopenharmony_ci		.mask = BD71828_MASK_DVS_BUCK6_CTRL,
568c2ecf20Sopenharmony_ci		.val = BD71828_DVS_BUCK6_CTRL_I2C,
578c2ecf20Sopenharmony_ci	},
588c2ecf20Sopenharmony_ci};
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_cistatic const struct reg_init buck7_inits[] = {
618c2ecf20Sopenharmony_ci	{
628c2ecf20Sopenharmony_ci		.reg = BD71828_REG_PS_CTRL_1,
638c2ecf20Sopenharmony_ci		.mask = BD71828_MASK_DVS_BUCK7_CTRL,
648c2ecf20Sopenharmony_ci		.val = BD71828_DVS_BUCK7_CTRL_I2C,
658c2ecf20Sopenharmony_ci	},
668c2ecf20Sopenharmony_ci};
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_cistatic const struct linear_range bd71828_buck1267_volts[] = {
698c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(500000, 0x00, 0xef, 6250),
708c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(2000000, 0xf0, 0xff, 0),
718c2ecf20Sopenharmony_ci};
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_cistatic const struct linear_range bd71828_buck3_volts[] = {
748c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1200000, 0x00, 0x0f, 50000),
758c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(2000000, 0x10, 0x1f, 0),
768c2ecf20Sopenharmony_ci};
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_cistatic const struct linear_range bd71828_buck4_volts[] = {
798c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1000000, 0x00, 0x1f, 25000),
808c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1800000, 0x20, 0x3f, 0),
818c2ecf20Sopenharmony_ci};
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_cistatic const struct linear_range bd71828_buck5_volts[] = {
848c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(2500000, 0x00, 0x0f, 50000),
858c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(3300000, 0x10, 0x1f, 0),
868c2ecf20Sopenharmony_ci};
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_cistatic const struct linear_range bd71828_ldo_volts[] = {
898c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(800000, 0x00, 0x31, 50000),
908c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(3300000, 0x32, 0x3f, 0),
918c2ecf20Sopenharmony_ci};
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_cistatic int bd71828_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
948c2ecf20Sopenharmony_ci{
958c2ecf20Sopenharmony_ci	unsigned int val;
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci	switch (ramp_delay) {
988c2ecf20Sopenharmony_ci	case 1 ... 2500:
998c2ecf20Sopenharmony_ci		val = 0;
1008c2ecf20Sopenharmony_ci		break;
1018c2ecf20Sopenharmony_ci	case 2501 ... 5000:
1028c2ecf20Sopenharmony_ci		val = 1;
1038c2ecf20Sopenharmony_ci		break;
1048c2ecf20Sopenharmony_ci	case 5001 ... 10000:
1058c2ecf20Sopenharmony_ci		val = 2;
1068c2ecf20Sopenharmony_ci		break;
1078c2ecf20Sopenharmony_ci	case 10001 ... 20000:
1088c2ecf20Sopenharmony_ci		val = 3;
1098c2ecf20Sopenharmony_ci		break;
1108c2ecf20Sopenharmony_ci	default:
1118c2ecf20Sopenharmony_ci		val = 3;
1128c2ecf20Sopenharmony_ci		dev_err(&rdev->dev,
1138c2ecf20Sopenharmony_ci			"ramp_delay: %d not supported, setting 20mV/uS",
1148c2ecf20Sopenharmony_ci			 ramp_delay);
1158c2ecf20Sopenharmony_ci	}
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci	/*
1188c2ecf20Sopenharmony_ci	 * On BD71828 the ramp delay level control reg is at offset +2 to
1198c2ecf20Sopenharmony_ci	 * enable reg
1208c2ecf20Sopenharmony_ci	 */
1218c2ecf20Sopenharmony_ci	return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg + 2,
1228c2ecf20Sopenharmony_ci				  BD71828_MASK_RAMP_DELAY,
1238c2ecf20Sopenharmony_ci				  val << (ffs(BD71828_MASK_RAMP_DELAY) - 1));
1248c2ecf20Sopenharmony_ci}
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_cistatic int buck_set_hw_dvs_levels(struct device_node *np,
1278c2ecf20Sopenharmony_ci				  const struct regulator_desc *desc,
1288c2ecf20Sopenharmony_ci				  struct regulator_config *cfg)
1298c2ecf20Sopenharmony_ci{
1308c2ecf20Sopenharmony_ci	struct bd71828_regulator_data *data;
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci	data = container_of(desc, struct bd71828_regulator_data, desc);
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci	return rohm_regulator_set_dvs_levels(&data->dvs, np, desc, cfg->regmap);
1358c2ecf20Sopenharmony_ci}
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_cistatic int ldo6_parse_dt(struct device_node *np,
1388c2ecf20Sopenharmony_ci			 const struct regulator_desc *desc,
1398c2ecf20Sopenharmony_ci			 struct regulator_config *cfg)
1408c2ecf20Sopenharmony_ci{
1418c2ecf20Sopenharmony_ci	int ret, i;
1428c2ecf20Sopenharmony_ci	uint32_t uv = 0;
1438c2ecf20Sopenharmony_ci	unsigned int en;
1448c2ecf20Sopenharmony_ci	struct regmap *regmap = cfg->regmap;
1458c2ecf20Sopenharmony_ci	static const char * const props[] = { "rohm,dvs-run-voltage",
1468c2ecf20Sopenharmony_ci					      "rohm,dvs-idle-voltage",
1478c2ecf20Sopenharmony_ci					      "rohm,dvs-suspend-voltage",
1488c2ecf20Sopenharmony_ci					      "rohm,dvs-lpsr-voltage" };
1498c2ecf20Sopenharmony_ci	unsigned int mask[] = { BD71828_MASK_RUN_EN, BD71828_MASK_IDLE_EN,
1508c2ecf20Sopenharmony_ci			       BD71828_MASK_SUSP_EN, BD71828_MASK_LPSR_EN };
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ci	for (i = 0; i < ARRAY_SIZE(props); i++) {
1538c2ecf20Sopenharmony_ci		ret = of_property_read_u32(np, props[i], &uv);
1548c2ecf20Sopenharmony_ci		if (ret) {
1558c2ecf20Sopenharmony_ci			if (ret != -EINVAL)
1568c2ecf20Sopenharmony_ci				return ret;
1578c2ecf20Sopenharmony_ci			continue;
1588c2ecf20Sopenharmony_ci		}
1598c2ecf20Sopenharmony_ci		if (uv)
1608c2ecf20Sopenharmony_ci			en = 0xffffffff;
1618c2ecf20Sopenharmony_ci		else
1628c2ecf20Sopenharmony_ci			en = 0;
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci		ret = regmap_update_bits(regmap, desc->enable_reg, mask[i], en);
1658c2ecf20Sopenharmony_ci		if (ret)
1668c2ecf20Sopenharmony_ci			return ret;
1678c2ecf20Sopenharmony_ci	}
1688c2ecf20Sopenharmony_ci	return 0;
1698c2ecf20Sopenharmony_ci}
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_cistatic const struct regulator_ops bd71828_buck_ops = {
1728c2ecf20Sopenharmony_ci	.enable = regulator_enable_regmap,
1738c2ecf20Sopenharmony_ci	.disable = regulator_disable_regmap,
1748c2ecf20Sopenharmony_ci	.is_enabled = regulator_is_enabled_regmap,
1758c2ecf20Sopenharmony_ci	.list_voltage = regulator_list_voltage_linear_range,
1768c2ecf20Sopenharmony_ci	.set_voltage_sel = regulator_set_voltage_sel_regmap,
1778c2ecf20Sopenharmony_ci	.get_voltage_sel = regulator_get_voltage_sel_regmap,
1788c2ecf20Sopenharmony_ci};
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_cistatic const struct regulator_ops bd71828_dvs_buck_ops = {
1818c2ecf20Sopenharmony_ci	.enable = regulator_enable_regmap,
1828c2ecf20Sopenharmony_ci	.disable = regulator_disable_regmap,
1838c2ecf20Sopenharmony_ci	.is_enabled = regulator_is_enabled_regmap,
1848c2ecf20Sopenharmony_ci	.list_voltage = regulator_list_voltage_linear_range,
1858c2ecf20Sopenharmony_ci	.set_voltage_sel = regulator_set_voltage_sel_regmap,
1868c2ecf20Sopenharmony_ci	.get_voltage_sel = regulator_get_voltage_sel_regmap,
1878c2ecf20Sopenharmony_ci	.set_voltage_time_sel = regulator_set_voltage_time_sel,
1888c2ecf20Sopenharmony_ci	.set_ramp_delay = bd71828_set_ramp_delay,
1898c2ecf20Sopenharmony_ci};
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_cistatic const struct regulator_ops bd71828_ldo_ops = {
1928c2ecf20Sopenharmony_ci	.enable = regulator_enable_regmap,
1938c2ecf20Sopenharmony_ci	.disable = regulator_disable_regmap,
1948c2ecf20Sopenharmony_ci	.is_enabled = regulator_is_enabled_regmap,
1958c2ecf20Sopenharmony_ci	.list_voltage = regulator_list_voltage_linear_range,
1968c2ecf20Sopenharmony_ci	.set_voltage_sel = regulator_set_voltage_sel_regmap,
1978c2ecf20Sopenharmony_ci	.get_voltage_sel = regulator_get_voltage_sel_regmap,
1988c2ecf20Sopenharmony_ci};
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_cistatic const struct regulator_ops bd71828_ldo6_ops = {
2018c2ecf20Sopenharmony_ci	.enable = regulator_enable_regmap,
2028c2ecf20Sopenharmony_ci	.disable = regulator_disable_regmap,
2038c2ecf20Sopenharmony_ci	.is_enabled = regulator_is_enabled_regmap,
2048c2ecf20Sopenharmony_ci};
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_cistatic const struct bd71828_regulator_data bd71828_rdata[] = {
2078c2ecf20Sopenharmony_ci	{
2088c2ecf20Sopenharmony_ci		.desc = {
2098c2ecf20Sopenharmony_ci			.name = "buck1",
2108c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("BUCK1"),
2118c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
2128c2ecf20Sopenharmony_ci			.id = BD71828_BUCK1,
2138c2ecf20Sopenharmony_ci			.ops = &bd71828_dvs_buck_ops,
2148c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
2158c2ecf20Sopenharmony_ci			.linear_ranges = bd71828_buck1267_volts,
2168c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd71828_buck1267_volts),
2178c2ecf20Sopenharmony_ci			.n_voltages = BD71828_BUCK1267_VOLTS,
2188c2ecf20Sopenharmony_ci			.enable_reg = BD71828_REG_BUCK1_EN,
2198c2ecf20Sopenharmony_ci			.enable_mask = BD71828_MASK_RUN_EN,
2208c2ecf20Sopenharmony_ci			.vsel_reg = BD71828_REG_BUCK1_VOLT,
2218c2ecf20Sopenharmony_ci			.vsel_mask = BD71828_MASK_BUCK1267_VOLT,
2228c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
2238c2ecf20Sopenharmony_ci			.of_parse_cb = buck_set_hw_dvs_levels,
2248c2ecf20Sopenharmony_ci		},
2258c2ecf20Sopenharmony_ci		.dvs = {
2268c2ecf20Sopenharmony_ci			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
2278c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_SUSPEND |
2288c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_LPSR,
2298c2ecf20Sopenharmony_ci			.run_reg = BD71828_REG_BUCK1_VOLT,
2308c2ecf20Sopenharmony_ci			.run_mask = BD71828_MASK_BUCK1267_VOLT,
2318c2ecf20Sopenharmony_ci			.idle_reg = BD71828_REG_BUCK1_IDLE_VOLT,
2328c2ecf20Sopenharmony_ci			.idle_mask = BD71828_MASK_BUCK1267_VOLT,
2338c2ecf20Sopenharmony_ci			.idle_on_mask = BD71828_MASK_IDLE_EN,
2348c2ecf20Sopenharmony_ci			.suspend_reg = BD71828_REG_BUCK1_SUSP_VOLT,
2358c2ecf20Sopenharmony_ci			.suspend_mask = BD71828_MASK_BUCK1267_VOLT,
2368c2ecf20Sopenharmony_ci			.suspend_on_mask = BD71828_MASK_SUSP_EN,
2378c2ecf20Sopenharmony_ci			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
2388c2ecf20Sopenharmony_ci			/*
2398c2ecf20Sopenharmony_ci			 * LPSR voltage is same as SUSPEND voltage. Allow
2408c2ecf20Sopenharmony_ci			 * setting it so that regulator can be set enabled at
2418c2ecf20Sopenharmony_ci			 * LPSR state
2428c2ecf20Sopenharmony_ci			 */
2438c2ecf20Sopenharmony_ci			.lpsr_reg = BD71828_REG_BUCK1_SUSP_VOLT,
2448c2ecf20Sopenharmony_ci			.lpsr_mask = BD71828_MASK_BUCK1267_VOLT,
2458c2ecf20Sopenharmony_ci		},
2468c2ecf20Sopenharmony_ci		.reg_inits = buck1_inits,
2478c2ecf20Sopenharmony_ci		.reg_init_amnt = ARRAY_SIZE(buck1_inits),
2488c2ecf20Sopenharmony_ci	},
2498c2ecf20Sopenharmony_ci	{
2508c2ecf20Sopenharmony_ci		.desc = {
2518c2ecf20Sopenharmony_ci			.name = "buck2",
2528c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("BUCK2"),
2538c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
2548c2ecf20Sopenharmony_ci			.id = BD71828_BUCK2,
2558c2ecf20Sopenharmony_ci			.ops = &bd71828_dvs_buck_ops,
2568c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
2578c2ecf20Sopenharmony_ci			.linear_ranges = bd71828_buck1267_volts,
2588c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd71828_buck1267_volts),
2598c2ecf20Sopenharmony_ci			.n_voltages = BD71828_BUCK1267_VOLTS,
2608c2ecf20Sopenharmony_ci			.enable_reg = BD71828_REG_BUCK2_EN,
2618c2ecf20Sopenharmony_ci			.enable_mask = BD71828_MASK_RUN_EN,
2628c2ecf20Sopenharmony_ci			.vsel_reg = BD71828_REG_BUCK2_VOLT,
2638c2ecf20Sopenharmony_ci			.vsel_mask = BD71828_MASK_BUCK1267_VOLT,
2648c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
2658c2ecf20Sopenharmony_ci			.of_parse_cb = buck_set_hw_dvs_levels,
2668c2ecf20Sopenharmony_ci		},
2678c2ecf20Sopenharmony_ci		.dvs = {
2688c2ecf20Sopenharmony_ci			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
2698c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_SUSPEND |
2708c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_LPSR,
2718c2ecf20Sopenharmony_ci			.run_reg = BD71828_REG_BUCK2_VOLT,
2728c2ecf20Sopenharmony_ci			.run_mask = BD71828_MASK_BUCK1267_VOLT,
2738c2ecf20Sopenharmony_ci			.idle_reg = BD71828_REG_BUCK2_IDLE_VOLT,
2748c2ecf20Sopenharmony_ci			.idle_mask = BD71828_MASK_BUCK1267_VOLT,
2758c2ecf20Sopenharmony_ci			.idle_on_mask = BD71828_MASK_IDLE_EN,
2768c2ecf20Sopenharmony_ci			.suspend_reg = BD71828_REG_BUCK2_SUSP_VOLT,
2778c2ecf20Sopenharmony_ci			.suspend_mask = BD71828_MASK_BUCK1267_VOLT,
2788c2ecf20Sopenharmony_ci			.suspend_on_mask = BD71828_MASK_SUSP_EN,
2798c2ecf20Sopenharmony_ci			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
2808c2ecf20Sopenharmony_ci			.lpsr_reg = BD71828_REG_BUCK2_SUSP_VOLT,
2818c2ecf20Sopenharmony_ci			.lpsr_mask = BD71828_MASK_BUCK1267_VOLT,
2828c2ecf20Sopenharmony_ci		},
2838c2ecf20Sopenharmony_ci		.reg_inits = buck2_inits,
2848c2ecf20Sopenharmony_ci		.reg_init_amnt = ARRAY_SIZE(buck2_inits),
2858c2ecf20Sopenharmony_ci	},
2868c2ecf20Sopenharmony_ci	{
2878c2ecf20Sopenharmony_ci		.desc = {
2888c2ecf20Sopenharmony_ci			.name = "buck3",
2898c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("BUCK3"),
2908c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
2918c2ecf20Sopenharmony_ci			.id = BD71828_BUCK3,
2928c2ecf20Sopenharmony_ci			.ops = &bd71828_buck_ops,
2938c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
2948c2ecf20Sopenharmony_ci			.linear_ranges = bd71828_buck3_volts,
2958c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd71828_buck3_volts),
2968c2ecf20Sopenharmony_ci			.n_voltages = BD71828_BUCK3_VOLTS,
2978c2ecf20Sopenharmony_ci			.enable_reg = BD71828_REG_BUCK3_EN,
2988c2ecf20Sopenharmony_ci			.enable_mask = BD71828_MASK_RUN_EN,
2998c2ecf20Sopenharmony_ci			.vsel_reg = BD71828_REG_BUCK3_VOLT,
3008c2ecf20Sopenharmony_ci			.vsel_mask = BD71828_MASK_BUCK3_VOLT,
3018c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
3028c2ecf20Sopenharmony_ci			.of_parse_cb = buck_set_hw_dvs_levels,
3038c2ecf20Sopenharmony_ci		},
3048c2ecf20Sopenharmony_ci		.dvs = {
3058c2ecf20Sopenharmony_ci			/*
3068c2ecf20Sopenharmony_ci			 * BUCK3 only supports single voltage for all states.
3078c2ecf20Sopenharmony_ci			 * voltage can be individually enabled for each state
3088c2ecf20Sopenharmony_ci			 * though => allow setting all states to support
3098c2ecf20Sopenharmony_ci			 * enabling power rail on different states.
3108c2ecf20Sopenharmony_ci			 */
3118c2ecf20Sopenharmony_ci			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
3128c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_SUSPEND |
3138c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_LPSR,
3148c2ecf20Sopenharmony_ci			.run_reg = BD71828_REG_BUCK3_VOLT,
3158c2ecf20Sopenharmony_ci			.idle_reg = BD71828_REG_BUCK3_VOLT,
3168c2ecf20Sopenharmony_ci			.suspend_reg = BD71828_REG_BUCK3_VOLT,
3178c2ecf20Sopenharmony_ci			.lpsr_reg = BD71828_REG_BUCK3_VOLT,
3188c2ecf20Sopenharmony_ci			.run_mask = BD71828_MASK_BUCK3_VOLT,
3198c2ecf20Sopenharmony_ci			.idle_mask = BD71828_MASK_BUCK3_VOLT,
3208c2ecf20Sopenharmony_ci			.suspend_mask = BD71828_MASK_BUCK3_VOLT,
3218c2ecf20Sopenharmony_ci			.lpsr_mask = BD71828_MASK_BUCK3_VOLT,
3228c2ecf20Sopenharmony_ci			.idle_on_mask = BD71828_MASK_IDLE_EN,
3238c2ecf20Sopenharmony_ci			.suspend_on_mask = BD71828_MASK_SUSP_EN,
3248c2ecf20Sopenharmony_ci			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
3258c2ecf20Sopenharmony_ci		},
3268c2ecf20Sopenharmony_ci	},
3278c2ecf20Sopenharmony_ci	{
3288c2ecf20Sopenharmony_ci		.desc = {
3298c2ecf20Sopenharmony_ci			.name = "buck4",
3308c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("BUCK4"),
3318c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
3328c2ecf20Sopenharmony_ci			.id = BD71828_BUCK4,
3338c2ecf20Sopenharmony_ci			.ops = &bd71828_buck_ops,
3348c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
3358c2ecf20Sopenharmony_ci			.linear_ranges = bd71828_buck4_volts,
3368c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd71828_buck4_volts),
3378c2ecf20Sopenharmony_ci			.n_voltages = BD71828_BUCK4_VOLTS,
3388c2ecf20Sopenharmony_ci			.enable_reg = BD71828_REG_BUCK4_EN,
3398c2ecf20Sopenharmony_ci			.enable_mask = BD71828_MASK_RUN_EN,
3408c2ecf20Sopenharmony_ci			.vsel_reg = BD71828_REG_BUCK4_VOLT,
3418c2ecf20Sopenharmony_ci			.vsel_mask = BD71828_MASK_BUCK4_VOLT,
3428c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
3438c2ecf20Sopenharmony_ci			.of_parse_cb = buck_set_hw_dvs_levels,
3448c2ecf20Sopenharmony_ci		},
3458c2ecf20Sopenharmony_ci		.dvs = {
3468c2ecf20Sopenharmony_ci			/*
3478c2ecf20Sopenharmony_ci			 * BUCK4 only supports single voltage for all states.
3488c2ecf20Sopenharmony_ci			 * voltage can be individually enabled for each state
3498c2ecf20Sopenharmony_ci			 * though => allow setting all states to support
3508c2ecf20Sopenharmony_ci			 * enabling power rail on different states.
3518c2ecf20Sopenharmony_ci			 */
3528c2ecf20Sopenharmony_ci			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
3538c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_SUSPEND |
3548c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_LPSR,
3558c2ecf20Sopenharmony_ci			.run_reg = BD71828_REG_BUCK4_VOLT,
3568c2ecf20Sopenharmony_ci			.idle_reg = BD71828_REG_BUCK4_VOLT,
3578c2ecf20Sopenharmony_ci			.suspend_reg = BD71828_REG_BUCK4_VOLT,
3588c2ecf20Sopenharmony_ci			.lpsr_reg = BD71828_REG_BUCK4_VOLT,
3598c2ecf20Sopenharmony_ci			.run_mask = BD71828_MASK_BUCK4_VOLT,
3608c2ecf20Sopenharmony_ci			.idle_mask = BD71828_MASK_BUCK4_VOLT,
3618c2ecf20Sopenharmony_ci			.suspend_mask = BD71828_MASK_BUCK4_VOLT,
3628c2ecf20Sopenharmony_ci			.lpsr_mask = BD71828_MASK_BUCK4_VOLT,
3638c2ecf20Sopenharmony_ci			.idle_on_mask = BD71828_MASK_IDLE_EN,
3648c2ecf20Sopenharmony_ci			.suspend_on_mask = BD71828_MASK_SUSP_EN,
3658c2ecf20Sopenharmony_ci			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
3668c2ecf20Sopenharmony_ci		},
3678c2ecf20Sopenharmony_ci	},
3688c2ecf20Sopenharmony_ci	{
3698c2ecf20Sopenharmony_ci		.desc = {
3708c2ecf20Sopenharmony_ci			.name = "buck5",
3718c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("BUCK5"),
3728c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
3738c2ecf20Sopenharmony_ci			.id = BD71828_BUCK5,
3748c2ecf20Sopenharmony_ci			.ops = &bd71828_buck_ops,
3758c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
3768c2ecf20Sopenharmony_ci			.linear_ranges = bd71828_buck5_volts,
3778c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd71828_buck5_volts),
3788c2ecf20Sopenharmony_ci			.n_voltages = BD71828_BUCK5_VOLTS,
3798c2ecf20Sopenharmony_ci			.enable_reg = BD71828_REG_BUCK5_EN,
3808c2ecf20Sopenharmony_ci			.enable_mask = BD71828_MASK_RUN_EN,
3818c2ecf20Sopenharmony_ci			.vsel_reg = BD71828_REG_BUCK5_VOLT,
3828c2ecf20Sopenharmony_ci			.vsel_mask = BD71828_MASK_BUCK5_VOLT,
3838c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
3848c2ecf20Sopenharmony_ci			.of_parse_cb = buck_set_hw_dvs_levels,
3858c2ecf20Sopenharmony_ci		},
3868c2ecf20Sopenharmony_ci		.dvs = {
3878c2ecf20Sopenharmony_ci			/*
3888c2ecf20Sopenharmony_ci			 * BUCK5 only supports single voltage for all states.
3898c2ecf20Sopenharmony_ci			 * voltage can be individually enabled for each state
3908c2ecf20Sopenharmony_ci			 * though => allow setting all states to support
3918c2ecf20Sopenharmony_ci			 * enabling power rail on different states.
3928c2ecf20Sopenharmony_ci			 */
3938c2ecf20Sopenharmony_ci			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
3948c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_SUSPEND |
3958c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_LPSR,
3968c2ecf20Sopenharmony_ci			.run_reg = BD71828_REG_BUCK5_VOLT,
3978c2ecf20Sopenharmony_ci			.idle_reg = BD71828_REG_BUCK5_VOLT,
3988c2ecf20Sopenharmony_ci			.suspend_reg = BD71828_REG_BUCK5_VOLT,
3998c2ecf20Sopenharmony_ci			.lpsr_reg = BD71828_REG_BUCK5_VOLT,
4008c2ecf20Sopenharmony_ci			.run_mask = BD71828_MASK_BUCK5_VOLT,
4018c2ecf20Sopenharmony_ci			.idle_mask = BD71828_MASK_BUCK5_VOLT,
4028c2ecf20Sopenharmony_ci			.suspend_mask = BD71828_MASK_BUCK5_VOLT,
4038c2ecf20Sopenharmony_ci			.lpsr_mask = BD71828_MASK_BUCK5_VOLT,
4048c2ecf20Sopenharmony_ci			.idle_on_mask = BD71828_MASK_IDLE_EN,
4058c2ecf20Sopenharmony_ci			.suspend_on_mask = BD71828_MASK_SUSP_EN,
4068c2ecf20Sopenharmony_ci			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
4078c2ecf20Sopenharmony_ci		},
4088c2ecf20Sopenharmony_ci	},
4098c2ecf20Sopenharmony_ci	{
4108c2ecf20Sopenharmony_ci		.desc = {
4118c2ecf20Sopenharmony_ci			.name = "buck6",
4128c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("BUCK6"),
4138c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
4148c2ecf20Sopenharmony_ci			.id = BD71828_BUCK6,
4158c2ecf20Sopenharmony_ci			.ops = &bd71828_dvs_buck_ops,
4168c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
4178c2ecf20Sopenharmony_ci			.linear_ranges = bd71828_buck1267_volts,
4188c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd71828_buck1267_volts),
4198c2ecf20Sopenharmony_ci			.n_voltages = BD71828_BUCK1267_VOLTS,
4208c2ecf20Sopenharmony_ci			.enable_reg = BD71828_REG_BUCK6_EN,
4218c2ecf20Sopenharmony_ci			.enable_mask = BD71828_MASK_RUN_EN,
4228c2ecf20Sopenharmony_ci			.vsel_reg = BD71828_REG_BUCK6_VOLT,
4238c2ecf20Sopenharmony_ci			.vsel_mask = BD71828_MASK_BUCK1267_VOLT,
4248c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
4258c2ecf20Sopenharmony_ci			.of_parse_cb = buck_set_hw_dvs_levels,
4268c2ecf20Sopenharmony_ci		},
4278c2ecf20Sopenharmony_ci		.dvs = {
4288c2ecf20Sopenharmony_ci			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
4298c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_SUSPEND |
4308c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_LPSR,
4318c2ecf20Sopenharmony_ci			.run_reg = BD71828_REG_BUCK6_VOLT,
4328c2ecf20Sopenharmony_ci			.run_mask = BD71828_MASK_BUCK1267_VOLT,
4338c2ecf20Sopenharmony_ci			.idle_reg = BD71828_REG_BUCK6_IDLE_VOLT,
4348c2ecf20Sopenharmony_ci			.idle_mask = BD71828_MASK_BUCK1267_VOLT,
4358c2ecf20Sopenharmony_ci			.idle_on_mask = BD71828_MASK_IDLE_EN,
4368c2ecf20Sopenharmony_ci			.suspend_reg = BD71828_REG_BUCK6_SUSP_VOLT,
4378c2ecf20Sopenharmony_ci			.suspend_mask = BD71828_MASK_BUCK1267_VOLT,
4388c2ecf20Sopenharmony_ci			.suspend_on_mask = BD71828_MASK_SUSP_EN,
4398c2ecf20Sopenharmony_ci			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
4408c2ecf20Sopenharmony_ci			.lpsr_reg = BD71828_REG_BUCK6_SUSP_VOLT,
4418c2ecf20Sopenharmony_ci			.lpsr_mask = BD71828_MASK_BUCK1267_VOLT,
4428c2ecf20Sopenharmony_ci		},
4438c2ecf20Sopenharmony_ci		.reg_inits = buck6_inits,
4448c2ecf20Sopenharmony_ci		.reg_init_amnt = ARRAY_SIZE(buck6_inits),
4458c2ecf20Sopenharmony_ci	},
4468c2ecf20Sopenharmony_ci	{
4478c2ecf20Sopenharmony_ci		.desc = {
4488c2ecf20Sopenharmony_ci			.name = "buck7",
4498c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("BUCK7"),
4508c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
4518c2ecf20Sopenharmony_ci			.id = BD71828_BUCK7,
4528c2ecf20Sopenharmony_ci			.ops = &bd71828_dvs_buck_ops,
4538c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
4548c2ecf20Sopenharmony_ci			.linear_ranges = bd71828_buck1267_volts,
4558c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd71828_buck1267_volts),
4568c2ecf20Sopenharmony_ci			.n_voltages = BD71828_BUCK1267_VOLTS,
4578c2ecf20Sopenharmony_ci			.enable_reg = BD71828_REG_BUCK7_EN,
4588c2ecf20Sopenharmony_ci			.enable_mask = BD71828_MASK_RUN_EN,
4598c2ecf20Sopenharmony_ci			.vsel_reg = BD71828_REG_BUCK7_VOLT,
4608c2ecf20Sopenharmony_ci			.vsel_mask = BD71828_MASK_BUCK1267_VOLT,
4618c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
4628c2ecf20Sopenharmony_ci			.of_parse_cb = buck_set_hw_dvs_levels,
4638c2ecf20Sopenharmony_ci		},
4648c2ecf20Sopenharmony_ci		.dvs = {
4658c2ecf20Sopenharmony_ci			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
4668c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_SUSPEND |
4678c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_LPSR,
4688c2ecf20Sopenharmony_ci			.run_reg = BD71828_REG_BUCK7_VOLT,
4698c2ecf20Sopenharmony_ci			.run_mask = BD71828_MASK_BUCK1267_VOLT,
4708c2ecf20Sopenharmony_ci			.idle_reg = BD71828_REG_BUCK7_IDLE_VOLT,
4718c2ecf20Sopenharmony_ci			.idle_mask = BD71828_MASK_BUCK1267_VOLT,
4728c2ecf20Sopenharmony_ci			.idle_on_mask = BD71828_MASK_IDLE_EN,
4738c2ecf20Sopenharmony_ci			.suspend_reg = BD71828_REG_BUCK7_SUSP_VOLT,
4748c2ecf20Sopenharmony_ci			.suspend_mask = BD71828_MASK_BUCK1267_VOLT,
4758c2ecf20Sopenharmony_ci			.suspend_on_mask = BD71828_MASK_SUSP_EN,
4768c2ecf20Sopenharmony_ci			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
4778c2ecf20Sopenharmony_ci			.lpsr_reg = BD71828_REG_BUCK7_SUSP_VOLT,
4788c2ecf20Sopenharmony_ci			.lpsr_mask = BD71828_MASK_BUCK1267_VOLT,
4798c2ecf20Sopenharmony_ci		},
4808c2ecf20Sopenharmony_ci		.reg_inits = buck7_inits,
4818c2ecf20Sopenharmony_ci		.reg_init_amnt = ARRAY_SIZE(buck7_inits),
4828c2ecf20Sopenharmony_ci	},
4838c2ecf20Sopenharmony_ci	{
4848c2ecf20Sopenharmony_ci		.desc = {
4858c2ecf20Sopenharmony_ci			.name = "ldo1",
4868c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("LDO1"),
4878c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
4888c2ecf20Sopenharmony_ci			.id = BD71828_LDO1,
4898c2ecf20Sopenharmony_ci			.ops = &bd71828_ldo_ops,
4908c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
4918c2ecf20Sopenharmony_ci			.linear_ranges = bd71828_ldo_volts,
4928c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd71828_ldo_volts),
4938c2ecf20Sopenharmony_ci			.n_voltages = BD71828_LDO_VOLTS,
4948c2ecf20Sopenharmony_ci			.enable_reg = BD71828_REG_LDO1_EN,
4958c2ecf20Sopenharmony_ci			.enable_mask = BD71828_MASK_RUN_EN,
4968c2ecf20Sopenharmony_ci			.vsel_reg = BD71828_REG_LDO1_VOLT,
4978c2ecf20Sopenharmony_ci			.vsel_mask = BD71828_MASK_LDO_VOLT,
4988c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
4998c2ecf20Sopenharmony_ci			.of_parse_cb = buck_set_hw_dvs_levels,
5008c2ecf20Sopenharmony_ci		},
5018c2ecf20Sopenharmony_ci		.dvs = {
5028c2ecf20Sopenharmony_ci			/*
5038c2ecf20Sopenharmony_ci			 * LDO1 only supports single voltage for all states.
5048c2ecf20Sopenharmony_ci			 * voltage can be individually enabled for each state
5058c2ecf20Sopenharmony_ci			 * though => allow setting all states to support
5068c2ecf20Sopenharmony_ci			 * enabling power rail on different states.
5078c2ecf20Sopenharmony_ci			 */
5088c2ecf20Sopenharmony_ci			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
5098c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_SUSPEND |
5108c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_LPSR,
5118c2ecf20Sopenharmony_ci			.run_reg = BD71828_REG_LDO1_VOLT,
5128c2ecf20Sopenharmony_ci			.idle_reg = BD71828_REG_LDO1_VOLT,
5138c2ecf20Sopenharmony_ci			.suspend_reg = BD71828_REG_LDO1_VOLT,
5148c2ecf20Sopenharmony_ci			.lpsr_reg = BD71828_REG_LDO1_VOLT,
5158c2ecf20Sopenharmony_ci			.run_mask = BD71828_MASK_LDO_VOLT,
5168c2ecf20Sopenharmony_ci			.idle_mask = BD71828_MASK_LDO_VOLT,
5178c2ecf20Sopenharmony_ci			.suspend_mask = BD71828_MASK_LDO_VOLT,
5188c2ecf20Sopenharmony_ci			.lpsr_mask = BD71828_MASK_LDO_VOLT,
5198c2ecf20Sopenharmony_ci			.idle_on_mask = BD71828_MASK_IDLE_EN,
5208c2ecf20Sopenharmony_ci			.suspend_on_mask = BD71828_MASK_SUSP_EN,
5218c2ecf20Sopenharmony_ci			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
5228c2ecf20Sopenharmony_ci		},
5238c2ecf20Sopenharmony_ci	}, {
5248c2ecf20Sopenharmony_ci		.desc = {
5258c2ecf20Sopenharmony_ci			.name = "ldo2",
5268c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("LDO2"),
5278c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
5288c2ecf20Sopenharmony_ci			.id = BD71828_LDO2,
5298c2ecf20Sopenharmony_ci			.ops = &bd71828_ldo_ops,
5308c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
5318c2ecf20Sopenharmony_ci			.linear_ranges = bd71828_ldo_volts,
5328c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd71828_ldo_volts),
5338c2ecf20Sopenharmony_ci			.n_voltages = BD71828_LDO_VOLTS,
5348c2ecf20Sopenharmony_ci			.enable_reg = BD71828_REG_LDO2_EN,
5358c2ecf20Sopenharmony_ci			.enable_mask = BD71828_MASK_RUN_EN,
5368c2ecf20Sopenharmony_ci			.vsel_reg = BD71828_REG_LDO2_VOLT,
5378c2ecf20Sopenharmony_ci			.vsel_mask = BD71828_MASK_LDO_VOLT,
5388c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
5398c2ecf20Sopenharmony_ci			.of_parse_cb = buck_set_hw_dvs_levels,
5408c2ecf20Sopenharmony_ci		},
5418c2ecf20Sopenharmony_ci		.dvs = {
5428c2ecf20Sopenharmony_ci			/*
5438c2ecf20Sopenharmony_ci			 * LDO2 only supports single voltage for all states.
5448c2ecf20Sopenharmony_ci			 * voltage can be individually enabled for each state
5458c2ecf20Sopenharmony_ci			 * though => allow setting all states to support
5468c2ecf20Sopenharmony_ci			 * enabling power rail on different states.
5478c2ecf20Sopenharmony_ci			 */
5488c2ecf20Sopenharmony_ci			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
5498c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_SUSPEND |
5508c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_LPSR,
5518c2ecf20Sopenharmony_ci			.run_reg = BD71828_REG_LDO2_VOLT,
5528c2ecf20Sopenharmony_ci			.idle_reg = BD71828_REG_LDO2_VOLT,
5538c2ecf20Sopenharmony_ci			.suspend_reg = BD71828_REG_LDO2_VOLT,
5548c2ecf20Sopenharmony_ci			.lpsr_reg = BD71828_REG_LDO2_VOLT,
5558c2ecf20Sopenharmony_ci			.run_mask = BD71828_MASK_LDO_VOLT,
5568c2ecf20Sopenharmony_ci			.idle_mask = BD71828_MASK_LDO_VOLT,
5578c2ecf20Sopenharmony_ci			.suspend_mask = BD71828_MASK_LDO_VOLT,
5588c2ecf20Sopenharmony_ci			.lpsr_mask = BD71828_MASK_LDO_VOLT,
5598c2ecf20Sopenharmony_ci			.idle_on_mask = BD71828_MASK_IDLE_EN,
5608c2ecf20Sopenharmony_ci			.suspend_on_mask = BD71828_MASK_SUSP_EN,
5618c2ecf20Sopenharmony_ci			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
5628c2ecf20Sopenharmony_ci		},
5638c2ecf20Sopenharmony_ci	}, {
5648c2ecf20Sopenharmony_ci		.desc = {
5658c2ecf20Sopenharmony_ci			.name = "ldo3",
5668c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("LDO3"),
5678c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
5688c2ecf20Sopenharmony_ci			.id = BD71828_LDO3,
5698c2ecf20Sopenharmony_ci			.ops = &bd71828_ldo_ops,
5708c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
5718c2ecf20Sopenharmony_ci			.linear_ranges = bd71828_ldo_volts,
5728c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd71828_ldo_volts),
5738c2ecf20Sopenharmony_ci			.n_voltages = BD71828_LDO_VOLTS,
5748c2ecf20Sopenharmony_ci			.enable_reg = BD71828_REG_LDO3_EN,
5758c2ecf20Sopenharmony_ci			.enable_mask = BD71828_MASK_RUN_EN,
5768c2ecf20Sopenharmony_ci			.vsel_reg = BD71828_REG_LDO3_VOLT,
5778c2ecf20Sopenharmony_ci			.vsel_mask = BD71828_MASK_LDO_VOLT,
5788c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
5798c2ecf20Sopenharmony_ci			.of_parse_cb = buck_set_hw_dvs_levels,
5808c2ecf20Sopenharmony_ci		},
5818c2ecf20Sopenharmony_ci		.dvs = {
5828c2ecf20Sopenharmony_ci			/*
5838c2ecf20Sopenharmony_ci			 * LDO3 only supports single voltage for all states.
5848c2ecf20Sopenharmony_ci			 * voltage can be individually enabled for each state
5858c2ecf20Sopenharmony_ci			 * though => allow setting all states to support
5868c2ecf20Sopenharmony_ci			 * enabling power rail on different states.
5878c2ecf20Sopenharmony_ci			 */
5888c2ecf20Sopenharmony_ci			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
5898c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_SUSPEND |
5908c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_LPSR,
5918c2ecf20Sopenharmony_ci			.run_reg = BD71828_REG_LDO3_VOLT,
5928c2ecf20Sopenharmony_ci			.idle_reg = BD71828_REG_LDO3_VOLT,
5938c2ecf20Sopenharmony_ci			.suspend_reg = BD71828_REG_LDO3_VOLT,
5948c2ecf20Sopenharmony_ci			.lpsr_reg = BD71828_REG_LDO3_VOLT,
5958c2ecf20Sopenharmony_ci			.run_mask = BD71828_MASK_LDO_VOLT,
5968c2ecf20Sopenharmony_ci			.idle_mask = BD71828_MASK_LDO_VOLT,
5978c2ecf20Sopenharmony_ci			.suspend_mask = BD71828_MASK_LDO_VOLT,
5988c2ecf20Sopenharmony_ci			.lpsr_mask = BD71828_MASK_LDO_VOLT,
5998c2ecf20Sopenharmony_ci			.idle_on_mask = BD71828_MASK_IDLE_EN,
6008c2ecf20Sopenharmony_ci			.suspend_on_mask = BD71828_MASK_SUSP_EN,
6018c2ecf20Sopenharmony_ci			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
6028c2ecf20Sopenharmony_ci		},
6038c2ecf20Sopenharmony_ci
6048c2ecf20Sopenharmony_ci	}, {
6058c2ecf20Sopenharmony_ci		.desc = {
6068c2ecf20Sopenharmony_ci			.name = "ldo4",
6078c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("LDO4"),
6088c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
6098c2ecf20Sopenharmony_ci			.id = BD71828_LDO4,
6108c2ecf20Sopenharmony_ci			.ops = &bd71828_ldo_ops,
6118c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
6128c2ecf20Sopenharmony_ci			.linear_ranges = bd71828_ldo_volts,
6138c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd71828_ldo_volts),
6148c2ecf20Sopenharmony_ci			.n_voltages = BD71828_LDO_VOLTS,
6158c2ecf20Sopenharmony_ci			.enable_reg = BD71828_REG_LDO4_EN,
6168c2ecf20Sopenharmony_ci			.enable_mask = BD71828_MASK_RUN_EN,
6178c2ecf20Sopenharmony_ci			.vsel_reg = BD71828_REG_LDO4_VOLT,
6188c2ecf20Sopenharmony_ci			.vsel_mask = BD71828_MASK_LDO_VOLT,
6198c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
6208c2ecf20Sopenharmony_ci			.of_parse_cb = buck_set_hw_dvs_levels,
6218c2ecf20Sopenharmony_ci		},
6228c2ecf20Sopenharmony_ci		.dvs = {
6238c2ecf20Sopenharmony_ci			/*
6248c2ecf20Sopenharmony_ci			 * LDO1 only supports single voltage for all states.
6258c2ecf20Sopenharmony_ci			 * voltage can be individually enabled for each state
6268c2ecf20Sopenharmony_ci			 * though => allow setting all states to support
6278c2ecf20Sopenharmony_ci			 * enabling power rail on different states.
6288c2ecf20Sopenharmony_ci			 */
6298c2ecf20Sopenharmony_ci			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
6308c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_SUSPEND |
6318c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_LPSR,
6328c2ecf20Sopenharmony_ci			.run_reg = BD71828_REG_LDO4_VOLT,
6338c2ecf20Sopenharmony_ci			.idle_reg = BD71828_REG_LDO4_VOLT,
6348c2ecf20Sopenharmony_ci			.suspend_reg = BD71828_REG_LDO4_VOLT,
6358c2ecf20Sopenharmony_ci			.lpsr_reg = BD71828_REG_LDO4_VOLT,
6368c2ecf20Sopenharmony_ci			.run_mask = BD71828_MASK_LDO_VOLT,
6378c2ecf20Sopenharmony_ci			.idle_mask = BD71828_MASK_LDO_VOLT,
6388c2ecf20Sopenharmony_ci			.suspend_mask = BD71828_MASK_LDO_VOLT,
6398c2ecf20Sopenharmony_ci			.lpsr_mask = BD71828_MASK_LDO_VOLT,
6408c2ecf20Sopenharmony_ci			.idle_on_mask = BD71828_MASK_IDLE_EN,
6418c2ecf20Sopenharmony_ci			.suspend_on_mask = BD71828_MASK_SUSP_EN,
6428c2ecf20Sopenharmony_ci			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
6438c2ecf20Sopenharmony_ci		},
6448c2ecf20Sopenharmony_ci	}, {
6458c2ecf20Sopenharmony_ci		.desc = {
6468c2ecf20Sopenharmony_ci			.name = "ldo5",
6478c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("LDO5"),
6488c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
6498c2ecf20Sopenharmony_ci			.id = BD71828_LDO5,
6508c2ecf20Sopenharmony_ci			.ops = &bd71828_ldo_ops,
6518c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
6528c2ecf20Sopenharmony_ci			.linear_ranges = bd71828_ldo_volts,
6538c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd71828_ldo_volts),
6548c2ecf20Sopenharmony_ci			.n_voltages = BD71828_LDO_VOLTS,
6558c2ecf20Sopenharmony_ci			.enable_reg = BD71828_REG_LDO5_EN,
6568c2ecf20Sopenharmony_ci			.enable_mask = BD71828_MASK_RUN_EN,
6578c2ecf20Sopenharmony_ci			.vsel_reg = BD71828_REG_LDO5_VOLT,
6588c2ecf20Sopenharmony_ci			.vsel_mask = BD71828_MASK_LDO_VOLT,
6598c2ecf20Sopenharmony_ci			.of_parse_cb = buck_set_hw_dvs_levels,
6608c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
6618c2ecf20Sopenharmony_ci		},
6628c2ecf20Sopenharmony_ci		/*
6638c2ecf20Sopenharmony_ci		 * LDO5 is special. It can choose vsel settings to be configured
6648c2ecf20Sopenharmony_ci		 * from 2 different registers (by GPIO).
6658c2ecf20Sopenharmony_ci		 *
6668c2ecf20Sopenharmony_ci		 * This driver supports only configuration where
6678c2ecf20Sopenharmony_ci		 * BD71828_REG_LDO5_VOLT_L is used.
6688c2ecf20Sopenharmony_ci		 */
6698c2ecf20Sopenharmony_ci		.dvs = {
6708c2ecf20Sopenharmony_ci			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
6718c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_SUSPEND |
6728c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_LPSR,
6738c2ecf20Sopenharmony_ci			.run_reg = BD71828_REG_LDO5_VOLT,
6748c2ecf20Sopenharmony_ci			.idle_reg = BD71828_REG_LDO5_VOLT,
6758c2ecf20Sopenharmony_ci			.suspend_reg = BD71828_REG_LDO5_VOLT,
6768c2ecf20Sopenharmony_ci			.lpsr_reg = BD71828_REG_LDO5_VOLT,
6778c2ecf20Sopenharmony_ci			.run_mask = BD71828_MASK_LDO_VOLT,
6788c2ecf20Sopenharmony_ci			.idle_mask = BD71828_MASK_LDO_VOLT,
6798c2ecf20Sopenharmony_ci			.suspend_mask = BD71828_MASK_LDO_VOLT,
6808c2ecf20Sopenharmony_ci			.lpsr_mask = BD71828_MASK_LDO_VOLT,
6818c2ecf20Sopenharmony_ci			.idle_on_mask = BD71828_MASK_IDLE_EN,
6828c2ecf20Sopenharmony_ci			.suspend_on_mask = BD71828_MASK_SUSP_EN,
6838c2ecf20Sopenharmony_ci			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
6848c2ecf20Sopenharmony_ci		},
6858c2ecf20Sopenharmony_ci
6868c2ecf20Sopenharmony_ci	}, {
6878c2ecf20Sopenharmony_ci		.desc = {
6888c2ecf20Sopenharmony_ci			.name = "ldo6",
6898c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("LDO6"),
6908c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
6918c2ecf20Sopenharmony_ci			.id = BD71828_LDO6,
6928c2ecf20Sopenharmony_ci			.ops = &bd71828_ldo6_ops,
6938c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
6948c2ecf20Sopenharmony_ci			.fixed_uV = BD71828_LDO_6_VOLTAGE,
6958c2ecf20Sopenharmony_ci			.n_voltages = 1,
6968c2ecf20Sopenharmony_ci			.enable_reg = BD71828_REG_LDO6_EN,
6978c2ecf20Sopenharmony_ci			.enable_mask = BD71828_MASK_RUN_EN,
6988c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
6998c2ecf20Sopenharmony_ci			/*
7008c2ecf20Sopenharmony_ci			 * LDO6 only supports enable/disable for all states.
7018c2ecf20Sopenharmony_ci			 * Voltage for LDO6 is fixed.
7028c2ecf20Sopenharmony_ci			 */
7038c2ecf20Sopenharmony_ci			.of_parse_cb = ldo6_parse_dt,
7048c2ecf20Sopenharmony_ci		},
7058c2ecf20Sopenharmony_ci	}, {
7068c2ecf20Sopenharmony_ci		.desc = {
7078c2ecf20Sopenharmony_ci			/* SNVS LDO in data-sheet */
7088c2ecf20Sopenharmony_ci			.name = "ldo7",
7098c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("LDO7"),
7108c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
7118c2ecf20Sopenharmony_ci			.id = BD71828_LDO_SNVS,
7128c2ecf20Sopenharmony_ci			.ops = &bd71828_ldo_ops,
7138c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
7148c2ecf20Sopenharmony_ci			.linear_ranges = bd71828_ldo_volts,
7158c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd71828_ldo_volts),
7168c2ecf20Sopenharmony_ci			.n_voltages = BD71828_LDO_VOLTS,
7178c2ecf20Sopenharmony_ci			.enable_reg = BD71828_REG_LDO7_EN,
7188c2ecf20Sopenharmony_ci			.enable_mask = BD71828_MASK_RUN_EN,
7198c2ecf20Sopenharmony_ci			.vsel_reg = BD71828_REG_LDO7_VOLT,
7208c2ecf20Sopenharmony_ci			.vsel_mask = BD71828_MASK_LDO_VOLT,
7218c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
7228c2ecf20Sopenharmony_ci			.of_parse_cb = buck_set_hw_dvs_levels,
7238c2ecf20Sopenharmony_ci		},
7248c2ecf20Sopenharmony_ci		.dvs = {
7258c2ecf20Sopenharmony_ci			/*
7268c2ecf20Sopenharmony_ci			 * LDO7 only supports single voltage for all states.
7278c2ecf20Sopenharmony_ci			 * voltage can be individually enabled for each state
7288c2ecf20Sopenharmony_ci			 * though => allow setting all states to support
7298c2ecf20Sopenharmony_ci			 * enabling power rail on different states.
7308c2ecf20Sopenharmony_ci			 */
7318c2ecf20Sopenharmony_ci			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
7328c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_SUSPEND |
7338c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_LPSR,
7348c2ecf20Sopenharmony_ci			.run_reg = BD71828_REG_LDO7_VOLT,
7358c2ecf20Sopenharmony_ci			.idle_reg = BD71828_REG_LDO7_VOLT,
7368c2ecf20Sopenharmony_ci			.suspend_reg = BD71828_REG_LDO7_VOLT,
7378c2ecf20Sopenharmony_ci			.lpsr_reg = BD71828_REG_LDO7_VOLT,
7388c2ecf20Sopenharmony_ci			.run_mask = BD71828_MASK_LDO_VOLT,
7398c2ecf20Sopenharmony_ci			.idle_mask = BD71828_MASK_LDO_VOLT,
7408c2ecf20Sopenharmony_ci			.suspend_mask = BD71828_MASK_LDO_VOLT,
7418c2ecf20Sopenharmony_ci			.lpsr_mask = BD71828_MASK_LDO_VOLT,
7428c2ecf20Sopenharmony_ci			.idle_on_mask = BD71828_MASK_IDLE_EN,
7438c2ecf20Sopenharmony_ci			.suspend_on_mask = BD71828_MASK_SUSP_EN,
7448c2ecf20Sopenharmony_ci			.lpsr_on_mask = BD71828_MASK_LPSR_EN,
7458c2ecf20Sopenharmony_ci		},
7468c2ecf20Sopenharmony_ci
7478c2ecf20Sopenharmony_ci	},
7488c2ecf20Sopenharmony_ci};
7498c2ecf20Sopenharmony_ci
7508c2ecf20Sopenharmony_cistatic int bd71828_probe(struct platform_device *pdev)
7518c2ecf20Sopenharmony_ci{
7528c2ecf20Sopenharmony_ci	struct rohm_regmap_dev *bd71828;
7538c2ecf20Sopenharmony_ci	int i, j, ret;
7548c2ecf20Sopenharmony_ci	struct regulator_config config = {
7558c2ecf20Sopenharmony_ci		.dev = pdev->dev.parent,
7568c2ecf20Sopenharmony_ci	};
7578c2ecf20Sopenharmony_ci
7588c2ecf20Sopenharmony_ci	bd71828 = dev_get_drvdata(pdev->dev.parent);
7598c2ecf20Sopenharmony_ci	if (!bd71828) {
7608c2ecf20Sopenharmony_ci		dev_err(&pdev->dev, "No MFD driver data\n");
7618c2ecf20Sopenharmony_ci		return -EINVAL;
7628c2ecf20Sopenharmony_ci	}
7638c2ecf20Sopenharmony_ci
7648c2ecf20Sopenharmony_ci	config.regmap = bd71828->regmap;
7658c2ecf20Sopenharmony_ci
7668c2ecf20Sopenharmony_ci	for (i = 0; i < ARRAY_SIZE(bd71828_rdata); i++) {
7678c2ecf20Sopenharmony_ci		struct regulator_dev *rdev;
7688c2ecf20Sopenharmony_ci		const struct bd71828_regulator_data *rd;
7698c2ecf20Sopenharmony_ci
7708c2ecf20Sopenharmony_ci		rd = &bd71828_rdata[i];
7718c2ecf20Sopenharmony_ci		rdev = devm_regulator_register(&pdev->dev,
7728c2ecf20Sopenharmony_ci					       &rd->desc, &config);
7738c2ecf20Sopenharmony_ci		if (IS_ERR(rdev)) {
7748c2ecf20Sopenharmony_ci			dev_err(&pdev->dev,
7758c2ecf20Sopenharmony_ci				"failed to register %s regulator\n",
7768c2ecf20Sopenharmony_ci				rd->desc.name);
7778c2ecf20Sopenharmony_ci			return PTR_ERR(rdev);
7788c2ecf20Sopenharmony_ci		}
7798c2ecf20Sopenharmony_ci		for (j = 0; j < rd->reg_init_amnt; j++) {
7808c2ecf20Sopenharmony_ci			ret = regmap_update_bits(bd71828->regmap,
7818c2ecf20Sopenharmony_ci						 rd->reg_inits[j].reg,
7828c2ecf20Sopenharmony_ci						 rd->reg_inits[j].mask,
7838c2ecf20Sopenharmony_ci						 rd->reg_inits[j].val);
7848c2ecf20Sopenharmony_ci			if (ret) {
7858c2ecf20Sopenharmony_ci				dev_err(&pdev->dev,
7868c2ecf20Sopenharmony_ci					"regulator %s init failed\n",
7878c2ecf20Sopenharmony_ci					rd->desc.name);
7888c2ecf20Sopenharmony_ci				return ret;
7898c2ecf20Sopenharmony_ci			}
7908c2ecf20Sopenharmony_ci		}
7918c2ecf20Sopenharmony_ci	}
7928c2ecf20Sopenharmony_ci	return 0;
7938c2ecf20Sopenharmony_ci}
7948c2ecf20Sopenharmony_ci
7958c2ecf20Sopenharmony_cistatic struct platform_driver bd71828_regulator = {
7968c2ecf20Sopenharmony_ci	.driver = {
7978c2ecf20Sopenharmony_ci		.name = "bd71828-pmic"
7988c2ecf20Sopenharmony_ci	},
7998c2ecf20Sopenharmony_ci	.probe = bd71828_probe,
8008c2ecf20Sopenharmony_ci};
8018c2ecf20Sopenharmony_ci
8028c2ecf20Sopenharmony_cimodule_platform_driver(bd71828_regulator);
8038c2ecf20Sopenharmony_ci
8048c2ecf20Sopenharmony_ciMODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>");
8058c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("BD71828 voltage regulator driver");
8068c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL");
8078c2ecf20Sopenharmony_ciMODULE_ALIAS("platform:bd71828-pmic");
808