Lines Matching defs:abb

135  * @abb:	pointer to the abb instance
139 static inline bool ti_abb_check_txdone(const struct ti_abb *abb)
141 return !!(readl(abb->int_base) & abb->txdone_mask);
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);
156 * @abb: pointer to the abb instance
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);
174 __func__, timeout, readl(abb->int_base));
181 * @abb: pointer to the abb instance
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);
201 __func__, timeout, readl(abb->int_base));
208 * @abb: pointer to the abb instance
211 static void ti_abb_program_ldovbb(struct device *dev, const struct ti_abb *abb,
216 val = readl(abb->ldo_base);
218 val &= ~(abb->ldovbb_override_mask | abb->ldovbb_vset_mask);
223 val |= abb->ldovbb_override_mask;
224 val |= info->vset << __ffs(abb->ldovbb_vset_mask);
228 writel(val, abb->ldo_base);
234 * @abb: pointer to the abb instance
239 static int ti_abb_set_opp(struct regulator_dev *rdev, struct ti_abb *abb,
242 const struct ti_abb_reg *regs = abb->regs;
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);
254 ti_abb_rmw(regs->rbb_sel_mask, 1, abb->setup_reg);
257 ti_abb_rmw(regs->fbb_sel_mask, 1, abb->setup_reg);
262 ti_abb_rmw(regs->opp_sel_mask, info->opp_sel, abb->control_reg);
269 if (abb->ldo_base && info->opp_sel != TI_ABB_NOMINAL_OPP)
270 ti_abb_program_ldovbb(dev, abb, info);
273 ti_abb_rmw(regs->opp_change_mask, 1, abb->control_reg);
276 ret = ti_abb_wait_txdone(dev, abb);
280 ret = ti_abb_clear_all_txdone(dev, abb);
289 if (abb->ldo_base && info->opp_sel == TI_ABB_NOMINAL_OPP)
290 ti_abb_program_ldovbb(dev, abb, info);
307 struct ti_abb *abb = rdev_get_drvdata(rdev);
312 if (!abb) {
318 if (!desc->n_voltages || !abb->info) {
332 if (sel == abb->current_info_idx) {
337 info = &abb->info[sel];
344 if (abb->current_info_idx == -EINVAL)
348 oinfo = &abb->info[abb->current_info_idx];
351 sel, abb->current_info_idx);
356 ret = ti_abb_set_opp(rdev, abb, info);
360 abb->current_info_idx = sel;
378 struct ti_abb *abb = rdev_get_drvdata(rdev);
381 if (!abb) {
387 if (!desc->n_voltages || !abb->info) {
394 if (abb->current_info_idx >= (int)desc->n_voltages) {
396 __func__, abb->current_info_idx, desc->n_voltages);
400 return abb->current_info_idx;
406 * @abb: pointer to the abb instance
410 static int ti_abb_init_timings(struct device *dev, struct ti_abb *abb)
414 const struct ti_abb_reg *regs = abb->regs;
419 ret = of_property_read_u32(dev->of_node, pname, &abb->settling_time);
426 if (!abb->settling_time) {
443 abb->clk = devm_clk_get(dev, NULL);
444 if (IS_ERR(abb->clk)) {
445 ret = PTR_ERR(abb->clk);
474 clk_rate = DIV_ROUND_CLOSEST(clk_get_rate(abb->clk), 1000000);
480 sr2_wt_cnt_val = DIV_ROUND_CLOSEST(abb->settling_time * 10, cycle_rate);
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);
493 * @abb: pointer to the abb instance
498 static int ti_abb_init_table(struct device *dev, struct ti_abb *abb,
531 abb->info = info;
538 abb->rdesc.n_voltages = num_entries;
539 abb->rdesc.volt_table = volt_table;
541 abb->current_info_idx = -EINVAL;
572 if (!abb->efuse_base) {
580 efuse_val = readl(abb->efuse_base + efuse_offset);
595 if (!abb->ldo_base) {
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},
693 struct ti_abb *abb;
713 abb = devm_kzalloc(dev, sizeof(struct ti_abb), GFP_KERNEL);
714 if (!abb)
716 abb->regs = match->data;
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);
745 * shared between regulator-abb-{ivahd,dspeve,gpu} driver
750 abb->int_base = devm_ioremap(dev, res->start,
752 if (!abb->int_base) {
770 abb->efuse_base = devm_ioremap(dev, res->start,
772 if (!abb->efuse_base) {
784 abb->ldo_base = devm_ioremap_resource(dev, res);
785 if (IS_ERR(abb->ldo_base))
786 return PTR_ERR(abb->ldo_base);
792 &abb->ldovbb_override_mask);
797 if (!abb->ldovbb_override_mask) {
805 &abb->ldovbb_vset_mask);
810 if (!abb->ldovbb_vset_mask) {
819 &abb->txdone_mask);
824 if (!abb->txdone_mask) {
830 &abb->rdesc);
838 ret = ti_abb_init_table(dev, abb, initdata);
843 ret = ti_abb_init_timings(dev, abb);
847 desc = &abb->rdesc;
860 config.driver_data = abb;
873 ti_abb_rmw(abb->regs->sr2_en_mask, 1, abb->setup_reg);