0001
0002
0003
0004
0005
0006
0007
0008 #include <linux/mfd/atc260x/core.h>
0009 #include <linux/module.h>
0010 #include <linux/of_device.h>
0011 #include <linux/regmap.h>
0012 #include <linux/regulator/driver.h>
0013
0014 struct atc260x_regulator_data {
0015 int voltage_time_dcdc;
0016 int voltage_time_ldo;
0017 };
0018
0019 static const struct linear_range atc2603c_dcdc_voltage_ranges[] = {
0020 REGULATOR_LINEAR_RANGE(1300000, 0, 13, 50000),
0021 REGULATOR_LINEAR_RANGE(1950000, 14, 15, 100000),
0022 };
0023
0024 static const struct linear_range atc2609a_dcdc_voltage_ranges[] = {
0025 REGULATOR_LINEAR_RANGE(600000, 0, 127, 6250),
0026 REGULATOR_LINEAR_RANGE(1400000, 128, 232, 25000),
0027 };
0028
0029 static const struct linear_range atc2609a_ldo_voltage_ranges0[] = {
0030 REGULATOR_LINEAR_RANGE(700000, 0, 15, 100000),
0031 REGULATOR_LINEAR_RANGE(2100000, 0, 12, 100000),
0032 };
0033
0034 static const struct linear_range atc2609a_ldo_voltage_ranges1[] = {
0035 REGULATOR_LINEAR_RANGE(850000, 0, 15, 100000),
0036 REGULATOR_LINEAR_RANGE(2100000, 0, 11, 100000),
0037 };
0038
0039 static const unsigned int atc260x_ldo_voltage_range_sel[] = {
0040 0x0, 0x20,
0041 };
0042
0043 static int atc260x_dcdc_set_voltage_time_sel(struct regulator_dev *rdev,
0044 unsigned int old_selector,
0045 unsigned int new_selector)
0046 {
0047 struct atc260x_regulator_data *data = rdev_get_drvdata(rdev);
0048
0049 if (new_selector > old_selector)
0050 return data->voltage_time_dcdc;
0051
0052 return 0;
0053 }
0054
0055 static int atc260x_ldo_set_voltage_time_sel(struct regulator_dev *rdev,
0056 unsigned int old_selector,
0057 unsigned int new_selector)
0058 {
0059 struct atc260x_regulator_data *data = rdev_get_drvdata(rdev);
0060
0061 if (new_selector > old_selector)
0062 return data->voltage_time_ldo;
0063
0064 return 0;
0065 }
0066
0067 static const struct regulator_ops atc260x_dcdc_ops = {
0068 .enable = regulator_enable_regmap,
0069 .disable = regulator_disable_regmap,
0070 .is_enabled = regulator_is_enabled_regmap,
0071 .list_voltage = regulator_list_voltage_linear,
0072 .set_voltage_sel = regulator_set_voltage_sel_regmap,
0073 .get_voltage_sel = regulator_get_voltage_sel_regmap,
0074 .set_voltage_time_sel = atc260x_dcdc_set_voltage_time_sel,
0075 };
0076
0077 static const struct regulator_ops atc260x_ldo_ops = {
0078 .enable = regulator_enable_regmap,
0079 .disable = regulator_disable_regmap,
0080 .is_enabled = regulator_is_enabled_regmap,
0081 .list_voltage = regulator_list_voltage_linear,
0082 .set_voltage_sel = regulator_set_voltage_sel_regmap,
0083 .get_voltage_sel = regulator_get_voltage_sel_regmap,
0084 .set_voltage_time_sel = atc260x_ldo_set_voltage_time_sel,
0085 };
0086
0087 static const struct regulator_ops atc260x_ldo_bypass_ops = {
0088 .enable = regulator_enable_regmap,
0089 .disable = regulator_disable_regmap,
0090 .is_enabled = regulator_is_enabled_regmap,
0091 .list_voltage = regulator_list_voltage_linear,
0092 .set_voltage_sel = regulator_set_voltage_sel_regmap,
0093 .get_voltage_sel = regulator_get_voltage_sel_regmap,
0094 .set_voltage_time_sel = atc260x_ldo_set_voltage_time_sel,
0095 .set_bypass = regulator_set_bypass_regmap,
0096 .get_bypass = regulator_get_bypass_regmap,
0097 };
0098
0099 static const struct regulator_ops atc260x_ldo_bypass_discharge_ops = {
0100 .enable = regulator_enable_regmap,
0101 .disable = regulator_disable_regmap,
0102 .is_enabled = regulator_is_enabled_regmap,
0103 .list_voltage = regulator_list_voltage_linear,
0104 .set_voltage_sel = regulator_set_voltage_sel_regmap,
0105 .get_voltage_sel = regulator_get_voltage_sel_regmap,
0106 .set_voltage_time_sel = atc260x_ldo_set_voltage_time_sel,
0107 .set_bypass = regulator_set_bypass_regmap,
0108 .get_bypass = regulator_get_bypass_regmap,
0109 .set_active_discharge = regulator_set_active_discharge_regmap,
0110 };
0111
0112 static const struct regulator_ops atc260x_dcdc_range_ops = {
0113 .enable = regulator_enable_regmap,
0114 .disable = regulator_disable_regmap,
0115 .is_enabled = regulator_is_enabled_regmap,
0116 .list_voltage = regulator_list_voltage_linear_range,
0117 .set_voltage_sel = regulator_set_voltage_sel_regmap,
0118 .get_voltage_sel = regulator_get_voltage_sel_regmap,
0119 .set_voltage_time_sel = atc260x_dcdc_set_voltage_time_sel,
0120 };
0121
0122 static const struct regulator_ops atc260x_ldo_range_pick_ops = {
0123 .enable = regulator_enable_regmap,
0124 .disable = regulator_disable_regmap,
0125 .is_enabled = regulator_is_enabled_regmap,
0126 .list_voltage = regulator_list_voltage_pickable_linear_range,
0127 .set_voltage_sel = regulator_set_voltage_sel_pickable_regmap,
0128 .get_voltage_sel = regulator_get_voltage_sel_pickable_regmap,
0129 .set_voltage_time_sel = atc260x_ldo_set_voltage_time_sel,
0130 };
0131
0132 static const struct regulator_ops atc260x_dcdc_fixed_ops = {
0133 .list_voltage = regulator_list_voltage_linear,
0134 .set_voltage_sel = regulator_set_voltage_sel_regmap,
0135 .get_voltage_sel = regulator_get_voltage_sel_regmap,
0136 .set_voltage_time_sel = atc260x_dcdc_set_voltage_time_sel,
0137 };
0138
0139 static const struct regulator_ops atc260x_ldo_fixed_ops = {
0140 .list_voltage = regulator_list_voltage_linear,
0141 .set_voltage_sel = regulator_set_voltage_sel_regmap,
0142 .get_voltage_sel = regulator_get_voltage_sel_regmap,
0143 .set_voltage_time_sel = atc260x_ldo_set_voltage_time_sel,
0144 };
0145
0146 static const struct regulator_ops atc260x_no_ops = {
0147 };
0148
0149
0150
0151
0152
0153 enum atc2603c_reg_ids {
0154 ATC2603C_ID_DCDC1,
0155 ATC2603C_ID_DCDC2,
0156 ATC2603C_ID_DCDC3,
0157 ATC2603C_ID_LDO1,
0158 ATC2603C_ID_LDO2,
0159 ATC2603C_ID_LDO3,
0160 ATC2603C_ID_LDO5,
0161 ATC2603C_ID_LDO6,
0162 ATC2603C_ID_LDO7,
0163 ATC2603C_ID_LDO8,
0164 ATC2603C_ID_LDO11,
0165 ATC2603C_ID_LDO12,
0166 ATC2603C_ID_SWITCHLDO1,
0167 ATC2603C_ID_MAX,
0168 };
0169
0170 #define atc2603c_reg_desc_dcdc(num, min, step, n_volt, vsel_h, vsel_l) { \
0171 .name = "DCDC"#num, \
0172 .supply_name = "dcdc"#num, \
0173 .of_match = of_match_ptr("dcdc"#num), \
0174 .regulators_node = of_match_ptr("regulators"), \
0175 .id = ATC2603C_ID_DCDC##num, \
0176 .ops = &atc260x_dcdc_ops, \
0177 .type = REGULATOR_VOLTAGE, \
0178 .min_uV = min, \
0179 .uV_step = step, \
0180 .n_voltages = n_volt, \
0181 .vsel_reg = ATC2603C_PMU_DC##num##_CTL0, \
0182 .vsel_mask = GENMASK(vsel_h, vsel_l), \
0183 .enable_reg = ATC2603C_PMU_DC##num##_CTL0, \
0184 .enable_mask = BIT(15), \
0185 .enable_time = 800, \
0186 .owner = THIS_MODULE, \
0187 }
0188
0189 #define atc2603c_reg_desc_dcdc_range(num, vsel_h, vsel_l) { \
0190 .name = "DCDC"#num, \
0191 .supply_name = "dcdc"#num, \
0192 .of_match = of_match_ptr("dcdc"#num), \
0193 .regulators_node = of_match_ptr("regulators"), \
0194 .id = ATC2603C_ID_DCDC##num, \
0195 .ops = &atc260x_dcdc_range_ops, \
0196 .type = REGULATOR_VOLTAGE, \
0197 .n_voltages = 16, \
0198 .linear_ranges = atc2603c_dcdc_voltage_ranges, \
0199 .n_linear_ranges = ARRAY_SIZE(atc2603c_dcdc_voltage_ranges), \
0200 .vsel_reg = ATC2603C_PMU_DC##num##_CTL0, \
0201 .vsel_mask = GENMASK(vsel_h, vsel_l), \
0202 .enable_reg = ATC2603C_PMU_DC##num##_CTL0, \
0203 .enable_mask = BIT(15), \
0204 .enable_time = 800, \
0205 .owner = THIS_MODULE, \
0206 }
0207
0208 #define atc2603c_reg_desc_dcdc_fixed(num, min, step, n_volt, vsel_h, vsel_l) { \
0209 .name = "DCDC"#num, \
0210 .supply_name = "dcdc"#num, \
0211 .of_match = of_match_ptr("dcdc"#num), \
0212 .regulators_node = of_match_ptr("regulators"), \
0213 .id = ATC2603C_ID_DCDC##num, \
0214 .ops = &atc260x_dcdc_fixed_ops, \
0215 .type = REGULATOR_VOLTAGE, \
0216 .min_uV = min, \
0217 .uV_step = step, \
0218 .n_voltages = n_volt, \
0219 .vsel_reg = ATC2603C_PMU_DC##num##_CTL0, \
0220 .vsel_mask = GENMASK(vsel_h, vsel_l), \
0221 .enable_time = 800, \
0222 .owner = THIS_MODULE, \
0223 }
0224
0225 #define atc2603c_reg_desc_ldo(num, min, step, n_volt, vsel_h, vsel_l) { \
0226 .name = "LDO"#num, \
0227 .supply_name = "ldo"#num, \
0228 .of_match = of_match_ptr("ldo"#num), \
0229 .regulators_node = of_match_ptr("regulators"), \
0230 .id = ATC2603C_ID_LDO##num, \
0231 .ops = &atc260x_ldo_ops, \
0232 .type = REGULATOR_VOLTAGE, \
0233 .min_uV = min, \
0234 .uV_step = step, \
0235 .n_voltages = n_volt, \
0236 .vsel_reg = ATC2603C_PMU_LDO##num##_CTL, \
0237 .vsel_mask = GENMASK(vsel_h, vsel_l), \
0238 .enable_reg = ATC2603C_PMU_LDO##num##_CTL, \
0239 .enable_mask = BIT(0), \
0240 .enable_time = 2000, \
0241 .owner = THIS_MODULE, \
0242 }
0243
0244 #define atc2603c_reg_desc_ldo_fixed(num, min, step, n_volt, vsel_h, vsel_l) { \
0245 .name = "LDO"#num, \
0246 .supply_name = "ldo"#num, \
0247 .of_match = of_match_ptr("ldo"#num), \
0248 .regulators_node = of_match_ptr("regulators"), \
0249 .id = ATC2603C_ID_LDO##num, \
0250 .ops = &atc260x_ldo_fixed_ops, \
0251 .type = REGULATOR_VOLTAGE, \
0252 .min_uV = min, \
0253 .uV_step = step, \
0254 .n_voltages = n_volt, \
0255 .vsel_reg = ATC2603C_PMU_LDO##num##_CTL, \
0256 .vsel_mask = GENMASK(vsel_h, vsel_l), \
0257 .enable_time = 2000, \
0258 .owner = THIS_MODULE, \
0259 }
0260
0261 #define atc2603c_reg_desc_ldo_noops(num, vfixed) { \
0262 .name = "LDO"#num, \
0263 .supply_name = "ldo"#num, \
0264 .of_match = of_match_ptr("ldo"#num), \
0265 .regulators_node = of_match_ptr("regulators"), \
0266 .id = ATC2603C_ID_LDO##num, \
0267 .ops = &atc260x_no_ops, \
0268 .type = REGULATOR_VOLTAGE, \
0269 .fixed_uV = vfixed, \
0270 .n_voltages = 1, \
0271 .owner = THIS_MODULE, \
0272 }
0273
0274 #define atc2603c_reg_desc_ldo_switch(num, min, step, n_volt, vsel_h, vsel_l) { \
0275 .name = "SWITCHLDO"#num, \
0276 .supply_name = "switchldo"#num, \
0277 .of_match = of_match_ptr("switchldo"#num), \
0278 .regulators_node = of_match_ptr("regulators"), \
0279 .id = ATC2603C_ID_SWITCHLDO##num, \
0280 .ops = &atc260x_ldo_bypass_discharge_ops, \
0281 .type = REGULATOR_VOLTAGE, \
0282 .min_uV = min, \
0283 .uV_step = step, \
0284 .n_voltages = n_volt, \
0285 .vsel_reg = ATC2603C_PMU_SWITCH_CTL, \
0286 .vsel_mask = GENMASK(vsel_h, vsel_l), \
0287 .enable_reg = ATC2603C_PMU_SWITCH_CTL, \
0288 .enable_mask = BIT(15), \
0289 .enable_is_inverted = true, \
0290 .enable_time = 2000, \
0291 .bypass_reg = ATC2603C_PMU_SWITCH_CTL, \
0292 .bypass_mask = BIT(5), \
0293 .active_discharge_reg = ATC2603C_PMU_SWITCH_CTL, \
0294 .active_discharge_mask = BIT(1), \
0295 .active_discharge_on = BIT(1), \
0296 .owner = THIS_MODULE, \
0297 }
0298
0299 static const struct regulator_desc atc2603c_reg[] = {
0300 atc2603c_reg_desc_dcdc_fixed(1, 700000, 25000, 29, 11, 7),
0301 atc2603c_reg_desc_dcdc_range(2, 12, 8),
0302 atc2603c_reg_desc_dcdc_fixed(3, 2600000, 100000, 8, 11, 9),
0303 atc2603c_reg_desc_ldo_fixed(1, 2600000, 100000, 8, 15, 13),
0304 atc2603c_reg_desc_ldo_fixed(2, 2600000, 100000, 8, 15, 13),
0305 atc2603c_reg_desc_ldo_fixed(3, 1500000, 100000, 6, 15, 13),
0306 atc2603c_reg_desc_ldo(5, 2600000, 100000, 8, 15, 13),
0307 atc2603c_reg_desc_ldo_fixed(6, 700000, 25000, 29, 15, 11),
0308 atc2603c_reg_desc_ldo(7, 1500000, 100000, 6, 15, 13),
0309 atc2603c_reg_desc_ldo(8, 2300000, 100000, 11, 15, 12),
0310 atc2603c_reg_desc_ldo_fixed(11, 2600000, 100000, 8, 15, 13),
0311 atc2603c_reg_desc_ldo_noops(12, 1800000),
0312 atc2603c_reg_desc_ldo_switch(1, 3000000, 100000, 4, 4, 3),
0313 };
0314
0315 static const struct regulator_desc atc2603c_reg_dcdc2_ver_b =
0316 atc2603c_reg_desc_dcdc(2, 1000000, 50000, 18, 12, 8);
0317
0318 enum atc2609a_reg_ids {
0319 ATC2609A_ID_DCDC0,
0320 ATC2609A_ID_DCDC1,
0321 ATC2609A_ID_DCDC2,
0322 ATC2609A_ID_DCDC3,
0323 ATC2609A_ID_DCDC4,
0324 ATC2609A_ID_LDO0,
0325 ATC2609A_ID_LDO1,
0326 ATC2609A_ID_LDO2,
0327 ATC2609A_ID_LDO3,
0328 ATC2609A_ID_LDO4,
0329 ATC2609A_ID_LDO5,
0330 ATC2609A_ID_LDO6,
0331 ATC2609A_ID_LDO7,
0332 ATC2609A_ID_LDO8,
0333 ATC2609A_ID_LDO9,
0334 ATC2609A_ID_MAX,
0335 };
0336
0337 #define atc2609a_reg_desc_dcdc(num, en_bit) { \
0338 .name = "DCDC"#num, \
0339 .supply_name = "dcdc"#num, \
0340 .of_match = of_match_ptr("dcdc"#num), \
0341 .regulators_node = of_match_ptr("regulators"), \
0342 .id = ATC2609A_ID_DCDC##num, \
0343 .ops = &atc260x_dcdc_ops, \
0344 .type = REGULATOR_VOLTAGE, \
0345 .min_uV = 600000, \
0346 .uV_step = 6250, \
0347 .n_voltages = 256, \
0348 .vsel_reg = ATC2609A_PMU_DC##num##_CTL0, \
0349 .vsel_mask = GENMASK(15, 8), \
0350 .enable_reg = ATC2609A_PMU_DC_OSC, \
0351 .enable_mask = BIT(en_bit), \
0352 .enable_time = 800, \
0353 .owner = THIS_MODULE, \
0354 }
0355
0356 #define atc2609a_reg_desc_dcdc_range(num, en_bit) { \
0357 .name = "DCDC"#num, \
0358 .supply_name = "dcdc"#num, \
0359 .of_match = of_match_ptr("dcdc"#num), \
0360 .regulators_node = of_match_ptr("regulators"), \
0361 .id = ATC2609A_ID_DCDC##num, \
0362 .ops = &atc260x_dcdc_range_ops, \
0363 .type = REGULATOR_VOLTAGE, \
0364 .n_voltages = 233, \
0365 .linear_ranges = atc2609a_dcdc_voltage_ranges, \
0366 .n_linear_ranges = ARRAY_SIZE(atc2609a_dcdc_voltage_ranges), \
0367 .vsel_reg = ATC2609A_PMU_DC##num##_CTL0, \
0368 .vsel_mask = GENMASK(15, 8), \
0369 .enable_reg = ATC2609A_PMU_DC_OSC, \
0370 .enable_mask = BIT(en_bit), \
0371 .enable_time = 800, \
0372 .owner = THIS_MODULE, \
0373 }
0374
0375 #define atc2609a_reg_desc_ldo(num) { \
0376 .name = "LDO"#num, \
0377 .supply_name = "ldo"#num, \
0378 .of_match = of_match_ptr("ldo"#num), \
0379 .regulators_node = of_match_ptr("regulators"), \
0380 .id = ATC2609A_ID_LDO##num, \
0381 .ops = &atc260x_ldo_ops, \
0382 .type = REGULATOR_VOLTAGE, \
0383 .min_uV = 700000, \
0384 .uV_step = 100000, \
0385 .n_voltages = 16, \
0386 .vsel_reg = ATC2609A_PMU_LDO##num##_CTL0, \
0387 .vsel_mask = GENMASK(4, 1), \
0388 .enable_reg = ATC2609A_PMU_LDO##num##_CTL0, \
0389 .enable_mask = BIT(0), \
0390 .enable_time = 2000, \
0391 .owner = THIS_MODULE, \
0392 }
0393
0394 #define atc2609a_reg_desc_ldo_bypass(num) { \
0395 .name = "LDO"#num, \
0396 .supply_name = "ldo"#num, \
0397 .of_match = of_match_ptr("ldo"#num), \
0398 .regulators_node = of_match_ptr("regulators"), \
0399 .id = ATC2609A_ID_LDO##num, \
0400 .ops = &atc260x_ldo_bypass_ops, \
0401 .type = REGULATOR_VOLTAGE, \
0402 .min_uV = 2300000, \
0403 .uV_step = 100000, \
0404 .n_voltages = 12, \
0405 .vsel_reg = ATC2609A_PMU_LDO##num##_CTL0, \
0406 .vsel_mask = GENMASK(5, 2), \
0407 .enable_reg = ATC2609A_PMU_LDO##num##_CTL0, \
0408 .enable_mask = BIT(0), \
0409 .enable_time = 2000, \
0410 .bypass_reg = ATC2609A_PMU_LDO##num##_CTL0, \
0411 .bypass_mask = BIT(1), \
0412 .owner = THIS_MODULE, \
0413 }
0414
0415 #define atc2609a_reg_desc_ldo_range_pick(num, n_range, n_volt) { \
0416 .name = "LDO"#num, \
0417 .supply_name = "ldo"#num, \
0418 .of_match = of_match_ptr("ldo"#num), \
0419 .regulators_node = of_match_ptr("regulators"), \
0420 .id = ATC2609A_ID_LDO##num, \
0421 .ops = &atc260x_ldo_range_pick_ops, \
0422 .type = REGULATOR_VOLTAGE, \
0423 .linear_ranges = atc2609a_ldo_voltage_ranges##n_range, \
0424 .n_linear_ranges = ARRAY_SIZE(atc2609a_ldo_voltage_ranges##n_range), \
0425 .n_voltages = n_volt, \
0426 .vsel_reg = ATC2609A_PMU_LDO##num##_CTL0, \
0427 .vsel_mask = GENMASK(4, 1), \
0428 .vsel_range_reg = ATC2609A_PMU_LDO##num##_CTL0, \
0429 .vsel_range_mask = BIT(5), \
0430 .linear_range_selectors = atc260x_ldo_voltage_range_sel, \
0431 .enable_reg = ATC2609A_PMU_LDO##num##_CTL0, \
0432 .enable_mask = BIT(0), \
0433 .enable_time = 2000, \
0434 .owner = THIS_MODULE, \
0435 }
0436
0437 #define atc2609a_reg_desc_ldo_fixed(num) { \
0438 .name = "LDO"#num, \
0439 .supply_name = "ldo"#num, \
0440 .of_match = of_match_ptr("ldo"#num), \
0441 .regulators_node = of_match_ptr("regulators"), \
0442 .id = ATC2609A_ID_LDO##num, \
0443 .ops = &atc260x_ldo_fixed_ops, \
0444 .type = REGULATOR_VOLTAGE, \
0445 .min_uV = 2600000, \
0446 .uV_step = 100000, \
0447 .n_voltages = 8, \
0448 .vsel_reg = ATC2609A_PMU_LDO##num##_CTL, \
0449 .vsel_mask = GENMASK(15, 13), \
0450 .enable_time = 2000, \
0451 .owner = THIS_MODULE, \
0452 }
0453
0454 static const struct regulator_desc atc2609a_reg[] = {
0455 atc2609a_reg_desc_dcdc(0, 4),
0456 atc2609a_reg_desc_dcdc(1, 5),
0457 atc2609a_reg_desc_dcdc(2, 6),
0458 atc2609a_reg_desc_dcdc_range(3, 7),
0459 atc2609a_reg_desc_dcdc(4, 8),
0460 atc2609a_reg_desc_ldo_bypass(0),
0461 atc2609a_reg_desc_ldo_bypass(1),
0462 atc2609a_reg_desc_ldo_bypass(2),
0463 atc2609a_reg_desc_ldo_range_pick(3, 0, 29),
0464 atc2609a_reg_desc_ldo_range_pick(4, 0, 29),
0465 atc2609a_reg_desc_ldo(5),
0466 atc2609a_reg_desc_ldo_range_pick(6, 1, 28),
0467 atc2609a_reg_desc_ldo_range_pick(7, 0, 29),
0468 atc2609a_reg_desc_ldo_range_pick(8, 0, 29),
0469 atc2609a_reg_desc_ldo_fixed(9),
0470 };
0471
0472 static int atc260x_regulator_probe(struct platform_device *pdev)
0473 {
0474 struct atc260x *atc260x = dev_get_drvdata(pdev->dev.parent);
0475 struct device *dev = atc260x->dev;
0476 struct atc260x_regulator_data *atc260x_data;
0477 struct regulator_config config = {};
0478 struct regulator_dev *atc260x_rdev;
0479 const struct regulator_desc *regulators;
0480 bool atc2603c_ver_b = false;
0481 int i, nregulators;
0482
0483 atc260x_data = devm_kzalloc(&pdev->dev, sizeof(*atc260x_data), GFP_KERNEL);
0484 if (!atc260x_data)
0485 return -ENOMEM;
0486
0487 atc260x_data->voltage_time_dcdc = 350;
0488 atc260x_data->voltage_time_ldo = 800;
0489
0490 switch (atc260x->ic_type) {
0491 case ATC2603C:
0492 regulators = atc2603c_reg;
0493 nregulators = ATC2603C_ID_MAX;
0494 atc2603c_ver_b = atc260x->ic_ver == ATC260X_B;
0495 break;
0496 case ATC2609A:
0497 atc260x_data->voltage_time_dcdc = 250;
0498 regulators = atc2609a_reg;
0499 nregulators = ATC2609A_ID_MAX;
0500 break;
0501 default:
0502 dev_err(dev, "unsupported ATC260X ID %d\n", atc260x->ic_type);
0503 return -EINVAL;
0504 }
0505
0506 config.dev = dev;
0507 config.regmap = atc260x->regmap;
0508 config.driver_data = atc260x_data;
0509
0510
0511 for (i = 0; i < nregulators; i++) {
0512 if (atc2603c_ver_b && regulators[i].id == ATC2603C_ID_DCDC2)
0513 atc260x_rdev = devm_regulator_register(&pdev->dev,
0514 &atc2603c_reg_dcdc2_ver_b,
0515 &config);
0516 else
0517 atc260x_rdev = devm_regulator_register(&pdev->dev,
0518 ®ulators[i],
0519 &config);
0520 if (IS_ERR(atc260x_rdev)) {
0521 dev_err(dev, "failed to register regulator: %d\n", i);
0522 return PTR_ERR(atc260x_rdev);
0523 }
0524 }
0525
0526 return 0;
0527 }
0528
0529 static struct platform_driver atc260x_regulator_driver = {
0530 .probe = atc260x_regulator_probe,
0531 .driver = {
0532 .name = "atc260x-regulator",
0533 },
0534 };
0535
0536 module_platform_driver(atc260x_regulator_driver);
0537
0538 MODULE_DESCRIPTION("Regulator driver for ATC260x PMICs");
0539 MODULE_AUTHOR("Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>");
0540 MODULE_AUTHOR("Cristian Ciocaltea <cristian.ciocaltea@gmail.com>");
0541 MODULE_LICENSE("GPL");