All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support
@ 2011-11-25 15:49 Tero Kristo
  2011-11-25 15:49 ` [PATCHv4 01/15] OMAP3+: PM: VP: use uV for max and min voltage limits Tero Kristo
                   ` (16 more replies)
  0 siblings, 17 replies; 43+ messages in thread
From: Tero Kristo @ 2011-11-25 15:49 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, nm

Hi,

Changes compared to previous version:

- merged most of the voltagedomain cleanup fixes to patch 2
- moved pmic latencies to omap_voltdm_pmic struct
- renamed omap_lp_params to omap2_oscillator as it only contains
  osc info now
- major changes to usecount support (patch 11+, needed for auto-ret)
  * added usecounts to voltagedomain / powerdomain
  * fixed usecount tracking so that the numbers are sane now
  * changed behavior of some usecounting sources that they do not
    update the counts (autoidle support)
- added auto-ret / auto-off support, based on fixed usecounting
  * smartreflex disabled / enabled
  * auto-ret / auto-off enabled based on target state
- some other minor tweaks I have probably forgotten to mention

Tested on omap3 beagle:
- voltages for vdd1 and vdd2 change when entering idle
- both suspend and dynamic idle tested
- tested that voltages reach target levels for both ret / off

Tested on omap4 blaze with custom kernel
- this requires a few additional patches missing from this set as
  omap4 PM support is still not merged
- will post missing patches once possible from upstream point of view
- voltages for vdd1 and vdd3 change when entering idle

Applies on top of Kevin's for_3.2/voltage-cleanup branch.

I have a bunch of additional debugging patches I have used in verification
of this set if anybody is interested.

TBD:
- no pmic off support yet
  * no pmic script support
  * vdd1 / vdd2 only reach 0.6V, not 0V in off
  * oscillator is not turned off

-Tero



^ permalink raw reply	[flat|nested] 43+ messages in thread

