H A D | ti-abb-regulator.c | 143 * @abb: pointer to the abb instance 147 static inline bool ti_abb_check_txdone(const struct ti_abb *abb) ti_abb_check_txdone() argument 149 return !!(readl(abb->int_base) & abb->txdone_mask); ti_abb_check_txdone() 154 * @abb: pointer to the abb instance 156 static inline void ti_abb_clear_txdone(const struct ti_abb *abb) ti_abb_clear_txdone() argument 158 writel(abb->txdone_mask, abb->int_base); ti_abb_clear_txdone() 164 * @abb: pointer to the abb instance 168 static int ti_abb_wait_txdone(struct device *dev, struct ti_abb *abb) ti_abb_wait_txdone() argument 173 while (timeout++ <= abb->settling_time) { ti_abb_wait_txdone() 174 status = ti_abb_check_txdone(abb); ti_abb_wait_txdone() 181 if (timeout > abb->settling_time) { ti_abb_wait_txdone() 184 __func__, timeout, readl(abb->int_base)); ti_abb_wait_txdone() 194 * @abb: pointer to the abb instance 198 static int ti_abb_clear_all_txdone(struct device *dev, const struct ti_abb *abb) ti_abb_clear_all_txdone() argument 203 while (timeout++ <= abb->settling_time) { ti_abb_clear_all_txdone() 204 ti_abb_clear_txdone(abb); ti_abb_clear_all_txdone() 206 status = ti_abb_check_txdone(abb); ti_abb_clear_all_txdone() 213 if (timeout > abb->settling_time) { ti_abb_clear_all_txdone() 216 __func__, timeout, readl(abb->int_base)); ti_abb_clear_all_txdone() 226 * @abb: pointer to the abb instance 229 static void ti_abb_program_ldovbb(struct device *dev, const struct ti_abb *abb, ti_abb_program_ldovbb() argument 234 val = readl(abb->ldo_base); ti_abb_program_ldovbb() 236 val &= ~(abb->ldovbb_override_mask | abb->ldovbb_vset_mask); ti_abb_program_ldovbb() 241 val |= abb->ldovbb_override_mask; ti_abb_program_ldovbb() 242 val |= info->vset << __ffs(abb->ldovbb_vset_mask); ti_abb_program_ldovbb() 246 writel(val, abb->ldo_base); ti_abb_program_ldovbb() 252 * @abb: pointer to the abb instance 257 static int ti_abb_set_opp(struct regulator_dev *rdev, struct ti_abb *abb, ti_abb_set_opp() argument 260 const struct ti_abb_reg *regs = abb->regs; ti_abb_set_opp() 264 ret = ti_abb_clear_all_txdone(dev, abb); ti_abb_set_opp() 268 ti_abb_rmw(regs->fbb_sel_mask | regs->rbb_sel_mask, 0, abb->setup_reg); ti_abb_set_opp() 272 ti_abb_rmw(regs->rbb_sel_mask, 1, abb->setup_reg); ti_abb_set_opp() 275 ti_abb_rmw(regs->fbb_sel_mask, 1, abb->setup_reg); ti_abb_set_opp() 280 ti_abb_rmw(regs->opp_sel_mask, info->opp_sel, abb->control_reg); ti_abb_set_opp() 287 if (abb->ldo_base && info->opp_sel != TI_ABB_NOMINAL_OPP) ti_abb_set_opp() 288 ti_abb_program_ldovbb(dev, abb, info); ti_abb_set_opp() 291 ti_abb_rmw(regs->opp_change_mask, 1, abb->control_reg); ti_abb_set_opp() 294 ret = ti_abb_wait_txdone(dev, abb); ti_abb_set_opp() 298 ret = ti_abb_clear_all_txdone(dev, abb); ti_abb_set_opp() 307 if (abb->ldo_base && info->opp_sel == TI_ABB_NOMINAL_OPP) ti_abb_set_opp() 308 ti_abb_program_ldovbb(dev, abb, info); ti_abb_set_opp() 325 struct ti_abb *abb = rdev_get_drvdata(rdev); ti_abb_set_voltage_sel() local 330 if (!abb) { ti_abb_set_voltage_sel() 336 if (!desc->n_voltages || !abb->info) { ti_abb_set_voltage_sel() 350 if (sel == abb->current_info_idx) { ti_abb_set_voltage_sel() 356 info = &abb->info[sel]; ti_abb_set_voltage_sel() 357 oinfo = &abb->info[abb->current_info_idx]; ti_abb_set_voltage_sel() 360 sel, abb->current_info_idx); ti_abb_set_voltage_sel() 364 ret = ti_abb_set_opp(rdev, abb, info); ti_abb_set_voltage_sel() 368 abb->current_info_idx = sel; ti_abb_set_voltage_sel() 386 struct ti_abb *abb = rdev_get_drvdata(rdev); ti_abb_get_voltage_sel() local 389 if (!abb) { ti_abb_get_voltage_sel() 395 if (!desc->n_voltages || !abb->info) { ti_abb_get_voltage_sel() 402 if (abb->current_info_idx >= (int)desc->n_voltages) { ti_abb_get_voltage_sel() 404 __func__, abb->current_info_idx, desc->n_voltages); ti_abb_get_voltage_sel() 408 return abb->current_info_idx; ti_abb_get_voltage_sel() 414 * @abb: pointer to the abb instance 418 static int ti_abb_init_timings(struct device *dev, struct ti_abb *abb) ti_abb_init_timings() argument 422 const struct ti_abb_reg *regs = abb->regs; ti_abb_init_timings() 427 ret = of_property_read_u32(dev->of_node, pname, &abb->settling_time); ti_abb_init_timings() 434 if (!abb->settling_time) { ti_abb_init_timings() 451 abb->clk = devm_clk_get(dev, NULL); ti_abb_init_timings() 452 if (IS_ERR(abb->clk)) { ti_abb_init_timings() 453 ret = PTR_ERR(abb->clk); ti_abb_init_timings() 482 clk_rate = DIV_ROUND_CLOSEST(clk_get_rate(abb->clk), 1000000); ti_abb_init_timings() 488 sr2_wt_cnt_val = DIV_ROUND_CLOSEST(abb->settling_time * 10, cycle_rate); ti_abb_init_timings() 491 clk_get_rate(abb->clk), sr2_wt_cnt_val); ti_abb_init_timings() 493 ti_abb_rmw(regs->sr2_wtcnt_value_mask, sr2_wt_cnt_val, abb->setup_reg); ti_abb_init_timings() 501 * @abb: pointer to the abb instance 506 static int ti_abb_init_table(struct device *dev, struct ti_abb *abb, ti_abb_init_table() argument 539 abb->info = info; ti_abb_init_table() 546 abb->rdesc.n_voltages = num_entries; ti_abb_init_table() 547 abb->rdesc.volt_table = volt_table; ti_abb_init_table() 549 abb->current_info_idx = -EINVAL; ti_abb_init_table() 580 if (!abb->efuse_base) { ti_abb_init_table() 588 efuse_val = readl(abb->efuse_base + efuse_offset); ti_abb_init_table() 603 if (!abb->ldo_base) { ti_abb_init_table() 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; ti_abb_probe() local 721 abb = devm_kzalloc(dev, sizeof(struct ti_abb), GFP_KERNEL); ti_abb_probe() 722 if (!abb) ti_abb_probe() 724 abb->regs = match->data; ti_abb_probe() 727 if (abb->regs->setup_off || abb->regs->control_off) { ti_abb_probe() 730 abb->base = devm_ioremap_resource(dev, res); ti_abb_probe() 731 if (IS_ERR(abb->base)) ti_abb_probe() 732 return PTR_ERR(abb->base); ti_abb_probe() 734 abb->setup_reg = abb->base + abb->regs->setup_off; ti_abb_probe() 735 abb->control_reg = abb->base + abb->regs->control_off; ti_abb_probe() 740 abb->control_reg = devm_ioremap_resource(dev, res); ti_abb_probe() 741 if (IS_ERR(abb->control_reg)) ti_abb_probe() 742 return PTR_ERR(abb->control_reg); ti_abb_probe() 746 abb->setup_reg = devm_ioremap_resource(dev, res); ti_abb_probe() 747 if (IS_ERR(abb->setup_reg)) ti_abb_probe() 748 return PTR_ERR(abb->setup_reg); ti_abb_probe() 761 abb->int_base = devm_ioremap_nocache(dev, res->start, ti_abb_probe() 763 if (!abb->int_base) { ti_abb_probe() 781 abb->efuse_base = devm_ioremap_nocache(dev, res->start, ti_abb_probe() 783 if (!abb->efuse_base) { ti_abb_probe() 795 abb->ldo_base = devm_ioremap_resource(dev, res); ti_abb_probe() 796 if (IS_ERR(abb->ldo_base)) ti_abb_probe() 797 return PTR_ERR(abb->ldo_base); ti_abb_probe() 803 &abb->ldovbb_override_mask); ti_abb_probe() 808 if (!abb->ldovbb_override_mask) { ti_abb_probe() 816 &abb->ldovbb_vset_mask); ti_abb_probe() 821 if (!abb->ldovbb_vset_mask) { ti_abb_probe() 830 &abb->txdone_mask); ti_abb_probe() 835 if (!abb->txdone_mask) { ti_abb_probe() 841 &abb->rdesc); ti_abb_probe() 849 ret = ti_abb_init_table(dev, abb, initdata); ti_abb_probe() 854 ret = ti_abb_init_timings(dev, abb); ti_abb_probe() 858 desc = &abb->rdesc; ti_abb_probe() 871 config.driver_data = abb; ti_abb_probe() 884 ti_abb_rmw(abb->regs->sr2_en_mask, 1, abb->setup_reg); ti_abb_probe()
|