1 #include <linux/kernel.h>
18 vsel = voltdm->
pmic->uv_to_vsel(volt);
21 vpconfig &= ~(vp->
common->vpconfig_initvoltage_mask |
22 vp->
common->vpconfig_forceupdate |
23 vp->
common->vpconfig_initvdd);
24 vpconfig |= vsel <<
__ffs(vp->
common->vpconfig_initvoltage_mask);
28 voltdm->
write((vpconfig | vp->
common->vpconfig_initvdd),
44 if (!voltdm->
pmic || !voltdm->
pmic->uv_to_vsel) {
45 pr_err(
"%s: No PMIC info for vdd_%s\n", __func__, voltdm->
name);
50 pr_err(
"%s: No read/write API for accessing vdd_%s regs\n",
51 __func__, voltdm->
name);
60 timeout = (sys_clk_rate * voltdm->
pmic->vp_timeout_us) / 1000;
61 vddmin = voltdm->
pmic->vp_vddmin;
62 vddmax = voltdm->
pmic->vp_vddmax;
65 1000 * voltdm->
pmic->slew_rate);
66 vstepmin = voltdm->
pmic->vp_vstepmin;
67 vstepmax = voltdm->
pmic->vp_vstepmax;
73 val = (voltdm->
pmic->vp_erroroffset <<
74 __ffs(voltdm->
vp->common->vpconfig_erroroffset_mask)) |
75 vp->
common->vpconfig_timeouten;
79 val = (waittime << vp->
common->vstepmin_smpswaittimemin_shift) |
80 (vstepmin << vp->
common->vstepmin_stepmin_shift);
84 val = (vstepmax << vp->
common->vstepmax_stepmax_shift) |
85 (waittime << vp->
common->vstepmax_smpswaittimemax_shift);
89 val = (vddmax << vp->
common->vlimitto_vddmax_shift) |
90 (vddmin << vp->
common->vlimitto_vddmin_shift) |
91 (timeout << vp->
common->vlimitto_timeout_shift);
96 unsigned long target_volt)
105 if (IS_ERR(volt_data))
109 voltdm->
rmw(voltdm->
vp->common->vpconfig_errorgain_mask,
111 __ffs(voltdm->
vp->common->vpconfig_errorgain_mask),
112 voltdm->
vp->vpconfig);
119 unsigned long target_volt)
123 u8 target_vsel, current_vsel;
135 vp->
common->ops->clear_txdone(vp->
id);
136 if (!vp->
common->ops->check_txdone(vp->
id))
141 pr_warn(
"%s: vdd_%s TRANXDONE timeout exceeded. Voltage change aborted",
142 __func__, voltdm->
name);
146 vpconfig = _vp_set_init_voltage(voltdm, target_volt);
149 voltdm->
write(vpconfig | vp->
common->vpconfig_forceupdate,
150 voltdm->
vp->vpconfig);
157 omap_test_timeout(vp->
common->ops->check_txdone(vp->
id),
160 pr_err(
"%s: vdd_%s TRANXDONE timeout exceeded. TRANXDONE never got set after the voltage update\n",
161 __func__, voltdm->
name);
171 vp->
common->ops->clear_txdone(vp->
id);
172 if (!vp->
common->ops->check_txdone(vp->
id))
178 pr_warn(
"%s: vdd_%s TRANXDONE timeout exceeded while trying to clear the TRANXDONE status\n",
179 __func__, voltdm->
name);
199 if (!voltdm || IS_ERR(voltdm)) {
200 pr_warning(
"%s: VDD specified does not exist!\n", __func__);
206 pr_err(
"%s: No read/write API for accessing vdd_%s regs\n",
207 __func__, voltdm->
name);
217 pr_warning(
"%s: unable to find current voltage for %s\n",
218 __func__, voltdm->
name);
222 vpconfig = _vp_set_init_voltage(voltdm, volt);
225 vpconfig |= vp->
common->vpconfig_vpenable;
244 if (!voltdm || IS_ERR(voltdm)) {
245 pr_warning(
"%s: VDD specified does not exist!\n", __func__);
251 pr_err(
"%s: No read/write API for accessing vdd_%s regs\n",
252 __func__, voltdm->
name);
258 pr_warn(
"%s: Trying to disable VP for vdd_%s when it is already disabled\n",
259 __func__, voltdm->
name);
265 vpconfig &= ~vp->
common->vpconfig_vpenable;
276 __func__, voltdm->
name);