Lines Matching defs:abb
143 * @abb: pointer to the abb instance
147 static inline bool ti_abb_check_txdone(const struct ti_abb *abb)
149 return !!(readl(abb->int_base) & abb->txdone_mask);
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);
164 * @abb: pointer to the abb instance
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);
182 __func__, timeout, readl(abb->int_base));
189 * @abb: pointer to the abb instance
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);
209 __func__, timeout, readl(abb->int_base));
216 * @abb: pointer to the abb instance
219 static void ti_abb_program_ldovbb(struct device *dev, const struct ti_abb *abb,
224 val = readl(abb->ldo_base);
226 val &= ~(abb->ldovbb_override_mask | abb->ldovbb_vset_mask);
231 val |= abb->ldovbb_override_mask;
232 val |= info->vset << __ffs(abb->ldovbb_vset_mask);
236 writel(val, abb->ldo_base);
242 * @abb: pointer to the abb instance
247 static int ti_abb_set_opp(struct regulator_dev *rdev, struct ti_abb *abb,
250 const struct ti_abb_reg *regs = abb->regs;
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);
262 ti_abb_rmw(regs->rbb_sel_mask, 1, abb->setup_reg);
265 ti_abb_rmw(regs->fbb_sel_mask, 1, abb->setup_reg);
270 ti_abb_rmw(regs->opp_sel_mask, info->opp_sel, abb->control_reg);
277 if (abb->ldo_base && info->opp_sel != TI_ABB_NOMINAL_OPP)
278 ti_abb_program_ldovbb(dev, abb, info);
281 ti_abb_rmw(regs->opp_change_mask, 1, abb->control_reg);
284 ret = ti_abb_wait_txdone(dev, abb);
288 ret = ti_abb_clear_all_txdone(dev, abb);
297 if (abb->ldo_base && info->opp_sel == TI_ABB_NOMINAL_OPP)
298 ti_abb_program_ldovbb(dev, abb, info);
315 struct ti_abb *abb = rdev_get_drvdata(rdev);
320 if (!abb) {
326 if (!desc->n_voltages || !abb->info) {
340 if (sel == abb->current_info_idx) {
345 info = &abb->info[sel];
352 if (abb->current_info_idx == -EINVAL)
356 oinfo = &abb->info[abb->current_info_idx];
359 sel, abb->current_info_idx);
364 ret = ti_abb_set_opp(rdev, abb, info);
368 abb->current_info_idx = sel;
386 struct ti_abb *abb = rdev_get_drvdata(rdev);
389 if (!abb) {
395 if (!desc->n_voltages || !abb->info) {
402 if (abb->current_info_idx >= (int)desc->n_voltages) {
404 __func__, abb->current_info_idx, desc->n_voltages);
408 return abb->current_info_idx;
414 * @abb: pointer to the abb instance
418 static int ti_abb_init_timings(struct device *dev, struct ti_abb *abb)
422 const struct ti_abb_reg *regs = abb->regs;
427 ret = of_property_read_u32(dev->of_node, pname, &abb->settling_time);
434 if (!abb->settling_time) {
451 abb->clk = devm_clk_get(dev, NULL);
452 if (IS_ERR(abb->clk)) {
453 ret = PTR_ERR(abb->clk);
482 clk_rate = DIV_ROUND_CLOSEST(clk_get_rate(abb->clk), 1000000);
488 sr2_wt_cnt_val = DIV_ROUND_CLOSEST(abb->settling_time * 10, cycle_rate);
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);
501 * @abb: pointer to the abb instance
506 static int ti_abb_init_table(struct device *dev, struct ti_abb *abb,
539 abb->info = info;
546 abb->rdesc.n_voltages = num_entries;
547 abb->rdesc.volt_table = volt_table;
549 abb->current_info_idx = -EINVAL;
580 if (!abb->efuse_base) {
588 efuse_val = readl(abb->efuse_base + efuse_offset);
603 if (!abb->ldo_base) {
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},
701 struct ti_abb *abb;
721 abb = devm_kzalloc(dev, sizeof(struct ti_abb), GFP_KERNEL);
722 if (!abb)
724 abb->regs = match->data;
727 if (abb->regs->setup_off || abb->regs->control_off) {
730 abb->base = devm_ioremap_resource(dev, res);
731 if (IS_ERR(abb->base))
732 return PTR_ERR(abb->base);
734 abb->setup_reg = abb->base + abb->regs->setup_off;
735 abb->control_reg = abb->base + abb->regs->control_off;
740 abb->control_reg = devm_ioremap_resource(dev, res);
741 if (IS_ERR(abb->control_reg))
742 return PTR_ERR(abb->control_reg);
746 abb->setup_reg = devm_ioremap_resource(dev, res);
747 if (IS_ERR(abb->setup_reg))
748 return PTR_ERR(abb->setup_reg);
761 abb->int_base = devm_ioremap(dev, res->start,
763 if (!abb->int_base) {
781 abb->efuse_base = devm_ioremap(dev, res->start,
783 if (!abb->efuse_base) {
795 abb->ldo_base = devm_ioremap_resource(dev, res);
796 if (IS_ERR(abb->ldo_base))
797 return PTR_ERR(abb->ldo_base);
803 &abb->ldovbb_override_mask);
808 if (!abb->ldovbb_override_mask) {
816 &abb->ldovbb_vset_mask);
821 if (!abb->ldovbb_vset_mask) {
830 &abb->txdone_mask);
835 if (!abb->txdone_mask) {
841 &abb->rdesc);
849 ret = ti_abb_init_table(dev, abb, initdata);
854 ret = ti_abb_init_timings(dev, abb);
858 desc = &abb->rdesc;
871 config.driver_data = abb;
884 ti_abb_rmw(abb->regs->sr2_en_mask, 1, abb->setup_reg);