* [PATCHv4 01/15] OMAP3+: PM: VP: use uV for max and min voltage limits
  2011-11-25 15:49 [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support Tero Kristo
@ 2011-11-25 15:49 ` Tero Kristo
  2011-12-09 18:07   ` Kevin Hilman
  2011-11-25 15:49 ` [PATCHv4 02/15] omap3+: voltage: parameter segregation Tero Kristo
                   ` (15 subsequent siblings)
  16 siblings, 1 reply; 43+ messages in thread
From: Tero Kristo @ 2011-11-25 15:49 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, nm, Vishwanath BS

From: Nishanth Menon <nm@ti.com>

Every PMIC has it's own eccentricities, For example, one of the
PMIC has MSB set to 1 for a specific function - voltage enable!
using an hardcoded value specific for TWL when copied over to
such an implementation causes the system to crash as the MSB bit
was 0 and the voltage got disabled!.

Instead we use actual values and depend on the convertion routines
to abstract out the eccentricities of each PMIC.

With this, we can now move the voltages to a common location in
voltage.h as they are no longer dependent on PMICs and expect the
PMIC's conversion routines to set a cap if the voltage is out of
reach for the PMIC.

Reported-by: Jon Hunter <jon-hunter@ti.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Vishwanath BS <vishwanath.bs@ti.com>
---
 arch/arm/mach-omap2/omap_twl.c |   17 -----------------
 arch/arm/mach-omap2/voltage.h  |   22 ++++++++++++++++++++--
 arch/arm/mach-omap2/vp.c       |    4 ++--
 3 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c
index f515a1a..df4e7c3 100644
--- a/arch/arm/mach-omap2/omap_twl.c
+++ b/arch/arm/mach-omap2/omap_twl.c
@@ -30,16 +30,6 @@
 #define OMAP3_VP_VSTEPMAX_VSTEPMAX	0x04
 #define OMAP3_VP_VLIMITTO_TIMEOUT_US	200
 
-#define OMAP3430_VP1_VLIMITTO_VDDMIN	0x14
-#define OMAP3430_VP1_VLIMITTO_VDDMAX	0x42
-#define OMAP3430_VP2_VLIMITTO_VDDMIN	0x18
-#define OMAP3430_VP2_VLIMITTO_VDDMAX	0x2c
-
-#define OMAP3630_VP1_VLIMITTO_VDDMIN	0x18
-#define OMAP3630_VP1_VLIMITTO_VDDMAX	0x3c
-#define OMAP3630_VP2_VLIMITTO_VDDMIN	0x18
-#define OMAP3630_VP2_VLIMITTO_VDDMAX	0x30
-
 #define OMAP4_SRI2C_SLAVE_ADDR		0x12
 #define OMAP4_VDD_MPU_SR_VOLT_REG	0x55
 #define OMAP4_VDD_MPU_SR_CMD_REG	0x56
@@ -53,13 +43,6 @@
 #define OMAP4_VP_VSTEPMAX_VSTEPMAX	0x04
 #define OMAP4_VP_VLIMITTO_TIMEOUT_US	200
 
-#define OMAP4_VP_MPU_VLIMITTO_VDDMIN	0xA
-#define OMAP4_VP_MPU_VLIMITTO_VDDMAX	0x39
-#define OMAP4_VP_IVA_VLIMITTO_VDDMIN	0xA
-#define OMAP4_VP_IVA_VLIMITTO_VDDMAX	0x2D
-#define OMAP4_VP_CORE_VLIMITTO_VDDMIN	0xA
-#define OMAP4_VP_CORE_VLIMITTO_VDDMAX	0x28
-
 static bool is_offset_valid;
 static u8 smps_offset;
 /*
diff --git a/arch/arm/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h
index 16a1b09..5204936 100644
--- a/arch/arm/mach-omap2/voltage.h
+++ b/arch/arm/mach-omap2/voltage.h
@@ -109,6 +109,24 @@ struct omap_volt_data {
 	u8	vp_errgain;
 };
 
+/* Min and max voltages from OMAP perspective */
+#define OMAP3430_VP1_VLIMITTO_VDDMIN	850000
+#define OMAP3430_VP1_VLIMITTO_VDDMAX	1425000
+#define OMAP3430_VP2_VLIMITTO_VDDMIN	900000
+#define OMAP3430_VP2_VLIMITTO_VDDMAX	1150000
+
+#define OMAP3630_VP1_VLIMITTO_VDDMIN	900000
+#define OMAP3630_VP1_VLIMITTO_VDDMAX	1350000
+#define OMAP3630_VP2_VLIMITTO_VDDMIN	900000
+#define OMAP3630_VP2_VLIMITTO_VDDMAX	1200000
+
+#define OMAP4_VP_MPU_VLIMITTO_VDDMIN	830000
+#define OMAP4_VP_MPU_VLIMITTO_VDDMAX	1410000
+#define OMAP4_VP_IVA_VLIMITTO_VDDMIN	830000
+#define OMAP4_VP_IVA_VLIMITTO_VDDMAX	1260000
+#define OMAP4_VP_CORE_VLIMITTO_VDDMIN	830000
+#define OMAP4_VP_CORE_VLIMITTO_VDDMAX	1200000
+
 /**
  * struct omap_voltdm_pmic - PMIC specific data required by voltage driver.
  * @slew_rate:	PMIC slew rate (in uv/us)
@@ -135,8 +153,8 @@ struct omap_voltdm_pmic {
 	u8 vp_erroroffset;
 	u8 vp_vstepmin;
 	u8 vp_vstepmax;
-	u8 vp_vddmin;
-	u8 vp_vddmax;
+	u32 vp_vddmin;
+	u32 vp_vddmax;
 	u8 vp_timeout_us;
 	bool i2c_high_speed;
 	u8 i2c_mcode;
diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c
index 66bd700..16cb6d4 100644
--- a/arch/arm/mach-omap2/vp.c
+++ b/arch/arm/mach-omap2/vp.c
@@ -53,8 +53,8 @@ void __init omap_vp_init(struct voltagedomain *voltdm)
 	sys_clk_rate = voltdm->sys_clk.rate / 1000;
 
 	timeout = (sys_clk_rate * voltdm->pmic->vp_timeout_us) / 1000;
-	vddmin = voltdm->pmic->vp_vddmin;
-	vddmax = voltdm->pmic->vp_vddmax;
+	vddmin = voltdm->pmic->uv_to_vsel(voltdm->pmic->vp_vddmin);
+	vddmax = voltdm->pmic->uv_to_vsel(voltdm->pmic->vp_vddmax);
 
 	waittime = ((voltdm->pmic->step_size / voltdm->pmic->slew_rate) *
 		    sys_clk_rate) / 1000;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCHv4 02/15] omap3+: voltage: parameter segregation
  2011-11-25 15:49 [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support Tero Kristo
  2011-11-25 15:49 ` [PATCHv4 01/15] OMAP3+: PM: VP: use uV for max and min voltage limits Tero Kristo
@ 2011-11-25 15:49 ` Tero Kristo
  2011-11-29 18:26   ` Menon, Nishanth
  2011-11-30 10:11   ` Jean Pihet
  2011-11-25 15:49 ` [PATCHv4 03/15] omap: voltage: add definition for pmic startup / shutdown times Tero Kristo
                   ` (14 subsequent siblings)
  16 siblings, 2 replies; 43+ messages in thread
From: Tero Kristo @ 2011-11-25 15:49 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, nm

Introduced two new voltage domain specific parameter structures,
omap_vp_param and omap_vc_param. These are used to describe the minimum
and maximum voltages for the voltagedomains, and also the sleep voltage
levels. Existing voltage levels are also moved into these new structures,
and the voltage domain code is changed to use these.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/omap_opp_data.h           |   15 ++
 arch/arm/mach-omap2/omap_twl.c                |   25 ----
 arch/arm/mach-omap2/opp3xxx_data.c            |   52 +++++++
 arch/arm/mach-omap2/opp4xxx_data.c            |   40 ++++++
 arch/arm/mach-omap2/vc.c                      |  178 +++++++++++++++++++++----
 arch/arm/mach-omap2/vc.h                      |    1 -
 arch/arm/mach-omap2/voltage.h                 |   18 ++-
 arch/arm/mach-omap2/voltagedomains3xxx_data.c |    8 +
 arch/arm/mach-omap2/voltagedomains44xx_data.c |    8 +
 9 files changed, 289 insertions(+), 56 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_opp_data.h b/arch/arm/mach-omap2/omap_opp_data.h
index c784c12..b5fe711 100644
--- a/arch/arm/mach-omap2/omap_opp_data.h
+++ b/arch/arm/mach-omap2/omap_opp_data.h
@@ -86,11 +86,26 @@ extern int __init omap_init_opp_table(struct omap_opp_def *opp_def,
 
 extern struct omap_volt_data omap34xx_vddmpu_volt_data[];
 extern struct omap_volt_data omap34xx_vddcore_volt_data[];
+extern struct omap_vp_param omap34xx_mpu_vp_data;
+extern struct omap_vp_param omap34xx_core_vp_data;
+extern struct omap_vc_param omap34xx_mpu_vc_data;
+extern struct omap_vc_param omap34xx_core_vc_data;
+
 extern struct omap_volt_data omap36xx_vddmpu_volt_data[];
 extern struct omap_volt_data omap36xx_vddcore_volt_data[];
+extern struct omap_vp_param omap36xx_mpu_vp_data;
+extern struct omap_vp_param omap36xx_core_vp_data;
+extern struct omap_vc_param omap36xx_mpu_vc_data;
+extern struct omap_vc_param omap36xx_core_vc_data;
 
 extern struct omap_volt_data omap44xx_vdd_mpu_volt_data[];
 extern struct omap_volt_data omap44xx_vdd_iva_volt_data[];
 extern struct omap_volt_data omap44xx_vdd_core_volt_data[];
+extern struct omap_vp_param omap44xx_mpu_vp_data;
+extern struct omap_vp_param omap44xx_iva_vp_data;
+extern struct omap_vp_param omap44xx_core_vp_data;
+extern struct omap_vc_param omap44xx_mpu_vc_data;
+extern struct omap_vc_param omap44xx_iva_vc_data;
+extern struct omap_vc_param omap44xx_core_vc_data;
 
 #endif		/* __ARCH_ARM_MACH_OMAP2_OMAP_OPP_DATA_H */
diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c
index df4e7c3..62ed050 100644
--- a/arch/arm/mach-omap2/omap_twl.c
+++ b/arch/arm/mach-omap2/omap_twl.c
@@ -141,11 +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,
 	.vp_vstepmax		= OMAP3_VP_VSTEPMAX_VSTEPMAX,
@@ -162,11 +157,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,
 	.vp_vstepmax		= OMAP3_VP_VSTEPMAX_VSTEPMAX,
@@ -183,11 +173,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,
 	.vp_vstepmax		= OMAP4_VP_VSTEPMAX_VSTEPMAX,
@@ -205,11 +190,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,
 	.vp_vstepmax		= OMAP4_VP_VSTEPMAX_VSTEPMAX,
@@ -227,11 +207,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,
 	.vp_vstepmax		= OMAP4_VP_VSTEPMAX_VSTEPMAX,
diff --git a/arch/arm/mach-omap2/opp3xxx_data.c b/arch/arm/mach-omap2/opp3xxx_data.c
index d95f3f9..1d44df5 100644
--- a/arch/arm/mach-omap2/opp3xxx_data.c
+++ b/arch/arm/mach-omap2/opp3xxx_data.c
@@ -26,6 +26,10 @@
 #include "pm.h"
 
 /* 34xx */
+#define OMAP3_ON_VOLTAGE_UV		1200000
+#define OMAP3_ONLP_VOLTAGE_UV		1000000
+#define OMAP3_RET_VOLTAGE_UV		975000
+#define OMAP3_OFF_VOLTAGE_UV		600000
 
 /* VDD1 */
 
@@ -44,6 +48,18 @@ struct omap_volt_data omap34xx_vddmpu_volt_data[] = {
 	VOLT_DATA_DEFINE(0, 0, 0, 0),
 };
 
+struct omap_vp_param omap34xx_mpu_vp_data = {
+	.vddmin			= OMAP3430_VP1_VLIMITTO_VDDMIN,
+	.vddmax			= OMAP3430_VP1_VLIMITTO_VDDMAX,
+};
+
+struct omap_vc_param omap34xx_mpu_vc_data = {
+	.on		= OMAP3_ON_VOLTAGE_UV,
+	.onlp		= OMAP3_ONLP_VOLTAGE_UV,
+	.ret		= OMAP3_RET_VOLTAGE_UV,
+	.off		= OMAP3_OFF_VOLTAGE_UV,
+};
+
 /* VDD2 */
 
 #define OMAP3430_VDD_CORE_OPP1_UV		975000
@@ -57,6 +73,18 @@ struct omap_volt_data omap34xx_vddcore_volt_data[] = {
 	VOLT_DATA_DEFINE(0, 0, 0, 0),
 };
 
+struct omap_vp_param omap34xx_core_vp_data = {
+	.vddmin			= OMAP3430_VP2_VLIMITTO_VDDMIN,
+	.vddmax			= OMAP3430_VP2_VLIMITTO_VDDMAX,
+};
+
+struct omap_vc_param omap34xx_core_vc_data = {
+	.on		= OMAP3_ON_VOLTAGE_UV,
+	.onlp		= OMAP3_ONLP_VOLTAGE_UV,
+	.ret		= OMAP3_RET_VOLTAGE_UV,
+	.off		= OMAP3_OFF_VOLTAGE_UV,
+};
+
 /* 36xx */
 
 /* VDD1 */
@@ -74,6 +102,18 @@ struct omap_volt_data omap36xx_vddmpu_volt_data[] = {
 	VOLT_DATA_DEFINE(0, 0, 0, 0),
 };
 
+struct omap_vp_param omap36xx_mpu_vp_data = {
+	.vddmin			= OMAP3630_VP1_VLIMITTO_VDDMIN,
+	.vddmax			= OMAP3630_VP1_VLIMITTO_VDDMAX,
+};
+
+struct omap_vc_param omap36xx_mpu_vc_data = {
+	.on		= OMAP3_ON_VOLTAGE_UV,
+	.onlp		= OMAP3_ONLP_VOLTAGE_UV,
+	.ret		= OMAP3_RET_VOLTAGE_UV,
+	.off		= OMAP3_OFF_VOLTAGE_UV,
+};
+
 /* VDD2 */
 
 #define OMAP3630_VDD_CORE_OPP50_UV		1000000
@@ -85,6 +125,18 @@ struct omap_volt_data omap36xx_vddcore_volt_data[] = {
 	VOLT_DATA_DEFINE(0, 0, 0, 0),
 };
 
+struct omap_vp_param omap36xx_core_vp_data = {
+	.vddmin			= OMAP3630_VP2_VLIMITTO_VDDMIN,
+	.vddmax			= OMAP3630_VP2_VLIMITTO_VDDMAX,
+};
+
+struct omap_vc_param omap36xx_core_vc_data = {
+	.on		= OMAP3_ON_VOLTAGE_UV,
+	.onlp		= OMAP3_ONLP_VOLTAGE_UV,
+	.ret		= OMAP3_RET_VOLTAGE_UV,
+	.off		= OMAP3_OFF_VOLTAGE_UV,
+};
+
 /* OPP data */
 
 static struct omap_opp_def __initdata omap34xx_opp_def_list[] = {
diff --git a/arch/arm/mach-omap2/opp4xxx_data.c b/arch/arm/mach-omap2/opp4xxx_data.c
index 2293ba2..dc405b6 100644
--- a/arch/arm/mach-omap2/opp4xxx_data.c
+++ b/arch/arm/mach-omap2/opp4xxx_data.c
@@ -31,6 +31,11 @@
  * voltage dependent data for each VDD.
  */
 
+#define OMAP4_ON_VOLTAGE_UV			1375000
+#define OMAP4_ONLP_VOLTAGE_UV			1375000
+#define OMAP4_RET_VOLTAGE_UV			837500
+#define OMAP4_OFF_VOLTAGE_UV			600000
+
 #define OMAP4430_VDD_MPU_OPP50_UV		1025000
 #define OMAP4430_VDD_MPU_OPP100_UV		1200000
 #define OMAP4430_VDD_MPU_OPPTURBO_UV		1313000
@@ -44,6 +49,18 @@ struct omap_volt_data omap44xx_vdd_mpu_volt_data[] = {
 	VOLT_DATA_DEFINE(0, 0, 0, 0),
 };
 
+struct omap_vp_param omap44xx_mpu_vp_data = {
+	.vddmin			= OMAP4_VP_MPU_VLIMITTO_VDDMIN,
+	.vddmax			= OMAP4_VP_MPU_VLIMITTO_VDDMAX,
+};
+
+struct omap_vc_param omap44xx_mpu_vc_data = {
+	.on			= OMAP4_ON_VOLTAGE_UV,
+	.onlp			= OMAP4_ONLP_VOLTAGE_UV,
+	.ret			= OMAP4_RET_VOLTAGE_UV,
+	.off			= OMAP4_OFF_VOLTAGE_UV,
+};
+
 #define OMAP4430_VDD_IVA_OPP50_UV		1013000
 #define OMAP4430_VDD_IVA_OPP100_UV		1188000
 #define OMAP4430_VDD_IVA_OPPTURBO_UV		1300000
@@ -55,6 +72,18 @@ struct omap_volt_data omap44xx_vdd_iva_volt_data[] = {
 	VOLT_DATA_DEFINE(0, 0, 0, 0),
 };
 
+struct omap_vp_param omap44xx_iva_vp_data = {
+	.vddmin			= OMAP4_VP_IVA_VLIMITTO_VDDMIN,
+	.vddmax			= OMAP4_VP_IVA_VLIMITTO_VDDMAX,
+};
+
+struct omap_vc_param omap44xx_iva_vc_data = {
+	.on			= OMAP4_ON_VOLTAGE_UV,
+	.onlp			= OMAP4_ONLP_VOLTAGE_UV,
+	.ret			= OMAP4_RET_VOLTAGE_UV,
+	.off			= OMAP4_OFF_VOLTAGE_UV,
+};
+
 #define OMAP4430_VDD_CORE_OPP50_UV		1025000
 #define OMAP4430_VDD_CORE_OPP100_UV		1200000
 
@@ -64,6 +93,17 @@ struct omap_volt_data omap44xx_vdd_core_volt_data[] = {
 	VOLT_DATA_DEFINE(0, 0, 0, 0),
 };
 
+struct omap_vp_param omap44xx_core_vp_data = {
+	.vddmin			= OMAP4_VP_CORE_VLIMITTO_VDDMIN,
+	.vddmax			= OMAP4_VP_CORE_VLIMITTO_VDDMAX,
+};
+
+struct omap_vc_param omap44xx_core_vc_data = {
+	.on			= OMAP4_ON_VOLTAGE_UV,
+	.onlp			= OMAP4_ONLP_VOLTAGE_UV,
+	.ret			= OMAP4_RET_VOLTAGE_UV,
+	.off			= OMAP4_OFF_VOLTAGE_UV,
+};
 
 static struct omap_opp_def __initdata omap44xx_opp_def_list[] = {
 	/* MPU OPP1 - OPP50 */
diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
index 031d116..8384b70 100644
--- a/arch/arm/mach-omap2/vc.c
+++ b/arch/arm/mach-omap2/vc.c
@@ -10,14 +10,18 @@
 #include <linux/kernel.h>
 #include <linux/delay.h>
 #include <linux/init.h>
+#include <linux/clk.h>
+#include <linux/io.h>
 
 #include <plat/cpu.h>
+#include <plat/prcm.h>
 
 #include "voltage.h"
 #include "vc.h"
 #include "prm-regbits-34xx.h"
 #include "prm-regbits-44xx.h"
 #include "prm44xx.h"
+#include "scrm44xx.h"
 
 /**
  * struct omap_vc_channel_cfg - describe the cfg_channel bitfield
@@ -136,6 +140,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;
@@ -203,44 +209,170 @@ int omap_vc_bypass_scale(struct voltagedomain *voltdm,
 	return 0;
 }
 
-static void __init omap3_vfsm_init(struct voltagedomain *voltdm)
+static void omap3_set_i2c_timings(struct voltagedomain *voltdm, int off_mode)
 {
+	unsigned long voltsetup1;
+	u32 tgt_volt;
+
+	if (off_mode)
+		tgt_volt = voltdm->vc_param->off;
+	else
+		tgt_volt = voltdm->vc_param->ret;
+
+	voltsetup1 = (voltdm->vc_param->on - tgt_volt) /
+			voltdm->pmic->slew_rate;
+
+	voltsetup1 = voltsetup1 * voltdm->sys_clk.rate / 8 / 1000000 + 1;
+
+	voltdm->rmw(voltdm->vfsm->voltsetup_mask,
+		voltsetup1 << __ffs(voltdm->vfsm->voltsetup_mask),
+		voltdm->vfsm->voltsetup_reg);
+
 	/*
-	 * Voltage Manager FSM parameters init
-	 * XXX This data should be passed in from the board file
+	 * pmic is not controlling the voltage scaling during retention,
+	 * thus set voltsetup2 to 0
 	 */
-	voltdm->write(OMAP3_CLKSETUP, OMAP3_PRM_CLKSETUP_OFFSET);
-	voltdm->write(OMAP3_VOLTOFFSET, OMAP3_PRM_VOLTOFFSET_OFFSET);
-	voltdm->write(OMAP3_VOLTSETUP2, OMAP3_PRM_VOLTSETUP2_OFFSET);
+	voltdm->write(0, OMAP3_PRM_VOLTSETUP2_OFFSET);
 }
 
-static void __init omap3_vc_init_channel(struct voltagedomain *voltdm)
+static void omap3_set_off_timings(struct voltagedomain *voltdm)
 {
-	static bool is_initialized;
+	unsigned long clksetup;
+	unsigned long voltsetup2;
+	unsigned long voltsetup2_old;
+	u32 val;
 
-	if (is_initialized)
+	/* check if pmic is controlling off-mode voltages */
+	val = voltdm->read(OMAP3_PRM_VOLTCTRL_OFFSET);
+	if (!(val & OMAP3430_SEL_OFF_MASK)) {
+		/* No, omap is controlling them over I2C */
+		omap3_set_i2c_timings(voltdm, 1);
 		return;
+	}
+
+	clksetup = voltdm->read(OMAP3_PRM_CLKSETUP_OFFSET);
+
+	/* voltsetup 2 in us */
+	voltsetup2 = voltdm->vc_param->on / voltdm->pmic->slew_rate;
+
+	/* convert to 32k clk cycles */
+	voltsetup2 = DIV_ROUND_UP(voltsetup2 * 32768, 1000000);
+
+	voltsetup2_old = voltdm->read(OMAP3_PRM_VOLTSETUP2_OFFSET);
+
+	/*
+	 * Update voltsetup2 if higher than current value (needed because
+	 * we have multiple channels with different ramp times), also
+	 * update voltoffset always to value recommended by TRM
+	 */
+	if (voltsetup2 > voltsetup2_old) {
+		voltdm->write(voltsetup2, OMAP3_PRM_VOLTSETUP2_OFFSET);
+		voltdm->write(clksetup - voltsetup2,
+			OMAP3_PRM_VOLTOFFSET_OFFSET);
+	} else
+		voltdm->write(clksetup - voltsetup2_old,
+			OMAP3_PRM_VOLTOFFSET_OFFSET);
+
+	/*
+	 * omap is not controlling voltage scaling during off-mode,
+	 * thus set voltsetup1 to 0
+	 */
+	voltdm->rmw(voltdm->vfsm->voltsetup_mask, 0,
+		voltdm->vfsm->voltsetup_reg);
+
+	/* voltoffset must be clksetup minus voltsetup2 according to TRM */
+	voltdm->write(clksetup - voltsetup2, OMAP3_PRM_VOLTOFFSET_OFFSET);
+}
+
+static void __init omap3_vc_init_channel(struct voltagedomain *voltdm)
+{
+	omap3_set_off_timings(voltdm);
+}
+
+static u32 omap4_calc_volt_ramp(struct voltagedomain *voltdm, u32 voltage_diff,
+		u32 clk_rate)
+{
+	u32 prescaler;
+	u32 cycles;
+	u32 time;
+
+	time = voltage_diff / voltdm->pmic->slew_rate;
+
+	cycles = clk_rate / 1000 * time / 1000;
+
+	cycles /= 64;
+	prescaler = 0;
+
+	/* shift to next prescaler until no overflow */
+
+	/* scale for div 256 = 64 * 4 */
+	if (cycles > 63) {
+		cycles /= 4;
+		prescaler++;
+	}
 
-	omap3_vfsm_init(voltdm);
+	/* scale for div 512 = 256 * 2 */
+	if (cycles > 63) {
+		cycles /= 2;
+		prescaler++;
+	}
+
+	/* scale for div 2048 = 512 * 4 */
+	if (cycles > 63) {
+		cycles /= 4;
+		prescaler++;
+	}
 
-	is_initialized = true;
+	/* check for overflow => invalid ramp time */
+	if (cycles > 63) {
+		pr_warning("%s: invalid setuptime for vdd_%s\n", __func__,
+			voltdm->name);
+		return 0;
+	}
+
+	cycles++;
+
+	return (prescaler << OMAP4430_RAMP_UP_PRESCAL_SHIFT) |
+		(cycles << OMAP4430_RAMP_UP_COUNT_SHIFT);
 }
 
+static void omap4_set_timings(struct voltagedomain *voltdm, bool off_mode)
+{
+	u32 val;
+	u32 ramp;
+
+	/* configure the setup times */
+	val = voltdm->read(voltdm->vfsm->voltsetup_reg);
+
+	if (off_mode)
+		ramp = omap4_calc_volt_ramp(voltdm,
+			voltdm->vc_param->on - voltdm->vc_param->off,
+			voltdm->sys_clk.rate);
+	else
+		ramp = omap4_calc_volt_ramp(voltdm,
+			voltdm->vc_param->on - voltdm->vc_param->ret,
+			voltdm->sys_clk.rate);
+
+	if (!ramp)
+		return;
+
+	val |= ramp << OMAP4430_RAMP_DOWN_COUNT_SHIFT;
+
+	val |= ramp << OMAP4430_RAMP_UP_COUNT_SHIFT;
+
+	voltdm->write(val, voltdm->vfsm->voltsetup_reg);
+}
 
 /* OMAP4 specific voltage init functions */
 static void __init omap4_vc_init_channel(struct voltagedomain *voltdm)
 {
-	static bool is_initialized;
 	u32 vc_val;
 
-	if (is_initialized)
-		return;
+	omap4_set_timings(voltdm, true);
 
 	/* XXX These are magic numbers and do not belong! */
 	vc_val = (0x60 << OMAP4430_SCLL_SHIFT | 0x26 << OMAP4430_SCLH_SHIFT);
 	voltdm->write(vc_val, OMAP4_PRM_VC_CFG_I2C_CLK_OFFSET);
-
-	is_initialized = true;
 }
 
 /**
@@ -314,7 +446,6 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm)
 	vc->i2c_slave_addr = voltdm->pmic->i2c_slave_addr;
 	vc->volt_reg_addr = voltdm->pmic->volt_reg_addr;
 	vc->cmd_reg_addr = voltdm->pmic->cmd_reg_addr;
-	vc->setup_time = voltdm->pmic->volt_setup_time;
 
 	/* Configure the i2c slave address for this VC */
 	voltdm->rmw(vc->smps_sa_mask,
@@ -338,10 +469,10 @@ 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 = voltdm->pmic->uv_to_vsel(voltdm->vc_param->on);
+	onlp_vsel = voltdm->pmic->uv_to_vsel(voltdm->vc_param->onlp);
+	ret_vsel = voltdm->pmic->uv_to_vsel(voltdm->vc_param->ret);
+	off_vsel = voltdm->pmic->uv_to_vsel(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) |
@@ -352,11 +483,6 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm)
 	/* Channel configuration */
 	omap_vc_config_channel(voltdm);
 
-	/* Configure the setup times */
-	voltdm->rmw(voltdm->vfsm->voltsetup_mask,
-		    vc->setup_time << __ffs(voltdm->vfsm->voltsetup_mask),
-		    voltdm->vfsm->voltsetup_reg);
-
 	omap_vc_i2c_init(voltdm);
 
 	if (cpu_is_omap34xx())
diff --git a/arch/arm/mach-omap2/vc.h b/arch/arm/mach-omap2/vc.h
index 478bf6b..916c8fc 100644
--- a/arch/arm/mach-omap2/vc.h
+++ b/arch/arm/mach-omap2/vc.h
@@ -86,7 +86,6 @@ struct omap_vc_channel {
 	u16 i2c_slave_addr;
 	u16 volt_reg_addr;
 	u16 cmd_reg_addr;
-	u16 setup_time;
 	u8 cfg_channel;
 	bool i2c_high_speed;
 
diff --git a/arch/arm/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h
index 5204936..3afd1fc 100644
--- a/arch/arm/mach-omap2/voltage.h
+++ b/arch/arm/mach-omap2/voltage.h
@@ -72,6 +72,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);
@@ -142,10 +144,6 @@ struct omap_volt_data {
 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;
@@ -162,6 +160,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,
diff --git a/arch/arm/mach-omap2/voltagedomains3xxx_data.c b/arch/arm/mach-omap2/voltagedomains3xxx_data.c
index 071101d..35b3bed 100644
--- a/arch/arm/mach-omap2/voltagedomains3xxx_data.c
+++ b/arch/arm/mach-omap2/voltagedomains3xxx_data.c
@@ -88,9 +88,17 @@ void __init omap3xxx_voltagedomains_init(void)
 	if (cpu_is_omap3630()) {
 		omap3_voltdm_mpu.volt_data = omap36xx_vddmpu_volt_data;
 		omap3_voltdm_core.volt_data = omap36xx_vddcore_volt_data;
+		omap3_voltdm_mpu.vp_param = &omap36xx_mpu_vp_data;
+		omap3_voltdm_core.vp_param = &omap36xx_core_vp_data;
+		omap3_voltdm_mpu.vc_param = &omap36xx_mpu_vc_data;
+		omap3_voltdm_core.vc_param = &omap36xx_core_vc_data;
 	} else {
 		omap3_voltdm_mpu.volt_data = omap34xx_vddmpu_volt_data;
 		omap3_voltdm_core.volt_data = omap34xx_vddcore_volt_data;
+		omap3_voltdm_mpu.vp_param = &omap34xx_mpu_vp_data;
+		omap3_voltdm_core.vp_param = &omap34xx_core_vp_data;
+		omap3_voltdm_mpu.vc_param = &omap34xx_mpu_vc_data;
+		omap3_voltdm_core.vc_param = &omap34xx_core_vc_data;
 	}
 
 	for (i = 0; voltdm = voltagedomains_omap3[i], voltdm; i++)
diff --git a/arch/arm/mach-omap2/voltagedomains44xx_data.c b/arch/arm/mach-omap2/voltagedomains44xx_data.c
index c4584e9..0a22960 100644
--- a/arch/arm/mach-omap2/voltagedomains44xx_data.c
+++ b/arch/arm/mach-omap2/voltagedomains44xx_data.c
@@ -104,6 +104,14 @@ void __init omap44xx_voltagedomains_init(void)
 	omap4_voltdm_iva.volt_data = omap44xx_vdd_iva_volt_data;
 	omap4_voltdm_core.volt_data = omap44xx_vdd_core_volt_data;
 
+	omap4_voltdm_mpu.vp_param = &omap44xx_mpu_vp_data;
+	omap4_voltdm_iva.vp_param = &omap44xx_iva_vp_data;
+	omap4_voltdm_core.vp_param = &omap44xx_core_vp_data;
+
+	omap4_voltdm_mpu.vc_param = &omap44xx_mpu_vc_data;
+	omap4_voltdm_iva.vc_param = &omap44xx_iva_vc_data;
+	omap4_voltdm_core.vc_param = &omap44xx_core_vc_data;
+
 	for (i = 0; voltdm = voltagedomains_omap4[i], voltdm; i++)
 		voltdm->sys_clk.name = sys_clk_name;
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCHv4 03/15] omap: voltage: add definition for pmic startup / shutdown times
  2011-11-25 15:49 [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support Tero Kristo
  2011-11-25 15:49 ` [PATCHv4 01/15] OMAP3+: PM: VP: use uV for max and min voltage limits Tero Kristo
  2011-11-25 15:49 ` [PATCHv4 02/15] omap3+: voltage: parameter segregation Tero Kristo
@ 2011-11-25 15:49 ` Tero Kristo
  2011-11-25 15:49 ` [PATCHv4 04/15] omap4: add " Tero Kristo
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 43+ messages in thread
From: Tero Kristo @ 2011-11-25 15:49 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, nm

This is applied when PMIC is entering or leaving a sleep mode.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/voltage.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h
index 3afd1fc..01d41d9 100644
--- a/arch/arm/mach-omap2/voltage.h
+++ b/arch/arm/mach-omap2/voltage.h
@@ -136,6 +136,8 @@ struct omap_volt_data {
  * @i2c_slave_addr: I2C slave address of PMIC
  * @volt_reg_addr: voltage configuration register address
  * @cmd_reg_addr: command (on, on-LP, ret, off) configuration register address
+ * @startup_time: PMIC startup time, only valid for core domain
+ * @shutdown_time: PMIC shutdown time, only valid for core domain
  * @i2c_high_speed: whether VC uses I2C high-speed mode to PMIC
  * @i2c_mcode: master code value for I2C high-speed preamble transmission
  * @vsel_to_uv:	PMIC API to convert vsel value to actual voltage in uV.
@@ -153,6 +155,8 @@ struct omap_voltdm_pmic {
 	u8 vp_vstepmax;
 	u32 vp_vddmin;
 	u32 vp_vddmax;
+	u32 startup_time;
+	u32 shutdown_time;
 	u8 vp_timeout_us;
 	bool i2c_high_speed;
 	u8 i2c_mcode;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCHv4 04/15] omap4: add pmic startup / shutdown times
  2011-11-25 15:49 [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support Tero Kristo
                   ` (2 preceding siblings ...)
  2011-11-25 15:49 ` [PATCHv4 03/15] omap: voltage: add definition for pmic startup / shutdown times Tero Kristo
@ 2011-11-25 15:49 ` Tero Kristo
  2011-11-29 18:30   ` Menon, Nishanth
  2011-11-25 15:49 ` [PATCHv4 05/15] omap: add support for oscillator setup Tero Kristo
                   ` (12 subsequent siblings)
  16 siblings, 1 reply; 43+ messages in thread
From: Tero Kristo @ 2011-11-25 15:49 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, nm

Both startup and shutdown take 500us at maximum, value taken from
TWL6030 data manual.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/omap_twl.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c
index 62ed050..bd99328 100644
--- a/arch/arm/mach-omap2/omap_twl.c
+++ b/arch/arm/mach-omap2/omap_twl.c
@@ -207,6 +207,8 @@ static struct omap_voltdm_pmic omap4_iva_pmic = {
 static struct omap_voltdm_pmic omap4_core_pmic = {
 	.slew_rate		= 4000,
 	.step_size		= 12660,
+	.startup_time		= 500,
+	.shutdown_time		= 500,
 	.vp_erroroffset		= OMAP4_VP_CONFIG_ERROROFFSET,
 	.vp_vstepmin		= OMAP4_VP_VSTEPMIN_VSTEPMIN,
 	.vp_vstepmax		= OMAP4_VP_VSTEPMAX_VSTEPMAX,
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCHv4 05/15] omap: add support for oscillator setup
  2011-11-25 15:49 [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support Tero Kristo
                   ` (3 preceding siblings ...)
  2011-11-25 15:49 ` [PATCHv4 04/15] omap4: add " Tero Kristo
@ 2011-11-25 15:49 ` Tero Kristo
  2011-12-09 18:27   ` Kevin Hilman
  2011-11-25 15:49 ` [PATCHv4 06/15] omap3+: vp: use new vp_params for calculating vddmin and vddmax Tero Kristo
                   ` (11 subsequent siblings)
  16 siblings, 1 reply; 43+ messages in thread
From: Tero Kristo @ 2011-11-25 15:49 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, nm

This contains startup and shutdown times for the oscillator. By default
use MAX_INT. Oscillator setup is used for calculating and setting up
latencies for sleep modes that disable oscillator.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/pm.c |   27 +++++++++++++++++++++++++++
 arch/arm/mach-omap2/pm.h |    8 ++++++++
 2 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index d34fc52..b60bae7 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -31,6 +31,21 @@ static struct device *iva_dev;
 static struct device *l3_dev;
 static struct device *dsp_dev;
 
+/**
+ * struct omap2_oscillator - Describe the board main oscillator latencies
+ * @startup_time: oscillator startup latency
+ * @shutdown_time: oscillator shutdown latency
+ */
+struct omap2_oscillator {
+	u32 startup_time;
+	u32 shutdown_time;
+};
+
+static struct omap2_oscillator oscillator = {
+	.startup_time = ULONG_MAX,
+	.shutdown_time = ULONG_MAX,
+};
+
 struct device *omap2_get_mpuss_device(void)
 {
 	WARN_ON_ONCE(!mpu_dev);
@@ -56,6 +71,18 @@ struct device *omap4_get_dsp_device(void)
 }
 EXPORT_SYMBOL(omap4_get_dsp_device);
 
+void omap_pm_setup_oscillator(u32 tstart, u32 tshut)
+{
+	oscillator.startup_time = tstart;
+	oscillator.shutdown_time = tshut;
+}
+
+void omap_pm_get_oscillator(u32 *tstart, u32 *tshut)
+{
+	*tstart = oscillator.startup_time;
+	*tshut = oscillator.shutdown_time;
+}
+
 /* static int _init_omap_device(struct omap_hwmod *oh, void *user) */
 static int _init_omap_device(char *name, struct device **new_dev)
 {
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index 4e166ad..3bdb359 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -134,4 +134,12 @@ static inline int omap4_twl_init(void)
 }
 #endif
 
+#ifdef CONFIG_PM
+extern void omap_pm_setup_oscillator(u32 tstart, u32 tshut);
+extern void omap_pm_get_oscillator(u32 *tstart, u32 *tshut);
+#else
+static inline void omap_pm_setup_oscillator(u32 tstart, u32 tshut) { }
+static inline void omap_pm_get_oscillator(u32 *tstart, u32 *tshut) { }
+#endif
+
 #endif
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCHv4 06/15] omap3+: vp: use new vp_params for calculating vddmin and vddmax
  2011-11-25 15:49 [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support Tero Kristo
                   ` (4 preceding siblings ...)
  2011-11-25 15:49 ` [PATCHv4 05/15] omap: add support for oscillator setup Tero Kristo
@ 2011-11-25 15:49 ` Tero Kristo
  2011-11-29 18:34   ` Menon, Nishanth
  2011-11-25 15:49 ` [PATCHv4 07/15] omap3+: voltage: use oscillator data to calculate setup times Tero Kristo
                   ` (10 subsequent siblings)
  16 siblings, 1 reply; 43+ messages in thread
From: Tero Kristo @ 2011-11-25 15:49 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, nm

Now we select the vddmin and vddmax values based on both pmic and
voltage processor data, this allows usage of different power ICs.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/vp.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c
index 16cb6d4..ffb68d8 100644
--- a/arch/arm/mach-omap2/vp.c
+++ b/arch/arm/mach-omap2/vp.c
@@ -53,8 +53,10 @@ void __init omap_vp_init(struct voltagedomain *voltdm)
 	sys_clk_rate = voltdm->sys_clk.rate / 1000;
 
 	timeout = (sys_clk_rate * voltdm->pmic->vp_timeout_us) / 1000;
-	vddmin = voltdm->pmic->uv_to_vsel(voltdm->pmic->vp_vddmin);
-	vddmax = voltdm->pmic->uv_to_vsel(voltdm->pmic->vp_vddmax);
+	vddmin = max(voltdm->vp_param->vddmin, voltdm->pmic->vp_vddmin);
+	vddmax = min(voltdm->vp_param->vddmax, voltdm->pmic->vp_vddmax);
+	vddmin = voltdm->pmic->uv_to_vsel(vddmin);
+	vddmax = voltdm->pmic->uv_to_vsel(vddmax);
 
 	waittime = ((voltdm->pmic->step_size / voltdm->pmic->slew_rate) *
 		    sys_clk_rate) / 1000;
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCHv4 07/15] omap3+: voltage: use oscillator data to calculate setup times
  2011-11-25 15:49 [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support Tero Kristo
                   ` (5 preceding siblings ...)
  2011-11-25 15:49 ` [PATCHv4 06/15] omap3+: vp: use new vp_params for calculating vddmin and vddmax Tero Kristo
@ 2011-11-25 15:49 ` Tero Kristo
  2011-11-25 15:49 ` [PATCHv4 08/15] omap4: use pmic params for calculating pmic " Tero Kristo
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 43+ messages in thread
From: Tero Kristo @ 2011-11-25 15:49 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, nm

We now use the previously defined oscillator setup / shutdown times
to calculate the register values for CLKSETUP.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/vc.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
index 8384b70..351319c 100644
--- a/arch/arm/mach-omap2/vc.c
+++ b/arch/arm/mach-omap2/vc.c
@@ -13,6 +13,8 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 
+#include <asm/div64.h>
+
 #include <plat/cpu.h>
 #include <plat/prcm.h>
 
@@ -22,6 +24,7 @@
 #include "prm-regbits-44xx.h"
 #include "prm44xx.h"
 #include "scrm44xx.h"
+#include "pm.h"
 
 /**
  * struct omap_vc_channel_cfg - describe the cfg_channel bitfield
@@ -209,11 +212,27 @@ int omap_vc_bypass_scale(struct voltagedomain *voltdm,
 	return 0;
 }
 
+static u32 omap_usec_to_32k(u32 usec)
+{
+	/* DIV_ROUND_UP expanded to 64bit to avoid overflow */
+	u64 val = 32768ULL * (u64)usec + 1000000ULL - 1;
+	do_div(val, 1000000ULL);
+	return val;
+}
+
+static void omap3_set_clksetup(u32 usec, struct voltagedomain *voltdm)
+{
+	voltdm->write(omap_usec_to_32k(usec), OMAP3_PRM_CLKSETUP_OFFSET);
+}
+
 static void omap3_set_i2c_timings(struct voltagedomain *voltdm, int off_mode)
 {
 	unsigned long voltsetup1;
 	u32 tgt_volt;
 
+	/* Oscillator is not shut down if omap is controlling voltages */
+	omap3_set_clksetup(1, voltdm);
+
 	if (off_mode)
 		tgt_volt = voltdm->vc_param->off;
 	else
@@ -241,6 +260,7 @@ static void omap3_set_off_timings(struct voltagedomain *voltdm)
 	unsigned long voltsetup2;
 	unsigned long voltsetup2_old;
 	u32 val;
+	u32 tstart, tshut;
 
 	/* check if pmic is controlling off-mode voltages */
 	val = voltdm->read(OMAP3_PRM_VOLTCTRL_OFFSET);
@@ -250,6 +270,9 @@ static void omap3_set_off_timings(struct voltagedomain *voltdm)
 		return;
 	}
 
+	omap_pm_get_oscillator(&tstart, &tshut);
+	omap3_set_clksetup(tstart, voltdm);
+
 	clksetup = voltdm->read(OMAP3_PRM_CLKSETUP_OFFSET);
 
 	/* voltsetup 2 in us */
@@ -336,10 +359,24 @@ static u32 omap4_calc_volt_ramp(struct voltagedomain *voltdm, u32 voltage_diff,
 		(cycles << OMAP4430_RAMP_UP_COUNT_SHIFT);
 }
 
+static u32 omap4_usec_to_val_scrm(u32 usec, int shift, u32 mask)
+{
+	u32 val;
+
+	val = omap_usec_to_32k(usec) << shift;
+
+	/* Check for overflow, if yes, force to max value */
+	if (val > mask)
+		val = mask;
+
+	return val;
+}
+
 static void omap4_set_timings(struct voltagedomain *voltdm, bool off_mode)
 {
 	u32 val;
 	u32 ramp;
+	u32 tstart, tshut;
 
 	/* configure the setup times */
 	val = voltdm->read(voltdm->vfsm->voltsetup_reg);
@@ -361,6 +398,15 @@ static void omap4_set_timings(struct voltagedomain *voltdm, bool off_mode)
 	val |= ramp << OMAP4430_RAMP_UP_COUNT_SHIFT;
 
 	voltdm->write(val, voltdm->vfsm->voltsetup_reg);
+
+	omap_pm_get_oscillator(&tstart, &tshut);
+
+	val = omap4_usec_to_val_scrm(tstart, OMAP4_SETUPTIME_SHIFT,
+		OMAP4_SETUPTIME_MASK);
+	val |= omap4_usec_to_val_scrm(tshut, OMAP4_DOWNTIME_SHIFT,
+		OMAP4_DOWNTIME_MASK);
+
+	__raw_writel(val, OMAP4_SCRM_CLKSETUPTIME);
 }
 
 /* OMAP4 specific voltage init functions */
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCHv4 08/15] omap4: use pmic params for calculating pmic setup times
  2011-11-25 15:49 [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support Tero Kristo
                   ` (6 preceding siblings ...)
  2011-11-25 15:49 ` [PATCHv4 07/15] omap3+: voltage: use oscillator data to calculate setup times Tero Kristo
@ 2011-11-25 15:49 ` Tero Kristo
  2011-11-25 15:49 ` [PATCHv4 09/15] TEMP: OMAP3: beagle rev-c4: enable OPP6 Tero Kristo
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 43+ messages in thread
From: Tero Kristo @ 2011-11-25 15:49 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, nm

As voltdm->pmic now contains startup and shutdown times for PMIC, use
these for calculating the fields in the PMICSETUPTIME register.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/vc.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
index 351319c..1562aa9 100644
--- a/arch/arm/mach-omap2/vc.c
+++ b/arch/arm/mach-omap2/vc.c
@@ -407,6 +407,17 @@ static void omap4_set_timings(struct voltagedomain *voltdm, bool off_mode)
 		OMAP4_DOWNTIME_MASK);
 
 	__raw_writel(val, OMAP4_SCRM_CLKSETUPTIME);
+
+	tstart = voltdm->pmic->startup_time;
+	tshut = voltdm->pmic->shutdown_time;
+
+	if (tstart && tshut) {
+		val = omap4_usec_to_val_scrm(tstart, OMAP4_WAKEUPTIME_SHIFT,
+			OMAP4_WAKEUPTIME_MASK);
+		val |= omap4_usec_to_val_scrm(tshut, OMAP4_SLEEPTIME_SHIFT,
+			OMAP4_SLEEPTIME_MASK);
+		__raw_writel(val, OMAP4_SCRM_PMICSETUPTIME);
+	}
 }
 
 /* OMAP4 specific voltage init functions */
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCHv4 09/15] TEMP: OMAP3: beagle rev-c4: enable OPP6
  2011-11-25 15:49 [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support Tero Kristo
                   ` (7 preceding siblings ...)
  2011-11-25 15:49 ` [PATCHv4 08/15] omap4: use pmic params for calculating pmic " Tero Kristo
@ 2011-11-25 15:49 ` Tero Kristo
  2011-11-25 15:49 ` [PATCHv4 10/15] omap: beagle: set oscillator startup time to 10ms for rev c4 Tero Kristo
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 43+ messages in thread
From: Tero Kristo @ 2011-11-25 15:49 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, nm

Beagleboard rev-c4 has a speed sorted OMAP3530 chip which can run at 720MHz.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/board-omap3beagle.c |   29 +++++++++++++++++++++++++++++
 arch/arm/mach-omap2/opp3xxx_data.c      |    4 ++++
 2 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 3ae16b4..a7c3d60 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -489,6 +489,35 @@ static void __init beagle_opp_init(void)
 		return;
 	}
 
+	if (omap3_beagle_version == OMAP3BEAGLE_BOARD_C4) {
+		struct device *mpu_dev, *iva_dev;
+
+		mpu_dev = omap2_get_mpuss_device();
+		iva_dev = omap2_get_iva_device();
+
+		if (!mpu_dev || !iva_dev) {
+			pr_err("%s: Aiee.. no mpu/dsp devices? %p %p\n",
+				__func__, mpu_dev, iva_dev);
+			return;
+		}
+		/* Enable MPU 720MHz opp */
+		r = opp_enable(mpu_dev, 720000000);
+
+		/* Enable IVA 520MHz opp */
+		r |= opp_enable(iva_dev, 520000000);
+
+		if (r) {
+			pr_err("%s: failed to enable higher opp %d\n",
+				__func__, r);
+			/*
+			 * Cleanup - disable the higher freqs - we dont care
+			 * about the results
+			 */
+			opp_disable(mpu_dev, 720000000);
+			opp_disable(iva_dev, 520000000);
+		}
+	}
+
 	/* Custom OPP enabled for all xM versions */
 	if (cpu_is_omap3630()) {
 		struct device *mpu_dev, *iva_dev;
diff --git a/arch/arm/mach-omap2/opp3xxx_data.c b/arch/arm/mach-omap2/opp3xxx_data.c
index 1d44df5..2e5bf6b 100644
--- a/arch/arm/mach-omap2/opp3xxx_data.c
+++ b/arch/arm/mach-omap2/opp3xxx_data.c
@@ -150,6 +150,8 @@ static struct omap_opp_def __initdata omap34xx_opp_def_list[] = {
 	OPP_INITIALIZER("mpu", true, 550000000, OMAP3430_VDD_MPU_OPP4_UV),
 	/* MPU OPP5 */
 	OPP_INITIALIZER("mpu", true, 600000000, OMAP3430_VDD_MPU_OPP5_UV),
+	/* MPU OPP6 : omap3530 high speed grade only */
+	OPP_INITIALIZER("mpu", false, 720000000, OMAP3430_VDD_MPU_OPP5_UV),
 
 	/*
 	 * L3 OPP1 - 41.5 MHz is disabled because: The voltage for that OPP is
@@ -175,6 +177,8 @@ static struct omap_opp_def __initdata omap34xx_opp_def_list[] = {
 	OPP_INITIALIZER("iva", true, 400000000, OMAP3430_VDD_MPU_OPP4_UV),
 	/* DSP OPP5 */
 	OPP_INITIALIZER("iva", true, 430000000, OMAP3430_VDD_MPU_OPP5_UV),
+	/* DSP OPP6 : omap3530 high speed grade only */
+	OPP_INITIALIZER("iva", false, 520000000, OMAP3430_VDD_MPU_OPP5_UV),
 };
 
 static struct omap_opp_def __initdata omap36xx_opp_def_list[] = {
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCHv4 10/15] omap: beagle: set oscillator startup time to 10ms for rev c4
  2011-11-25 15:49 [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support Tero Kristo
                   ` (8 preceding siblings ...)
  2011-11-25 15:49 ` [PATCHv4 09/15] TEMP: OMAP3: beagle rev-c4: enable OPP6 Tero Kristo
@ 2011-11-25 15:49 ` Tero Kristo
  2011-12-09 19:11   ` Kevin Hilman
  2011-11-25 15:49 ` [PATCHv4 11/15] omap3+: voltage/pwrdm/clkdm/clock add recursive usecount tracking Tero Kristo
                   ` (6 subsequent siblings)
  16 siblings, 1 reply; 43+ messages in thread
From: Tero Kristo @ 2011-11-25 15:49 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, nm

Based on the oscillator datasheet for this device.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/board-omap3beagle.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index a7c3d60..5e3f575 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -516,6 +516,9 @@ static void __init beagle_opp_init(void)
 			opp_disable(mpu_dev, 720000000);
 			opp_disable(iva_dev, 520000000);
 		}
+
+		/* Setup oscillator startup time to 10ms */
+		omap_pm_setup_oscillator(10000, 0);
 	}
 
 	/* Custom OPP enabled for all xM versions */
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCHv4 11/15] omap3+: voltage/pwrdm/clkdm/clock add recursive usecount tracking
  2011-11-25 15:49 [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support Tero Kristo
                   ` (9 preceding siblings ...)
  2011-11-25 15:49 ` [PATCHv4 10/15] omap: beagle: set oscillator startup time to 10ms for rev c4 Tero Kristo
@ 2011-11-25 15:49 ` Tero Kristo
  2011-11-30  9:52   ` Jean Pihet
  2011-12-09 19:37   ` Kevin Hilman
  2011-11-25 15:49 ` [PATCHv4 12/15] vc: omap3: auto_ret / auto_off support Tero Kristo
                   ` (5 subsequent siblings)
  16 siblings, 2 replies; 43+ messages in thread
From: Tero Kristo @ 2011-11-25 15:49 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, nm

This patch fixes the usecount tracking for omap3+, previously the
usecount numbers were rather bogus and were not really useful for
any purpose. Now usecount numbers track the number of really active
clients on each domain. This patch also adds support for usecount
tracking on powerdomain and voltagedomain levels.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/clkt_iclk.c         |   11 +++++++++
 arch/arm/mach-omap2/clockdomain.c       |   38 +++++++++++++++++++++++++++++-
 arch/arm/mach-omap2/clockdomain.h       |    3 ++
 arch/arm/mach-omap2/powerdomain.c       |   12 +++++++++
 arch/arm/mach-omap2/powerdomain.h       |    5 ++++
 arch/arm/mach-omap2/voltage.c           |   30 ++++++++++++++++++++++++
 arch/arm/mach-omap2/voltage.h           |    7 +++++
 arch/arm/plat-omap/clock.c              |    2 +
 arch/arm/plat-omap/include/plat/clock.h |    1 +
 9 files changed, 107 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/clkt_iclk.c b/arch/arm/mach-omap2/clkt_iclk.c
index 3d43fba..8e61776 100644
--- a/arch/arm/mach-omap2/clkt_iclk.c
+++ b/arch/arm/mach-omap2/clkt_iclk.c
@@ -21,6 +21,7 @@
 #include "clock2xxx.h"
 #include "cm2xxx_3xxx.h"
 #include "cm-regbits-24xx.h"
+#include "clockdomain.h"
 
 /* Private functions */
 
@@ -34,6 +35,11 @@ void omap2_clkt_iclk_allow_idle(struct clk *clk)
 	v = __raw_readl((__force void __iomem *)r);
 	v |= (1 << clk->enable_bit);
 	__raw_writel(v, (__force void __iomem *)r);
+
+	if (clk->usecount && clk->clkdm)
+		clkdm_usecount_dec(clk->clkdm);
+
+	clk->autoidle = 1;
 }
 
 /* XXX */
@@ -46,6 +52,11 @@ void omap2_clkt_iclk_deny_idle(struct clk *clk)
 	v = __raw_readl((__force void __iomem *)r);
 	v &= ~(1 << clk->enable_bit);
 	__raw_writel(v, (__force void __iomem *)r);
+
+	if (clk->usecount && clk->clkdm)
+		clkdm_usecount_inc(clk->clkdm);
+
+	clk->autoidle = 0;
 }
 
 /* Public data */
diff --git a/arch/arm/mach-omap2/clockdomain.c b/arch/arm/mach-omap2/clockdomain.c
index 8480ee4..a14baaf 100644
--- a/arch/arm/mach-omap2/clockdomain.c
+++ b/arch/arm/mach-omap2/clockdomain.c
@@ -906,6 +906,28 @@ bool clkdm_in_hwsup(struct clockdomain *clkdm)
 
 /* Clockdomain-to-clock/hwmod framework interface code */
 
+int clkdm_usecount_inc(struct clockdomain *clkdm)
+{
+	int usecount;
+
+	usecount = atomic_inc_return(&clkdm->usecount);
+
+	if (usecount == 1)
+		pwrdm_clkdm_enable(clkdm->pwrdm.ptr);
+	return usecount;
+}
+
+int clkdm_usecount_dec(struct clockdomain *clkdm)
+{
+	int usecount;
+
+	usecount = atomic_dec_return(&clkdm->usecount);
+
+	if (usecount == 0)
+		pwrdm_clkdm_disable(clkdm->pwrdm.ptr);
+	return usecount;
+}
+
 static int _clkdm_clk_hwmod_enable(struct clockdomain *clkdm)
 {
 	unsigned long flags;
@@ -918,7 +940,10 @@ static int _clkdm_clk_hwmod_enable(struct clockdomain *clkdm)
 	 * should be called for every clock instance or hwmod that is
 	 * enabled, so the clkdm can be force woken up.
 	 */
-	if ((atomic_inc_return(&clkdm->usecount) > 1) && autodeps)
+	if ((clkdm_usecount_inc(clkdm) > 1) && autodeps)
+		return 0;
+
+	if (clkdm->flags & CLKDM_NO_MANUAL_TRANSITIONS)
 		return 0;
 
 	spin_lock_irqsave(&clkdm->lock, flags);
@@ -944,7 +969,10 @@ static int _clkdm_clk_hwmod_disable(struct clockdomain *clkdm)
 		return -ERANGE;
 	}
 
-	if (atomic_dec_return(&clkdm->usecount) > 0)
+	if (clkdm_usecount_dec(clkdm) > 0)
+		return 0;
+
+	if (clkdm->flags & CLKDM_NO_MANUAL_TRANSITIONS)
 		return 0;
 
 	spin_lock_irqsave(&clkdm->lock, flags);
@@ -981,6 +1009,9 @@ int clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk)
 	if (!clk)
 		return -EINVAL;
 
+	if (clk->autoidle)
+		return 0;
+
 	return _clkdm_clk_hwmod_enable(clkdm);
 }
 
@@ -1007,6 +1038,9 @@ int clkdm_clk_disable(struct clockdomain *clkdm, struct clk *clk)
 	if (!clk)
 		return -EINVAL;
 
+	if (clk->autoidle)
+		return 0;
+
 	return _clkdm_clk_hwmod_disable(clkdm);
 }
 
diff --git a/arch/arm/mach-omap2/clockdomain.h b/arch/arm/mach-omap2/clockdomain.h
index f7b5860..38321cd 100644
--- a/arch/arm/mach-omap2/clockdomain.h
+++ b/arch/arm/mach-omap2/clockdomain.h
@@ -37,6 +37,7 @@
 #define CLKDM_CAN_ENABLE_AUTO			(1 << 2)
 #define CLKDM_CAN_DISABLE_AUTO			(1 << 3)
 #define CLKDM_NO_AUTODEPS			(1 << 4)
+#define CLKDM_NO_MANUAL_TRANSITIONS		(1 << 5)
 
 #define CLKDM_CAN_HWSUP		(CLKDM_CAN_ENABLE_AUTO | CLKDM_CAN_DISABLE_AUTO)
 #define CLKDM_CAN_SWSUP		(CLKDM_CAN_FORCE_SLEEP | CLKDM_CAN_FORCE_WAKEUP)
@@ -191,6 +192,8 @@ int clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk);
 int clkdm_clk_disable(struct clockdomain *clkdm, struct clk *clk);
 int clkdm_hwmod_enable(struct clockdomain *clkdm, struct omap_hwmod *oh);
 int clkdm_hwmod_disable(struct clockdomain *clkdm, struct omap_hwmod *oh);
+int clkdm_usecount_inc(struct clockdomain *clkdm);
+int clkdm_usecount_dec(struct clockdomain *clkdm);
 
 extern void __init omap242x_clockdomains_init(void);
 extern void __init omap243x_clockdomains_init(void);
diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
index 5164d58..010d274 100644
--- a/arch/arm/mach-omap2/powerdomain.c
+++ b/arch/arm/mach-omap2/powerdomain.c
@@ -985,6 +985,18 @@ int pwrdm_clkdm_state_switch(struct clockdomain *clkdm)
 	return -EINVAL;
 }
 
+void pwrdm_clkdm_enable(struct powerdomain *pwrdm)
+{
+	if (atomic_inc_return(&pwrdm->usecount) == 1)
+		voltdm_pwrdm_enable(pwrdm->voltdm.ptr);
+}
+
+void pwrdm_clkdm_disable(struct powerdomain *pwrdm)
+{
+	if (!atomic_dec_return(&pwrdm->usecount))
+		voltdm_pwrdm_disable(pwrdm->voltdm.ptr);
+}
+
 int pwrdm_pre_transition(void)
 {
 	pwrdm_for_each(_pwrdm_pre_transition_cb, NULL);
diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h
index 42e6dd8..8623e87 100644
--- a/arch/arm/mach-omap2/powerdomain.h
+++ b/arch/arm/mach-omap2/powerdomain.h
@@ -120,6 +120,7 @@ struct powerdomain {
 	unsigned state_counter[PWRDM_MAX_PWRSTS];
 	unsigned ret_logic_off_counter;
 	unsigned ret_mem_off_counter[PWRDM_MAX_MEM_BANKS];
+	atomic_t usecount;
 
 #ifdef CONFIG_PM_DEBUG
 	s64 timer;
@@ -216,6 +217,10 @@ int pwrdm_state_switch(struct powerdomain *pwrdm);
 int pwrdm_clkdm_state_switch(struct clockdomain *clkdm);
 int pwrdm_pre_transition(void);
 int pwrdm_post_transition(void);
+
+void pwrdm_clkdm_enable(struct powerdomain *pwrdm);
+void pwrdm_clkdm_disable(struct powerdomain *pwrdm);
+
 int pwrdm_set_lowpwrstchange(struct powerdomain *pwrdm);
 u32 pwrdm_get_context_loss_count(struct powerdomain *pwrdm);
 bool pwrdm_can_ever_lose_context(struct powerdomain *pwrdm);
diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c
index 64070ac..2232e7a 100644
--- a/arch/arm/mach-omap2/voltage.c
+++ b/arch/arm/mach-omap2/voltage.c
@@ -37,6 +37,7 @@
 
 #include "voltage.h"
 #include "powerdomain.h"
+#include "smartreflex.h"
 
 #include "vc.h"
 #include "vp.h"
@@ -323,6 +324,35 @@ int voltdm_add_pwrdm(struct voltagedomain *voltdm, struct powerdomain *pwrdm)
 	return 0;
 }
 
+void voltdm_pwrdm_enable(struct voltagedomain *voltdm)
+{
+	if (atomic_inc_return(&voltdm->usecount) == 1) {
+		if (voltdm->wakeup)
+			voltdm->wakeup(voltdm);
+		omap_sr_enable(voltdm);
+	}
+}
+
+void voltdm_pwrdm_disable(struct voltagedomain *voltdm)
+{
+	int target_state = -EINVAL;
+	int state;
+	struct powerdomain *pwrdm;
+
+	if (!atomic_dec_return(&voltdm->usecount)) {
+		omap_sr_disable(voltdm);
+		/* Determine target state for voltdm */
+		list_for_each_entry(pwrdm, &voltdm->pwrdm_list, voltdm_node) {
+			state = pwrdm_read_next_pwrst(pwrdm);
+			if (state > target_state)
+				target_state = state;
+		}
+		voltdm->target_state = target_state;
+		if (voltdm->sleep)
+			voltdm->sleep(voltdm);
+	}
+}
+
 /**
  * voltdm_for_each_pwrdm - call function for each pwrdm in a voltdm
  * @voltdm: struct voltagedomain * to iterate over
diff --git a/arch/arm/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h
index 01d41d9..1a07b76 100644
--- a/arch/arm/mach-omap2/voltage.h
+++ b/arch/arm/mach-omap2/voltage.h
@@ -75,6 +75,9 @@ struct voltagedomain {
 	struct omap_vp_param *vp_param;
 	struct omap_vc_param *vc_param;
 
+	atomic_t usecount;
+	int target_state;
+
 	/* VC/VP register access functions: SoC specific */
 	u32 (*read) (u8 offset);
 	void (*write) (u32 val, u8 offset);
@@ -85,6 +88,8 @@ struct voltagedomain {
 		u32 rate;
 	} sys_clk;
 
+	void (*sleep) (struct voltagedomain *voltdm);
+	void (*wakeup) (struct voltagedomain *voltdm);
 	int (*scale) (struct voltagedomain *voltdm,
 		      unsigned long target_volt);
 
@@ -193,6 +198,8 @@ extern void omap44xx_voltagedomains_init(void);
 struct voltagedomain *voltdm_lookup(const char *name);
 void voltdm_init(struct voltagedomain **voltdm_list);
 int voltdm_add_pwrdm(struct voltagedomain *voltdm, struct powerdomain *pwrdm);
+void voltdm_pwrdm_enable(struct voltagedomain *voltdm);
+void voltdm_pwrdm_disable(struct voltagedomain *voltdm);
 int voltdm_for_each(int (*fn)(struct voltagedomain *voltdm, void *user),
 		    void *user);
 int voltdm_for_each_pwrdm(struct voltagedomain *voltdm,
diff --git a/arch/arm/plat-omap/clock.c b/arch/arm/plat-omap/clock.c
index 3ba4d11..7267818 100644
--- a/arch/arm/plat-omap/clock.c
+++ b/arch/arm/plat-omap/clock.c
@@ -282,6 +282,8 @@ int clk_register(struct clk *clk)
 		list_add(&clk->sibling, &root_clks);
 
 	list_add(&clk->node, &clocks);
+	if (clk->ops == &clkops_null)
+		clk->autoidle = 1;
 	if (clk->init)
 		clk->init(clk);
 	mutex_unlock(&clocks_mutex);
diff --git a/arch/arm/plat-omap/include/plat/clock.h b/arch/arm/plat-omap/include/plat/clock.h
index df4b968..f18dd5f 100644
--- a/arch/arm/plat-omap/include/plat/clock.h
+++ b/arch/arm/plat-omap/include/plat/clock.h
@@ -254,6 +254,7 @@ struct clk {
 	void			(*init)(struct clk *);
 	u8			enable_bit;
 	s8			usecount;
+	u8			autoidle;
 	u8			fixed_div;
 	u8			flags;
 #ifdef CONFIG_ARCH_OMAP2PLUS
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCHv4 12/15] vc: omap3: auto_ret / auto_off support
  2011-11-25 15:49 [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support Tero Kristo
                   ` (10 preceding siblings ...)
  2011-11-25 15:49 ` [PATCHv4 11/15] omap3+: voltage/pwrdm/clkdm/clock add recursive usecount tracking Tero Kristo
@ 2011-11-25 15:49 ` Tero Kristo
  2011-12-09 20:13   ` Kevin Hilman
  2011-11-25 15:49 ` [PATCHv4 13/15] omap3: fix usecount tracking Tero Kristo
                   ` (4 subsequent siblings)
  16 siblings, 1 reply; 43+ messages in thread
From: Tero Kristo @ 2011-11-25 15:49 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, nm

Voltage code will now enable / disable auto_ret / auto_off dynamically
according to the voltagedomain usecounts. This is accomplished via
the usage of the voltdm callback functions for sleep / wakeup.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/vc.c |   91 ++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 75 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
index 1562aa9..ec74c68 100644
--- a/arch/arm/mach-omap2/vc.c
+++ b/arch/arm/mach-omap2/vc.c
@@ -12,6 +12,7 @@
 #include <linux/init.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/string.h>
 
 #include <asm/div64.h>
 
@@ -230,9 +231,6 @@ static void omap3_set_i2c_timings(struct voltagedomain *voltdm, int off_mode)
 	unsigned long voltsetup1;
 	u32 tgt_volt;
 
-	/* Oscillator is not shut down if omap is controlling voltages */
-	omap3_set_clksetup(1, voltdm);
-
 	if (off_mode)
 		tgt_volt = voltdm->vc_param->off;
 	else
@@ -246,12 +244,6 @@ static void omap3_set_i2c_timings(struct voltagedomain *voltdm, int off_mode)
 	voltdm->rmw(voltdm->vfsm->voltsetup_mask,
 		voltsetup1 << __ffs(voltdm->vfsm->voltsetup_mask),
 		voltdm->vfsm->voltsetup_reg);
-
-	/*
-	 * pmic is not controlling the voltage scaling during retention,
-	 * thus set voltsetup2 to 0
-	 */
-	voltdm->write(0, OMAP3_PRM_VOLTSETUP2_OFFSET);
 }
 
 static void omap3_set_off_timings(struct voltagedomain *voltdm)
@@ -260,7 +252,6 @@ static void omap3_set_off_timings(struct voltagedomain *voltdm)
 	unsigned long voltsetup2;
 	unsigned long voltsetup2_old;
 	u32 val;
-	u32 tstart, tshut;
 
 	/* check if pmic is controlling off-mode voltages */
 	val = voltdm->read(OMAP3_PRM_VOLTCTRL_OFFSET);
@@ -270,9 +261,6 @@ static void omap3_set_off_timings(struct voltagedomain *voltdm)
 		return;
 	}
 
-	omap_pm_get_oscillator(&tstart, &tshut);
-	omap3_set_clksetup(tstart, voltdm);
-
 	clksetup = voltdm->read(OMAP3_PRM_CLKSETUP_OFFSET);
 
 	/* voltsetup 2 in us */
@@ -302,16 +290,87 @@ static void omap3_set_off_timings(struct voltagedomain *voltdm)
 	 */
 	voltdm->rmw(voltdm->vfsm->voltsetup_mask, 0,
 		voltdm->vfsm->voltsetup_reg);
+}
 
-	/* voltoffset must be clksetup minus voltsetup2 according to TRM */
-	voltdm->write(clksetup - voltsetup2, OMAP3_PRM_VOLTOFFSET_OFFSET);
+static void omap3_set_core_ret_timings(struct voltagedomain *voltdm)
+{
+	omap3_set_clksetup(1, voltdm);
+
+	/*
+	 * Reset voltsetup 2 and voltoffset when entering retention
+	 * as they are only used when pmic is controlling voltages
+	 */
+	voltdm->write(0, OMAP3_PRM_VOLTSETUP2_OFFSET);
+	voltdm->write(0, OMAP3_PRM_VOLTOFFSET_OFFSET);
+	omap3_set_i2c_timings(voltdm, 0);
 }
 
-static void __init omap3_vc_init_channel(struct voltagedomain *voltdm)
+static void omap3_set_core_off_timings(struct voltagedomain *voltdm)
 {
+	u32 tstart, tshut;
+	omap_pm_get_oscillator(&tstart, &tshut);
+	omap3_set_clksetup(tstart, voltdm);
 	omap3_set_off_timings(voltdm);
 }
 
+static void omap3_vc_channel_sleep(struct voltagedomain *voltdm)
+{
+	/* Set off timings if entering off */
+	if (voltdm->target_state == PWRDM_POWER_OFF)
+		omap3_set_off_timings(voltdm);
+	else
+		omap3_set_i2c_timings(voltdm, 0);
+}
+
+static void omap3_vc_channel_wakeup(struct voltagedomain *voltdm)
+{
+}
+
+static void omap3_vc_core_sleep(struct voltagedomain *voltdm)
+{
+	u8 mode;
+
+	switch (voltdm->target_state) {
+	case PWRDM_POWER_OFF:
+		mode = OMAP3430_AUTO_OFF_MASK;
+		break;
+	case PWRDM_POWER_RET:
+		mode = OMAP3430_AUTO_RET_MASK;
+		break;
+	default:
+		mode = OMAP3430_AUTO_SLEEP_MASK;
+		break;
+	}
+
+	if (mode & OMAP3430_AUTO_OFF_MASK)
+		omap3_set_core_off_timings(voltdm);
+	else
+		omap3_set_core_ret_timings(voltdm);
+
+	voltdm->rmw(OMAP3430_AUTO_OFF_MASK | OMAP3430_AUTO_RET_MASK |
+		    OMAP3430_AUTO_SLEEP_MASK, mode,
+		    OMAP3_PRM_VOLTCTRL_OFFSET);
+}
+
+static void omap3_vc_core_wakeup(struct voltagedomain *voltdm)
+{
+	voltdm->rmw(OMAP3430_AUTO_OFF_MASK | OMAP3430_AUTO_RET_MASK |
+		    OMAP3430_AUTO_SLEEP_MASK, 0, OMAP3_PRM_VOLTCTRL_OFFSET);
+}
+
+static void __init omap3_vc_init_channel(struct voltagedomain *voltdm)
+{
+	if (!strcmp(voltdm->name, "core")) {
+		voltdm->sleep = omap3_vc_core_sleep;
+		voltdm->wakeup = omap3_vc_core_wakeup;
+		omap3_set_core_ret_timings(voltdm);
+	} else {
+		voltdm->sleep = omap3_vc_channel_sleep;
+		voltdm->wakeup = omap3_vc_channel_wakeup;
+		omap3_set_i2c_timings(voltdm, 0);
+	}
+}
+
 static u32 omap4_calc_volt_ramp(struct voltagedomain *voltdm, u32 voltage_diff,
 		u32 clk_rate)
 {
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCHv4 13/15] omap3: fix usecount tracking
  2011-11-25 15:49 [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support Tero Kristo
                   ` (11 preceding siblings ...)
  2011-11-25 15:49 ` [PATCHv4 12/15] vc: omap3: auto_ret / auto_off support Tero Kristo
@ 2011-11-25 15:49 ` Tero Kristo
  2011-11-25 15:49 ` [PATCHv4 14/15] omap3: voltage: fix channel configuration Tero Kristo
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 43+ messages in thread
From: Tero Kristo @ 2011-11-25 15:49 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, nm

Some of the clocks are marked as autoidle, as they are handled by hardware.
Namely, core and per dplls are marked as such, and also sdrc_ick.

Per clkdomain manual transitions are also disabled, as this does not work,
and attempting to do so causes problems.

mpu_iva voltdm usecounts are also now handled within idle loop to allow
mpu_iva domain to transition smoothly.

After this patch, usecount numbers for core, per and mpu_iva domains
reach zero when domain is ready to idle (i.e. just before wfi.)

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/clock3xxx_data.c        |    3 +++
 arch/arm/mach-omap2/clockdomains3xxx_data.c |    2 +-
 arch/arm/mach-omap2/pm34xx.c                |    8 ++++++++
 3 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/clock3xxx_data.c b/arch/arm/mach-omap2/clock3xxx_data.c
index dadb8c6..76c2a28 100644
--- a/arch/arm/mach-omap2/clock3xxx_data.c
+++ b/arch/arm/mach-omap2/clock3xxx_data.c
@@ -432,6 +432,7 @@ static struct clk dpll3_ck = {
 	.round_rate	= &omap2_dpll_round_rate,
 	.clkdm_name	= "dpll3_clkdm",
 	.recalc		= &omap3_dpll_recalc,
+	.autoidle	= 1,
 };
 
 /*
@@ -615,6 +616,7 @@ static struct clk dpll4_ck = {
 	.set_rate	= &omap3_dpll4_set_rate,
 	.clkdm_name	= "dpll4_clkdm",
 	.recalc		= &omap3_dpll_recalc,
+	.autoidle	= 1,
 };
 
 /*
@@ -1744,6 +1746,7 @@ static struct clk sdrc_ick = {
 	.flags		= ENABLE_ON_INIT,
 	.clkdm_name	= "core_l3_clkdm",
 	.recalc		= &followparent_recalc,
+	.autoidle	= 1,
 };
 
 static struct clk gpmc_fck = {
diff --git a/arch/arm/mach-omap2/clockdomains3xxx_data.c b/arch/arm/mach-omap2/clockdomains3xxx_data.c
index b84e138..d0cbeb4 100644
--- a/arch/arm/mach-omap2/clockdomains3xxx_data.c
+++ b/arch/arm/mach-omap2/clockdomains3xxx_data.c
@@ -282,7 +282,7 @@ static struct clockdomain usbhost_clkdm = {
 static struct clockdomain per_clkdm = {
 	.name		= "per_clkdm",
 	.pwrdm		= { .name = "per_pwrdm" },
-	.flags		= CLKDM_CAN_HWSUP_SWSUP,
+	.flags		= CLKDM_CAN_HWSUP_SWSUP | CLKDM_NO_MANUAL_TRANSITIONS,
 	.dep_bit	= OMAP3430_EN_PER_SHIFT,
 	.wkdep_srcs	= per_wkdeps,
 	.sleepdep_srcs	= per_sleepdeps,
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 7255d9b..dc0d040 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -84,6 +84,7 @@ void (*omap3_do_wfi_sram)(void);
 static struct powerdomain *mpu_pwrdm, *neon_pwrdm;
 static struct powerdomain *core_pwrdm, *per_pwrdm;
 static struct powerdomain *cam_pwrdm;
+static struct voltagedomain *mpu_iva_voltdm;
 
 static inline void omap3_per_save_context(void)
 {
@@ -365,6 +366,8 @@ void omap_sram_idle(void)
 	}
 	pwrdm_pre_transition();
 
+	voltdm_pwrdm_disable(mpu_iva_voltdm);
+
 	/* NEON control */
 	if (pwrdm_read_pwrst(neon_pwrdm) == PWRDM_POWER_ON)
 		pwrdm_set_next_pwrst(neon_pwrdm, mpu_next_state);
@@ -478,6 +481,8 @@ console_still_active:
 		omap3_disable_io_chain();
 	}
 
+	voltdm_pwrdm_enable(mpu_iva_voltdm);
+
 	pwrdm_post_transition();
 
 	clkdm_allow_idle(mpu_pwrdm->pwrdm_clkdms[0]);
@@ -893,6 +898,9 @@ static int __init omap3_pm_init(void)
 
 	(void) clkdm_for_each(clkdms_setup, NULL);
 
+	mpu_iva_voltdm = voltdm_lookup("mpu_iva");
+	voltdm_pwrdm_enable(mpu_iva_voltdm);
+
 	mpu_pwrdm = pwrdm_lookup("mpu_pwrdm");
 	if (mpu_pwrdm == NULL) {
 		printk(KERN_ERR "Failed to get mpu_pwrdm\n");
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCHv4 14/15] omap3: voltage: fix channel configuration
  2011-11-25 15:49 [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support Tero Kristo
                   ` (12 preceding siblings ...)
  2011-11-25 15:49 ` [PATCHv4 13/15] omap3: fix usecount tracking Tero Kristo
@ 2011-11-25 15:49 ` Tero Kristo
  2011-11-25 15:49 ` [PATCHv4 15/15] omap: pm: wait for domain wakeup if changing state of idle domain Tero Kristo
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 43+ messages in thread
From: Tero Kristo @ 2011-11-25 15:49 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, nm

OMAP3 uses the default settings for VDD1 channel, otherwise the settings will
overlap with VDD2 and attempting to modify VDD1 voltage will actually change
VDD2 voltage.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/vc.c          |    5 ++++-
 arch/arm/mach-omap2/vc3xxx_data.c |    1 +
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
index ec74c68..94fda64 100644
--- a/arch/arm/mach-omap2/vc.c
+++ b/arch/arm/mach-omap2/vc.c
@@ -581,9 +581,12 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm)
 		voltdm->rmw(vc->smps_cmdra_mask,
 			    vc->cmd_reg_addr << __ffs(vc->smps_cmdra_mask),
 			    vc->smps_cmdra_reg);
-		vc->cfg_channel |= vc_cfg_bits->rac | vc_cfg_bits->racen;
+		vc->cfg_channel |= vc_cfg_bits->rac;
 	}
 
+	if (vc->cmd_reg_addr == vc->volt_reg_addr)
+		vc->cfg_channel |= vc_cfg_bits->racen;
+
 	/* Set up the on, inactive, retention and off voltage */
 	on_vsel = voltdm->pmic->uv_to_vsel(voltdm->vc_param->on);
 	onlp_vsel = voltdm->pmic->uv_to_vsel(voltdm->vc_param->onlp);
diff --git a/arch/arm/mach-omap2/vc3xxx_data.c b/arch/arm/mach-omap2/vc3xxx_data.c
index cfe348e..0136ad5 100644
--- a/arch/arm/mach-omap2/vc3xxx_data.c
+++ b/arch/arm/mach-omap2/vc3xxx_data.c
@@ -46,6 +46,7 @@ static struct omap_vc_common omap3_vc_common = {
 };
 
 struct omap_vc_channel omap3_vc_mpu = {
+	.flags = OMAP_VC_CHANNEL_DEFAULT,
 	.common = &omap3_vc_common,
 	.smps_sa_reg	 = OMAP3_PRM_VC_SMPS_SA_OFFSET,
 	.smps_volra_reg	 = OMAP3_PRM_VC_SMPS_VOL_RA_OFFSET,
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCHv4 15/15] omap: pm: wait for domain wakeup if changing state of idle domain
  2011-11-25 15:49 [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support Tero Kristo
                   ` (13 preceding siblings ...)
  2011-11-25 15:49 ` [PATCHv4 14/15] omap3: voltage: fix channel configuration Tero Kristo
@ 2011-11-25 15:49 ` Tero Kristo
  2011-11-30 10:06 ` [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support Jean Pihet
  2011-12-09 20:23 ` Kevin Hilman
  16 siblings, 0 replies; 43+ messages in thread
From: Tero Kristo @ 2011-11-25 15:49 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, nm

If we are switching the state of an idle powerdomain, we must wait for
the wakeup to complete before attempting to switch to the new state,
otherwise the powerdomain may not be ready for the switch and will fail.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/pm.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index b60bae7..c853f39 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -157,6 +157,7 @@ int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state)
 		} else {
 			hwsup = clkdm_in_hwsup(pwrdm->pwrdm_clkdms[0]);
 			clkdm_wakeup(pwrdm->pwrdm_clkdms[0]);
+			pwrdm_wait_transition(pwrdm);
 			sleep_switch = FORCEWAKEUP_SWITCH;
 		}
 	}
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 02/15] omap3+: voltage: parameter segregation
  2011-11-25 15:49 ` [PATCHv4 02/15] omap3+: voltage: parameter segregation Tero Kristo
@ 2011-11-29 18:26   ` Menon, Nishanth
  2011-11-30 10:07     ` Tero Kristo
  2011-11-30 10:11   ` Jean Pihet
  1 sibling, 1 reply; 43+ messages in thread
