0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include <linux/clk.h>
0013 #include <linux/delay.h>
0014 #include <linux/err.h>
0015 #include <linux/io.h>
0016 #include <linux/module.h>
0017 #include <linux/of_device.h>
0018 #include <linux/of.h>
0019 #include <linux/platform_device.h>
0020 #include <linux/regulator/driver.h>
0021 #include <linux/regulator/machine.h>
0022 #include <linux/regulator/of_regulator.h>
0023
0024
0025
0026
0027
0028
0029
0030 #define TI_ABB_NOMINAL_OPP 0
0031 #define TI_ABB_FAST_OPP 1
0032 #define TI_ABB_SLOW_OPP 3
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 struct ti_abb_info {
0043 u32 opp_sel;
0044 u32 vset;
0045 };
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058 struct ti_abb_reg {
0059 u32 setup_off;
0060 u32 control_off;
0061
0062
0063 u32 sr2_wtcnt_value_mask;
0064 u32 fbb_sel_mask;
0065 u32 rbb_sel_mask;
0066 u32 sr2_en_mask;
0067
0068
0069 u32 opp_change_mask;
0070 u32 opp_sel_mask;
0071 };
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092 struct ti_abb {
0093 struct regulator_desc rdesc;
0094 struct clk *clk;
0095 void __iomem *base;
0096 void __iomem *setup_reg;
0097 void __iomem *control_reg;
0098 void __iomem *int_base;
0099 void __iomem *efuse_base;
0100 void __iomem *ldo_base;
0101
0102 const struct ti_abb_reg *regs;
0103 u32 txdone_mask;
0104 u32 ldovbb_override_mask;
0105 u32 ldovbb_vset_mask;
0106
0107 struct ti_abb_info *info;
0108 int current_info_idx;
0109
0110 u32 settling_time;
0111 };
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121 static inline u32 ti_abb_rmw(u32 mask, u32 value, void __iomem *reg)
0122 {
0123 u32 val;
0124
0125 val = readl(reg);
0126 val &= ~mask;
0127 val |= (value << __ffs(mask)) & mask;
0128 writel(val, reg);
0129
0130 return val;
0131 }
0132
0133
0134
0135
0136
0137
0138
0139 static inline bool ti_abb_check_txdone(const struct ti_abb *abb)
0140 {
0141 return !!(readl(abb->int_base) & abb->txdone_mask);
0142 }
0143
0144
0145
0146
0147
0148 static inline void ti_abb_clear_txdone(const struct ti_abb *abb)
0149 {
0150 writel(abb->txdone_mask, abb->int_base);
0151 };
0152
0153
0154
0155
0156
0157
0158
0159
0160 static int ti_abb_wait_txdone(struct device *dev, struct ti_abb *abb)
0161 {
0162 int timeout = 0;
0163 bool status;
0164
0165 while (timeout++ <= abb->settling_time) {
0166 status = ti_abb_check_txdone(abb);
0167 if (status)
0168 return 0;
0169
0170 udelay(1);
0171 }
0172
0173 dev_warn_ratelimited(dev, "%s:TRANXDONE timeout(%duS) int=0x%08x\n",
0174 __func__, timeout, readl(abb->int_base));
0175 return -ETIMEDOUT;
0176 }
0177
0178
0179
0180
0181
0182
0183
0184
0185 static int ti_abb_clear_all_txdone(struct device *dev, const struct ti_abb *abb)
0186 {
0187 int timeout = 0;
0188 bool status;
0189
0190 while (timeout++ <= abb->settling_time) {
0191 ti_abb_clear_txdone(abb);
0192
0193 status = ti_abb_check_txdone(abb);
0194 if (!status)
0195 return 0;
0196
0197 udelay(1);
0198 }
0199
0200 dev_warn_ratelimited(dev, "%s:TRANXDONE timeout(%duS) int=0x%08x\n",
0201 __func__, timeout, readl(abb->int_base));
0202 return -ETIMEDOUT;
0203 }
0204
0205
0206
0207
0208
0209
0210
0211 static void ti_abb_program_ldovbb(struct device *dev, const struct ti_abb *abb,
0212 struct ti_abb_info *info)
0213 {
0214 u32 val;
0215
0216 val = readl(abb->ldo_base);
0217
0218 val &= ~(abb->ldovbb_override_mask | abb->ldovbb_vset_mask);
0219
0220 switch (info->opp_sel) {
0221 case TI_ABB_SLOW_OPP:
0222 case TI_ABB_FAST_OPP:
0223 val |= abb->ldovbb_override_mask;
0224 val |= info->vset << __ffs(abb->ldovbb_vset_mask);
0225 break;
0226 }
0227
0228 writel(val, abb->ldo_base);
0229 }
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239 static int ti_abb_set_opp(struct regulator_dev *rdev, struct ti_abb *abb,
0240 struct ti_abb_info *info)
0241 {
0242 const struct ti_abb_reg *regs = abb->regs;
0243 struct device *dev = &rdev->dev;
0244 int ret;
0245
0246 ret = ti_abb_clear_all_txdone(dev, abb);
0247 if (ret)
0248 goto out;
0249
0250 ti_abb_rmw(regs->fbb_sel_mask | regs->rbb_sel_mask, 0, abb->setup_reg);
0251
0252 switch (info->opp_sel) {
0253 case TI_ABB_SLOW_OPP:
0254 ti_abb_rmw(regs->rbb_sel_mask, 1, abb->setup_reg);
0255 break;
0256 case TI_ABB_FAST_OPP:
0257 ti_abb_rmw(regs->fbb_sel_mask, 1, abb->setup_reg);
0258 break;
0259 }
0260
0261
0262 ti_abb_rmw(regs->opp_sel_mask, info->opp_sel, abb->control_reg);
0263
0264
0265
0266
0267
0268
0269 if (abb->ldo_base && info->opp_sel != TI_ABB_NOMINAL_OPP)
0270 ti_abb_program_ldovbb(dev, abb, info);
0271
0272
0273 ti_abb_rmw(regs->opp_change_mask, 1, abb->control_reg);
0274
0275
0276 ret = ti_abb_wait_txdone(dev, abb);
0277 if (ret)
0278 goto out;
0279
0280 ret = ti_abb_clear_all_txdone(dev, abb);
0281 if (ret)
0282 goto out;
0283
0284
0285
0286
0287
0288
0289 if (abb->ldo_base && info->opp_sel == TI_ABB_NOMINAL_OPP)
0290 ti_abb_program_ldovbb(dev, abb, info);
0291
0292 out:
0293 return ret;
0294 }
0295
0296
0297
0298
0299
0300
0301
0302
0303
0304 static int ti_abb_set_voltage_sel(struct regulator_dev *rdev, unsigned int sel)
0305 {
0306 const struct regulator_desc *desc = rdev->desc;
0307 struct ti_abb *abb = rdev_get_drvdata(rdev);
0308 struct device *dev = &rdev->dev;
0309 struct ti_abb_info *info, *oinfo;
0310 int ret = 0;
0311
0312 if (!abb) {
0313 dev_err_ratelimited(dev, "%s: No regulator drvdata\n",
0314 __func__);
0315 return -ENODEV;
0316 }
0317
0318 if (!desc->n_voltages || !abb->info) {
0319 dev_err_ratelimited(dev,
0320 "%s: No valid voltage table entries?\n",
0321 __func__);
0322 return -EINVAL;
0323 }
0324
0325 if (sel >= desc->n_voltages) {
0326 dev_err(dev, "%s: sel idx(%d) >= n_voltages(%d)\n", __func__,
0327 sel, desc->n_voltages);
0328 return -EINVAL;
0329 }
0330
0331
0332 if (sel == abb->current_info_idx) {
0333 dev_dbg(dev, "%s: Already at sel=%d\n", __func__, sel);
0334 return ret;
0335 }
0336
0337 info = &abb->info[sel];
0338
0339
0340
0341
0342
0343
0344 if (abb->current_info_idx == -EINVAL)
0345 goto just_set_abb;
0346
0347
0348 oinfo = &abb->info[abb->current_info_idx];
0349 if (!memcmp(info, oinfo, sizeof(*info))) {
0350 dev_dbg(dev, "%s: Same data new idx=%d, old idx=%d\n", __func__,
0351 sel, abb->current_info_idx);
0352 goto out;
0353 }
0354
0355 just_set_abb:
0356 ret = ti_abb_set_opp(rdev, abb, info);
0357
0358 out:
0359 if (!ret)
0360 abb->current_info_idx = sel;
0361 else
0362 dev_err_ratelimited(dev,
0363 "%s: Volt[%d] idx[%d] mode[%d] Fail(%d)\n",
0364 __func__, desc->volt_table[sel], sel,
0365 info->opp_sel, ret);
0366 return ret;
0367 }
0368
0369
0370
0371
0372
0373
0374
0375 static int ti_abb_get_voltage_sel(struct regulator_dev *rdev)
0376 {
0377 const struct regulator_desc *desc = rdev->desc;
0378 struct ti_abb *abb = rdev_get_drvdata(rdev);
0379 struct device *dev = &rdev->dev;
0380
0381 if (!abb) {
0382 dev_err_ratelimited(dev, "%s: No regulator drvdata\n",
0383 __func__);
0384 return -ENODEV;
0385 }
0386
0387 if (!desc->n_voltages || !abb->info) {
0388 dev_err_ratelimited(dev,
0389 "%s: No valid voltage table entries?\n",
0390 __func__);
0391 return -EINVAL;
0392 }
0393
0394 if (abb->current_info_idx >= (int)desc->n_voltages) {
0395 dev_err(dev, "%s: Corrupted data? idx(%d) >= n_voltages(%d)\n",
0396 __func__, abb->current_info_idx, desc->n_voltages);
0397 return -EINVAL;
0398 }
0399
0400 return abb->current_info_idx;
0401 }
0402
0403
0404
0405
0406
0407
0408
0409
0410 static int ti_abb_init_timings(struct device *dev, struct ti_abb *abb)
0411 {
0412 u32 clock_cycles;
0413 u32 clk_rate, sr2_wt_cnt_val, cycle_rate;
0414 const struct ti_abb_reg *regs = abb->regs;
0415 int ret;
0416 char *pname = "ti,settling-time";
0417
0418
0419 ret = of_property_read_u32(dev->of_node, pname, &abb->settling_time);
0420 if (ret) {
0421 dev_err(dev, "Unable to get property '%s'(%d)\n", pname, ret);
0422 return ret;
0423 }
0424
0425
0426 if (!abb->settling_time) {
0427 dev_err(dev, "Invalid property:'%s' set as 0!\n", pname);
0428 return -EINVAL;
0429 }
0430
0431 pname = "ti,clock-cycles";
0432 ret = of_property_read_u32(dev->of_node, pname, &clock_cycles);
0433 if (ret) {
0434 dev_err(dev, "Unable to get property '%s'(%d)\n", pname, ret);
0435 return ret;
0436 }
0437
0438 if (!clock_cycles) {
0439 dev_err(dev, "Invalid property:'%s' set as 0!\n", pname);
0440 return -EINVAL;
0441 }
0442
0443 abb->clk = devm_clk_get(dev, NULL);
0444 if (IS_ERR(abb->clk)) {
0445 ret = PTR_ERR(abb->clk);
0446 dev_err(dev, "%s: Unable to get clk(%d)\n", __func__, ret);
0447 return ret;
0448 }
0449
0450
0451
0452
0453
0454
0455
0456
0457
0458
0459
0460
0461
0462
0463
0464
0465
0466
0467
0468
0469
0470
0471
0472
0473
0474 clk_rate = DIV_ROUND_CLOSEST(clk_get_rate(abb->clk), 1000000);
0475
0476
0477 cycle_rate = DIV_ROUND_CLOSEST(clock_cycles * 10, clk_rate);
0478
0479
0480 sr2_wt_cnt_val = DIV_ROUND_CLOSEST(abb->settling_time * 10, cycle_rate);
0481
0482 dev_dbg(dev, "%s: Clk_rate=%ld, sr2_cnt=0x%08x\n", __func__,
0483 clk_get_rate(abb->clk), sr2_wt_cnt_val);
0484
0485 ti_abb_rmw(regs->sr2_wtcnt_value_mask, sr2_wt_cnt_val, abb->setup_reg);
0486
0487 return 0;
0488 }
0489
0490
0491
0492
0493
0494
0495
0496
0497
0498 static int ti_abb_init_table(struct device *dev, struct ti_abb *abb,
0499 struct regulator_init_data *rinit_data)
0500 {
0501 struct ti_abb_info *info;
0502 const u32 num_values = 6;
0503 char *pname = "ti,abb_info";
0504 u32 i;
0505 unsigned int *volt_table;
0506 int num_entries, min_uV = INT_MAX, max_uV = 0;
0507 struct regulation_constraints *c = &rinit_data->constraints;
0508
0509
0510
0511
0512
0513
0514 num_entries = of_property_count_u32_elems(dev->of_node, pname);
0515 if (num_entries < 0) {
0516 dev_err(dev, "No '%s' property?\n", pname);
0517 return num_entries;
0518 }
0519
0520 if (!num_entries || (num_entries % num_values)) {
0521 dev_err(dev, "All '%s' list entries need %d vals\n", pname,
0522 num_values);
0523 return -EINVAL;
0524 }
0525 num_entries /= num_values;
0526
0527 info = devm_kcalloc(dev, num_entries, sizeof(*info), GFP_KERNEL);
0528 if (!info)
0529 return -ENOMEM;
0530
0531 abb->info = info;
0532
0533 volt_table = devm_kcalloc(dev, num_entries, sizeof(unsigned int),
0534 GFP_KERNEL);
0535 if (!volt_table)
0536 return -ENOMEM;
0537
0538 abb->rdesc.n_voltages = num_entries;
0539 abb->rdesc.volt_table = volt_table;
0540
0541 abb->current_info_idx = -EINVAL;
0542
0543 for (i = 0; i < num_entries; i++, info++, volt_table++) {
0544 u32 efuse_offset, rbb_mask, fbb_mask, vset_mask;
0545 u32 efuse_val;
0546
0547
0548 of_property_read_u32_index(dev->of_node, pname, i * num_values,
0549 volt_table);
0550 of_property_read_u32_index(dev->of_node, pname,
0551 i * num_values + 1, &info->opp_sel);
0552 of_property_read_u32_index(dev->of_node, pname,
0553 i * num_values + 2, &efuse_offset);
0554 of_property_read_u32_index(dev->of_node, pname,
0555 i * num_values + 3, &rbb_mask);
0556 of_property_read_u32_index(dev->of_node, pname,
0557 i * num_values + 4, &fbb_mask);
0558 of_property_read_u32_index(dev->of_node, pname,
0559 i * num_values + 5, &vset_mask);
0560
0561 dev_dbg(dev,
0562 "[%d]v=%d ABB=%d ef=0x%x rbb=0x%x fbb=0x%x vset=0x%x\n",
0563 i, *volt_table, info->opp_sel, efuse_offset, rbb_mask,
0564 fbb_mask, vset_mask);
0565
0566
0567 if (min_uV > *volt_table)
0568 min_uV = *volt_table;
0569 if (max_uV < *volt_table)
0570 max_uV = *volt_table;
0571
0572 if (!abb->efuse_base) {
0573
0574 if (efuse_offset || rbb_mask || fbb_mask || vset_mask)
0575 dev_err(dev, "prop '%s': v=%d,bad efuse/mask\n",
0576 pname, *volt_table);
0577 goto check_abb;
0578 }
0579
0580 efuse_val = readl(abb->efuse_base + efuse_offset);
0581
0582
0583 if (efuse_val & rbb_mask)
0584 info->opp_sel = TI_ABB_SLOW_OPP;
0585 else if (efuse_val & fbb_mask)
0586 info->opp_sel = TI_ABB_FAST_OPP;
0587 else if (rbb_mask || fbb_mask)
0588 info->opp_sel = TI_ABB_NOMINAL_OPP;
0589
0590 dev_dbg(dev,
0591 "[%d]v=%d efusev=0x%x final ABB=%d\n",
0592 i, *volt_table, efuse_val, info->opp_sel);
0593
0594
0595 if (!abb->ldo_base) {
0596 if (vset_mask)
0597 dev_err(dev, "prop'%s':v=%d vst=%x LDO base?\n",
0598 pname, *volt_table, vset_mask);
0599 continue;
0600 }
0601 info->vset = (efuse_val & vset_mask) >> __ffs(vset_mask);
0602 dev_dbg(dev, "[%d]v=%d vset=%x\n", i, *volt_table, info->vset);
0603 check_abb:
0604 switch (info->opp_sel) {
0605 case TI_ABB_NOMINAL_OPP:
0606 case TI_ABB_FAST_OPP:
0607 case TI_ABB_SLOW_OPP:
0608
0609 break;
0610 default:
0611 dev_err(dev, "%s:[%d]v=%d, ABB=%d is invalid! Abort!\n",
0612 __func__, i, *volt_table, info->opp_sel);
0613 return -EINVAL;
0614 }
0615 }
0616
0617
0618 c->min_uV = min_uV;
0619 c->max_uV = max_uV;
0620
0621 return 0;
0622 }
0623
0624 static const struct regulator_ops ti_abb_reg_ops = {
0625 .list_voltage = regulator_list_voltage_table,
0626
0627 .set_voltage_sel = ti_abb_set_voltage_sel,
0628 .get_voltage_sel = ti_abb_get_voltage_sel,
0629 };
0630
0631
0632 static const struct ti_abb_reg abb_regs_v1 = {
0633
0634 .setup_off = 0x04,
0635 .control_off = 0x00,
0636
0637 .sr2_wtcnt_value_mask = (0xff << 8),
0638 .fbb_sel_mask = (0x01 << 2),
0639 .rbb_sel_mask = (0x01 << 1),
0640 .sr2_en_mask = (0x01 << 0),
0641
0642 .opp_change_mask = (0x01 << 2),
0643 .opp_sel_mask = (0x03 << 0),
0644 };
0645
0646 static const struct ti_abb_reg abb_regs_v2 = {
0647 .setup_off = 0x00,
0648 .control_off = 0x04,
0649
0650 .sr2_wtcnt_value_mask = (0xff << 8),
0651 .fbb_sel_mask = (0x01 << 2),
0652 .rbb_sel_mask = (0x01 << 1),
0653 .sr2_en_mask = (0x01 << 0),
0654
0655 .opp_change_mask = (0x01 << 2),
0656 .opp_sel_mask = (0x03 << 0),
0657 };
0658
0659 static const struct ti_abb_reg abb_regs_generic = {
0660 .sr2_wtcnt_value_mask = (0xff << 8),
0661 .fbb_sel_mask = (0x01 << 2),
0662 .rbb_sel_mask = (0x01 << 1),
0663 .sr2_en_mask = (0x01 << 0),
0664
0665 .opp_change_mask = (0x01 << 2),
0666 .opp_sel_mask = (0x03 << 0),
0667 };
0668
0669 static const struct of_device_id ti_abb_of_match[] = {
0670 {.compatible = "ti,abb-v1", .data = &abb_regs_v1},
0671 {.compatible = "ti,abb-v2", .data = &abb_regs_v2},
0672 {.compatible = "ti,abb-v3", .data = &abb_regs_generic},
0673 { },
0674 };
0675
0676 MODULE_DEVICE_TABLE(of, ti_abb_of_match);
0677
0678
0679
0680
0681
0682
0683
0684
0685
0686
0687
0688 static int ti_abb_probe(struct platform_device *pdev)
0689 {
0690 struct device *dev = &pdev->dev;
0691 const struct of_device_id *match;
0692 struct resource *res;
0693 struct ti_abb *abb;
0694 struct regulator_init_data *initdata = NULL;
0695 struct regulator_dev *rdev = NULL;
0696 struct regulator_desc *desc;
0697 struct regulation_constraints *c;
0698 struct regulator_config config = { };
0699 char *pname;
0700 int ret = 0;
0701
0702 match = of_match_device(ti_abb_of_match, dev);
0703 if (!match) {
0704
0705 dev_err(dev, "%s: Unable to match device\n", __func__);
0706 return -ENODEV;
0707 }
0708 if (!match->data) {
0709 dev_err(dev, "%s: Bad data in match\n", __func__);
0710 return -EINVAL;
0711 }
0712
0713 abb = devm_kzalloc(dev, sizeof(struct ti_abb), GFP_KERNEL);
0714 if (!abb)
0715 return -ENOMEM;
0716 abb->regs = match->data;
0717
0718
0719 if (abb->regs->setup_off || abb->regs->control_off) {
0720 abb->base = devm_platform_ioremap_resource_byname(pdev, "base-address");
0721 if (IS_ERR(abb->base))
0722 return PTR_ERR(abb->base);
0723
0724 abb->setup_reg = abb->base + abb->regs->setup_off;
0725 abb->control_reg = abb->base + abb->regs->control_off;
0726
0727 } else {
0728 abb->control_reg = devm_platform_ioremap_resource_byname(pdev, "control-address");
0729 if (IS_ERR(abb->control_reg))
0730 return PTR_ERR(abb->control_reg);
0731
0732 abb->setup_reg = devm_platform_ioremap_resource_byname(pdev, "setup-address");
0733 if (IS_ERR(abb->setup_reg))
0734 return PTR_ERR(abb->setup_reg);
0735 }
0736
0737 abb->int_base = devm_platform_ioremap_resource_byname(pdev, "int-address");
0738 if (IS_ERR(abb->int_base))
0739 return PTR_ERR(abb->int_base);
0740
0741
0742 pname = "efuse-address";
0743 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname);
0744 if (!res) {
0745 dev_dbg(dev, "Missing '%s' IO resource\n", pname);
0746 ret = -ENODEV;
0747 goto skip_opt;
0748 }
0749
0750
0751
0752
0753
0754 abb->efuse_base = devm_ioremap(dev, res->start,
0755 resource_size(res));
0756 if (!abb->efuse_base) {
0757 dev_err(dev, "Unable to map '%s'\n", pname);
0758 return -ENOMEM;
0759 }
0760
0761 pname = "ldo-address";
0762 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname);
0763 if (!res) {
0764 dev_dbg(dev, "Missing '%s' IO resource\n", pname);
0765 ret = -ENODEV;
0766 goto skip_opt;
0767 }
0768 abb->ldo_base = devm_ioremap_resource(dev, res);
0769 if (IS_ERR(abb->ldo_base))
0770 return PTR_ERR(abb->ldo_base);
0771
0772
0773 pname = "ti,ldovbb-override-mask";
0774 ret =
0775 of_property_read_u32(pdev->dev.of_node, pname,
0776 &abb->ldovbb_override_mask);
0777 if (ret) {
0778 dev_err(dev, "Missing '%s' (%d)\n", pname, ret);
0779 return ret;
0780 }
0781 if (!abb->ldovbb_override_mask) {
0782 dev_err(dev, "Invalid property:'%s' set as 0!\n", pname);
0783 return -EINVAL;
0784 }
0785
0786 pname = "ti,ldovbb-vset-mask";
0787 ret =
0788 of_property_read_u32(pdev->dev.of_node, pname,
0789 &abb->ldovbb_vset_mask);
0790 if (ret) {
0791 dev_err(dev, "Missing '%s' (%d)\n", pname, ret);
0792 return ret;
0793 }
0794 if (!abb->ldovbb_vset_mask) {
0795 dev_err(dev, "Invalid property:'%s' set as 0!\n", pname);
0796 return -EINVAL;
0797 }
0798
0799 skip_opt:
0800 pname = "ti,tranxdone-status-mask";
0801 ret =
0802 of_property_read_u32(pdev->dev.of_node, pname,
0803 &abb->txdone_mask);
0804 if (ret) {
0805 dev_err(dev, "Missing '%s' (%d)\n", pname, ret);
0806 return ret;
0807 }
0808 if (!abb->txdone_mask) {
0809 dev_err(dev, "Invalid property:'%s' set as 0!\n", pname);
0810 return -EINVAL;
0811 }
0812
0813 initdata = of_get_regulator_init_data(dev, pdev->dev.of_node,
0814 &abb->rdesc);
0815 if (!initdata) {
0816 dev_err(dev, "%s: Unable to alloc regulator init data\n",
0817 __func__);
0818 return -ENOMEM;
0819 }
0820
0821
0822 ret = ti_abb_init_table(dev, abb, initdata);
0823 if (ret)
0824 return ret;
0825
0826
0827 ret = ti_abb_init_timings(dev, abb);
0828 if (ret)
0829 return ret;
0830
0831 desc = &abb->rdesc;
0832 desc->name = dev_name(dev);
0833 desc->owner = THIS_MODULE;
0834 desc->type = REGULATOR_VOLTAGE;
0835 desc->ops = &ti_abb_reg_ops;
0836
0837 c = &initdata->constraints;
0838 if (desc->n_voltages > 1)
0839 c->valid_ops_mask |= REGULATOR_CHANGE_VOLTAGE;
0840 c->always_on = true;
0841
0842 config.dev = dev;
0843 config.init_data = initdata;
0844 config.driver_data = abb;
0845 config.of_node = pdev->dev.of_node;
0846
0847 rdev = devm_regulator_register(dev, desc, &config);
0848 if (IS_ERR(rdev)) {
0849 ret = PTR_ERR(rdev);
0850 dev_err(dev, "%s: failed to register regulator(%d)\n",
0851 __func__, ret);
0852 return ret;
0853 }
0854 platform_set_drvdata(pdev, rdev);
0855
0856
0857 ti_abb_rmw(abb->regs->sr2_en_mask, 1, abb->setup_reg);
0858
0859 return 0;
0860 }
0861
0862 MODULE_ALIAS("platform:ti_abb");
0863
0864 static struct platform_driver ti_abb_driver = {
0865 .probe = ti_abb_probe,
0866 .driver = {
0867 .name = "ti_abb",
0868 .of_match_table = of_match_ptr(ti_abb_of_match),
0869 },
0870 };
0871 module_platform_driver(ti_abb_driver);
0872
0873 MODULE_DESCRIPTION("Texas Instruments ABB LDO regulator driver");
0874 MODULE_AUTHOR("Texas Instruments Inc.");
0875 MODULE_LICENSE("GPL v2");