From fe9bf4373aa24e077bfac4e8da94fa3cb43ae184 Mon Sep 17 00:00:00 2001 From: Afzal Mohammed Date: Tue, 29 Nov 2011 16:11:10 +0530 Subject: [PATCH] arm:omap:am33xx: MPU voltage domain MPU voltage domain data added. Also added OPP table for MPU voltage domain. OPP table for CORE voltage domain has not been added as there were issues upon reducing CORE voltage, hence no dependency has been defined for MPU. Signed-off-by: Afzal Mohammed --- arch/arm/mach-omap2/opp3xxx_data.c | 23 +++++++++ arch/arm/mach-omap2/voltagedomains33xx_data.c | 73 +++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) diff --git a/arch/arm/mach-omap2/opp3xxx_data.c b/arch/arm/mach-omap2/opp3xxx_data.c index 7662662..4cb1b72 100644 --- a/arch/arm/mach-omap2/opp3xxx_data.c +++ b/arch/arm/mach-omap2/opp3xxx_data.c @@ -185,6 +185,26 @@ struct omap_vdd_dep_info omap36xx_vddmpu_dep_info[] = { {.name = NULL, .dep_table = NULL, .nr_dep_entries = 0}, }; +/* 33xx */ + +/* VDD1 */ + +#define AM33XX_VDD_MPU_OPP50_UV 950000 +#define AM33XX_VDD_MPU_OPP100_UV 1100000 +#define AM33XX_VDD_MPU_OPP120_UV 1200000 +#define AM33XX_VDD_MPU_OPPTURBO_UV 1260000 + +static struct omap_opp_def __initdata am33xx_opp_def_list[] = { + /* MPU OPP1 - OPP50 */ + OPP_INITIALIZER("mpu", "dpll_mpu_ck", "mpu", true, 275000000, AM33XX_VDD_MPU_OPP50_UV), + /* MPU OPP2 - OPP100 */ + OPP_INITIALIZER("mpu", "dpll_mpu_ck", "mpu", true, 500000000, AM33XX_VDD_MPU_OPP100_UV), + /* MPU OPP3 - OPP120 */ + OPP_INITIALIZER("mpu", "dpll_mpu_ck", "mpu", true, 600000000, AM33XX_VDD_MPU_OPP120_UV), + /* MPU OPP4 - OPPTurbo */ + OPP_INITIALIZER("mpu", "dpll_mpu_ck", "mpu", true, 720000000, AM33XX_VDD_MPU_OPPTURBO_UV), +}; + /** * omap3_opp_init() - initialize omap3 opp table */ @@ -198,6 +218,9 @@ int __init omap3_opp_init(void) if (cpu_is_omap3630()) r = omap_init_opp_table(omap36xx_opp_def_list, ARRAY_SIZE(omap36xx_opp_def_list)); + else if (cpu_is_am33xx()) + r = omap_init_opp_table(am33xx_opp_def_list, + ARRAY_SIZE(am33xx_opp_def_list)); else r = omap_init_opp_table(omap34xx_opp_def_list, ARRAY_SIZE(omap34xx_opp_def_list)); diff --git a/arch/arm/mach-omap2/voltagedomains33xx_data.c b/arch/arm/mach-omap2/voltagedomains33xx_data.c index 46f0447..18fd7ad 100644 --- a/arch/arm/mach-omap2/voltagedomains33xx_data.c +++ b/arch/arm/mach-omap2/voltagedomains33xx_data.c @@ -9,11 +9,74 @@ */ #include #include +#include #include +#include + +#include "omap_opp_data.h" + +#define TOLERANCE 12500 /* in uV */ + +int am33x_mpu_voltdm_scale(struct voltagedomain *voltdm, + unsigned long target_volt) +{ + int ret = -EINVAL; + + + if (!voltdm->regulator) + return ret; + + + ret = regulator_set_voltage(voltdm->regulator, target_volt, + target_volt + TOLERANCE); + + if (ret) + pr_debug("Voltage change failed, ret = %d\n", ret); + else + pr_debug("Voltage scaled to %d\n", + regulator_get_voltage(voltdm->regulator)); + + return ret; +} + +struct omap_vdd_dep_info am33xx_vddmpu_dep_info[] = { + {.name = NULL, .dep_table = NULL, .nr_dep_entries = 0}, +}; + +static struct omap_vdd_info am33xx_vdd1_info; + +int am33x_mpu_voltdm_init(struct voltagedomain *voltdm) +{ + struct regulator *mpu_regulator; + struct device *mpu_dev; + + mpu_dev = omap_device_get_by_hwmod_name("mpu"); + if (!mpu_dev) { + pr_warning("%s: unable to get the mpu device\n", __func__); + return -EINVAL; + } + + mpu_regulator = regulator_get(mpu_dev, voltdm->name); + + if (IS_ERR(mpu_regulator)) { + pr_err("%s: Could not get regulator for %s\n", + __func__, voltdm->name); + return -ENODEV; + } else { + voltdm->regulator = mpu_regulator; + voltdm->scale = &am33x_mpu_voltdm_scale; + } + + return 0; +} static struct voltagedomain am33xx_voltdm_mpu = { .name = "mpu", + .scalable = true, + .use_regulator = 1, + .regulator_init = &am33x_mpu_voltdm_init, + .vdd = &am33xx_vdd1_info, }; static struct voltagedomain am33xx_voltdm_core = { @@ -31,7 +94,17 @@ static struct voltagedomain *voltagedomains_am33xx[] __initdata = { NULL, }; +static const char *sys_clk_name __initdata = "sys_clkin_ck"; + void __init am33xx_voltagedomains_init(void) { + struct voltagedomain *voltdm; + int i; + + am33xx_vdd1_info.dep_vdd_info = am33xx_vddmpu_dep_info; + + for (i = 0; voltdm = voltagedomains_am33xx[i], voltdm; i++) + voltdm->sys_clk.name = sys_clk_name; + voltdm_init(voltagedomains_am33xx); } -- 1.9.1