• Home
  • Raw
  • Download

Lines Matching full:abb

3  * Texas Instruments SoC Adaptive Body Bias(ABB) Regulator
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
35 * struct ti_abb_info - ABB information per voltage setting
48 * struct ti_abb_reg - Register description for ABB block
74 * struct ti_abb - ABB instance data
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
81 * @efuse_base: (optional) efuse base address for ABB modes
83 * @regs: pointer to struct ti_abb_reg for ABB block
88 * @info: array to per voltage ABB configuration
134 * ti_abb_check_txdone() - handy wrapper to check ABB tranxdone status
135 * @abb: pointer to the abb instance
139 static inline bool ti_abb_check_txdone(const struct ti_abb *abb) in ti_abb_check_txdone() argument
141 return !!(readl(abb->int_base) & abb->txdone_mask); in ti_abb_check_txdone()
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) in ti_abb_clear_txdone() argument
150 writel(abb->txdone_mask, abb->int_base); in ti_abb_clear_txdone()
154 * ti_abb_wait_txdone() - waits for ABB tranxdone event
156 * @abb: pointer to the abb instance
160 static int ti_abb_wait_txdone(struct device *dev, struct ti_abb *abb) in ti_abb_wait_txdone() argument
165 while (timeout++ <= abb->settling_time) { in ti_abb_wait_txdone()
166 status = ti_abb_check_txdone(abb); in ti_abb_wait_txdone()
174 __func__, timeout, readl(abb->int_base)); in ti_abb_wait_txdone()
179 * ti_abb_clear_all_txdone() - clears ABB tranxdone event
181 * @abb: pointer to the abb instance
185 static int ti_abb_clear_all_txdone(struct device *dev, const struct ti_abb *abb) in ti_abb_clear_all_txdone() argument
190 while (timeout++ <= abb->settling_time) { in ti_abb_clear_all_txdone()
191 ti_abb_clear_txdone(abb); in ti_abb_clear_all_txdone()
193 status = ti_abb_check_txdone(abb); in ti_abb_clear_all_txdone()
201 __func__, timeout, readl(abb->int_base)); in ti_abb_clear_all_txdone()
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, in ti_abb_program_ldovbb() argument
216 val = readl(abb->ldo_base); in ti_abb_program_ldovbb()
218 val &= ~(abb->ldovbb_override_mask | abb->ldovbb_vset_mask); in ti_abb_program_ldovbb()
223 val |= abb->ldovbb_override_mask; in ti_abb_program_ldovbb()
224 val |= info->vset << __ffs(abb->ldovbb_vset_mask); in ti_abb_program_ldovbb()
228 writel(val, abb->ldo_base); in ti_abb_program_ldovbb()
232 * ti_abb_set_opp() - Setup ABB and LDO VBB for required bias
234 * @abb: pointer to the abb instance
235 * @info: ABB info to program
239 static int ti_abb_set_opp(struct regulator_dev *rdev, struct ti_abb *abb, in ti_abb_set_opp() argument
242 const struct ti_abb_reg *regs = abb->regs; in ti_abb_set_opp()
246 ret = ti_abb_clear_all_txdone(dev, abb); in ti_abb_set_opp()
250 ti_abb_rmw(regs->fbb_sel_mask | regs->rbb_sel_mask, 0, abb->setup_reg); in ti_abb_set_opp()
254 ti_abb_rmw(regs->rbb_sel_mask, 1, abb->setup_reg); in ti_abb_set_opp()
257 ti_abb_rmw(regs->fbb_sel_mask, 1, abb->setup_reg); in ti_abb_set_opp()
261 /* program next state of ABB ldo */ in ti_abb_set_opp()
262 ti_abb_rmw(regs->opp_sel_mask, info->opp_sel, abb->control_reg); in ti_abb_set_opp()
269 if (abb->ldo_base && info->opp_sel != TI_ABB_NOMINAL_OPP) in ti_abb_set_opp()
270 ti_abb_program_ldovbb(dev, abb, info); in ti_abb_set_opp()
272 /* Initiate ABB ldo change */ in ti_abb_set_opp()
273 ti_abb_rmw(regs->opp_change_mask, 1, abb->control_reg); in ti_abb_set_opp()
275 /* Wait for ABB LDO to complete transition to new Bias setting */ in ti_abb_set_opp()
276 ret = ti_abb_wait_txdone(dev, abb); in ti_abb_set_opp()
280 ret = ti_abb_clear_all_txdone(dev, abb); in ti_abb_set_opp()
289 if (abb->ldo_base && info->opp_sel == TI_ABB_NOMINAL_OPP) in ti_abb_set_opp()
290 ti_abb_program_ldovbb(dev, abb, info); in ti_abb_set_opp()
297 * ti_abb_set_voltage_sel() - regulator accessor function to set ABB LDO
299 * @sel: selector to index into required ABB LDO settings (maps to
307 struct ti_abb *abb = rdev_get_drvdata(rdev); in ti_abb_set_voltage_sel() local
312 if (!abb) { in ti_abb_set_voltage_sel()
318 if (!desc->n_voltages || !abb->info) { in ti_abb_set_voltage_sel()
332 if (sel == abb->current_info_idx) { in ti_abb_set_voltage_sel()
337 info = &abb->info[sel]; in ti_abb_set_voltage_sel()
344 if (abb->current_info_idx == -EINVAL) in ti_abb_set_voltage_sel()
348 oinfo = &abb->info[abb->current_info_idx]; in ti_abb_set_voltage_sel()
351 sel, abb->current_info_idx); in ti_abb_set_voltage_sel()
356 ret = ti_abb_set_opp(rdev, abb, info); in ti_abb_set_voltage_sel()
360 abb->current_info_idx = sel; in ti_abb_set_voltage_sel()
370 * ti_abb_get_voltage_sel() - Regulator accessor to get current ABB LDO setting
378 struct ti_abb *abb = rdev_get_drvdata(rdev); in ti_abb_get_voltage_sel() local
381 if (!abb) { in ti_abb_get_voltage_sel()
387 if (!desc->n_voltages || !abb->info) { in ti_abb_get_voltage_sel()
394 if (abb->current_info_idx >= (int)desc->n_voltages) { in ti_abb_get_voltage_sel()
396 __func__, abb->current_info_idx, desc->n_voltages); in ti_abb_get_voltage_sel()
400 return abb->current_info_idx; in ti_abb_get_voltage_sel()
404 * ti_abb_init_timings() - setup ABB clock timing for the current platform
406 * @abb: pointer to the abb instance
410 static int ti_abb_init_timings(struct device *dev, struct ti_abb *abb) in ti_abb_init_timings() argument
414 const struct ti_abb_reg *regs = abb->regs; in ti_abb_init_timings()
419 ret = of_property_read_u32(dev->of_node, pname, &abb->settling_time); in ti_abb_init_timings()
425 /* ABB LDO cannot be settle in 0 time */ in ti_abb_init_timings()
426 if (!abb->settling_time) { in ti_abb_init_timings()
437 /* ABB LDO cannot be settle in 0 clock cycles */ in ti_abb_init_timings()
443 abb->clk = devm_clk_get(dev, NULL); in ti_abb_init_timings()
444 if (IS_ERR(abb->clk)) { in ti_abb_init_timings()
445 ret = PTR_ERR(abb->clk); in ti_abb_init_timings()
451 * SR2_WTCNT_VALUE is the settling time for the ABB ldo after a in ti_abb_init_timings()
474 clk_rate = DIV_ROUND_CLOSEST(clk_get_rate(abb->clk), 1000000); in ti_abb_init_timings()
480 sr2_wt_cnt_val = DIV_ROUND_CLOSEST(abb->settling_time * 10, cycle_rate); in ti_abb_init_timings()
483 clk_get_rate(abb->clk), sr2_wt_cnt_val); in ti_abb_init_timings()
485 ti_abb_rmw(regs->sr2_wtcnt_value_mask, sr2_wt_cnt_val, abb->setup_reg); in ti_abb_init_timings()
491 * ti_abb_init_table() - Initialize ABB table from device tree
493 * @abb: pointer to the abb instance
498 static int ti_abb_init_table(struct device *dev, struct ti_abb *abb, in ti_abb_init_table() argument
511 * of voltage and a set of detection logic for ABB information for that in ti_abb_init_table()
531 abb->info = info; in ti_abb_init_table()
538 abb->rdesc.n_voltages = num_entries; in ti_abb_init_table()
539 abb->rdesc.volt_table = volt_table; in ti_abb_init_table()
541 abb->current_info_idx = -EINVAL; in ti_abb_init_table()
562 "[%d]v=%d ABB=%d ef=0x%x rbb=0x%x fbb=0x%x vset=0x%x\n", in ti_abb_init_table()
572 if (!abb->efuse_base) { in ti_abb_init_table()
580 efuse_val = readl(abb->efuse_base + efuse_offset); in ti_abb_init_table()
582 /* Use ABB recommendation from Efuse */ in ti_abb_init_table()
591 "[%d]v=%d efusev=0x%x final ABB=%d\n", in ti_abb_init_table()
595 if (!abb->ldo_base) { in ti_abb_init_table()
611 dev_err(dev, "%s:[%d]v=%d, ABB=%d is invalid! Abort!\n", in ti_abb_init_table()
631 /* Default ABB block offsets, IF this changes in future, create new one */
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},
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
693 struct ti_abb *abb; in ti_abb_probe() local
713 abb = devm_kzalloc(dev, sizeof(struct ti_abb), GFP_KERNEL); in ti_abb_probe()
714 if (!abb) in ti_abb_probe()
716 abb->regs = match->data; in ti_abb_probe()
718 /* Map ABB resources */ in ti_abb_probe()
719 if (abb->regs->setup_off || abb->regs->control_off) { in ti_abb_probe()
720 abb->base = devm_platform_ioremap_resource_byname(pdev, "base-address"); in ti_abb_probe()
721 if (IS_ERR(abb->base)) in ti_abb_probe()
722 return PTR_ERR(abb->base); in ti_abb_probe()
724 abb->setup_reg = abb->base + abb->regs->setup_off; in ti_abb_probe()
725 abb->control_reg = abb->base + abb->regs->control_off; in ti_abb_probe()
728 abb->control_reg = devm_platform_ioremap_resource_byname(pdev, "control-address"); in ti_abb_probe()
729 if (IS_ERR(abb->control_reg)) in ti_abb_probe()
730 return PTR_ERR(abb->control_reg); in ti_abb_probe()
732 abb->setup_reg = devm_platform_ioremap_resource_byname(pdev, "setup-address"); in ti_abb_probe()
733 if (IS_ERR(abb->setup_reg)) in ti_abb_probe()
734 return PTR_ERR(abb->setup_reg); in ti_abb_probe()
745 * shared between regulator-abb-{ivahd,dspeve,gpu} driver in ti_abb_probe()
750 abb->int_base = devm_ioremap(dev, res->start, in ti_abb_probe()
752 if (!abb->int_base) { in ti_abb_probe()
770 abb->efuse_base = devm_ioremap(dev, res->start, in ti_abb_probe()
772 if (!abb->efuse_base) { in ti_abb_probe()
784 abb->ldo_base = devm_ioremap_resource(dev, res); in ti_abb_probe()
785 if (IS_ERR(abb->ldo_base)) in ti_abb_probe()
786 return PTR_ERR(abb->ldo_base); in ti_abb_probe()
792 &abb->ldovbb_override_mask); in ti_abb_probe()
797 if (!abb->ldovbb_override_mask) { in ti_abb_probe()
805 &abb->ldovbb_vset_mask); in ti_abb_probe()
810 if (!abb->ldovbb_vset_mask) { in ti_abb_probe()
819 &abb->txdone_mask); in ti_abb_probe()
824 if (!abb->txdone_mask) { in ti_abb_probe()
830 &abb->rdesc); in ti_abb_probe()
837 /* init ABB opp_sel table */ in ti_abb_probe()
838 ret = ti_abb_init_table(dev, abb, initdata); in ti_abb_probe()
842 /* init ABB timing */ in ti_abb_probe()
843 ret = ti_abb_init_timings(dev, abb); in ti_abb_probe()
847 desc = &abb->rdesc; in ti_abb_probe()
860 config.driver_data = abb; in ti_abb_probe()
873 ti_abb_rmw(abb->regs->sr2_en_mask, 1, abb->setup_reg); in ti_abb_probe()
890 MODULE_DESCRIPTION("Texas Instruments ABB LDO regulator driver");