162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci// Copyright (C) STMicroelectronics 2018
362306a36Sopenharmony_ci// Author: Pascal Paillet <p.paillet@st.com> for STMicroelectronics.
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#include <linux/interrupt.h>
662306a36Sopenharmony_ci#include <linux/mfd/stpmic1.h>
762306a36Sopenharmony_ci#include <linux/module.h>
862306a36Sopenharmony_ci#include <linux/of_irq.h>
962306a36Sopenharmony_ci#include <linux/platform_device.h>
1062306a36Sopenharmony_ci#include <linux/regmap.h>
1162306a36Sopenharmony_ci#include <linux/regulator/driver.h>
1262306a36Sopenharmony_ci#include <linux/regulator/machine.h>
1362306a36Sopenharmony_ci#include <linux/regulator/of_regulator.h>
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#include <dt-bindings/mfd/st,stpmic1.h>
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci/**
1862306a36Sopenharmony_ci * struct stpmic1 regulator description: this structure is used as driver data
1962306a36Sopenharmony_ci * @desc: regulator framework description
2062306a36Sopenharmony_ci * @mask_reset_reg: mask reset register address
2162306a36Sopenharmony_ci * @mask_reset_mask: mask rank and mask reset register mask
2262306a36Sopenharmony_ci * @icc_reg: icc register address
2362306a36Sopenharmony_ci * @icc_mask: icc register mask
2462306a36Sopenharmony_ci */
2562306a36Sopenharmony_cistruct stpmic1_regulator_cfg {
2662306a36Sopenharmony_ci	struct regulator_desc desc;
2762306a36Sopenharmony_ci	u8 mask_reset_reg;
2862306a36Sopenharmony_ci	u8 mask_reset_mask;
2962306a36Sopenharmony_ci	u8 icc_reg;
3062306a36Sopenharmony_ci	u8 icc_mask;
3162306a36Sopenharmony_ci};
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_cistatic int stpmic1_set_mode(struct regulator_dev *rdev, unsigned int mode);
3462306a36Sopenharmony_cistatic unsigned int stpmic1_get_mode(struct regulator_dev *rdev);
3562306a36Sopenharmony_cistatic int stpmic1_set_icc(struct regulator_dev *rdev, int lim, int severity,
3662306a36Sopenharmony_ci			   bool enable);
3762306a36Sopenharmony_cistatic unsigned int stpmic1_map_mode(unsigned int mode);
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_cienum {
4062306a36Sopenharmony_ci	STPMIC1_BUCK1 = 0,
4162306a36Sopenharmony_ci	STPMIC1_BUCK2 = 1,
4262306a36Sopenharmony_ci	STPMIC1_BUCK3 = 2,
4362306a36Sopenharmony_ci	STPMIC1_BUCK4 = 3,
4462306a36Sopenharmony_ci	STPMIC1_LDO1 = 4,
4562306a36Sopenharmony_ci	STPMIC1_LDO2 = 5,
4662306a36Sopenharmony_ci	STPMIC1_LDO3 = 6,
4762306a36Sopenharmony_ci	STPMIC1_LDO4 = 7,
4862306a36Sopenharmony_ci	STPMIC1_LDO5 = 8,
4962306a36Sopenharmony_ci	STPMIC1_LDO6 = 9,
5062306a36Sopenharmony_ci	STPMIC1_VREF_DDR = 10,
5162306a36Sopenharmony_ci	STPMIC1_BOOST = 11,
5262306a36Sopenharmony_ci	STPMIC1_VBUS_OTG = 12,
5362306a36Sopenharmony_ci	STPMIC1_SW_OUT = 13,
5462306a36Sopenharmony_ci};
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci/* Enable time worst case is 5000mV/(2250uV/uS) */
5762306a36Sopenharmony_ci#define PMIC_ENABLE_TIME_US 2200
5862306a36Sopenharmony_ci/* Ramp delay worst case is (2250uV/uS) */
5962306a36Sopenharmony_ci#define PMIC_RAMP_DELAY 2200
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_cistatic const struct linear_range buck1_ranges[] = {
6262306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(725000, 0, 4, 0),
6362306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(725000, 5, 36, 25000),
6462306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1500000, 37, 63, 0),
6562306a36Sopenharmony_ci};
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_cistatic const struct linear_range buck2_ranges[] = {
6862306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1000000, 0, 17, 0),
6962306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1050000, 18, 19, 0),
7062306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1100000, 20, 21, 0),
7162306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1150000, 22, 23, 0),
7262306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1200000, 24, 25, 0),
7362306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1250000, 26, 27, 0),
7462306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1300000, 28, 29, 0),
7562306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1350000, 30, 31, 0),
7662306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1400000, 32, 33, 0),
7762306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1450000, 34, 35, 0),
7862306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1500000, 36, 63, 0),
7962306a36Sopenharmony_ci};
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_cistatic const struct linear_range buck3_ranges[] = {
8262306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1000000, 0, 19, 0),
8362306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1100000, 20, 23, 0),
8462306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1200000, 24, 27, 0),
8562306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1300000, 28, 31, 0),
8662306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1400000, 32, 35, 0),
8762306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1500000, 36, 55, 100000),
8862306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(3400000, 56, 63, 0),
8962306a36Sopenharmony_ci};
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_cistatic const struct linear_range buck4_ranges[] = {
9262306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(600000, 0, 27, 25000),
9362306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1300000, 28, 29, 0),
9462306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1350000, 30, 31, 0),
9562306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1400000, 32, 33, 0),
9662306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1450000, 34, 35, 0),
9762306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1500000, 36, 60, 100000),
9862306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(3900000, 61, 63, 0),
9962306a36Sopenharmony_ci};
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_cistatic const struct linear_range ldo1_ranges[] = {
10262306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1700000, 0, 7, 0),
10362306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1700000, 8, 24, 100000),
10462306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(3300000, 25, 31, 0),
10562306a36Sopenharmony_ci};
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_cistatic const struct linear_range ldo2_ranges[] = {
10862306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1700000, 0, 7, 0),
10962306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1700000, 8, 24, 100000),
11062306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(3300000, 25, 30, 0),
11162306a36Sopenharmony_ci};
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_cistatic const struct linear_range ldo3_ranges[] = {
11462306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1700000, 0, 7, 0),
11562306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1700000, 8, 24, 100000),
11662306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(3300000, 25, 30, 0),
11762306a36Sopenharmony_ci	/* with index 31 LDO3 is in DDR mode */
11862306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(500000, 31, 31, 0),
11962306a36Sopenharmony_ci};
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_cistatic const struct linear_range ldo5_ranges[] = {
12262306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1700000, 0, 7, 0),
12362306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(1700000, 8, 30, 100000),
12462306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(3900000, 31, 31, 0),
12562306a36Sopenharmony_ci};
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_cistatic const struct linear_range ldo6_ranges[] = {
12862306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(900000, 0, 24, 100000),
12962306a36Sopenharmony_ci	REGULATOR_LINEAR_RANGE(3300000, 25, 31, 0),
13062306a36Sopenharmony_ci};
13162306a36Sopenharmony_ci
13262306a36Sopenharmony_cistatic const struct regulator_ops stpmic1_ldo_ops = {
13362306a36Sopenharmony_ci	.list_voltage = regulator_list_voltage_linear_range,
13462306a36Sopenharmony_ci	.map_voltage = regulator_map_voltage_linear_range,
13562306a36Sopenharmony_ci	.is_enabled = regulator_is_enabled_regmap,
13662306a36Sopenharmony_ci	.enable = regulator_enable_regmap,
13762306a36Sopenharmony_ci	.disable = regulator_disable_regmap,
13862306a36Sopenharmony_ci	.get_voltage_sel = regulator_get_voltage_sel_regmap,
13962306a36Sopenharmony_ci	.set_voltage_sel = regulator_set_voltage_sel_regmap,
14062306a36Sopenharmony_ci	.set_over_current_protection = stpmic1_set_icc,
14162306a36Sopenharmony_ci};
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_cistatic const struct regulator_ops stpmic1_ldo3_ops = {
14462306a36Sopenharmony_ci	.list_voltage = regulator_list_voltage_linear_range,
14562306a36Sopenharmony_ci	.map_voltage = regulator_map_voltage_iterate,
14662306a36Sopenharmony_ci	.is_enabled = regulator_is_enabled_regmap,
14762306a36Sopenharmony_ci	.enable = regulator_enable_regmap,
14862306a36Sopenharmony_ci	.disable = regulator_disable_regmap,
14962306a36Sopenharmony_ci	.get_voltage_sel = regulator_get_voltage_sel_regmap,
15062306a36Sopenharmony_ci	.set_voltage_sel = regulator_set_voltage_sel_regmap,
15162306a36Sopenharmony_ci	.get_bypass = regulator_get_bypass_regmap,
15262306a36Sopenharmony_ci	.set_bypass = regulator_set_bypass_regmap,
15362306a36Sopenharmony_ci	.set_over_current_protection = stpmic1_set_icc,
15462306a36Sopenharmony_ci};
15562306a36Sopenharmony_ci
15662306a36Sopenharmony_cistatic const struct regulator_ops stpmic1_ldo4_fixed_regul_ops = {
15762306a36Sopenharmony_ci	.is_enabled = regulator_is_enabled_regmap,
15862306a36Sopenharmony_ci	.enable = regulator_enable_regmap,
15962306a36Sopenharmony_ci	.disable = regulator_disable_regmap,
16062306a36Sopenharmony_ci	.set_over_current_protection = stpmic1_set_icc,
16162306a36Sopenharmony_ci};
16262306a36Sopenharmony_ci
16362306a36Sopenharmony_cistatic const struct regulator_ops stpmic1_buck_ops = {
16462306a36Sopenharmony_ci	.list_voltage = regulator_list_voltage_linear_range,
16562306a36Sopenharmony_ci	.map_voltage = regulator_map_voltage_linear_range,
16662306a36Sopenharmony_ci	.is_enabled = regulator_is_enabled_regmap,
16762306a36Sopenharmony_ci	.enable = regulator_enable_regmap,
16862306a36Sopenharmony_ci	.disable = regulator_disable_regmap,
16962306a36Sopenharmony_ci	.get_voltage_sel = regulator_get_voltage_sel_regmap,
17062306a36Sopenharmony_ci	.set_voltage_sel = regulator_set_voltage_sel_regmap,
17162306a36Sopenharmony_ci	.set_pull_down = regulator_set_pull_down_regmap,
17262306a36Sopenharmony_ci	.set_mode = stpmic1_set_mode,
17362306a36Sopenharmony_ci	.get_mode = stpmic1_get_mode,
17462306a36Sopenharmony_ci	.set_over_current_protection = stpmic1_set_icc,
17562306a36Sopenharmony_ci};
17662306a36Sopenharmony_ci
17762306a36Sopenharmony_cistatic const struct regulator_ops stpmic1_vref_ddr_ops = {
17862306a36Sopenharmony_ci	.is_enabled = regulator_is_enabled_regmap,
17962306a36Sopenharmony_ci	.enable = regulator_enable_regmap,
18062306a36Sopenharmony_ci	.disable = regulator_disable_regmap,
18162306a36Sopenharmony_ci};
18262306a36Sopenharmony_ci
18362306a36Sopenharmony_cistatic const struct regulator_ops stpmic1_boost_regul_ops = {
18462306a36Sopenharmony_ci	.is_enabled = regulator_is_enabled_regmap,
18562306a36Sopenharmony_ci	.enable = regulator_enable_regmap,
18662306a36Sopenharmony_ci	.disable = regulator_disable_regmap,
18762306a36Sopenharmony_ci	.set_over_current_protection = stpmic1_set_icc,
18862306a36Sopenharmony_ci};
18962306a36Sopenharmony_ci
19062306a36Sopenharmony_cistatic const struct regulator_ops stpmic1_switch_regul_ops = {
19162306a36Sopenharmony_ci	.is_enabled = regulator_is_enabled_regmap,
19262306a36Sopenharmony_ci	.enable = regulator_enable_regmap,
19362306a36Sopenharmony_ci	.disable = regulator_disable_regmap,
19462306a36Sopenharmony_ci	.set_over_current_protection = stpmic1_set_icc,
19562306a36Sopenharmony_ci	.set_active_discharge = regulator_set_active_discharge_regmap,
19662306a36Sopenharmony_ci};
19762306a36Sopenharmony_ci
19862306a36Sopenharmony_ci#define REG_LDO(ids, base) { \
19962306a36Sopenharmony_ci	.name = #ids, \
20062306a36Sopenharmony_ci	.id = STPMIC1_##ids, \
20162306a36Sopenharmony_ci	.n_voltages = 32, \
20262306a36Sopenharmony_ci	.ops = &stpmic1_ldo_ops, \
20362306a36Sopenharmony_ci	.linear_ranges = base ## _ranges, \
20462306a36Sopenharmony_ci	.n_linear_ranges = ARRAY_SIZE(base ## _ranges), \
20562306a36Sopenharmony_ci	.type = REGULATOR_VOLTAGE, \
20662306a36Sopenharmony_ci	.owner = THIS_MODULE, \
20762306a36Sopenharmony_ci	.vsel_reg = ids##_ACTIVE_CR, \
20862306a36Sopenharmony_ci	.vsel_mask = LDO_VOLTAGE_MASK, \
20962306a36Sopenharmony_ci	.enable_reg = ids##_ACTIVE_CR, \
21062306a36Sopenharmony_ci	.enable_mask = LDO_ENABLE_MASK, \
21162306a36Sopenharmony_ci	.enable_val = 1, \
21262306a36Sopenharmony_ci	.disable_val = 0, \
21362306a36Sopenharmony_ci	.enable_time = PMIC_ENABLE_TIME_US, \
21462306a36Sopenharmony_ci	.ramp_delay = PMIC_RAMP_DELAY, \
21562306a36Sopenharmony_ci	.supply_name = #base, \
21662306a36Sopenharmony_ci}
21762306a36Sopenharmony_ci
21862306a36Sopenharmony_ci#define REG_LDO3(ids, base) { \
21962306a36Sopenharmony_ci	.name = #ids, \
22062306a36Sopenharmony_ci	.id = STPMIC1_##ids, \
22162306a36Sopenharmony_ci	.n_voltages = 32, \
22262306a36Sopenharmony_ci	.ops = &stpmic1_ldo3_ops, \
22362306a36Sopenharmony_ci	.linear_ranges = ldo3_ranges, \
22462306a36Sopenharmony_ci	.n_linear_ranges = ARRAY_SIZE(ldo3_ranges), \
22562306a36Sopenharmony_ci	.type = REGULATOR_VOLTAGE, \
22662306a36Sopenharmony_ci	.owner = THIS_MODULE, \
22762306a36Sopenharmony_ci	.vsel_reg = LDO3_ACTIVE_CR, \
22862306a36Sopenharmony_ci	.vsel_mask = LDO_VOLTAGE_MASK, \
22962306a36Sopenharmony_ci	.enable_reg = LDO3_ACTIVE_CR, \
23062306a36Sopenharmony_ci	.enable_mask = LDO_ENABLE_MASK, \
23162306a36Sopenharmony_ci	.enable_val = 1, \
23262306a36Sopenharmony_ci	.disable_val = 0, \
23362306a36Sopenharmony_ci	.enable_time = PMIC_ENABLE_TIME_US, \
23462306a36Sopenharmony_ci	.ramp_delay = PMIC_RAMP_DELAY, \
23562306a36Sopenharmony_ci	.bypass_reg = LDO3_ACTIVE_CR, \
23662306a36Sopenharmony_ci	.bypass_mask = LDO_BYPASS_MASK, \
23762306a36Sopenharmony_ci	.bypass_val_on = LDO_BYPASS_MASK, \
23862306a36Sopenharmony_ci	.bypass_val_off = 0, \
23962306a36Sopenharmony_ci	.supply_name = #base, \
24062306a36Sopenharmony_ci}
24162306a36Sopenharmony_ci
24262306a36Sopenharmony_ci#define REG_LDO4(ids, base) { \
24362306a36Sopenharmony_ci	.name = #ids, \
24462306a36Sopenharmony_ci	.id = STPMIC1_##ids, \
24562306a36Sopenharmony_ci	.n_voltages = 1, \
24662306a36Sopenharmony_ci	.ops = &stpmic1_ldo4_fixed_regul_ops, \
24762306a36Sopenharmony_ci	.type = REGULATOR_VOLTAGE, \
24862306a36Sopenharmony_ci	.owner = THIS_MODULE, \
24962306a36Sopenharmony_ci	.min_uV = 3300000, \
25062306a36Sopenharmony_ci	.fixed_uV = 3300000, \
25162306a36Sopenharmony_ci	.enable_reg = LDO4_ACTIVE_CR, \
25262306a36Sopenharmony_ci	.enable_mask = LDO_ENABLE_MASK, \
25362306a36Sopenharmony_ci	.enable_val = 1, \
25462306a36Sopenharmony_ci	.disable_val = 0, \
25562306a36Sopenharmony_ci	.enable_time = PMIC_ENABLE_TIME_US, \
25662306a36Sopenharmony_ci	.ramp_delay = PMIC_RAMP_DELAY, \
25762306a36Sopenharmony_ci	.supply_name = #base, \
25862306a36Sopenharmony_ci}
25962306a36Sopenharmony_ci
26062306a36Sopenharmony_ci#define REG_BUCK(ids, base) { \
26162306a36Sopenharmony_ci	.name = #ids, \
26262306a36Sopenharmony_ci	.id = STPMIC1_##ids, \
26362306a36Sopenharmony_ci	.ops = &stpmic1_buck_ops, \
26462306a36Sopenharmony_ci	.n_voltages = 64, \
26562306a36Sopenharmony_ci	.linear_ranges = base ## _ranges, \
26662306a36Sopenharmony_ci	.n_linear_ranges = ARRAY_SIZE(base ## _ranges), \
26762306a36Sopenharmony_ci	.type = REGULATOR_VOLTAGE, \
26862306a36Sopenharmony_ci	.owner = THIS_MODULE, \
26962306a36Sopenharmony_ci	.vsel_reg = ids##_ACTIVE_CR, \
27062306a36Sopenharmony_ci	.vsel_mask = BUCK_VOLTAGE_MASK, \
27162306a36Sopenharmony_ci	.enable_reg = ids##_ACTIVE_CR, \
27262306a36Sopenharmony_ci	.enable_mask = BUCK_ENABLE_MASK, \
27362306a36Sopenharmony_ci	.enable_val = 1, \
27462306a36Sopenharmony_ci	.disable_val = 0, \
27562306a36Sopenharmony_ci	.enable_time = PMIC_ENABLE_TIME_US, \
27662306a36Sopenharmony_ci	.ramp_delay = PMIC_RAMP_DELAY, \
27762306a36Sopenharmony_ci	.of_map_mode = stpmic1_map_mode, \
27862306a36Sopenharmony_ci	.pull_down_reg = ids##_PULL_DOWN_REG, \
27962306a36Sopenharmony_ci	.pull_down_mask = ids##_PULL_DOWN_MASK, \
28062306a36Sopenharmony_ci	.supply_name = #base, \
28162306a36Sopenharmony_ci}
28262306a36Sopenharmony_ci
28362306a36Sopenharmony_ci#define REG_VREF_DDR(ids, base) { \
28462306a36Sopenharmony_ci	.name = #ids, \
28562306a36Sopenharmony_ci	.id = STPMIC1_##ids, \
28662306a36Sopenharmony_ci	.n_voltages = 1, \
28762306a36Sopenharmony_ci	.ops = &stpmic1_vref_ddr_ops, \
28862306a36Sopenharmony_ci	.type = REGULATOR_VOLTAGE, \
28962306a36Sopenharmony_ci	.owner = THIS_MODULE, \
29062306a36Sopenharmony_ci	.min_uV = 500000, \
29162306a36Sopenharmony_ci	.fixed_uV = 500000, \
29262306a36Sopenharmony_ci	.enable_reg = VREF_DDR_ACTIVE_CR, \
29362306a36Sopenharmony_ci	.enable_mask = BUCK_ENABLE_MASK, \
29462306a36Sopenharmony_ci	.enable_val = 1, \
29562306a36Sopenharmony_ci	.disable_val = 0, \
29662306a36Sopenharmony_ci	.enable_time = PMIC_ENABLE_TIME_US, \
29762306a36Sopenharmony_ci	.supply_name = #base, \
29862306a36Sopenharmony_ci}
29962306a36Sopenharmony_ci
30062306a36Sopenharmony_ci#define REG_BOOST(ids, base) { \
30162306a36Sopenharmony_ci	.name = #ids, \
30262306a36Sopenharmony_ci	.id = STPMIC1_##ids, \
30362306a36Sopenharmony_ci	.n_voltages = 1, \
30462306a36Sopenharmony_ci	.ops = &stpmic1_boost_regul_ops, \
30562306a36Sopenharmony_ci	.type = REGULATOR_VOLTAGE, \
30662306a36Sopenharmony_ci	.owner = THIS_MODULE, \
30762306a36Sopenharmony_ci	.min_uV = 0, \
30862306a36Sopenharmony_ci	.fixed_uV = 5000000, \
30962306a36Sopenharmony_ci	.enable_reg = BST_SW_CR, \
31062306a36Sopenharmony_ci	.enable_mask = BOOST_ENABLED, \
31162306a36Sopenharmony_ci	.enable_val = BOOST_ENABLED, \
31262306a36Sopenharmony_ci	.disable_val = 0, \
31362306a36Sopenharmony_ci	.enable_time = PMIC_ENABLE_TIME_US, \
31462306a36Sopenharmony_ci	.supply_name = #base, \
31562306a36Sopenharmony_ci}
31662306a36Sopenharmony_ci
31762306a36Sopenharmony_ci#define REG_VBUS_OTG(ids, base) { \
31862306a36Sopenharmony_ci	.name = #ids, \
31962306a36Sopenharmony_ci	.id = STPMIC1_##ids, \
32062306a36Sopenharmony_ci	.n_voltages = 1, \
32162306a36Sopenharmony_ci	.ops = &stpmic1_switch_regul_ops, \
32262306a36Sopenharmony_ci	.type = REGULATOR_VOLTAGE, \
32362306a36Sopenharmony_ci	.owner = THIS_MODULE, \
32462306a36Sopenharmony_ci	.min_uV = 0, \
32562306a36Sopenharmony_ci	.fixed_uV = 5000000, \
32662306a36Sopenharmony_ci	.enable_reg = BST_SW_CR, \
32762306a36Sopenharmony_ci	.enable_mask = USBSW_OTG_SWITCH_ENABLED, \
32862306a36Sopenharmony_ci	.enable_val = USBSW_OTG_SWITCH_ENABLED, \
32962306a36Sopenharmony_ci	.disable_val = 0, \
33062306a36Sopenharmony_ci	.enable_time = PMIC_ENABLE_TIME_US, \
33162306a36Sopenharmony_ci	.supply_name = #base, \
33262306a36Sopenharmony_ci	.active_discharge_reg = BST_SW_CR, \
33362306a36Sopenharmony_ci	.active_discharge_mask = VBUS_OTG_DISCHARGE, \
33462306a36Sopenharmony_ci	.active_discharge_on = VBUS_OTG_DISCHARGE, \
33562306a36Sopenharmony_ci}
33662306a36Sopenharmony_ci
33762306a36Sopenharmony_ci#define REG_SW_OUT(ids, base) { \
33862306a36Sopenharmony_ci	.name = #ids, \
33962306a36Sopenharmony_ci	.id = STPMIC1_##ids, \
34062306a36Sopenharmony_ci	.n_voltages = 1, \
34162306a36Sopenharmony_ci	.ops = &stpmic1_switch_regul_ops, \
34262306a36Sopenharmony_ci	.type = REGULATOR_VOLTAGE, \
34362306a36Sopenharmony_ci	.owner = THIS_MODULE, \
34462306a36Sopenharmony_ci	.min_uV = 0, \
34562306a36Sopenharmony_ci	.fixed_uV = 5000000, \
34662306a36Sopenharmony_ci	.enable_reg = BST_SW_CR, \
34762306a36Sopenharmony_ci	.enable_mask = SWIN_SWOUT_ENABLED, \
34862306a36Sopenharmony_ci	.enable_val = SWIN_SWOUT_ENABLED, \
34962306a36Sopenharmony_ci	.disable_val = 0, \
35062306a36Sopenharmony_ci	.enable_time = PMIC_ENABLE_TIME_US, \
35162306a36Sopenharmony_ci	.supply_name = #base, \
35262306a36Sopenharmony_ci	.active_discharge_reg = BST_SW_CR, \
35362306a36Sopenharmony_ci	.active_discharge_mask = SW_OUT_DISCHARGE, \
35462306a36Sopenharmony_ci	.active_discharge_on = SW_OUT_DISCHARGE, \
35562306a36Sopenharmony_ci}
35662306a36Sopenharmony_ci
35762306a36Sopenharmony_cistatic const struct stpmic1_regulator_cfg stpmic1_regulator_cfgs[] = {
35862306a36Sopenharmony_ci	[STPMIC1_BUCK1] = {
35962306a36Sopenharmony_ci		.desc = REG_BUCK(BUCK1, buck1),
36062306a36Sopenharmony_ci		.icc_reg = BUCKS_ICCTO_CR,
36162306a36Sopenharmony_ci		.icc_mask = BIT(0),
36262306a36Sopenharmony_ci		.mask_reset_reg = BUCKS_MASK_RESET_CR,
36362306a36Sopenharmony_ci		.mask_reset_mask = BIT(0),
36462306a36Sopenharmony_ci	},
36562306a36Sopenharmony_ci	[STPMIC1_BUCK2] = {
36662306a36Sopenharmony_ci		.desc = REG_BUCK(BUCK2, buck2),
36762306a36Sopenharmony_ci		.icc_reg = BUCKS_ICCTO_CR,
36862306a36Sopenharmony_ci		.icc_mask = BIT(1),
36962306a36Sopenharmony_ci		.mask_reset_reg = BUCKS_MASK_RESET_CR,
37062306a36Sopenharmony_ci		.mask_reset_mask = BIT(1),
37162306a36Sopenharmony_ci	},
37262306a36Sopenharmony_ci	[STPMIC1_BUCK3] = {
37362306a36Sopenharmony_ci		.desc = REG_BUCK(BUCK3, buck3),
37462306a36Sopenharmony_ci		.icc_reg = BUCKS_ICCTO_CR,
37562306a36Sopenharmony_ci		.icc_mask = BIT(2),
37662306a36Sopenharmony_ci		.mask_reset_reg = BUCKS_MASK_RESET_CR,
37762306a36Sopenharmony_ci		.mask_reset_mask = BIT(2),
37862306a36Sopenharmony_ci	},
37962306a36Sopenharmony_ci	[STPMIC1_BUCK4] = {
38062306a36Sopenharmony_ci		.desc = REG_BUCK(BUCK4, buck4),
38162306a36Sopenharmony_ci		.icc_reg = BUCKS_ICCTO_CR,
38262306a36Sopenharmony_ci		.icc_mask = BIT(3),
38362306a36Sopenharmony_ci		.mask_reset_reg = BUCKS_MASK_RESET_CR,
38462306a36Sopenharmony_ci		.mask_reset_mask = BIT(3),
38562306a36Sopenharmony_ci	},
38662306a36Sopenharmony_ci	[STPMIC1_LDO1] = {
38762306a36Sopenharmony_ci		.desc = REG_LDO(LDO1, ldo1),
38862306a36Sopenharmony_ci		.icc_reg = LDOS_ICCTO_CR,
38962306a36Sopenharmony_ci		.icc_mask = BIT(0),
39062306a36Sopenharmony_ci		.mask_reset_reg = LDOS_MASK_RESET_CR,
39162306a36Sopenharmony_ci		.mask_reset_mask = BIT(0),
39262306a36Sopenharmony_ci	},
39362306a36Sopenharmony_ci	[STPMIC1_LDO2] = {
39462306a36Sopenharmony_ci		.desc = REG_LDO(LDO2, ldo2),
39562306a36Sopenharmony_ci		.icc_reg = LDOS_ICCTO_CR,
39662306a36Sopenharmony_ci		.icc_mask = BIT(1),
39762306a36Sopenharmony_ci		.mask_reset_reg = LDOS_MASK_RESET_CR,
39862306a36Sopenharmony_ci		.mask_reset_mask = BIT(1),
39962306a36Sopenharmony_ci	},
40062306a36Sopenharmony_ci	[STPMIC1_LDO3] = {
40162306a36Sopenharmony_ci		.desc = REG_LDO3(LDO3, ldo3),
40262306a36Sopenharmony_ci		.icc_reg = LDOS_ICCTO_CR,
40362306a36Sopenharmony_ci		.icc_mask = BIT(2),
40462306a36Sopenharmony_ci		.mask_reset_reg = LDOS_MASK_RESET_CR,
40562306a36Sopenharmony_ci		.mask_reset_mask = BIT(2),
40662306a36Sopenharmony_ci	},
40762306a36Sopenharmony_ci	[STPMIC1_LDO4] = {
40862306a36Sopenharmony_ci		.desc = REG_LDO4(LDO4, ldo4),
40962306a36Sopenharmony_ci		.icc_reg = LDOS_ICCTO_CR,
41062306a36Sopenharmony_ci		.icc_mask = BIT(3),
41162306a36Sopenharmony_ci		.mask_reset_reg = LDOS_MASK_RESET_CR,
41262306a36Sopenharmony_ci		.mask_reset_mask = BIT(3),
41362306a36Sopenharmony_ci	},
41462306a36Sopenharmony_ci	[STPMIC1_LDO5] = {
41562306a36Sopenharmony_ci		.desc = REG_LDO(LDO5, ldo5),
41662306a36Sopenharmony_ci		.icc_reg = LDOS_ICCTO_CR,
41762306a36Sopenharmony_ci		.icc_mask = BIT(4),
41862306a36Sopenharmony_ci		.mask_reset_reg = LDOS_MASK_RESET_CR,
41962306a36Sopenharmony_ci		.mask_reset_mask = BIT(4),
42062306a36Sopenharmony_ci	},
42162306a36Sopenharmony_ci	[STPMIC1_LDO6] = {
42262306a36Sopenharmony_ci		.desc = REG_LDO(LDO6, ldo6),
42362306a36Sopenharmony_ci		.icc_reg = LDOS_ICCTO_CR,
42462306a36Sopenharmony_ci		.icc_mask = BIT(5),
42562306a36Sopenharmony_ci		.mask_reset_reg = LDOS_MASK_RESET_CR,
42662306a36Sopenharmony_ci		.mask_reset_mask = BIT(5),
42762306a36Sopenharmony_ci	},
42862306a36Sopenharmony_ci	[STPMIC1_VREF_DDR] = {
42962306a36Sopenharmony_ci		.desc = REG_VREF_DDR(VREF_DDR, vref_ddr),
43062306a36Sopenharmony_ci		.mask_reset_reg = LDOS_MASK_RESET_CR,
43162306a36Sopenharmony_ci		.mask_reset_mask = BIT(6),
43262306a36Sopenharmony_ci	},
43362306a36Sopenharmony_ci	[STPMIC1_BOOST] = {
43462306a36Sopenharmony_ci		.desc = REG_BOOST(BOOST, boost),
43562306a36Sopenharmony_ci		.icc_reg = BUCKS_ICCTO_CR,
43662306a36Sopenharmony_ci		.icc_mask = BIT(6),
43762306a36Sopenharmony_ci	},
43862306a36Sopenharmony_ci	[STPMIC1_VBUS_OTG] = {
43962306a36Sopenharmony_ci		.desc = REG_VBUS_OTG(VBUS_OTG, pwr_sw1),
44062306a36Sopenharmony_ci		.icc_reg = BUCKS_ICCTO_CR,
44162306a36Sopenharmony_ci		.icc_mask = BIT(4),
44262306a36Sopenharmony_ci	},
44362306a36Sopenharmony_ci	[STPMIC1_SW_OUT] = {
44462306a36Sopenharmony_ci		.desc = REG_SW_OUT(SW_OUT, pwr_sw2),
44562306a36Sopenharmony_ci		.icc_reg = BUCKS_ICCTO_CR,
44662306a36Sopenharmony_ci		.icc_mask = BIT(5),
44762306a36Sopenharmony_ci	},
44862306a36Sopenharmony_ci};
44962306a36Sopenharmony_ci
45062306a36Sopenharmony_cistatic unsigned int stpmic1_map_mode(unsigned int mode)
45162306a36Sopenharmony_ci{
45262306a36Sopenharmony_ci	switch (mode) {
45362306a36Sopenharmony_ci	case STPMIC1_BUCK_MODE_NORMAL:
45462306a36Sopenharmony_ci		return REGULATOR_MODE_NORMAL;
45562306a36Sopenharmony_ci	case STPMIC1_BUCK_MODE_LP:
45662306a36Sopenharmony_ci		return REGULATOR_MODE_STANDBY;
45762306a36Sopenharmony_ci	default:
45862306a36Sopenharmony_ci		return REGULATOR_MODE_INVALID;
45962306a36Sopenharmony_ci	}
46062306a36Sopenharmony_ci}
46162306a36Sopenharmony_ci
46262306a36Sopenharmony_cistatic unsigned int stpmic1_get_mode(struct regulator_dev *rdev)
46362306a36Sopenharmony_ci{
46462306a36Sopenharmony_ci	int value;
46562306a36Sopenharmony_ci	struct regmap *regmap = rdev_get_regmap(rdev);
46662306a36Sopenharmony_ci
46762306a36Sopenharmony_ci	regmap_read(regmap, rdev->desc->enable_reg, &value);
46862306a36Sopenharmony_ci
46962306a36Sopenharmony_ci	if (value & STPMIC1_BUCK_MODE_LP)
47062306a36Sopenharmony_ci		return REGULATOR_MODE_STANDBY;
47162306a36Sopenharmony_ci
47262306a36Sopenharmony_ci	return REGULATOR_MODE_NORMAL;
47362306a36Sopenharmony_ci}
47462306a36Sopenharmony_ci
47562306a36Sopenharmony_cistatic int stpmic1_set_mode(struct regulator_dev *rdev, unsigned int mode)
47662306a36Sopenharmony_ci{
47762306a36Sopenharmony_ci	int value;
47862306a36Sopenharmony_ci	struct regmap *regmap = rdev_get_regmap(rdev);
47962306a36Sopenharmony_ci
48062306a36Sopenharmony_ci	switch (mode) {
48162306a36Sopenharmony_ci	case REGULATOR_MODE_NORMAL:
48262306a36Sopenharmony_ci		value = STPMIC1_BUCK_MODE_NORMAL;
48362306a36Sopenharmony_ci		break;
48462306a36Sopenharmony_ci	case REGULATOR_MODE_STANDBY:
48562306a36Sopenharmony_ci		value = STPMIC1_BUCK_MODE_LP;
48662306a36Sopenharmony_ci		break;
48762306a36Sopenharmony_ci	default:
48862306a36Sopenharmony_ci		return -EINVAL;
48962306a36Sopenharmony_ci	}
49062306a36Sopenharmony_ci
49162306a36Sopenharmony_ci	return regmap_update_bits(regmap, rdev->desc->enable_reg,
49262306a36Sopenharmony_ci				  STPMIC1_BUCK_MODE_LP, value);
49362306a36Sopenharmony_ci}
49462306a36Sopenharmony_ci
49562306a36Sopenharmony_cistatic int stpmic1_set_icc(struct regulator_dev *rdev, int lim, int severity,
49662306a36Sopenharmony_ci			   bool enable)
49762306a36Sopenharmony_ci{
49862306a36Sopenharmony_ci	struct stpmic1_regulator_cfg *cfg = rdev_get_drvdata(rdev);
49962306a36Sopenharmony_ci	struct regmap *regmap = rdev_get_regmap(rdev);
50062306a36Sopenharmony_ci
50162306a36Sopenharmony_ci	/*
50262306a36Sopenharmony_ci	 * The code seems like one bit in a register controls whether OCP is
50362306a36Sopenharmony_ci	 * enabled. So we might be able to turn it off here is if that
50462306a36Sopenharmony_ci	 * was requested. I won't support this because I don't have the HW.
50562306a36Sopenharmony_ci	 * Feel free to try and implement if you have the HW and need kernel
50662306a36Sopenharmony_ci	 * to disable this.
50762306a36Sopenharmony_ci	 *
50862306a36Sopenharmony_ci	 * Also, I don't know if limit can be configured or if we support
50962306a36Sopenharmony_ci	 * error/warning instead of protect. So I just keep existing logic
51062306a36Sopenharmony_ci	 * and assume no.
51162306a36Sopenharmony_ci	 */
51262306a36Sopenharmony_ci	if (lim || severity != REGULATOR_SEVERITY_PROT || !enable)
51362306a36Sopenharmony_ci		return -EINVAL;
51462306a36Sopenharmony_ci
51562306a36Sopenharmony_ci	/* enable switch off in case of over current */
51662306a36Sopenharmony_ci	return regmap_update_bits(regmap, cfg->icc_reg, cfg->icc_mask,
51762306a36Sopenharmony_ci				  cfg->icc_mask);
51862306a36Sopenharmony_ci}
51962306a36Sopenharmony_ci
52062306a36Sopenharmony_cistatic irqreturn_t stpmic1_curlim_irq_handler(int irq, void *data)
52162306a36Sopenharmony_ci{
52262306a36Sopenharmony_ci	struct regulator_dev *rdev = (struct regulator_dev *)data;
52362306a36Sopenharmony_ci
52462306a36Sopenharmony_ci	/* Send an overcurrent notification */
52562306a36Sopenharmony_ci	regulator_notifier_call_chain(rdev,
52662306a36Sopenharmony_ci				      REGULATOR_EVENT_OVER_CURRENT,
52762306a36Sopenharmony_ci				      NULL);
52862306a36Sopenharmony_ci
52962306a36Sopenharmony_ci	return IRQ_HANDLED;
53062306a36Sopenharmony_ci}
53162306a36Sopenharmony_ci
53262306a36Sopenharmony_ci#define MATCH(_name, _id) \
53362306a36Sopenharmony_ci	[STPMIC1_##_id] = { \
53462306a36Sopenharmony_ci		.name = #_name, \
53562306a36Sopenharmony_ci		.desc = &stpmic1_regulator_cfgs[STPMIC1_##_id].desc, \
53662306a36Sopenharmony_ci	}
53762306a36Sopenharmony_ci
53862306a36Sopenharmony_cistatic struct of_regulator_match stpmic1_matches[] = {
53962306a36Sopenharmony_ci	MATCH(buck1, BUCK1),
54062306a36Sopenharmony_ci	MATCH(buck2, BUCK2),
54162306a36Sopenharmony_ci	MATCH(buck3, BUCK3),
54262306a36Sopenharmony_ci	MATCH(buck4, BUCK4),
54362306a36Sopenharmony_ci	MATCH(ldo1, LDO1),
54462306a36Sopenharmony_ci	MATCH(ldo2, LDO2),
54562306a36Sopenharmony_ci	MATCH(ldo3, LDO3),
54662306a36Sopenharmony_ci	MATCH(ldo4, LDO4),
54762306a36Sopenharmony_ci	MATCH(ldo5, LDO5),
54862306a36Sopenharmony_ci	MATCH(ldo6, LDO6),
54962306a36Sopenharmony_ci	MATCH(vref_ddr, VREF_DDR),
55062306a36Sopenharmony_ci	MATCH(boost, BOOST),
55162306a36Sopenharmony_ci	MATCH(pwr_sw1, VBUS_OTG),
55262306a36Sopenharmony_ci	MATCH(pwr_sw2, SW_OUT),
55362306a36Sopenharmony_ci};
55462306a36Sopenharmony_ci
55562306a36Sopenharmony_cistatic int stpmic1_regulator_register(struct platform_device *pdev, int id,
55662306a36Sopenharmony_ci				      struct of_regulator_match *match,
55762306a36Sopenharmony_ci				      const struct stpmic1_regulator_cfg *cfg)
55862306a36Sopenharmony_ci{
55962306a36Sopenharmony_ci	struct stpmic1 *pmic_dev = dev_get_drvdata(pdev->dev.parent);
56062306a36Sopenharmony_ci	struct regulator_dev *rdev;
56162306a36Sopenharmony_ci	struct regulator_config config = {};
56262306a36Sopenharmony_ci	int ret = 0;
56362306a36Sopenharmony_ci	int irq;
56462306a36Sopenharmony_ci
56562306a36Sopenharmony_ci	config.dev = &pdev->dev;
56662306a36Sopenharmony_ci	config.init_data = match->init_data;
56762306a36Sopenharmony_ci	config.of_node = match->of_node;
56862306a36Sopenharmony_ci	config.regmap = pmic_dev->regmap;
56962306a36Sopenharmony_ci	config.driver_data = (void *)cfg;
57062306a36Sopenharmony_ci
57162306a36Sopenharmony_ci	rdev = devm_regulator_register(&pdev->dev, &cfg->desc, &config);
57262306a36Sopenharmony_ci	if (IS_ERR(rdev)) {
57362306a36Sopenharmony_ci		dev_err(&pdev->dev, "failed to register %s regulator\n",
57462306a36Sopenharmony_ci			cfg->desc.name);
57562306a36Sopenharmony_ci		return PTR_ERR(rdev);
57662306a36Sopenharmony_ci	}
57762306a36Sopenharmony_ci
57862306a36Sopenharmony_ci	/* set mask reset */
57962306a36Sopenharmony_ci	if (of_property_read_bool(config.of_node, "st,mask-reset") &&
58062306a36Sopenharmony_ci	    cfg->mask_reset_reg != 0) {
58162306a36Sopenharmony_ci		ret = regmap_update_bits(pmic_dev->regmap,
58262306a36Sopenharmony_ci					 cfg->mask_reset_reg,
58362306a36Sopenharmony_ci					 cfg->mask_reset_mask,
58462306a36Sopenharmony_ci					 cfg->mask_reset_mask);
58562306a36Sopenharmony_ci		if (ret) {
58662306a36Sopenharmony_ci			dev_err(&pdev->dev, "set mask reset failed\n");
58762306a36Sopenharmony_ci			return ret;
58862306a36Sopenharmony_ci		}
58962306a36Sopenharmony_ci	}
59062306a36Sopenharmony_ci
59162306a36Sopenharmony_ci	/* setup an irq handler for over-current detection */
59262306a36Sopenharmony_ci	irq = of_irq_get(config.of_node, 0);
59362306a36Sopenharmony_ci	if (irq > 0) {
59462306a36Sopenharmony_ci		ret = devm_request_threaded_irq(&pdev->dev,
59562306a36Sopenharmony_ci						irq, NULL,
59662306a36Sopenharmony_ci						stpmic1_curlim_irq_handler,
59762306a36Sopenharmony_ci						IRQF_ONESHOT | IRQF_SHARED,
59862306a36Sopenharmony_ci						pdev->name, rdev);
59962306a36Sopenharmony_ci		if (ret) {
60062306a36Sopenharmony_ci			dev_err(&pdev->dev, "Request IRQ failed\n");
60162306a36Sopenharmony_ci			return ret;
60262306a36Sopenharmony_ci		}
60362306a36Sopenharmony_ci	}
60462306a36Sopenharmony_ci	return 0;
60562306a36Sopenharmony_ci}
60662306a36Sopenharmony_ci
60762306a36Sopenharmony_cistatic int stpmic1_regulator_probe(struct platform_device *pdev)
60862306a36Sopenharmony_ci{
60962306a36Sopenharmony_ci	int i, ret;
61062306a36Sopenharmony_ci
61162306a36Sopenharmony_ci	ret = of_regulator_match(&pdev->dev, pdev->dev.of_node, stpmic1_matches,
61262306a36Sopenharmony_ci				 ARRAY_SIZE(stpmic1_matches));
61362306a36Sopenharmony_ci	if (ret < 0) {
61462306a36Sopenharmony_ci		dev_err(&pdev->dev,
61562306a36Sopenharmony_ci			"Error in PMIC regulator device tree node");
61662306a36Sopenharmony_ci		return ret;
61762306a36Sopenharmony_ci	}
61862306a36Sopenharmony_ci
61962306a36Sopenharmony_ci	for (i = 0; i < ARRAY_SIZE(stpmic1_regulator_cfgs); i++) {
62062306a36Sopenharmony_ci		ret = stpmic1_regulator_register(pdev, i, &stpmic1_matches[i],
62162306a36Sopenharmony_ci						 &stpmic1_regulator_cfgs[i]);
62262306a36Sopenharmony_ci		if (ret < 0)
62362306a36Sopenharmony_ci			return ret;
62462306a36Sopenharmony_ci	}
62562306a36Sopenharmony_ci
62662306a36Sopenharmony_ci	dev_dbg(&pdev->dev, "stpmic1_regulator driver probed\n");
62762306a36Sopenharmony_ci
62862306a36Sopenharmony_ci	return 0;
62962306a36Sopenharmony_ci}
63062306a36Sopenharmony_ci
63162306a36Sopenharmony_cistatic const struct of_device_id of_pmic_regulator_match[] = {
63262306a36Sopenharmony_ci	{ .compatible = "st,stpmic1-regulators" },
63362306a36Sopenharmony_ci	{ },
63462306a36Sopenharmony_ci};
63562306a36Sopenharmony_ci
63662306a36Sopenharmony_ciMODULE_DEVICE_TABLE(of, of_pmic_regulator_match);
63762306a36Sopenharmony_ci
63862306a36Sopenharmony_cistatic struct platform_driver stpmic1_regulator_driver = {
63962306a36Sopenharmony_ci	.driver = {
64062306a36Sopenharmony_ci		.name = "stpmic1-regulator",
64162306a36Sopenharmony_ci		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
64262306a36Sopenharmony_ci		.of_match_table = of_match_ptr(of_pmic_regulator_match),
64362306a36Sopenharmony_ci	},
64462306a36Sopenharmony_ci	.probe = stpmic1_regulator_probe,
64562306a36Sopenharmony_ci};
64662306a36Sopenharmony_ci
64762306a36Sopenharmony_cimodule_platform_driver(stpmic1_regulator_driver);
64862306a36Sopenharmony_ci
64962306a36Sopenharmony_ciMODULE_DESCRIPTION("STPMIC1 PMIC voltage regulator driver");
65062306a36Sopenharmony_ciMODULE_AUTHOR("Pascal Paillet <p.paillet@st.com>");
65162306a36Sopenharmony_ciMODULE_LICENSE("GPL v2");
652