]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ARM: OMAP3+: voltage: introduce omap vc / vp params for voltagedomains
authorTero Kristo <t-kristo@ti.com>
Tue, 25 Sep 2012 16:33:35 +0000 (19:33 +0300)
committerKevin Hilman <khilman@ti.com>
Mon, 5 Nov 2012 23:08:22 +0000 (15:08 -0800)
These new structs will hold the sleep voltage levels (omap_vc_params)
and voltage processor min / max voltages (omap_vp_params.) Previously
these were part of the PMIC struct, but they do not really belong there,
as they are OMAP chip specific, not PMIC specific parameters. voltdm
code is also changed to use the new structs.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Kevin Hilman <khilman@ti.com>
arch/arm/mach-omap2/omap_twl.c
arch/arm/mach-omap2/vc.c
arch/arm/mach-omap2/vc.h
arch/arm/mach-omap2/vc3xxx_data.c
arch/arm/mach-omap2/vc44xx_data.c
arch/arm/mach-omap2/voltage.h
arch/arm/mach-omap2/voltagedomains3xxx_data.c
arch/arm/mach-omap2/voltagedomains44xx_data.c
arch/arm/mach-omap2/vp.h
arch/arm/mach-omap2/vp3xxx_data.c
arch/arm/mach-omap2/vp44xx_data.c

