18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci// Copyright (C) 2018 ROHM Semiconductors
38c2ecf20Sopenharmony_ci// bd71837-regulator.c ROHM BD71837MWV/BD71847MWV regulator driver
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <linux/delay.h>
68c2ecf20Sopenharmony_ci#include <linux/err.h>
78c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
88c2ecf20Sopenharmony_ci#include <linux/kernel.h>
98c2ecf20Sopenharmony_ci#include <linux/mfd/rohm-bd718x7.h>
108c2ecf20Sopenharmony_ci#include <linux/module.h>
118c2ecf20Sopenharmony_ci#include <linux/of.h>
128c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
138c2ecf20Sopenharmony_ci#include <linux/regulator/driver.h>
148c2ecf20Sopenharmony_ci#include <linux/regulator/machine.h>
158c2ecf20Sopenharmony_ci#include <linux/regulator/of_regulator.h>
168c2ecf20Sopenharmony_ci#include <linux/slab.h>
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci/* Typical regulator startup times as per data sheet in uS */
198c2ecf20Sopenharmony_ci#define BD71847_BUCK1_STARTUP_TIME 144
208c2ecf20Sopenharmony_ci#define BD71847_BUCK2_STARTUP_TIME 162
218c2ecf20Sopenharmony_ci#define BD71847_BUCK3_STARTUP_TIME 162
228c2ecf20Sopenharmony_ci#define BD71847_BUCK4_STARTUP_TIME 240
238c2ecf20Sopenharmony_ci#define BD71847_BUCK5_STARTUP_TIME 270
248c2ecf20Sopenharmony_ci#define BD71847_BUCK6_STARTUP_TIME 200
258c2ecf20Sopenharmony_ci#define BD71847_LDO1_STARTUP_TIME  440
268c2ecf20Sopenharmony_ci#define BD71847_LDO2_STARTUP_TIME  370
278c2ecf20Sopenharmony_ci#define BD71847_LDO3_STARTUP_TIME  310
288c2ecf20Sopenharmony_ci#define BD71847_LDO4_STARTUP_TIME  400
298c2ecf20Sopenharmony_ci#define BD71847_LDO5_STARTUP_TIME  530
308c2ecf20Sopenharmony_ci#define BD71847_LDO6_STARTUP_TIME  400
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci#define BD71837_BUCK1_STARTUP_TIME 160
338c2ecf20Sopenharmony_ci#define BD71837_BUCK2_STARTUP_TIME 180
348c2ecf20Sopenharmony_ci#define BD71837_BUCK3_STARTUP_TIME 180
358c2ecf20Sopenharmony_ci#define BD71837_BUCK4_STARTUP_TIME 180
368c2ecf20Sopenharmony_ci#define BD71837_BUCK5_STARTUP_TIME 160
378c2ecf20Sopenharmony_ci#define BD71837_BUCK6_STARTUP_TIME 240
388c2ecf20Sopenharmony_ci#define BD71837_BUCK7_STARTUP_TIME 220
398c2ecf20Sopenharmony_ci#define BD71837_BUCK8_STARTUP_TIME 200
408c2ecf20Sopenharmony_ci#define BD71837_LDO1_STARTUP_TIME  440
418c2ecf20Sopenharmony_ci#define BD71837_LDO2_STARTUP_TIME  370
428c2ecf20Sopenharmony_ci#define BD71837_LDO3_STARTUP_TIME  310
438c2ecf20Sopenharmony_ci#define BD71837_LDO4_STARTUP_TIME  400
448c2ecf20Sopenharmony_ci#define BD71837_LDO5_STARTUP_TIME  310
458c2ecf20Sopenharmony_ci#define BD71837_LDO6_STARTUP_TIME  400
468c2ecf20Sopenharmony_ci#define BD71837_LDO7_STARTUP_TIME  530
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci/*
498c2ecf20Sopenharmony_ci * BD718(37/47/50) have two "enable control modes". ON/OFF can either be
508c2ecf20Sopenharmony_ci * controlled by software - or by PMIC internal HW state machine. Whether
518c2ecf20Sopenharmony_ci * regulator should be under SW or HW control can be defined from device-tree.
528c2ecf20Sopenharmony_ci * Let's provide separate ops for regulators to use depending on the "enable
538c2ecf20Sopenharmony_ci * control mode".
548c2ecf20Sopenharmony_ci */
558c2ecf20Sopenharmony_ci#define BD718XX_HWOPNAME(swopname) swopname##_hwcontrol
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci#define BD718XX_OPS(name, _list_voltage, _map_voltage, _set_voltage_sel, \
588c2ecf20Sopenharmony_ci		   _get_voltage_sel, _set_voltage_time_sel, _set_ramp_delay) \
598c2ecf20Sopenharmony_cistatic const struct regulator_ops name = {			\
608c2ecf20Sopenharmony_ci	.enable = regulator_enable_regmap,			\
618c2ecf20Sopenharmony_ci	.disable = regulator_disable_regmap,			\
628c2ecf20Sopenharmony_ci	.is_enabled = regulator_is_enabled_regmap,		\
638c2ecf20Sopenharmony_ci	.list_voltage = (_list_voltage),			\
648c2ecf20Sopenharmony_ci	.map_voltage = (_map_voltage),				\
658c2ecf20Sopenharmony_ci	.set_voltage_sel = (_set_voltage_sel),			\
668c2ecf20Sopenharmony_ci	.get_voltage_sel = (_get_voltage_sel),			\
678c2ecf20Sopenharmony_ci	.set_voltage_time_sel = (_set_voltage_time_sel),	\
688c2ecf20Sopenharmony_ci	.set_ramp_delay = (_set_ramp_delay),			\
698c2ecf20Sopenharmony_ci};								\
708c2ecf20Sopenharmony_ci								\
718c2ecf20Sopenharmony_cistatic const struct regulator_ops BD718XX_HWOPNAME(name) = {	\
728c2ecf20Sopenharmony_ci	.is_enabled = always_enabled_by_hwstate,		\
738c2ecf20Sopenharmony_ci	.list_voltage = (_list_voltage),			\
748c2ecf20Sopenharmony_ci	.map_voltage = (_map_voltage),				\
758c2ecf20Sopenharmony_ci	.set_voltage_sel = (_set_voltage_sel),			\
768c2ecf20Sopenharmony_ci	.get_voltage_sel = (_get_voltage_sel),			\
778c2ecf20Sopenharmony_ci	.set_voltage_time_sel = (_set_voltage_time_sel),	\
788c2ecf20Sopenharmony_ci	.set_ramp_delay = (_set_ramp_delay),			\
798c2ecf20Sopenharmony_ci}								\
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci/*
828c2ecf20Sopenharmony_ci * BUCK1/2/3/4
838c2ecf20Sopenharmony_ci * BUCK1RAMPRATE[1:0] BUCK1 DVS ramp rate setting
848c2ecf20Sopenharmony_ci * 00: 10.00mV/usec 10mV 1uS
858c2ecf20Sopenharmony_ci * 01: 5.00mV/usec	10mV 2uS
868c2ecf20Sopenharmony_ci * 10: 2.50mV/usec	10mV 4uS
878c2ecf20Sopenharmony_ci * 11: 1.25mV/usec	10mV 8uS
888c2ecf20Sopenharmony_ci */
898c2ecf20Sopenharmony_cistatic int bd718xx_buck1234_set_ramp_delay(struct regulator_dev *rdev,
908c2ecf20Sopenharmony_ci					   int ramp_delay)
918c2ecf20Sopenharmony_ci{
928c2ecf20Sopenharmony_ci	int id = rdev_get_id(rdev);
938c2ecf20Sopenharmony_ci	unsigned int ramp_value;
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci	dev_dbg(&rdev->dev, "Buck[%d] Set Ramp = %d\n", id + 1,
968c2ecf20Sopenharmony_ci		ramp_delay);
978c2ecf20Sopenharmony_ci	switch (ramp_delay) {
988c2ecf20Sopenharmony_ci	case 1 ... 1250:
998c2ecf20Sopenharmony_ci		ramp_value = BUCK_RAMPRATE_1P25MV;
1008c2ecf20Sopenharmony_ci		break;
1018c2ecf20Sopenharmony_ci	case 1251 ... 2500:
1028c2ecf20Sopenharmony_ci		ramp_value = BUCK_RAMPRATE_2P50MV;
1038c2ecf20Sopenharmony_ci		break;
1048c2ecf20Sopenharmony_ci	case 2501 ... 5000:
1058c2ecf20Sopenharmony_ci		ramp_value = BUCK_RAMPRATE_5P00MV;
1068c2ecf20Sopenharmony_ci		break;
1078c2ecf20Sopenharmony_ci	case 5001 ... 10000:
1088c2ecf20Sopenharmony_ci		ramp_value = BUCK_RAMPRATE_10P00MV;
1098c2ecf20Sopenharmony_ci		break;
1108c2ecf20Sopenharmony_ci	default:
1118c2ecf20Sopenharmony_ci		ramp_value = BUCK_RAMPRATE_10P00MV;
1128c2ecf20Sopenharmony_ci		dev_err(&rdev->dev,
1138c2ecf20Sopenharmony_ci			"%s: ramp_delay: %d not supported, setting 10000mV//us\n",
1148c2ecf20Sopenharmony_ci			rdev->desc->name, ramp_delay);
1158c2ecf20Sopenharmony_ci	}
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci	return regmap_update_bits(rdev->regmap, BD718XX_REG_BUCK1_CTRL + id,
1188c2ecf20Sopenharmony_ci				  BUCK_RAMPRATE_MASK, ramp_value << 6);
1198c2ecf20Sopenharmony_ci}
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci/* These functions are used when regulators are under HW state machine control.
1228c2ecf20Sopenharmony_ci * We assume PMIC is in RUN state because SW running and able to query the
1238c2ecf20Sopenharmony_ci * status. Most of the regulators have fixed ON or OFF state at RUN/IDLE so for
1248c2ecf20Sopenharmony_ci * them we just return a constant. BD71837 BUCK3 and BUCK4 are exceptions as
1258c2ecf20Sopenharmony_ci * they support configuring the ON/OFF state for RUN.
1268c2ecf20Sopenharmony_ci *
1278c2ecf20Sopenharmony_ci * Note for next hacker - these PMICs have a register where the HW state can be
1288c2ecf20Sopenharmony_ci * read. If assuming RUN appears to be false in your use-case - you can
1298c2ecf20Sopenharmony_ci * implement state reading (although that is not going to be atomic) before
1308c2ecf20Sopenharmony_ci * returning the enable state.
1318c2ecf20Sopenharmony_ci */
1328c2ecf20Sopenharmony_cistatic int always_enabled_by_hwstate(struct regulator_dev *rdev)
1338c2ecf20Sopenharmony_ci{
1348c2ecf20Sopenharmony_ci	return 1;
1358c2ecf20Sopenharmony_ci}
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_cistatic int never_enabled_by_hwstate(struct regulator_dev *rdev)
1388c2ecf20Sopenharmony_ci{
1398c2ecf20Sopenharmony_ci	return 0;
1408c2ecf20Sopenharmony_ci}
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_cistatic int bd71837_get_buck34_enable_hwctrl(struct regulator_dev *rdev)
1438c2ecf20Sopenharmony_ci{
1448c2ecf20Sopenharmony_ci	int ret;
1458c2ecf20Sopenharmony_ci	unsigned int val;
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci	ret = regmap_read(rdev->regmap, rdev->desc->enable_reg, &val);
1488c2ecf20Sopenharmony_ci	if (ret)
1498c2ecf20Sopenharmony_ci		return ret;
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ci	return !!(BD718XX_BUCK_RUN_ON & val);
1528c2ecf20Sopenharmony_ci}
1538c2ecf20Sopenharmony_ci/*
1548c2ecf20Sopenharmony_ci * On BD71837 (not on BD71847, BD71850, ...)
1558c2ecf20Sopenharmony_ci * Bucks 1 to 4 support DVS. PWM mode is used when voltage is changed.
1568c2ecf20Sopenharmony_ci * Bucks 5 to 8 and LDOs can use PFM and must be disabled when voltage
1578c2ecf20Sopenharmony_ci * is changed. Hence we return -EBUSY for these if voltage is changed
1588c2ecf20Sopenharmony_ci * when BUCK/LDO is enabled.
1598c2ecf20Sopenharmony_ci *
1608c2ecf20Sopenharmony_ci * On BD71847, BD71850, ... The LDO voltage can be changed when LDO is
1618c2ecf20Sopenharmony_ci * enabled. But if voltage is increased the LDO power-good monitoring
1628c2ecf20Sopenharmony_ci * must be disabled for the duration of changing + 1mS to ensure voltage
1638c2ecf20Sopenharmony_ci * has reached the higher level before HW does next under voltage detection
1648c2ecf20Sopenharmony_ci * cycle.
1658c2ecf20Sopenharmony_ci */
1668c2ecf20Sopenharmony_cistatic int bd71837_set_voltage_sel_restricted(struct regulator_dev *rdev,
1678c2ecf20Sopenharmony_ci						    unsigned int sel)
1688c2ecf20Sopenharmony_ci{
1698c2ecf20Sopenharmony_ci	if (rdev->desc->ops->is_enabled(rdev))
1708c2ecf20Sopenharmony_ci		return -EBUSY;
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ci	return regulator_set_voltage_sel_regmap(rdev, sel);
1738c2ecf20Sopenharmony_ci}
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_cistatic void voltage_change_done(struct regulator_dev *rdev, unsigned int sel,
1768c2ecf20Sopenharmony_ci				unsigned int *mask)
1778c2ecf20Sopenharmony_ci{
1788c2ecf20Sopenharmony_ci	int ret;
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ci	if (*mask) {
1818c2ecf20Sopenharmony_ci		/*
1828c2ecf20Sopenharmony_ci		 * Let's allow scheduling as we use I2C anyways. We just need to
1838c2ecf20Sopenharmony_ci		 * guarantee minimum of 1ms sleep - it shouldn't matter if we
1848c2ecf20Sopenharmony_ci		 * exceed it due to the scheduling.
1858c2ecf20Sopenharmony_ci		 */
1868c2ecf20Sopenharmony_ci		msleep(1);
1878c2ecf20Sopenharmony_ci		/*
1888c2ecf20Sopenharmony_ci		 * Note for next hacker. The PWRGOOD should not be masked on
1898c2ecf20Sopenharmony_ci		 * BD71847 so we will just unconditionally enable detection
1908c2ecf20Sopenharmony_ci		 * when voltage is set.
1918c2ecf20Sopenharmony_ci		 * If someone want's to disable PWRGOOD he must implement
1928c2ecf20Sopenharmony_ci		 * caching and restoring the old value here. I am not
1938c2ecf20Sopenharmony_ci		 * aware of such use-cases so for the sake of the simplicity
1948c2ecf20Sopenharmony_ci		 * we just always enable PWRGOOD here.
1958c2ecf20Sopenharmony_ci		 */
1968c2ecf20Sopenharmony_ci		ret = regmap_update_bits(rdev->regmap, BD718XX_REG_MVRFLTMASK2,
1978c2ecf20Sopenharmony_ci					 *mask, 0);
1988c2ecf20Sopenharmony_ci		if (ret)
1998c2ecf20Sopenharmony_ci			dev_err(&rdev->dev,
2008c2ecf20Sopenharmony_ci				"Failed to re-enable voltage monitoring (%d)\n",
2018c2ecf20Sopenharmony_ci				ret);
2028c2ecf20Sopenharmony_ci	}
2038c2ecf20Sopenharmony_ci}
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_cistatic int voltage_change_prepare(struct regulator_dev *rdev, unsigned int sel,
2068c2ecf20Sopenharmony_ci				  unsigned int *mask)
2078c2ecf20Sopenharmony_ci{
2088c2ecf20Sopenharmony_ci	int ret;
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_ci	*mask = 0;
2118c2ecf20Sopenharmony_ci	if (rdev->desc->ops->is_enabled(rdev)) {
2128c2ecf20Sopenharmony_ci		int now, new;
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci		now = rdev->desc->ops->get_voltage_sel(rdev);
2158c2ecf20Sopenharmony_ci		if (now < 0)
2168c2ecf20Sopenharmony_ci			return now;
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_ci		now = rdev->desc->ops->list_voltage(rdev, now);
2198c2ecf20Sopenharmony_ci		if (now < 0)
2208c2ecf20Sopenharmony_ci			return now;
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_ci		new = rdev->desc->ops->list_voltage(rdev, sel);
2238c2ecf20Sopenharmony_ci		if (new < 0)
2248c2ecf20Sopenharmony_ci			return new;
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_ci		/*
2278c2ecf20Sopenharmony_ci		 * If we increase LDO voltage when LDO is enabled we need to
2288c2ecf20Sopenharmony_ci		 * disable the power-good detection until voltage has reached
2298c2ecf20Sopenharmony_ci		 * the new level. According to HW colleagues the maximum time
2308c2ecf20Sopenharmony_ci		 * it takes is 1000us. I assume that on systems with light load
2318c2ecf20Sopenharmony_ci		 * this might be less - and we could probably use DT to give
2328c2ecf20Sopenharmony_ci		 * system specific delay value if performance matters.
2338c2ecf20Sopenharmony_ci		 *
2348c2ecf20Sopenharmony_ci		 * Well, knowing we use I2C here and can add scheduling delays
2358c2ecf20Sopenharmony_ci		 * I don't think it is worth the hassle and I just add fixed
2368c2ecf20Sopenharmony_ci		 * 1ms sleep here (and allow scheduling). If this turns out to
2378c2ecf20Sopenharmony_ci		 * be a problem we can change it to delay and make the delay
2388c2ecf20Sopenharmony_ci		 * time configurable.
2398c2ecf20Sopenharmony_ci		 */
2408c2ecf20Sopenharmony_ci		if (new > now) {
2418c2ecf20Sopenharmony_ci			int ldo_offset = rdev->desc->id - BD718XX_LDO1;
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_ci			*mask = BD718XX_LDO1_VRMON80 << ldo_offset;
2448c2ecf20Sopenharmony_ci			ret = regmap_update_bits(rdev->regmap,
2458c2ecf20Sopenharmony_ci						 BD718XX_REG_MVRFLTMASK2,
2468c2ecf20Sopenharmony_ci						 *mask, *mask);
2478c2ecf20Sopenharmony_ci			if (ret) {
2488c2ecf20Sopenharmony_ci				dev_err(&rdev->dev,
2498c2ecf20Sopenharmony_ci					"Failed to stop voltage monitoring\n");
2508c2ecf20Sopenharmony_ci				return ret;
2518c2ecf20Sopenharmony_ci			}
2528c2ecf20Sopenharmony_ci		}
2538c2ecf20Sopenharmony_ci	}
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_ci	return 0;
2568c2ecf20Sopenharmony_ci}
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_cistatic int bd718xx_set_voltage_sel_restricted(struct regulator_dev *rdev,
2598c2ecf20Sopenharmony_ci						    unsigned int sel)
2608c2ecf20Sopenharmony_ci{
2618c2ecf20Sopenharmony_ci	int ret;
2628c2ecf20Sopenharmony_ci	int mask;
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_ci	ret = voltage_change_prepare(rdev, sel, &mask);
2658c2ecf20Sopenharmony_ci	if (ret)
2668c2ecf20Sopenharmony_ci		return ret;
2678c2ecf20Sopenharmony_ci
2688c2ecf20Sopenharmony_ci	ret = regulator_set_voltage_sel_regmap(rdev, sel);
2698c2ecf20Sopenharmony_ci	voltage_change_done(rdev, sel, &mask);
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_ci	return ret;
2728c2ecf20Sopenharmony_ci}
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_cistatic int bd718xx_set_voltage_sel_pickable_restricted(
2758c2ecf20Sopenharmony_ci		struct regulator_dev *rdev, unsigned int sel)
2768c2ecf20Sopenharmony_ci{
2778c2ecf20Sopenharmony_ci	int ret;
2788c2ecf20Sopenharmony_ci	int mask;
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ci	ret = voltage_change_prepare(rdev, sel, &mask);
2818c2ecf20Sopenharmony_ci	if (ret)
2828c2ecf20Sopenharmony_ci		return ret;
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_ci	ret = regulator_set_voltage_sel_pickable_regmap(rdev, sel);
2858c2ecf20Sopenharmony_ci	voltage_change_done(rdev, sel, &mask);
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_ci	return ret;
2888c2ecf20Sopenharmony_ci}
2898c2ecf20Sopenharmony_ci
2908c2ecf20Sopenharmony_cistatic int bd71837_set_voltage_sel_pickable_restricted(
2918c2ecf20Sopenharmony_ci		struct regulator_dev *rdev, unsigned int sel)
2928c2ecf20Sopenharmony_ci{
2938c2ecf20Sopenharmony_ci	if (rdev->desc->ops->is_enabled(rdev))
2948c2ecf20Sopenharmony_ci		return -EBUSY;
2958c2ecf20Sopenharmony_ci
2968c2ecf20Sopenharmony_ci	return regulator_set_voltage_sel_pickable_regmap(rdev, sel);
2978c2ecf20Sopenharmony_ci}
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_ci/*
3008c2ecf20Sopenharmony_ci * OPS common for BD71847 and BD71850
3018c2ecf20Sopenharmony_ci */
3028c2ecf20Sopenharmony_ciBD718XX_OPS(bd718xx_pickable_range_ldo_ops,
3038c2ecf20Sopenharmony_ci	    regulator_list_voltage_pickable_linear_range, NULL,
3048c2ecf20Sopenharmony_ci	    bd718xx_set_voltage_sel_pickable_restricted,
3058c2ecf20Sopenharmony_ci	    regulator_get_voltage_sel_pickable_regmap, NULL, NULL);
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_ci/* BD71847 and BD71850 LDO 5 is by default OFF at RUN state */
3088c2ecf20Sopenharmony_cistatic const struct regulator_ops bd718xx_ldo5_ops_hwstate = {
3098c2ecf20Sopenharmony_ci	.is_enabled = never_enabled_by_hwstate,
3108c2ecf20Sopenharmony_ci	.list_voltage = regulator_list_voltage_pickable_linear_range,
3118c2ecf20Sopenharmony_ci	.set_voltage_sel = bd718xx_set_voltage_sel_pickable_restricted,
3128c2ecf20Sopenharmony_ci	.get_voltage_sel = regulator_get_voltage_sel_pickable_regmap,
3138c2ecf20Sopenharmony_ci};
3148c2ecf20Sopenharmony_ci
3158c2ecf20Sopenharmony_ciBD718XX_OPS(bd718xx_pickable_range_buck_ops,
3168c2ecf20Sopenharmony_ci	    regulator_list_voltage_pickable_linear_range, NULL,
3178c2ecf20Sopenharmony_ci	    regulator_set_voltage_sel_pickable_regmap,
3188c2ecf20Sopenharmony_ci	    regulator_get_voltage_sel_pickable_regmap,
3198c2ecf20Sopenharmony_ci	    regulator_set_voltage_time_sel, NULL);
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_ciBD718XX_OPS(bd718xx_ldo_regulator_ops, regulator_list_voltage_linear_range,
3228c2ecf20Sopenharmony_ci	    NULL, bd718xx_set_voltage_sel_restricted,
3238c2ecf20Sopenharmony_ci	    regulator_get_voltage_sel_regmap, NULL, NULL);
3248c2ecf20Sopenharmony_ci
3258c2ecf20Sopenharmony_ciBD718XX_OPS(bd718xx_ldo_regulator_nolinear_ops, regulator_list_voltage_table,
3268c2ecf20Sopenharmony_ci	    NULL, bd718xx_set_voltage_sel_restricted,
3278c2ecf20Sopenharmony_ci	    regulator_get_voltage_sel_regmap, NULL, NULL);
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_ciBD718XX_OPS(bd718xx_buck_regulator_ops, regulator_list_voltage_linear_range,
3308c2ecf20Sopenharmony_ci	    NULL, regulator_set_voltage_sel_regmap,
3318c2ecf20Sopenharmony_ci	    regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
3328c2ecf20Sopenharmony_ci	    NULL);
3338c2ecf20Sopenharmony_ci
3348c2ecf20Sopenharmony_ciBD718XX_OPS(bd718xx_buck_regulator_nolinear_ops, regulator_list_voltage_table,
3358c2ecf20Sopenharmony_ci	    regulator_map_voltage_ascend, regulator_set_voltage_sel_regmap,
3368c2ecf20Sopenharmony_ci	    regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
3378c2ecf20Sopenharmony_ci	    NULL);
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_ci/*
3408c2ecf20Sopenharmony_ci * OPS for BD71837
3418c2ecf20Sopenharmony_ci */
3428c2ecf20Sopenharmony_ciBD718XX_OPS(bd71837_pickable_range_ldo_ops,
3438c2ecf20Sopenharmony_ci	    regulator_list_voltage_pickable_linear_range, NULL,
3448c2ecf20Sopenharmony_ci	    bd71837_set_voltage_sel_pickable_restricted,
3458c2ecf20Sopenharmony_ci	    regulator_get_voltage_sel_pickable_regmap, NULL, NULL);
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_ciBD718XX_OPS(bd71837_pickable_range_buck_ops,
3488c2ecf20Sopenharmony_ci	    regulator_list_voltage_pickable_linear_range, NULL,
3498c2ecf20Sopenharmony_ci	    bd71837_set_voltage_sel_pickable_restricted,
3508c2ecf20Sopenharmony_ci	    regulator_get_voltage_sel_pickable_regmap,
3518c2ecf20Sopenharmony_ci	    regulator_set_voltage_time_sel, NULL);
3528c2ecf20Sopenharmony_ci
3538c2ecf20Sopenharmony_ciBD718XX_OPS(bd71837_ldo_regulator_ops, regulator_list_voltage_linear_range,
3548c2ecf20Sopenharmony_ci	    NULL, bd71837_set_voltage_sel_restricted,
3558c2ecf20Sopenharmony_ci	    regulator_get_voltage_sel_regmap, NULL, NULL);
3568c2ecf20Sopenharmony_ci
3578c2ecf20Sopenharmony_ciBD718XX_OPS(bd71837_ldo_regulator_nolinear_ops, regulator_list_voltage_table,
3588c2ecf20Sopenharmony_ci	    NULL, bd71837_set_voltage_sel_restricted,
3598c2ecf20Sopenharmony_ci	    regulator_get_voltage_sel_regmap, NULL, NULL);
3608c2ecf20Sopenharmony_ci
3618c2ecf20Sopenharmony_ciBD718XX_OPS(bd71837_buck_regulator_ops, regulator_list_voltage_linear_range,
3628c2ecf20Sopenharmony_ci	    NULL, bd71837_set_voltage_sel_restricted,
3638c2ecf20Sopenharmony_ci	    regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
3648c2ecf20Sopenharmony_ci	    NULL);
3658c2ecf20Sopenharmony_ci
3668c2ecf20Sopenharmony_ciBD718XX_OPS(bd71837_buck_regulator_nolinear_ops, regulator_list_voltage_table,
3678c2ecf20Sopenharmony_ci	    regulator_map_voltage_ascend, bd71837_set_voltage_sel_restricted,
3688c2ecf20Sopenharmony_ci	    regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
3698c2ecf20Sopenharmony_ci	    NULL);
3708c2ecf20Sopenharmony_ci/*
3718c2ecf20Sopenharmony_ci * BD71837 bucks 3 and 4 support defining their enable/disable state also
3728c2ecf20Sopenharmony_ci * when buck enable state is under HW state machine control. In that case the
3738c2ecf20Sopenharmony_ci * bit [2] in CTRL register is used to indicate if regulator should be ON.
3748c2ecf20Sopenharmony_ci */
3758c2ecf20Sopenharmony_cistatic const struct regulator_ops bd71837_buck34_ops_hwctrl = {
3768c2ecf20Sopenharmony_ci	.is_enabled = bd71837_get_buck34_enable_hwctrl,
3778c2ecf20Sopenharmony_ci	.list_voltage = regulator_list_voltage_linear_range,
3788c2ecf20Sopenharmony_ci	.set_voltage_sel = regulator_set_voltage_sel_regmap,
3798c2ecf20Sopenharmony_ci	.get_voltage_sel = regulator_get_voltage_sel_regmap,
3808c2ecf20Sopenharmony_ci	.set_voltage_time_sel = regulator_set_voltage_time_sel,
3818c2ecf20Sopenharmony_ci	.set_ramp_delay = bd718xx_buck1234_set_ramp_delay,
3828c2ecf20Sopenharmony_ci};
3838c2ecf20Sopenharmony_ci
3848c2ecf20Sopenharmony_ci/*
3858c2ecf20Sopenharmony_ci * OPS for all of the ICs - BD718(37/47/50)
3868c2ecf20Sopenharmony_ci */
3878c2ecf20Sopenharmony_ciBD718XX_OPS(bd718xx_dvs_buck_regulator_ops, regulator_list_voltage_linear_range,
3888c2ecf20Sopenharmony_ci	    NULL, regulator_set_voltage_sel_regmap,
3898c2ecf20Sopenharmony_ci	    regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
3908c2ecf20Sopenharmony_ci	    bd718xx_buck1234_set_ramp_delay);
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_ci/*
3938c2ecf20Sopenharmony_ci * BD71837 BUCK1/2/3/4
3948c2ecf20Sopenharmony_ci * BD71847 BUCK1/2
3958c2ecf20Sopenharmony_ci * 0.70 to 1.30V (10mV step)
3968c2ecf20Sopenharmony_ci */
3978c2ecf20Sopenharmony_cistatic const struct linear_range bd718xx_dvs_buck_volts[] = {
3988c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(700000, 0x00, 0x3C, 10000),
3998c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1300000, 0x3D, 0x3F, 0),
4008c2ecf20Sopenharmony_ci};
4018c2ecf20Sopenharmony_ci
4028c2ecf20Sopenharmony_ci/*
4038c2ecf20Sopenharmony_ci * BD71837 BUCK5
4048c2ecf20Sopenharmony_ci * 0.7V to 1.35V  (range 0)
4058c2ecf20Sopenharmony_ci * and
4068c2ecf20Sopenharmony_ci * 0.675 to 1.325 (range 1)
4078c2ecf20Sopenharmony_ci */
4088c2ecf20Sopenharmony_cistatic const struct linear_range bd71837_buck5_volts[] = {
4098c2ecf20Sopenharmony_ci	/* Ranges when VOLT_SEL bit is 0 */
4108c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(700000, 0x00, 0x03, 100000),
4118c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1050000, 0x04, 0x05, 50000),
4128c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1200000, 0x06, 0x07, 150000),
4138c2ecf20Sopenharmony_ci	/* Ranges when VOLT_SEL bit is 1  */
4148c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(675000, 0x0, 0x3, 100000),
4158c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1025000, 0x4, 0x5, 50000),
4168c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1175000, 0x6, 0x7, 150000),
4178c2ecf20Sopenharmony_ci};
4188c2ecf20Sopenharmony_ci
4198c2ecf20Sopenharmony_ci/*
4208c2ecf20Sopenharmony_ci * Range selector for first 3 linear ranges is 0x0
4218c2ecf20Sopenharmony_ci * and 0x1 for last 3 ranges.
4228c2ecf20Sopenharmony_ci */
4238c2ecf20Sopenharmony_cistatic const unsigned int bd71837_buck5_volt_range_sel[] = {
4248c2ecf20Sopenharmony_ci	0x0, 0x0, 0x0, 0x80, 0x80, 0x80
4258c2ecf20Sopenharmony_ci};
4268c2ecf20Sopenharmony_ci
4278c2ecf20Sopenharmony_ci/*
4288c2ecf20Sopenharmony_ci * BD71847 BUCK3
4298c2ecf20Sopenharmony_ci */
4308c2ecf20Sopenharmony_cistatic const struct linear_range bd71847_buck3_volts[] = {
4318c2ecf20Sopenharmony_ci	/* Ranges when VOLT_SEL bits are 00 */
4328c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(700000, 0x00, 0x03, 100000),
4338c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1050000, 0x04, 0x05, 50000),
4348c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1200000, 0x06, 0x07, 150000),
4358c2ecf20Sopenharmony_ci	/* Ranges when VOLT_SEL bits are 01 */
4368c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(550000, 0x0, 0x7, 50000),
4378c2ecf20Sopenharmony_ci	/* Ranges when VOLT_SEL bits are 11 */
4388c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(675000, 0x0, 0x3, 100000),
4398c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1025000, 0x4, 0x5, 50000),
4408c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1175000, 0x6, 0x7, 150000),
4418c2ecf20Sopenharmony_ci};
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_cistatic const unsigned int bd71847_buck3_volt_range_sel[] = {
4448c2ecf20Sopenharmony_ci	0x0, 0x0, 0x0, 0x40, 0x80, 0x80, 0x80
4458c2ecf20Sopenharmony_ci};
4468c2ecf20Sopenharmony_ci
4478c2ecf20Sopenharmony_cistatic const struct linear_range bd71847_buck4_volts[] = {
4488c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(3000000, 0x00, 0x03, 100000),
4498c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(2600000, 0x00, 0x03, 100000),
4508c2ecf20Sopenharmony_ci};
4518c2ecf20Sopenharmony_ci
4528c2ecf20Sopenharmony_cistatic const unsigned int bd71847_buck4_volt_range_sel[] = { 0x0, 0x40 };
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_ci/*
4558c2ecf20Sopenharmony_ci * BUCK6
4568c2ecf20Sopenharmony_ci * 3.0V to 3.3V (step 100mV)
4578c2ecf20Sopenharmony_ci */
4588c2ecf20Sopenharmony_cistatic const struct linear_range bd71837_buck6_volts[] = {
4598c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(3000000, 0x00, 0x03, 100000),
4608c2ecf20Sopenharmony_ci};
4618c2ecf20Sopenharmony_ci
4628c2ecf20Sopenharmony_ci/*
4638c2ecf20Sopenharmony_ci * BD71837 BUCK7
4648c2ecf20Sopenharmony_ci * BD71847 BUCK5
4658c2ecf20Sopenharmony_ci * 000 = 1.605V
4668c2ecf20Sopenharmony_ci * 001 = 1.695V
4678c2ecf20Sopenharmony_ci * 010 = 1.755V
4688c2ecf20Sopenharmony_ci * 011 = 1.8V (Initial)
4698c2ecf20Sopenharmony_ci * 100 = 1.845V
4708c2ecf20Sopenharmony_ci * 101 = 1.905V
4718c2ecf20Sopenharmony_ci * 110 = 1.95V
4728c2ecf20Sopenharmony_ci * 111 = 1.995V
4738c2ecf20Sopenharmony_ci */
4748c2ecf20Sopenharmony_cistatic const unsigned int bd718xx_3rd_nodvs_buck_volts[] = {
4758c2ecf20Sopenharmony_ci	1605000, 1695000, 1755000, 1800000, 1845000, 1905000, 1950000, 1995000
4768c2ecf20Sopenharmony_ci};
4778c2ecf20Sopenharmony_ci
4788c2ecf20Sopenharmony_ci/*
4798c2ecf20Sopenharmony_ci * BUCK8
4808c2ecf20Sopenharmony_ci * 0.8V to 1.40V (step 10mV)
4818c2ecf20Sopenharmony_ci */
4828c2ecf20Sopenharmony_cistatic const struct linear_range bd718xx_4th_nodvs_buck_volts[] = {
4838c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(800000, 0x00, 0x3C, 10000),
4848c2ecf20Sopenharmony_ci};
4858c2ecf20Sopenharmony_ci
4868c2ecf20Sopenharmony_ci/*
4878c2ecf20Sopenharmony_ci * LDO1
4888c2ecf20Sopenharmony_ci * 3.0 to 3.3V (100mV step)
4898c2ecf20Sopenharmony_ci */
4908c2ecf20Sopenharmony_cistatic const struct linear_range bd718xx_ldo1_volts[] = {
4918c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(3000000, 0x00, 0x03, 100000),
4928c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1600000, 0x00, 0x03, 100000),
4938c2ecf20Sopenharmony_ci};
4948c2ecf20Sopenharmony_ci
4958c2ecf20Sopenharmony_cistatic const unsigned int bd718xx_ldo1_volt_range_sel[] = { 0x0, 0x20 };
4968c2ecf20Sopenharmony_ci
4978c2ecf20Sopenharmony_ci/*
4988c2ecf20Sopenharmony_ci * LDO2
4998c2ecf20Sopenharmony_ci * 0.8 or 0.9V
5008c2ecf20Sopenharmony_ci */
5018c2ecf20Sopenharmony_cistatic const unsigned int ldo_2_volts[] = {
5028c2ecf20Sopenharmony_ci	900000, 800000
5038c2ecf20Sopenharmony_ci};
5048c2ecf20Sopenharmony_ci
5058c2ecf20Sopenharmony_ci/*
5068c2ecf20Sopenharmony_ci * LDO3
5078c2ecf20Sopenharmony_ci * 1.8 to 3.3V (100mV step)
5088c2ecf20Sopenharmony_ci */
5098c2ecf20Sopenharmony_cistatic const struct linear_range bd718xx_ldo3_volts[] = {
5108c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
5118c2ecf20Sopenharmony_ci};
5128c2ecf20Sopenharmony_ci
5138c2ecf20Sopenharmony_ci/*
5148c2ecf20Sopenharmony_ci * LDO4
5158c2ecf20Sopenharmony_ci * 0.9 to 1.8V (100mV step)
5168c2ecf20Sopenharmony_ci */
5178c2ecf20Sopenharmony_cistatic const struct linear_range bd718xx_ldo4_volts[] = {
5188c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(900000, 0x00, 0x09, 100000),
5198c2ecf20Sopenharmony_ci};
5208c2ecf20Sopenharmony_ci
5218c2ecf20Sopenharmony_ci/*
5228c2ecf20Sopenharmony_ci * LDO5 for BD71837
5238c2ecf20Sopenharmony_ci * 1.8 to 3.3V (100mV step)
5248c2ecf20Sopenharmony_ci */
5258c2ecf20Sopenharmony_cistatic const struct linear_range bd71837_ldo5_volts[] = {
5268c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
5278c2ecf20Sopenharmony_ci};
5288c2ecf20Sopenharmony_ci
5298c2ecf20Sopenharmony_ci/*
5308c2ecf20Sopenharmony_ci * LDO5 for BD71837
5318c2ecf20Sopenharmony_ci * 1.8 to 3.3V (100mV step)
5328c2ecf20Sopenharmony_ci */
5338c2ecf20Sopenharmony_cistatic const struct linear_range bd71847_ldo5_volts[] = {
5348c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
5358c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(800000, 0x00, 0x0F, 100000),
5368c2ecf20Sopenharmony_ci};
5378c2ecf20Sopenharmony_ci
5388c2ecf20Sopenharmony_cistatic const unsigned int bd71847_ldo5_volt_range_sel[] = { 0x0, 0x20 };
5398c2ecf20Sopenharmony_ci
5408c2ecf20Sopenharmony_ci/*
5418c2ecf20Sopenharmony_ci * LDO6
5428c2ecf20Sopenharmony_ci * 0.9 to 1.8V (100mV step)
5438c2ecf20Sopenharmony_ci */
5448c2ecf20Sopenharmony_cistatic const struct linear_range bd718xx_ldo6_volts[] = {
5458c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(900000, 0x00, 0x09, 100000),
5468c2ecf20Sopenharmony_ci};
5478c2ecf20Sopenharmony_ci
5488c2ecf20Sopenharmony_ci/*
5498c2ecf20Sopenharmony_ci * LDO7
5508c2ecf20Sopenharmony_ci * 1.8 to 3.3V (100mV step)
5518c2ecf20Sopenharmony_ci */
5528c2ecf20Sopenharmony_cistatic const struct linear_range bd71837_ldo7_volts[] = {
5538c2ecf20Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
5548c2ecf20Sopenharmony_ci};
5558c2ecf20Sopenharmony_ci
5568c2ecf20Sopenharmony_cistruct reg_init {
5578c2ecf20Sopenharmony_ci	unsigned int reg;
5588c2ecf20Sopenharmony_ci	unsigned int mask;
5598c2ecf20Sopenharmony_ci	unsigned int val;
5608c2ecf20Sopenharmony_ci};
5618c2ecf20Sopenharmony_cistruct bd718xx_regulator_data {
5628c2ecf20Sopenharmony_ci	struct regulator_desc desc;
5638c2ecf20Sopenharmony_ci	const struct rohm_dvs_config dvs;
5648c2ecf20Sopenharmony_ci	const struct reg_init init;
5658c2ecf20Sopenharmony_ci	const struct reg_init *additional_inits;
5668c2ecf20Sopenharmony_ci	int additional_init_amnt;
5678c2ecf20Sopenharmony_ci};
5688c2ecf20Sopenharmony_ci
5698c2ecf20Sopenharmony_ci/*
5708c2ecf20Sopenharmony_ci * There is a HW quirk in BD71837. The shutdown sequence timings for
5718c2ecf20Sopenharmony_ci * bucks/LDOs which are controlled via register interface are changed.
5728c2ecf20Sopenharmony_ci * At PMIC poweroff the voltage for BUCK6/7 is cut immediately at the
5738c2ecf20Sopenharmony_ci * beginning of shut-down sequence. As bucks 6 and 7 are parent
5748c2ecf20Sopenharmony_ci * supplies for LDO5 and LDO6 - this causes LDO5/6 voltage
5758c2ecf20Sopenharmony_ci * monitoring to errorneously detect under voltage and force PMIC to
5768c2ecf20Sopenharmony_ci * emergency state instead of poweroff. In order to avoid this we
5778c2ecf20Sopenharmony_ci * disable voltage monitoring for LDO5 and LDO6
5788c2ecf20Sopenharmony_ci */
5798c2ecf20Sopenharmony_cistatic const struct reg_init bd71837_ldo5_inits[] = {
5808c2ecf20Sopenharmony_ci	{
5818c2ecf20Sopenharmony_ci		.reg = BD718XX_REG_MVRFLTMASK2,
5828c2ecf20Sopenharmony_ci		.mask = BD718XX_LDO5_VRMON80,
5838c2ecf20Sopenharmony_ci		.val = BD718XX_LDO5_VRMON80,
5848c2ecf20Sopenharmony_ci	},
5858c2ecf20Sopenharmony_ci};
5868c2ecf20Sopenharmony_ci
5878c2ecf20Sopenharmony_cistatic const struct reg_init bd71837_ldo6_inits[] = {
5888c2ecf20Sopenharmony_ci	{
5898c2ecf20Sopenharmony_ci		.reg = BD718XX_REG_MVRFLTMASK2,
5908c2ecf20Sopenharmony_ci		.mask = BD718XX_LDO6_VRMON80,
5918c2ecf20Sopenharmony_ci		.val = BD718XX_LDO6_VRMON80,
5928c2ecf20Sopenharmony_ci	},
5938c2ecf20Sopenharmony_ci};
5948c2ecf20Sopenharmony_ci
5958c2ecf20Sopenharmony_cistatic int buck_set_hw_dvs_levels(struct device_node *np,
5968c2ecf20Sopenharmony_ci			    const struct regulator_desc *desc,
5978c2ecf20Sopenharmony_ci			    struct regulator_config *cfg)
5988c2ecf20Sopenharmony_ci{
5998c2ecf20Sopenharmony_ci	struct bd718xx_regulator_data *data;
6008c2ecf20Sopenharmony_ci
6018c2ecf20Sopenharmony_ci	data = container_of(desc, struct bd718xx_regulator_data, desc);
6028c2ecf20Sopenharmony_ci
6038c2ecf20Sopenharmony_ci	return rohm_regulator_set_dvs_levels(&data->dvs, np, desc, cfg->regmap);
6048c2ecf20Sopenharmony_ci}
6058c2ecf20Sopenharmony_ci
6068c2ecf20Sopenharmony_cistatic const struct regulator_ops *bd71847_swcontrol_ops[] = {
6078c2ecf20Sopenharmony_ci	&bd718xx_dvs_buck_regulator_ops, &bd718xx_dvs_buck_regulator_ops,
6088c2ecf20Sopenharmony_ci	&bd718xx_pickable_range_buck_ops, &bd718xx_pickable_range_buck_ops,
6098c2ecf20Sopenharmony_ci	&bd718xx_buck_regulator_nolinear_ops, &bd718xx_buck_regulator_ops,
6108c2ecf20Sopenharmony_ci	&bd718xx_pickable_range_ldo_ops, &bd718xx_ldo_regulator_nolinear_ops,
6118c2ecf20Sopenharmony_ci	&bd718xx_ldo_regulator_ops, &bd718xx_ldo_regulator_ops,
6128c2ecf20Sopenharmony_ci	&bd718xx_pickable_range_ldo_ops, &bd718xx_ldo_regulator_ops,
6138c2ecf20Sopenharmony_ci};
6148c2ecf20Sopenharmony_ci
6158c2ecf20Sopenharmony_cistatic const struct regulator_ops *bd71847_hwcontrol_ops[] = {
6168c2ecf20Sopenharmony_ci	&BD718XX_HWOPNAME(bd718xx_dvs_buck_regulator_ops),
6178c2ecf20Sopenharmony_ci	&BD718XX_HWOPNAME(bd718xx_dvs_buck_regulator_ops),
6188c2ecf20Sopenharmony_ci	&BD718XX_HWOPNAME(bd718xx_pickable_range_buck_ops),
6198c2ecf20Sopenharmony_ci	&BD718XX_HWOPNAME(bd718xx_pickable_range_buck_ops),
6208c2ecf20Sopenharmony_ci	&BD718XX_HWOPNAME(bd718xx_buck_regulator_nolinear_ops),
6218c2ecf20Sopenharmony_ci	&BD718XX_HWOPNAME(bd718xx_buck_regulator_ops),
6228c2ecf20Sopenharmony_ci	&BD718XX_HWOPNAME(bd718xx_pickable_range_ldo_ops),
6238c2ecf20Sopenharmony_ci	&BD718XX_HWOPNAME(bd718xx_ldo_regulator_nolinear_ops),
6248c2ecf20Sopenharmony_ci	&BD718XX_HWOPNAME(bd718xx_ldo_regulator_ops),
6258c2ecf20Sopenharmony_ci	&BD718XX_HWOPNAME(bd718xx_ldo_regulator_ops),
6268c2ecf20Sopenharmony_ci	&bd718xx_ldo5_ops_hwstate,
6278c2ecf20Sopenharmony_ci	&BD718XX_HWOPNAME(bd718xx_ldo_regulator_ops),
6288c2ecf20Sopenharmony_ci};
6298c2ecf20Sopenharmony_ci
6308c2ecf20Sopenharmony_cistatic struct bd718xx_regulator_data bd71847_regulators[] = {
6318c2ecf20Sopenharmony_ci	{
6328c2ecf20Sopenharmony_ci		.desc = {
6338c2ecf20Sopenharmony_ci			.name = "buck1",
6348c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("BUCK1"),
6358c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
6368c2ecf20Sopenharmony_ci			.id = BD718XX_BUCK1,
6378c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
6388c2ecf20Sopenharmony_ci			.n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
6398c2ecf20Sopenharmony_ci			.linear_ranges = bd718xx_dvs_buck_volts,
6408c2ecf20Sopenharmony_ci			.n_linear_ranges =
6418c2ecf20Sopenharmony_ci				ARRAY_SIZE(bd718xx_dvs_buck_volts),
6428c2ecf20Sopenharmony_ci			.vsel_reg = BD718XX_REG_BUCK1_VOLT_RUN,
6438c2ecf20Sopenharmony_ci			.vsel_mask = DVS_BUCK_RUN_MASK,
6448c2ecf20Sopenharmony_ci			.enable_reg = BD718XX_REG_BUCK1_CTRL,
6458c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_BUCK_EN,
6468c2ecf20Sopenharmony_ci			.enable_time = BD71847_BUCK1_STARTUP_TIME,
6478c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
6488c2ecf20Sopenharmony_ci			.of_parse_cb = buck_set_hw_dvs_levels,
6498c2ecf20Sopenharmony_ci		},
6508c2ecf20Sopenharmony_ci		.dvs = {
6518c2ecf20Sopenharmony_ci			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
6528c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_SUSPEND,
6538c2ecf20Sopenharmony_ci			.run_reg = BD718XX_REG_BUCK1_VOLT_RUN,
6548c2ecf20Sopenharmony_ci			.run_mask = DVS_BUCK_RUN_MASK,
6558c2ecf20Sopenharmony_ci			.idle_reg = BD718XX_REG_BUCK1_VOLT_IDLE,
6568c2ecf20Sopenharmony_ci			.idle_mask = DVS_BUCK_RUN_MASK,
6578c2ecf20Sopenharmony_ci			.suspend_reg = BD718XX_REG_BUCK1_VOLT_SUSP,
6588c2ecf20Sopenharmony_ci			.suspend_mask = DVS_BUCK_RUN_MASK,
6598c2ecf20Sopenharmony_ci		},
6608c2ecf20Sopenharmony_ci		.init = {
6618c2ecf20Sopenharmony_ci			.reg = BD718XX_REG_BUCK1_CTRL,
6628c2ecf20Sopenharmony_ci			.mask = BD718XX_BUCK_SEL,
6638c2ecf20Sopenharmony_ci			.val = BD718XX_BUCK_SEL,
6648c2ecf20Sopenharmony_ci		},
6658c2ecf20Sopenharmony_ci	},
6668c2ecf20Sopenharmony_ci	{
6678c2ecf20Sopenharmony_ci		.desc = {
6688c2ecf20Sopenharmony_ci			.name = "buck2",
6698c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("BUCK2"),
6708c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
6718c2ecf20Sopenharmony_ci			.id = BD718XX_BUCK2,
6728c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
6738c2ecf20Sopenharmony_ci			.n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
6748c2ecf20Sopenharmony_ci			.linear_ranges = bd718xx_dvs_buck_volts,
6758c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd718xx_dvs_buck_volts),
6768c2ecf20Sopenharmony_ci			.vsel_reg = BD718XX_REG_BUCK2_VOLT_RUN,
6778c2ecf20Sopenharmony_ci			.vsel_mask = DVS_BUCK_RUN_MASK,
6788c2ecf20Sopenharmony_ci			.enable_reg = BD718XX_REG_BUCK2_CTRL,
6798c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_BUCK_EN,
6808c2ecf20Sopenharmony_ci			.enable_time = BD71847_BUCK2_STARTUP_TIME,
6818c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
6828c2ecf20Sopenharmony_ci			.of_parse_cb = buck_set_hw_dvs_levels,
6838c2ecf20Sopenharmony_ci		},
6848c2ecf20Sopenharmony_ci		.dvs = {
6858c2ecf20Sopenharmony_ci			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE,
6868c2ecf20Sopenharmony_ci			.run_reg = BD718XX_REG_BUCK2_VOLT_RUN,
6878c2ecf20Sopenharmony_ci			.run_mask = DVS_BUCK_RUN_MASK,
6888c2ecf20Sopenharmony_ci			.idle_reg = BD718XX_REG_BUCK2_VOLT_IDLE,
6898c2ecf20Sopenharmony_ci			.idle_mask = DVS_BUCK_RUN_MASK,
6908c2ecf20Sopenharmony_ci		},
6918c2ecf20Sopenharmony_ci		.init = {
6928c2ecf20Sopenharmony_ci			.reg = BD718XX_REG_BUCK2_CTRL,
6938c2ecf20Sopenharmony_ci			.mask = BD718XX_BUCK_SEL,
6948c2ecf20Sopenharmony_ci			.val = BD718XX_BUCK_SEL,
6958c2ecf20Sopenharmony_ci		},
6968c2ecf20Sopenharmony_ci	},
6978c2ecf20Sopenharmony_ci	{
6988c2ecf20Sopenharmony_ci		.desc = {
6998c2ecf20Sopenharmony_ci			.name = "buck3",
7008c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("BUCK3"),
7018c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
7028c2ecf20Sopenharmony_ci			.id = BD718XX_BUCK3,
7038c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
7048c2ecf20Sopenharmony_ci			.n_voltages = BD71847_BUCK3_VOLTAGE_NUM,
7058c2ecf20Sopenharmony_ci			.linear_ranges = bd71847_buck3_volts,
7068c2ecf20Sopenharmony_ci			.n_linear_ranges =
7078c2ecf20Sopenharmony_ci				ARRAY_SIZE(bd71847_buck3_volts),
7088c2ecf20Sopenharmony_ci			.vsel_reg = BD718XX_REG_1ST_NODVS_BUCK_VOLT,
7098c2ecf20Sopenharmony_ci			.vsel_mask = BD718XX_1ST_NODVS_BUCK_MASK,
7108c2ecf20Sopenharmony_ci			.vsel_range_reg = BD718XX_REG_1ST_NODVS_BUCK_VOLT,
7118c2ecf20Sopenharmony_ci			.vsel_range_mask = BD71847_BUCK3_RANGE_MASK,
7128c2ecf20Sopenharmony_ci			.linear_range_selectors = bd71847_buck3_volt_range_sel,
7138c2ecf20Sopenharmony_ci			.enable_reg = BD718XX_REG_1ST_NODVS_BUCK_CTRL,
7148c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_BUCK_EN,
7158c2ecf20Sopenharmony_ci			.enable_time = BD71847_BUCK3_STARTUP_TIME,
7168c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
7178c2ecf20Sopenharmony_ci		},
7188c2ecf20Sopenharmony_ci		.init = {
7198c2ecf20Sopenharmony_ci			.reg = BD718XX_REG_1ST_NODVS_BUCK_CTRL,
7208c2ecf20Sopenharmony_ci			.mask = BD718XX_BUCK_SEL,
7218c2ecf20Sopenharmony_ci			.val = BD718XX_BUCK_SEL,
7228c2ecf20Sopenharmony_ci		},
7238c2ecf20Sopenharmony_ci	},
7248c2ecf20Sopenharmony_ci	{
7258c2ecf20Sopenharmony_ci		.desc = {
7268c2ecf20Sopenharmony_ci			.name = "buck4",
7278c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("BUCK4"),
7288c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
7298c2ecf20Sopenharmony_ci			.id = BD718XX_BUCK4,
7308c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
7318c2ecf20Sopenharmony_ci			.n_voltages = BD71847_BUCK4_VOLTAGE_NUM,
7328c2ecf20Sopenharmony_ci			.linear_ranges = bd71847_buck4_volts,
7338c2ecf20Sopenharmony_ci			.n_linear_ranges =
7348c2ecf20Sopenharmony_ci				ARRAY_SIZE(bd71847_buck4_volts),
7358c2ecf20Sopenharmony_ci			.enable_reg = BD718XX_REG_2ND_NODVS_BUCK_CTRL,
7368c2ecf20Sopenharmony_ci			.vsel_reg = BD718XX_REG_2ND_NODVS_BUCK_VOLT,
7378c2ecf20Sopenharmony_ci			.vsel_mask = BD71847_BUCK4_MASK,
7388c2ecf20Sopenharmony_ci			.vsel_range_reg = BD718XX_REG_2ND_NODVS_BUCK_VOLT,
7398c2ecf20Sopenharmony_ci			.vsel_range_mask = BD71847_BUCK4_RANGE_MASK,
7408c2ecf20Sopenharmony_ci			.linear_range_selectors = bd71847_buck4_volt_range_sel,
7418c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_BUCK_EN,
7428c2ecf20Sopenharmony_ci			.enable_time = BD71847_BUCK4_STARTUP_TIME,
7438c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
7448c2ecf20Sopenharmony_ci		},
7458c2ecf20Sopenharmony_ci		.init = {
7468c2ecf20Sopenharmony_ci			.reg = BD718XX_REG_2ND_NODVS_BUCK_CTRL,
7478c2ecf20Sopenharmony_ci			.mask = BD718XX_BUCK_SEL,
7488c2ecf20Sopenharmony_ci			.val = BD718XX_BUCK_SEL,
7498c2ecf20Sopenharmony_ci		},
7508c2ecf20Sopenharmony_ci	},
7518c2ecf20Sopenharmony_ci	{
7528c2ecf20Sopenharmony_ci		.desc = {
7538c2ecf20Sopenharmony_ci			.name = "buck5",
7548c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("BUCK5"),
7558c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
7568c2ecf20Sopenharmony_ci			.id = BD718XX_BUCK5,
7578c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
7588c2ecf20Sopenharmony_ci			.volt_table = &bd718xx_3rd_nodvs_buck_volts[0],
7598c2ecf20Sopenharmony_ci			.n_voltages = ARRAY_SIZE(bd718xx_3rd_nodvs_buck_volts),
7608c2ecf20Sopenharmony_ci			.vsel_reg = BD718XX_REG_3RD_NODVS_BUCK_VOLT,
7618c2ecf20Sopenharmony_ci			.vsel_mask = BD718XX_3RD_NODVS_BUCK_MASK,
7628c2ecf20Sopenharmony_ci			.enable_reg = BD718XX_REG_3RD_NODVS_BUCK_CTRL,
7638c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_BUCK_EN,
7648c2ecf20Sopenharmony_ci			.enable_time = BD71847_BUCK5_STARTUP_TIME,
7658c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
7668c2ecf20Sopenharmony_ci		},
7678c2ecf20Sopenharmony_ci		.init = {
7688c2ecf20Sopenharmony_ci			.reg = BD718XX_REG_3RD_NODVS_BUCK_CTRL,
7698c2ecf20Sopenharmony_ci			.mask = BD718XX_BUCK_SEL,
7708c2ecf20Sopenharmony_ci			.val = BD718XX_BUCK_SEL,
7718c2ecf20Sopenharmony_ci		},
7728c2ecf20Sopenharmony_ci	},
7738c2ecf20Sopenharmony_ci	{
7748c2ecf20Sopenharmony_ci		.desc = {
7758c2ecf20Sopenharmony_ci			.name = "buck6",
7768c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("BUCK6"),
7778c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
7788c2ecf20Sopenharmony_ci			.id = BD718XX_BUCK6,
7798c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
7808c2ecf20Sopenharmony_ci			.n_voltages = BD718XX_4TH_NODVS_BUCK_VOLTAGE_NUM,
7818c2ecf20Sopenharmony_ci			.linear_ranges = bd718xx_4th_nodvs_buck_volts,
7828c2ecf20Sopenharmony_ci			.n_linear_ranges =
7838c2ecf20Sopenharmony_ci				ARRAY_SIZE(bd718xx_4th_nodvs_buck_volts),
7848c2ecf20Sopenharmony_ci			.vsel_reg = BD718XX_REG_4TH_NODVS_BUCK_VOLT,
7858c2ecf20Sopenharmony_ci			.vsel_mask = BD718XX_4TH_NODVS_BUCK_MASK,
7868c2ecf20Sopenharmony_ci			.enable_reg = BD718XX_REG_4TH_NODVS_BUCK_CTRL,
7878c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_BUCK_EN,
7888c2ecf20Sopenharmony_ci			.enable_time = BD71847_BUCK6_STARTUP_TIME,
7898c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
7908c2ecf20Sopenharmony_ci		},
7918c2ecf20Sopenharmony_ci		.init = {
7928c2ecf20Sopenharmony_ci			.reg = BD718XX_REG_4TH_NODVS_BUCK_CTRL,
7938c2ecf20Sopenharmony_ci			.mask = BD718XX_BUCK_SEL,
7948c2ecf20Sopenharmony_ci			.val = BD718XX_BUCK_SEL,
7958c2ecf20Sopenharmony_ci		},
7968c2ecf20Sopenharmony_ci	},
7978c2ecf20Sopenharmony_ci	{
7988c2ecf20Sopenharmony_ci		.desc = {
7998c2ecf20Sopenharmony_ci			.name = "ldo1",
8008c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("LDO1"),
8018c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
8028c2ecf20Sopenharmony_ci			.id = BD718XX_LDO1,
8038c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
8048c2ecf20Sopenharmony_ci			.n_voltages = BD718XX_LDO1_VOLTAGE_NUM,
8058c2ecf20Sopenharmony_ci			.linear_ranges = bd718xx_ldo1_volts,
8068c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd718xx_ldo1_volts),
8078c2ecf20Sopenharmony_ci			.vsel_reg = BD718XX_REG_LDO1_VOLT,
8088c2ecf20Sopenharmony_ci			.vsel_mask = BD718XX_LDO1_MASK,
8098c2ecf20Sopenharmony_ci			.vsel_range_reg = BD718XX_REG_LDO1_VOLT,
8108c2ecf20Sopenharmony_ci			.vsel_range_mask = BD718XX_LDO1_RANGE_MASK,
8118c2ecf20Sopenharmony_ci			.linear_range_selectors = bd718xx_ldo1_volt_range_sel,
8128c2ecf20Sopenharmony_ci			.enable_reg = BD718XX_REG_LDO1_VOLT,
8138c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_LDO_EN,
8148c2ecf20Sopenharmony_ci			.enable_time = BD71847_LDO1_STARTUP_TIME,
8158c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
8168c2ecf20Sopenharmony_ci		},
8178c2ecf20Sopenharmony_ci		.init = {
8188c2ecf20Sopenharmony_ci			.reg = BD718XX_REG_LDO1_VOLT,
8198c2ecf20Sopenharmony_ci			.mask = BD718XX_LDO_SEL,
8208c2ecf20Sopenharmony_ci			.val = BD718XX_LDO_SEL,
8218c2ecf20Sopenharmony_ci		},
8228c2ecf20Sopenharmony_ci	},
8238c2ecf20Sopenharmony_ci	{
8248c2ecf20Sopenharmony_ci		.desc = {
8258c2ecf20Sopenharmony_ci			.name = "ldo2",
8268c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("LDO2"),
8278c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
8288c2ecf20Sopenharmony_ci			.id = BD718XX_LDO2,
8298c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
8308c2ecf20Sopenharmony_ci			.volt_table = &ldo_2_volts[0],
8318c2ecf20Sopenharmony_ci			.vsel_reg = BD718XX_REG_LDO2_VOLT,
8328c2ecf20Sopenharmony_ci			.vsel_mask = BD718XX_LDO2_MASK,
8338c2ecf20Sopenharmony_ci			.n_voltages = ARRAY_SIZE(ldo_2_volts),
8348c2ecf20Sopenharmony_ci			.enable_reg = BD718XX_REG_LDO2_VOLT,
8358c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_LDO_EN,
8368c2ecf20Sopenharmony_ci			.enable_time = BD71847_LDO2_STARTUP_TIME,
8378c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
8388c2ecf20Sopenharmony_ci		},
8398c2ecf20Sopenharmony_ci		.init = {
8408c2ecf20Sopenharmony_ci			.reg = BD718XX_REG_LDO2_VOLT,
8418c2ecf20Sopenharmony_ci			.mask = BD718XX_LDO_SEL,
8428c2ecf20Sopenharmony_ci			.val = BD718XX_LDO_SEL,
8438c2ecf20Sopenharmony_ci		},
8448c2ecf20Sopenharmony_ci	},
8458c2ecf20Sopenharmony_ci	{
8468c2ecf20Sopenharmony_ci		.desc = {
8478c2ecf20Sopenharmony_ci			.name = "ldo3",
8488c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("LDO3"),
8498c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
8508c2ecf20Sopenharmony_ci			.id = BD718XX_LDO3,
8518c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
8528c2ecf20Sopenharmony_ci			.n_voltages = BD718XX_LDO3_VOLTAGE_NUM,
8538c2ecf20Sopenharmony_ci			.linear_ranges = bd718xx_ldo3_volts,
8548c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd718xx_ldo3_volts),
8558c2ecf20Sopenharmony_ci			.vsel_reg = BD718XX_REG_LDO3_VOLT,
8568c2ecf20Sopenharmony_ci			.vsel_mask = BD718XX_LDO3_MASK,
8578c2ecf20Sopenharmony_ci			.enable_reg = BD718XX_REG_LDO3_VOLT,
8588c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_LDO_EN,
8598c2ecf20Sopenharmony_ci			.enable_time = BD71847_LDO3_STARTUP_TIME,
8608c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
8618c2ecf20Sopenharmony_ci		},
8628c2ecf20Sopenharmony_ci		.init = {
8638c2ecf20Sopenharmony_ci			.reg = BD718XX_REG_LDO3_VOLT,
8648c2ecf20Sopenharmony_ci			.mask = BD718XX_LDO_SEL,
8658c2ecf20Sopenharmony_ci			.val = BD718XX_LDO_SEL,
8668c2ecf20Sopenharmony_ci		},
8678c2ecf20Sopenharmony_ci	},
8688c2ecf20Sopenharmony_ci	{
8698c2ecf20Sopenharmony_ci		.desc = {
8708c2ecf20Sopenharmony_ci			.name = "ldo4",
8718c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("LDO4"),
8728c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
8738c2ecf20Sopenharmony_ci			.id = BD718XX_LDO4,
8748c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
8758c2ecf20Sopenharmony_ci			.n_voltages = BD718XX_LDO4_VOLTAGE_NUM,
8768c2ecf20Sopenharmony_ci			.linear_ranges = bd718xx_ldo4_volts,
8778c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd718xx_ldo4_volts),
8788c2ecf20Sopenharmony_ci			.vsel_reg = BD718XX_REG_LDO4_VOLT,
8798c2ecf20Sopenharmony_ci			.vsel_mask = BD718XX_LDO4_MASK,
8808c2ecf20Sopenharmony_ci			.enable_reg = BD718XX_REG_LDO4_VOLT,
8818c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_LDO_EN,
8828c2ecf20Sopenharmony_ci			.enable_time = BD71847_LDO4_STARTUP_TIME,
8838c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
8848c2ecf20Sopenharmony_ci		},
8858c2ecf20Sopenharmony_ci		.init = {
8868c2ecf20Sopenharmony_ci			.reg = BD718XX_REG_LDO4_VOLT,
8878c2ecf20Sopenharmony_ci			.mask = BD718XX_LDO_SEL,
8888c2ecf20Sopenharmony_ci			.val = BD718XX_LDO_SEL,
8898c2ecf20Sopenharmony_ci		},
8908c2ecf20Sopenharmony_ci	},
8918c2ecf20Sopenharmony_ci	{
8928c2ecf20Sopenharmony_ci		.desc = {
8938c2ecf20Sopenharmony_ci			.name = "ldo5",
8948c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("LDO5"),
8958c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
8968c2ecf20Sopenharmony_ci			.id = BD718XX_LDO5,
8978c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
8988c2ecf20Sopenharmony_ci			.n_voltages = BD71847_LDO5_VOLTAGE_NUM,
8998c2ecf20Sopenharmony_ci			.linear_ranges = bd71847_ldo5_volts,
9008c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd71847_ldo5_volts),
9018c2ecf20Sopenharmony_ci			.vsel_reg = BD718XX_REG_LDO5_VOLT,
9028c2ecf20Sopenharmony_ci			.vsel_mask = BD71847_LDO5_MASK,
9038c2ecf20Sopenharmony_ci			.vsel_range_reg = BD718XX_REG_LDO5_VOLT,
9048c2ecf20Sopenharmony_ci			.vsel_range_mask = BD71847_LDO5_RANGE_MASK,
9058c2ecf20Sopenharmony_ci			.linear_range_selectors = bd71847_ldo5_volt_range_sel,
9068c2ecf20Sopenharmony_ci			.enable_reg = BD718XX_REG_LDO5_VOLT,
9078c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_LDO_EN,
9088c2ecf20Sopenharmony_ci			.enable_time = BD71847_LDO5_STARTUP_TIME,
9098c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
9108c2ecf20Sopenharmony_ci		},
9118c2ecf20Sopenharmony_ci		.init = {
9128c2ecf20Sopenharmony_ci			.reg = BD718XX_REG_LDO5_VOLT,
9138c2ecf20Sopenharmony_ci			.mask = BD718XX_LDO_SEL,
9148c2ecf20Sopenharmony_ci			.val = BD718XX_LDO_SEL,
9158c2ecf20Sopenharmony_ci		},
9168c2ecf20Sopenharmony_ci	},
9178c2ecf20Sopenharmony_ci	{
9188c2ecf20Sopenharmony_ci		.desc = {
9198c2ecf20Sopenharmony_ci			.name = "ldo6",
9208c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("LDO6"),
9218c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
9228c2ecf20Sopenharmony_ci			.id = BD718XX_LDO6,
9238c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
9248c2ecf20Sopenharmony_ci			.n_voltages = BD718XX_LDO6_VOLTAGE_NUM,
9258c2ecf20Sopenharmony_ci			.linear_ranges = bd718xx_ldo6_volts,
9268c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd718xx_ldo6_volts),
9278c2ecf20Sopenharmony_ci			/* LDO6 is supplied by buck5 */
9288c2ecf20Sopenharmony_ci			.supply_name = "buck5",
9298c2ecf20Sopenharmony_ci			.vsel_reg = BD718XX_REG_LDO6_VOLT,
9308c2ecf20Sopenharmony_ci			.vsel_mask = BD718XX_LDO6_MASK,
9318c2ecf20Sopenharmony_ci			.enable_reg = BD718XX_REG_LDO6_VOLT,
9328c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_LDO_EN,
9338c2ecf20Sopenharmony_ci			.enable_time = BD71847_LDO6_STARTUP_TIME,
9348c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
9358c2ecf20Sopenharmony_ci		},
9368c2ecf20Sopenharmony_ci		.init = {
9378c2ecf20Sopenharmony_ci			.reg = BD718XX_REG_LDO6_VOLT,
9388c2ecf20Sopenharmony_ci			.mask = BD718XX_LDO_SEL,
9398c2ecf20Sopenharmony_ci			.val = BD718XX_LDO_SEL,
9408c2ecf20Sopenharmony_ci		},
9418c2ecf20Sopenharmony_ci	},
9428c2ecf20Sopenharmony_ci};
9438c2ecf20Sopenharmony_ci
9448c2ecf20Sopenharmony_cistatic const struct regulator_ops *bd71837_swcontrol_ops[] = {
9458c2ecf20Sopenharmony_ci	&bd718xx_dvs_buck_regulator_ops, &bd718xx_dvs_buck_regulator_ops,
9468c2ecf20Sopenharmony_ci	&bd718xx_dvs_buck_regulator_ops, &bd718xx_dvs_buck_regulator_ops,
9478c2ecf20Sopenharmony_ci	&bd71837_pickable_range_buck_ops, &bd71837_buck_regulator_ops,
9488c2ecf20Sopenharmony_ci	&bd71837_buck_regulator_nolinear_ops, &bd71837_buck_regulator_ops,
9498c2ecf20Sopenharmony_ci	&bd71837_pickable_range_ldo_ops, &bd71837_ldo_regulator_nolinear_ops,
9508c2ecf20Sopenharmony_ci	&bd71837_ldo_regulator_ops, &bd71837_ldo_regulator_ops,
9518c2ecf20Sopenharmony_ci	&bd71837_ldo_regulator_ops, &bd71837_ldo_regulator_ops,
9528c2ecf20Sopenharmony_ci	&bd71837_ldo_regulator_ops,
9538c2ecf20Sopenharmony_ci};
9548c2ecf20Sopenharmony_ci
9558c2ecf20Sopenharmony_cistatic const struct regulator_ops *bd71837_hwcontrol_ops[] = {
9568c2ecf20Sopenharmony_ci	&BD718XX_HWOPNAME(bd718xx_dvs_buck_regulator_ops),
9578c2ecf20Sopenharmony_ci	&BD718XX_HWOPNAME(bd718xx_dvs_buck_regulator_ops),
9588c2ecf20Sopenharmony_ci	&bd71837_buck34_ops_hwctrl, &bd71837_buck34_ops_hwctrl,
9598c2ecf20Sopenharmony_ci	&BD718XX_HWOPNAME(bd71837_pickable_range_buck_ops),
9608c2ecf20Sopenharmony_ci	&BD718XX_HWOPNAME(bd71837_buck_regulator_ops),
9618c2ecf20Sopenharmony_ci	&BD718XX_HWOPNAME(bd71837_buck_regulator_nolinear_ops),
9628c2ecf20Sopenharmony_ci	&BD718XX_HWOPNAME(bd71837_buck_regulator_ops),
9638c2ecf20Sopenharmony_ci	&BD718XX_HWOPNAME(bd71837_pickable_range_ldo_ops),
9648c2ecf20Sopenharmony_ci	&BD718XX_HWOPNAME(bd71837_ldo_regulator_nolinear_ops),
9658c2ecf20Sopenharmony_ci	&BD718XX_HWOPNAME(bd71837_ldo_regulator_ops),
9668c2ecf20Sopenharmony_ci	&BD718XX_HWOPNAME(bd71837_ldo_regulator_ops),
9678c2ecf20Sopenharmony_ci	&BD718XX_HWOPNAME(bd71837_ldo_regulator_ops),
9688c2ecf20Sopenharmony_ci	&BD718XX_HWOPNAME(bd71837_ldo_regulator_ops),
9698c2ecf20Sopenharmony_ci	&BD718XX_HWOPNAME(bd71837_ldo_regulator_ops),
9708c2ecf20Sopenharmony_ci};
9718c2ecf20Sopenharmony_ci
9728c2ecf20Sopenharmony_cistatic struct bd718xx_regulator_data bd71837_regulators[] = {
9738c2ecf20Sopenharmony_ci	{
9748c2ecf20Sopenharmony_ci		.desc = {
9758c2ecf20Sopenharmony_ci			.name = "buck1",
9768c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("BUCK1"),
9778c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
9788c2ecf20Sopenharmony_ci			.id = BD718XX_BUCK1,
9798c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
9808c2ecf20Sopenharmony_ci			.n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
9818c2ecf20Sopenharmony_ci			.linear_ranges = bd718xx_dvs_buck_volts,
9828c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd718xx_dvs_buck_volts),
9838c2ecf20Sopenharmony_ci			.vsel_reg = BD718XX_REG_BUCK1_VOLT_RUN,
9848c2ecf20Sopenharmony_ci			.vsel_mask = DVS_BUCK_RUN_MASK,
9858c2ecf20Sopenharmony_ci			.enable_reg = BD718XX_REG_BUCK1_CTRL,
9868c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_BUCK_EN,
9878c2ecf20Sopenharmony_ci			.enable_time = BD71837_BUCK1_STARTUP_TIME,
9888c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
9898c2ecf20Sopenharmony_ci			.of_parse_cb = buck_set_hw_dvs_levels,
9908c2ecf20Sopenharmony_ci		},
9918c2ecf20Sopenharmony_ci		.dvs = {
9928c2ecf20Sopenharmony_ci			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
9938c2ecf20Sopenharmony_ci				     ROHM_DVS_LEVEL_SUSPEND,
9948c2ecf20Sopenharmony_ci			.run_reg = BD718XX_REG_BUCK1_VOLT_RUN,
9958c2ecf20Sopenharmony_ci			.run_mask = DVS_BUCK_RUN_MASK,
9968c2ecf20Sopenharmony_ci			.idle_reg = BD718XX_REG_BUCK1_VOLT_IDLE,
9978c2ecf20Sopenharmony_ci			.idle_mask = DVS_BUCK_RUN_MASK,
9988c2ecf20Sopenharmony_ci			.suspend_reg = BD718XX_REG_BUCK1_VOLT_SUSP,
9998c2ecf20Sopenharmony_ci			.suspend_mask = DVS_BUCK_RUN_MASK,
10008c2ecf20Sopenharmony_ci		},
10018c2ecf20Sopenharmony_ci		.init = {
10028c2ecf20Sopenharmony_ci			.reg = BD718XX_REG_BUCK1_CTRL,
10038c2ecf20Sopenharmony_ci			.mask = BD718XX_BUCK_SEL,
10048c2ecf20Sopenharmony_ci			.val = BD718XX_BUCK_SEL,
10058c2ecf20Sopenharmony_ci		},
10068c2ecf20Sopenharmony_ci	},
10078c2ecf20Sopenharmony_ci	{
10088c2ecf20Sopenharmony_ci		.desc = {
10098c2ecf20Sopenharmony_ci			.name = "buck2",
10108c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("BUCK2"),
10118c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
10128c2ecf20Sopenharmony_ci			.id = BD718XX_BUCK2,
10138c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
10148c2ecf20Sopenharmony_ci			.n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
10158c2ecf20Sopenharmony_ci			.linear_ranges = bd718xx_dvs_buck_volts,
10168c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd718xx_dvs_buck_volts),
10178c2ecf20Sopenharmony_ci			.vsel_reg = BD718XX_REG_BUCK2_VOLT_RUN,
10188c2ecf20Sopenharmony_ci			.vsel_mask = DVS_BUCK_RUN_MASK,
10198c2ecf20Sopenharmony_ci			.enable_reg = BD718XX_REG_BUCK2_CTRL,
10208c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_BUCK_EN,
10218c2ecf20Sopenharmony_ci			.enable_time = BD71837_BUCK2_STARTUP_TIME,
10228c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
10238c2ecf20Sopenharmony_ci			.of_parse_cb = buck_set_hw_dvs_levels,
10248c2ecf20Sopenharmony_ci		},
10258c2ecf20Sopenharmony_ci		.dvs = {
10268c2ecf20Sopenharmony_ci			.level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE,
10278c2ecf20Sopenharmony_ci			.run_reg = BD718XX_REG_BUCK2_VOLT_RUN,
10288c2ecf20Sopenharmony_ci			.run_mask = DVS_BUCK_RUN_MASK,
10298c2ecf20Sopenharmony_ci			.idle_reg = BD718XX_REG_BUCK2_VOLT_IDLE,
10308c2ecf20Sopenharmony_ci			.idle_mask = DVS_BUCK_RUN_MASK,
10318c2ecf20Sopenharmony_ci		},
10328c2ecf20Sopenharmony_ci		.init = {
10338c2ecf20Sopenharmony_ci			.reg = BD718XX_REG_BUCK2_CTRL,
10348c2ecf20Sopenharmony_ci			.mask = BD718XX_BUCK_SEL,
10358c2ecf20Sopenharmony_ci			.val = BD718XX_BUCK_SEL,
10368c2ecf20Sopenharmony_ci		},
10378c2ecf20Sopenharmony_ci	},
10388c2ecf20Sopenharmony_ci	{
10398c2ecf20Sopenharmony_ci		.desc = {
10408c2ecf20Sopenharmony_ci			.name = "buck3",
10418c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("BUCK3"),
10428c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
10438c2ecf20Sopenharmony_ci			.id = BD718XX_BUCK3,
10448c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
10458c2ecf20Sopenharmony_ci			.n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
10468c2ecf20Sopenharmony_ci			.linear_ranges = bd718xx_dvs_buck_volts,
10478c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd718xx_dvs_buck_volts),
10488c2ecf20Sopenharmony_ci			.vsel_reg = BD71837_REG_BUCK3_VOLT_RUN,
10498c2ecf20Sopenharmony_ci			.vsel_mask = DVS_BUCK_RUN_MASK,
10508c2ecf20Sopenharmony_ci			.enable_reg = BD71837_REG_BUCK3_CTRL,
10518c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_BUCK_EN,
10528c2ecf20Sopenharmony_ci			.enable_time = BD71837_BUCK3_STARTUP_TIME,
10538c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
10548c2ecf20Sopenharmony_ci			.of_parse_cb = buck_set_hw_dvs_levels,
10558c2ecf20Sopenharmony_ci		},
10568c2ecf20Sopenharmony_ci		.dvs = {
10578c2ecf20Sopenharmony_ci			.level_map = ROHM_DVS_LEVEL_RUN,
10588c2ecf20Sopenharmony_ci			.run_reg = BD71837_REG_BUCK3_VOLT_RUN,
10598c2ecf20Sopenharmony_ci			.run_mask = DVS_BUCK_RUN_MASK,
10608c2ecf20Sopenharmony_ci		},
10618c2ecf20Sopenharmony_ci		.init = {
10628c2ecf20Sopenharmony_ci			.reg = BD71837_REG_BUCK3_CTRL,
10638c2ecf20Sopenharmony_ci			.mask = BD718XX_BUCK_SEL,
10648c2ecf20Sopenharmony_ci			.val = BD718XX_BUCK_SEL,
10658c2ecf20Sopenharmony_ci		},
10668c2ecf20Sopenharmony_ci	},
10678c2ecf20Sopenharmony_ci	{
10688c2ecf20Sopenharmony_ci		.desc = {
10698c2ecf20Sopenharmony_ci			.name = "buck4",
10708c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("BUCK4"),
10718c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
10728c2ecf20Sopenharmony_ci			.id = BD718XX_BUCK4,
10738c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
10748c2ecf20Sopenharmony_ci			.n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
10758c2ecf20Sopenharmony_ci			.linear_ranges = bd718xx_dvs_buck_volts,
10768c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd718xx_dvs_buck_volts),
10778c2ecf20Sopenharmony_ci			.vsel_reg = BD71837_REG_BUCK4_VOLT_RUN,
10788c2ecf20Sopenharmony_ci			.vsel_mask = DVS_BUCK_RUN_MASK,
10798c2ecf20Sopenharmony_ci			.enable_reg = BD71837_REG_BUCK4_CTRL,
10808c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_BUCK_EN,
10818c2ecf20Sopenharmony_ci			.enable_time = BD71837_BUCK4_STARTUP_TIME,
10828c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
10838c2ecf20Sopenharmony_ci			.of_parse_cb = buck_set_hw_dvs_levels,
10848c2ecf20Sopenharmony_ci		},
10858c2ecf20Sopenharmony_ci		.dvs = {
10868c2ecf20Sopenharmony_ci			.level_map = ROHM_DVS_LEVEL_RUN,
10878c2ecf20Sopenharmony_ci			.run_reg = BD71837_REG_BUCK4_VOLT_RUN,
10888c2ecf20Sopenharmony_ci			.run_mask = DVS_BUCK_RUN_MASK,
10898c2ecf20Sopenharmony_ci		},
10908c2ecf20Sopenharmony_ci		.init = {
10918c2ecf20Sopenharmony_ci			.reg = BD71837_REG_BUCK4_CTRL,
10928c2ecf20Sopenharmony_ci			.mask = BD718XX_BUCK_SEL,
10938c2ecf20Sopenharmony_ci			.val = BD718XX_BUCK_SEL,
10948c2ecf20Sopenharmony_ci		},
10958c2ecf20Sopenharmony_ci	},
10968c2ecf20Sopenharmony_ci	{
10978c2ecf20Sopenharmony_ci		.desc = {
10988c2ecf20Sopenharmony_ci			.name = "buck5",
10998c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("BUCK5"),
11008c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
11018c2ecf20Sopenharmony_ci			.id = BD718XX_BUCK5,
11028c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
11038c2ecf20Sopenharmony_ci			.n_voltages = BD71837_BUCK5_VOLTAGE_NUM,
11048c2ecf20Sopenharmony_ci			.linear_ranges = bd71837_buck5_volts,
11058c2ecf20Sopenharmony_ci			.n_linear_ranges =
11068c2ecf20Sopenharmony_ci				ARRAY_SIZE(bd71837_buck5_volts),
11078c2ecf20Sopenharmony_ci			.vsel_reg = BD718XX_REG_1ST_NODVS_BUCK_VOLT,
11088c2ecf20Sopenharmony_ci			.vsel_mask = BD71837_BUCK5_MASK,
11098c2ecf20Sopenharmony_ci			.vsel_range_reg = BD718XX_REG_1ST_NODVS_BUCK_VOLT,
11108c2ecf20Sopenharmony_ci			.vsel_range_mask = BD71837_BUCK5_RANGE_MASK,
11118c2ecf20Sopenharmony_ci			.linear_range_selectors = bd71837_buck5_volt_range_sel,
11128c2ecf20Sopenharmony_ci			.enable_reg = BD718XX_REG_1ST_NODVS_BUCK_CTRL,
11138c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_BUCK_EN,
11148c2ecf20Sopenharmony_ci			.enable_time = BD71837_BUCK5_STARTUP_TIME,
11158c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
11168c2ecf20Sopenharmony_ci		},
11178c2ecf20Sopenharmony_ci		.init = {
11188c2ecf20Sopenharmony_ci			.reg = BD718XX_REG_1ST_NODVS_BUCK_CTRL,
11198c2ecf20Sopenharmony_ci			.mask = BD718XX_BUCK_SEL,
11208c2ecf20Sopenharmony_ci			.val = BD718XX_BUCK_SEL,
11218c2ecf20Sopenharmony_ci		},
11228c2ecf20Sopenharmony_ci	},
11238c2ecf20Sopenharmony_ci	{
11248c2ecf20Sopenharmony_ci		.desc = {
11258c2ecf20Sopenharmony_ci			.name = "buck6",
11268c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("BUCK6"),
11278c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
11288c2ecf20Sopenharmony_ci			.id = BD718XX_BUCK6,
11298c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
11308c2ecf20Sopenharmony_ci			.n_voltages = BD71837_BUCK6_VOLTAGE_NUM,
11318c2ecf20Sopenharmony_ci			.linear_ranges = bd71837_buck6_volts,
11328c2ecf20Sopenharmony_ci			.n_linear_ranges =
11338c2ecf20Sopenharmony_ci				ARRAY_SIZE(bd71837_buck6_volts),
11348c2ecf20Sopenharmony_ci			.vsel_reg = BD718XX_REG_2ND_NODVS_BUCK_VOLT,
11358c2ecf20Sopenharmony_ci			.vsel_mask = BD71837_BUCK6_MASK,
11368c2ecf20Sopenharmony_ci			.enable_reg = BD718XX_REG_2ND_NODVS_BUCK_CTRL,
11378c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_BUCK_EN,
11388c2ecf20Sopenharmony_ci			.enable_time = BD71837_BUCK6_STARTUP_TIME,
11398c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
11408c2ecf20Sopenharmony_ci		},
11418c2ecf20Sopenharmony_ci		.init = {
11428c2ecf20Sopenharmony_ci			.reg = BD718XX_REG_2ND_NODVS_BUCK_CTRL,
11438c2ecf20Sopenharmony_ci			.mask = BD718XX_BUCK_SEL,
11448c2ecf20Sopenharmony_ci			.val = BD718XX_BUCK_SEL,
11458c2ecf20Sopenharmony_ci		},
11468c2ecf20Sopenharmony_ci	},
11478c2ecf20Sopenharmony_ci	{
11488c2ecf20Sopenharmony_ci		.desc = {
11498c2ecf20Sopenharmony_ci			.name = "buck7",
11508c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("BUCK7"),
11518c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
11528c2ecf20Sopenharmony_ci			.id = BD718XX_BUCK7,
11538c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
11548c2ecf20Sopenharmony_ci			.volt_table = &bd718xx_3rd_nodvs_buck_volts[0],
11558c2ecf20Sopenharmony_ci			.n_voltages = ARRAY_SIZE(bd718xx_3rd_nodvs_buck_volts),
11568c2ecf20Sopenharmony_ci			.vsel_reg = BD718XX_REG_3RD_NODVS_BUCK_VOLT,
11578c2ecf20Sopenharmony_ci			.vsel_mask = BD718XX_3RD_NODVS_BUCK_MASK,
11588c2ecf20Sopenharmony_ci			.enable_reg = BD718XX_REG_3RD_NODVS_BUCK_CTRL,
11598c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_BUCK_EN,
11608c2ecf20Sopenharmony_ci			.enable_time = BD71837_BUCK7_STARTUP_TIME,
11618c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
11628c2ecf20Sopenharmony_ci		},
11638c2ecf20Sopenharmony_ci		.init = {
11648c2ecf20Sopenharmony_ci			.reg = BD718XX_REG_3RD_NODVS_BUCK_CTRL,
11658c2ecf20Sopenharmony_ci			.mask = BD718XX_BUCK_SEL,
11668c2ecf20Sopenharmony_ci			.val = BD718XX_BUCK_SEL,
11678c2ecf20Sopenharmony_ci		},
11688c2ecf20Sopenharmony_ci	},
11698c2ecf20Sopenharmony_ci	{
11708c2ecf20Sopenharmony_ci		.desc = {
11718c2ecf20Sopenharmony_ci			.name = "buck8",
11728c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("BUCK8"),
11738c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
11748c2ecf20Sopenharmony_ci			.id = BD718XX_BUCK8,
11758c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
11768c2ecf20Sopenharmony_ci			.n_voltages = BD718XX_4TH_NODVS_BUCK_VOLTAGE_NUM,
11778c2ecf20Sopenharmony_ci			.linear_ranges = bd718xx_4th_nodvs_buck_volts,
11788c2ecf20Sopenharmony_ci			.n_linear_ranges =
11798c2ecf20Sopenharmony_ci				ARRAY_SIZE(bd718xx_4th_nodvs_buck_volts),
11808c2ecf20Sopenharmony_ci			.vsel_reg = BD718XX_REG_4TH_NODVS_BUCK_VOLT,
11818c2ecf20Sopenharmony_ci			.vsel_mask = BD718XX_4TH_NODVS_BUCK_MASK,
11828c2ecf20Sopenharmony_ci			.enable_reg = BD718XX_REG_4TH_NODVS_BUCK_CTRL,
11838c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_BUCK_EN,
11848c2ecf20Sopenharmony_ci			.enable_time = BD71837_BUCK8_STARTUP_TIME,
11858c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
11868c2ecf20Sopenharmony_ci		},
11878c2ecf20Sopenharmony_ci		.init = {
11888c2ecf20Sopenharmony_ci			.reg = BD718XX_REG_4TH_NODVS_BUCK_CTRL,
11898c2ecf20Sopenharmony_ci			.mask = BD718XX_BUCK_SEL,
11908c2ecf20Sopenharmony_ci			.val = BD718XX_BUCK_SEL,
11918c2ecf20Sopenharmony_ci		},
11928c2ecf20Sopenharmony_ci	},
11938c2ecf20Sopenharmony_ci	{
11948c2ecf20Sopenharmony_ci		.desc = {
11958c2ecf20Sopenharmony_ci			.name = "ldo1",
11968c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("LDO1"),
11978c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
11988c2ecf20Sopenharmony_ci			.id = BD718XX_LDO1,
11998c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
12008c2ecf20Sopenharmony_ci			.n_voltages = BD718XX_LDO1_VOLTAGE_NUM,
12018c2ecf20Sopenharmony_ci			.linear_ranges = bd718xx_ldo1_volts,
12028c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd718xx_ldo1_volts),
12038c2ecf20Sopenharmony_ci			.vsel_reg = BD718XX_REG_LDO1_VOLT,
12048c2ecf20Sopenharmony_ci			.vsel_mask = BD718XX_LDO1_MASK,
12058c2ecf20Sopenharmony_ci			.vsel_range_reg = BD718XX_REG_LDO1_VOLT,
12068c2ecf20Sopenharmony_ci			.vsel_range_mask = BD718XX_LDO1_RANGE_MASK,
12078c2ecf20Sopenharmony_ci			.linear_range_selectors = bd718xx_ldo1_volt_range_sel,
12088c2ecf20Sopenharmony_ci			.enable_reg = BD718XX_REG_LDO1_VOLT,
12098c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_LDO_EN,
12108c2ecf20Sopenharmony_ci			.enable_time = BD71837_LDO1_STARTUP_TIME,
12118c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
12128c2ecf20Sopenharmony_ci		},
12138c2ecf20Sopenharmony_ci		.init = {
12148c2ecf20Sopenharmony_ci			.reg = BD718XX_REG_LDO1_VOLT,
12158c2ecf20Sopenharmony_ci			.mask = BD718XX_LDO_SEL,
12168c2ecf20Sopenharmony_ci			.val = BD718XX_LDO_SEL,
12178c2ecf20Sopenharmony_ci		},
12188c2ecf20Sopenharmony_ci	},
12198c2ecf20Sopenharmony_ci	{
12208c2ecf20Sopenharmony_ci		.desc = {
12218c2ecf20Sopenharmony_ci			.name = "ldo2",
12228c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("LDO2"),
12238c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
12248c2ecf20Sopenharmony_ci			.id = BD718XX_LDO2,
12258c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
12268c2ecf20Sopenharmony_ci			.volt_table = &ldo_2_volts[0],
12278c2ecf20Sopenharmony_ci			.vsel_reg = BD718XX_REG_LDO2_VOLT,
12288c2ecf20Sopenharmony_ci			.vsel_mask = BD718XX_LDO2_MASK,
12298c2ecf20Sopenharmony_ci			.n_voltages = ARRAY_SIZE(ldo_2_volts),
12308c2ecf20Sopenharmony_ci			.enable_reg = BD718XX_REG_LDO2_VOLT,
12318c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_LDO_EN,
12328c2ecf20Sopenharmony_ci			.enable_time = BD71837_LDO2_STARTUP_TIME,
12338c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
12348c2ecf20Sopenharmony_ci		},
12358c2ecf20Sopenharmony_ci		.init = {
12368c2ecf20Sopenharmony_ci			.reg = BD718XX_REG_LDO2_VOLT,
12378c2ecf20Sopenharmony_ci			.mask = BD718XX_LDO_SEL,
12388c2ecf20Sopenharmony_ci			.val = BD718XX_LDO_SEL,
12398c2ecf20Sopenharmony_ci		},
12408c2ecf20Sopenharmony_ci	},
12418c2ecf20Sopenharmony_ci	{
12428c2ecf20Sopenharmony_ci		.desc = {
12438c2ecf20Sopenharmony_ci			.name = "ldo3",
12448c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("LDO3"),
12458c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
12468c2ecf20Sopenharmony_ci			.id = BD718XX_LDO3,
12478c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
12488c2ecf20Sopenharmony_ci			.n_voltages = BD718XX_LDO3_VOLTAGE_NUM,
12498c2ecf20Sopenharmony_ci			.linear_ranges = bd718xx_ldo3_volts,
12508c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd718xx_ldo3_volts),
12518c2ecf20Sopenharmony_ci			.vsel_reg = BD718XX_REG_LDO3_VOLT,
12528c2ecf20Sopenharmony_ci			.vsel_mask = BD718XX_LDO3_MASK,
12538c2ecf20Sopenharmony_ci			.enable_reg = BD718XX_REG_LDO3_VOLT,
12548c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_LDO_EN,
12558c2ecf20Sopenharmony_ci			.enable_time = BD71837_LDO3_STARTUP_TIME,
12568c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
12578c2ecf20Sopenharmony_ci		},
12588c2ecf20Sopenharmony_ci		.init = {
12598c2ecf20Sopenharmony_ci			.reg = BD718XX_REG_LDO3_VOLT,
12608c2ecf20Sopenharmony_ci			.mask = BD718XX_LDO_SEL,
12618c2ecf20Sopenharmony_ci			.val = BD718XX_LDO_SEL,
12628c2ecf20Sopenharmony_ci		},
12638c2ecf20Sopenharmony_ci	},
12648c2ecf20Sopenharmony_ci	{
12658c2ecf20Sopenharmony_ci		.desc = {
12668c2ecf20Sopenharmony_ci			.name = "ldo4",
12678c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("LDO4"),
12688c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
12698c2ecf20Sopenharmony_ci			.id = BD718XX_LDO4,
12708c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
12718c2ecf20Sopenharmony_ci			.n_voltages = BD718XX_LDO4_VOLTAGE_NUM,
12728c2ecf20Sopenharmony_ci			.linear_ranges = bd718xx_ldo4_volts,
12738c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd718xx_ldo4_volts),
12748c2ecf20Sopenharmony_ci			.vsel_reg = BD718XX_REG_LDO4_VOLT,
12758c2ecf20Sopenharmony_ci			.vsel_mask = BD718XX_LDO4_MASK,
12768c2ecf20Sopenharmony_ci			.enable_reg = BD718XX_REG_LDO4_VOLT,
12778c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_LDO_EN,
12788c2ecf20Sopenharmony_ci			.enable_time = BD71837_LDO4_STARTUP_TIME,
12798c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
12808c2ecf20Sopenharmony_ci		},
12818c2ecf20Sopenharmony_ci		.init = {
12828c2ecf20Sopenharmony_ci			.reg = BD718XX_REG_LDO4_VOLT,
12838c2ecf20Sopenharmony_ci			.mask = BD718XX_LDO_SEL,
12848c2ecf20Sopenharmony_ci			.val = BD718XX_LDO_SEL,
12858c2ecf20Sopenharmony_ci		},
12868c2ecf20Sopenharmony_ci	},
12878c2ecf20Sopenharmony_ci	{
12888c2ecf20Sopenharmony_ci		.desc = {
12898c2ecf20Sopenharmony_ci			.name = "ldo5",
12908c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("LDO5"),
12918c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
12928c2ecf20Sopenharmony_ci			.id = BD718XX_LDO5,
12938c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
12948c2ecf20Sopenharmony_ci			.n_voltages = BD71837_LDO5_VOLTAGE_NUM,
12958c2ecf20Sopenharmony_ci			.linear_ranges = bd71837_ldo5_volts,
12968c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd71837_ldo5_volts),
12978c2ecf20Sopenharmony_ci			/* LDO5 is supplied by buck6 */
12988c2ecf20Sopenharmony_ci			.supply_name = "buck6",
12998c2ecf20Sopenharmony_ci			.vsel_reg = BD718XX_REG_LDO5_VOLT,
13008c2ecf20Sopenharmony_ci			.vsel_mask = BD71837_LDO5_MASK,
13018c2ecf20Sopenharmony_ci			.enable_reg = BD718XX_REG_LDO5_VOLT,
13028c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_LDO_EN,
13038c2ecf20Sopenharmony_ci			.enable_time = BD71837_LDO5_STARTUP_TIME,
13048c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
13058c2ecf20Sopenharmony_ci		},
13068c2ecf20Sopenharmony_ci		.init = {
13078c2ecf20Sopenharmony_ci			.reg = BD718XX_REG_LDO5_VOLT,
13088c2ecf20Sopenharmony_ci			.mask = BD718XX_LDO_SEL,
13098c2ecf20Sopenharmony_ci			.val = BD718XX_LDO_SEL,
13108c2ecf20Sopenharmony_ci		},
13118c2ecf20Sopenharmony_ci		.additional_inits = bd71837_ldo5_inits,
13128c2ecf20Sopenharmony_ci		.additional_init_amnt = ARRAY_SIZE(bd71837_ldo5_inits),
13138c2ecf20Sopenharmony_ci	},
13148c2ecf20Sopenharmony_ci	{
13158c2ecf20Sopenharmony_ci		.desc = {
13168c2ecf20Sopenharmony_ci			.name = "ldo6",
13178c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("LDO6"),
13188c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
13198c2ecf20Sopenharmony_ci			.id = BD718XX_LDO6,
13208c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
13218c2ecf20Sopenharmony_ci			.n_voltages = BD718XX_LDO6_VOLTAGE_NUM,
13228c2ecf20Sopenharmony_ci			.linear_ranges = bd718xx_ldo6_volts,
13238c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd718xx_ldo6_volts),
13248c2ecf20Sopenharmony_ci			/* LDO6 is supplied by buck7 */
13258c2ecf20Sopenharmony_ci			.supply_name = "buck7",
13268c2ecf20Sopenharmony_ci			.vsel_reg = BD718XX_REG_LDO6_VOLT,
13278c2ecf20Sopenharmony_ci			.vsel_mask = BD718XX_LDO6_MASK,
13288c2ecf20Sopenharmony_ci			.enable_reg = BD718XX_REG_LDO6_VOLT,
13298c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_LDO_EN,
13308c2ecf20Sopenharmony_ci			.enable_time = BD71837_LDO6_STARTUP_TIME,
13318c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
13328c2ecf20Sopenharmony_ci		},
13338c2ecf20Sopenharmony_ci		.init = {
13348c2ecf20Sopenharmony_ci			.reg = BD718XX_REG_LDO6_VOLT,
13358c2ecf20Sopenharmony_ci			.mask = BD718XX_LDO_SEL,
13368c2ecf20Sopenharmony_ci			.val = BD718XX_LDO_SEL,
13378c2ecf20Sopenharmony_ci		},
13388c2ecf20Sopenharmony_ci		.additional_inits = bd71837_ldo6_inits,
13398c2ecf20Sopenharmony_ci		.additional_init_amnt = ARRAY_SIZE(bd71837_ldo6_inits),
13408c2ecf20Sopenharmony_ci	},
13418c2ecf20Sopenharmony_ci	{
13428c2ecf20Sopenharmony_ci		.desc = {
13438c2ecf20Sopenharmony_ci			.name = "ldo7",
13448c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("LDO7"),
13458c2ecf20Sopenharmony_ci			.regulators_node = of_match_ptr("regulators"),
13468c2ecf20Sopenharmony_ci			.id = BD718XX_LDO7,
13478c2ecf20Sopenharmony_ci			.type = REGULATOR_VOLTAGE,
13488c2ecf20Sopenharmony_ci			.n_voltages = BD71837_LDO7_VOLTAGE_NUM,
13498c2ecf20Sopenharmony_ci			.linear_ranges = bd71837_ldo7_volts,
13508c2ecf20Sopenharmony_ci			.n_linear_ranges = ARRAY_SIZE(bd71837_ldo7_volts),
13518c2ecf20Sopenharmony_ci			.vsel_reg = BD71837_REG_LDO7_VOLT,
13528c2ecf20Sopenharmony_ci			.vsel_mask = BD71837_LDO7_MASK,
13538c2ecf20Sopenharmony_ci			.enable_reg = BD71837_REG_LDO7_VOLT,
13548c2ecf20Sopenharmony_ci			.enable_mask = BD718XX_LDO_EN,
13558c2ecf20Sopenharmony_ci			.enable_time = BD71837_LDO7_STARTUP_TIME,
13568c2ecf20Sopenharmony_ci			.owner = THIS_MODULE,
13578c2ecf20Sopenharmony_ci		},
13588c2ecf20Sopenharmony_ci		.init = {
13598c2ecf20Sopenharmony_ci			.reg = BD71837_REG_LDO7_VOLT,
13608c2ecf20Sopenharmony_ci			.mask = BD718XX_LDO_SEL,
13618c2ecf20Sopenharmony_ci			.val = BD718XX_LDO_SEL,
13628c2ecf20Sopenharmony_ci		},
13638c2ecf20Sopenharmony_ci	},
13648c2ecf20Sopenharmony_ci};
13658c2ecf20Sopenharmony_ci
13668c2ecf20Sopenharmony_cistatic void mark_hw_controlled(struct device *dev, struct device_node *np,
13678c2ecf20Sopenharmony_ci			       struct bd718xx_regulator_data *reg_data,
13688c2ecf20Sopenharmony_ci			       unsigned int num_reg_data, int *info)
13698c2ecf20Sopenharmony_ci{
13708c2ecf20Sopenharmony_ci	int i;
13718c2ecf20Sopenharmony_ci
13728c2ecf20Sopenharmony_ci	for (i = 1; i <= num_reg_data; i++) {
13738c2ecf20Sopenharmony_ci		if (!of_node_name_eq(np, reg_data[i-1].desc.of_match))
13748c2ecf20Sopenharmony_ci			continue;
13758c2ecf20Sopenharmony_ci
13768c2ecf20Sopenharmony_ci		*info |= 1 << (i - 1);
13778c2ecf20Sopenharmony_ci		dev_dbg(dev, "regulator %d runlevel controlled\n", i);
13788c2ecf20Sopenharmony_ci		return;
13798c2ecf20Sopenharmony_ci	}
13808c2ecf20Sopenharmony_ci	dev_warn(dev, "Bad regulator node\n");
13818c2ecf20Sopenharmony_ci}
13828c2ecf20Sopenharmony_ci
13838c2ecf20Sopenharmony_cistatic int get_hw_controlled_regulators(struct device *dev,
13848c2ecf20Sopenharmony_ci					struct bd718xx_regulator_data *reg_data,
13858c2ecf20Sopenharmony_ci					unsigned int num_reg_data, int *info)
13868c2ecf20Sopenharmony_ci{
13878c2ecf20Sopenharmony_ci	struct device_node *np;
13888c2ecf20Sopenharmony_ci	struct device_node *nproot = dev->of_node;
13898c2ecf20Sopenharmony_ci	const char *prop = "rohm,no-regulator-enable-control";
13908c2ecf20Sopenharmony_ci
13918c2ecf20Sopenharmony_ci	*info = 0;
13928c2ecf20Sopenharmony_ci
13938c2ecf20Sopenharmony_ci	nproot = of_get_child_by_name(nproot, "regulators");
13948c2ecf20Sopenharmony_ci	if (!nproot) {
13958c2ecf20Sopenharmony_ci		dev_err(dev, "failed to find regulators node\n");
13968c2ecf20Sopenharmony_ci		return -ENODEV;
13978c2ecf20Sopenharmony_ci	}
13988c2ecf20Sopenharmony_ci	for_each_child_of_node(nproot, np)
13998c2ecf20Sopenharmony_ci		if (of_property_read_bool(np, prop))
14008c2ecf20Sopenharmony_ci			mark_hw_controlled(dev, np, reg_data, num_reg_data,
14018c2ecf20Sopenharmony_ci					   info);
14028c2ecf20Sopenharmony_ci
14038c2ecf20Sopenharmony_ci	of_node_put(nproot);
14048c2ecf20Sopenharmony_ci	return 0;
14058c2ecf20Sopenharmony_ci}
14068c2ecf20Sopenharmony_ci
14078c2ecf20Sopenharmony_cistatic int bd718xx_probe(struct platform_device *pdev)
14088c2ecf20Sopenharmony_ci{
14098c2ecf20Sopenharmony_ci	struct bd718xx *mfd;
14108c2ecf20Sopenharmony_ci	struct regulator_config config = { 0 };
14118c2ecf20Sopenharmony_ci	int i, j, err, omit_enable;
14128c2ecf20Sopenharmony_ci	bool use_snvs;
14138c2ecf20Sopenharmony_ci	struct bd718xx_regulator_data *reg_data;
14148c2ecf20Sopenharmony_ci	unsigned int num_reg_data;
14158c2ecf20Sopenharmony_ci	enum rohm_chip_type chip = platform_get_device_id(pdev)->driver_data;
14168c2ecf20Sopenharmony_ci	const struct regulator_ops **swops, **hwops;
14178c2ecf20Sopenharmony_ci
14188c2ecf20Sopenharmony_ci	mfd = dev_get_drvdata(pdev->dev.parent);
14198c2ecf20Sopenharmony_ci	if (!mfd) {
14208c2ecf20Sopenharmony_ci		dev_err(&pdev->dev, "No MFD driver data\n");
14218c2ecf20Sopenharmony_ci		err = -EINVAL;
14228c2ecf20Sopenharmony_ci		goto err;
14238c2ecf20Sopenharmony_ci	}
14248c2ecf20Sopenharmony_ci
14258c2ecf20Sopenharmony_ci	switch (chip) {
14268c2ecf20Sopenharmony_ci	case ROHM_CHIP_TYPE_BD71837:
14278c2ecf20Sopenharmony_ci		reg_data = bd71837_regulators;
14288c2ecf20Sopenharmony_ci		num_reg_data = ARRAY_SIZE(bd71837_regulators);
14298c2ecf20Sopenharmony_ci		swops = &bd71837_swcontrol_ops[0];
14308c2ecf20Sopenharmony_ci		hwops = &bd71837_hwcontrol_ops[0];
14318c2ecf20Sopenharmony_ci		break;
14328c2ecf20Sopenharmony_ci	case ROHM_CHIP_TYPE_BD71847:
14338c2ecf20Sopenharmony_ci		reg_data = bd71847_regulators;
14348c2ecf20Sopenharmony_ci		num_reg_data = ARRAY_SIZE(bd71847_regulators);
14358c2ecf20Sopenharmony_ci		swops = &bd71847_swcontrol_ops[0];
14368c2ecf20Sopenharmony_ci		hwops = &bd71847_hwcontrol_ops[0];
14378c2ecf20Sopenharmony_ci		break;
14388c2ecf20Sopenharmony_ci	default:
14398c2ecf20Sopenharmony_ci		dev_err(&pdev->dev, "Unsupported chip type\n");
14408c2ecf20Sopenharmony_ci		err = -EINVAL;
14418c2ecf20Sopenharmony_ci		goto err;
14428c2ecf20Sopenharmony_ci	}
14438c2ecf20Sopenharmony_ci
14448c2ecf20Sopenharmony_ci	/* Register LOCK release */
14458c2ecf20Sopenharmony_ci	err = regmap_update_bits(mfd->chip.regmap, BD718XX_REG_REGLOCK,
14468c2ecf20Sopenharmony_ci				 (REGLOCK_PWRSEQ | REGLOCK_VREG), 0);
14478c2ecf20Sopenharmony_ci	if (err) {
14488c2ecf20Sopenharmony_ci		dev_err(&pdev->dev, "Failed to unlock PMIC (%d)\n", err);
14498c2ecf20Sopenharmony_ci		goto err;
14508c2ecf20Sopenharmony_ci	} else {
14518c2ecf20Sopenharmony_ci		dev_dbg(&pdev->dev, "Unlocked lock register 0x%x\n",
14528c2ecf20Sopenharmony_ci			BD718XX_REG_REGLOCK);
14538c2ecf20Sopenharmony_ci	}
14548c2ecf20Sopenharmony_ci
14558c2ecf20Sopenharmony_ci	use_snvs = of_property_read_bool(pdev->dev.parent->of_node,
14568c2ecf20Sopenharmony_ci					 "rohm,reset-snvs-powered");
14578c2ecf20Sopenharmony_ci
14588c2ecf20Sopenharmony_ci	/*
14598c2ecf20Sopenharmony_ci	 * Change the next stage from poweroff to be READY instead of SNVS
14608c2ecf20Sopenharmony_ci	 * for all reset types because OTP loading at READY will clear SEL
14618c2ecf20Sopenharmony_ci	 * bit allowing HW defaults for power rails to be used
14628c2ecf20Sopenharmony_ci	 */
14638c2ecf20Sopenharmony_ci	if (!use_snvs) {
14648c2ecf20Sopenharmony_ci		err = regmap_update_bits(mfd->chip.regmap,
14658c2ecf20Sopenharmony_ci					 BD718XX_REG_TRANS_COND1,
14668c2ecf20Sopenharmony_ci					 BD718XX_ON_REQ_POWEROFF_MASK |
14678c2ecf20Sopenharmony_ci					 BD718XX_SWRESET_POWEROFF_MASK |
14688c2ecf20Sopenharmony_ci					 BD718XX_WDOG_POWEROFF_MASK |
14698c2ecf20Sopenharmony_ci					 BD718XX_KEY_L_POWEROFF_MASK,
14708c2ecf20Sopenharmony_ci					 BD718XX_POWOFF_TO_RDY);
14718c2ecf20Sopenharmony_ci		if (err) {
14728c2ecf20Sopenharmony_ci			dev_err(&pdev->dev, "Failed to change reset target\n");
14738c2ecf20Sopenharmony_ci			goto err;
14748c2ecf20Sopenharmony_ci		} else {
14758c2ecf20Sopenharmony_ci			dev_dbg(&pdev->dev,
14768c2ecf20Sopenharmony_ci				"Changed all resets from SVNS to READY\n");
14778c2ecf20Sopenharmony_ci		}
14788c2ecf20Sopenharmony_ci	}
14798c2ecf20Sopenharmony_ci
14808c2ecf20Sopenharmony_ci	config.dev = pdev->dev.parent;
14818c2ecf20Sopenharmony_ci	config.regmap = mfd->chip.regmap;
14828c2ecf20Sopenharmony_ci	/*
14838c2ecf20Sopenharmony_ci	 * There are cases when we want to leave the enable-control for
14848c2ecf20Sopenharmony_ci	 * the HW state machine and use this driver only for voltage control.
14858c2ecf20Sopenharmony_ci	 * One special case is when we use PMIC_STBY_REQ line from SoC to PMIC
14868c2ecf20Sopenharmony_ci	 * in order to set the system to SUSPEND state.
14878c2ecf20Sopenharmony_ci	 *
14888c2ecf20Sopenharmony_ci	 * If regulator is taken under SW control the regulator state will not
14898c2ecf20Sopenharmony_ci	 * be affected by PMIC state machine - Eg. regulator is likely to stay
14908c2ecf20Sopenharmony_ci	 * on even in SUSPEND
14918c2ecf20Sopenharmony_ci	 */
14928c2ecf20Sopenharmony_ci	get_hw_controlled_regulators(pdev->dev.parent, reg_data, num_reg_data,
14938c2ecf20Sopenharmony_ci				     &omit_enable);
14948c2ecf20Sopenharmony_ci
14958c2ecf20Sopenharmony_ci	for (i = 0; i < num_reg_data; i++) {
14968c2ecf20Sopenharmony_ci
14978c2ecf20Sopenharmony_ci		struct regulator_desc *desc;
14988c2ecf20Sopenharmony_ci		struct regulator_dev *rdev;
14998c2ecf20Sopenharmony_ci		struct bd718xx_regulator_data *r;
15008c2ecf20Sopenharmony_ci		int no_enable_control = omit_enable & (1 << i);
15018c2ecf20Sopenharmony_ci
15028c2ecf20Sopenharmony_ci		r = &reg_data[i];
15038c2ecf20Sopenharmony_ci		desc = &r->desc;
15048c2ecf20Sopenharmony_ci
15058c2ecf20Sopenharmony_ci		if (no_enable_control)
15068c2ecf20Sopenharmony_ci			desc->ops = hwops[i];
15078c2ecf20Sopenharmony_ci		else
15088c2ecf20Sopenharmony_ci			desc->ops = swops[i];
15098c2ecf20Sopenharmony_ci
15108c2ecf20Sopenharmony_ci		rdev = devm_regulator_register(&pdev->dev, desc, &config);
15118c2ecf20Sopenharmony_ci		if (IS_ERR(rdev)) {
15128c2ecf20Sopenharmony_ci			dev_err(&pdev->dev,
15138c2ecf20Sopenharmony_ci				"failed to register %s regulator\n",
15148c2ecf20Sopenharmony_ci				desc->name);
15158c2ecf20Sopenharmony_ci			err = PTR_ERR(rdev);
15168c2ecf20Sopenharmony_ci			goto err;
15178c2ecf20Sopenharmony_ci		}
15188c2ecf20Sopenharmony_ci
15198c2ecf20Sopenharmony_ci		/*
15208c2ecf20Sopenharmony_ci		 * Regulator register gets the regulator constraints and
15218c2ecf20Sopenharmony_ci		 * applies them (set_machine_constraints). This should have
15228c2ecf20Sopenharmony_ci		 * turned the control register(s) to correct values and we
15238c2ecf20Sopenharmony_ci		 * can now switch the control from PMIC state machine to the
15248c2ecf20Sopenharmony_ci		 * register interface
15258c2ecf20Sopenharmony_ci		 *
15268c2ecf20Sopenharmony_ci		 * At poweroff transition PMIC HW disables EN bit for
15278c2ecf20Sopenharmony_ci		 * regulators but leaves SEL bit untouched. So if state
15288c2ecf20Sopenharmony_ci		 * transition from POWEROFF is done to SNVS - then all power
15298c2ecf20Sopenharmony_ci		 * rails controlled by SW (having SEL bit set) stay disabled
15308c2ecf20Sopenharmony_ci		 * as EN is cleared. This will result boot failure if any
15318c2ecf20Sopenharmony_ci		 * crucial systems are powered by these rails. We don't
15328c2ecf20Sopenharmony_ci		 * enable SW control for crucial regulators if snvs state is
15338c2ecf20Sopenharmony_ci		 * used
15348c2ecf20Sopenharmony_ci		 */
15358c2ecf20Sopenharmony_ci		if (!no_enable_control && (!use_snvs ||
15368c2ecf20Sopenharmony_ci		    !rdev->constraints->always_on ||
15378c2ecf20Sopenharmony_ci		    !rdev->constraints->boot_on)) {
15388c2ecf20Sopenharmony_ci			err = regmap_update_bits(mfd->chip.regmap, r->init.reg,
15398c2ecf20Sopenharmony_ci						 r->init.mask, r->init.val);
15408c2ecf20Sopenharmony_ci			if (err) {
15418c2ecf20Sopenharmony_ci				dev_err(&pdev->dev,
15428c2ecf20Sopenharmony_ci					"Failed to take control for (%s)\n",
15438c2ecf20Sopenharmony_ci					desc->name);
15448c2ecf20Sopenharmony_ci				goto err;
15458c2ecf20Sopenharmony_ci			}
15468c2ecf20Sopenharmony_ci		}
15478c2ecf20Sopenharmony_ci		for (j = 0; j < r->additional_init_amnt; j++) {
15488c2ecf20Sopenharmony_ci			err = regmap_update_bits(mfd->chip.regmap,
15498c2ecf20Sopenharmony_ci						 r->additional_inits[j].reg,
15508c2ecf20Sopenharmony_ci						 r->additional_inits[j].mask,
15518c2ecf20Sopenharmony_ci						 r->additional_inits[j].val);
15528c2ecf20Sopenharmony_ci			if (err) {
15538c2ecf20Sopenharmony_ci				dev_err(&pdev->dev,
15548c2ecf20Sopenharmony_ci					"Buck (%s) initialization failed\n",
15558c2ecf20Sopenharmony_ci					desc->name);
15568c2ecf20Sopenharmony_ci				goto err;
15578c2ecf20Sopenharmony_ci			}
15588c2ecf20Sopenharmony_ci		}
15598c2ecf20Sopenharmony_ci	}
15608c2ecf20Sopenharmony_ci
15618c2ecf20Sopenharmony_cierr:
15628c2ecf20Sopenharmony_ci	return err;
15638c2ecf20Sopenharmony_ci}
15648c2ecf20Sopenharmony_ci
15658c2ecf20Sopenharmony_cistatic const struct platform_device_id bd718x7_pmic_id[] = {
15668c2ecf20Sopenharmony_ci	{ "bd71837-pmic", ROHM_CHIP_TYPE_BD71837 },
15678c2ecf20Sopenharmony_ci	{ "bd71847-pmic", ROHM_CHIP_TYPE_BD71847 },
15688c2ecf20Sopenharmony_ci	{ },
15698c2ecf20Sopenharmony_ci};
15708c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(platform, bd718x7_pmic_id);
15718c2ecf20Sopenharmony_ci
15728c2ecf20Sopenharmony_cistatic struct platform_driver bd718xx_regulator = {
15738c2ecf20Sopenharmony_ci	.driver = {
15748c2ecf20Sopenharmony_ci		.name = "bd718xx-pmic",
15758c2ecf20Sopenharmony_ci	},
15768c2ecf20Sopenharmony_ci	.probe = bd718xx_probe,
15778c2ecf20Sopenharmony_ci	.id_table = bd718x7_pmic_id,
15788c2ecf20Sopenharmony_ci};
15798c2ecf20Sopenharmony_ci
15808c2ecf20Sopenharmony_cimodule_platform_driver(bd718xx_regulator);
15818c2ecf20Sopenharmony_ci
15828c2ecf20Sopenharmony_ciMODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>");
15838c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("BD71837/BD71847 voltage regulator driver");
15848c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL");
15858c2ecf20Sopenharmony_ciMODULE_ALIAS("platform:bd718xx-pmic");
1586