From f4b6825a6613ceb12a0a0dad6729a1f198af706c Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Mon, 19 Jul 2010 16:25:37 +0200 Subject: [PATCH 4/5] omap: Use the regulator API in the OPP change code Instead of directly calling into the OMAP voltage layer, we now use the regulator API to adjust the voltage of the VDD1 and VDD2 regulators. TODO: * It seems we still need to call directly into the OMAP voltage code using omap_smartreflex_disable() and omap_smartreflex_enable(), because these must be done around the frequency+voltage change and not only around the voltage change. This is quite sad as it doesn't allow to hide all the voltage change procedure behind the regulator API. Signed-off-by: Thomas Petazzoni --- arch/arm/mach-omap2/resource34xx.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/arch/arm/mach-omap2/resource34xx.c b/arch/arm/mach-omap2/resource34xx.c index 17cb1bd..dc868c7 100644 --- a/arch/arm/mach-omap2/resource34xx.c +++ b/arch/arm/mach-omap2/resource34xx.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -157,6 +158,7 @@ static int vdd2_lock; static struct clk *dpll1_clk, *dpll2_clk, *dpll3_clk; static int curr_vdd1_opp; static int curr_vdd2_opp; +static struct regulator *vdd1_reg, *vdd2_reg; static DEFINE_MUTEX(dvfs_mutex); /** @@ -228,6 +230,8 @@ void init_opp(struct shared_resource *resp) vdd1_resp = resp; dpll1_clk = clk_get(NULL, "dpll1_ck"); dpll2_clk = clk_get(NULL, "dpll2_ck"); + vdd1_reg = regulator_get(dev, "vcc"); + BUG_ON(! vdd1_reg); ret = freq_to_opp(&opp_id, dev, dpll1_clk->rate); if (ret) { pr_err("%s: initializing %s failed! !match for %ld\n", @@ -248,6 +252,8 @@ void init_opp(struct shared_resource *resp) vdd2_resp = resp; dpll3_clk = clk_get(NULL, "dpll3_m2_ck"); l3_clk = clk_get(NULL, "l3_ick"); + vdd2_reg = regulator_get(dev, "vcc"); + BUG_ON(! vdd2_reg); ret = freq_to_opp(&opp_id, dev, l3_clk->rate); if (ret) { pr_err("%s: initializing %s failed! !match for %ld\n", @@ -400,7 +406,10 @@ static int program_opp(int res, struct device *dev, int target_level, uvdc_current = opp_get_voltage(oppx); /* ok to scale.. */ - omap_voltage_scale(res - 1, uvdc_target); + if (res == 1) + regulator_set_voltage(vdd1_reg, uvdc_target, uvdc_target); + else if (res == 2) + regulator_set_voltage(vdd2_reg, uvdc_target, uvdc_target); } } -- 1.7.0.4