Commit fe9bf4373aa24e077bfac4e8da94fa3cb43ae184

Authored by Afzal Mohammed
1 parent af4ec5a39f
Exists in master

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 <afzal@ti.com>

Showing 2 changed files with 96 additions and 0 deletions Side-by-side Diff

arch/arm/mach-omap2/opp3xxx_data.c
... ... @@ -185,6 +185,26 @@
185 185 {.name = NULL, .dep_table = NULL, .nr_dep_entries = 0},
186 186 };
187 187  
  188 +/* 33xx */
  189 +
  190 +/* VDD1 */
  191 +
  192 +#define AM33XX_VDD_MPU_OPP50_UV 950000
  193 +#define AM33XX_VDD_MPU_OPP100_UV 1100000
  194 +#define AM33XX_VDD_MPU_OPP120_UV 1200000
  195 +#define AM33XX_VDD_MPU_OPPTURBO_UV 1260000
  196 +
  197 +static struct omap_opp_def __initdata am33xx_opp_def_list[] = {
  198 + /* MPU OPP1 - OPP50 */
  199 + OPP_INITIALIZER("mpu", "dpll_mpu_ck", "mpu", true, 275000000, AM33XX_VDD_MPU_OPP50_UV),
  200 + /* MPU OPP2 - OPP100 */
  201 + OPP_INITIALIZER("mpu", "dpll_mpu_ck", "mpu", true, 500000000, AM33XX_VDD_MPU_OPP100_UV),
  202 + /* MPU OPP3 - OPP120 */
  203 + OPP_INITIALIZER("mpu", "dpll_mpu_ck", "mpu", true, 600000000, AM33XX_VDD_MPU_OPP120_UV),
  204 + /* MPU OPP4 - OPPTurbo */
  205 + OPP_INITIALIZER("mpu", "dpll_mpu_ck", "mpu", true, 720000000, AM33XX_VDD_MPU_OPPTURBO_UV),
  206 +};
  207 +
188 208 /**
189 209 * omap3_opp_init() - initialize omap3 opp table
190 210 */
... ... @@ -198,6 +218,9 @@
198 218 if (cpu_is_omap3630())
199 219 r = omap_init_opp_table(omap36xx_opp_def_list,
200 220 ARRAY_SIZE(omap36xx_opp_def_list));
  221 + else if (cpu_is_am33xx())
  222 + r = omap_init_opp_table(am33xx_opp_def_list,
  223 + ARRAY_SIZE(am33xx_opp_def_list));
201 224 else
202 225 r = omap_init_opp_table(omap34xx_opp_def_list,
203 226 ARRAY_SIZE(omap34xx_opp_def_list));
arch/arm/mach-omap2/voltagedomains33xx_data.c
... ... @@ -9,11 +9,74 @@
9 9 */
10 10 #include <linux/kernel.h>
11 11 #include <linux/init.h>
  12 +#include <linux/regulator/consumer.h>
12 13  
13 14 #include <plat/voltage.h>
  15 +#include <plat/omap_device.h>
14 16  
  17 +#include "omap_opp_data.h"
  18 +
  19 +#define TOLERANCE 12500 /* in uV */
  20 +
  21 +int am33x_mpu_voltdm_scale(struct voltagedomain *voltdm,
  22 + unsigned long target_volt)
  23 +{
  24 + int ret = -EINVAL;
  25 +
  26 +
  27 + if (!voltdm->regulator)
  28 + return ret;
  29 +
  30 +
  31 + ret = regulator_set_voltage(voltdm->regulator, target_volt,
  32 + target_volt + TOLERANCE);
  33 +
  34 + if (ret)
  35 + pr_debug("Voltage change failed, ret = %d\n", ret);
  36 + else
  37 + pr_debug("Voltage scaled to %d\n",
  38 + regulator_get_voltage(voltdm->regulator));
  39 +
  40 + return ret;
  41 +}
  42 +
  43 +struct omap_vdd_dep_info am33xx_vddmpu_dep_info[] = {
  44 + {.name = NULL, .dep_table = NULL, .nr_dep_entries = 0},
  45 +};
  46 +
  47 +static struct omap_vdd_info am33xx_vdd1_info;
  48 +
  49 +int am33x_mpu_voltdm_init(struct voltagedomain *voltdm)
  50 +{
  51 + struct regulator *mpu_regulator;
  52 + struct device *mpu_dev;
  53 +
  54 + mpu_dev = omap_device_get_by_hwmod_name("mpu");
  55 + if (!mpu_dev) {
  56 + pr_warning("%s: unable to get the mpu device\n", __func__);
  57 + return -EINVAL;
  58 + }
  59 +
  60 + mpu_regulator = regulator_get(mpu_dev, voltdm->name);
  61 +
  62 + if (IS_ERR(mpu_regulator)) {
  63 + pr_err("%s: Could not get regulator for %s\n",
  64 + __func__, voltdm->name);
  65 + return -ENODEV;
  66 + } else {
  67 + voltdm->regulator = mpu_regulator;
  68 + voltdm->scale = &am33x_mpu_voltdm_scale;
  69 + }
  70 +
  71 + return 0;
  72 +}
  73 +
15 74 static struct voltagedomain am33xx_voltdm_mpu = {
16 75 .name = "mpu",
  76 + .scalable = true,
  77 + .use_regulator = 1,
  78 + .regulator_init = &am33x_mpu_voltdm_init,
  79 + .vdd = &am33xx_vdd1_info,
17 80 };
18 81  
19 82 static struct voltagedomain am33xx_voltdm_core = {
20 83  
... ... @@ -31,8 +94,18 @@
31 94 NULL,
32 95 };
33 96  
  97 +static const char *sys_clk_name __initdata = "sys_clkin_ck";
  98 +
34 99 void __init am33xx_voltagedomains_init(void)
35 100 {
  101 + struct voltagedomain *voltdm;
  102 + int i;
  103 +
  104 + am33xx_vdd1_info.dep_vdd_info = am33xx_vddmpu_dep_info;
  105 +
  106 + for (i = 0; voltdm = voltagedomains_am33xx[i], voltdm; i++)
  107 + voltdm->sys_clk.name = sys_clk_name;
  108 +
36 109 voltdm_init(voltagedomains_am33xx);
37 110 }