aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/vc.c
diff options
context:
space:
mode:
authorTero Kristo <t-kristo@ti.com>2012-09-25 12:33:35 -0400
committerKevin Hilman <khilman@ti.com>2012-11-05 18:08:22 -0500
commit8b5d8c0d718379ce29dad74b4bda8b669fc1f1c2 (patch)
treeac3240218ab68158c92edfdc35e2e22a8b4e8dba /arch/arm/mach-omap2/vc.c
parentb254012b21e3f0dec798de8d12e3ce009d1c09e0 (diff)
ARM: OMAP3+: voltage: introduce omap vc / vp params for voltagedomains
These new structs will hold the sleep voltage levels (omap_vc_params) and voltage processor min / max voltages (omap_vp_params.) Previously these were part of the PMIC struct, but they do not really belong there, as they are OMAP chip specific, not PMIC specific parameters. voltdm code is also changed to use the new structs. Signed-off-by: Tero Kristo <t-kristo@ti.com> Signed-off-by: Kevin Hilman <khilman@ti.com>
Diffstat (limited to 'arch/arm/mach-omap2/vc.c')
-rw-r--r--arch/arm/mach-omap2/vc.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
index 880249b17012..4c3c41fd2637 100644
--- a/arch/arm/mach-omap2/vc.c
+++ b/arch/arm/mach-omap2/vc.c
@@ -135,6 +135,8 @@ int omap_vc_pre_scale(struct voltagedomain *voltdm,
135 vc_cmdval |= (*target_vsel << vc->common->cmd_on_shift); 135 vc_cmdval |= (*target_vsel << vc->common->cmd_on_shift);
136 voltdm->write(vc_cmdval, vc->cmdval_reg); 136 voltdm->write(vc_cmdval, vc->cmdval_reg);
137 137
138 voltdm->vc_param->on = target_volt;
139
138 omap_vp_update_errorgain(voltdm, target_volt); 140 omap_vp_update_errorgain(voltdm, target_volt);
139 141
140 return 0; 142 return 0;
@@ -284,6 +286,30 @@ static void __init omap_vc_i2c_init(struct voltagedomain *voltdm)
284 initialized = true; 286 initialized = true;
285} 287}
286 288
289/**
290 * omap_vc_calc_vsel - calculate vsel value for a channel
291 * @voltdm: channel to calculate value for
292 * @uvolt: microvolt value to convert to vsel
293 *
294 * Converts a microvolt value to vsel value for the used PMIC.
295 * This checks whether the microvolt value is out of bounds, and
296 * adjusts the value accordingly. If unsupported value detected,
297 * warning is thrown.
298 */
299static u8 omap_vc_calc_vsel(struct voltagedomain *voltdm, u32 uvolt)
300{
301 if (voltdm->pmic->vddmin > uvolt)
302 uvolt = voltdm->pmic->vddmin;
303 if (voltdm->pmic->vddmax < uvolt) {
304 WARN(1, "%s: voltage not supported by pmic: %u vs max %u\n",
305 __func__, uvolt, voltdm->pmic->vddmax);
306 /* Lets try maximum value anyway */
307 uvolt = voltdm->pmic->vddmax;
308 }
309
310 return voltdm->pmic->uv_to_vsel(uvolt);
311}
312
287void __init omap_vc_init_channel(struct voltagedomain *voltdm) 313void __init omap_vc_init_channel(struct voltagedomain *voltdm)
288{ 314{
289 struct omap_vc_channel *vc = voltdm->vc; 315 struct omap_vc_channel *vc = voltdm->vc;
@@ -335,10 +361,11 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm)
335 } 361 }
336 362
337 /* Set up the on, inactive, retention and off voltage */ 363 /* Set up the on, inactive, retention and off voltage */
338 on_vsel = voltdm->pmic->uv_to_vsel(voltdm->pmic->on_volt); 364 on_vsel = omap_vc_calc_vsel(voltdm, voltdm->vc_param->on);
339 onlp_vsel = voltdm->pmic->uv_to_vsel(voltdm->pmic->onlp_volt); 365 onlp_vsel = omap_vc_calc_vsel(voltdm, voltdm->vc_param->onlp);
340 ret_vsel = voltdm->pmic->uv_to_vsel(voltdm->pmic->ret_volt); 366 ret_vsel = omap_vc_calc_vsel(voltdm, voltdm->vc_param->ret);
341 off_vsel = voltdm->pmic->uv_to_vsel(voltdm->pmic->off_volt); 367 off_vsel = omap_vc_calc_vsel(voltdm, voltdm->vc_param->off);
368
342 val = ((on_vsel << vc->common->cmd_on_shift) | 369 val = ((on_vsel << vc->common->cmd_on_shift) |
343 (onlp_vsel << vc->common->cmd_onlp_shift) | 370 (onlp_vsel << vc->common->cmd_onlp_shift) |
344 (ret_vsel << vc->common->cmd_ret_shift) | 371 (ret_vsel << vc->common->cmd_ret_shift) |