index c38a530a7f47dbf22261404d95dad270bf99b600..dca1d662d5e0ff663ace9cd63fa0c4960e3432b0 100644 (file)
@@ -141,10 +141,6 @@ static u8 twl6030_uv_to_vsel(unsigned long uv)
 static struct omap_voltdm_pmic omap3_mpu_pmic = {
        .slew_rate              = 4000,
        .step_size              = 12500,
-       .on_volt                = 1200000,
-       .onlp_volt              = 1000000,
-       .ret_volt               = 975000,
-       .off_volt               = 600000,
        .volt_setup_time        = 0xfff,
        .vp_erroroffset         = OMAP3_VP_CONFIG_ERROROFFSET,
        .vp_vstepmin            = OMAP3_VP_VSTEPMIN_VSTEPMIN,
@@ -162,10 +158,6 @@ static struct omap_voltdm_pmic omap3_mpu_pmic = {
 static struct omap_voltdm_pmic omap3_core_pmic = {
        .slew_rate              = 4000,
        .step_size              = 12500,
-       .on_volt                = 1200000,
-       .onlp_volt              = 1000000,
-       .ret_volt               = 975000,
-       .off_volt               = 600000,
        .volt_setup_time        = 0xfff,
        .vp_erroroffset         = OMAP3_VP_CONFIG_ERROROFFSET,
        .vp_vstepmin            = OMAP3_VP_VSTEPMIN_VSTEPMIN,
@@ -183,10 +175,6 @@ static struct omap_voltdm_pmic omap3_core_pmic = {
 static struct omap_voltdm_pmic omap4_mpu_pmic = {
        .slew_rate              = 4000,
        .step_size              = 12660,
-       .on_volt                = 1375000,
-       .onlp_volt              = 1375000,
-       .ret_volt               = 830000,
-       .off_volt               = 0,
        .volt_setup_time        = 0,
        .vp_erroroffset         = OMAP4_VP_CONFIG_ERROROFFSET,
        .vp_vstepmin            = OMAP4_VP_VSTEPMIN_VSTEPMIN,
@@ -205,10 +193,6 @@ static struct omap_voltdm_pmic omap4_mpu_pmic = {
 static struct omap_voltdm_pmic omap4_iva_pmic = {
        .slew_rate              = 4000,
        .step_size              = 12660,
-       .on_volt                = 1188000,
-       .onlp_volt              = 1188000,
-       .ret_volt               = 830000,
-       .off_volt               = 0,
        .volt_setup_time        = 0,
        .vp_erroroffset         = OMAP4_VP_CONFIG_ERROROFFSET,
        .vp_vstepmin            = OMAP4_VP_VSTEPMIN_VSTEPMIN,
@@ -227,10 +211,6 @@ static struct omap_voltdm_pmic omap4_iva_pmic = {
 static struct omap_voltdm_pmic omap4_core_pmic = {
        .slew_rate              = 4000,
        .step_size              = 12660,
-       .on_volt                = 1200000,
-       .onlp_volt              = 1200000,
-       .ret_volt               = 830000,
-       .off_volt               = 0,
        .volt_setup_time        = 0,
        .vp_erroroffset         = OMAP4_VP_CONFIG_ERROROFFSET,
        .vp_vstepmin            = OMAP4_VP_VSTEPMIN_VSTEPMIN,
index 880249b170125b0c9f6b4d870e9f3d6a6420fc53..4c3c41fd26373cfd1cd0eb519fd358a170aed0d7 100644 (file)
@@ -135,6 +135,8 @@ int omap_vc_pre_scale(struct voltagedomain *voltdm,
        vc_cmdval |= (*target_vsel << vc->common->cmd_on_shift);
        voltdm->write(vc_cmdval, vc->cmdval_reg);
 
+       voltdm->vc_param->on = target_volt;
+
        omap_vp_update_errorgain(voltdm, target_volt);
 
        return 0;
@@ -284,6 +286,30 @@ static void __init omap_vc_i2c_init(struct voltagedomain *voltdm)
        initialized = true;
 }
 
+/**
+ * omap_vc_calc_vsel - calculate vsel value for a channel
+ * @voltdm: channel to calculate value for
+ * @uvolt: microvolt value to convert to vsel
+ *
+ * Converts a microvolt value to vsel value for the used PMIC.
+ * This checks whether the microvolt value is out of bounds, and
+ * adjusts the value accordingly. If unsupported value detected,
+ * warning is thrown.
+ */
+static u8 omap_vc_calc_vsel(struct voltagedomain *voltdm, u32 uvolt)
+{
+       if (voltdm->pmic->vddmin > uvolt)
+               uvolt = voltdm->pmic->vddmin;
+       if (voltdm->pmic->vddmax < uvolt) {
+               WARN(1, "%s: voltage not supported by pmic: %u vs max %u\n",
+                       __func__, uvolt, voltdm->pmic->vddmax);
+               /* Lets try maximum value anyway */
+               uvolt = voltdm->pmic->vddmax;
+       }
+
+       return voltdm->pmic->uv_to_vsel(uvolt);
+}
+
 void __init omap_vc_init_channel(struct voltagedomain *voltdm)
 {
        struct omap_vc_channel *vc = voltdm->vc;
@@ -335,10 +361,11 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm)
        }
 
        /* Set up the on, inactive, retention and off voltage */
-       on_vsel = voltdm->pmic->uv_to_vsel(voltdm->pmic->on_volt);
-       onlp_vsel = voltdm->pmic->uv_to_vsel(voltdm->pmic->onlp_volt);
-       ret_vsel = voltdm->pmic->uv_to_vsel(voltdm->pmic->ret_volt);
-       off_vsel = voltdm->pmic->uv_to_vsel(voltdm->pmic->off_volt);
+       on_vsel = omap_vc_calc_vsel(voltdm, voltdm->vc_param->on);
+       onlp_vsel = omap_vc_calc_vsel(voltdm, voltdm->vc_param->onlp);
+       ret_vsel = omap_vc_calc_vsel(voltdm, voltdm->vc_param->ret);
+       off_vsel = omap_vc_calc_vsel(voltdm, voltdm->vc_param->off);
+
        val = ((on_vsel << vc->common->cmd_on_shift) |
               (onlp_vsel << vc->common->cmd_onlp_shift) |
               (ret_vsel << vc->common->cmd_ret_shift) |
index 478bf6b432c42c5c92f5329311e94ac12c5d023b..7618b69811d0c0e6e8cf37e7d1d38ce612898552 100644 (file)
@@ -111,6 +111,13 @@ extern struct omap_vc_channel omap4_vc_mpu;
 extern struct omap_vc_channel omap4_vc_iva;
 extern struct omap_vc_channel omap4_vc_core;
 
+extern struct omap_vc_param omap3_mpu_vc_data;
+extern struct omap_vc_param omap3_core_vc_data;
+
+extern struct omap_vc_param omap4_mpu_vc_data;
+extern struct omap_vc_param omap4_iva_vc_data;
+extern struct omap_vc_param omap4_core_vc_data;
+
 void omap_vc_init_channel(struct voltagedomain *voltdm);
 int omap_vc_pre_scale(struct voltagedomain *voltdm,
                      unsigned long target_volt,
index 5d8eaf31569c6ebbcaf35a73f5270cb78c07bc38..75bc4aa22b3a0963d0e6ed468fecc5e17257eef4 100644 (file)
@@ -71,3 +71,25 @@ struct omap_vc_channel omap3_vc_core = {
        .smps_cmdra_mask = OMAP3430_CMDRA1_MASK,
        .cfg_channel_sa_shift = OMAP3430_PRM_VC_SMPS_SA_SA1_SHIFT,
 };
+
+/*
+ * Voltage levels for different operating modes: on, sleep, retention and off
+ */
+#define OMAP3_ON_VOLTAGE_UV            1200000
+#define OMAP3_ONLP_VOLTAGE_UV          1000000
+#define OMAP3_RET_VOLTAGE_UV           975000
+#define OMAP3_OFF_VOLTAGE_UV           600000
+
+struct omap_vc_param omap3_mpu_vc_data = {
+       .on             = OMAP3_ON_VOLTAGE_UV,
+       .onlp           = OMAP3_ONLP_VOLTAGE_UV,
+       .ret            = OMAP3_RET_VOLTAGE_UV,
+       .off            = OMAP3_OFF_VOLTAGE_UV,
+};
+
+struct omap_vc_param omap3_core_vc_data = {
+       .on             = OMAP3_ON_VOLTAGE_UV,
+       .onlp           = OMAP3_ONLP_VOLTAGE_UV,
+       .ret            = OMAP3_RET_VOLTAGE_UV,
+       .off            = OMAP3_OFF_VOLTAGE_UV,
+};
index d70b930f2739e22ce726a93474d104684409a480..085e5d6a04fd088c5422235478bb012861a96078 100644 (file)
@@ -87,3 +87,31 @@ struct omap_vc_channel omap4_vc_core = {
        .cfg_channel_sa_shift = OMAP4430_SA_VDD_CORE_L_SHIFT,
 };
 
+/*
+ * Voltage levels for different operating modes: on, sleep, retention and off
+ */
+#define OMAP4_ON_VOLTAGE_UV                    1375000
+#define OMAP4_ONLP_VOLTAGE_UV                  1375000
+#define OMAP4_RET_VOLTAGE_UV                   837500
+#define OMAP4_OFF_VOLTAGE_UV                   0
+
+struct omap_vc_param omap4_mpu_vc_data = {
+       .on                     = OMAP4_ON_VOLTAGE_UV,
+       .onlp                   = OMAP4_ONLP_VOLTAGE_UV,
+       .ret                    = OMAP4_RET_VOLTAGE_UV,
+       .off                    = OMAP4_OFF_VOLTAGE_UV,
+};
+
+struct omap_vc_param omap4_iva_vc_data = {
+       .on                     = OMAP4_ON_VOLTAGE_UV,
+       .onlp                   = OMAP4_ONLP_VOLTAGE_UV,
+       .ret                    = OMAP4_RET_VOLTAGE_UV,
+       .off                    = OMAP4_OFF_VOLTAGE_UV,
+};
+
+struct omap_vc_param omap4_core_vc_data = {
+       .on                     = OMAP4_ON_VOLTAGE_UV,
+       .onlp                   = OMAP4_ONLP_VOLTAGE_UV,
+       .ret                    = OMAP4_RET_VOLTAGE_UV,
+       .off                    = OMAP4_OFF_VOLTAGE_UV,
+};
index a3607b83790db73645ddffaa67b941d2161e38a8..697095551bb62ccc4a46eb5362e155b3520b9971 100644 (file)
@@ -74,6 +74,8 @@ struct voltagedomain {
        const struct omap_vfsm_instance *vfsm;
        struct omap_vp_instance *vp;
        struct omap_voltdm_pmic *pmic;
+       struct omap_vp_param *vp_param;
+       struct omap_vc_param *vc_param;
 
        /* VC/VP register access functions: SoC specific */
        u32 (*read) (u8 offset);
@@ -125,10 +127,6 @@ struct voltagedomain {
 struct omap_voltdm_pmic {
        int slew_rate;
        int step_size;
-       u32 on_volt;
-       u32 onlp_volt;
-       u32 ret_volt;
-       u32 off_volt;
        u16 volt_setup_time;
        u16 i2c_slave_addr;
        u16 volt_reg_addr;
@@ -145,6 +143,18 @@ struct omap_voltdm_pmic {
        u8 (*uv_to_vsel) (unsigned long uV);
 };
 
+struct omap_vp_param {
+       u32 vddmax;
+       u32 vddmin;
+};
+
+struct omap_vc_param {
+       u32 on;
+       u32 onlp;
+       u32 ret;
+       u32 off;
+};
+
 void omap_voltage_get_volttable(struct voltagedomain *voltdm,
                struct omap_volt_data **volt_data);
 struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm,
index 63afbfed3cbc2dba4f8c7ef0f9d9661b646b5e97..261bb7cb4e60e20bc58cfa72ff030e5655676fdb 100644 (file)
@@ -117,6 +117,11 @@ void __init omap3xxx_voltagedomains_init(void)
        }
 #endif
 
+       omap3_voltdm_mpu.vp_param = &omap3_mpu_vp_data;
+       omap3_voltdm_core.vp_param = &omap3_core_vp_data;
+       omap3_voltdm_mpu.vc_param = &omap3_mpu_vc_data;
+       omap3_voltdm_core.vc_param = &omap3_core_vc_data;
+
        if (soc_is_am35xx())
                voltdms = voltagedomains_am35xx;
        else
index c3115f6853d40414af8e6f8fa6982bedf9529ece..a2d7d9ca2380994b591edc97114f18de3c2299d2 100644 (file)
@@ -106,6 +106,14 @@ void __init omap44xx_voltagedomains_init(void)
        omap4_voltdm_core.volt_data = omap44xx_vdd_core_volt_data;
 #endif
 
+       omap4_voltdm_mpu.vp_param = &omap4_mpu_vp_data;
+       omap4_voltdm_iva.vp_param = &omap4_iva_vp_data;
+       omap4_voltdm_core.vp_param = &omap4_core_vp_data;
+
+       omap4_voltdm_mpu.vc_param = &omap4_mpu_vc_data;
+       omap4_voltdm_iva.vc_param = &omap4_iva_vc_data;
+       omap4_voltdm_core.vc_param = &omap4_core_vc_data;
+
        for (i = 0; voltdm = voltagedomains_omap4[i], voltdm; i++)
                voltdm->sys_clk.name = sys_clk_name;
 
index 7c155d248aa3b5b1dc62f8e1bb8fcc8adf98c221..0fdf7080e4a641002796a0f9fe34b76c363b95c3 100644 (file)
@@ -117,6 +117,13 @@ extern struct omap_vp_instance omap4_vp_mpu;
 extern struct omap_vp_instance omap4_vp_iva;
 extern struct omap_vp_instance omap4_vp_core;
 
+extern struct omap_vp_param omap3_mpu_vp_data;
+extern struct omap_vp_param omap3_core_vp_data;
+
+extern struct omap_vp_param omap4_mpu_vp_data;
+extern struct omap_vp_param omap4_iva_vp_data;
+extern struct omap_vp_param omap4_core_vp_data;
+
 void omap_vp_init(struct voltagedomain *voltdm);
 void omap_vp_enable(struct voltagedomain *voltdm);
 void omap_vp_disable(struct voltagedomain *voltdm);
index bd89f80089f5b2c1e32cf6246ed43a82dad4ca6d..1914e026245e0464f77d9bd49d6c4aba29fefb3a 100644 (file)
@@ -77,3 +77,13 @@ struct omap_vp_instance omap3_vp_core = {
        .vstatus = OMAP3_PRM_VP2_STATUS_OFFSET,
        .voltage = OMAP3_PRM_VP2_VOLTAGE_OFFSET,
 };
+
+struct omap_vp_param omap3_mpu_vp_data = {
+       .vddmin                 = OMAP3430_VP1_VLIMITTO_VDDMIN,
+       .vddmax                 = OMAP3430_VP1_VLIMITTO_VDDMAX,
+};
+
+struct omap_vp_param omap3_core_vp_data = {
+       .vddmin                 = OMAP3430_VP2_VLIMITTO_VDDMIN,
+       .vddmax                 = OMAP3430_VP2_VLIMITTO_VDDMAX,
+};
index 8c031d16879e8b833c281be6267a88ced41bd38d..e62f6b018beb2379ad5dde520cfa84fe6e39e454 100644 (file)
@@ -87,3 +87,18 @@ struct omap_vp_instance omap4_vp_core = {
        .vstatus = OMAP4_PRM_VP_CORE_STATUS_OFFSET,
        .voltage = OMAP4_PRM_VP_CORE_VOLTAGE_OFFSET,
 };
+
+struct omap_vp_param omap4_mpu_vp_data = {
+       .vddmin                 = OMAP4_VP_MPU_VLIMITTO_VDDMIN,
+       .vddmax                 = OMAP4_VP_MPU_VLIMITTO_VDDMAX,
+};
+
+struct omap_vp_param omap4_iva_vp_data = {
+       .vddmin                 = OMAP4_VP_IVA_VLIMITTO_VDDMIN,
+       .vddmax                 = OMAP4_VP_IVA_VLIMITTO_VDDMAX,
+};
+
+struct omap_vp_param omap4_core_vp_data = {
+       .vddmin                 = OMAP4_VP_CORE_VLIMITTO_VDDMIN,
+       .vddmax                 = OMAP4_VP_CORE_VLIMITTO_VDDMAX,
+};