summaryrefslogtreecommitdiff
path: root/drivers/regulator
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2023-09-26 13:57:13 +0200
committerMark Brown <broonie@kernel.org>2023-09-26 13:57:13 +0200
commit4a710a0b0c68d4bf48ed70083e5a28984e5994c2 (patch)
tree64d3f0d92a948d6eb460dbb348b4ccb088a6d721 /drivers/regulator
parent66af368359816d62cf91ed1b02fe99f9a4015f3a (diff)
parent017c6658fd59740f9845ca0d3369ddd778e3e0c0 (diff)
regulator: mt6358: Remove bogus regulators and
Merge series from Chen-Yu Tsai <wenst@chromium.org>: Hi, This is v3 of the remainder of the MT6358 regulator driver cleanup and improvement series. v1 can be found here [1]; v2 is here [2]. Changes since v2: - Merged patches dropped - Fixed up pickable linear ranges' selector values - Collected tags - Patch adding missing regulator definitions squashed into patch using the definitions; recommended by Krzysztof on my MT6366 series. - Remaining dts patch split out to be sent separately Changes since v1: - Merged patches dropped - Added patch to move VCN33 regulator status sync after ID check - Added patch to fix VCN33 sync fail error message - Added patch to add missing register definitions Various discrepancies were found while preparing to upstream MT8186 device trees, which utilize the MT6366 PMIC, that is also covered by this driver. Patches 1~3 should go through the regulator tree, and patch 4 through the soc/mediatek tree. ** Note: patch 2 needs an ack from Lee for the mfd header change. This v3 series can be seen as two parts. v1 had three parts, but one part was fully merged, and then v2 gained another cleanup. v3 drops the "fixing bogus regulators" part: driver changes are fully merged and device tree change will be sent separately. Part 1 - Robust chip ID checking (patch 1) Angelo suggested making the driver fail to probe if an unexpected chip ID was found. Patch 1 implements this. Part 2 - Output voltage fine tuning support (patches 2, 3) Many of the LDOs on these PMIC support an extra level of output voltage fine tuning. Most default to no offset, but a couple have a non-zero offset by default. Previously this was unaccounted for in the driver and device tree constraints. On the outputs with non-zero offset, this ends up becoming a discrepancy between the device tree and actual hardware. These two patches adds support for this second level of tuning, modeled as bunch of linear ranges. While it's unlikely we need this level of control, it's nice to be able to read back the accurate hardware settings. Please have a look. Thanks ChenYu [1] https://lore.kernel.org/linux-arm-kernel/20230609083009.2822259-1-wenst@chromium.org/ [2] https://lore.kernel.org/linux-mediatek/20230721082903.2038975-1-wenst@chromium.org/ Chen-Yu Tsai (3): regulator: mt6358: Fail probe on unknown chip ID regulator: mt6358: Add output voltage fine tuning to fixed regulators regulator: mt6358: Add output voltage fine tuning to variable LDOs drivers/regulator/mt6358-regulator.c | 304 ++++++++++++--------------- include/linux/mfd/mt6358/registers.h | 6 + 2 files changed, 144 insertions(+), 166 deletions(-) -- 2.42.0.283.g2d96d420d3-goog
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/helpers.c2
-rw-r--r--drivers/regulator/mt6358-regulator.c304
2 files changed, 139 insertions, 167 deletions
diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c
index 5ad5f3b3a6b5..d49268336553 100644
--- a/drivers/regulator/helpers.c
+++ b/drivers/regulator/helpers.c
@@ -197,7 +197,7 @@ int regulator_set_voltage_sel_pickable_regmap(struct regulator_dev *rdev,
sel += rdev->desc->linear_ranges[i].min_sel;
range = rdev->desc->linear_range_selectors_bitfield[i];
- range <<= ffs(rdev->desc->vsel_mask) - 1;
+ range <<= ffs(rdev->desc->vsel_range_mask) - 1;
if (rdev->desc->vsel_reg == rdev->desc->vsel_range_reg) {
ret = regmap_update_bits(rdev->regmap,
diff --git a/drivers/regulator/mt6358-regulator.c b/drivers/regulator/mt6358-regulator.c
index b9cda2210c33..064ad968af95 100644
--- a/drivers/regulator/mt6358-regulator.c
+++ b/drivers/regulator/mt6358-regulator.c
@@ -26,8 +26,6 @@ struct mt6358_regulator_info {
struct regulator_desc desc;
u32 status_reg;
u32 qi;
- const u32 *index_table;
- unsigned int n_table;
u32 da_vsel_reg;
u32 da_vsel_mask;
u32 modeset_reg;
@@ -64,9 +62,7 @@ struct mt6358_regulator_info {
.modeset_mask = BIT(_modeset_shift), \
}
-#define MT6358_LDO(match, vreg, ldo_volt_table, \
- ldo_index_table, enreg, enbit, vosel, \
- vosel_mask) \
+#define MT6358_LDO(match, vreg, volt_ranges, enreg, enbit, vosel, vosel_mask) \
[MT6358_ID_##vreg] = { \
.desc = { \
.name = #vreg, \
@@ -75,17 +71,19 @@ struct mt6358_regulator_info {
.type = REGULATOR_VOLTAGE, \
.id = MT6358_ID_##vreg, \
.owner = THIS_MODULE, \
- .n_voltages = ARRAY_SIZE(ldo_volt_table), \
- .volt_table = ldo_volt_table, \
- .vsel_reg = vosel, \
- .vsel_mask = vosel_mask, \
+ .n_voltages = ARRAY_SIZE(volt_ranges##_ranges) * 11, \
+ .linear_ranges = volt_ranges##_ranges, \
+ .linear_range_selectors_bitfield = volt_ranges##_selectors, \
+ .n_linear_ranges = ARRAY_SIZE(volt_ranges##_ranges), \
+ .vsel_range_reg = vosel, \
+ .vsel_range_mask = vosel_mask, \
+ .vsel_reg = MT6358_##vreg##_ANA_CON0, \
+ .vsel_mask = GENMASK(3, 0), \
.enable_reg = enreg, \
.enable_mask = BIT(enbit), \
}, \
.status_reg = MT6358_LDO_##vreg##_CON1, \
.qi = BIT(15), \
- .index_table = ldo_index_table, \
- .n_table = ARRAY_SIZE(ldo_index_table), \
}
#define MT6358_LDO1(match, vreg, min, max, step, \
@@ -123,10 +121,13 @@ struct mt6358_regulator_info {
.type = REGULATOR_VOLTAGE, \
.id = MT6358_ID_##vreg, \
.owner = THIS_MODULE, \
- .n_voltages = 1, \
+ .n_voltages = 11, \
+ .vsel_reg = MT6358_##vreg##_ANA_CON0, \
+ .vsel_mask = GENMASK(3, 0), \
.enable_reg = enreg, \
.enable_mask = BIT(enbit), \
.min_uV = volt, \
+ .uV_step = 10000, \
}, \
.status_reg = MT6358_LDO_##vreg##_CON1, \
.qi = BIT(15), \
@@ -160,9 +161,7 @@ struct mt6358_regulator_info {
.modeset_mask = BIT(_modeset_shift), \
}
-#define MT6366_LDO(match, vreg, ldo_volt_table, \
- ldo_index_table, enreg, enbit, vosel, \
- vosel_mask) \
+#define MT6366_LDO(match, vreg, volt_ranges, enreg, enbit, vosel, vosel_mask) \
[MT6366_ID_##vreg] = { \
.desc = { \
.name = #vreg, \
@@ -171,17 +170,19 @@ struct mt6358_regulator_info {
.type = REGULATOR_VOLTAGE, \
.id = MT6366_ID_##vreg, \
.owner = THIS_MODULE, \
- .n_voltages = ARRAY_SIZE(ldo_volt_table), \
- .volt_table = ldo_volt_table, \
- .vsel_reg = vosel, \
- .vsel_mask = vosel_mask, \
+ .n_voltages = ARRAY_SIZE(volt_ranges##_ranges) * 11, \
+ .linear_ranges = volt_ranges##_ranges, \
+ .linear_range_selectors_bitfield = volt_ranges##_selectors, \
+ .n_linear_ranges = ARRAY_SIZE(volt_ranges##_ranges), \
+ .vsel_range_reg = vosel, \
+ .vsel_range_mask = vosel_mask, \
+ .vsel_reg = MT6358_##vreg##_ANA_CON0, \
+ .vsel_mask = GENMASK(3, 0), \
.enable_reg = enreg, \
.enable_mask = BIT(enbit), \
}, \
.status_reg = MT6358_LDO_##vreg##_CON1, \
.qi = BIT(15), \
- .index_table = ldo_index_table, \
- .n_table = ARRAY_SIZE(ldo_index_table), \
}
#define MT6366_LDO1(match, vreg, min, max, step, \
@@ -219,105 +220,108 @@ struct mt6358_regulator_info {
.type = REGULATOR_VOLTAGE, \
.id = MT6366_ID_##vreg, \
.owner = THIS_MODULE, \
- .n_voltages = 1, \
+ .n_voltages = 11, \
+ .vsel_reg = MT6358_##vreg##_ANA_CON0, \
+ .vsel_mask = GENMASK(3, 0), \
.enable_reg = enreg, \
.enable_mask = BIT(enbit), \
.min_uV = volt, \
+ .uV_step = 10000, \
}, \
.status_reg = MT6358_LDO_##vreg##_CON1, \
.qi = BIT(15), \
}
-static const unsigned int vdram2_voltages[] = {
- 600000, 1800000,
-};
-
-static const unsigned int vsim_voltages[] = {
- 1700000, 1800000, 2700000, 3000000, 3100000,
-};
-
-static const unsigned int vibr_voltages[] = {
- 1200000, 1300000, 1500000, 1800000,
- 2000000, 2800000, 3000000, 3300000,
+/* VDRAM2 voltage selector not shown in datasheet */
+static const unsigned int vdram2_selectors[] = { 0, 12 };
+static const struct linear_range vdram2_ranges[] = {
+ REGULATOR_LINEAR_RANGE(600000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(1800000, 0, 10, 10000),
};
-static const unsigned int vusb_voltages[] = {
- 3000000, 3100000,
+static const unsigned int vsim_selectors[] = { 3, 4, 8, 11, 12 };
+static const struct linear_range vsim_ranges[] = {
+ REGULATOR_LINEAR_RANGE(1700000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(1800000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(2700000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(3000000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(3100000, 0, 10, 10000),
};
-static const unsigned int vcamd_voltages[] = {
- 900000, 1000000, 1100000, 1200000,
- 1300000, 1500000, 1800000,
+static const unsigned int vibr_selectors[] = { 0, 1, 2, 4, 5, 9, 11, 13 };
+static const struct linear_range vibr_ranges[] = {
+ REGULATOR_LINEAR_RANGE(1200000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(1300000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(1500000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(1800000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(2000000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(2800000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(3000000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(3300000, 0, 10, 10000),
};
-static const unsigned int vefuse_voltages[] = {
- 1700000, 1800000, 1900000,
+/* VUSB voltage selector not shown in datasheet */
+static const unsigned int vusb_selectors[] = { 3, 4 };
+static const struct linear_range vusb_ranges[] = {
+ REGULATOR_LINEAR_RANGE(3000000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(3100000, 0, 10, 10000),
};
-static const unsigned int vmch_vemc_voltages[] = {
- 2900000, 3000000, 3300000,
+static const unsigned int vcamd_selectors[] = { 3, 4, 5, 6, 7, 9, 12 };
+static const struct linear_range vcamd_ranges[] = {
+ REGULATOR_LINEAR_RANGE(900000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(1000000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(1100000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(1200000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(1300000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(1500000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(1800000, 0, 10, 10000),
};
-static const unsigned int vcama_voltages[] = {
- 1800000, 2500000, 2700000,
- 2800000, 2900000, 3000000,
+static const unsigned int vefuse_selectors[] = { 11, 12, 13 };
+static const struct linear_range vefuse_ranges[] = {
+ REGULATOR_LINEAR_RANGE(1700000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(1800000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(1900000, 0, 10, 10000),
};
-static const unsigned int vcn33_voltages[] = {
- 3300000, 3400000, 3500000,
+static const unsigned int vmch_vemc_selectors[] = { 2, 3, 5 };
+static const struct linear_range vmch_vemc_ranges[] = {
+ REGULATOR_LINEAR_RANGE(2900000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(3000000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(3300000, 0, 10, 10000),
};
-static const unsigned int vmc_voltages[] = {
- 1800000, 2900000, 3000000, 3300000,
+static const unsigned int vcama_selectors[] = { 0, 7, 9, 10, 11, 12 };
+static const struct linear_range vcama_ranges[] = {
+ REGULATOR_LINEAR_RANGE(1800000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(2500000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(2700000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(2800000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(2900000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(3000000, 0, 10, 10000),
};
-static const unsigned int vldo28_voltages[] = {
- 2800000, 3000000,
+static const unsigned int vcn33_selectors[] = { 1, 2, 3 };
+static const struct linear_range vcn33_ranges[] = {
+ REGULATOR_LINEAR_RANGE(3300000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(3400000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(3500000, 0, 10, 10000),
};
-static const u32 vdram2_idx[] = {
- 0, 12,
+static const unsigned int vmc_selectors[] = { 4, 10, 11, 13 };
+static const struct linear_range vmc_ranges[] = {
+ REGULATOR_LINEAR_RANGE(1800000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(2900000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(3000000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(3300000, 0, 10, 10000),
};
-static const u32 vsim_idx[] = {
- 3, 4, 8, 11, 12,
-};
-
-static const u32 vibr_idx[] = {
- 0, 1, 2, 4, 5, 9, 11, 13,
-};
-
-static const u32 vusb_idx[] = {
- 3, 4,
-};
-
-static const u32 vcamd_idx[] = {
- 3, 4, 5, 6, 7, 9, 12,
-};
-
-static const u32 vefuse_idx[] = {
- 11, 12, 13,
-};
-
-static const u32 vmch_vemc_idx[] = {
- 2, 3, 5,
-};
-
-static const u32 vcama_idx[] = {
- 0, 7, 9, 10, 11, 12,
-};
-
-static const u32 vcn33_idx[] = {
- 1, 2, 3,
-};
-
-static const u32 vmc_idx[] = {
- 4, 10, 11, 13,
-};
-
-static const u32 vldo28_idx[] = {
- 1, 3,
+static const unsigned int vldo28_selectors[] = { 1, 3 };
+static const struct linear_range vldo28_ranges[] = {
+ REGULATOR_LINEAR_RANGE(2800000, 0, 10, 10000),
+ REGULATOR_LINEAR_RANGE(3000000, 0, 10, 10000),
};
static unsigned int mt6358_map_mode(unsigned int mode)
@@ -326,49 +330,6 @@ static unsigned int mt6358_map_mode(unsigned int mode)
REGULATOR_MODE_NORMAL : REGULATOR_MODE_FAST;
}
-static int mt6358_set_voltage_sel(struct regulator_dev *rdev,
- unsigned int selector)
-{
- const struct mt6358_regulator_info *info = to_regulator_info(rdev->desc);
- int idx, ret;
- const u32 *pvol;
-
- pvol = info->index_table;
-
- idx = pvol[selector];
- idx <<= ffs(info->desc.vsel_mask) - 1;
- ret = regmap_update_bits(rdev->regmap, info->desc.vsel_reg,
- info->desc.vsel_mask, idx);
-
- return ret;
-}
-
-static int mt6358_get_voltage_sel(struct regulator_dev *rdev)
-{
- const struct mt6358_regulator_info *info = to_regulator_info(rdev->desc);
- int idx, ret;
- u32 selector;
- const u32 *pvol;
-
- ret = regmap_read(rdev->regmap, info->desc.vsel_reg, &selector);
- if (ret != 0) {
- dev_info(&rdev->dev,
- "Failed to get mt6358 %s vsel reg: %d\n",
- info->desc.name, ret);
- return ret;
- }
-
- selector = (selector & info->desc.vsel_mask) >>
- (ffs(info->desc.vsel_mask) - 1);
- pvol = info->index_table;
- for (idx = 0; idx < info->desc.n_voltages; idx++) {
- if (pvol[idx] == selector)
- return idx;
- }
-
- return -EINVAL;
-}
-
static int mt6358_get_buck_voltage_sel(struct regulator_dev *rdev)
{
const struct mt6358_regulator_info *info = to_regulator_info(rdev->desc);
@@ -465,10 +426,10 @@ static const struct regulator_ops mt6358_volt_range_ops = {
};
static const struct regulator_ops mt6358_volt_table_ops = {
- .list_voltage = regulator_list_voltage_table,
- .map_voltage = regulator_map_voltage_iterate,
- .set_voltage_sel = mt6358_set_voltage_sel,
- .get_voltage_sel = mt6358_get_voltage_sel,
+ .list_voltage = regulator_list_voltage_pickable_linear_range,
+ .map_voltage = regulator_map_voltage_pickable_linear_range,
+ .set_voltage_sel = regulator_set_voltage_sel_pickable_regmap,
+ .get_voltage_sel = regulator_get_voltage_sel_pickable_regmap,
.set_voltage_time_sel = regulator_set_voltage_time_sel,
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
@@ -476,8 +437,13 @@ static const struct regulator_ops mt6358_volt_table_ops = {
.get_status = mt6358_get_status,
};
+/* "Fixed" LDOs with output voltage calibration +0 ~ +10 mV */
static const struct regulator_ops mt6358_volt_fixed_ops = {
.list_voltage = regulator_list_voltage_linear,
+ .map_voltage = regulator_map_voltage_linear,
+ .set_voltage_sel = regulator_set_voltage_sel_regmap,
+ .get_voltage_sel = mt6358_get_buck_voltage_sel,
+ .set_voltage_time_sel = regulator_set_voltage_time_sel,
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
@@ -523,34 +489,34 @@ static const struct mt6358_regulator_info mt6358_regulators[] = {
MT6358_REG_FIXED("ldo_vrf18", VRF18, MT6358_LDO_VRF18_CON0, 0, 1800000),
MT6358_REG_FIXED("ldo_vaud28", VAUD28,
MT6358_LDO_VAUD28_CON0, 0, 2800000),
- MT6358_LDO("ldo_vdram2", VDRAM2, vdram2_voltages, vdram2_idx,
+ MT6358_LDO("ldo_vdram2", VDRAM2, vdram2,
MT6358_LDO_VDRAM2_CON0, 0, MT6358_LDO_VDRAM2_ELR0, 0xf),
- MT6358_LDO("ldo_vsim1", VSIM1, vsim_voltages, vsim_idx,
+ MT6358_LDO("ldo_vsim1", VSIM1, vsim,
MT6358_LDO_VSIM1_CON0, 0, MT6358_VSIM1_ANA_CON0, 0xf00),
- MT6358_LDO("ldo_vibr", VIBR, vibr_voltages, vibr_idx,
+ MT6358_LDO("ldo_vibr", VIBR, vibr,
MT6358_LDO_VIBR_CON0, 0, MT6358_VIBR_ANA_CON0, 0xf00),
- MT6358_LDO("ldo_vusb", VUSB, vusb_voltages, vusb_idx,
+ MT6358_LDO("ldo_vusb", VUSB, vusb,
MT6358_LDO_VUSB_CON0_0, 0, MT6358_VUSB_ANA_CON0, 0x700),
- MT6358_LDO("ldo_vcamd", VCAMD, vcamd_voltages, vcamd_idx,
+ MT6358_LDO("ldo_vcamd", VCAMD, vcamd,
MT6358_LDO_VCAMD_CON0, 0, MT6358_VCAMD_ANA_CON0, 0xf00),
- MT6358_LDO("ldo_vefuse", VEFUSE, vefuse_voltages, vefuse_idx,
+ MT6358_LDO("ldo_vefuse", VEFUSE, vefuse,
MT6358_LDO_VEFUSE_CON0, 0, MT6358_VEFUSE_ANA_CON0, 0xf00),
- MT6358_LDO("ldo_vmch", VMCH, vmch_vemc_voltages, vmch_vemc_idx,
+ MT6358_LDO("ldo_vmch", VMCH, vmch_vemc,
MT6358_LDO_VMCH_CON0, 0, MT6358_VMCH_ANA_CON0, 0x700),
- MT6358_LDO("ldo_vcama1", VCAMA1, vcama_voltages, vcama_idx,
+ MT6358_LDO("ldo_vcama1", VCAMA1, vcama,
MT6358_LDO_VCAMA1_CON0, 0, MT6358_VCAMA1_ANA_CON0, 0xf00),
- MT6358_LDO("ldo_vemc", VEMC, vmch_vemc_voltages, vmch_vemc_idx,
+ MT6358_LDO("ldo_vemc", VEMC, vmch_vemc,
MT6358_LDO_VEMC_CON0, 0, MT6358_VEMC_ANA_CON0, 0x700),
- MT6358_LDO("ldo_vcn33", VCN33, vcn33_voltages, vcn33_idx,
+ MT6358_LDO("ldo_vcn33", VCN33, vcn33,
MT6358_LDO_VCN33_CON0_0, 0, MT6358_VCN33_ANA_CON0, 0x300),
- MT6358_LDO("ldo_vcama2", VCAMA2, vcama_voltages, vcama_idx,
+ MT6358_LDO("ldo_vcama2", VCAMA2, vcama,
MT6358_LDO_VCAMA2_CON0, 0, MT6358_VCAMA2_ANA_CON0, 0xf00),
- MT6358_LDO("ldo_vmc", VMC, vmc_voltages, vmc_idx,
+ MT6358_LDO("ldo_vmc", VMC, vmc,
MT6358_LDO_VMC_CON0, 0, MT6358_VMC_ANA_CON0, 0xf00),
- MT6358_LDO("ldo_vldo28", VLDO28, vldo28_voltages, vldo28_idx,
+ MT6358_LDO("ldo_vldo28", VLDO28, vldo28,
MT6358_LDO_VLDO28_CON0_0, 0,
MT6358_VLDO28_ANA_CON0, 0x300),
- MT6358_LDO("ldo_vsim2", VSIM2, vsim_voltages, vsim_idx,
+ MT6358_LDO("ldo_vsim2", VSIM2, vsim,
MT6358_LDO_VSIM2_CON0, 0, MT6358_VSIM2_ANA_CON0, 0xf00),
MT6358_LDO1("ldo_vsram_proc11", VSRAM_PROC11, 500000, 1293750, 6250,
MT6358_LDO_VSRAM_PROC11_DBG0, 0x7f00, MT6358_LDO_VSRAM_CON0, 0x7f),
@@ -599,25 +565,25 @@ static const struct mt6358_regulator_info mt6366_regulators[] = {
MT6366_REG_FIXED("ldo_vrf18", VRF18, MT6358_LDO_VRF18_CON0, 0, 1800000),
MT6366_REG_FIXED("ldo_vaud28", VAUD28,
MT6358_LDO_VAUD28_CON0, 0, 2800000),
- MT6366_LDO("ldo_vdram2", VDRAM2, vdram2_voltages, vdram2_idx,
+ MT6366_LDO("ldo_vdram2", VDRAM2, vdram2,
MT6358_LDO_VDRAM2_CON0, 0, MT6358_LDO_VDRAM2_ELR0, 0x10),
- MT6366_LDO("ldo_vsim1", VSIM1, vsim_voltages, vsim_idx,
+ MT6366_LDO("ldo_vsim1", VSIM1, vsim,
MT6358_LDO_VSIM1_CON0, 0, MT6358_VSIM1_ANA_CON0, 0xf00),
- MT6366_LDO("ldo_vibr", VIBR, vibr_voltages, vibr_idx,
+ MT6366_LDO("ldo_vibr", VIBR, vibr,
MT6358_LDO_VIBR_CON0, 0, MT6358_VIBR_ANA_CON0, 0xf00),
- MT6366_LDO("ldo_vusb", VUSB, vusb_voltages, vusb_idx,
+ MT6366_LDO("ldo_vusb", VUSB, vusb,
MT6358_LDO_VUSB_CON0_0, 0, MT6358_VUSB_ANA_CON0, 0x700),
- MT6366_LDO("ldo_vefuse", VEFUSE, vefuse_voltages, vefuse_idx,
+ MT6366_LDO("ldo_vefuse", VEFUSE, vefuse,
MT6358_LDO_VEFUSE_CON0, 0, MT6358_VEFUSE_ANA_CON0, 0xf00),
- MT6366_LDO("ldo_vmch", VMCH, vmch_vemc_voltages, vmch_vemc_idx,
+ MT6366_LDO("ldo_vmch", VMCH, vmch_vemc,
MT6358_LDO_VMCH_CON0, 0, MT6358_VMCH_ANA_CON0, 0x700),
- MT6366_LDO("ldo_vemc", VEMC, vmch_vemc_voltages, vmch_vemc_idx,
+ MT6366_LDO("ldo_vemc", VEMC, vmch_vemc,
MT6358_LDO_VEMC_CON0, 0, MT6358_VEMC_ANA_CON0, 0x700),
- MT6366_LDO("ldo_vcn33", VCN33, vcn33_voltages, vcn33_idx,
+ MT6366_LDO("ldo_vcn33", VCN33, vcn33,
MT6358_LDO_VCN33_CON0_0, 0, MT6358_VCN33_ANA_CON0, 0x300),
- MT6366_LDO("ldo_vmc", VMC, vmc_voltages, vmc_idx,
+ MT6366_LDO("ldo_vmc", VMC, vmc,
MT6358_LDO_VMC_CON0, 0, MT6358_VMC_ANA_CON0, 0xf00),
- MT6366_LDO("ldo_vsim2", VSIM2, vsim_voltages, vsim_idx,
+ MT6366_LDO("ldo_vsim2", VSIM2, vsim,
MT6358_LDO_VSIM2_CON0, 0, MT6358_VSIM2_ANA_CON0, 0xf00),
MT6366_LDO1("ldo_vsram_proc11", VSRAM_PROC11, 500000, 1293750, 6250,
MT6358_LDO_VSRAM_PROC11_DBG0, 0x7f00, MT6358_LDO_VSRAM_CON0, 0x7f),
@@ -676,12 +642,18 @@ static int mt6358_regulator_probe(struct platform_device *pdev)
const struct mt6358_regulator_info *mt6358_info;
int i, max_regulator, ret;
- if (mt6397->chip_id == MT6366_CHIP_ID) {
- max_regulator = MT6366_MAX_REGULATOR;
- mt6358_info = mt6366_regulators;
- } else {
+ switch (mt6397->chip_id) {
+ case MT6358_CHIP_ID:
max_regulator = MT6358_MAX_REGULATOR;
mt6358_info = mt6358_regulators;
+ break;
+ case MT6366_CHIP_ID:
+ max_regulator = MT6366_MAX_REGULATOR;
+ mt6358_info = mt6366_regulators;
+ break;
+ default:
+ dev_err(&pdev->dev, "unsupported chip ID: %d\n", mt6397->chip_id);
+ return -EINVAL;
}
ret = mt6358_sync_vcn33_setting(&pdev->dev);