msm: acpuclock-8960: Initialize regulators and bus_bw earlier
The init code assumes that the regulators have already been set
up to support the max CPU frequency. While this is true, the
fewer assumptions we make, the better. So, switch the ordering to
initialize the regulators before switching the frequency. This
also has the nice side-effect of not running the regulators at a
higher than required voltage for fast parts.
While we are at it, also change the bus init ordering so that we
can pick the bus bandwidth that corresponds to the freq the L2
will be initialized to instead of picking the max bandwidth
defined in the bandwidth table.
Change-Id: I58432f6e236a7077536e6565157b96c309df590d
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
diff --git a/arch/arm/mach-msm/acpuclock-8960.c b/arch/arm/mach-msm/acpuclock-8960.c
index 1cc1499..61c742d 100644
--- a/arch/arm/mach-msm/acpuclock-8960.c
+++ b/arch/arm/mach-msm/acpuclock-8960.c
@@ -1163,7 +1163,7 @@
}
/* Voltage regulator initialization. */
-static void __init regulator_init(void)
+static void __init regulator_init(int set_vdd)
{
int cpu, ret;
struct scalable *sc;
@@ -1180,7 +1180,7 @@
}
ret = regulator_set_voltage(sc->vreg[VREG_CORE].reg,
- sc->vreg[VREG_CORE].max_vdd,
+ set_vdd,
sc->vreg[VREG_CORE].max_vdd);
if (ret)
pr_err("regulator_set_voltage(%s) failed"
@@ -1234,7 +1234,7 @@
}
/* Register with bus driver. */
-static void __init bus_init(void)
+static void __init bus_init(unsigned int init_bw)
{
int ret;
@@ -1244,8 +1244,7 @@
BUG();
}
- ret = msm_bus_scale_client_update_request(bus_perf_client,
- (ARRAY_SIZE(bw_level_tbl)-1));
+ ret = msm_bus_scale_client_update_request(bus_perf_client, init_bw);
if (ret)
pr_err("initial bandwidth request failed (%d)\n", ret);
}
@@ -1449,11 +1448,13 @@
static int __init acpuclk_8960_init(struct acpuclk_soc_data *soc_data)
{
struct acpu_level *max_acpu_level = select_freq_plan();
+
+ regulator_init(max_acpu_level->vdd_core);
+ bus_init(max_acpu_level->l2_level->bw_level);
+
init_clock_sources(&scalable[L2], &max_acpu_level->l2_level->speed);
on_each_cpu(per_cpu_init, max_acpu_level, true);
- regulator_init();
- bus_init();
cpufreq_table_init();
acpuclk_register(&acpuclk_8960_data);