From: Menon, Nishanth @ 2011-11-29 18:26 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap, khilman

On Fri, Nov 25, 2011 at 09:49, Tero Kristo <t-kristo@ti.com> wrote:
>
> Introduced two new voltage domain specific parameter structures,
> omap_vp_param and omap_vc_param. These are used to describe the minimum
> and maximum voltages for the voltagedomains, and also the sleep voltage
> levels. Existing voltage levels are also moved into these new structures,
> and the voltage domain code is changed to use these.
>
> Signed-off-by: Tero Kristo <t-kristo@ti.com>
> ---
>  arch/arm/mach-omap2/omap_opp_data.h           |   15 ++
>  arch/arm/mach-omap2/omap_twl.c                |   25 ----
>  arch/arm/mach-omap2/opp3xxx_data.c            |   52 +++++++
>  arch/arm/mach-omap2/opp4xxx_data.c            |   40 ++++++
>  arch/arm/mach-omap2/vc.c                      |  178 +++++++++++++++++++++----
>  arch/arm/mach-omap2/vc.h                      |    1 -
>  arch/arm/mach-omap2/voltage.h                 |   18 ++-
>  arch/arm/mach-omap2/voltagedomains3xxx_data.c |    8 +
>  arch/arm/mach-omap2/voltagedomains44xx_data.c |    8 +
>  9 files changed, 289 insertions(+), 56 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/omap_opp_data.h b/arch/arm/mach-omap2/omap_opp_data.h
> index c784c12..b5fe711 100644
> --- a/arch/arm/mach-omap2/omap_opp_data.h
> +++ b/arch/arm/mach-omap2/omap_opp_data.h
> @@ -86,11 +86,26 @@ extern int __init omap_init_opp_table(struct omap_opp_def *opp_def,
>
>  extern struct omap_volt_data omap34xx_vddmpu_volt_data[];
>  extern struct omap_volt_data omap34xx_vddcore_volt_data[];
> +extern struct omap_vp_param omap34xx_mpu_vp_data;
> +extern struct omap_vp_param omap34xx_core_vp_data;
> +extern struct omap_vc_param omap34xx_mpu_vc_data;
> +extern struct omap_vc_param omap34xx_core_vc_data;
> +
>  extern struct omap_volt_data omap36xx_vddmpu_volt_data[];
>  extern struct omap_volt_data omap36xx_vddcore_volt_data[];
> +extern struct omap_vp_param omap36xx_mpu_vp_data;
> +extern struct omap_vp_param omap36xx_core_vp_data;
> +extern struct omap_vc_param omap36xx_mpu_vc_data;
> +extern struct omap_vc_param omap36xx_core_vc_data;
>
>  extern struct omap_volt_data omap44xx_vdd_mpu_volt_data[];
>  extern struct omap_volt_data omap44xx_vdd_iva_volt_data[];
>  extern struct omap_volt_data omap44xx_vdd_core_volt_data[];
> +extern struct omap_vp_param omap44xx_mpu_vp_data;
> +extern struct omap_vp_param omap44xx_iva_vp_data;
> +extern struct omap_vp_param omap44xx_core_vp_data;
> +extern struct omap_vc_param omap44xx_mpu_vc_data;
> +extern struct omap_vc_param omap44xx_iva_vc_data;
> +extern struct omap_vc_param omap44xx_core_vc_data;
>
>  #endif         /* __ARCH_ARM_MACH_OMAP2_OMAP_OPP_DATA_H */
> diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c
> index df4e7c3..62ed050 100644
> --- a/arch/arm/mach-omap2/omap_twl.c
> +++ b/arch/arm/mach-omap2/omap_twl.c
> @@ -141,11 +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,
>        .vp_vstepmax            = OMAP3_VP_VSTEPMAX_VSTEPMAX,
> @@ -162,11 +157,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,
>        .vp_vstepmax            = OMAP3_VP_VSTEPMAX_VSTEPMAX,
> @@ -183,11 +173,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,
>        .vp_vstepmax            = OMAP4_VP_VSTEPMAX_VSTEPMAX,
> @@ -205,11 +190,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,
>        .vp_vstepmax            = OMAP4_VP_VSTEPMAX_VSTEPMAX,
> @@ -227,11 +207,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,
>        .vp_vstepmax            = OMAP4_VP_VSTEPMAX_VSTEPMAX,
> diff --git a/arch/arm/mach-omap2/opp3xxx_data.c b/arch/arm/mach-omap2/opp3xxx_data.c
> index d95f3f9..1d44df5 100644
> --- a/arch/arm/mach-omap2/opp3xxx_data.c
> +++ b/arch/arm/mach-omap2/opp3xxx_data.c
> @@ -26,6 +26,10 @@
>  #include "pm.h"
>
>  /* 34xx */
> +#define OMAP3_ON_VOLTAGE_UV            1200000
> +#define OMAP3_ONLP_VOLTAGE_UV          1000000
> +#define OMAP3_RET_VOLTAGE_UV           975000
> +#define OMAP3_OFF_VOLTAGE_UV           600000

this approach has a problem -> ON, ONLP and RET voltage should consider:
a) OMAP capabiltiy as above.
b) PMIC capability which is being removed in this patch

