Lines Matching refs:abb

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()
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()
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()
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()
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()
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()
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()
273 ti_abb_rmw(regs->opp_change_mask, 1, abb->control_reg); 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()
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()
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()
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()
426 if (!abb->settling_time) { 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()
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()
498 static int ti_abb_init_table(struct device *dev, struct ti_abb *abb, in ti_abb_init_table() argument
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()
572 if (!abb->efuse_base) { in ti_abb_init_table()
580 efuse_val = readl(abb->efuse_base + efuse_offset); in ti_abb_init_table()
595 if (!abb->ldo_base) { in ti_abb_init_table()
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()
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()
737 abb->int_base = devm_platform_ioremap_resource_byname(pdev, "int-address"); in ti_abb_probe()
738 if (IS_ERR(abb->int_base)) in ti_abb_probe()
739 return PTR_ERR(abb->int_base); in ti_abb_probe()
754 abb->efuse_base = devm_ioremap(dev, res->start, in ti_abb_probe()
756 if (!abb->efuse_base) { in ti_abb_probe()
768 abb->ldo_base = devm_ioremap_resource(dev, res); in ti_abb_probe()
769 if (IS_ERR(abb->ldo_base)) in ti_abb_probe()
770 return PTR_ERR(abb->ldo_base); in ti_abb_probe()
776 &abb->ldovbb_override_mask); in ti_abb_probe()
781 if (!abb->ldovbb_override_mask) { in ti_abb_probe()
789 &abb->ldovbb_vset_mask); in ti_abb_probe()
794 if (!abb->ldovbb_vset_mask) { in ti_abb_probe()
803 &abb->txdone_mask); in ti_abb_probe()
808 if (!abb->txdone_mask) { in ti_abb_probe()
814 &abb->rdesc); in ti_abb_probe()
822 ret = ti_abb_init_table(dev, abb, initdata); in ti_abb_probe()
827 ret = ti_abb_init_timings(dev, abb); in ti_abb_probe()
831 desc = &abb->rdesc; in ti_abb_probe()
844 config.driver_data = abb; in ti_abb_probe()
857 ti_abb_rmw(abb->regs->sr2_en_mask, 1, abb->setup_reg); in ti_abb_probe()