2 * Texas Instruments SoC Adaptive Body Bias(ABB) Regulator
4 * Copyright (C) 2011 Texas Instruments, Inc.
7 * Copyright (C) 2012-2013 Texas Instruments, Inc.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
16 * kind, whether express or implied; without even the implied warranty
17 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 #include <linux/clk.h>
21 #include <linux/delay.h>
22 #include <linux/err.h>
24 #include <linux/module.h>
25 #include <linux/of_device.h>
27 #include <linux/platform_device.h>
28 #include <linux/regulator/driver.h>
29 #include <linux/regulator/machine.h>
30 #include <linux/regulator/of_regulator.h>
33 * ABB LDO operating states:
34 * NOMINAL_OPP: bypasses the ABB LDO
35 * FAST_OPP: sets ABB LDO to Forward Body-Bias
36 * SLOW_OPP: sets ABB LDO to Reverse Body-Bias
38 #define TI_ABB_NOMINAL_OPP 0
39 #define TI_ABB_FAST_OPP 1
40 #define TI_ABB_SLOW_OPP 3
43 * struct ti_abb_info - ABB information per voltage setting
44 * @opp_sel: one of TI_ABB macro
45 * @vset: (optional) vset value that LDOVBB needs to be overriden with.
47 * Array of per voltage entries organized in the same order as regulator_desc's
48 * volt_table list. (selector is used to index from this array)
56 * struct ti_abb_reg - Register description for ABB block
57 * @setup_off: setup register offset from base
58 * @control_off: control register offset from base
59 * @sr2_wtcnt_value_mask: setup register- sr2_wtcnt_value mask
60 * @fbb_sel_mask: setup register- FBB sel mask
61 * @rbb_sel_mask: setup register- RBB sel mask
62 * @sr2_en_mask: setup register- enable mask
63 * @opp_change_mask: control register - mask to trigger LDOVBB change
64 * @opp_sel_mask: control register - mask for mode to operate
70 /* Setup register fields */
71 u32 sr2_wtcnt_value_mask;
76 /* Control register fields */
82 * struct ti_abb - ABB instance data
83 * @rdesc: regulator descriptor
84 * @clk: clock(usually sysclk) supplying ABB block
85 * @base: base address of ABB block
86 * @setup_reg: setup register of ABB block
87 * @control_reg: control register of ABB block
88 * @int_base: interrupt register base address
89 * @efuse_base: (optional) efuse base address for ABB modes
90 * @ldo_base: (optional) LDOVBB vset override base address
91 * @regs: pointer to struct ti_abb_reg for ABB block
92 * @txdone_mask: mask on int_base for tranxdone interrupt
93 * @ldovbb_override_mask: mask to ldo_base for overriding default LDO VBB
94 * vset with value from efuse
95 * @ldovbb_vset_mask: mask to ldo_base for providing the VSET override
96 * @info: array to per voltage ABB configuration
97 * @current_info_idx: current index to info
98 * @settling_time: SoC specific settling time for LDO VBB
101 struct regulator_desc rdesc;
104 void __iomem *setup_reg;
105 void __iomem *control_reg;
106 void __iomem *int_base;
107 void __iomem *efuse_base;
108 void __iomem *ldo_base;
110 const struct ti_abb_reg *regs;
112 u32 ldovbb_override_mask;
113 u32 ldovbb_vset_mask;
115 struct ti_abb_info *info;
116 int current_info_idx;
122 * ti_abb_rmw() - handy wrapper to set specific register bits
123 * @mask: mask for register field
124 * @value: value shifted to mask location and written
125 * @reg: register address
127 * Return: final register value (may be unused)
129 static inline u32 ti_abb_rmw(u32 mask, u32 value, void __iomem *reg)
135 val |= (value << __ffs(mask)) & mask;
142 * ti_abb_check_txdone() - handy wrapper to check ABB tranxdone status
143 * @abb: pointer to the abb instance
145 * Return: true or false
147 static inline bool ti_abb_check_txdone(const struct ti_abb *abb)
149 return !!(readl(abb->int_base) & abb->txdone_mask);
153 * ti_abb_clear_txdone() - handy wrapper to clear ABB tranxdone status
154 * @abb: pointer to the abb instance
156 static inline void ti_abb_clear_txdone(const struct ti_abb *abb)
158 writel(abb->txdone_mask, abb->int_base);
162 * ti_abb_wait_tranx() - waits for ABB tranxdone event
164 * @abb: pointer to the abb instance
166 * Return: 0 on success or -ETIMEDOUT if the event is not cleared on time.
168 static int ti_abb_wait_txdone(struct device *dev, struct ti_abb *abb)
173 while (timeout++ <= abb->settling_time) {
174 status = ti_abb_check_txdone(abb);
181 dev_warn_ratelimited(dev, "%s:TRANXDONE timeout(%duS) int=0x%08x\n",
182 __func__, timeout, readl(abb->int_base));
187 * ti_abb_clear_all_txdone() - clears ABB tranxdone event
189 * @abb: pointer to the abb instance
191 * Return: 0 on success or -ETIMEDOUT if the event is not cleared on time.
193 static int ti_abb_clear_all_txdone(struct device *dev, const struct ti_abb *abb)
198 while (timeout++ <= abb->settling_time) {
199 ti_abb_clear_txdone(abb);
201 status = ti_abb_check_txdone(abb);
208 dev_warn_ratelimited(dev, "%s:TRANXDONE timeout(%duS) int=0x%08x\n",
209 __func__, timeout, readl(abb->int_base));
214 * ti_abb_program_ldovbb() - program LDOVBB register for override value
216 * @abb: pointer to the abb instance
217 * @info: ABB info to program
219 static void ti_abb_program_ldovbb(struct device *dev, const struct ti_abb *abb,
220 struct ti_abb_info *info)
224 val = readl(abb->ldo_base);
225 /* clear up previous values */
226 val &= ~(abb->ldovbb_override_mask | abb->ldovbb_vset_mask);
228 switch (info->opp_sel) {
229 case TI_ABB_SLOW_OPP:
230 case TI_ABB_FAST_OPP:
231 val |= abb->ldovbb_override_mask;
232 val |= info->vset << __ffs(abb->ldovbb_vset_mask);
236 writel(val, abb->ldo_base);
240 * ti_abb_set_opp() - Setup ABB and LDO VBB for required bias
241 * @rdev: regulator device
242 * @abb: pointer to the abb instance
243 * @info: ABB info to program
245 * Return: 0 on success or appropriate error value when fails
247 static int ti_abb_set_opp(struct regulator_dev *rdev, struct ti_abb *abb,
248 struct ti_abb_info *info)
250 const struct ti_abb_reg *regs = abb->regs;
251 struct device *dev = &rdev->dev;
254 ret = ti_abb_clear_all_txdone(dev, abb);
258 ti_abb_rmw(regs->fbb_sel_mask | regs->rbb_sel_mask, 0, abb->setup_reg);
260 switch (info->opp_sel) {
261 case TI_ABB_SLOW_OPP:
262 ti_abb_rmw(regs->rbb_sel_mask, 1, abb->setup_reg);
264 case TI_ABB_FAST_OPP:
265 ti_abb_rmw(regs->fbb_sel_mask, 1, abb->setup_reg);
269 /* program next state of ABB ldo */
270 ti_abb_rmw(regs->opp_sel_mask, info->opp_sel, abb->control_reg);
273 * program LDO VBB vset override if needed for !bypass mode
274 * XXX: Do not switch sequence - for !bypass, LDO override reset *must*
275 * be performed *before* switch to bias mode else VBB glitches.
277 if (abb->ldo_base && info->opp_sel != TI_ABB_NOMINAL_OPP)
278 ti_abb_program_ldovbb(dev, abb, info);
280 /* Initiate ABB ldo change */
281 ti_abb_rmw(regs->opp_change_mask, 1, abb->control_reg);
283 /* Wait for ABB LDO to complete transition to new Bias setting */
284 ret = ti_abb_wait_txdone(dev, abb);
288 ret = ti_abb_clear_all_txdone(dev, abb);
293 * Reset LDO VBB vset override bypass mode
294 * XXX: Do not switch sequence - for bypass, LDO override reset *must*
295 * be performed *after* switch to bypass else VBB glitches.
297 if (abb->ldo_base && info->opp_sel == TI_ABB_NOMINAL_OPP)
298 ti_abb_program_ldovbb(dev, abb, info);
305 * ti_abb_set_voltage_sel() - regulator accessor function to set ABB LDO
306 * @rdev: regulator device
307 * @sel: selector to index into required ABB LDO settings (maps to
308 * regulator descriptor's volt_table)
310 * Return: 0 on success or appropriate error value when fails
312 static int ti_abb_set_voltage_sel(struct regulator_dev *rdev, unsigned sel)
314 const struct regulator_desc *desc = rdev->desc;
315 struct ti_abb *abb = rdev_get_drvdata(rdev);
316 struct device *dev = &rdev->dev;
317 struct ti_abb_info *info, *oinfo;
321 dev_err_ratelimited(dev, "%s: No regulator drvdata\n",
326 if (!desc->n_voltages || !abb->info) {
327 dev_err_ratelimited(dev,
328 "%s: No valid voltage table entries?\n",
333 if (sel >= desc->n_voltages) {
334 dev_err(dev, "%s: sel idx(%d) >= n_voltages(%d)\n", __func__,
335 sel, desc->n_voltages);
339 /* If we are in the same index as we were, nothing to do here! */
340 if (sel == abb->current_info_idx) {
341 dev_dbg(dev, "%s: Already at sel=%d\n", __func__, sel);
345 info = &abb->info[sel];
347 * When Linux kernel is starting up, we are'nt sure of the
348 * Bias configuration that bootloader has configured.
349 * So, we get to know the actual setting the first time
350 * we are asked to transition.
352 if (abb->current_info_idx == -EINVAL)
355 /* If data is exactly the same, then just update index, no change */
356 oinfo = &abb->info[abb->current_info_idx];
357 if (!memcmp(info, oinfo, sizeof(*info))) {
358 dev_dbg(dev, "%s: Same data new idx=%d, old idx=%d\n", __func__,
359 sel, abb->current_info_idx);
364 ret = ti_abb_set_opp(rdev, abb, info);
368 abb->current_info_idx = sel;
370 dev_err_ratelimited(dev,
371 "%s: Volt[%d] idx[%d] mode[%d] Fail(%d)\n",
372 __func__, desc->volt_table[sel], sel,
378 * ti_abb_get_voltage_sel() - Regulator accessor to get current ABB LDO setting
379 * @rdev: regulator device
381 * Return: 0 on success or appropriate error value when fails
383 static int ti_abb_get_voltage_sel(struct regulator_dev *rdev)
385 const struct regulator_desc *desc = rdev->desc;
386 struct ti_abb *abb = rdev_get_drvdata(rdev);
387 struct device *dev = &rdev->dev;
390 dev_err_ratelimited(dev, "%s: No regulator drvdata\n",
395 if (!desc->n_voltages || !abb->info) {
396 dev_err_ratelimited(dev,
397 "%s: No valid voltage table entries?\n",
402 if (abb->current_info_idx >= (int)desc->n_voltages) {
403 dev_err(dev, "%s: Corrupted data? idx(%d) >= n_voltages(%d)\n",
404 __func__, abb->current_info_idx, desc->n_voltages);
408 return abb->current_info_idx;
412 * ti_abb_init_timings() - setup ABB clock timing for the current platform
414 * @abb: pointer to the abb instance
416 * Return: 0 if timing is updated, else returns error result.
418 static int ti_abb_init_timings(struct device *dev, struct ti_abb *abb)
421 u32 clk_rate, sr2_wt_cnt_val, cycle_rate;
422 const struct ti_abb_reg *regs = abb->regs;
424 char *pname = "ti,settling-time";
426 /* read device tree properties */
427 ret = of_property_read_u32(dev->of_node, pname, &abb->settling_time);
429 dev_err(dev, "Unable to get property '%s'(%d)\n", pname, ret);
433 /* ABB LDO cannot be settle in 0 time */
434 if (!abb->settling_time) {
435 dev_err(dev, "Invalid property:'%s' set as 0!\n", pname);
439 pname = "ti,clock-cycles";
440 ret = of_property_read_u32(dev->of_node, pname, &clock_cycles);
442 dev_err(dev, "Unable to get property '%s'(%d)\n", pname, ret);
445 /* ABB LDO cannot be settle in 0 clock cycles */
447 dev_err(dev, "Invalid property:'%s' set as 0!\n", pname);
451 abb->clk = devm_clk_get(dev, NULL);
452 if (IS_ERR(abb->clk)) {
453 ret = PTR_ERR(abb->clk);
454 dev_err(dev, "%s: Unable to get clk(%d)\n", __func__, ret);
459 * SR2_WTCNT_VALUE is the settling time for the ABB ldo after a
460 * transition and must be programmed with the correct time at boot.
461 * The value programmed into the register is the number of SYS_CLK
462 * clock cycles that match a given wall time profiled for the ldo.
463 * This value depends on:
464 * settling time of ldo in micro-seconds (varies per OMAP family)
465 * # of clock cycles per SYS_CLK period (varies per OMAP family)
466 * the SYS_CLK frequency in MHz (varies per board)
469 * ldo settling time (in micro-seconds)
470 * SR2_WTCNT_VALUE = ------------------------------------------
471 * (# system clock cycles) * (sys_clk period)
475 * SR2_WTCNT_VALUE = settling time / (# SYS_CLK cycles / SYS_CLK rate))
477 * To avoid dividing by zero multiply both "# clock cycles" and
478 * "settling time" by 10 such that the final result is the one we want.
481 /* Convert SYS_CLK rate to MHz & prevent divide by zero */
482 clk_rate = DIV_ROUND_CLOSEST(clk_get_rate(abb->clk), 1000000);
484 /* Calculate cycle rate */
485 cycle_rate = DIV_ROUND_CLOSEST(clock_cycles * 10, clk_rate);
487 /* Calulate SR2_WTCNT_VALUE */
488 sr2_wt_cnt_val = DIV_ROUND_CLOSEST(abb->settling_time * 10, cycle_rate);
490 dev_dbg(dev, "%s: Clk_rate=%ld, sr2_cnt=0x%08x\n", __func__,
491 clk_get_rate(abb->clk), sr2_wt_cnt_val);
493 ti_abb_rmw(regs->sr2_wtcnt_value_mask, sr2_wt_cnt_val, abb->setup_reg);
499 * ti_abb_init_table() - Initialize ABB table from device tree
501 * @abb: pointer to the abb instance
502 * @rinit_data: regulator initdata
504 * Return: 0 on success or appropriate error value when fails
506 static int ti_abb_init_table(struct device *dev, struct ti_abb *abb,
507 struct regulator_init_data *rinit_data)
509 struct ti_abb_info *info;
510 const u32 num_values = 6;
511 char *pname = "ti,abb_info";
513 unsigned int *volt_table;
514 int num_entries, min_uV = INT_MAX, max_uV = 0;
515 struct regulation_constraints *c = &rinit_data->constraints;
518 * Each abb_info is a set of n-tuple, where n is num_values, consisting
519 * of voltage and a set of detection logic for ABB information for that
522 num_entries = of_property_count_u32_elems(dev->of_node, pname);
523 if (num_entries < 0) {
524 dev_err(dev, "No '%s' property?\n", pname);
528 if (!num_entries || (num_entries % num_values)) {
529 dev_err(dev, "All '%s' list entries need %d vals\n", pname,
533 num_entries /= num_values;
535 info = devm_kcalloc(dev, num_entries, sizeof(*info), GFP_KERNEL);
541 volt_table = devm_kcalloc(dev, num_entries, sizeof(unsigned int),
546 abb->rdesc.n_voltages = num_entries;
547 abb->rdesc.volt_table = volt_table;
548 /* We do not know where the OPP voltage is at the moment */
549 abb->current_info_idx = -EINVAL;
551 for (i = 0; i < num_entries; i++, info++, volt_table++) {
552 u32 efuse_offset, rbb_mask, fbb_mask, vset_mask;
555 /* NOTE: num_values should equal to entries picked up here */
556 of_property_read_u32_index(dev->of_node, pname, i * num_values,
558 of_property_read_u32_index(dev->of_node, pname,
559 i * num_values + 1, &info->opp_sel);
560 of_property_read_u32_index(dev->of_node, pname,
561 i * num_values + 2, &efuse_offset);
562 of_property_read_u32_index(dev->of_node, pname,
563 i * num_values + 3, &rbb_mask);
564 of_property_read_u32_index(dev->of_node, pname,
565 i * num_values + 4, &fbb_mask);
566 of_property_read_u32_index(dev->of_node, pname,
567 i * num_values + 5, &vset_mask);
570 "[%d]v=%d ABB=%d ef=0x%x rbb=0x%x fbb=0x%x vset=0x%x\n",
571 i, *volt_table, info->opp_sel, efuse_offset, rbb_mask,
572 fbb_mask, vset_mask);
574 /* Find min/max for voltage set */
575 if (min_uV > *volt_table)
576 min_uV = *volt_table;
577 if (max_uV < *volt_table)
578 max_uV = *volt_table;
580 if (!abb->efuse_base) {
581 /* Ignore invalid data, but warn to help cleanup */
582 if (efuse_offset || rbb_mask || fbb_mask || vset_mask)
583 dev_err(dev, "prop '%s': v=%d,bad efuse/mask\n",
588 efuse_val = readl(abb->efuse_base + efuse_offset);
590 /* Use ABB recommendation from Efuse */
591 if (efuse_val & rbb_mask)
592 info->opp_sel = TI_ABB_SLOW_OPP;
593 else if (efuse_val & fbb_mask)
594 info->opp_sel = TI_ABB_FAST_OPP;
595 else if (rbb_mask || fbb_mask)
596 info->opp_sel = TI_ABB_NOMINAL_OPP;
599 "[%d]v=%d efusev=0x%x final ABB=%d\n",
600 i, *volt_table, efuse_val, info->opp_sel);
602 /* Use recommended Vset bits from Efuse */
603 if (!abb->ldo_base) {
605 dev_err(dev, "prop'%s':v=%d vst=%x LDO base?\n",
606 pname, *volt_table, vset_mask);
609 info->vset = (efuse_val & vset_mask) >> __ffs(vset_mask);
610 dev_dbg(dev, "[%d]v=%d vset=%x\n", i, *volt_table, info->vset);
612 switch (info->opp_sel) {
613 case TI_ABB_NOMINAL_OPP:
614 case TI_ABB_FAST_OPP:
615 case TI_ABB_SLOW_OPP:
619 dev_err(dev, "%s:[%d]v=%d, ABB=%d is invalid! Abort!\n",
620 __func__, i, *volt_table, info->opp_sel);
625 /* Setup the min/max voltage constraints from the supported list */
632 static const struct regulator_ops ti_abb_reg_ops = {
633 .list_voltage = regulator_list_voltage_table,
635 .set_voltage_sel = ti_abb_set_voltage_sel,
636 .get_voltage_sel = ti_abb_get_voltage_sel,
639 /* Default ABB block offsets, IF this changes in future, create new one */
640 static const struct ti_abb_reg abb_regs_v1 = {
641 /* WARNING: registers are wrongly documented in TRM */
645 .sr2_wtcnt_value_mask = (0xff << 8),
646 .fbb_sel_mask = (0x01 << 2),
647 .rbb_sel_mask = (0x01 << 1),
648 .sr2_en_mask = (0x01 << 0),
650 .opp_change_mask = (0x01 << 2),
651 .opp_sel_mask = (0x03 << 0),
654 static const struct ti_abb_reg abb_regs_v2 = {
658 .sr2_wtcnt_value_mask = (0xff << 8),
659 .fbb_sel_mask = (0x01 << 2),
660 .rbb_sel_mask = (0x01 << 1),
661 .sr2_en_mask = (0x01 << 0),
663 .opp_change_mask = (0x01 << 2),
664 .opp_sel_mask = (0x03 << 0),
667 static const struct ti_abb_reg abb_regs_generic = {
668 .sr2_wtcnt_value_mask = (0xff << 8),
669 .fbb_sel_mask = (0x01 << 2),
670 .rbb_sel_mask = (0x01 << 1),
671 .sr2_en_mask = (0x01 << 0),
673 .opp_change_mask = (0x01 << 2),
674 .opp_sel_mask = (0x03 << 0),
677 static const struct of_device_id ti_abb_of_match[] = {
678 {.compatible = "ti,abb-v1", .data = &abb_regs_v1},
679 {.compatible = "ti,abb-v2", .data = &abb_regs_v2},
680 {.compatible = "ti,abb-v3", .data = &abb_regs_generic},
684 MODULE_DEVICE_TABLE(of, ti_abb_of_match);
687 * ti_abb_probe() - Initialize an ABB ldo instance
688 * @pdev: ABB platform device
690 * Initializes an individual ABB LDO for required Body-Bias. ABB is used to
691 * addional bias supply to SoC modules for power savings or mandatory stability
692 * configuration at certain Operating Performance Points(OPPs).
694 * Return: 0 on success or appropriate error value when fails
696 static int ti_abb_probe(struct platform_device *pdev)
698 struct device *dev = &pdev->dev;
699 const struct of_device_id *match;
700 struct resource *res;
702 struct regulator_init_data *initdata = NULL;
703 struct regulator_dev *rdev = NULL;
704 struct regulator_desc *desc;
705 struct regulation_constraints *c;
706 struct regulator_config config = { };
710 match = of_match_device(ti_abb_of_match, dev);
712 /* We do not expect this to happen */
713 dev_err(dev, "%s: Unable to match device\n", __func__);
717 dev_err(dev, "%s: Bad data in match\n", __func__);
721 abb = devm_kzalloc(dev, sizeof(struct ti_abb), GFP_KERNEL);
724 abb->regs = match->data;
726 /* Map ABB resources */
727 if (abb->regs->setup_off || abb->regs->control_off) {
728 abb->base = devm_platform_ioremap_resource_byname(pdev, "base-address");
729 if (IS_ERR(abb->base))
730 return PTR_ERR(abb->base);
732 abb->setup_reg = abb->base + abb->regs->setup_off;
733 abb->control_reg = abb->base + abb->regs->control_off;
736 abb->control_reg = devm_platform_ioremap_resource_byname(pdev, "control-address");
737 if (IS_ERR(abb->control_reg))
738 return PTR_ERR(abb->control_reg);
740 abb->setup_reg = devm_platform_ioremap_resource_byname(pdev, "setup-address");
741 if (IS_ERR(abb->setup_reg))
742 return PTR_ERR(abb->setup_reg);
745 abb->int_base = devm_platform_ioremap_resource_byname(pdev, "int-address");
746 if (IS_ERR(abb->int_base))
747 return PTR_ERR(abb->int_base);
749 /* Map Optional resources */
750 pname = "efuse-address";
751 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname);
753 dev_dbg(dev, "Missing '%s' IO resource\n", pname);
759 * We may have shared efuse register offsets which are read-only
762 abb->efuse_base = devm_ioremap(dev, res->start,
764 if (!abb->efuse_base) {
765 dev_err(dev, "Unable to map '%s'\n", pname);
769 pname = "ldo-address";
770 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname);
772 dev_dbg(dev, "Missing '%s' IO resource\n", pname);
776 abb->ldo_base = devm_ioremap_resource(dev, res);
777 if (IS_ERR(abb->ldo_base))
778 return PTR_ERR(abb->ldo_base);
780 /* IF ldo_base is set, the following are mandatory */
781 pname = "ti,ldovbb-override-mask";
783 of_property_read_u32(pdev->dev.of_node, pname,
784 &abb->ldovbb_override_mask);
786 dev_err(dev, "Missing '%s' (%d)\n", pname, ret);
789 if (!abb->ldovbb_override_mask) {
790 dev_err(dev, "Invalid property:'%s' set as 0!\n", pname);
794 pname = "ti,ldovbb-vset-mask";
796 of_property_read_u32(pdev->dev.of_node, pname,
797 &abb->ldovbb_vset_mask);
799 dev_err(dev, "Missing '%s' (%d)\n", pname, ret);
802 if (!abb->ldovbb_vset_mask) {
803 dev_err(dev, "Invalid property:'%s' set as 0!\n", pname);
808 pname = "ti,tranxdone-status-mask";
810 of_property_read_u32(pdev->dev.of_node, pname,
813 dev_err(dev, "Missing '%s' (%d)\n", pname, ret);
816 if (!abb->txdone_mask) {
817 dev_err(dev, "Invalid property:'%s' set as 0!\n", pname);
821 initdata = of_get_regulator_init_data(dev, pdev->dev.of_node,
824 dev_err(dev, "%s: Unable to alloc regulator init data\n",
829 /* init ABB opp_sel table */
830 ret = ti_abb_init_table(dev, abb, initdata);
834 /* init ABB timing */
835 ret = ti_abb_init_timings(dev, abb);
840 desc->name = dev_name(dev);
841 desc->owner = THIS_MODULE;
842 desc->type = REGULATOR_VOLTAGE;
843 desc->ops = &ti_abb_reg_ops;
845 c = &initdata->constraints;
846 if (desc->n_voltages > 1)
847 c->valid_ops_mask |= REGULATOR_CHANGE_VOLTAGE;
851 config.init_data = initdata;
852 config.driver_data = abb;
853 config.of_node = pdev->dev.of_node;
855 rdev = devm_regulator_register(dev, desc, &config);
858 dev_err(dev, "%s: failed to register regulator(%d)\n",
862 platform_set_drvdata(pdev, rdev);
864 /* Enable the ldo if not already done by bootloader */
865 ti_abb_rmw(abb->regs->sr2_en_mask, 1, abb->setup_reg);
870 MODULE_ALIAS("platform:ti_abb");
872 static struct platform_driver ti_abb_driver = {
873 .probe = ti_abb_probe,
876 .of_match_table = of_match_ptr(ti_abb_of_match),
879 module_platform_driver(ti_abb_driver);
881 MODULE_DESCRIPTION("Texas Instruments ABB LDO regulator driver");
882 MODULE_AUTHOR("Texas Instruments Inc.");
883 MODULE_LICENSE("GPL v2");