the framework should use the combination of both to make a decision.


>
>  /* VDD1 */
>
> @@ -44,6 +48,18 @@ struct omap_volt_data omap34xx_vddmpu_volt_data[] = {
>        VOLT_DATA_DEFINE(0, 0, 0, 0),
>  };
>
> +struct omap_vp_param omap34xx_mpu_vp_data = {
> +       .vddmin                 = OMAP3430_VP1_VLIMITTO_VDDMIN,
> +       .vddmax                 = OMAP3430_VP1_VLIMITTO_VDDMAX,
> +};
> +
> +struct omap_vc_param omap34xx_mpu_vc_data = {
> +       .on             = OMAP3_ON_VOLTAGE_UV,
> +       .onlp           = OMAP3_ONLP_VOLTAGE_UV,
> +       .ret            = OMAP3_RET_VOLTAGE_UV,
> +       .off            = OMAP3_OFF_VOLTAGE_UV,
> +};
> +
>  /* VDD2 */
>
>  #define OMAP3430_VDD_CORE_OPP1_UV              975000
> @@ -57,6 +73,18 @@ struct omap_volt_data omap34xx_vddcore_volt_data[] = {
>        VOLT_DATA_DEFINE(0, 0, 0, 0),
>  };
>
> +struct omap_vp_param omap34xx_core_vp_data = {
> +       .vddmin                 = OMAP3430_VP2_VLIMITTO_VDDMIN,
> +       .vddmax                 = OMAP3430_VP2_VLIMITTO_VDDMAX,
> +};
> +
> +struct omap_vc_param omap34xx_core_vc_data = {
> +       .on             = OMAP3_ON_VOLTAGE_UV,
> +       .onlp           = OMAP3_ONLP_VOLTAGE_UV,
> +       .ret            = OMAP3_RET_VOLTAGE_UV,
> +       .off            = OMAP3_OFF_VOLTAGE_UV,
> +};
> +
>  /* 36xx */
>
>  /* VDD1 */
> @@ -74,6 +102,18 @@ struct omap_volt_data omap36xx_vddmpu_volt_data[] = {
>        VOLT_DATA_DEFINE(0, 0, 0, 0),
>  };
>
> +struct omap_vp_param omap36xx_mpu_vp_data = {
> +       .vddmin                 = OMAP3630_VP1_VLIMITTO_VDDMIN,
> +       .vddmax                 = OMAP3630_VP1_VLIMITTO_VDDMAX,
> +};
> +
> +struct omap_vc_param omap36xx_mpu_vc_data = {
> +       .on             = OMAP3_ON_VOLTAGE_UV,
> +       .onlp           = OMAP3_ONLP_VOLTAGE_UV,
> +       .ret            = OMAP3_RET_VOLTAGE_UV,
> +       .off            = OMAP3_OFF_VOLTAGE_UV,
> +};
> +
>  /* VDD2 */
>
>  #define OMAP3630_VDD_CORE_OPP50_UV             1000000
> @@ -85,6 +125,18 @@ struct omap_volt_data omap36xx_vddcore_volt_data[] = {
>        VOLT_DATA_DEFINE(0, 0, 0, 0),
>  };
>
> +struct omap_vp_param omap36xx_core_vp_data = {
> +       .vddmin                 = OMAP3630_VP2_VLIMITTO_VDDMIN,
> +       .vddmax                 = OMAP3630_VP2_VLIMITTO_VDDMAX,
> +};
> +
> +struct omap_vc_param omap36xx_core_vc_data = {
> +       .on             = OMAP3_ON_VOLTAGE_UV,
> +       .onlp           = OMAP3_ONLP_VOLTAGE_UV,
> +       .ret            = OMAP3_RET_VOLTAGE_UV,
> +       .off            = OMAP3_OFF_VOLTAGE_UV,
> +};
> +
>  /* OPP data */
>
>  static struct omap_opp_def __initdata omap34xx_opp_def_list[] = {
> diff --git a/arch/arm/mach-omap2/opp4xxx_data.c b/arch/arm/mach-omap2/opp4xxx_data.c
> index 2293ba2..dc405b6 100644
> --- a/arch/arm/mach-omap2/opp4xxx_data.c
> +++ b/arch/arm/mach-omap2/opp4xxx_data.c
> @@ -31,6 +31,11 @@
>  * voltage dependent data for each VDD.
>  */
>
> +#define OMAP4_ON_VOLTAGE_UV                    1375000
> +#define OMAP4_ONLP_VOLTAGE_UV                  1375000
> +#define OMAP4_RET_VOLTAGE_UV                   837500
> +#define OMAP4_OFF_VOLTAGE_UV                   600000
> +
>  #define OMAP4430_VDD_MPU_OPP50_UV              1025000
>  #define OMAP4430_VDD_MPU_OPP100_UV             1200000
>  #define OMAP4430_VDD_MPU_OPPTURBO_UV           1313000
> @@ -44,6 +49,18 @@ struct omap_volt_data omap44xx_vdd_mpu_volt_data[] = {
>        VOLT_DATA_DEFINE(0, 0, 0, 0),
>  };
>
> +struct omap_vp_param omap44xx_mpu_vp_data = {
> +       .vddmin                 = OMAP4_VP_MPU_VLIMITTO_VDDMIN,
> +       .vddmax                 = OMAP4_VP_MPU_VLIMITTO_VDDMAX,
> +};
> +
> +struct omap_vc_param omap44xx_mpu_vc_data = {
> +       .on                     = OMAP4_ON_VOLTAGE_UV,
> +       .onlp                   = OMAP4_ONLP_VOLTAGE_UV,
> +       .ret                    = OMAP4_RET_VOLTAGE_UV,
> +       .off                    = OMAP4_OFF_VOLTAGE_UV,
> +};
> +
>  #define OMAP4430_VDD_IVA_OPP50_UV              1013000
>  #define OMAP4430_VDD_IVA_OPP100_UV             1188000
>  #define OMAP4430_VDD_IVA_OPPTURBO_UV           1300000
> @@ -55,6 +72,18 @@ struct omap_volt_data omap44xx_vdd_iva_volt_data[] = {
>        VOLT_DATA_DEFINE(0, 0, 0, 0),
>  };
>
> +struct omap_vp_param omap44xx_iva_vp_data = {
> +       .vddmin                 = OMAP4_VP_IVA_VLIMITTO_VDDMIN,
> +       .vddmax                 = OMAP4_VP_IVA_VLIMITTO_VDDMAX,
> +};
> +
> +struct omap_vc_param omap44xx_iva_vc_data = {
> +       .on                     = OMAP4_ON_VOLTAGE_UV,
> +       .onlp                   = OMAP4_ONLP_VOLTAGE_UV,
> +       .ret                    = OMAP4_RET_VOLTAGE_UV,
> +       .off                    = OMAP4_OFF_VOLTAGE_UV,
> +};
> +
>  #define OMAP4430_VDD_CORE_OPP50_UV             1025000
>  #define OMAP4430_VDD_CORE_OPP100_UV            1200000
>
> @@ -64,6 +93,17 @@ struct omap_volt_data omap44xx_vdd_core_volt_data[] = {
>        VOLT_DATA_DEFINE(0, 0, 0, 0),
>  };
>
> +struct omap_vp_param omap44xx_core_vp_data = {
> +       .vddmin                 = OMAP4_VP_CORE_VLIMITTO_VDDMIN,
> +       .vddmax                 = OMAP4_VP_CORE_VLIMITTO_VDDMAX,
> +};
> +
> +struct omap_vc_param omap44xx_core_vc_data = {
> +       .on                     = OMAP4_ON_VOLTAGE_UV,
> +       .onlp                   = OMAP4_ONLP_VOLTAGE_UV,
> +       .ret                    = OMAP4_RET_VOLTAGE_UV,
> +       .off                    = OMAP4_OFF_VOLTAGE_UV,
> +};

NOTE: we will be reaching all combinations ahead - in time to come
ahead we will have 4470 as well - linking this to opp data seems wrong
to me..

Regards,
Nishanth Menon

>
>  static struct omap_opp_def __initdata omap44xx_opp_def_list[] = {
>        /* MPU OPP1 - OPP50 */
> diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
> index 031d116..8384b70 100644
> --- a/arch/arm/mach-omap2/vc.c
> +++ b/arch/arm/mach-omap2/vc.c
> @@ -10,14 +10,18 @@
>  #include <linux/kernel.h>
>  #include <linux/delay.h>
>  #include <linux/init.h>
> +#include <linux/clk.h>
> +#include <linux/io.h>
>
>  #include <plat/cpu.h>
> +#include <plat/prcm.h>
>
>  #include "voltage.h"
>  #include "vc.h"
>  #include "prm-regbits-34xx.h"
>  #include "prm-regbits-44xx.h"
>  #include "prm44xx.h"
> +#include "scrm44xx.h"
>
>  /**
>  * struct omap_vc_channel_cfg - describe the cfg_channel bitfield
> @@ -136,6 +140,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;
> @@ -203,44 +209,170 @@ int omap_vc_bypass_scale(struct voltagedomain *voltdm,
>        return 0;
>  }
>
> -static void __init omap3_vfsm_init(struct voltagedomain *voltdm)
> +static void omap3_set_i2c_timings(struct voltagedomain *voltdm, int off_mode)
>  {
> +       unsigned long voltsetup1;
> +       u32 tgt_volt;
> +
> +       if (off_mode)
> +               tgt_volt = voltdm->vc_param->off;
> +       else
> +               tgt_volt = voltdm->vc_param->ret;
> +
> +       voltsetup1 = (voltdm->vc_param->on - tgt_volt) /
> +                       voltdm->pmic->slew_rate;
> +
> +       voltsetup1 = voltsetup1 * voltdm->sys_clk.rate / 8 / 1000000 + 1;
> +
> +       voltdm->rmw(voltdm->vfsm->voltsetup_mask,
> +               voltsetup1 << __ffs(voltdm->vfsm->voltsetup_mask),
> +               voltdm->vfsm->voltsetup_reg);
> +
>        /*
> -        * Voltage Manager FSM parameters init
> -        * XXX This data should be passed in from the board file
> +        * pmic is not controlling the voltage scaling during retention,
> +        * thus set voltsetup2 to 0
>         */
> -       voltdm->write(OMAP3_CLKSETUP, OMAP3_PRM_CLKSETUP_OFFSET);
> -       voltdm->write(OMAP3_VOLTOFFSET, OMAP3_PRM_VOLTOFFSET_OFFSET);
> -       voltdm->write(OMAP3_VOLTSETUP2, OMAP3_PRM_VOLTSETUP2_OFFSET);
> +       voltdm->write(0, OMAP3_PRM_VOLTSETUP2_OFFSET);
>  }
>
> -static void __init omap3_vc_init_channel(struct voltagedomain *voltdm)
> +static void omap3_set_off_timings(struct voltagedomain *voltdm)
>  {
> -       static bool is_initialized;
> +       unsigned long clksetup;
> +       unsigned long voltsetup2;
> +       unsigned long voltsetup2_old;
> +       u32 val;
>
> -       if (is_initialized)
> +       /* check if pmic is controlling off-mode voltages */
> +       val = voltdm->read(OMAP3_PRM_VOLTCTRL_OFFSET);
> +       if (!(val & OMAP3430_SEL_OFF_MASK)) {
> +               /* No, omap is controlling them over I2C */
> +               omap3_set_i2c_timings(voltdm, 1);
>                return;
> +       }
> +
> +       clksetup = voltdm->read(OMAP3_PRM_CLKSETUP_OFFSET);
> +
> +       /* voltsetup 2 in us */
> +       voltsetup2 = voltdm->vc_param->on / voltdm->pmic->slew_rate;
> +
> +       /* convert to 32k clk cycles */
> +       voltsetup2 = DIV_ROUND_UP(voltsetup2 * 32768, 1000000);
> +
> +       voltsetup2_old = voltdm->read(OMAP3_PRM_VOLTSETUP2_OFFSET);
> +
> +       /*
> +        * Update voltsetup2 if higher than current value (needed because
> +        * we have multiple channels with different ramp times), also
> +        * update voltoffset always to value recommended by TRM
> +        */
> +       if (voltsetup2 > voltsetup2_old) {
> +               voltdm->write(voltsetup2, OMAP3_PRM_VOLTSETUP2_OFFSET);
> +               voltdm->write(clksetup - voltsetup2,
> +                       OMAP3_PRM_VOLTOFFSET_OFFSET);
> +       } else
> +               voltdm->write(clksetup - voltsetup2_old,
> +                       OMAP3_PRM_VOLTOFFSET_OFFSET);
> +
> +       /*
> +        * omap is not controlling voltage scaling during off-mode,
> +        * thus set voltsetup1 to 0
> +        */
> +       voltdm->rmw(voltdm->vfsm->voltsetup_mask, 0,
> +               voltdm->vfsm->voltsetup_reg);
> +
> +       /* voltoffset must be clksetup minus voltsetup2 according to TRM */
> +       voltdm->write(clksetup - voltsetup2, OMAP3_PRM_VOLTOFFSET_OFFSET);
> +}
> +
> +static void __init omap3_vc_init_channel(struct voltagedomain *voltdm)
> +{
> +       omap3_set_off_timings(voltdm);
> +}
> +
> +static u32 omap4_calc_volt_ramp(struct voltagedomain *voltdm, u32 voltage_diff,
> +               u32 clk_rate)
> +{
> +       u32 prescaler;
> +       u32 cycles;
> +       u32 time;
> +
> +       time = voltage_diff / voltdm->pmic->slew_rate;
> +
> +       cycles = clk_rate / 1000 * time / 1000;
> +
> +       cycles /= 64;
> +       prescaler = 0;
> +
> +       /* shift to next prescaler until no overflow */
> +
> +       /* scale for div 256 = 64 * 4 */
> +       if (cycles > 63) {
> +               cycles /= 4;
> +               prescaler++;
> +       }
>
> -       omap3_vfsm_init(voltdm);
> +       /* scale for div 512 = 256 * 2 */
> +       if (cycles > 63) {
> +               cycles /= 2;
> +               prescaler++;
> +       }
> +
> +       /* scale for div 2048 = 512 * 4 */
> +       if (cycles > 63) {
> +               cycles /= 4;
> +               prescaler++;
> +       }
>
> -       is_initialized = true;
> +       /* check for overflow => invalid ramp time */
> +       if (cycles > 63) {
> +               pr_warning("%s: invalid setuptime for vdd_%s\n", __func__,
> +                       voltdm->name);
> +               return 0;
> +       }
> +
> +       cycles++;
> +
> +       return (prescaler << OMAP4430_RAMP_UP_PRESCAL_SHIFT) |
> +               (cycles << OMAP4430_RAMP_UP_COUNT_SHIFT);
>  }
>
> +static void omap4_set_timings(struct voltagedomain *voltdm, bool off_mode)
> +{
> +       u32 val;
> +       u32 ramp;
> +
> +       /* configure the setup times */
> +       val = voltdm->read(voltdm->vfsm->voltsetup_reg);
> +
> +       if (off_mode)
> +               ramp = omap4_calc_volt_ramp(voltdm,
> +                       voltdm->vc_param->on - voltdm->vc_param->off,
> +                       voltdm->sys_clk.rate);
> +       else
> +               ramp = omap4_calc_volt_ramp(voltdm,
> +                       voltdm->vc_param->on - voltdm->vc_param->ret,
> +                       voltdm->sys_clk.rate);
> +
> +       if (!ramp)
> +               return;
> +
> +       val |= ramp << OMAP4430_RAMP_DOWN_COUNT_SHIFT;
> +
> +       val |= ramp << OMAP4430_RAMP_UP_COUNT_SHIFT;
> +
> +       voltdm->write(val, voltdm->vfsm->voltsetup_reg);
> +}
>
>  /* OMAP4 specific voltage init functions */
>  static void __init omap4_vc_init_channel(struct voltagedomain *voltdm)
>  {
> -       static bool is_initialized;
>        u32 vc_val;
>
> -       if (is_initialized)
> -               return;
> +       omap4_set_timings(voltdm, true);
>
>        /* XXX These are magic numbers and do not belong! */
>        vc_val = (0x60 << OMAP4430_SCLL_SHIFT | 0x26 << OMAP4430_SCLH_SHIFT);
>        voltdm->write(vc_val, OMAP4_PRM_VC_CFG_I2C_CLK_OFFSET);
> -
> -       is_initialized = true;
>  }
>
>  /**
> @@ -314,7 +446,6 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm)
>        vc->i2c_slave_addr = voltdm->pmic->i2c_slave_addr;
>        vc->volt_reg_addr = voltdm->pmic->volt_reg_addr;
>        vc->cmd_reg_addr = voltdm->pmic->cmd_reg_addr;
> -       vc->setup_time = voltdm->pmic->volt_setup_time;
>
>        /* Configure the i2c slave address for this VC */
>        voltdm->rmw(vc->smps_sa_mask,
> @@ -338,10 +469,10 @@ 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 = voltdm->pmic->uv_to_vsel(voltdm->vc_param->on);
> +       onlp_vsel = voltdm->pmic->uv_to_vsel(voltdm->vc_param->onlp);
> +       ret_vsel = voltdm->pmic->uv_to_vsel(voltdm->vc_param->ret);
> +       off_vsel = voltdm->pmic->uv_to_vsel(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) |
> @@ -352,11 +483,6 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm)
>        /* Channel configuration */
>        omap_vc_config_channel(voltdm);
>
> -       /* Configure the setup times */
> -       voltdm->rmw(voltdm->vfsm->voltsetup_mask,
> -                   vc->setup_time << __ffs(voltdm->vfsm->voltsetup_mask),
> -                   voltdm->vfsm->voltsetup_reg);
> -
>        omap_vc_i2c_init(voltdm);
>
>        if (cpu_is_omap34xx())
> diff --git a/arch/arm/mach-omap2/vc.h b/arch/arm/mach-omap2/vc.h
> index 478bf6b..916c8fc 100644
> --- a/arch/arm/mach-omap2/vc.h
> +++ b/arch/arm/mach-omap2/vc.h
> @@ -86,7 +86,6 @@ struct omap_vc_channel {
>        u16 i2c_slave_addr;
>        u16 volt_reg_addr;
>        u16 cmd_reg_addr;
> -       u16 setup_time;
>        u8 cfg_channel;
>        bool i2c_high_speed;
>
> diff --git a/arch/arm/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h
> index 5204936..3afd1fc 100644
> --- a/arch/arm/mach-omap2/voltage.h
> +++ b/arch/arm/mach-omap2/voltage.h
> @@ -72,6 +72,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);
> @@ -142,10 +144,6 @@ struct omap_volt_data {
>  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;
> @@ -162,6 +160,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,
> diff --git a/arch/arm/mach-omap2/voltagedomains3xxx_data.c b/arch/arm/mach-omap2/voltagedomains3xxx_data.c
> index 071101d..35b3bed 100644
> --- a/arch/arm/mach-omap2/voltagedomains3xxx_data.c
> +++ b/arch/arm/mach-omap2/voltagedomains3xxx_data.c
> @@ -88,9 +88,17 @@ void __init omap3xxx_voltagedomains_init(void)
>        if (cpu_is_omap3630()) {
>                omap3_voltdm_mpu.volt_data = omap36xx_vddmpu_volt_data;
>                omap3_voltdm_core.volt_data = omap36xx_vddcore_volt_data;
> +               omap3_voltdm_mpu.vp_param = &omap36xx_mpu_vp_data;
> +               omap3_voltdm_core.vp_param = &omap36xx_core_vp_data;
> +               omap3_voltdm_mpu.vc_param = &omap36xx_mpu_vc_data;
> +               omap3_voltdm_core.vc_param = &omap36xx_core_vc_data;
>        } else {
>                omap3_voltdm_mpu.volt_data = omap34xx_vddmpu_volt_data;
>                omap3_voltdm_core.volt_data = omap34xx_vddcore_volt_data;
> +               omap3_voltdm_mpu.vp_param = &omap34xx_mpu_vp_data;
> +               omap3_voltdm_core.vp_param = &omap34xx_core_vp_data;
> +               omap3_voltdm_mpu.vc_param = &omap34xx_mpu_vc_data;
> +               omap3_voltdm_core.vc_param = &omap34xx_core_vc_data;
>        }
>
>        for (i = 0; voltdm = voltagedomains_omap3[i], voltdm; i++)
> diff --git a/arch/arm/mach-omap2/voltagedomains44xx_data.c b/arch/arm/mach-omap2/voltagedomains44xx_data.c
> index c4584e9..0a22960 100644
> --- a/arch/arm/mach-omap2/voltagedomains44xx_data.c
> +++ b/arch/arm/mach-omap2/voltagedomains44xx_data.c
> @@ -104,6 +104,14 @@ void __init omap44xx_voltagedomains_init(void)
>        omap4_voltdm_iva.volt_data = omap44xx_vdd_iva_volt_data;
>        omap4_voltdm_core.volt_data = omap44xx_vdd_core_volt_data;
>
> +       omap4_voltdm_mpu.vp_param = &omap44xx_mpu_vp_data;
> +       omap4_voltdm_iva.vp_param = &omap44xx_iva_vp_data;
> +       omap4_voltdm_core.vp_param = &omap44xx_core_vp_data;
> +
> +       omap4_voltdm_mpu.vc_param = &omap44xx_mpu_vc_data;
> +       omap4_voltdm_iva.vc_param = &omap44xx_iva_vc_data;
> +       omap4_voltdm_core.vc_param = &omap44xx_core_vc_data;
> +
>        for (i = 0; voltdm = voltagedomains_omap4[i], voltdm; i++)
>                voltdm->sys_clk.name = sys_clk_name;
>
> --
> 1.7.4.1
>
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 04/15] omap4: add pmic startup / shutdown times
  2011-11-25 15:49 ` [PATCHv4 04/15] omap4: add " Tero Kristo
@ 2011-11-29 18:30   ` Menon, Nishanth
  2011-11-30  9:45     ` Tero Kristo
  0 siblings, 1 reply; 43+ messages in thread
From: Menon, Nishanth @ 2011-11-29 18:30 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap, khilman

On Fri, Nov 25, 2011 at 09:49, Tero Kristo <t-kristo@ti.com> wrote:
> Both startup and shutdown take 500us at maximum, value taken from
> TWL6030 data manual.
>
> Signed-off-by: Tero Kristo <t-kristo@ti.com>
> ---
>  arch/arm/mach-omap2/omap_twl.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c
> index 62ed050..bd99328 100644
> --- a/arch/arm/mach-omap2/omap_twl.c
> +++ b/arch/arm/mach-omap2/omap_twl.c
> @@ -207,6 +207,8 @@ static struct omap_voltdm_pmic omap4_iva_pmic = {
>  static struct omap_voltdm_pmic omap4_core_pmic = {
>        .slew_rate              = 4000,
>        .step_size              = 12660,
> +       .startup_time           = 500,
549?
> +       .shutdown_time          = 500,
>        .vp_erroroffset         = OMAP4_VP_CONFIG_ERROROFFSET,
>        .vp_vstepmin            = OMAP4_VP_VSTEPMIN_VSTEPMIN,
>        .vp_vstepmax            = OMAP4_VP_VSTEPMAX_VSTEPMAX,
> --
> 1.7.4.1
>


Regards,
Nishanth Menon
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 06/15] omap3+: vp: use new vp_params for calculating vddmin and vddmax
  2011-11-25 15:49 ` [PATCHv4 06/15] omap3+: vp: use new vp_params for calculating vddmin and vddmax Tero Kristo
@ 2011-11-29 18:34   ` Menon, Nishanth
  0 siblings, 0 replies; 43+ messages in thread
From: Menon, Nishanth @ 2011-11-29 18:34 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap, khilman

On Fri, Nov 25, 2011 at 09:49, Tero Kristo <t-kristo@ti.com> wrote:
> Now we select the vddmin and vddmax values based on both pmic and
> voltage processor data, this allows usage of different power ICs.
>
> Signed-off-by: Tero Kristo <t-kristo@ti.com>
Acked-by: Nishanth Menon <nm@ti.com>

Regards,
Nishanth Menon


> ---
>  arch/arm/mach-omap2/vp.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c
> index 16cb6d4..ffb68d8 100644
> --- a/arch/arm/mach-omap2/vp.c
> +++ b/arch/arm/mach-omap2/vp.c
> @@ -53,8 +53,10 @@ void __init omap_vp_init(struct voltagedomain *voltdm)
>        sys_clk_rate = voltdm->sys_clk.rate / 1000;
>
>        timeout = (sys_clk_rate * voltdm->pmic->vp_timeout_us) / 1000;
> -       vddmin = voltdm->pmic->uv_to_vsel(voltdm->pmic->vp_vddmin);
> -       vddmax = voltdm->pmic->uv_to_vsel(voltdm->pmic->vp_vddmax);
> +       vddmin = max(voltdm->vp_param->vddmin, voltdm->pmic->vp_vddmin);
> +       vddmax = min(voltdm->vp_param->vddmax, voltdm->pmic->vp_vddmax);
> +       vddmin = voltdm->pmic->uv_to_vsel(vddmin);
> +       vddmax = voltdm->pmic->uv_to_vsel(vddmax);
>
>        waittime = ((voltdm->pmic->step_size / voltdm->pmic->slew_rate) *
>                    sys_clk_rate) / 1000;
> --
> 1.7.4.1
>
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 04/15] omap4: add pmic startup / shutdown times
  2011-11-29 18:30   ` Menon, Nishanth
@ 2011-11-30  9:45     ` Tero Kristo
  2011-11-30 12:20       ` Menon, Nishanth
  0 siblings, 1 reply; 43+ messages in thread
From: Tero Kristo @ 2011-11-30  9:45 UTC (permalink / raw)
  To: Menon, Nishanth; +Cc: linux-omap, khilman

On Tue, 2011-11-29 at 12:30 -0600, Menon, Nishanth wrote:
> On Fri, Nov 25, 2011 at 09:49, Tero Kristo <t-kristo@ti.com> wrote:
> > Both startup and shutdown take 500us at maximum, value taken from
> > TWL6030 data manual.
> >
> > Signed-off-by: Tero Kristo <t-kristo@ti.com>
> > ---
> >  arch/arm/mach-omap2/omap_twl.c |    2 ++
> >  1 files changed, 2 insertions(+), 0 deletions(-)
> >
> > diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c
> > index 62ed050..bd99328 100644
> > --- a/arch/arm/mach-omap2/omap_twl.c
> > +++ b/arch/arm/mach-omap2/omap_twl.c
> > @@ -207,6 +207,8 @@ static struct omap_voltdm_pmic omap4_iva_pmic = {
> >  static struct omap_voltdm_pmic omap4_core_pmic = {
> >        .slew_rate              = 4000,
> >        .step_size              = 12660,
> > +       .startup_time           = 500,
> 549?

Where do you get 549? You looking at a different version of the DM? Or
are you adding something to the value?

-Tero

> > +       .shutdown_time          = 500,
> >        .vp_erroroffset         = OMAP4_VP_CONFIG_ERROROFFSET,
> >        .vp_vstepmin            = OMAP4_VP_VSTEPMIN_VSTEPMIN,
> >        .vp_vstepmax            = OMAP4_VP_VSTEPMAX_VSTEPMAX,
> > --
> > 1.7.4.1
> >
> 
> 
> Regards,
> Nishanth Menon



^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 11/15] omap3+: voltage/pwrdm/clkdm/clock add recursive usecount tracking
  2011-11-25 15:49 ` [PATCHv4 11/15] omap3+: voltage/pwrdm/clkdm/clock add recursive usecount tracking Tero Kristo
@ 2011-11-30  9:52   ` Jean Pihet
  2011-11-30 10:11     ` Tero Kristo
  2011-12-09 19:37   ` Kevin Hilman
  1 sibling, 1 reply; 43+ messages in thread
From: Jean Pihet @ 2011-11-30  9:52 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap, khilman, nm

Hi Tero,

On Fri, Nov 25, 2011 at 4:49 PM, Tero Kristo <t-kristo@ti.com> wrote:
> This patch fixes the usecount tracking for omap3+, previously the
> usecount numbers were rather bogus and were not really useful for
> any purpose. Now usecount numbers track the number of really active
> clients on each domain. This patch also adds support for usecount
> tracking on powerdomain and voltagedomain levels.
>
> Signed-off-by: Tero Kristo <t-kristo@ti.com>
> ---
>  arch/arm/mach-omap2/clkt_iclk.c         |   11 +++++++++
>  arch/arm/mach-omap2/clockdomain.c       |   38 +++++++++++++++++++++++++++++-
>  arch/arm/mach-omap2/clockdomain.h       |    3 ++
>  arch/arm/mach-omap2/powerdomain.c       |   12 +++++++++
>  arch/arm/mach-omap2/powerdomain.h       |    5 ++++
>  arch/arm/mach-omap2/voltage.c           |   30 ++++++++++++++++++++++++
>  arch/arm/mach-omap2/voltage.h           |    7 +++++
>  arch/arm/plat-omap/clock.c              |    2 +
>  arch/arm/plat-omap/include/plat/clock.h |    1 +
>  9 files changed, 107 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/clkt_iclk.c b/arch/arm/mach-omap2/clkt_iclk.c
> index 3d43fba..8e61776 100644
> --- a/arch/arm/mach-omap2/clkt_iclk.c
> +++ b/arch/arm/mach-omap2/clkt_iclk.c
> @@ -21,6 +21,7 @@
>  #include "clock2xxx.h"
>  #include "cm2xxx_3xxx.h"
>  #include "cm-regbits-24xx.h"
> +#include "clockdomain.h"
>
>  /* Private functions */
>
> @@ -34,6 +35,11 @@ void omap2_clkt_iclk_allow_idle(struct clk *clk)
>        v = __raw_readl((__force void __iomem *)r);
>        v |= (1 << clk->enable_bit);
>        __raw_writel(v, (__force void __iomem *)r);
> +
> +       if (clk->usecount && clk->clkdm)
> +               clkdm_usecount_dec(clk->clkdm);
Is the test on clk->usecount needed? Is that a problem when usecount reaches 0?

> +
> +       clk->autoidle = 1;
>  }
>
>  /* XXX */
> @@ -46,6 +52,11 @@ void omap2_clkt_iclk_deny_idle(struct clk *clk)
>        v = __raw_readl((__force void __iomem *)r);
>        v &= ~(1 << clk->enable_bit);
>        __raw_writel(v, (__force void __iomem *)r);
> +
> +       if (clk->usecount && clk->clkdm)
> +               clkdm_usecount_inc(clk->clkdm);
Same here.

> +
> +       clk->autoidle = 0;
>  }
>
>  /* Public data */
...

