• Home
  • Raw
  • Download

Lines Matching +full:ldo +full:- +full:v

7  * Copyright (C) 2012-2013 Texas Instruments, Inc.
33 * ABB LDO operating states:
34 * NOMINAL_OPP: bypasses the ABB LDO
35 * FAST_OPP: sets ABB LDO to Forward Body-Bias
36 * SLOW_OPP: sets ABB LDO to Reverse Body-Bias
43 * struct ti_abb_info - ABB information per voltage setting
56 * struct ti_abb_reg - Register description for ABB block
59 * @sr2_wtcnt_value_mask: setup register- sr2_wtcnt_value mask
60 * @fbb_sel_mask: setup register- FBB sel mask
61 * @rbb_sel_mask: setup register- RBB sel mask
62 * @sr2_en_mask: setup register- enable mask
63 * @opp_change_mask: control register - mask to trigger LDOVBB change
64 * @opp_sel_mask: control register - mask for mode to operate
82 * struct ti_abb - ABB instance data
93 * @ldovbb_override_mask: mask to ldo_base for overriding default LDO VBB
98 * @settling_time: SoC specific settling time for LDO VBB
122 * ti_abb_rmw() - handy wrapper to set specific register bits
142 * ti_abb_check_txdone() - handy wrapper to check ABB tranxdone status
149 return !!(readl(abb->int_base) & abb->txdone_mask); in ti_abb_check_txdone()
153 * ti_abb_clear_txdone() - handy wrapper to clear ABB tranxdone status
158 writel(abb->txdone_mask, abb->int_base); in ti_abb_clear_txdone()
162 * ti_abb_wait_tranx() - waits for ABB tranxdone event
166 * Return: 0 on success or -ETIMEDOUT if the event is not cleared on time.
173 while (timeout++ <= abb->settling_time) { in ti_abb_wait_txdone()
182 __func__, timeout, readl(abb->int_base)); in ti_abb_wait_txdone()
183 return -ETIMEDOUT; in ti_abb_wait_txdone()
187 * ti_abb_clear_all_txdone() - clears ABB tranxdone event
191 * Return: 0 on success or -ETIMEDOUT if the event is not cleared on time.
198 while (timeout++ <= abb->settling_time) { in ti_abb_clear_all_txdone()
209 __func__, timeout, readl(abb->int_base)); in ti_abb_clear_all_txdone()
210 return -ETIMEDOUT; in ti_abb_clear_all_txdone()
214 * ti_abb_program_ldovbb() - program LDOVBB register for override value
224 val = readl(abb->ldo_base); in ti_abb_program_ldovbb()
226 val &= ~(abb->ldovbb_override_mask | abb->ldovbb_vset_mask); in ti_abb_program_ldovbb()
228 switch (info->opp_sel) { in ti_abb_program_ldovbb()
231 val |= abb->ldovbb_override_mask; in ti_abb_program_ldovbb()
232 val |= info->vset << __ffs(abb->ldovbb_vset_mask); in ti_abb_program_ldovbb()
236 writel(val, abb->ldo_base); in ti_abb_program_ldovbb()
240 * ti_abb_set_opp() - Setup ABB and LDO VBB for required bias
250 const struct ti_abb_reg *regs = abb->regs; in ti_abb_set_opp()
251 struct device *dev = &rdev->dev; in ti_abb_set_opp()
258 ti_abb_rmw(regs->fbb_sel_mask | regs->rbb_sel_mask, 0, abb->setup_reg); in ti_abb_set_opp()
260 switch (info->opp_sel) { in ti_abb_set_opp()
262 ti_abb_rmw(regs->rbb_sel_mask, 1, abb->setup_reg); in ti_abb_set_opp()
265 ti_abb_rmw(regs->fbb_sel_mask, 1, abb->setup_reg); in ti_abb_set_opp()
269 /* program next state of ABB ldo */ in ti_abb_set_opp()
270 ti_abb_rmw(regs->opp_sel_mask, info->opp_sel, abb->control_reg); in ti_abb_set_opp()
273 * program LDO VBB vset override if needed for !bypass mode in ti_abb_set_opp()
274 * XXX: Do not switch sequence - for !bypass, LDO override reset *must* in ti_abb_set_opp()
277 if (abb->ldo_base && info->opp_sel != TI_ABB_NOMINAL_OPP) in ti_abb_set_opp()
280 /* Initiate ABB ldo change */ in ti_abb_set_opp()
281 ti_abb_rmw(regs->opp_change_mask, 1, abb->control_reg); in ti_abb_set_opp()
283 /* Wait for ABB LDO to complete transition to new Bias setting */ in ti_abb_set_opp()
293 * Reset LDO VBB vset override bypass mode in ti_abb_set_opp()
294 * XXX: Do not switch sequence - for bypass, LDO override reset *must* in ti_abb_set_opp()
297 if (abb->ldo_base && info->opp_sel == TI_ABB_NOMINAL_OPP) in ti_abb_set_opp()
305 * ti_abb_set_voltage_sel() - regulator accessor function to set ABB LDO
307 * @sel: selector to index into required ABB LDO settings (maps to
314 const struct regulator_desc *desc = rdev->desc; in ti_abb_set_voltage_sel()
316 struct device *dev = &rdev->dev; in ti_abb_set_voltage_sel()
323 return -ENODEV; in ti_abb_set_voltage_sel()
326 if (!desc->n_voltages || !abb->info) { in ti_abb_set_voltage_sel()
330 return -EINVAL; in ti_abb_set_voltage_sel()
333 if (sel >= desc->n_voltages) { in ti_abb_set_voltage_sel()
335 sel, desc->n_voltages); in ti_abb_set_voltage_sel()
336 return -EINVAL; in ti_abb_set_voltage_sel()
340 if (sel == abb->current_info_idx) { in ti_abb_set_voltage_sel()
345 info = &abb->info[sel]; in ti_abb_set_voltage_sel()
352 if (abb->current_info_idx == -EINVAL) in ti_abb_set_voltage_sel()
356 oinfo = &abb->info[abb->current_info_idx]; in ti_abb_set_voltage_sel()
359 sel, abb->current_info_idx); in ti_abb_set_voltage_sel()
368 abb->current_info_idx = sel; in ti_abb_set_voltage_sel()
372 __func__, desc->volt_table[sel], sel, in ti_abb_set_voltage_sel()
373 info->opp_sel, ret); in ti_abb_set_voltage_sel()
378 * ti_abb_get_voltage_sel() - Regulator accessor to get current ABB LDO setting
385 const struct regulator_desc *desc = rdev->desc; in ti_abb_get_voltage_sel()
387 struct device *dev = &rdev->dev; in ti_abb_get_voltage_sel()
392 return -ENODEV; in ti_abb_get_voltage_sel()
395 if (!desc->n_voltages || !abb->info) { in ti_abb_get_voltage_sel()
399 return -EINVAL; in ti_abb_get_voltage_sel()
402 if (abb->current_info_idx >= (int)desc->n_voltages) { in ti_abb_get_voltage_sel()
404 __func__, abb->current_info_idx, desc->n_voltages); in ti_abb_get_voltage_sel()
405 return -EINVAL; in ti_abb_get_voltage_sel()
408 return abb->current_info_idx; in ti_abb_get_voltage_sel()
412 * ti_abb_init_timings() - setup ABB clock timing for the current platform
422 const struct ti_abb_reg *regs = abb->regs; in ti_abb_init_timings()
424 char *pname = "ti,settling-time"; in ti_abb_init_timings()
427 ret = of_property_read_u32(dev->of_node, pname, &abb->settling_time); in ti_abb_init_timings()
433 /* ABB LDO cannot be settle in 0 time */ in ti_abb_init_timings()
434 if (!abb->settling_time) { in ti_abb_init_timings()
436 return -EINVAL; in ti_abb_init_timings()
439 pname = "ti,clock-cycles"; in ti_abb_init_timings()
440 ret = of_property_read_u32(dev->of_node, pname, &clock_cycles); in ti_abb_init_timings()
445 /* ABB LDO cannot be settle in 0 clock cycles */ in ti_abb_init_timings()
448 return -EINVAL; in ti_abb_init_timings()
451 abb->clk = devm_clk_get(dev, NULL); in ti_abb_init_timings()
452 if (IS_ERR(abb->clk)) { in ti_abb_init_timings()
453 ret = PTR_ERR(abb->clk); in ti_abb_init_timings()
459 * SR2_WTCNT_VALUE is the settling time for the ABB ldo after a in ti_abb_init_timings()
462 * clock cycles that match a given wall time profiled for the ldo. in ti_abb_init_timings()
464 * settling time of ldo in micro-seconds (varies per OMAP family) in ti_abb_init_timings()
469 * ldo settling time (in micro-seconds) in ti_abb_init_timings()
470 * SR2_WTCNT_VALUE = ------------------------------------------ in ti_abb_init_timings()
482 clk_rate = DIV_ROUND_CLOSEST(clk_get_rate(abb->clk), 1000000); in ti_abb_init_timings()
488 sr2_wt_cnt_val = DIV_ROUND_CLOSEST(abb->settling_time * 10, cycle_rate); in ti_abb_init_timings()
491 clk_get_rate(abb->clk), sr2_wt_cnt_val); in ti_abb_init_timings()
493 ti_abb_rmw(regs->sr2_wtcnt_value_mask, sr2_wt_cnt_val, abb->setup_reg); in ti_abb_init_timings()
499 * ti_abb_init_table() - Initialize ABB table from device tree
515 struct regulation_constraints *c = &rinit_data->constraints; in ti_abb_init_table()
518 * Each abb_info is a set of n-tuple, where n is num_values, consisting in ti_abb_init_table()
522 num_entries = of_property_count_u32_elems(dev->of_node, pname); in ti_abb_init_table()
531 return -EINVAL; in ti_abb_init_table()
537 return -ENOMEM; in ti_abb_init_table()
539 abb->info = info; in ti_abb_init_table()
544 return -ENOMEM; in ti_abb_init_table()
546 abb->rdesc.n_voltages = num_entries; in ti_abb_init_table()
547 abb->rdesc.volt_table = volt_table; in ti_abb_init_table()
549 abb->current_info_idx = -EINVAL; in ti_abb_init_table()
556 of_property_read_u32_index(dev->of_node, pname, i * num_values, in ti_abb_init_table()
558 of_property_read_u32_index(dev->of_node, pname, in ti_abb_init_table()
559 i * num_values + 1, &info->opp_sel); in ti_abb_init_table()
560 of_property_read_u32_index(dev->of_node, pname, in ti_abb_init_table()
562 of_property_read_u32_index(dev->of_node, pname, in ti_abb_init_table()
564 of_property_read_u32_index(dev->of_node, pname, in ti_abb_init_table()
566 of_property_read_u32_index(dev->of_node, pname, in ti_abb_init_table()
570 "[%d]v=%d ABB=%d ef=0x%x rbb=0x%x fbb=0x%x vset=0x%x\n", in ti_abb_init_table()
571 i, *volt_table, info->opp_sel, efuse_offset, rbb_mask, in ti_abb_init_table()
580 if (!abb->efuse_base) { in ti_abb_init_table()
583 dev_err(dev, "prop '%s': v=%d,bad efuse/mask\n", in ti_abb_init_table()
588 efuse_val = readl(abb->efuse_base + efuse_offset); in ti_abb_init_table()
592 info->opp_sel = TI_ABB_SLOW_OPP; in ti_abb_init_table()
594 info->opp_sel = TI_ABB_FAST_OPP; in ti_abb_init_table()
596 info->opp_sel = TI_ABB_NOMINAL_OPP; in ti_abb_init_table()
599 "[%d]v=%d efusev=0x%x final ABB=%d\n", in ti_abb_init_table()
600 i, *volt_table, efuse_val, info->opp_sel); in ti_abb_init_table()
603 if (!abb->ldo_base) { in ti_abb_init_table()
605 dev_err(dev, "prop'%s':v=%d vst=%x LDO base?\n", in ti_abb_init_table()
609 info->vset = (efuse_val & vset_mask) >> __ffs(vset_mask); in ti_abb_init_table()
610 dev_dbg(dev, "[%d]v=%d vset=%x\n", i, *volt_table, info->vset); in ti_abb_init_table()
612 switch (info->opp_sel) { in ti_abb_init_table()
619 dev_err(dev, "%s:[%d]v=%d, ABB=%d is invalid! Abort!\n", in ti_abb_init_table()
620 __func__, i, *volt_table, info->opp_sel); in ti_abb_init_table()
621 return -EINVAL; in ti_abb_init_table()
626 c->min_uV = min_uV; in ti_abb_init_table()
627 c->max_uV = max_uV; in 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},
687 * ti_abb_probe() - Initialize an ABB ldo instance
690 * Initializes an individual ABB LDO for required Body-Bias. ABB is used to
698 struct device *dev = &pdev->dev; in ti_abb_probe()
714 return -ENODEV; in ti_abb_probe()
716 if (!match->data) { in ti_abb_probe()
718 return -EINVAL; in ti_abb_probe()
723 return -ENOMEM; in ti_abb_probe()
724 abb->regs = match->data; in ti_abb_probe()
727 if (abb->regs->setup_off || abb->regs->control_off) { in ti_abb_probe()
728 pname = "base-address"; in ti_abb_probe()
730 abb->base = devm_ioremap_resource(dev, res); in ti_abb_probe()
731 if (IS_ERR(abb->base)) in ti_abb_probe()
732 return PTR_ERR(abb->base); in ti_abb_probe()
734 abb->setup_reg = abb->base + abb->regs->setup_off; in ti_abb_probe()
735 abb->control_reg = abb->base + abb->regs->control_off; in ti_abb_probe()
738 pname = "control-address"; in ti_abb_probe()
740 abb->control_reg = devm_ioremap_resource(dev, res); in ti_abb_probe()
741 if (IS_ERR(abb->control_reg)) in ti_abb_probe()
742 return PTR_ERR(abb->control_reg); in ti_abb_probe()
744 pname = "setup-address"; in ti_abb_probe()
746 abb->setup_reg = devm_ioremap_resource(dev, res); in ti_abb_probe()
747 if (IS_ERR(abb->setup_reg)) in ti_abb_probe()
748 return PTR_ERR(abb->setup_reg); in ti_abb_probe()
751 pname = "int-address"; in ti_abb_probe()
755 return -ENODEV; in ti_abb_probe()
759 * write-1-to-clear between domains ensuring exclusivity. in ti_abb_probe()
761 abb->int_base = devm_ioremap(dev, res->start, in ti_abb_probe()
763 if (!abb->int_base) { in ti_abb_probe()
765 return -ENOMEM; in ti_abb_probe()
769 pname = "efuse-address"; in ti_abb_probe()
773 ret = -ENODEV; in ti_abb_probe()
778 * We may have shared efuse register offsets which are read-only in ti_abb_probe()
781 abb->efuse_base = devm_ioremap(dev, res->start, in ti_abb_probe()
783 if (!abb->efuse_base) { in ti_abb_probe()
785 return -ENOMEM; in ti_abb_probe()
788 pname = "ldo-address"; in ti_abb_probe()
792 ret = -ENODEV; in ti_abb_probe()
795 abb->ldo_base = devm_ioremap_resource(dev, res); in ti_abb_probe()
796 if (IS_ERR(abb->ldo_base)) in ti_abb_probe()
797 return PTR_ERR(abb->ldo_base); in ti_abb_probe()
800 pname = "ti,ldovbb-override-mask"; in ti_abb_probe()
802 of_property_read_u32(pdev->dev.of_node, pname, in ti_abb_probe()
803 &abb->ldovbb_override_mask); in ti_abb_probe()
808 if (!abb->ldovbb_override_mask) { in ti_abb_probe()
810 return -EINVAL; in ti_abb_probe()
813 pname = "ti,ldovbb-vset-mask"; in ti_abb_probe()
815 of_property_read_u32(pdev->dev.of_node, pname, in ti_abb_probe()
816 &abb->ldovbb_vset_mask); in ti_abb_probe()
821 if (!abb->ldovbb_vset_mask) { in ti_abb_probe()
823 return -EINVAL; in ti_abb_probe()
827 pname = "ti,tranxdone-status-mask"; in ti_abb_probe()
829 of_property_read_u32(pdev->dev.of_node, pname, in ti_abb_probe()
830 &abb->txdone_mask); in ti_abb_probe()
835 if (!abb->txdone_mask) { in ti_abb_probe()
837 return -EINVAL; in ti_abb_probe()
840 initdata = of_get_regulator_init_data(dev, pdev->dev.of_node, in ti_abb_probe()
841 &abb->rdesc); in ti_abb_probe()
845 return -ENOMEM; in ti_abb_probe()
858 desc = &abb->rdesc; in ti_abb_probe()
859 desc->name = dev_name(dev); in ti_abb_probe()
860 desc->owner = THIS_MODULE; in ti_abb_probe()
861 desc->type = REGULATOR_VOLTAGE; in ti_abb_probe()
862 desc->ops = &ti_abb_reg_ops; in ti_abb_probe()
864 c = &initdata->constraints; in ti_abb_probe()
865 if (desc->n_voltages > 1) in ti_abb_probe()
866 c->valid_ops_mask |= REGULATOR_CHANGE_VOLTAGE; in ti_abb_probe()
867 c->always_on = true; in ti_abb_probe()
872 config.of_node = pdev->dev.of_node; in ti_abb_probe()
883 /* Enable the ldo if not already done by bootloader */ in ti_abb_probe()
884 ti_abb_rmw(abb->regs->sr2_en_mask, 1, abb->setup_reg); in ti_abb_probe()
900 MODULE_DESCRIPTION("Texas Instruments ABB LDO regulator driver");