diff options
Diffstat (limited to 'arch/arm/mach-omap2/vc.c')
-rw-r--r-- | arch/arm/mach-omap2/vc.c | 35 |
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 | */ | ||
299 | static 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 | |||
287 | void __init omap_vc_init_channel(struct voltagedomain *voltdm) | 313 | void __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) | |