Regards,
Jean
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support
  2011-11-25 15:49 [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support Tero Kristo
                   ` (14 preceding siblings ...)
  2011-11-25 15:49 ` [PATCHv4 15/15] omap: pm: wait for domain wakeup if changing state of idle domain Tero Kristo
@ 2011-11-30 10:06 ` Jean Pihet
  2011-11-30 10:19   ` Tero Kristo
  2011-12-09 20:23 ` Kevin Hilman
  16 siblings, 1 reply; 43+ messages in thread
From: Jean Pihet @ 2011-11-30 10:06 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap, khilman, nm

Hi Tero,

On Fri, Nov 25, 2011 at 4:49 PM, Tero Kristo <t-kristo@ti.com> wrote:
> Hi,
>
> Changes compared to previous version:
>
> - merged most of the voltagedomain cleanup fixes to patch 2
> - moved pmic latencies to omap_voltdm_pmic struct
> - renamed omap_lp_params to omap2_oscillator as it only contains
>  osc info now
> - major changes to usecount support (patch 11+, needed for auto-ret)
>  * added usecounts to voltagedomain / powerdomain
>  * fixed usecount tracking so that the numbers are sane now
>  * changed behavior of some usecounting sources that they do not
>    update the counts (autoidle support)
> - added auto-ret / auto-off support, based on fixed usecounting
>  * smartreflex disabled / enabled
>  * auto-ret / auto-off enabled based on target state
> - some other minor tweaks I have probably forgotten to mention
Ok after review, except the remarks I sent as replies to the specific patches.

Minor remark: the patch set could be split into the following features:
- oscillator startup/shutdown time,
- Beagle OPP6,
- usecount code,
- auto ret/off.

> Tested on omap3 beagle:
> - voltages for vdd1 and vdd2 change when entering idle
Nice!

> - both suspend and dynamic idle tested
> - tested that voltages reach target levels for both ret / off
>
> Tested on omap4 blaze with custom kernel
> - this requires a few additional patches missing from this set as
>  omap4 PM support is still not merged
> - will post missing patches once possible from upstream point of view
> - voltages for vdd1 and vdd3 change when entering idle
>
> Applies on top of Kevin's for_3.2/voltage-cleanup branch.
>
> I have a bunch of additional debugging patches I have used in verification
> of this set if anybody is interested.
>
> TBD:
> - no pmic off support yet
>  * no pmic script support
>  * vdd1 / vdd2 only reach 0.6V, not 0V in off
>  * oscillator is not turned off
That would be nice to have. IIRC last time I checked the existing T2
scripts where not working on Beagle due to a different wiring of the
PMIC<->OMAP signals.

>
> -Tero

Regards,
Jean

>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 02/15] omap3+: voltage: parameter segregation
  2011-11-29 18:26   ` Menon, Nishanth
@ 2011-11-30 10:07     ` Tero Kristo
  2011-11-30 12:31       ` Menon, Nishanth
  0 siblings, 1 reply; 43+ messages in thread
From: Tero Kristo @ 2011-11-30 10:07 UTC (permalink / raw)
  To: Menon, Nishanth; +Cc: linux-omap, khilman

Hi,

Removed part of patch for easier readability of comments.

On Tue, 2011-11-29 at 12:26 -0600, Menon, Nishanth wrote:
> On Fri, Nov 25, 2011 at 09:49, Tero Kristo <t-kristo@ti.com> wrote:
<clip>

> > @@ -227,11 +207,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,
> >        .vp_vstepmax            = OMAP4_VP_VSTEPMAX_VSTEPMAX,
> > diff --git a/arch/arm/mach-omap2/opp3xxx_data.c b/arch/arm/mach-omap2/opp3xxx_data.c
> > index d95f3f9..1d44df5 100644
> > --- a/arch/arm/mach-omap2/opp3xxx_data.c
> > +++ b/arch/arm/mach-omap2/opp3xxx_data.c
> > @@ -26,6 +26,10 @@
> >  #include "pm.h"
> >
> >  /* 34xx */
> > +#define OMAP3_ON_VOLTAGE_UV            1200000
> > +#define OMAP3_ONLP_VOLTAGE_UV          1000000
> > +#define OMAP3_RET_VOLTAGE_UV           975000
> > +#define OMAP3_OFF_VOLTAGE_UV           600000
> 
> this approach has a problem -> ON, ONLP and RET voltage should consider:
> a) OMAP capabiltiy as above.
> b) PMIC capability which is being removed in this patch
> 
> the framework should use the combination of both to make a decision.

