1 // SPDX-License-Identifier: GPL-2.0-only
3 * Texas Instruments SoC Adaptive Body Bias(ABB) Regulator
5 * Copyright (C) 2011 Texas Instruments, Inc.
6 * Mike Turquette <mturquette@ti.com>
8 * Copyright (C) 2012-2013 Texas Instruments, Inc.
9 * Andrii Tseglytskyi <andrii.tseglytskyi@ti.com>
10 * Nishanth Menon <nm@ti.com>
12 #include <linux/clk.h>
13 #include <linux/delay.h>
14 #include <linux/err.h>
16 #include <linux/module.h>
17 #include <linux/of_device.h>
19 #include <linux/platform_device.h>
20 #include <linux/regulator/driver.h>
21 #include <linux/regulator/machine.h>
22 #include <linux/regulator/of_regulator.h>
25 * ABB LDO operating states:
26 * NOMINAL_OPP: bypasses the ABB LDO
27 * FAST_OPP: sets ABB LDO to Forward Body-Bias
28 * SLOW_OPP: sets ABB LDO to Reverse Body-Bias
30 #define TI_ABB_NOMINAL_OPP 0
31 #define TI_ABB_FAST_OPP 1
32 #define TI_ABB_SLOW_OPP 3
35 * struct ti_abb_info - ABB information per voltage setting
36 * @opp_sel: one of TI_ABB macro
37 * @vset: (optional) vset value that LDOVBB needs to be overridden with.
39 * Array of per voltage entries organized in the same order as regulator_desc's
40 * volt_table list. (selector is used to index from this array)
48 * struct ti_abb_reg - Register description for ABB block
49 * @setup_off: setup register offset from base
50 * @control_off: control register offset from base
51 * @sr2_wtcnt_value_mask: setup register- sr2_wtcnt_value mask
52 * @fbb_sel_mask: setup register- FBB sel mask
53 * @rbb_sel_mask: setup register- RBB sel mask
54 * @sr2_en_mask: setup register- enable mask
55 * @opp_change_mask: control register - mask to trigger LDOVBB change
56 * @opp_sel_mask: control register - mask for mode to operate
62 /* Setup register fields */
63 u32 sr2_wtcnt_value_mask;
68 /* Control register fields */
74 * struct ti_abb - ABB instance data
75 * @rdesc: regulator descriptor
76 * @clk: clock(usually sysclk) supplying ABB block
77 * @base: base address of ABB block
78 * @setup_reg: setup register of ABB block
79 * @control_reg: control register of ABB block
80 * @int_base: interrupt register base address
81 * @efuse_base: (optional) efuse base address for ABB modes
82 * @ldo_base: (optional) LDOVBB vset override base address
83 * @regs: pointer to struct ti_abb_reg for ABB block
84 * @txdone_mask: mask on int_base for tranxdone interrupt
85 * @ldovbb_override_mask: mask to ldo_base for overriding default LDO VBB
86 * vset with value from efuse
87 * @ldovbb_vset_mask: mask to ldo_base for providing the VSET override
88 * @info: array to per voltage ABB configuration
89 * @current_info_idx: current index to info
90 * @settling_time: SoC specific settling time for LDO VBB
93 struct regulator_desc rdesc;
96 void __iomem *setup_reg;
97 void __iomem *control_reg;
98 void __iomem *int_base;
99 void __iomem *efuse_base;
100 void __iomem *ldo_base;
102 const struct ti_abb_reg *regs;
104 u32 ldovbb_override_mask;
105 u32 ldovbb_vset_mask;
107 struct ti_abb_info *info;
108 int current_info_idx;
114 * ti_abb_rmw() - handy wrapper to set specific register bits
115 * @mask: mask for register field
116 * @value: value shifted to mask location and written
117 * @reg: register address
119 * Return: final register value (may be unused)
121 static inline u32 ti_abb_rmw(u32 mask, u32 value, void __iomem *reg)
127 val |= (value << __ffs(mask)) & mask;
134 * ti_abb_check_txdone() - handy wrapper to check ABB tranxdone status
135 * @abb: pointer to the abb instance
137 * Return: true or false
139 static inline bool ti_abb_check_txdone(const struct ti_abb *abb)
141 return !!(readl(abb->int_base) & abb->txdone_mask);
145 * ti_abb_clear_txdone() - handy wrapper to clear ABB tranxdone status
146 * @abb: pointer to the abb instance
148 static inline void ti_abb_clear_txdone(const struct ti_abb *abb)
150 writel(abb->txdone_mask, abb->int_base);
154 * ti_abb_wait_txdone() - waits for ABB tranxdone event
156 * @abb: pointer to the abb instance
158 * Return: 0 on success or -ETIMEDOUT if the event is not cleared on time.
160 static int ti_abb_wait_txdone(struct device *dev, struct ti_abb *abb)
165 while (timeout++ <= abb->settling_time) {
166 status = ti_abb_check_txdone(abb);
173 dev_warn_ratelimited(dev, "%s:TRANXDONE timeout(%duS) int=0x%08x\n",
174 __func__, timeout, readl(abb->int_base));
179 * ti_abb_clear_all_txdone() - clears ABB tranxdone event
181 * @abb: pointer to the abb instance
183 * Return: 0 on success or -ETIMEDOUT if the event is not cleared on time.
185 static int ti_abb_clear_all_txdone(struct device *dev, const struct ti_abb *abb)
190 while (timeout++ <= abb->settling_time) {
191 ti_abb_clear_txdone(abb);
193 status = ti_abb_check_txdone(abb);
200 dev_warn_ratelimited(dev, "%s:TRANXDONE timeout(%duS) int=0x%08x\n",
201 __func__, timeout, readl(abb->int_base));
206 * ti_abb_program_ldovbb() - program LDOVBB register for override value
208 * @abb: pointer to the abb instance
209 * @info: ABB info to program
211 static void ti_abb_program_ldovbb(struct device *dev, const struct ti_abb *abb,
212 struct ti_abb_info *info)
216 val = readl(abb->ldo_base);
217 /* clear up previous values */
218 val &= ~(abb->ldovbb_override_mask | abb->ldovbb_vset_mask);
220 switch (info->opp_sel) {
221 case TI_ABB_SLOW_OPP:
222 case TI_ABB_FAST_OPP:
223 val |= abb->ldovbb_override_mask;
224 val |= info->vset << __ffs(abb->ldovbb_vset_mask);
228 writel(val, abb->ldo_base);
232 * ti_abb_set_opp() - Setup ABB and LDO VBB for required bias
233 * @rdev: regulator device
234 * @abb: pointer to the abb instance
235 * @info: ABB info to program
237 * Return: 0 on success or appropriate error value when fails
239 static int ti_abb_set_opp(struct regulator_dev *rdev, struct ti_abb *abb,
240 struct ti_abb_info *info)
242 const struct ti_abb_reg *regs = abb->regs;
243 struct device *dev = &rdev->dev;
246 ret = ti_abb_clear_all_txdone(dev, abb);
250 ti_abb_rmw(regs->fbb_sel_mask | regs->rbb_sel_mask, 0, abb->setup_reg);
252 switch (info->opp_sel) {
253 case TI_ABB_SLOW_OPP:
254 ti_abb_rmw(regs->rbb_sel_mask, 1, abb->setup_reg);
256 case TI_ABB_FAST_OPP:
257 ti_abb_rmw(regs->fbb_sel_mask, 1, abb->setup_reg);
261 /* program next state of ABB ldo */
262 ti_abb_rmw(regs->opp_sel_mask, info->opp_sel, abb->control_reg);
265 * program LDO VBB vset override if needed for !bypass mode
266 * XXX: Do not switch sequence - for !bypass, LDO override reset *must*
267 * be performed *before* switch to bias mode else VBB glitches.
269 if (abb->ldo_base && info->opp_sel != TI_ABB_NOMINAL_OPP)
270 ti_abb_program_ldovbb(dev, abb, info);
272 /* Initiate ABB ldo change */
273 ti_abb_rmw(regs->opp_change_mask, 1, abb->control_reg);
275 /* Wait for ABB LDO to complete transition to new Bias setting */
276 ret = ti_abb_wait_txdone(dev, abb);
280 ret = ti_abb_clear_all_txdone(dev, abb);
285 * Reset LDO VBB vset override bypass mode
286 * XXX: Do not switch sequence - for bypass, LDO override reset *must*
287 * be performed *after* switch to bypass else VBB glitches.
289 if (abb->ldo_base && info->opp_sel == TI_ABB_NOMINAL_OPP)
290 ti_abb_program_ldovbb(dev, abb, info);
297 * ti_abb_set_voltage_sel() - regulator accessor function to set ABB LDO
298 * @rdev: regulator device
299 * @sel: selector to index into required ABB LDO settings (maps to
300 * regulator descriptor's volt_table)
302 * Return: 0 on success or appropriate error value when fails
304 static int ti_abb_set_voltage_sel(struct regulator_dev *rdev, unsigned int sel)
306 const struct regulator_desc *desc = rdev->desc;
307 struct ti_abb *abb = rdev_get_drvdata(rdev);
308 struct device *dev = &rdev->dev;
309 struct ti_abb_info *info, *oinfo;
313 dev_err_ratelimited(dev, "%s: No regulator drvdata\n",
318 if (!desc->n_voltages || !abb->info) {
319 dev_err_ratelimited(dev,
320 "%s: No valid voltage table entries?\n",
325 if (sel >= desc->n_voltages) {
326 dev_err(dev, "%s: sel idx(%d) >= n_voltages(%d)\n", __func__,
327 sel, desc->n_voltages);
331 /* If we are in the same index as we were, nothing to do here! */
332 if (sel == abb->current_info_idx) {
333 dev_dbg(dev, "%s: Already at sel=%d\n", __func__, sel);
337 info = &abb->info[sel];
339 * When Linux kernel is starting up, we aren't sure of the
340 * Bias configuration that bootloader has configured.
341 * So, we get to know the actual setting the first time
342 * we are asked to transition.
344 if (abb->current_info_idx == -EINVAL)
347 /* If data is exactly the same, then just update index, no change */
348 oinfo = &abb->info[abb->current_info_idx];
349 if (!memcmp(info, oinfo, sizeof(*info))) {
350 dev_dbg(dev, "%s: Same data new idx=%d, old idx=%d\n", __func__,
351 sel, abb->current_info_idx);
356 ret = ti_abb_set_opp(rdev, abb, info);
360 abb->current_info_idx = sel;
362 dev_err_ratelimited(dev,
363 "%s: Volt[%d] idx[%d] mode[%d] Fail(%d)\n",
364 __func__, desc->volt_table[sel], sel,
370 * ti_abb_get_voltage_sel() - Regulator accessor to get current ABB LDO setting
371 * @rdev: regulator device
373 * Return: 0 on success or appropriate error value when fails
375 static int ti_abb_get_voltage_sel(struct regulator_dev *rdev)
377 const struct regulator_desc *desc = rdev->desc;
378 struct ti_abb *abb = rdev_get_drvdata(rdev);
379 struct device *dev = &rdev->dev;
382 dev_err_ratelimited(dev, "%s: No regulator drvdata\n",
387 if (!desc->n_voltages || !abb->info) {
388 dev_err_ratelimited(dev,
389 "%s: No valid voltage table entries?\n",
394 if (abb->current_info_idx >= (int)desc->n_voltages) {
395 dev_err(dev, "%s: Corrupted data? idx(%d) >= n_voltages(%d)\n",
396 __func__, abb->current_info_idx, desc->n_voltages);
400 return abb->current_info_idx;
404 * ti_abb_init_timings() - setup ABB clock timing for the current platform
406 * @abb: pointer to the abb instance
408 * Return: 0 if timing is updated, else returns error result.
410 static int ti_abb_init_timings(struct device *dev, struct ti_abb *abb)
413 u32 clk_rate, sr2_wt_cnt_val, cycle_rate;
414 const struct ti_abb_reg *regs = abb->regs;
416 char *pname = "ti,settling-time";
418 /* read device tree properties */
419 ret = of_property_read_u32(dev->of_node, pname, &abb->settling_time);
421 dev_err(dev, "Unable to get property '%s'(%d)\n", pname, ret);
425 /* ABB LDO cannot be settle in 0 time */
426 if (!abb->settling_time) {
427 dev_err(dev, "Invalid property:'%s' set as 0!\n", pname);
431 pname = "ti,clock-cycles";
432 ret = of_property_read_u32(dev->of_node, pname, &clock_cycles);
434 dev_err(dev, "Unable to get property '%s'(%d)\n", pname, ret);
437 /* ABB LDO cannot be settle in 0 clock cycles */
439 dev_err(dev, "Invalid property:'%s' set as 0!\n", pname);
443 abb->clk = devm_clk_get(dev, NULL);
444 if (IS_ERR(abb->clk)) {
445 ret = PTR_ERR(abb->clk);
446 dev_err(dev, "%s: Unable to get clk(%d)\n", __func__, ret);
451 * SR2_WTCNT_VALUE is the settling time for the ABB ldo after a
452 * transition and must be programmed with the correct time at boot.
453 * The value programmed into the register is the number of SYS_CLK
454 * clock cycles that match a given wall time profiled for the ldo.
455 * This value depends on:
456 * settling time of ldo in micro-seconds (varies per OMAP family)
457 * # of clock cycles per SYS_CLK period (varies per OMAP family)
458 * the SYS_CLK frequency in MHz (varies per board)
461 * ldo settling time (in micro-seconds)
462 * SR2_WTCNT_VALUE = ------------------------------------------
463 * (# system clock cycles) * (sys_clk period)
467 * SR2_WTCNT_VALUE = settling time / (# SYS_CLK cycles / SYS_CLK rate))
469 * To avoid dividing by zero multiply both "# clock cycles" and
470 * "settling time" by 10 such that the final result is the one we want.
473 /* Convert SYS_CLK rate to MHz & prevent divide by zero */
474 clk_rate = DIV_ROUND_CLOSEST(clk_get_rate(abb->clk), 1000000);
476 /* Calculate cycle rate */
477 cycle_rate = DIV_ROUND_CLOSEST(clock_cycles * 10, clk_rate);
479 /* Calculate SR2_WTCNT_VALUE */
480 sr2_wt_cnt_val = DIV_ROUND_CLOSEST(abb->settling_time * 10, cycle_rate);
482 dev_dbg(dev, "%s: Clk_rate=%ld, sr2_cnt=0x%08x\n", __func__,
483 clk_get_rate(abb->clk), sr2_wt_cnt_val);
485 ti_abb_rmw(regs->sr2_wtcnt_value_mask, sr2_wt_cnt_val, abb->setup_reg);
491 * ti_abb_init_table() - Initialize ABB table from device tree
493 * @abb: pointer to the abb instance
494 * @rinit_data: regulator initdata
496 * Return: 0 on success or appropriate error value when fails
498 static int ti_abb_init_table(struct device *dev, struct ti_abb *abb,
499 struct regulator_init_data *rinit_data)
501 struct ti_abb_info *info;
502 const u32 num_values = 6;
503 char *pname = "ti,abb_info";
505 unsigned int *volt_table;
506 int num_entries, min_uV = INT_MAX, max_uV = 0;
507 struct regulation_constraints *c = &rinit_data->constraints;
510 * Each abb_info is a set of n-tuple, where n is num_values, consisting
511 * of voltage and a set of detection logic for ABB information for that
514 num_entries = of_property_count_u32_elems(dev->of_node, pname);
515 if (num_entries < 0) {
516 dev_err(dev, "No '%s' property?\n", pname);
520 if (!num_entries || (num_entries % num_values)) {
521 dev_err(dev, "All '%s' list entries need %d vals\n", pname,
525 num_entries /= num_values;
527 info = devm_kcalloc(dev, num_entries, sizeof(*info), GFP_KERNEL);
533 volt_table = devm_kcalloc(dev, num_entries, sizeof(unsigned int),
538 abb->rdesc.n_voltages = num_entries;
539 abb->rdesc.volt_table = volt_table;
540 /* We do not know where the OPP voltage is at the moment */
541 abb->current_info_idx = -EINVAL;
543 for (i = 0; i < num_entries; i++, info++, volt_table++) {
544 u32 efuse_offset, rbb_mask, fbb_mask, vset_mask;
547 /* NOTE: num_values should equal to entries picked up here */
548 of_property_read_u32_index(dev->of_node, pname, i * num_values,
550 of_property_read_u32_index(dev->of_node, pname,
551 i * num_values + 1, &info->opp_sel);
552 of_property_read_u32_index(dev->of_node, pname,
553 i * num_values + 2, &efuse_offset);
554 of_property_read_u32_index(dev->of_node, pname,
555 i * num_values + 3, &rbb_mask);
556 of_property_read_u32_index(dev->of_node, pname,
557 i * num_values + 4, &fbb_mask);
558 of_property_read_u32_index(dev->of_node, pname,
559 i * num_values + 5, &vset_mask);
562 "[%d]v=%d ABB=%d ef=0x%x rbb=0x%x fbb=0x%x vset=0x%x\n",
563 i, *volt_table, info->opp_sel, efuse_offset, rbb_mask,
564 fbb_mask, vset_mask);
566 /* Find min/max for voltage set */
567 if (min_uV > *volt_table)
568 min_uV = *volt_table;
569 if (max_uV < *volt_table)
570 max_uV = *volt_table;
572 if (!abb->efuse_base) {
573 /* Ignore invalid data, but warn to help cleanup */
574 if (efuse_offset || rbb_mask || fbb_mask || vset_mask)
575 dev_err(dev, "prop '%s': v=%d,bad efuse/mask\n",
580 efuse_val = readl(abb->efuse_base + efuse_offset);
582 /* Use ABB recommendation from Efuse */
583 if (efuse_val & rbb_mask)
584 info->opp_sel = TI_ABB_SLOW_OPP;
585 else if (efuse_val & fbb_mask)
586 info->opp_sel = TI_ABB_FAST_OPP;
587 else if (rbb_mask || fbb_mask)
588 info->opp_sel = TI_ABB_NOMINAL_OPP;
591 "[%d]v=%d efusev=0x%x final ABB=%d\n",
592 i, *volt_table, efuse_val, info->opp_sel);
594 /* Use recommended Vset bits from Efuse */
595 if (!abb->ldo_base) {
597 dev_err(dev, "prop'%s':v=%d vst=%x LDO base?\n",
598 pname, *volt_table, vset_mask);
601 info->vset = (efuse_val & vset_mask) >> __ffs(vset_mask);
602 dev_dbg(dev, "[%d]v=%d vset=%x\n", i, *volt_table, info->vset);
604 switch (info->opp_sel) {
605 case TI_ABB_NOMINAL_OPP:
606 case TI_ABB_FAST_OPP:
607 case TI_ABB_SLOW_OPP:
611 dev_err(dev, "%s:[%d]v=%d, ABB=%d is invalid! Abort!\n",
612 __func__, i, *volt_table, info->opp_sel);
617 /* Setup the min/max voltage constraints from the supported list */
624 static const struct regulator_ops ti_abb_reg_ops = {
625 .list_voltage = regulator_list_voltage_table,
627 .set_voltage_sel = ti_abb_set_voltage_sel,
628 .get_voltage_sel = ti_abb_get_voltage_sel,
631 /* Default ABB block offsets, IF this changes in future, create new one */
632 static const struct ti_abb_reg abb_regs_v1 = {
633 /* WARNING: registers are wrongly documented in TRM */
637 .sr2_wtcnt_value_mask = (0xff << 8),
638 .fbb_sel_mask = (0x01 << 2),
639 .rbb_sel_mask = (0x01 << 1),
640 .sr2_en_mask = (0x01 << 0),
642 .opp_change_mask = (0x01 << 2),
643 .opp_sel_mask = (0x03 << 0),
646 static const struct ti_abb_reg abb_regs_v2 = {
650 .sr2_wtcnt_value_mask = (0xff << 8),
651 .fbb_sel_mask = (0x01 << 2),
652 .rbb_sel_mask = (0x01 << 1),
653 .sr2_en_mask = (0x01 << 0),
655 .opp_change_mask = (0x01 << 2),
656 .opp_sel_mask = (0x03 << 0),
659 static const struct ti_abb_reg abb_regs_generic = {
660 .sr2_wtcnt_value_mask = (0xff << 8),
661 .fbb_sel_mask = (0x01 << 2),
662 .rbb_sel_mask = (0x01 << 1),
663 .sr2_en_mask = (0x01 << 0),
665 .opp_change_mask = (0x01 << 2),
666 .opp_sel_mask = (0x03 << 0),
669 static const struct of_device_id ti_abb_of_match[] = {
670 {.compatible = "ti,abb-v1", .data = &abb_regs_v1},
671 {.compatible = "ti,abb-v2", .data = &abb_regs_v2},
672 {.compatible = "ti,abb-v3", .data = &abb_regs_generic},
676 MODULE_DEVICE_TABLE(of, ti_abb_of_match);
679 * ti_abb_probe() - Initialize an ABB ldo instance
680 * @pdev: ABB platform device
682 * Initializes an individual ABB LDO for required Body-Bias. ABB is used to
683 * additional bias supply to SoC modules for power savings or mandatory stability
684 * configuration at certain Operating Performance Points(OPPs).
686 * Return: 0 on success or appropriate error value when fails
688 static int ti_abb_probe(struct platform_device *pdev)
690 struct device *dev = &pdev->dev;
691 const struct of_device_id *match;
692 struct resource *res;
694 struct regulator_init_data *initdata = NULL;
695 struct regulator_dev *rdev = NULL;
696 struct regulator_desc *desc;
697 struct regulation_constraints *c;
698 struct regulator_config config = { };
702 match = of_match_device(ti_abb_of_match, dev);
704 /* We do not expect this to happen */
705 dev_err(dev, "%s: Unable to match device\n", __func__);
709 dev_err(dev, "%s: Bad data in match\n", __func__);
713 abb = devm_kzalloc(dev, sizeof(struct ti_abb), GFP_KERNEL);
716 abb->regs = match->data;
718 /* Map ABB resources */
719 if (abb->regs->setup_off || abb->regs->control_off) {
720 abb->base = devm_platform_ioremap_resource_byname(pdev, "base-address");
721 if (IS_ERR(abb->base))
722 return PTR_ERR(abb->base);
724 abb->setup_reg = abb->base + abb->regs->setup_off;
725 abb->control_reg = abb->base + abb->regs->control_off;
728 abb->control_reg = devm_platform_ioremap_resource_byname(pdev, "control-address");
729 if (IS_ERR(abb->control_reg))
730 return PTR_ERR(abb->control_reg);
732 abb->setup_reg = devm_platform_ioremap_resource_byname(pdev, "setup-address");
733 if (IS_ERR(abb->setup_reg))
734 return PTR_ERR(abb->setup_reg);
737 abb->int_base = devm_platform_ioremap_resource_byname(pdev, "int-address");
738 if (IS_ERR(abb->int_base))
739 return PTR_ERR(abb->int_base);
741 /* Map Optional resources */
742 pname = "efuse-address";
743 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname);
745 dev_dbg(dev, "Missing '%s' IO resource\n", pname);
751 * We may have shared efuse register offsets which are read-only
754 abb->efuse_base = devm_ioremap(dev, res->start,
756 if (!abb->efuse_base) {
757 dev_err(dev, "Unable to map '%s'\n", pname);
761 pname = "ldo-address";
762 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname);
764 dev_dbg(dev, "Missing '%s' IO resource\n", pname);
768 abb->ldo_base = devm_ioremap_resource(dev, res);
769 if (IS_ERR(abb->ldo_base))
770 return PTR_ERR(abb->ldo_base);
772 /* IF ldo_base is set, the following are mandatory */
773 pname = "ti,ldovbb-override-mask";
775 of_property_read_u32(pdev->dev.of_node, pname,
776 &abb->ldovbb_override_mask);
778 dev_err(dev, "Missing '%s' (%d)\n", pname, ret);
781 if (!abb->ldovbb_override_mask) {
782 dev_err(dev, "Invalid property:'%s' set as 0!\n", pname);
786 pname = "ti,ldovbb-vset-mask";
788 of_property_read_u32(pdev->dev.of_node, pname,
789 &abb->ldovbb_vset_mask);
791 dev_err(dev, "Missing '%s' (%d)\n", pname, ret);
794 if (!abb->ldovbb_vset_mask) {
795 dev_err(dev, "Invalid property:'%s' set as 0!\n", pname);
800 pname = "ti,tranxdone-status-mask";
802 of_property_read_u32(pdev->dev.of_node, pname,
805 dev_err(dev, "Missing '%s' (%d)\n", pname, ret);
808 if (!abb->txdone_mask) {
809 dev_err(dev, "Invalid property:'%s' set as 0!\n", pname);
813 initdata = of_get_regulator_init_data(dev, pdev->dev.of_node,
816 dev_err(dev, "%s: Unable to alloc regulator init data\n",
821 /* init ABB opp_sel table */
822 ret = ti_abb_init_table(dev, abb, initdata);
826 /* init ABB timing */
827 ret = ti_abb_init_timings(dev, abb);
832 desc->name = dev_name(dev);
833 desc->owner = THIS_MODULE;
834 desc->type = REGULATOR_VOLTAGE;
835 desc->ops = &ti_abb_reg_ops;
837 c = &initdata->constraints;
838 if (desc->n_voltages > 1)
839 c->valid_ops_mask |= REGULATOR_CHANGE_VOLTAGE;
843 config.init_data = initdata;
844 config.driver_data = abb;
845 config.of_node = pdev->dev.of_node;
847 rdev = devm_regulator_register(dev, desc, &config);
850 dev_err(dev, "%s: failed to register regulator(%d)\n",
854 platform_set_drvdata(pdev, rdev);
856 /* Enable the ldo if not already done by bootloader */
857 ti_abb_rmw(abb->regs->sr2_en_mask, 1, abb->setup_reg);
862 MODULE_ALIAS("platform:ti_abb");
864 static struct platform_driver ti_abb_driver = {
865 .probe = ti_abb_probe,
868 .of_match_table = of_match_ptr(ti_abb_of_match),
871 module_platform_driver(ti_abb_driver);
873 MODULE_DESCRIPTION("Texas Instruments ABB LDO regulator driver");
874 MODULE_AUTHOR("Texas Instruments Inc.");
875 MODULE_LICENSE("GPL v2");