0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #include <linux/init.h>
0018 #include <linux/kernel.h>
0019 #include <linux/module.h>
0020 #include <linux/err.h>
0021 #include <linux/platform_device.h>
0022 #include <linux/mfd/abx500.h>
0023 #include <linux/mfd/abx500/ab8500.h>
0024 #include <linux/of.h>
0025 #include <linux/regulator/of_regulator.h>
0026 #include <linux/regulator/driver.h>
0027 #include <linux/regulator/machine.h>
0028 #include <linux/slab.h>
0029
0030
0031 enum ab8500_regulator_id {
0032 AB8500_LDO_AUX1,
0033 AB8500_LDO_AUX2,
0034 AB8500_LDO_AUX3,
0035 AB8500_LDO_INTCORE,
0036 AB8500_LDO_TVOUT,
0037 AB8500_LDO_AUDIO,
0038 AB8500_LDO_ANAMIC1,
0039 AB8500_LDO_ANAMIC2,
0040 AB8500_LDO_DMIC,
0041 AB8500_LDO_ANA,
0042 AB8500_NUM_REGULATORS,
0043 };
0044
0045
0046 enum ab8505_regulator_id {
0047 AB8505_LDO_AUX1,
0048 AB8505_LDO_AUX2,
0049 AB8505_LDO_AUX3,
0050 AB8505_LDO_AUX4,
0051 AB8505_LDO_AUX5,
0052 AB8505_LDO_AUX6,
0053 AB8505_LDO_INTCORE,
0054 AB8505_LDO_ADC,
0055 AB8505_LDO_AUDIO,
0056 AB8505_LDO_ANAMIC1,
0057 AB8505_LDO_ANAMIC2,
0058 AB8505_LDO_AUX8,
0059 AB8505_LDO_ANA,
0060 AB8505_NUM_REGULATORS,
0061 };
0062
0063
0064 enum ab8500_regulator_reg {
0065 AB8500_REGUREQUESTCTRL2,
0066 AB8500_REGUREQUESTCTRL3,
0067 AB8500_REGUREQUESTCTRL4,
0068 AB8500_REGUSYSCLKREQ1HPVALID1,
0069 AB8500_REGUSYSCLKREQ1HPVALID2,
0070 AB8500_REGUHWHPREQ1VALID1,
0071 AB8500_REGUHWHPREQ1VALID2,
0072 AB8500_REGUHWHPREQ2VALID1,
0073 AB8500_REGUHWHPREQ2VALID2,
0074 AB8500_REGUSWHPREQVALID1,
0075 AB8500_REGUSWHPREQVALID2,
0076 AB8500_REGUSYSCLKREQVALID1,
0077 AB8500_REGUSYSCLKREQVALID2,
0078 AB8500_REGUMISC1,
0079 AB8500_VAUDIOSUPPLY,
0080 AB8500_REGUCTRL1VAMIC,
0081 AB8500_VPLLVANAREGU,
0082 AB8500_VREFDDR,
0083 AB8500_EXTSUPPLYREGU,
0084 AB8500_VAUX12REGU,
0085 AB8500_VRF1VAUX3REGU,
0086 AB8500_VAUX1SEL,
0087 AB8500_VAUX2SEL,
0088 AB8500_VRF1VAUX3SEL,
0089 AB8500_REGUCTRL2SPARE,
0090 AB8500_REGUCTRLDISCH,
0091 AB8500_REGUCTRLDISCH2,
0092 AB8500_NUM_REGULATOR_REGISTERS,
0093 };
0094
0095
0096 enum ab8505_regulator_reg {
0097 AB8505_REGUREQUESTCTRL1,
0098 AB8505_REGUREQUESTCTRL2,
0099 AB8505_REGUREQUESTCTRL3,
0100 AB8505_REGUREQUESTCTRL4,
0101 AB8505_REGUSYSCLKREQ1HPVALID1,
0102 AB8505_REGUSYSCLKREQ1HPVALID2,
0103 AB8505_REGUHWHPREQ1VALID1,
0104 AB8505_REGUHWHPREQ1VALID2,
0105 AB8505_REGUHWHPREQ2VALID1,
0106 AB8505_REGUHWHPREQ2VALID2,
0107 AB8505_REGUSWHPREQVALID1,
0108 AB8505_REGUSWHPREQVALID2,
0109 AB8505_REGUSYSCLKREQVALID1,
0110 AB8505_REGUSYSCLKREQVALID2,
0111 AB8505_REGUVAUX4REQVALID,
0112 AB8505_REGUMISC1,
0113 AB8505_VAUDIOSUPPLY,
0114 AB8505_REGUCTRL1VAMIC,
0115 AB8505_VSMPSAREGU,
0116 AB8505_VSMPSBREGU,
0117 AB8505_VSAFEREGU,
0118 AB8505_VPLLVANAREGU,
0119 AB8505_EXTSUPPLYREGU,
0120 AB8505_VAUX12REGU,
0121 AB8505_VRF1VAUX3REGU,
0122 AB8505_VSMPSASEL1,
0123 AB8505_VSMPSASEL2,
0124 AB8505_VSMPSASEL3,
0125 AB8505_VSMPSBSEL1,
0126 AB8505_VSMPSBSEL2,
0127 AB8505_VSMPSBSEL3,
0128 AB8505_VSAFESEL1,
0129 AB8505_VSAFESEL2,
0130 AB8505_VSAFESEL3,
0131 AB8505_VAUX1SEL,
0132 AB8505_VAUX2SEL,
0133 AB8505_VRF1VAUX3SEL,
0134 AB8505_VAUX4REQCTRL,
0135 AB8505_VAUX4REGU,
0136 AB8505_VAUX4SEL,
0137 AB8505_REGUCTRLDISCH,
0138 AB8505_REGUCTRLDISCH2,
0139 AB8505_REGUCTRLDISCH3,
0140 AB8505_CTRLVAUX5,
0141 AB8505_CTRLVAUX6,
0142 AB8505_NUM_REGULATOR_REGISTERS,
0143 };
0144
0145
0146
0147
0148
0149
0150
0151 struct ab8500_shared_mode {
0152 struct ab8500_regulator_info *shared_regulator;
0153 bool lp_mode_req;
0154 };
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178 struct ab8500_regulator_info {
0179 struct device *dev;
0180 struct regulator_desc desc;
0181 struct ab8500_shared_mode *shared_mode;
0182 int load_lp_uA;
0183 u8 update_bank;
0184 u8 update_reg;
0185 u8 update_mask;
0186 u8 update_val;
0187 u8 update_val_idle;
0188 u8 update_val_normal;
0189 u8 mode_bank;
0190 u8 mode_reg;
0191 u8 mode_mask;
0192 u8 mode_val_idle;
0193 u8 mode_val_normal;
0194 u8 voltage_bank;
0195 u8 voltage_reg;
0196 u8 voltage_mask;
0197 };
0198
0199
0200 static const unsigned int ldo_vauxn_voltages[] = {
0201 1100000,
0202 1200000,
0203 1300000,
0204 1400000,
0205 1500000,
0206 1800000,
0207 1850000,
0208 1900000,
0209 2500000,
0210 2650000,
0211 2700000,
0212 2750000,
0213 2800000,
0214 2900000,
0215 3000000,
0216 3300000,
0217 };
0218
0219 static const unsigned int ldo_vaux3_voltages[] = {
0220 1200000,
0221 1500000,
0222 1800000,
0223 2100000,
0224 2500000,
0225 2750000,
0226 2790000,
0227 2910000,
0228 };
0229
0230 static const unsigned int ldo_vaux56_voltages[] = {
0231 1800000,
0232 1050000,
0233 1100000,
0234 1200000,
0235 1500000,
0236 2200000,
0237 2500000,
0238 2790000,
0239 };
0240
0241 static const unsigned int ldo_vintcore_voltages[] = {
0242 1200000,
0243 1225000,
0244 1250000,
0245 1275000,
0246 1300000,
0247 1325000,
0248 1350000,
0249 };
0250
0251 static const unsigned int fixed_1200000_voltage[] = {
0252 1200000,
0253 };
0254
0255 static const unsigned int fixed_1800000_voltage[] = {
0256 1800000,
0257 };
0258
0259 static const unsigned int fixed_2000000_voltage[] = {
0260 2000000,
0261 };
0262
0263 static const unsigned int fixed_2050000_voltage[] = {
0264 2050000,
0265 };
0266
0267 static const unsigned int ldo_vana_voltages[] = {
0268 1050000,
0269 1075000,
0270 1100000,
0271 1125000,
0272 1150000,
0273 1175000,
0274 1200000,
0275 1225000,
0276 };
0277
0278 static const unsigned int ldo_vaudio_voltages[] = {
0279 2000000,
0280 2100000,
0281 2200000,
0282 2300000,
0283 2400000,
0284 2500000,
0285 2600000,
0286 2600000,
0287 };
0288
0289 static DEFINE_MUTEX(shared_mode_mutex);
0290 static struct ab8500_shared_mode ldo_anamic1_shared;
0291 static struct ab8500_shared_mode ldo_anamic2_shared;
0292
0293 static int ab8500_regulator_enable(struct regulator_dev *rdev)
0294 {
0295 int ret;
0296 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
0297
0298 if (info == NULL) {
0299 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
0300 return -EINVAL;
0301 }
0302
0303 ret = abx500_mask_and_set_register_interruptible(info->dev,
0304 info->update_bank, info->update_reg,
0305 info->update_mask, info->update_val);
0306 if (ret < 0) {
0307 dev_err(rdev_get_dev(rdev),
0308 "couldn't set enable bits for regulator\n");
0309 return ret;
0310 }
0311
0312 dev_vdbg(rdev_get_dev(rdev),
0313 "%s-enable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
0314 info->desc.name, info->update_bank, info->update_reg,
0315 info->update_mask, info->update_val);
0316
0317 return ret;
0318 }
0319
0320 static int ab8500_regulator_disable(struct regulator_dev *rdev)
0321 {
0322 int ret;
0323 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
0324
0325 if (info == NULL) {
0326 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
0327 return -EINVAL;
0328 }
0329
0330 ret = abx500_mask_and_set_register_interruptible(info->dev,
0331 info->update_bank, info->update_reg,
0332 info->update_mask, 0x0);
0333 if (ret < 0) {
0334 dev_err(rdev_get_dev(rdev),
0335 "couldn't set disable bits for regulator\n");
0336 return ret;
0337 }
0338
0339 dev_vdbg(rdev_get_dev(rdev),
0340 "%s-disable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
0341 info->desc.name, info->update_bank, info->update_reg,
0342 info->update_mask, 0x0);
0343
0344 return ret;
0345 }
0346
0347 static int ab8500_regulator_is_enabled(struct regulator_dev *rdev)
0348 {
0349 int ret;
0350 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
0351 u8 regval;
0352
0353 if (info == NULL) {
0354 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
0355 return -EINVAL;
0356 }
0357
0358 ret = abx500_get_register_interruptible(info->dev,
0359 info->update_bank, info->update_reg, ®val);
0360 if (ret < 0) {
0361 dev_err(rdev_get_dev(rdev),
0362 "couldn't read 0x%x register\n", info->update_reg);
0363 return ret;
0364 }
0365
0366 dev_vdbg(rdev_get_dev(rdev),
0367 "%s-is_enabled (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
0368 " 0x%x\n",
0369 info->desc.name, info->update_bank, info->update_reg,
0370 info->update_mask, regval);
0371
0372 if (regval & info->update_mask)
0373 return 1;
0374 else
0375 return 0;
0376 }
0377
0378 static unsigned int ab8500_regulator_get_optimum_mode(
0379 struct regulator_dev *rdev, int input_uV,
0380 int output_uV, int load_uA)
0381 {
0382 unsigned int mode;
0383
0384 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
0385
0386 if (info == NULL) {
0387 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
0388 return -EINVAL;
0389 }
0390
0391 if (load_uA <= info->load_lp_uA)
0392 mode = REGULATOR_MODE_IDLE;
0393 else
0394 mode = REGULATOR_MODE_NORMAL;
0395
0396 return mode;
0397 }
0398
0399 static int ab8500_regulator_set_mode(struct regulator_dev *rdev,
0400 unsigned int mode)
0401 {
0402 int ret = 0;
0403 u8 bank, reg, mask, val;
0404 bool lp_mode_req = false;
0405 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
0406
0407 if (info == NULL) {
0408 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
0409 return -EINVAL;
0410 }
0411
0412 if (info->mode_mask) {
0413 bank = info->mode_bank;
0414 reg = info->mode_reg;
0415 mask = info->mode_mask;
0416 } else {
0417 bank = info->update_bank;
0418 reg = info->update_reg;
0419 mask = info->update_mask;
0420 }
0421
0422 if (info->shared_mode)
0423 mutex_lock(&shared_mode_mutex);
0424
0425 switch (mode) {
0426 case REGULATOR_MODE_NORMAL:
0427 if (info->shared_mode)
0428 lp_mode_req = false;
0429
0430 if (info->mode_mask)
0431 val = info->mode_val_normal;
0432 else
0433 val = info->update_val_normal;
0434 break;
0435 case REGULATOR_MODE_IDLE:
0436 if (info->shared_mode) {
0437 struct ab8500_regulator_info *shared_regulator;
0438
0439 shared_regulator = info->shared_mode->shared_regulator;
0440 if (!shared_regulator->shared_mode->lp_mode_req) {
0441
0442 info->shared_mode->lp_mode_req = true;
0443 goto out_unlock;
0444 }
0445
0446 lp_mode_req = true;
0447 }
0448
0449 if (info->mode_mask)
0450 val = info->mode_val_idle;
0451 else
0452 val = info->update_val_idle;
0453 break;
0454 default:
0455 ret = -EINVAL;
0456 goto out_unlock;
0457 }
0458
0459 if (info->mode_mask || ab8500_regulator_is_enabled(rdev)) {
0460 ret = abx500_mask_and_set_register_interruptible(info->dev,
0461 bank, reg, mask, val);
0462 if (ret < 0) {
0463 dev_err(rdev_get_dev(rdev),
0464 "couldn't set regulator mode\n");
0465 goto out_unlock;
0466 }
0467
0468 dev_vdbg(rdev_get_dev(rdev),
0469 "%s-set_mode (bank, reg, mask, value): "
0470 "0x%x, 0x%x, 0x%x, 0x%x\n",
0471 info->desc.name, bank, reg,
0472 mask, val);
0473 }
0474
0475 if (!info->mode_mask)
0476 info->update_val = val;
0477
0478 if (info->shared_mode)
0479 info->shared_mode->lp_mode_req = lp_mode_req;
0480
0481 out_unlock:
0482 if (info->shared_mode)
0483 mutex_unlock(&shared_mode_mutex);
0484
0485 return ret;
0486 }
0487
0488 static unsigned int ab8500_regulator_get_mode(struct regulator_dev *rdev)
0489 {
0490 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
0491 int ret;
0492 u8 val;
0493 u8 val_normal;
0494 u8 val_idle;
0495
0496 if (info == NULL) {
0497 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
0498 return -EINVAL;
0499 }
0500
0501
0502 if (info->shared_mode) {
0503 if (info->shared_mode->lp_mode_req)
0504 return REGULATOR_MODE_IDLE;
0505 else
0506 return REGULATOR_MODE_NORMAL;
0507 }
0508
0509 if (info->mode_mask) {
0510
0511 ret = abx500_get_register_interruptible(info->dev,
0512 info->mode_bank, info->mode_reg, &val);
0513 val = val & info->mode_mask;
0514
0515 val_normal = info->mode_val_normal;
0516 val_idle = info->mode_val_idle;
0517 } else {
0518
0519 val = info->update_val;
0520 val_normal = info->update_val_normal;
0521 val_idle = info->update_val_idle;
0522 }
0523
0524 if (val == val_normal)
0525 ret = REGULATOR_MODE_NORMAL;
0526 else if (val == val_idle)
0527 ret = REGULATOR_MODE_IDLE;
0528 else
0529 ret = -EINVAL;
0530
0531 return ret;
0532 }
0533
0534 static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev)
0535 {
0536 int ret, voltage_shift;
0537 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
0538 u8 regval;
0539
0540 if (info == NULL) {
0541 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
0542 return -EINVAL;
0543 }
0544
0545 voltage_shift = ffs(info->voltage_mask) - 1;
0546
0547 ret = abx500_get_register_interruptible(info->dev,
0548 info->voltage_bank, info->voltage_reg, ®val);
0549 if (ret < 0) {
0550 dev_err(rdev_get_dev(rdev),
0551 "couldn't read voltage reg for regulator\n");
0552 return ret;
0553 }
0554
0555 dev_vdbg(rdev_get_dev(rdev),
0556 "%s-get_voltage (bank, reg, mask, shift, value): "
0557 "0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n",
0558 info->desc.name, info->voltage_bank,
0559 info->voltage_reg, info->voltage_mask,
0560 voltage_shift, regval);
0561
0562 return (regval & info->voltage_mask) >> voltage_shift;
0563 }
0564
0565 static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev,
0566 unsigned selector)
0567 {
0568 int ret, voltage_shift;
0569 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
0570 u8 regval;
0571
0572 if (info == NULL) {
0573 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
0574 return -EINVAL;
0575 }
0576
0577 voltage_shift = ffs(info->voltage_mask) - 1;
0578
0579
0580 regval = (u8)selector << voltage_shift;
0581 ret = abx500_mask_and_set_register_interruptible(info->dev,
0582 info->voltage_bank, info->voltage_reg,
0583 info->voltage_mask, regval);
0584 if (ret < 0)
0585 dev_err(rdev_get_dev(rdev),
0586 "couldn't set voltage reg for regulator\n");
0587
0588 dev_vdbg(rdev_get_dev(rdev),
0589 "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
0590 " 0x%x\n",
0591 info->desc.name, info->voltage_bank, info->voltage_reg,
0592 info->voltage_mask, regval);
0593
0594 return ret;
0595 }
0596
0597 static const struct regulator_ops ab8500_regulator_volt_mode_ops = {
0598 .enable = ab8500_regulator_enable,
0599 .disable = ab8500_regulator_disable,
0600 .is_enabled = ab8500_regulator_is_enabled,
0601 .get_optimum_mode = ab8500_regulator_get_optimum_mode,
0602 .set_mode = ab8500_regulator_set_mode,
0603 .get_mode = ab8500_regulator_get_mode,
0604 .get_voltage_sel = ab8500_regulator_get_voltage_sel,
0605 .set_voltage_sel = ab8500_regulator_set_voltage_sel,
0606 .list_voltage = regulator_list_voltage_table,
0607 };
0608
0609 static const struct regulator_ops ab8500_regulator_volt_ops = {
0610 .enable = ab8500_regulator_enable,
0611 .disable = ab8500_regulator_disable,
0612 .is_enabled = ab8500_regulator_is_enabled,
0613 .get_voltage_sel = ab8500_regulator_get_voltage_sel,
0614 .set_voltage_sel = ab8500_regulator_set_voltage_sel,
0615 .list_voltage = regulator_list_voltage_table,
0616 };
0617
0618 static const struct regulator_ops ab8500_regulator_mode_ops = {
0619 .enable = ab8500_regulator_enable,
0620 .disable = ab8500_regulator_disable,
0621 .is_enabled = ab8500_regulator_is_enabled,
0622 .get_optimum_mode = ab8500_regulator_get_optimum_mode,
0623 .set_mode = ab8500_regulator_set_mode,
0624 .get_mode = ab8500_regulator_get_mode,
0625 .list_voltage = regulator_list_voltage_table,
0626 };
0627
0628 static const struct regulator_ops ab8500_regulator_ops = {
0629 .enable = ab8500_regulator_enable,
0630 .disable = ab8500_regulator_disable,
0631 .is_enabled = ab8500_regulator_is_enabled,
0632 .list_voltage = regulator_list_voltage_table,
0633 };
0634
0635 static const struct regulator_ops ab8500_regulator_anamic_mode_ops = {
0636 .enable = ab8500_regulator_enable,
0637 .disable = ab8500_regulator_disable,
0638 .is_enabled = ab8500_regulator_is_enabled,
0639 .set_mode = ab8500_regulator_set_mode,
0640 .get_mode = ab8500_regulator_get_mode,
0641 .list_voltage = regulator_list_voltage_table,
0642 };
0643
0644
0645 static struct ab8500_regulator_info
0646 ab8500_regulator_info[AB8500_NUM_REGULATORS] = {
0647
0648
0649
0650
0651
0652
0653 [AB8500_LDO_AUX1] = {
0654 .desc = {
0655 .name = "LDO-AUX1",
0656 .ops = &ab8500_regulator_volt_mode_ops,
0657 .type = REGULATOR_VOLTAGE,
0658 .id = AB8500_LDO_AUX1,
0659 .owner = THIS_MODULE,
0660 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
0661 .volt_table = ldo_vauxn_voltages,
0662 .enable_time = 200,
0663 .supply_name = "vin",
0664 },
0665 .load_lp_uA = 5000,
0666 .update_bank = 0x04,
0667 .update_reg = 0x09,
0668 .update_mask = 0x03,
0669 .update_val = 0x01,
0670 .update_val_idle = 0x03,
0671 .update_val_normal = 0x01,
0672 .voltage_bank = 0x04,
0673 .voltage_reg = 0x1f,
0674 .voltage_mask = 0x0f,
0675 },
0676 [AB8500_LDO_AUX2] = {
0677 .desc = {
0678 .name = "LDO-AUX2",
0679 .ops = &ab8500_regulator_volt_mode_ops,
0680 .type = REGULATOR_VOLTAGE,
0681 .id = AB8500_LDO_AUX2,
0682 .owner = THIS_MODULE,
0683 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
0684 .volt_table = ldo_vauxn_voltages,
0685 .enable_time = 200,
0686 .supply_name = "vin",
0687 },
0688 .load_lp_uA = 5000,
0689 .update_bank = 0x04,
0690 .update_reg = 0x09,
0691 .update_mask = 0x0c,
0692 .update_val = 0x04,
0693 .update_val_idle = 0x0c,
0694 .update_val_normal = 0x04,
0695 .voltage_bank = 0x04,
0696 .voltage_reg = 0x20,
0697 .voltage_mask = 0x0f,
0698 },
0699 [AB8500_LDO_AUX3] = {
0700 .desc = {
0701 .name = "LDO-AUX3",
0702 .ops = &ab8500_regulator_volt_mode_ops,
0703 .type = REGULATOR_VOLTAGE,
0704 .id = AB8500_LDO_AUX3,
0705 .owner = THIS_MODULE,
0706 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
0707 .volt_table = ldo_vaux3_voltages,
0708 .enable_time = 450,
0709 .supply_name = "vin",
0710 },
0711 .load_lp_uA = 5000,
0712 .update_bank = 0x04,
0713 .update_reg = 0x0a,
0714 .update_mask = 0x03,
0715 .update_val = 0x01,
0716 .update_val_idle = 0x03,
0717 .update_val_normal = 0x01,
0718 .voltage_bank = 0x04,
0719 .voltage_reg = 0x21,
0720 .voltage_mask = 0x07,
0721 },
0722 [AB8500_LDO_INTCORE] = {
0723 .desc = {
0724 .name = "LDO-INTCORE",
0725 .ops = &ab8500_regulator_volt_mode_ops,
0726 .type = REGULATOR_VOLTAGE,
0727 .id = AB8500_LDO_INTCORE,
0728 .owner = THIS_MODULE,
0729 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
0730 .volt_table = ldo_vintcore_voltages,
0731 .enable_time = 750,
0732 },
0733 .load_lp_uA = 5000,
0734 .update_bank = 0x03,
0735 .update_reg = 0x80,
0736 .update_mask = 0x44,
0737 .update_val = 0x44,
0738 .update_val_idle = 0x44,
0739 .update_val_normal = 0x04,
0740 .voltage_bank = 0x03,
0741 .voltage_reg = 0x80,
0742 .voltage_mask = 0x38,
0743 },
0744
0745
0746
0747
0748
0749
0750 [AB8500_LDO_TVOUT] = {
0751 .desc = {
0752 .name = "LDO-TVOUT",
0753 .ops = &ab8500_regulator_mode_ops,
0754 .type = REGULATOR_VOLTAGE,
0755 .id = AB8500_LDO_TVOUT,
0756 .owner = THIS_MODULE,
0757 .n_voltages = 1,
0758 .volt_table = fixed_2000000_voltage,
0759 .enable_time = 500,
0760 },
0761 .load_lp_uA = 1000,
0762 .update_bank = 0x03,
0763 .update_reg = 0x80,
0764 .update_mask = 0x82,
0765 .update_val = 0x02,
0766 .update_val_idle = 0x82,
0767 .update_val_normal = 0x02,
0768 },
0769 [AB8500_LDO_AUDIO] = {
0770 .desc = {
0771 .name = "LDO-AUDIO",
0772 .ops = &ab8500_regulator_ops,
0773 .type = REGULATOR_VOLTAGE,
0774 .id = AB8500_LDO_AUDIO,
0775 .owner = THIS_MODULE,
0776 .n_voltages = 1,
0777 .enable_time = 140,
0778 .volt_table = fixed_2000000_voltage,
0779 },
0780 .update_bank = 0x03,
0781 .update_reg = 0x83,
0782 .update_mask = 0x02,
0783 .update_val = 0x02,
0784 },
0785 [AB8500_LDO_ANAMIC1] = {
0786 .desc = {
0787 .name = "LDO-ANAMIC1",
0788 .ops = &ab8500_regulator_ops,
0789 .type = REGULATOR_VOLTAGE,
0790 .id = AB8500_LDO_ANAMIC1,
0791 .owner = THIS_MODULE,
0792 .n_voltages = 1,
0793 .enable_time = 500,
0794 .volt_table = fixed_2050000_voltage,
0795 },
0796 .update_bank = 0x03,
0797 .update_reg = 0x83,
0798 .update_mask = 0x08,
0799 .update_val = 0x08,
0800 },
0801 [AB8500_LDO_ANAMIC2] = {
0802 .desc = {
0803 .name = "LDO-ANAMIC2",
0804 .ops = &ab8500_regulator_ops,
0805 .type = REGULATOR_VOLTAGE,
0806 .id = AB8500_LDO_ANAMIC2,
0807 .owner = THIS_MODULE,
0808 .n_voltages = 1,
0809 .enable_time = 500,
0810 .volt_table = fixed_2050000_voltage,
0811 },
0812 .update_bank = 0x03,
0813 .update_reg = 0x83,
0814 .update_mask = 0x10,
0815 .update_val = 0x10,
0816 },
0817 [AB8500_LDO_DMIC] = {
0818 .desc = {
0819 .name = "LDO-DMIC",
0820 .ops = &ab8500_regulator_ops,
0821 .type = REGULATOR_VOLTAGE,
0822 .id = AB8500_LDO_DMIC,
0823 .owner = THIS_MODULE,
0824 .n_voltages = 1,
0825 .enable_time = 420,
0826 .volt_table = fixed_1800000_voltage,
0827 },
0828 .update_bank = 0x03,
0829 .update_reg = 0x83,
0830 .update_mask = 0x04,
0831 .update_val = 0x04,
0832 },
0833
0834
0835
0836
0837 [AB8500_LDO_ANA] = {
0838 .desc = {
0839 .name = "LDO-ANA",
0840 .ops = &ab8500_regulator_mode_ops,
0841 .type = REGULATOR_VOLTAGE,
0842 .id = AB8500_LDO_ANA,
0843 .owner = THIS_MODULE,
0844 .n_voltages = 1,
0845 .enable_time = 140,
0846 .volt_table = fixed_1200000_voltage,
0847 },
0848 .load_lp_uA = 1000,
0849 .update_bank = 0x04,
0850 .update_reg = 0x06,
0851 .update_mask = 0x0c,
0852 .update_val = 0x04,
0853 .update_val_idle = 0x0c,
0854 .update_val_normal = 0x04,
0855 },
0856 };
0857
0858
0859 static struct ab8500_regulator_info
0860 ab8505_regulator_info[AB8505_NUM_REGULATORS] = {
0861
0862
0863
0864
0865
0866
0867 [AB8505_LDO_AUX1] = {
0868 .desc = {
0869 .name = "LDO-AUX1",
0870 .ops = &ab8500_regulator_volt_mode_ops,
0871 .type = REGULATOR_VOLTAGE,
0872 .id = AB8505_LDO_AUX1,
0873 .owner = THIS_MODULE,
0874 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
0875 .volt_table = ldo_vauxn_voltages,
0876 },
0877 .load_lp_uA = 5000,
0878 .update_bank = 0x04,
0879 .update_reg = 0x09,
0880 .update_mask = 0x03,
0881 .update_val = 0x01,
0882 .update_val_idle = 0x03,
0883 .update_val_normal = 0x01,
0884 .voltage_bank = 0x04,
0885 .voltage_reg = 0x1f,
0886 .voltage_mask = 0x0f,
0887 },
0888 [AB8505_LDO_AUX2] = {
0889 .desc = {
0890 .name = "LDO-AUX2",
0891 .ops = &ab8500_regulator_volt_mode_ops,
0892 .type = REGULATOR_VOLTAGE,
0893 .id = AB8505_LDO_AUX2,
0894 .owner = THIS_MODULE,
0895 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
0896 .volt_table = ldo_vauxn_voltages,
0897 },
0898 .load_lp_uA = 5000,
0899 .update_bank = 0x04,
0900 .update_reg = 0x09,
0901 .update_mask = 0x0c,
0902 .update_val = 0x04,
0903 .update_val_idle = 0x0c,
0904 .update_val_normal = 0x04,
0905 .voltage_bank = 0x04,
0906 .voltage_reg = 0x20,
0907 .voltage_mask = 0x0f,
0908 },
0909 [AB8505_LDO_AUX3] = {
0910 .desc = {
0911 .name = "LDO-AUX3",
0912 .ops = &ab8500_regulator_volt_mode_ops,
0913 .type = REGULATOR_VOLTAGE,
0914 .id = AB8505_LDO_AUX3,
0915 .owner = THIS_MODULE,
0916 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
0917 .volt_table = ldo_vaux3_voltages,
0918 },
0919 .load_lp_uA = 5000,
0920 .update_bank = 0x04,
0921 .update_reg = 0x0a,
0922 .update_mask = 0x03,
0923 .update_val = 0x01,
0924 .update_val_idle = 0x03,
0925 .update_val_normal = 0x01,
0926 .voltage_bank = 0x04,
0927 .voltage_reg = 0x21,
0928 .voltage_mask = 0x07,
0929 },
0930 [AB8505_LDO_AUX4] = {
0931 .desc = {
0932 .name = "LDO-AUX4",
0933 .ops = &ab8500_regulator_volt_mode_ops,
0934 .type = REGULATOR_VOLTAGE,
0935 .id = AB8505_LDO_AUX4,
0936 .owner = THIS_MODULE,
0937 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
0938 .volt_table = ldo_vauxn_voltages,
0939 },
0940 .load_lp_uA = 5000,
0941
0942 .update_bank = 0x04,
0943 .update_reg = 0x2e,
0944 .update_mask = 0x03,
0945 .update_val = 0x01,
0946 .update_val_idle = 0x03,
0947 .update_val_normal = 0x01,
0948
0949 .voltage_bank = 0x04,
0950 .voltage_reg = 0x2f,
0951 .voltage_mask = 0x0f,
0952 },
0953 [AB8505_LDO_AUX5] = {
0954 .desc = {
0955 .name = "LDO-AUX5",
0956 .ops = &ab8500_regulator_volt_mode_ops,
0957 .type = REGULATOR_VOLTAGE,
0958 .id = AB8505_LDO_AUX5,
0959 .owner = THIS_MODULE,
0960 .n_voltages = ARRAY_SIZE(ldo_vaux56_voltages),
0961 .volt_table = ldo_vaux56_voltages,
0962 },
0963 .load_lp_uA = 2000,
0964
0965 .update_bank = 0x01,
0966 .update_reg = 0x55,
0967 .update_mask = 0x18,
0968 .update_val = 0x10,
0969 .update_val_idle = 0x18,
0970 .update_val_normal = 0x10,
0971 .voltage_bank = 0x01,
0972 .voltage_reg = 0x55,
0973 .voltage_mask = 0x07,
0974 },
0975 [AB8505_LDO_AUX6] = {
0976 .desc = {
0977 .name = "LDO-AUX6",
0978 .ops = &ab8500_regulator_volt_mode_ops,
0979 .type = REGULATOR_VOLTAGE,
0980 .id = AB8505_LDO_AUX6,
0981 .owner = THIS_MODULE,
0982 .n_voltages = ARRAY_SIZE(ldo_vaux56_voltages),
0983 .volt_table = ldo_vaux56_voltages,
0984 },
0985 .load_lp_uA = 2000,
0986
0987 .update_bank = 0x01,
0988 .update_reg = 0x56,
0989 .update_mask = 0x18,
0990 .update_val = 0x10,
0991 .update_val_idle = 0x18,
0992 .update_val_normal = 0x10,
0993 .voltage_bank = 0x01,
0994 .voltage_reg = 0x56,
0995 .voltage_mask = 0x07,
0996 },
0997 [AB8505_LDO_INTCORE] = {
0998 .desc = {
0999 .name = "LDO-INTCORE",
1000 .ops = &ab8500_regulator_volt_mode_ops,
1001 .type = REGULATOR_VOLTAGE,
1002 .id = AB8505_LDO_INTCORE,
1003 .owner = THIS_MODULE,
1004 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
1005 .volt_table = ldo_vintcore_voltages,
1006 },
1007 .load_lp_uA = 5000,
1008 .update_bank = 0x03,
1009 .update_reg = 0x80,
1010 .update_mask = 0x44,
1011 .update_val = 0x04,
1012 .update_val_idle = 0x44,
1013 .update_val_normal = 0x04,
1014 .voltage_bank = 0x03,
1015 .voltage_reg = 0x80,
1016 .voltage_mask = 0x38,
1017 },
1018
1019
1020
1021
1022
1023
1024 [AB8505_LDO_ADC] = {
1025 .desc = {
1026 .name = "LDO-ADC",
1027 .ops = &ab8500_regulator_mode_ops,
1028 .type = REGULATOR_VOLTAGE,
1029 .id = AB8505_LDO_ADC,
1030 .owner = THIS_MODULE,
1031 .n_voltages = 1,
1032 .volt_table = fixed_2000000_voltage,
1033 .enable_time = 10000,
1034 },
1035 .load_lp_uA = 1000,
1036 .update_bank = 0x03,
1037 .update_reg = 0x80,
1038 .update_mask = 0x82,
1039 .update_val = 0x02,
1040 .update_val_idle = 0x82,
1041 .update_val_normal = 0x02,
1042 },
1043 [AB8505_LDO_AUDIO] = {
1044 .desc = {
1045 .name = "LDO-AUDIO",
1046 .ops = &ab8500_regulator_volt_ops,
1047 .type = REGULATOR_VOLTAGE,
1048 .id = AB8505_LDO_AUDIO,
1049 .owner = THIS_MODULE,
1050 .n_voltages = ARRAY_SIZE(ldo_vaudio_voltages),
1051 .volt_table = ldo_vaudio_voltages,
1052 },
1053 .update_bank = 0x03,
1054 .update_reg = 0x83,
1055 .update_mask = 0x02,
1056 .update_val = 0x02,
1057 .voltage_bank = 0x01,
1058 .voltage_reg = 0x57,
1059 .voltage_mask = 0x70,
1060 },
1061 [AB8505_LDO_ANAMIC1] = {
1062 .desc = {
1063 .name = "LDO-ANAMIC1",
1064 .ops = &ab8500_regulator_anamic_mode_ops,
1065 .type = REGULATOR_VOLTAGE,
1066 .id = AB8505_LDO_ANAMIC1,
1067 .owner = THIS_MODULE,
1068 .n_voltages = 1,
1069 .volt_table = fixed_2050000_voltage,
1070 },
1071 .shared_mode = &ldo_anamic1_shared,
1072 .update_bank = 0x03,
1073 .update_reg = 0x83,
1074 .update_mask = 0x08,
1075 .update_val = 0x08,
1076 .mode_bank = 0x01,
1077 .mode_reg = 0x54,
1078 .mode_mask = 0x04,
1079 .mode_val_idle = 0x04,
1080 .mode_val_normal = 0x00,
1081 },
1082 [AB8505_LDO_ANAMIC2] = {
1083 .desc = {
1084 .name = "LDO-ANAMIC2",
1085 .ops = &ab8500_regulator_anamic_mode_ops,
1086 .type = REGULATOR_VOLTAGE,
1087 .id = AB8505_LDO_ANAMIC2,
1088 .owner = THIS_MODULE,
1089 .n_voltages = 1,
1090 .volt_table = fixed_2050000_voltage,
1091 },
1092 .shared_mode = &ldo_anamic2_shared,
1093 .update_bank = 0x03,
1094 .update_reg = 0x83,
1095 .update_mask = 0x10,
1096 .update_val = 0x10,
1097 .mode_bank = 0x01,
1098 .mode_reg = 0x54,
1099 .mode_mask = 0x04,
1100 .mode_val_idle = 0x04,
1101 .mode_val_normal = 0x00,
1102 },
1103 [AB8505_LDO_AUX8] = {
1104 .desc = {
1105 .name = "LDO-AUX8",
1106 .ops = &ab8500_regulator_ops,
1107 .type = REGULATOR_VOLTAGE,
1108 .id = AB8505_LDO_AUX8,
1109 .owner = THIS_MODULE,
1110 .n_voltages = 1,
1111 .volt_table = fixed_1800000_voltage,
1112 },
1113 .update_bank = 0x03,
1114 .update_reg = 0x83,
1115 .update_mask = 0x04,
1116 .update_val = 0x04,
1117 },
1118
1119
1120
1121 [AB8505_LDO_ANA] = {
1122 .desc = {
1123 .name = "LDO-ANA",
1124 .ops = &ab8500_regulator_volt_mode_ops,
1125 .type = REGULATOR_VOLTAGE,
1126 .id = AB8505_LDO_ANA,
1127 .owner = THIS_MODULE,
1128 .n_voltages = ARRAY_SIZE(ldo_vana_voltages),
1129 .volt_table = ldo_vana_voltages,
1130 },
1131 .load_lp_uA = 1000,
1132 .update_bank = 0x04,
1133 .update_reg = 0x06,
1134 .update_mask = 0x0c,
1135 .update_val = 0x04,
1136 .update_val_idle = 0x0c,
1137 .update_val_normal = 0x04,
1138 .voltage_bank = 0x04,
1139 .voltage_reg = 0x29,
1140 .voltage_mask = 0x7,
1141 },
1142 };
1143
1144 static struct ab8500_shared_mode ldo_anamic1_shared = {
1145 .shared_regulator = &ab8505_regulator_info[AB8505_LDO_ANAMIC2],
1146 };
1147
1148 static struct ab8500_shared_mode ldo_anamic2_shared = {
1149 .shared_regulator = &ab8505_regulator_info[AB8505_LDO_ANAMIC1],
1150 };
1151
1152 struct ab8500_reg_init {
1153 u8 bank;
1154 u8 addr;
1155 u8 mask;
1156 };
1157
1158 #define REG_INIT(_id, _bank, _addr, _mask) \
1159 [_id] = { \
1160 .bank = _bank, \
1161 .addr = _addr, \
1162 .mask = _mask, \
1163 }
1164
1165
1166 static struct ab8500_reg_init ab8500_reg_init[] = {
1167
1168
1169
1170
1171 REG_INIT(AB8500_REGUREQUESTCTRL2, 0x03, 0x04, 0xf0),
1172
1173
1174
1175
1176
1177
1178 REG_INIT(AB8500_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
1179
1180
1181
1182
1183 REG_INIT(AB8500_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
1184
1185
1186
1187
1188
1189
1190 REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xe8),
1191
1192
1193
1194
1195
1196 REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x70),
1197
1198
1199
1200
1201
1202
1203 REG_INIT(AB8500_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xe8),
1204
1205
1206
1207
1208
1209 REG_INIT(AB8500_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x07),
1210
1211
1212
1213
1214
1215
1216 REG_INIT(AB8500_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xe8),
1217
1218
1219
1220
1221
1222 REG_INIT(AB8500_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x07),
1223
1224
1225
1226
1227 REG_INIT(AB8500_REGUSWHPREQVALID1, 0x03, 0x0d, 0xa0),
1228
1229
1230
1231
1232
1233
1234
1235 REG_INIT(AB8500_REGUSWHPREQVALID2, 0x03, 0x0e, 0x1f),
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245 REG_INIT(AB8500_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xfe),
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255 REG_INIT(AB8500_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xfe),
1256
1257
1258
1259
1260
1261
1262
1263 REG_INIT(AB8500_REGUMISC1, 0x03, 0x80, 0xfe),
1264
1265
1266
1267
1268
1269
1270 REG_INIT(AB8500_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
1271
1272
1273
1274
1275 REG_INIT(AB8500_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
1276
1277
1278
1279
1280 REG_INIT(AB8500_VPLLVANAREGU, 0x04, 0x06, 0x0f),
1281
1282
1283
1284
1285 REG_INIT(AB8500_VREFDDR, 0x04, 0x07, 0x03),
1286
1287
1288
1289
1290
1291
1292
1293 REG_INIT(AB8500_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
1294
1295
1296
1297
1298 REG_INIT(AB8500_VAUX12REGU, 0x04, 0x09, 0x0f),
1299
1300
1301
1302 REG_INIT(AB8500_VRF1VAUX3REGU, 0x04, 0x0a, 0x03),
1303
1304
1305
1306 REG_INIT(AB8500_VAUX1SEL, 0x04, 0x1f, 0x0f),
1307
1308
1309
1310 REG_INIT(AB8500_VAUX2SEL, 0x04, 0x20, 0x0f),
1311
1312
1313
1314 REG_INIT(AB8500_VRF1VAUX3SEL, 0x04, 0x21, 0x07),
1315
1316
1317
1318 REG_INIT(AB8500_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
1319
1320
1321
1322
1323
1324
1325
1326
1327 REG_INIT(AB8500_REGUCTRLDISCH, 0x04, 0x43, 0xfc),
1328
1329
1330
1331
1332
1333 REG_INIT(AB8500_REGUCTRLDISCH2, 0x04, 0x44, 0x16),
1334 };
1335
1336
1337 static struct ab8500_reg_init ab8505_reg_init[] = {
1338
1339
1340
1341
1342
1343
1344 REG_INIT(AB8505_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
1345
1346
1347
1348
1349
1350 REG_INIT(AB8505_REGUREQUESTCTRL2, 0x03, 0x04, 0x3f),
1351
1352
1353
1354
1355 REG_INIT(AB8505_REGUREQUESTCTRL3, 0x03, 0x05, 0xf0),
1356
1357
1358
1359
1360 REG_INIT(AB8505_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371 REG_INIT(AB8505_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
1372
1373
1374
1375
1376
1377
1378 REG_INIT(AB8505_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x0f),
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389 REG_INIT(AB8505_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
1390
1391
1392
1393 REG_INIT(AB8505_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x08),
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404 REG_INIT(AB8505_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
1405
1406
1407
1408 REG_INIT(AB8505_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x08),
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419 REG_INIT(AB8505_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
1420
1421
1422
1423
1424
1425 REG_INIT(AB8505_REGUSWHPREQVALID2, 0x03, 0x0e, 0x23),
1426
1427
1428
1429
1430
1431 REG_INIT(AB8505_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0x0e),
1432
1433
1434
1435
1436
1437 REG_INIT(AB8505_REGUSYSCLKREQVALID2, 0x03, 0x10, 0x0e),
1438
1439
1440
1441
1442
1443
1444 REG_INIT(AB8505_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
1445
1446
1447
1448
1449
1450
1451
1452 REG_INIT(AB8505_REGUMISC1, 0x03, 0x80, 0xfe),
1453
1454
1455
1456
1457
1458
1459 REG_INIT(AB8505_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
1460
1461
1462
1463
1464 REG_INIT(AB8505_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
1465
1466
1467
1468
1469
1470
1471 REG_INIT(AB8505_VSMPSAREGU, 0x04, 0x03, 0x3f),
1472
1473
1474
1475
1476
1477
1478 REG_INIT(AB8505_VSMPSBREGU, 0x04, 0x04, 0x3f),
1479
1480
1481
1482
1483
1484
1485 REG_INIT(AB8505_VSAFEREGU, 0x04, 0x05, 0x3f),
1486
1487
1488
1489
1490 REG_INIT(AB8505_VPLLVANAREGU, 0x04, 0x06, 0x0f),
1491
1492
1493
1494
1495
1496
1497
1498 REG_INIT(AB8505_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
1499
1500
1501
1502
1503 REG_INIT(AB8505_VAUX12REGU, 0x04, 0x09, 0x0f),
1504
1505
1506
1507 REG_INIT(AB8505_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
1508
1509
1510
1511 REG_INIT(AB8505_VSMPSASEL1, 0x04, 0x13, 0x3f),
1512
1513
1514
1515 REG_INIT(AB8505_VSMPSASEL2, 0x04, 0x14, 0x3f),
1516
1517
1518
1519 REG_INIT(AB8505_VSMPSASEL3, 0x04, 0x15, 0x3f),
1520
1521
1522
1523 REG_INIT(AB8505_VSMPSBSEL1, 0x04, 0x17, 0x3f),
1524
1525
1526
1527 REG_INIT(AB8505_VSMPSBSEL2, 0x04, 0x18, 0x3f),
1528
1529
1530
1531 REG_INIT(AB8505_VSMPSBSEL3, 0x04, 0x19, 0x3f),
1532
1533
1534
1535 REG_INIT(AB8505_VSAFESEL1, 0x04, 0x1b, 0x7f),
1536
1537
1538
1539 REG_INIT(AB8505_VSAFESEL2, 0x04, 0x1c, 0x7f),
1540
1541
1542
1543 REG_INIT(AB8505_VSAFESEL3, 0x04, 0x1d, 0x7f),
1544
1545
1546
1547 REG_INIT(AB8505_VAUX1SEL, 0x04, 0x1f, 0x0f),
1548
1549
1550
1551 REG_INIT(AB8505_VAUX2SEL, 0x04, 0x20, 0x0f),
1552
1553
1554
1555
1556 REG_INIT(AB8505_VRF1VAUX3SEL, 0x04, 0x21, 0x37),
1557
1558
1559
1560 REG_INIT(AB8505_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
1561
1562
1563
1564 REG_INIT(AB8505_VAUX4REGU, 0x04, 0x2e, 0x03),
1565
1566
1567
1568 REG_INIT(AB8505_VAUX4SEL, 0x04, 0x2f, 0x0f),
1569
1570
1571
1572
1573
1574
1575
1576
1577 REG_INIT(AB8505_REGUCTRLDISCH, 0x04, 0x43, 0xfc),
1578
1579
1580
1581
1582
1583 REG_INIT(AB8505_REGUCTRLDISCH2, 0x04, 0x44, 0x16),
1584
1585
1586
1587 REG_INIT(AB8505_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
1588
1589
1590
1591
1592
1593
1594
1595
1596 REG_INIT(AB8505_CTRLVAUX5, 0x01, 0x55, 0xff),
1597
1598
1599
1600
1601
1602
1603 REG_INIT(AB8505_CTRLVAUX6, 0x01, 0x56, 0x9f),
1604 };
1605
1606 static struct of_regulator_match ab8500_regulator_match[] = {
1607 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8500_LDO_AUX1, },
1608 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8500_LDO_AUX2, },
1609 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8500_LDO_AUX3, },
1610 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8500_LDO_INTCORE, },
1611 { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB8500_LDO_TVOUT, },
1612 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8500_LDO_AUDIO, },
1613 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8500_LDO_ANAMIC1, },
1614 { .name = "ab8500_ldo_anamic2", .driver_data = (void *) AB8500_LDO_ANAMIC2, },
1615 { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB8500_LDO_DMIC, },
1616 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8500_LDO_ANA, },
1617 };
1618
1619 static struct of_regulator_match ab8505_regulator_match[] = {
1620 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8505_LDO_AUX1, },
1621 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8505_LDO_AUX2, },
1622 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8505_LDO_AUX3, },
1623 { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB8505_LDO_AUX4, },
1624 { .name = "ab8500_ldo_aux5", .driver_data = (void *) AB8505_LDO_AUX5, },
1625 { .name = "ab8500_ldo_aux6", .driver_data = (void *) AB8505_LDO_AUX6, },
1626 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8505_LDO_INTCORE, },
1627 { .name = "ab8500_ldo_adc", .driver_data = (void *) AB8505_LDO_ADC, },
1628 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8505_LDO_AUDIO, },
1629 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8505_LDO_ANAMIC1, },
1630 { .name = "ab8500_ldo_anamic2", .driver_data = (void *) AB8505_LDO_ANAMIC2, },
1631 { .name = "ab8500_ldo_aux8", .driver_data = (void *) AB8505_LDO_AUX8, },
1632 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8505_LDO_ANA, },
1633 };
1634
1635 static struct {
1636 struct ab8500_regulator_info *info;
1637 int info_size;
1638 struct ab8500_reg_init *init;
1639 int init_size;
1640 struct of_regulator_match *match;
1641 int match_size;
1642 } abx500_regulator;
1643
1644 static void abx500_get_regulator_info(struct ab8500 *ab8500)
1645 {
1646 if (is_ab8505(ab8500)) {
1647 abx500_regulator.info = ab8505_regulator_info;
1648 abx500_regulator.info_size = ARRAY_SIZE(ab8505_regulator_info);
1649 abx500_regulator.init = ab8505_reg_init;
1650 abx500_regulator.init_size = AB8505_NUM_REGULATOR_REGISTERS;
1651 abx500_regulator.match = ab8505_regulator_match;
1652 abx500_regulator.match_size = ARRAY_SIZE(ab8505_regulator_match);
1653 } else {
1654 abx500_regulator.info = ab8500_regulator_info;
1655 abx500_regulator.info_size = ARRAY_SIZE(ab8500_regulator_info);
1656 abx500_regulator.init = ab8500_reg_init;
1657 abx500_regulator.init_size = AB8500_NUM_REGULATOR_REGISTERS;
1658 abx500_regulator.match = ab8500_regulator_match;
1659 abx500_regulator.match_size = ARRAY_SIZE(ab8500_regulator_match);
1660 }
1661 }
1662
1663 static int ab8500_regulator_register(struct platform_device *pdev,
1664 struct regulator_init_data *init_data,
1665 int id, struct device_node *np)
1666 {
1667 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
1668 struct ab8500_regulator_info *info = NULL;
1669 struct regulator_config config = { };
1670 struct regulator_dev *rdev;
1671
1672
1673 info = &abx500_regulator.info[id];
1674 info->dev = &pdev->dev;
1675
1676 config.dev = &pdev->dev;
1677 config.init_data = init_data;
1678 config.driver_data = info;
1679 config.of_node = np;
1680
1681
1682 if (is_ab8500_1p1_or_earlier(ab8500)) {
1683 if (info->desc.id == AB8500_LDO_AUX3) {
1684 info->desc.n_voltages =
1685 ARRAY_SIZE(ldo_vauxn_voltages);
1686 info->desc.volt_table = ldo_vauxn_voltages;
1687 info->voltage_mask = 0xf;
1688 }
1689 }
1690
1691
1692 rdev = devm_regulator_register(&pdev->dev, &info->desc, &config);
1693 if (IS_ERR(rdev)) {
1694 dev_err(&pdev->dev, "failed to register regulator %s\n",
1695 info->desc.name);
1696 return PTR_ERR(rdev);
1697 }
1698
1699 return 0;
1700 }
1701
1702 static int ab8500_regulator_probe(struct platform_device *pdev)
1703 {
1704 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
1705 struct device_node *np = pdev->dev.of_node;
1706 struct of_regulator_match *match;
1707 int err, i;
1708
1709 if (!ab8500) {
1710 dev_err(&pdev->dev, "null mfd parent\n");
1711 return -EINVAL;
1712 }
1713
1714 abx500_get_regulator_info(ab8500);
1715
1716 err = of_regulator_match(&pdev->dev, np,
1717 abx500_regulator.match,
1718 abx500_regulator.match_size);
1719 if (err < 0) {
1720 dev_err(&pdev->dev,
1721 "Error parsing regulator init data: %d\n", err);
1722 return err;
1723 }
1724
1725 match = abx500_regulator.match;
1726 for (i = 0; i < abx500_regulator.info_size; i++) {
1727 err = ab8500_regulator_register(pdev, match[i].init_data, i,
1728 match[i].of_node);
1729 if (err)
1730 return err;
1731 }
1732
1733 return 0;
1734 }
1735
1736 static struct platform_driver ab8500_regulator_driver = {
1737 .probe = ab8500_regulator_probe,
1738 .driver = {
1739 .name = "ab8500-regulator",
1740 },
1741 };
1742
1743 static int __init ab8500_regulator_init(void)
1744 {
1745 int ret;
1746
1747 ret = platform_driver_register(&ab8500_regulator_driver);
1748 if (ret != 0)
1749 pr_err("Failed to register ab8500 regulator: %d\n", ret);
1750
1751 return ret;
1752 }
1753 subsys_initcall(ab8500_regulator_init);
1754
1755 static void __exit ab8500_regulator_exit(void)
1756 {
1757 platform_driver_unregister(&ab8500_regulator_driver);
1758 }
1759 module_exit(ab8500_regulator_exit);
1760
1761 MODULE_LICENSE("GPL v2");
1762 MODULE_AUTHOR("Sundar Iyer <sundar.iyer@stericsson.com>");
1763 MODULE_AUTHOR("Bengt Jonsson <bengt.g.jonsson@stericsson.com>");
1764 MODULE_AUTHOR("Daniel Willerud <daniel.willerud@stericsson.com>");
1765 MODULE_DESCRIPTION("Regulator Driver for ST-Ericsson AB8500 Mixed-Sig PMIC");
1766 MODULE_ALIAS("platform:ab8500-regulator");