So, I think we should limit these voltages based on the PMIC vddmin /
vddmax values, right? I don't think PMIC has any other limitations, and
we shouldn't define the voltage levels for all of these modes for PMIC.
PMIC limits should also probably be changed from current values (based
on OMAP defines) and changed to actual values, like vddmin = 600mV
(vsel=0), or whatever is the minimum voltage for the corresponding PMIC.

<clip>

> > +};
> > +
> >  #define OMAP4430_VDD_CORE_OPP50_UV             1025000
> >  #define OMAP4430_VDD_CORE_OPP100_UV            1200000
> >
> > @@ -64,6 +93,17 @@ struct omap_volt_data omap44xx_vdd_core_volt_data[] = {
> >        VOLT_DATA_DEFINE(0, 0, 0, 0),
> >  };
> >
> > +struct omap_vp_param omap44xx_core_vp_data = {
> > +       .vddmin                 = OMAP4_VP_CORE_VLIMITTO_VDDMIN,
> > +       .vddmax                 = OMAP4_VP_CORE_VLIMITTO_VDDMAX,
> > +};
> > +
> > +struct omap_vc_param omap44xx_core_vc_data = {
> > +       .on                     = OMAP4_ON_VOLTAGE_UV,
> > +       .onlp                   = OMAP4_ONLP_VOLTAGE_UV,
> > +       .ret                    = OMAP4_RET_VOLTAGE_UV,
> > +       .off                    = OMAP4_OFF_VOLTAGE_UV,
> > +};
> 
> NOTE: we will be reaching all combinations ahead - in time to come
> ahead we will have 4470 as well - linking this to opp data seems wrong
> to me..

They are not really that much linked to opp data, they are just defined
in this file. The actual attach to voltdm is done in
voltagedomainsxxxx_data.c file, where we can link data to whatever
voltagedomain we want to. See for example voltagedomains3xxx_data.c what
is done for omap34xx vs. omap36xx. Should we move this data over there
then...?

-Tero

<clip>


^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 11/15] omap3+: voltage/pwrdm/clkdm/clock add recursive usecount tracking
  2011-11-30  9:52   ` Jean Pihet
@ 2011-11-30 10:11     ` Tero Kristo
  0 siblings, 0 replies; 43+ messages in thread
From: Tero Kristo @ 2011-11-30 10:11 UTC (permalink / raw)
  To: Jean Pihet; +Cc: linux-omap, khilman, nm

On Wed, 2011-11-30 at 10:52 +0100, Jean Pihet wrote:
> Hi Tero,
> 
> On Fri, Nov 25, 2011 at 4:49 PM, Tero Kristo <t-kristo@ti.com> wrote:
> > This patch fixes the usecount tracking for omap3+, previously the
> > usecount numbers were rather bogus and were not really useful for
> > any purpose. Now usecount numbers track the number of really active
> > clients on each domain. This patch also adds support for usecount
> > tracking on powerdomain and voltagedomain levels.
> >
> > Signed-off-by: Tero Kristo <t-kristo@ti.com>
> > ---
> >  arch/arm/mach-omap2/clkt_iclk.c         |   11 +++++++++
> >  arch/arm/mach-omap2/clockdomain.c       |   38 +++++++++++++++++++++++++++++-
> >  arch/arm/mach-omap2/clockdomain.h       |    3 ++
> >  arch/arm/mach-omap2/powerdomain.c       |   12 +++++++++
> >  arch/arm/mach-omap2/powerdomain.h       |    5 ++++
> >  arch/arm/mach-omap2/voltage.c           |   30 ++++++++++++++++++++++++
> >  arch/arm/mach-omap2/voltage.h           |    7 +++++
> >  arch/arm/plat-omap/clock.c              |    2 +
> >  arch/arm/plat-omap/include/plat/clock.h |    1 +
> >  9 files changed, 107 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/arm/mach-omap2/clkt_iclk.c b/arch/arm/mach-omap2/clkt_iclk.c
> > index 3d43fba..8e61776 100644
> > --- a/arch/arm/mach-omap2/clkt_iclk.c
> > +++ b/arch/arm/mach-omap2/clkt_iclk.c
> > @@ -21,6 +21,7 @@
> >  #include "clock2xxx.h"
> >  #include "cm2xxx_3xxx.h"
> >  #include "cm-regbits-24xx.h"
> > +#include "clockdomain.h"
> >
> >  /* Private functions */
> >
> > @@ -34,6 +35,11 @@ void omap2_clkt_iclk_allow_idle(struct clk *clk)
> >        v = __raw_readl((__force void __iomem *)r);
> >        v |= (1 << clk->enable_bit);
> >        __raw_writel(v, (__force void __iomem *)r);
> > +
> > +       if (clk->usecount && clk->clkdm)
> > +               clkdm_usecount_dec(clk->clkdm);
> Is the test on clk->usecount needed? Is that a problem when usecount reaches 0?

Yea, this check is needed because we don't really know whether the clock
is active or not when allow_idle is called. If it is active, we want to
decrease the clkdm usecount as this clock has increased the usecount on
that domain when it was enabled, otherwise not.

> 
> > +
> > +       clk->autoidle = 1;
> >  }
> >
> >  /* XXX */
> > @@ -46,6 +52,11 @@ void omap2_clkt_iclk_deny_idle(struct clk *clk)
> >        v = __raw_readl((__force void __iomem *)r);
> >        v &= ~(1 << clk->enable_bit);
> >        __raw_writel(v, (__force void __iomem *)r);
> > +
> > +       if (clk->usecount && clk->clkdm)
> > +               clkdm_usecount_inc(clk->clkdm);
> Same here.

Same deal, but other way around.

-Tero

> 
> > +
> > +       clk->autoidle = 0;
> >  }
> >
> >  /* Public data */
> ...
> 
> Regards,
> Jean



^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 02/15] omap3+: voltage: parameter segregation
  2011-11-25 15:49 ` [PATCHv4 02/15] omap3+: voltage: parameter segregation Tero Kristo
  2011-11-29 18:26   ` Menon, Nishanth
