From: Corey O'Connor Date: Fri, 23 Jul 2010 19:38:44 +0000 (-0700) Subject: Adding vpforce voltage scaling method patches X-Git-Url: http://vcs.maemo.org/git/?p=kernel-bfs;a=commitdiff_plain;h=552c22bd04f7c3fb11eadd5219f7c48cbbe14eba Adding vpforce voltage scaling method patches --- diff --git a/kernel-power-2.6.28/debian/patches/series b/kernel-power-2.6.28/debian/patches/series index e854891..fa6e867 100644 --- a/kernel-power-2.6.28/debian/patches/series +++ b/kernel-power-2.6.28/debian/patches/series @@ -31,3 +31,5 @@ overclock.diff #usbhost4.diff #usbhostmode.diff bfs.patch +voltage_scaling_1.diff +voltage_scaling_0.diff diff --git a/kernel-power-2.6.28/debian/patches/voltage_scaling_0.diff b/kernel-power-2.6.28/debian/patches/voltage_scaling_0.diff new file mode 100644 index 0000000..e5ede12 --- /dev/null +++ b/kernel-power-2.6.28/debian/patches/voltage_scaling_0.diff @@ -0,0 +1,46 @@ +From: Thara Gopinath +Date: Wed, 7 Oct 2009 00:59:43 +0000 (-0500) +Subject: OMAP3: PM: Voltage Scaling fixes +X-Git-Tag: android-2.6.29-1.6-13~23 +X-Git-Url: http://git.omapzoom.org/?p=kernel%2Fomap.git;a=commitdiff_plain;h=4243e3ab5eb2ff8cccb022387e49a2bcd9c6175e + +OMAP3: PM: Voltage Scaling fixes + +This patch does the following: + +* Update VC_CMD_VAL0 and VC_CMD_VAL1 registers during voltage + scaling using vp force update. Without this VDD1 and VDD2 + voltages will not be restored back to the proper values once + ret/off is hit. +* Enable VP force update method of voltage scaling by default. + +Signed-off-by: Thara Gopinath +Signed-off-by: Leed Aguilar +--- + +Index: kernel-2.6.28-patched/arch/arm/mach-omap2/pm34xx.c +=================================================================== +--- kernel-2.6.28-patched.orig/arch/arm/mach-omap2/pm34xx.c ++++ kernel-2.6.28-patched/arch/arm/mach-omap2/pm34xx.c +@@ -1330,6 +1330,10 @@ static int voltagescale_vpforceupdate(u3 + ((target_opp_no < VDD1_OPP3) + ? PRM_VP1_CONFIG_ERRORGAIN_OPPLOW + : PRM_VP1_CONFIG_ERRORGAIN_OPPHIGH); ++ prm_rmw_mod_reg_bits(OMAP3430_VC_CMD_ON_MASK, ++ (target_vsel << OMAP3430_VC_CMD_ON_SHIFT), ++ OMAP3430_GR_MOD, ++ OMAP3_PRM_VC_CMD_VAL_0_OFFSET); + } else if (vdd == VDD2_OPP) { + vp_config_offs = OMAP3_PRM_VP2_CONFIG_OFFSET; + vp_tranxdone_st = OMAP3430_VP2_TRANXDONE_ST; +@@ -1337,6 +1341,10 @@ static int voltagescale_vpforceupdate(u3 + ((target_opp_no < VDD2_OPP3) + ? PRM_VP2_CONFIG_ERRORGAIN_OPPLOW + : PRM_VP2_CONFIG_ERRORGAIN_OPPHIGH); ++ prm_rmw_mod_reg_bits(OMAP3430_VC_CMD_ON_MASK, ++ (target_vsel << OMAP3430_VC_CMD_ON_SHIFT), ++ OMAP3430_GR_MOD, ++ OMAP3_PRM_VC_CMD_VAL_1_OFFSET); + } + /* Clear all pending TransactionDone interrupt/status */ + while (timeout < VP_TRANXDONE_TIMEOUT) { diff --git a/kernel-power-2.6.28/debian/patches/voltage_scaling_1.diff b/kernel-power-2.6.28/debian/patches/voltage_scaling_1.diff new file mode 100644 index 0000000..633836c --- /dev/null +++ b/kernel-power-2.6.28/debian/patches/voltage_scaling_1.diff @@ -0,0 +1,201 @@ +From: Leed Aguilar +Date: Wed, 7 Oct 2009 00:55:09 +0000 (-0500) +Subject: OMAP3: PM: Voltage scaling through VP force update +X-Git-Tag: android-2.6.29-1.6-13~25 +X-Git-Url: http://git.omapzoom.org/?p=kernel%2Fomap.git;a=commitdiff_plain;h=337cafa871baae4699dbd9f2cedb7466e5df1f12 + +OMAP3: PM: Voltage scaling through VP force update + +This patch implements the VP forcee update method of voltage +scaling as per h/w recommendations. Also adds Kconfig option to +choose between the existing vc bypass and vp force update methods +voltage scaling + +Signed-off-by: Thara Gopinath +Signed-off-by: Leed Aguilar +--- + +diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c +index 97b61ca..be1092c 100644 +--- a/arch/arm/mach-omap2/pm34xx.c ++++ b/arch/arm/mach-omap2/pm34xx.c +@@ -66,6 +66,8 @@ static int regset_save_on_suspend; + #define OMAP343X_TABLE_VALUE_OFFSET 0x30 + #define OMAP343X_CONTROL_REG_VALUE_OFFSET 0x32 + ++#define VP_TRANXDONE_TIMEOUT 62 ++ + struct power_state { + struct powerdomain *pwrdm; + u32 next_state; +@@ -1308,6 +1308,123 @@ int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state) + return -EINVAL; + } + ++#ifdef CONFIG_VOLTSCALE_VPFORCE ++/* Voltage Scale using vp force update */ ++static int voltagescale_vpforceupdate(u32 target_opp, u32 current_opp, ++ u8 target_vsel, u8 current_vsel) ++{ ++ u32 vdd, target_opp_no, current_opp_no; ++ u32 t2_smps_delay = 0; ++ u32 t2_smps_steps = 0; ++ u32 vpconfig, vp_config_offs, vp_tranxdone_st; ++ int timeout = 0; ++ ++ vdd = get_vdd(target_opp); ++ target_opp_no = get_opp_no(target_opp); ++ current_opp_no = get_opp_no(current_opp); ++ t2_smps_steps = abs(target_vsel - current_vsel); ++ ++ if (vdd == VDD1_OPP) { ++ vp_config_offs = OMAP3_PRM_VP1_CONFIG_OFFSET; ++ vp_tranxdone_st = OMAP3430_VP1_TRANXDONE_ST; ++ vpconfig = target_vsel << OMAP3430_INITVOLTAGE_SHIFT | ++ ((target_opp_no < VDD1_OPP3) ++ ? PRM_VP1_CONFIG_ERRORGAIN_OPPLOW ++ : PRM_VP1_CONFIG_ERRORGAIN_OPPHIGH); ++ } else if (vdd == VDD2_OPP) { ++ vp_config_offs = OMAP3_PRM_VP2_CONFIG_OFFSET; ++ vp_tranxdone_st = OMAP3430_VP2_TRANXDONE_ST; ++ vpconfig = target_vsel << OMAP3430_INITVOLTAGE_SHIFT | ++ ((target_opp_no < VDD2_OPP3) ++ ? PRM_VP2_CONFIG_ERRORGAIN_OPPLOW ++ : PRM_VP2_CONFIG_ERRORGAIN_OPPHIGH); ++ } ++ /* Clear all pending TransactionDone interrupt/status */ ++ while (timeout < VP_TRANXDONE_TIMEOUT) { ++ prm_write_mod_reg(vp_tranxdone_st, OCP_MOD, ++ OMAP2_PRM_IRQSTATUS_MPU_OFFSET); ++ if (!(prm_read_mod_reg(OCP_MOD, OMAP2_PRM_IRQSTATUS_MPU_OFFSET) ++ & vp_tranxdone_st)) ++ break; ++ ++ udelay(1); ++ timeout++; ++ } ++ if (timeout == VP_TRANXDONE_TIMEOUT) ++ pr_warning("VP1:TRANXDONE timeout exceeded still\ ++ going ahead with voltage changed\n"); ++ ++ /* Configuring for vpforceupdate */ ++ prm_rmw_mod_reg_bits(OMAP3430_ERRORGAIN_MASK | ++ OMAP3430_INITVOLTAGE_MASK | OMAP3430_INITVDD | ++ OMAP3430_FORCEUPDATE, vpconfig, OMAP3430_GR_MOD, ++ vp_config_offs); ++ /* Initialize VP voltage */ ++ prm_set_mod_reg_bits(OMAP3430_INITVDD, OMAP3430_GR_MOD, ++ vp_config_offs); ++ /* Force update of voltage */ ++ prm_set_mod_reg_bits(OMAP3430_FORCEUPDATE, OMAP3430_GR_MOD, ++ vp_config_offs); ++ timeout = 0; ++ /* Wait for TransactionDone */ ++ while ((timeout < VP_TRANXDONE_TIMEOUT) && ++ (!(prm_read_mod_reg(OCP_MOD, ++ OMAP2_PRM_IRQSTATUS_MPU_OFFSET) & ++ vp_tranxdone_st))) { ++ udelay(1); ++ timeout++; ++ } ++ ++ if (timeout == VP_TRANXDONE_TIMEOUT) ++ pr_warning("VP1:TRANXDONE timeout exceeded going ahead with\ ++ the t2 smps wait\n"); ++ ++ /* Wait for voltage to settle with SW wait-loop */ ++ t2_smps_delay = ((t2_smps_steps * 125) / 40) + 2; ++ udelay(t2_smps_delay); ++ ++ timeout = 0; ++ /* Clear all pending TransactionDone interrupt/status */ ++ while (timeout < VP_TRANXDONE_TIMEOUT) { ++ prm_write_mod_reg(vp_tranxdone_st, OCP_MOD, ++ OMAP2_PRM_IRQSTATUS_MPU_OFFSET); ++ if (!(prm_read_mod_reg(OCP_MOD, OMAP2_PRM_IRQSTATUS_MPU_OFFSET) ++ & vp_tranxdone_st)) ++ break; ++ ++ udelay(1); ++ timeout++; ++ } ++ if (timeout == VP_TRANXDONE_TIMEOUT) ++ pr_warning("VP1:TRANXDONE timeout exceeded\n"); ++ ++ /* Clear INITVDD bit */ ++ prm_clear_mod_reg_bits(OMAP3430_INITVDD, OMAP3430_GR_MOD, ++ vp_config_offs); ++ ++ /* Clear force bit */ ++ prm_clear_mod_reg_bits(OMAP3430_FORCEUPDATE, OMAP3430_GR_MOD, ++ vp_config_offs); ++ return 0; ++} ++#endif ++ ++/* Scale voltage using vcbypass or vpforceupdate */ ++int omap_scale_voltage(u32 target_opp, u32 current_opp, ++ u8 target_vsel, u8 current_vsel) ++{ ++ #if defined(CONFIG_VOLTSCALE_VPFORCE) ++ return voltagescale_vpforceupdate(target_opp, current_opp, ++ target_vsel, current_vsel); ++ #elif defined(CONFIG_OMAP_SMARTREFLEX) ++ return sr_voltagescale_vcbypass(target_opp, current_opp, ++ target_vsel, current_vsel); ++ #else ++ return 0; ++ #endif ++} ++EXPORT_SYMBOL(omap_scale_voltage); ++ + void omap3_set_prm_setup_times(struct prm_setup_times *setup_times) + { + prm_setup.clksetup = setup_vc->clksetup; +diff --git a/arch/arm/mach-omap2/resource34xx.c b/arch/arm/mach-omap2/resource34xx.c +index 68616f0..7beaa8b 100644 +--- a/arch/arm/mach-omap2/resource34xx.c ++++ b/arch/arm/mach-omap2/resource34xx.c +@@ -288,9 +288,9 @@ static int program_opp(int res, struct omap_opp *opp, int target_level, + #ifdef CONFIG_OMAP_SMARTREFLEX + else +- sr_voltagescale_vcbypass(t_opp, c_opp, ++ omap_scale_voltage(t_opp, c_opp, + opp[target_level].vsel, + opp[current_level].vsel); + #endif + } + #ifdef CONFIG_OMAP_SMARTREFLEX + if (sr_status) +diff --git a/arch/arm/mach-omap2/resource34xx.h b/arch/arm/mach-omap2/resource34xx.h +index 5b5618a..f5c0636 100644 +--- a/arch/arm/mach-omap2/resource34xx.h ++++ b/arch/arm/mach-omap2/resource34xx.h +@@ -31,5 +31,5 @@ + #include + #include "resource34xx_mutex.h" + +-extern int sr_voltagescale_vcbypass(u32 t_opp, u32 c_opp, u8 t_vsel, u8 c_vsel); ++extern int omap_scale_voltage(u32 t_opp, u32 c_opp, u8 t_vsel, u8 c_vsel); + +diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig +index 8918e8f..7737890 100644 +--- a/arch/arm/plat-omap/Kconfig ++++ b/arch/arm/plat-omap/Kconfig +@@ -402,6 +402,16 @@ config OMAP3_MPU_L2_CACHE_WORKAROUND + instruction a system hang or reset via watchdog occurs. OFF + mode is still safe to use. + ++config VOLTSCALE_VPFORCE ++ bool "Voltage scaling using VP force update method" ++ depends on ARCH_OMAP3 && PM ++ help ++ Say Y if you want to enable VP force update method ++ of voltage scaling. This is the h/w recomended way ++ of voltage scaling. ++ ++ If not enabled and if OMAP_SMARTREFLEX is enabled ++ vcbypass method will be used for voltage scaling. + endmenu + + endif