@ 2011-11-30 10:11   ` Jean Pihet
  1 sibling, 0 replies; 43+ messages in thread
From: Jean Pihet @ 2011-11-30 10:11 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap, khilman, nm

Tero,

On Fri, Nov 25, 2011 at 4:49 PM, Tero Kristo <t-kristo@ti.com> wrote:
> -static void __init omap3_vfsm_init(struct voltagedomain *voltdm)
> +static void omap3_set_i2c_timings(struct voltagedomain *voltdm, int off_mode)
>  {
> +       unsigned long voltsetup1;
> +       u32 tgt_volt;
> +
> +       if (off_mode)
> +               tgt_volt = voltdm->vc_param->off;
> +       else
> +               tgt_volt = voltdm->vc_param->ret;
> +
> +       voltsetup1 = (voltdm->vc_param->on - tgt_volt) /
> +                       voltdm->pmic->slew_rate;
> +
> +       voltsetup1 = voltsetup1 * voltdm->sys_clk.rate / 8 / 1000000 + 1;
Minor: some () here would improve the code readability.

> +
> +       voltdm->rmw(voltdm->vfsm->voltsetup_mask,
> +               voltsetup1 << __ffs(voltdm->vfsm->voltsetup_mask),
> +               voltdm->vfsm->voltsetup_reg);
> +
>

Regards,
Jean
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support
  2011-11-30 10:06 ` [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support Jean Pihet
@ 2011-11-30 10:19   ` Tero Kristo
  0 siblings, 0 replies; 43+ messages in thread
From: Tero Kristo @ 2011-11-30 10:19 UTC (permalink / raw)
  To: Jean Pihet; +Cc: linux-omap, khilman, nm

On Wed, 2011-11-30 at 11:06 +0100, Jean Pihet wrote:
> Hi Tero,
> 
> On Fri, Nov 25, 2011 at 4:49 PM, Tero Kristo <t-kristo@ti.com> wrote:
> > Hi,
> >
> > Changes compared to previous version:
> >
> > - merged most of the voltagedomain cleanup fixes to patch 2
> > - moved pmic latencies to omap_voltdm_pmic struct
> > - renamed omap_lp_params to omap2_oscillator as it only contains
> >  osc info now
> > - major changes to usecount support (patch 11+, needed for auto-ret)
> >  * added usecounts to voltagedomain / powerdomain
> >  * fixed usecount tracking so that the numbers are sane now
> >  * changed behavior of some usecounting sources that they do not
> >    update the counts (autoidle support)
> > - added auto-ret / auto-off support, based on fixed usecounting
> >  * smartreflex disabled / enabled
> >  * auto-ret / auto-off enabled based on target state
> > - some other minor tweaks I have probably forgotten to mention
> Ok after review, except the remarks I sent as replies to the specific patches.
> 
> Minor remark: the patch set could be split into the following features:
> - oscillator startup/shutdown time,
> - Beagle OPP6,
> - usecount code,
> - auto ret/off.

True. It was actually split almost like that earlier, however it is now
a big pile of patches together. :)

> 
> > Tested on omap3 beagle:
> > - voltages for vdd1 and vdd2 change when entering idle
> Nice!
> 
> > - both suspend and dynamic idle tested
> > - tested that voltages reach target levels for both ret / off
> >
> > Tested on omap4 blaze with custom kernel
> > - this requires a few additional patches missing from this set as
> >  omap4 PM support is still not merged
> > - will post missing patches once possible from upstream point of view
> > - voltages for vdd1 and vdd3 change when entering idle
> >
> > Applies on top of Kevin's for_3.2/voltage-cleanup branch.
> >
> > I have a bunch of additional debugging patches I have used in verification
> > of this set if anybody is interested.
> >
> > TBD:
> > - no pmic off support yet
> >  * no pmic script support
> >  * vdd1 / vdd2 only reach 0.6V, not 0V in off
> >  * oscillator is not turned off
> That would be nice to have. IIRC last time I checked the existing T2
> scripts where not working on Beagle due to a different wiring of the
> PMIC<->OMAP signals.

Yeah, fixing the script support should probably be done also, not sure
who is going to do that though. Looking at the board files quickly, I
can only see pmic script support for board-rx51.

-Tero



^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 04/15] omap4: add pmic startup / shutdown times
  2011-11-30  9:45     ` Tero Kristo
@ 2011-11-30 12:20       ` Menon, Nishanth
  2011-11-30 13:08         ` Tero Kristo
  0 siblings, 1 reply; 43+ messages in thread
From: Menon, Nishanth @ 2011-11-30 12:20 UTC (permalink / raw)
  To: t-kristo; +Cc: linux-omap, khilman

On Wed, Nov 30, 2011 at 03:45, Tero Kristo <t-kristo@ti.com> wrote:
>
> On Tue, 2011-11-29 at 12:30 -0600, Menon, Nishanth wrote:
> > On Fri, Nov 25, 2011 at 09:49, Tero Kristo <t-kristo@ti.com> wrote:
> > > Both startup and shutdown take 500us at maximum, value taken from
> > > TWL6030 data manual.
Might be good to add reference version as well for traceability.

> > >
> > > Signed-off-by: Tero Kristo <t-kristo@ti.com>
> > > ---
> > >  arch/arm/mach-omap2/omap_twl.c |    2 ++
> > >  1 files changed, 2 insertions(+), 0 deletions(-)
> > >
> > > diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c
> > > index 62ed050..bd99328 100644
> > > --- a/arch/arm/mach-omap2/omap_twl.c
> > > +++ b/arch/arm/mach-omap2/omap_twl.c
> > > @@ -207,6 +207,8 @@ static struct omap_voltdm_pmic omap4_iva_pmic = {
> > >  static struct omap_voltdm_pmic omap4_core_pmic = {
> > >        .slew_rate              = 4000,
> > >        .step_size              = 12660,
> > > +       .startup_time           = 500,
> > 549?
>
> Where do you get 549? You looking at a different version of the DM? Or
> are you adding something to the value?
>
woohoo.. welcome to TWL6030 doc hell ;)
Data Sheet: 0.05: T on =500Usec
*but* TRM 0.1 says T on = 500uSec for SMPS  not freq locked, and upto
3ms with SMPS frequency locked).
*then* Functional spec rev 0.12 says "Enable VCORE[1,2,3] = 549uSec.

Regards,
Nishanth Menon
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 02/15] omap3+: voltage: parameter segregation
  2011-11-30 10:07     ` Tero Kristo
@ 2011-11-30 12:31       ` Menon, Nishanth
  2011-11-30 13:04         ` Tero Kristo
  0 siblings, 1 reply; 43+ messages in thread
From: Menon, Nishanth @ 2011-11-30 12:31 UTC (permalink / raw)
  To: t-kristo; +Cc: linux-omap, khilman

On Wed, Nov 30, 2011 at 04:07, Tero Kristo <t-kristo@ti.com> wrote:
> On Tue, 2011-11-29 at 12:26 -0600, Menon, Nishanth wrote:
>> On Fri, Nov 25, 2011 at 09:49, Tero Kristo <t-kristo@ti.com> wrote:
<more snip>
>> > diff --git a/arch/arm/mach-omap2/opp3xxx_data.c b/arch/arm/mach-omap2/opp3xxx_data.c
>> > index d95f3f9..1d44df5 100644
>> > --- a/arch/arm/mach-omap2/opp3xxx_data.c
>> > +++ b/arch/arm/mach-omap2/opp3xxx_data.c
>> >
>> >  /* 34xx */
>> > +#define OMAP3_ON_VOLTAGE_UV            1200000
>> > +#define OMAP3_ONLP_VOLTAGE_UV          1000000
>> > +#define OMAP3_RET_VOLTAGE_UV           975000
>> > +#define OMAP3_OFF_VOLTAGE_UV           600000
>>
>> this approach has a problem -> ON, ONLP and RET voltage should consider:
Make that ON, ONLP, RET, OFF voltages! Sigh..

>> a) OMAP capabiltiy as above.
>> b) PMIC capability which is being removed in this patch
>>
>> the framework should use the combination of both to make a decision.
>
> So, I think we should limit these voltages based on the PMIC vddmin /
> vddmax values, right? I don't think PMIC has any other limitations, and
Ideally speaking - this is what we want:
PMIC says - on this rail - I can give max x V and min y V. and when
you(kernel) gets control, expect Voltage = ON.

OMAP requirements - which ever wierd ones they might be - will be very
specific to OMAP variants.
some factors such as timing closures also come into play -> ON, ONLP,
RET and OFF are OMAP reqs.

Now, we can have combinations like TPS+TWL+OMAP4430 (yep - those do
exist) or something like custom PMIC+OMAP4460
or many other combinations..

You could have additional complications as well - e.g. PMIC OFF path
is definitely our favourite.
writing 0x0 to TWL causes 0V and a 1 is 709..mV or 607..mV, 0x0 on TPS is 500mV!

> we shouldn't define the voltage levels for all of these modes for PMIC.
> PMIC limits should also probably be changed from current values (based
> on OMAP defines) and changed to actual values, like vddmin = 600mV
> (vsel=0), or whatever is the minimum voltage for the corresponding PMIC.

my point being: framework cannot expect any assumption about the PMIC
and the person writing the support for a new PMIC should be completely
ignorant for which OMAP he/she is writing for.

>> > +};
>> > +
>> >  #define OMAP4430_VDD_CORE_OPP50_UV             1025000
>> >  #define OMAP4430_VDD_CORE_OPP100_UV            1200000
>> >
>> > @@ -64,6 +93,17 @@ struct omap_volt_data omap44xx_vdd_core_volt_data[] = {
>> >        VOLT_DATA_DEFINE(0, 0, 0, 0),
>> >  };
>> >
>> > +struct omap_vp_param omap44xx_core_vp_data = {
>> > +       .vddmin                 = OMAP4_VP_CORE_VLIMITTO_VDDMIN,
>> > +       .vddmax                 = OMAP4_VP_CORE_VLIMITTO_VDDMAX,
>> > +};
>> > +
>> > +struct omap_vc_param omap44xx_core_vc_data = {
>> > +       .on                     = OMAP4_ON_VOLTAGE_UV,
>> > +       .onlp                   = OMAP4_ONLP_VOLTAGE_UV,
>> > +       .ret                    = OMAP4_RET_VOLTAGE_UV,
>> > +       .off                    = OMAP4_OFF_VOLTAGE_UV,
>> > +};
>>
>> NOTE: we will be reaching all combinations ahead - in time to come
>> ahead we will have 4470 as well - linking this to opp data seems wrong
>> to me..
>
> They are not really that much linked to opp data, they are just defined
> in this file. The actual attach to voltdm is done in
> voltagedomainsxxxx_data.c file, where we can link data to whatever
> voltagedomain we want to. See for example voltagedomains3xxx_data.c what
> is done for omap34xx vs. omap36xx. Should we move this data over there
> then...?
I think it belongs to VP/VC data and not in OPP file (which was meant
for OPPs in the first place).
we might want to think about replacing these with device tree data
someday - OPP data makes it
kinda hard to distinguish IMHO when we do that.

Regards,
Nishanth Menon
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 02/15] omap3+: voltage: parameter segregation
  2011-11-30 12:31       ` Menon, Nishanth
@ 2011-11-30 13:04         ` Tero Kristo
  0 siblings, 0 replies; 43+ messages in thread
From: Tero Kristo @ 2011-11-30 13:04 UTC (permalink / raw)
  To: Menon, Nishanth; +Cc: linux-omap, khilman

On Wed, 2011-11-30 at 06:31 -0600, Menon, Nishanth wrote:
> On Wed, Nov 30, 2011 at 04:07, Tero Kristo <t-kristo@ti.com> wrote:
> > On Tue, 2011-11-29 at 12:26 -0600, Menon, Nishanth wrote:
> >> On Fri, Nov 25, 2011 at 09:49, Tero Kristo <t-kristo@ti.com> wrote:
> <more snip>
> >> > diff --git a/arch/arm/mach-omap2/opp3xxx_data.c b/arch/arm/mach-omap2/opp3xxx_data.c
> >> > index d95f3f9..1d44df5 100644
> >> > --- a/arch/arm/mach-omap2/opp3xxx_data.c
> >> > +++ b/arch/arm/mach-omap2/opp3xxx_data.c
> >> >
> >> >  /* 34xx */
> >> > +#define OMAP3_ON_VOLTAGE_UV            1200000
> >> > +#define OMAP3_ONLP_VOLTAGE_UV          1000000
> >> > +#define OMAP3_RET_VOLTAGE_UV           975000
> >> > +#define OMAP3_OFF_VOLTAGE_UV           600000
> >>
> >> this approach has a problem -> ON, ONLP and RET voltage should consider:
> Make that ON, ONLP, RET, OFF voltages! Sigh..
> 
> >> a) OMAP capabiltiy as above.
> >> b) PMIC capability which is being removed in this patch
> >>
> >> the framework should use the combination of both to make a decision.
> >
> > So, I think we should limit these voltages based on the PMIC vddmin /
> > vddmax values, right? I don't think PMIC has any other limitations, and
> Ideally speaking - this is what we want:
> PMIC says - on this rail - I can give max x V and min y V. and when
> you(kernel) gets control, expect Voltage = ON.
> 
> OMAP requirements - which ever wierd ones they might be - will be very
> specific to OMAP variants.
> some factors such as timing closures also come into play -> ON, ONLP,
> RET and OFF are OMAP reqs.
> 
> Now, we can have combinations like TPS+TWL+OMAP4430 (yep - those do
> exist) or something like custom PMIC+OMAP4460
> or many other combinations..
> 
> You could have additional complications as well - e.g. PMIC OFF path
> is definitely our favourite.
> writing 0x0 to TWL causes 0V and a 1 is 709..mV or 607..mV, 0x0 on TPS is 500mV!
> 
> > we shouldn't define the voltage levels for all of these modes for PMIC.
> > PMIC limits should also probably be changed from current values (based
> > on OMAP defines) and changed to actual values, like vddmin = 600mV
> > (vsel=0), or whatever is the minimum voltage for the corresponding PMIC.
> 
> my point being: framework cannot expect any assumption about the PMIC
> and the person writing the support for a new PMIC should be completely
> ignorant for which OMAP he/she is writing for.

Okay, so I will update the ON/ONLP/RET/OFF voltage level calculations to
use a PMIC specific function for the voltage level calculation, and use
a minimum value defined in vc_param, and select a voltage from PMIC
point that is at least this value, whatever weirdness would be added by
the PMIC. I can probably re-use something from the uv_to_vsel
implementations for example.

> 
> >> > +};
> >> > +
> >> >  #define OMAP4430_VDD_CORE_OPP50_UV             1025000
> >> >  #define OMAP4430_VDD_CORE_OPP100_UV            1200000
> >> >
> >> > @@ -64,6 +93,17 @@ struct omap_volt_data omap44xx_vdd_core_volt_data[] = {
> >> >        VOLT_DATA_DEFINE(0, 0, 0, 0),
> >> >  };
> >> >
> >> > +struct omap_vp_param omap44xx_core_vp_data = {
> >> > +       .vddmin                 = OMAP4_VP_CORE_VLIMITTO_VDDMIN,
> >> > +       .vddmax                 = OMAP4_VP_CORE_VLIMITTO_VDDMAX,
> >> > +};
> >> > +
> >> > +struct omap_vc_param omap44xx_core_vc_data = {
> >> > +       .on                     = OMAP4_ON_VOLTAGE_UV,
> >> > +       .onlp                   = OMAP4_ONLP_VOLTAGE_UV,
> >> > +       .ret                    = OMAP4_RET_VOLTAGE_UV,
> >> > +       .off                    = OMAP4_OFF_VOLTAGE_UV,
> >> > +};
> >>
> >> NOTE: we will be reaching all combinations ahead - in time to come
> >> ahead we will have 4470 as well - linking this to opp data seems wrong
> >> to me..
> >
> > They are not really that much linked to opp data, they are just defined
> > in this file. The actual attach to voltdm is done in
> > voltagedomainsxxxx_data.c file, where we can link data to whatever
> > voltagedomain we want to. See for example voltagedomains3xxx_data.c what
> > is done for omap34xx vs. omap36xx. Should we move this data over there
> > then...?
> I think it belongs to VP/VC data and not in OPP file (which was meant
> for OPPs in the first place).
> we might want to think about replacing these with device tree data
> someday - OPP data makes it
> kinda hard to distinguish IMHO when we do that.

Oh yea, vc_xxxxdata would be the most logical location for it now, I'll
move it there in the next version of the series.

-Tero

> 
> Regards,
> Nishanth Menon



^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 04/15] omap4: add pmic startup / shutdown times
  2011-11-30 12:20       ` Menon, Nishanth
@ 2011-11-30 13:08         ` Tero Kristo
  0 siblings, 0 replies; 43+ messages in thread
From: Tero Kristo @ 2011-11-30 13:08 UTC (permalink / raw)
  To: Menon, Nishanth; +Cc: linux-omap, khilman

On Wed, 2011-11-30 at 06:20 -0600, Menon, Nishanth wrote:
> On Wed, Nov 30, 2011 at 03:45, Tero Kristo <t-kristo@ti.com> wrote:
> >
> > On Tue, 2011-11-29 at 12:30 -0600, Menon, Nishanth wrote:
> > > On Fri, Nov 25, 2011 at 09:49, Tero Kristo <t-kristo@ti.com> wrote:
> > > > Both startup and shutdown take 500us at maximum, value taken from
> > > > TWL6030 data manual.
> Might be good to add reference version as well for traceability.

Good point.

> 
> > > >
> > > > Signed-off-by: Tero Kristo <t-kristo@ti.com>
> > > > ---
> > > >  arch/arm/mach-omap2/omap_twl.c |    2 ++
> > > >  1 files changed, 2 insertions(+), 0 deletions(-)
> > > >
> > > > diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c
> > > > index 62ed050..bd99328 100644
> > > > --- a/arch/arm/mach-omap2/omap_twl.c
> > > > +++ b/arch/arm/mach-omap2/omap_twl.c
> > > > @@ -207,6 +207,8 @@ static struct omap_voltdm_pmic omap4_iva_pmic = {
> > > >  static struct omap_voltdm_pmic omap4_core_pmic = {
> > > >        .slew_rate              = 4000,
> > > >        .step_size              = 12660,
> > > > +       .startup_time           = 500,
> > > 549?
> >
> > Where do you get 549? You looking at a different version of the DM? Or
> > are you adding something to the value?
> >
> woohoo.. welcome to TWL6030 doc hell ;)
> Data Sheet: 0.05: T on =500Usec
> *but* TRM 0.1 says T on = 500uSec for SMPS  not freq locked, and upto
> 3ms with SMPS frequency locked).
> *then* Functional spec rev 0.12 says "Enable VCORE[1,2,3] = 549uSec.

Oh yea, thats great. Well, lets see what the design team says what we
should actually use. :)

-Tero



^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 01/15] OMAP3+: PM: VP: use uV for max and min voltage limits
  2011-11-25 15:49 ` [PATCHv4 01/15] OMAP3+: PM: VP: use uV for max and min voltage limits Tero Kristo
@ 2011-12-09 18:07   ` Kevin Hilman
  2011-12-12  9:39     ` Tero Kristo
  0 siblings, 1 reply; 43+ messages in thread
From: Kevin Hilman @ 2011-12-09 18:07 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap, nm, Vishwanath BS

Tero Kristo <t-kristo@ti.com> writes:

> From: Nishanth Menon <nm@ti.com>
>
> Every PMIC has it's own eccentricities, For example, one of the
> PMIC has MSB set to 1 for a specific function - voltage enable!
> using an hardcoded value specific for TWL when copied over to
> such an implementation causes the system to crash as the MSB bit
> was 0 and the voltage got disabled!.
>
> Instead we use actual values and depend on the convertion routines
> to abstract out the eccentricities of each PMIC.
>
> With this, we can now move the voltages to a common location in
> voltage.h as they are no longer dependent on PMICs and expect the
> PMIC's conversion routines to set a cap if the voltage is out of
> reach for the PMIC.

Nice.

> Reported-by: Jon Hunter <jon-hunter@ti.com>
> Signed-off-by: Nishanth Menon <nm@ti.com>
> Signed-off-by: Vishwanath BS <vishwanath.bs@ti.com>

Also needs your sign-off, since you're on the delivery path now.

Kevin

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 05/15] omap: add support for oscillator setup
  2011-11-25 15:49 ` [PATCHv4 05/15] omap: add support for oscillator setup Tero Kristo
@ 2011-12-09 18:27   ` Kevin Hilman
  2011-12-12  9:40     ` Tero Kristo
  0 siblings, 1 reply; 43+ messages in thread
From: Kevin Hilman @ 2011-12-09 18:27 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap, nm

Tero Kristo <t-kristo@ti.com> writes:

> This contains startup and shutdown times for the oscillator. By default
> use MAX_INT. 

nit: code uses ULONG_MAX

> Oscillator setup is used for calculating and setting up
> latencies for sleep modes that disable oscillator.
>
> Signed-off-by: Tero Kristo <t-kristo@ti.com>

Otherwise, looks fine.

Kevin

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 10/15] omap: beagle: set oscillator startup time to 10ms for rev c4
  2011-11-25 15:49 ` [PATCHv4 10/15] omap: beagle: set oscillator startup time to 10ms for rev c4 Tero Kristo
@ 2011-12-09 19:11   ` Kevin Hilman
  2011-12-12  9:42     ` Tero Kristo
  0 siblings, 1 reply; 43+ messages in thread
From: Kevin Hilman @ 2011-12-09 19:11 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap, nm

Tero Kristo <t-kristo@ti.com> writes:

> Based on the oscillator datasheet for this device.
>
> Signed-off-by: Tero Kristo <t-kristo@ti.com>
> ---
>  arch/arm/mach-omap2/board-omap3beagle.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
> index a7c3d60..5e3f575 100644
> --- a/arch/arm/mach-omap2/board-omap3beagle.c
> +++ b/arch/arm/mach-omap2/board-omap3beagle.c
> @@ -516,6 +516,9 @@ static void __init beagle_opp_init(void)
>  			opp_disable(mpu_dev, 720000000);
>  			opp_disable(iva_dev, 520000000);
>  		}
> +
> +		/* Setup oscillator startup time to 10ms */
> +		omap_pm_setup_oscillator(10000, 0);
>  	}

...but shutdown time is probably not zero. :)

This should probably be -1, or ULONG_MAX.

Yes, I see that tshut isn't even used on OMAP3, so it doesn't matter,
but it does help readability IMO.

Kevin

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 11/15] omap3+: voltage/pwrdm/clkdm/clock add recursive usecount tracking
  2011-11-25 15:49 ` [PATCHv4 11/15] omap3+: voltage/pwrdm/clkdm/clock add recursive usecount tracking Tero Kristo
  2011-11-30  9:52   ` Jean Pihet
@ 2011-12-09 19:37   ` Kevin Hilman
  2011-12-12  9:45     ` Tero Kristo
  1 sibling, 1 reply; 43+ messages in thread
From: Kevin Hilman @ 2011-12-09 19:37 UTC (permalink / raw)
  To: Tero Kristo, Paul Walmsley; +Cc: linux-omap, nm

+Paul

Tero Kristo <t-kristo@ti.com> writes:

> This patch fixes the usecount tracking for omap3+, previously the
> usecount numbers were rather bogus and were not really useful for
> any purpose. Now usecount numbers track the number of really active
> clients on each domain. 

Excellent!  

This dramatically improves the usefulness of <debugfs>/pm_debug/count.
Adding the voltage domains to that debugfs would help even more.

Also, the changelog should be a bit more verbose about the new clk->autoidle
field, it's usage, and how it affects usecounting.  

Speaking of debugfs: not a requirement for this series, but another
"nice to have" (which you can do while waiting for the slow maintainers
to review :) would be for this debugfs to show the clkdomains under the
powerdomains they are in, and the powerdomains under the voltage domains
(instead of the current list of pwrdms followed by clkdms.)  Maybe using
voltdm_for_each_pwrdm() + pwrdm_for_each_clkdm() might help there.

> This patch also adds support for usecount tracking on powerdomain and
> voltagedomain levels.

The clock/clkdm/pwrdm changes should probably be split separate patch
for review/merge by Paul.  Then the voltdm changes can included in this
series.  Although, with Paul's ack on the clock/clkdm/powerdomain
changes, I'll be happy to queue this as well.

[...]

> diff --git a/arch/arm/plat-omap/include/plat/clock.h b/arch/arm/plat-omap/include/plat/clock.h
> index df4b968..f18dd5f 100644
> --- a/arch/arm/plat-omap/include/plat/clock.h
> +++ b/arch/arm/plat-omap/include/plat/clock.h
> @@ -254,6 +254,7 @@ struct clk {
>  	void			(*init)(struct clk *);
>  	u8			enable_bit;
>  	s8			usecount;
> +	u8			autoidle;

should be bool, and assignments using true | false.

Kevin

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 12/15] vc: omap3: auto_ret / auto_off support
  2011-11-25 15:49 ` [PATCHv4 12/15] vc: omap3: auto_ret / auto_off support Tero Kristo
@ 2011-12-09 20:13   ` Kevin Hilman
  2011-12-12  9:53     ` Tero Kristo
  0 siblings, 1 reply; 43+ messages in thread
From: Kevin Hilman @ 2011-12-09 20:13 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap, nm

Tero Kristo <t-kristo@ti.com> writes:

> Voltage code will now enable / disable auto_ret / auto_off dynamically
> according to the voltagedomain usecounts. This is accomplished via
> the usage of the voltdm callback functions for sleep / wakeup.
>
> Signed-off-by: Tero Kristo <t-kristo@ti.com>

[...]

> -static void __init omap3_vc_init_channel(struct voltagedomain *voltdm)
> +static void omap3_set_core_off_timings(struct voltagedomain *voltdm)
>  {
> +	u32 tstart, tshut;

nit: insert blank line here

> +	omap_pm_get_oscillator(&tstart, &tshut);
> +	omap3_set_clksetup(tstart, voltdm);
>  	omap3_set_off_timings(voltdm);
>  }
>  
> +static void omap3_vc_channel_sleep(struct voltagedomain *voltdm)
> +{
> +	/* Set off timings if entering off */
> +	if (voltdm->target_state == PWRDM_POWER_OFF)
> +		omap3_set_off_timings(voltdm);
> +	else
> +		omap3_set_i2c_timings(voltdm, 0);

Comment probably applies more to patch 2 since that's where it was
introduced, but this is where I got confused, so mentioning it here:

Calling this 'set_i2c_timings' is a bit confusing IMO because reading
the code there is a choice between 'i2c' timings and 'off' timings.
Maybe just calling these 'ret' and 'off' timings will be better for
readability.

> +}
> +
> +static void omap3_vc_channel_wakeup(struct voltagedomain *voltdm)
> +{
> +}

nit: empty function not needed since code checks for non-NULL function
pointer.

> +static void omap3_vc_core_sleep(struct voltagedomain *voltdm)
> +{
> +	u8 mode;
> +
> +	switch (voltdm->target_state) {
> +	case PWRDM_POWER_OFF:
> +		mode = OMAP3430_AUTO_OFF_MASK;
> +		break;
> +	case PWRDM_POWER_RET:
> +		mode = OMAP3430_AUTO_RET_MASK;
> +		break;
> +	default:
> +		mode = OMAP3430_AUTO_SLEEP_MASK;
> +		break;
> +	}
> +
> +	if (mode & OMAP3430_AUTO_OFF_MASK)

AND vs. == ?

speaking of which, this function probably needs a comment mentioning
that these bits are all mutually exclusive (with a TRM reference.)

> +		omap3_set_core_off_timings(voltdm);
> +	else
> +		omap3_set_core_ret_timings(voltdm);
> +
> +	voltdm->rmw(OMAP3430_AUTO_OFF_MASK | OMAP3430_AUTO_RET_MASK |
> +		    OMAP3430_AUTO_SLEEP_MASK, mode,
> +		    OMAP3_PRM_VOLTCTRL_OFFSET);
> +}

Kevin

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support
  2011-11-25 15:49 [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support Tero Kristo
                   ` (15 preceding siblings ...)
  2011-11-30 10:06 ` [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support Jean Pihet
@ 2011-12-09 20:23 ` Kevin Hilman
  2011-12-12  9:38   ` Tero Kristo
  16 siblings, 1 reply; 43+ messages in thread
From: Kevin Hilman @ 2011-12-09 20:23 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap, nm

Hi Tero,

Tero Kristo <t-kristo@ti.com> writes:

> Changes compared to previous version:
>
> - merged most of the voltagedomain cleanup fixes to patch 2
> - moved pmic latencies to omap_voltdm_pmic struct
> - renamed omap_lp_params to omap2_oscillator as it only contains
>   osc info now
> - major changes to usecount support (patch 11+, needed for auto-ret)
>   * added usecounts to voltagedomain / powerdomain
>   * fixed usecount tracking so that the numbers are sane now
>   * changed behavior of some usecounting sources that they do not
>     update the counts (autoidle support)
> - added auto-ret / auto-off support, based on fixed usecounting
>   * smartreflex disabled / enabled
>   * auto-ret / auto-off enabled based on target state
> - some other minor tweaks I have probably forgotten to mention

This series is looking really good.  Thanks!

One thing I'd like to see is a bit more comments.  Particularily, the
new functions in the VC core need kerneldoc comments and verbose
descriptions.

The differences in timing setups between retention and off are not
obvious when reading the code (and are easily forgotten).  They also
equire a bit of TRM (re)reading to understand what's going on.  Some
summary comments in the code, along with TRM references would be most
helpful so when coming back to this code in a few months or more, we can
easily remember what's going on (or at least where to look.)  Thanks.

> Tested on omap3 beagle:
> - voltages for vdd1 and vdd2 change when entering idle
> - both suspend and dynamic idle tested
> - tested that voltages reach target levels for both ret / off
>
> Tested on omap4 blaze with custom kernel
> - this requires a few additional patches missing from this set as
>   omap4 PM support is still not merged

MPUSS support is now queued (in Tony's tree), but CORE PM is still
missing.

> - will post missing patches once possible from upstream point of view
> - voltages for vdd1 and vdd3 change when entering idle
>
> Applies on top of Kevin's for_3.2/voltage-cleanup branch.

You can use mainline now as that branch is merged.

Also, please Cc linux-arm-kernel on future versions of this series.

Thanks,

Kevin

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support
  2011-12-09 20:23 ` Kevin Hilman
@ 2011-12-12  9:38   ` Tero Kristo
  0 siblings, 0 replies; 43+ messages in thread
From: Tero Kristo @ 2011-12-12  9:38 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: linux-omap, nm

On Fri, 2011-12-09 at 12:23 -0800, Kevin Hilman wrote:
> Hi Tero,
> 
> Tero Kristo <t-kristo@ti.com> writes:
> 
> > Changes compared to previous version:
> >
> > - merged most of the voltagedomain cleanup fixes to patch 2
> > - moved pmic latencies to omap_voltdm_pmic struct
> > - renamed omap_lp_params to omap2_oscillator as it only contains
> >   osc info now
> > - major changes to usecount support (patch 11+, needed for auto-ret)
> >   * added usecounts to voltagedomain / powerdomain
> >   * fixed usecount tracking so that the numbers are sane now
> >   * changed behavior of some usecounting sources that they do not
> >     update the counts (autoidle support)
> > - added auto-ret / auto-off support, based on fixed usecounting
> >   * smartreflex disabled / enabled
> >   * auto-ret / auto-off enabled based on target state
> > - some other minor tweaks I have probably forgotten to mention
> 
> This series is looking really good.  Thanks!
> 
> One thing I'd like to see is a bit more comments.  Particularily, the
> new functions in the VC core need kerneldoc comments and verbose
> descriptions.
> 
> The differences in timing setups between retention and off are not
> obvious when reading the code (and are easily forgotten).  They also
> equire a bit of TRM (re)reading to understand what's going on.  Some
> summary comments in the code, along with TRM references would be most
> helpful so when coming back to this code in a few months or more, we can
> easily remember what's going on (or at least where to look.)  Thanks.
> 

Okay, I'll try to figure out more comments on next rev. This has never
been too strong point in the code I write I guess. :)

> > Tested on omap3 beagle:
> > - voltages for vdd1 and vdd2 change when entering idle
> > - both suspend and dynamic idle tested
> > - tested that voltages reach target levels for both ret / off
> >
> > Tested on omap4 blaze with custom kernel
> > - this requires a few additional patches missing from this set as
> >   omap4 PM support is still not merged
> 
> MPUSS support is now queued (in Tony's tree), but CORE PM is still
> missing.

I can take a look at this part also, but CORE PM is needed for this set
for testing purposes I believe, otherwise the auto-ret part does nothing
and is rather impossible to test (not sure if mpu part scales without
CORE PM, it might actually.)

> 
> > - will post missing patches once possible from upstream point of view
> > - voltages for vdd1 and vdd3 change when entering idle
> >
> > Applies on top of Kevin's for_3.2/voltage-cleanup branch.
> 
> You can use mainline now as that branch is merged.

Ah okay, good to know.

> 
> Also, please Cc linux-arm-kernel on future versions of this series.

Can do.

-Tero



^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 01/15] OMAP3+: PM: VP: use uV for max and min voltage limits
  2011-12-09 18:07   ` Kevin Hilman
@ 2011-12-12  9:39     ` Tero Kristo
  0 siblings, 0 replies; 43+ messages in thread
From: Tero Kristo @ 2011-12-12  9:39 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: linux-omap, nm, Vishwanath BS

On Fri, 2011-12-09 at 10:07 -0800, Kevin Hilman wrote:
> Tero Kristo <t-kristo@ti.com> writes:
> 
> > From: Nishanth Menon <nm@ti.com>
> >
> > Every PMIC has it's own eccentricities, For example, one of the
> > PMIC has MSB set to 1 for a specific function - voltage enable!
> > using an hardcoded value specific for TWL when copied over to
> > such an implementation causes the system to crash as the MSB bit
> > was 0 and the voltage got disabled!.
> >
> > Instead we use actual values and depend on the convertion routines
> > to abstract out the eccentricities of each PMIC.
> >
> > With this, we can now move the voltages to a common location in
> > voltage.h as they are no longer dependent on PMICs and expect the
> > PMIC's conversion routines to set a cap if the voltage is out of
> > reach for the PMIC.
> 
> Nice.
> 
> > Reported-by: Jon Hunter <jon-hunter@ti.com>
> > Signed-off-by: Nishanth Menon <nm@ti.com>
> > Signed-off-by: Vishwanath BS <vishwanath.bs@ti.com>
> 
> Also needs your sign-off, since you're on the delivery path now.

Oh sorry about that, I'll add it.

-Tero



^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 05/15] omap: add support for oscillator setup
  2011-12-09 18:27   ` Kevin Hilman
@ 2011-12-12  9:40     ` Tero Kristo
  0 siblings, 0 replies; 43+ messages in thread
From: Tero Kristo @ 2011-12-12  9:40 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: linux-omap, nm

On Fri, 2011-12-09 at 10:27 -0800, Kevin Hilman wrote:
> Tero Kristo <t-kristo@ti.com> writes:
> 
> > This contains startup and shutdown times for the oscillator. By default
> > use MAX_INT. 
> 
> nit: code uses ULONG_MAX

Oops, will fix the comment.

> 
> > Oscillator setup is used for calculating and setting up
> > latencies for sleep modes that disable oscillator.
> >
> > Signed-off-by: Tero Kristo <t-kristo@ti.com>
> 
> Otherwise, looks fine.
> 
> Kevin



^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 10/15] omap: beagle: set oscillator startup time to 10ms for rev c4
  2011-12-09 19:11   ` Kevin Hilman
@ 2011-12-12  9:42     ` Tero Kristo
  0 siblings, 0 replies; 43+ messages in thread
From: Tero Kristo @ 2011-12-12  9:42 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: linux-omap, nm

On Fri, 2011-12-09 at 11:11 -0800, Kevin Hilman wrote:
> Tero Kristo <t-kristo@ti.com> writes:
> 
> > Based on the oscillator datasheet for this device.
> >
> > Signed-off-by: Tero Kristo <t-kristo@ti.com>
> > ---
> >  arch/arm/mach-omap2/board-omap3beagle.c |    3 +++
> >  1 files changed, 3 insertions(+), 0 deletions(-)
> >
> > diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
> > index a7c3d60..5e3f575 100644
> > --- a/arch/arm/mach-omap2/board-omap3beagle.c
> > +++ b/arch/arm/mach-omap2/board-omap3beagle.c
> > @@ -516,6 +516,9 @@ static void __init beagle_opp_init(void)
> >  			opp_disable(mpu_dev, 720000000);
> >  			opp_disable(iva_dev, 520000000);
> >  		}
> > +
> > +		/* Setup oscillator startup time to 10ms */
> > +		omap_pm_setup_oscillator(10000, 0);
> >  	}
> 
> ...but shutdown time is probably not zero. :)
> 
> This should probably be -1, or ULONG_MAX.
> 
> Yes, I see that tshut isn't even used on OMAP3, so it doesn't matter,
> but it does help readability IMO.

Exactly the reason it was set as zero... I'll think of something for the
next rev for this. Maybe use -1 as you suggested (and add a comment), it
is not going to break anything.

-Tero


^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 11/15] omap3+: voltage/pwrdm/clkdm/clock add recursive usecount tracking
  2011-12-09 19:37   ` Kevin Hilman
@ 2011-12-12  9:45     ` Tero Kristo
  0 siblings, 0 replies; 43+ messages in thread
From: Tero Kristo @ 2011-12-12  9:45 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: Paul Walmsley, linux-omap, nm

On Fri, 2011-12-09 at 11:37 -0800, Kevin Hilman wrote:
> +Paul
> 
> Tero Kristo <t-kristo@ti.com> writes:
> 
> > This patch fixes the usecount tracking for omap3+, previously the
> > usecount numbers were rather bogus and were not really useful for
> > any purpose. Now usecount numbers track the number of really active
> > clients on each domain. 
> 
> Excellent!  
> 
> This dramatically improves the usefulness of <debugfs>/pm_debug/count.
> Adding the voltage domains to that debugfs would help even more.
> 
> Also, the changelog should be a bit more verbose about the new clk->autoidle
> field, it's usage, and how it affects usecounting.  

Okay, will try to add some more beef here.

> 
> Speaking of debugfs: not a requirement for this series, but another
> "nice to have" (which you can do while waiting for the slow maintainers
> to review :) would be for this debugfs to show the clkdomains under the
> powerdomains they are in, and the powerdomains under the voltage domains
> (instead of the current list of pwrdms followed by clkdms.)  Maybe using
> voltdm_for_each_pwrdm() + pwrdm_for_each_clkdm() might help there.

Yea, I have used something close to this myself for testing purposes, I
can maybe add something for this in next version.

> 
> > This patch also adds support for usecount tracking on powerdomain and
> > voltagedomain levels.
> 
> The clock/clkdm/pwrdm changes should probably be split separate patch
> for review/merge by Paul.  Then the voltdm changes can included in this
> series.  Although, with Paul's ack on the clock/clkdm/powerdomain
> changes, I'll be happy to queue this as well.

Okay, will wait for Paul's comment on this.

> 
> [...]
> 
> > diff --git a/arch/arm/plat-omap/include/plat/clock.h b/arch/arm/plat-omap/include/plat/clock.h
> > index df4b968..f18dd5f 100644
> > --- a/arch/arm/plat-omap/include/plat/clock.h
> > +++ b/arch/arm/plat-omap/include/plat/clock.h
> > @@ -254,6 +254,7 @@ struct clk {
> >  	void			(*init)(struct clk *);
> >  	u8			enable_bit;
> >  	s8			usecount;
> > +	u8			autoidle;
> 
> should be bool, and assignments using true | false.

Yea can change that one.

-Tero


^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 12/15] vc: omap3: auto_ret / auto_off support
  2011-12-09 20:13   ` Kevin Hilman
@ 2011-12-12  9:53     ` Tero Kristo
  2011-12-12 15:05       ` Kevin Hilman
  0 siblings, 1 reply; 43+ messages in thread
From: Tero Kristo @ 2011-12-12  9:53 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: linux-omap, nm

On Fri, 2011-12-09 at 12:13 -0800, Kevin Hilman wrote:
> Tero Kristo <t-kristo@ti.com> writes:
> 
> > Voltage code will now enable / disable auto_ret / auto_off dynamically
> > according to the voltagedomain usecounts. This is accomplished via
> > the usage of the voltdm callback functions for sleep / wakeup.
> >
> > Signed-off-by: Tero Kristo <t-kristo@ti.com>
> 
> [...]
> 
> > -static void __init omap3_vc_init_channel(struct voltagedomain *voltdm)
> > +static void omap3_set_core_off_timings(struct voltagedomain *voltdm)
> >  {
> > +	u32 tstart, tshut;
> 
> nit: insert blank line here

Okay.

> 
> > +	omap_pm_get_oscillator(&tstart, &tshut);
> > +	omap3_set_clksetup(tstart, voltdm);
> >  	omap3_set_off_timings(voltdm);
> >  }
> >  
> > +static void omap3_vc_channel_sleep(struct voltagedomain *voltdm)
> > +{
> > +	/* Set off timings if entering off */
> > +	if (voltdm->target_state == PWRDM_POWER_OFF)
> > +		omap3_set_off_timings(voltdm);
> > +	else
> > +		omap3_set_i2c_timings(voltdm, 0);
> 
> Comment probably applies more to patch 2 since that's where it was
> introduced, but this is where I got confused, so mentioning it here:
> 
> Calling this 'set_i2c_timings' is a bit confusing IMO because reading
> the code there is a choice between 'i2c' timings and 'off' timings.
> Maybe just calling these 'ret' and 'off' timings will be better for
> readability.

Well, actually, you can use i2c timings when scaling voltage to off
level also. You have following options for voltage scaling on omap3:

- scale to ret level (0.975V) using i2c command
- scale to off level (0.6V) using i2c command
- switch to off (0V) using pmic scripts

I was kind of trying to reflect this here, even though the pmic script
support is missing.

> 
> > +}
> > +
> > +static void omap3_vc_channel_wakeup(struct voltagedomain *voltdm)
> > +{
> > +}
> 
> nit: empty function not needed since code checks for non-NULL function
> pointer.

Yea can drop that away, I left it there because I thought it might need
some beef in it at some point.

> 
> > +static void omap3_vc_core_sleep(struct voltagedomain *voltdm)
> > +{
> > +	u8 mode;
> > +
> > +	switch (voltdm->target_state) {
> > +	case PWRDM_POWER_OFF:
> > +		mode = OMAP3430_AUTO_OFF_MASK;
> > +		break;
> > +	case PWRDM_POWER_RET:
> > +		mode = OMAP3430_AUTO_RET_MASK;
> > +		break;
> > +	default:
> > +		mode = OMAP3430_AUTO_SLEEP_MASK;
> > +		break;
> > +	}
> > +
> > +	if (mode & OMAP3430_AUTO_OFF_MASK)
> 
> AND vs. == ?

Oh yea, some strange logic here for sure, I'll change that to ==. :)

> 
> speaking of which, this function probably needs a comment mentioning
> that these bits are all mutually exclusive (with a TRM reference.)

Can add that too.

-Tero



^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCHv4 12/15] vc: omap3: auto_ret / auto_off support
  2011-12-12  9:53     ` Tero Kristo
@ 2011-12-12 15:05       ` Kevin Hilman
  0 siblings, 0 replies; 43+ messages in thread
From: Kevin Hilman @ 2011-12-12 15:05 UTC (permalink / raw)
  To: t-kristo; +Cc: linux-omap, nm

Tero Kristo <t-kristo@ti.com> writes:

> On Fri, 2011-12-09 at 12:13 -0800, Kevin Hilman wrote:
>> Tero Kristo <t-kristo@ti.com> writes:
>> 
>> > Voltage code will now enable / disable auto_ret / auto_off dynamically
>> > according to the voltagedomain usecounts. This is accomplished via
>> > the usage of the voltdm callback functions for sleep / wakeup.
>> >
>> > Signed-off-by: Tero Kristo <t-kristo@ti.com>
>> 
>> [...]
>> 
>> > -static void __init omap3_vc_init_channel(struct voltagedomain *voltdm)
>> > +static void omap3_set_core_off_timings(struct voltagedomain *voltdm)
>> >  {
>> > +	u32 tstart, tshut;
>> 
>> nit: insert blank line here
>
> Okay.
>
>> 
>> > +	omap_pm_get_oscillator(&tstart, &tshut);
>> > +	omap3_set_clksetup(tstart, voltdm);
>> >  	omap3_set_off_timings(voltdm);
>> >  }
>> >  
>> > +static void omap3_vc_channel_sleep(struct voltagedomain *voltdm)
>> > +{
>> > +	/* Set off timings if entering off */
>> > +	if (voltdm->target_state == PWRDM_POWER_OFF)
>> > +		omap3_set_off_timings(voltdm);
>> > +	else
>> > +		omap3_set_i2c_timings(voltdm, 0);
>> 
>> Comment probably applies more to patch 2 since that's where it was
>> introduced, but this is where I got confused, so mentioning it here:
>> 
>> Calling this 'set_i2c_timings' is a bit confusing IMO because reading
>> the code there is a choice between 'i2c' timings and 'off' timings.
>> Maybe just calling these 'ret' and 'off' timings will be better for
>> readability.
>
> Well, actually, you can use i2c timings when scaling voltage to off
> level also. You have following options for voltage scaling on omap3:
>
> - scale to ret level (0.975V) using i2c command
> - scale to off level (0.6V) using i2c command
> - switch to off (0V) using pmic scripts
>
> I was kind of trying to reflect this here, even though the pmic script
> support is missing.
>

OK, makes sense now.   Being more vebose in the changelog, or better,
having verbose kernel comments for the functions would help here.

Kevin

^ permalink raw reply	[flat|nested] 43+ messages in thread

end of thread, other threads:[~2011-12-12 15:05 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-25 15:49 [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support Tero Kristo
2011-11-25 15:49 ` [PATCHv4 01/15] OMAP3+: PM: VP: use uV for max and min voltage limits Tero Kristo
2011-12-09 18:07   ` Kevin Hilman
2011-12-12  9:39     ` Tero Kristo
2011-11-25 15:49 ` [PATCHv4 02/15] omap3+: voltage: parameter segregation Tero Kristo
2011-11-29 18:26   ` Menon, Nishanth
2011-11-30 10:07     ` Tero Kristo
2011-11-30 12:31       ` Menon, Nishanth
2011-11-30 13:04         ` Tero Kristo
2011-11-30 10:11   ` Jean Pihet
2011-11-25 15:49 ` [PATCHv4 03/15] omap: voltage: add definition for pmic startup / shutdown times Tero Kristo
2011-11-25 15:49 ` [PATCHv4 04/15] omap4: add " Tero Kristo
2011-11-29 18:30   ` Menon, Nishanth
2011-11-30  9:45     ` Tero Kristo
2011-11-30 12:20       ` Menon, Nishanth
2011-11-30 13:08         ` Tero Kristo
2011-11-25 15:49 ` [PATCHv4 05/15] omap: add support for oscillator setup Tero Kristo
2011-12-09 18:27   ` Kevin Hilman
2011-12-12  9:40     ` Tero Kristo
2011-11-25 15:49 ` [PATCHv4 06/15] omap3+: vp: use new vp_params for calculating vddmin and vddmax Tero Kristo
2011-11-29 18:34   ` Menon, Nishanth
2011-11-25 15:49 ` [PATCHv4 07/15] omap3+: voltage: use oscillator data to calculate setup times Tero Kristo
2011-11-25 15:49 ` [PATCHv4 08/15] omap4: use pmic params for calculating pmic " Tero Kristo
2011-11-25 15:49 ` [PATCHv4 09/15] TEMP: OMAP3: beagle rev-c4: enable OPP6 Tero Kristo
2011-11-25 15:49 ` [PATCHv4 10/15] omap: beagle: set oscillator startup time to 10ms for rev c4 Tero Kristo
2011-12-09 19:11   ` Kevin Hilman
2011-12-12  9:42     ` Tero Kristo
2011-11-25 15:49 ` [PATCHv4 11/15] omap3+: voltage/pwrdm/clkdm/clock add recursive usecount tracking Tero Kristo
2011-11-30  9:52   ` Jean Pihet
2011-11-30 10:11     ` Tero Kristo
2011-12-09 19:37   ` Kevin Hilman
2011-12-12  9:45     ` Tero Kristo
2011-11-25 15:49 ` [PATCHv4 12/15] vc: omap3: auto_ret / auto_off support Tero Kristo
2011-12-09 20:13   ` Kevin Hilman
2011-12-12  9:53     ` Tero Kristo
2011-12-12 15:05       ` Kevin Hilman
2011-11-25 15:49 ` [PATCHv4 13/15] omap3: fix usecount tracking Tero Kristo
2011-11-25 15:49 ` [PATCHv4 14/15] omap3: voltage: fix channel configuration Tero Kristo
2011-11-25 15:49 ` [PATCHv4 15/15] omap: pm: wait for domain wakeup if changing state of idle domain Tero Kristo
2011-11-30 10:06 ` [PATCHv4 00/15] voltdm cleanup + auto-ret / auto-off support Jean Pihet
2011-11-30 10:19   ` Tero Kristo
2011-12-09 20:23 ` Kevin Hilman
2011-12-12  9:38   ` Tero Kristo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.