public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCHv3 00/11] voltage domain cleanup
@ 2011-10-05 17:17 Tero Kristo
  2011-10-05 17:17 ` [PATCHv3 01/11] OMAP3+: PM: VP: use uV for max and min voltage limits Tero Kristo
                   ` (10 more replies)
  0 siblings, 11 replies; 24+ messages in thread
From: Tero Kristo @ 2011-10-05 17:17 UTC (permalink / raw)
  To: linux-omap

This set contains following changes compared to v2:

- split into several patches for easier handling
- added a couple of patches from Nishanth Menon (01, 05)
- vddmin / vddmax are now defined for both pmic and omap, max of vddmin and
  min of vddmax is used
- clock setup / pmic setup times calculated from lp params (patch 10, 11)

Todo:
- figure out a way to configure ramp times based on sleep mode (callbacks
  from pm34xx / pm44xx files?)
- add oscillator and pmic ramp times for omap3
- add oscillator ramp times for omap4

Misc notes:
- Applies on top of Kevin's old pm-wip/voltdm branch
- Tested on OMAP3 beagle

-Tero


Texas Instruments Oy, Porkkalankatu 22, 00180 Helsinki, Finland. Business ID: 0115040-6. Domicile: Helsinki
 


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

* [PATCHv3 01/11] OMAP3+: PM: VP: use uV for max and min voltage limits
  2011-10-05 17:17 [PATCHv3 00/11] voltage domain cleanup Tero Kristo
@ 2011-10-05 17:17 ` Tero Kristo
  2011-10-05 17:17 ` [PATCHv3 02/11] omap: voltage: add definitions for omap_vp_param and omap_vc_param Tero Kristo
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 24+ messages in thread
From: Tero Kristo @ 2011-10-05 17:17 UTC (permalink / raw)
  To: linux-omap; +Cc: Nishanth Menon, 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 b4c6259..1577c2f 100644
--- a/arch/arm/mach-omap2/voltage.h
+++ b/arch/arm/mach-omap2/voltage.h
@@ -107,6 +107,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)
@@ -130,8 +148,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


Texas Instruments Oy, Porkkalankatu 22, 00180 Helsinki, Finland. Business ID: 0115040-6. Domicile: Helsinki
 


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

* [PATCHv3 02/11] omap: voltage: add definitions for omap_vp_param and omap_vc_param
  2011-10-05 17:17 [PATCHv3 00/11] voltage domain cleanup Tero Kristo
  2011-10-05 17:17 ` [PATCHv3 01/11] OMAP3+: PM: VP: use uV for max and min voltage limits Tero Kristo
@ 2011-10-05 17:17 ` Tero Kristo
  2011-10-05 17:17 ` [PATCHv3 03/11] omap3: add vp and vc parameter data Tero Kristo
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 24+ messages in thread
From: Tero Kristo @ 2011-10-05 17:17 UTC (permalink / raw)
  To: linux-omap

These are used to contain omap specific minimum and maximum voltages
for domains, and also operating voltages for different power modes.

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

diff --git a/arch/arm/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h
index 1577c2f..92cbc67 100644
--- a/arch/arm/mach-omap2/voltage.h
+++ b/arch/arm/mach-omap2/voltage.h
@@ -70,6 +70,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);
@@ -137,10 +139,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;
@@ -157,6 +155,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,
-- 
1.7.4.1


Texas Instruments Oy, Porkkalankatu 22, 00180 Helsinki, Finland. Business ID: 0115040-6. Domicile: Helsinki
 


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

* [PATCHv3 03/11] omap3: add vp and vc parameter data
  2011-10-05 17:17 [PATCHv3 00/11] voltage domain cleanup Tero Kristo
  2011-10-05 17:17 ` [PATCHv3 01/11] OMAP3+: PM: VP: use uV for max and min voltage limits Tero Kristo
  2011-10-05 17:17 ` [PATCHv3 02/11] omap: voltage: add definitions for omap_vp_param and omap_vc_param Tero Kristo
@ 2011-10-05 17:17 ` Tero Kristo
  2011-11-04 20:22   ` Kevin Hilman
  2011-10-05 17:17 ` [PATCHv3 04/11] omap4: " Tero Kristo
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 24+ messages in thread
From: Tero Kristo @ 2011-10-05 17:17 UTC (permalink / raw)
  To: linux-omap

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/omap_opp_data.h           |    9 ++++
 arch/arm/mach-omap2/opp3xxx_data.c            |   52 +++++++++++++++++++++++++
 arch/arm/mach-omap2/voltagedomains3xxx_data.c |    8 ++++
 3 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_opp_data.h b/arch/arm/mach-omap2/omap_opp_data.h
index c784c12..b940a09 100644
--- a/arch/arm/mach-omap2/omap_opp_data.h
+++ b/arch/arm/mach-omap2/omap_opp_data.h
@@ -86,8 +86,17 @@ 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[];
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/voltagedomains3xxx_data.c b/arch/arm/mach-omap2/voltagedomains3xxx_data.c
index b0d0ae1..9c907af 100644
--- a/arch/arm/mach-omap2/voltagedomains3xxx_data.c
+++ b/arch/arm/mach-omap2/voltagedomains3xxx_data.c
@@ -90,9 +90,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++)
-- 
1.7.4.1


Texas Instruments Oy, Porkkalankatu 22, 00180 Helsinki, Finland. Business ID: 0115040-6. Domicile: Helsinki
 


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

* [PATCHv3 04/11] omap4: add vp and vc parameter data
  2011-10-05 17:17 [PATCHv3 00/11] voltage domain cleanup Tero Kristo
                   ` (2 preceding siblings ...)
  2011-10-05 17:17 ` [PATCHv3 03/11] omap3: add vp and vc parameter data Tero Kristo
@ 2011-10-05 17:17 ` Tero Kristo
  2011-11-04 20:22   ` Kevin Hilman
  2011-10-05 17:17 ` [PATCHv3 05/11] OMAP2+: PM: provide mechanism to describe overall behavior of osc and PMIC Tero Kristo
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 24+ messages in thread
From: Tero Kristo @ 2011-10-05 17:17 UTC (permalink / raw)
  To: linux-omap

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/omap_opp_data.h           |    6 ++++
 arch/arm/mach-omap2/opp4xxx_data.c            |   40 +++++++++++++++++++++++++
 arch/arm/mach-omap2/voltagedomains44xx_data.c |    8 +++++
 3 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_opp_data.h b/arch/arm/mach-omap2/omap_opp_data.h
index b940a09..b5fe711 100644
--- a/arch/arm/mach-omap2/omap_opp_data.h
+++ b/arch/arm/mach-omap2/omap_opp_data.h
@@ -101,5 +101,11 @@ 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/opp4xxx_data.c b/arch/arm/mach-omap2/opp4xxx_data.c
index 2293ba2..bf37279 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			1350000
+#define OMAP4_ONLP_VOLTAGE_UV			1350000
+#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/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


Texas Instruments Oy, Porkkalankatu 22, 00180 Helsinki, Finland. Business ID: 0115040-6. Domicile: Helsinki
 


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

* [PATCHv3 05/11] OMAP2+: PM: provide mechanism to describe overall behavior of osc and PMIC.
  2011-10-05 17:17 [PATCHv3 00/11] voltage domain cleanup Tero Kristo
                   ` (3 preceding siblings ...)
  2011-10-05 17:17 ` [PATCHv3 04/11] omap4: " Tero Kristo
@ 2011-10-05 17:17 ` Tero Kristo
  2011-11-04 21:02   ` Kevin Hilman
  2011-10-05 17:17 ` [PATCHv3 06/11] omap3+: vc: use new vc_params and vp_params in parameter calculations Tero Kristo
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 24+ messages in thread
From: Tero Kristo @ 2011-10-05 17:17 UTC (permalink / raw)
  To: linux-omap; +Cc: Nishanth Menon

From: Nishanth Menon <nm@ti.com>

We currently have mechanisms in place to describe the PMIC per
rail, however we also need to configure the system for situations
such as OFF mode, where, oscillator switch off and on time, and
similar durations for PMIC also tends to play a major factor.
Introduce a few apis to OMAP2's pm framework to use these. OMAP1
does'nt seem to need this at the moment, hence not a OMAP generic
framework. The set functions are meant to be used by initialization
code.

The OMAP specific implementation would need to use this ofcourse.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-omap2/pm.c |  122 ++++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/pm.h |   18 +++++++
 2 files changed, 140 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index 659e400..e130d92 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -24,6 +24,52 @@
 #include "clockdomain.h"
 #include "pm.h"
 
+/**
+ * struct omap2_pm_lp_description - Describe low power behavior of the system
+ * @oscillator_startup_time:	Time rounded up to uSec for the oscillator to
+ *				provide a stable clock from power on.
+ * @oscillator_shutdown_time:	Time rounded up to uSec for oscillator to safely
+ *				switch off.
+ * @pmic_startup_time:		Time rounded up to uSec for the PMIC to
+ *				provide be ready for operation from low power
+ *				state. Note: this is not the same as voltage
+ *				rampup time, instead, consider the PMIC to be
+ *				in lowest power state(say OFF), this is the time
+ *				required for it to become ready for it's DCDCs
+ *				or LDOs to start operation.
+ * @pmic_shutdown_time:		Time rounded up to uSec for the PMIC to
+ *				go to low power after the LDOs are pulled to
+ *				appropriate state. Note: this is not the same as
+ *				voltage rampdown time, instead, consider the
+ *				PMIC to have switched it's LDOs down, this is
+ *				time taken to reach it's lowest power state(say
+ *				sleep/OFF).
+ *
+ * With complex systems like OMAP, we need a generic description of system
+ * behavior beyond the normal description of device/peripheral operation
+ * which in conjunction with other parameters describe and control the low
+ * power operation of the device. This information tends to be specific
+ * to every board.
+ */
+struct omap2_pm_lp_description {
+	u32 oscillator_startup_time;
+	u32 oscillator_shutdown_time;
+	u32 pmic_startup_time;
+	u32 pmic_shutdown_time;
+};
+
+/*
+ * Setup time to be the max... we want to err towards the worst
+ * as default. rest of the system can populate these with more
+ * optimal values
+ */
+static struct omap2_pm_lp_description _pm_lp_desc = {
+	.oscillator_startup_time = ULONG_MAX,
+	.oscillator_shutdown_time = ULONG_MAX,
+	.pmic_startup_time = ULONG_MAX,
+	.pmic_shutdown_time = ULONG_MAX,
+};
+
 static struct omap_device_pm_latency *pm_lats;
 
 static struct device *mpu_dev;
@@ -56,6 +102,82 @@ struct device *omap4_get_dsp_device(void)
 }
 EXPORT_SYMBOL(omap4_get_dsp_device);
 
+/**
+ * omap_pm_get_pmic_lp_time() - retrieve the oscillator time
+ * @tstart:	pointer to startup time in uSec
+ * @tshut:	pointer to shutdown time in uSec
+ *
+ * if the pointers are invalid, returns error, else
+ * populates the tstart and tshut values with the currently
+ * stored values.
+ */
+int omap_pm_get_osc_lp_time(u32 *tstart, u32 *tshut)
+{
+	if (!tstart || !tshut)
+		return -EINVAL;
+
+	*tstart = _pm_lp_desc.oscillator_startup_time;
+	*tshut = _pm_lp_desc.oscillator_shutdown_time;
+
+	return 0;
+}
+
+/**
+ * omap_pm_get_pmic_lp_time() - retrieve the PMIC time
+ * @tstart:	pointer to startup time in uSec
+ * @tshut:	pointer to shutdown time in uSec
+ *
+ * if the pointers are invalid, returns error, else
+ * populates the tstart and tshut values with the currently
+ * stored values.
+ */
+int omap_pm_get_pmic_lp_time(u32 *tstart, u32 *tshut)
+{
+	if (!tstart || !tshut)
+		return -EINVAL;
+
+	*tstart = _pm_lp_desc.pmic_startup_time;
+	*tshut = _pm_lp_desc.pmic_shutdown_time;
+
+	return 0;
+}
+
+/**
+ * omap_pm_set_osc_lp_time() - setup the system oscillator time
+ * @tstart:	startup time rounded up to uSec
+ * @tshut:	shutdown time rounded up to uSec
+ *
+ * All boards do need an oscillator for the device to function.
+ * The startup and stop time of these oscillators vary. Populate
+ * from the board file to optimize the timing.
+ * This function is meant to be used at boot-time configuration.
+ *
+ * NOTE: This API is intended to be invoked from board file
+ */
+void __init omap_pm_set_osc_lp_time(u32 tstart, u32 tshut)
+{
+	_pm_lp_desc.oscillator_startup_time = tstart;
+	_pm_lp_desc.oscillator_shutdown_time = tshut;
+}
+
+/**
+ * omap_pm_set_pmic_lp_time() - setup the pmic low power time
+ * @tstart:	startup time rounded up to uSec
+ * @tshut:	shutdown time rounded up to uSec
+ *
+ * Store the time for PMIC to enter to lowest state supported.
+ * in the case of multiple PMIC on a platform, choose the one
+ * that ends the sequence for LP state such as OFF and starts
+ * the sequence such as wakeup from OFF - e.g. a PMIC that
+ * controls core-domain.
+ * This function is meant to be used at boot-time configuration.
+ */
+void __init omap_pm_set_pmic_lp_time(u32 tstart, u32 tshut)
+{
+	_pm_lp_desc.pmic_startup_time = tstart;
+	_pm_lp_desc.pmic_shutdown_time = tshut;
+}
+
 /* 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 babac19..dcceb90 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -124,4 +124,22 @@ static inline int omap4_twl_init(void)
 }
 #endif
 
+#ifdef CONFIG_PM
+extern int omap_pm_get_osc_lp_time(u32 *tstart, u32 *tshut);
+extern int omap_pm_get_pmic_lp_time(u32 *tstart, u32 *tshut);
+extern void omap_pm_set_osc_lp_time(u32 tstart, u32 tshut);
+extern void omap_pm_set_pmic_lp_time(u32 tstart, u32 tshut);
+#else
+static inline int omap_pm_get_osc_lp_time(u32 *tstart, u32 *tshut)
+{
+	return -EINVAL;
+}
+static inline int omap_pm_get_pmic_lp_time(u32 *tstart, u32 *tshut)
+{
+	return -EINVAL;
+}
+static inline void omap_pm_set_osc_lp_time(u32 tstart, u32 tshut) { }
+static inline void omap_pm_set_pmic_lp_time(u32 tstart, u32 tshut) { }
+#endif
+
 #endif
-- 
1.7.4.1


Texas Instruments Oy, Porkkalankatu 22, 00180 Helsinki, Finland. Business ID: 0115040-6. Domicile: Helsinki
 


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

* [PATCHv3 06/11] omap3+: vc: use new vc_params and vp_params in parameter calculations
  2011-10-05 17:17 [PATCHv3 00/11] voltage domain cleanup Tero Kristo
                   ` (4 preceding siblings ...)
  2011-10-05 17:17 ` [PATCHv3 05/11] OMAP2+: PM: provide mechanism to describe overall behavior of osc and PMIC Tero Kristo
@ 2011-10-05 17:17 ` Tero Kristo
  2011-11-04 21:11   ` Kevin Hilman
  2011-10-05 17:17 ` [PATCHv3 07/11] omap3+: vp: use new vp_params for calculating vddmin and vddmax Tero Kristo
                   ` (4 subsequent siblings)
  10 siblings, 1 reply; 24+ messages in thread
From: Tero Kristo @ 2011-10-05 17:17 UTC (permalink / raw)
  To: linux-omap

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

diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
index 16fa912..c50e598 100644
--- a/arch/arm/mach-omap2/vc.c
+++ b/arch/arm/mach-omap2/vc.c
@@ -1,14 +1,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
@@ -194,44 +198,156 @@ int omap_vc_bypass_scale(struct voltagedomain *voltdm,
 	return 0;
 }
 
-static void __init omap3_vfsm_init(struct voltagedomain *voltdm)
+static void omap3_set_ret_timings(struct voltagedomain *voltdm)
 {
-	/*
-	 * Voltage Manager FSM parameters init
-	 * XXX This data should be passed in from the board file
-	 */
-	voltdm->write(OMAP3_CLKSETUP, OMAP3_PRM_CLKSETUP_OFFSET);
-	voltdm->write(OMAP3_VOLTOFFSET, OMAP3_PRM_VOLTOFFSET_OFFSET);
-	voltdm->write(OMAP3_VOLTSETUP2, OMAP3_PRM_VOLTSETUP2_OFFSET);
+	unsigned long voltsetup1;
+	struct clk *sys_ck;
+	u32 sys_clk_rate;
+
+	sys_ck = clk_get(NULL, "sys_ck");
+	if (IS_ERR(sys_ck)) {
+		pr_warning("%s: unable to get sys_ck to calculate "
+			"vdd_%s timings\n", __func__, voltdm->name);
+		return;
+	}
+	sys_clk_rate = clk_get_rate(sys_ck);
+	clk_put(sys_ck);
+
+	voltsetup1 = (voltdm->vc_param->on - voltdm->vc_param->ret) /
+			voltdm->pmic->slew_rate;
+
+	voltsetup1 = voltsetup1 * sys_clk_rate / 8 / 1000000 + 1;
+	voltdm->rmw(voltdm->vfsm->voltsetup_mask,
+		voltsetup1 << __ffs(voltdm->vfsm->voltsetup_mask),
+		voltdm->vfsm->voltsetup_reg);
+
+	/* set voltsetup 2 to 0 */
+	voltdm->write(0, OMAP3_PRM_VOLTSETUP2_OFFSET);
+}
+
+static void omap3_set_off_timings(struct voltagedomain *voltdm)
+{
+	unsigned long clksetup;
+	unsigned long voltsetup2;
+
+	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 = voltsetup2 * 32768 / 1000000 + 1;
+
+	voltdm->write(voltsetup2, OMAP3_PRM_VOLTSETUP2_OFFSET);
+
+	/* set voltsetup1 to 0 */
+	voltdm->rmw(voltdm->vfsm->voltsetup_mask, 0,
+		voltdm->vfsm->voltsetup_reg);
+
+	/* set voltoffset */
+	voltdm->write(clksetup - voltsetup2, OMAP3_PRM_VOLTOFFSET_OFFSET);
 }
 
 static void __init omap3_vc_init_channel(struct voltagedomain *voltdm)
 {
-	static bool is_initialized;
+	omap3_set_off_timings(voltdm);
+}
 
-	if (is_initialized)
-		return;
+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;
+
+	cycles /= 64;
+	prescaler = 0;
+
+	/* shift to next prescaler until no overflow */
+
+	/* scale for div 256 = 64 * 4 */
+	if (cycles > 63) {
+		cycles /= 4;
+		prescaler++;
+	}
+
+	/* scale for div 512 = 256 * 2 */
+	if (cycles > 63) {
+		cycles /= 2;
+		prescaler++;
+	}
+
+	/* scale for div 2048 = 512 * 4 */
+	if (cycles > 63) {
+		cycles /= 4;
+		prescaler++;
+	}
+
+	/* check for overflow => invalid ramp time */
+	if (cycles > 63) {
+		pr_warning("%s: invalid setuptime for vdd_%s\n", __func__,
+			voltdm->name);
+		return 0;
+	}
 
-	omap3_vfsm_init(voltdm);
+	cycles++;
 
-	is_initialized = true;
+	return (prescaler << OMAP4430_RAMP_UP_PRESCAL_SHIFT) |
+		(cycles << OMAP4430_RAMP_UP_COUNT_SHIFT);
 }
 
+static void omap4_set_timings(struct voltagedomain *voltdm, bool off_mode)
+{
+	struct clk *sys_ck;
+	u32 sys_clk_rate;
+	u32 val;
+	u32 ramp;
+
+	sys_ck = clk_get(NULL, "sys_clkin_ck");
+	if (IS_ERR(sys_ck)) {
+		pr_warning("%s: unable to get sys_ck to calculate "
+			"vdd_%s timings\n", __func__, voltdm->name);
+		return;
+	}
+	sys_clk_rate = clk_get_rate(sys_ck);
+	clk_put(sys_ck);
+
+	/* 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,
+			sys_clk_rate);
+	else
+		ramp = omap4_calc_volt_ramp(voltdm,
+			voltdm->vc_param->on - voltdm->vc_param->ret,
+			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;
 }
 
 /**
@@ -305,7 +421,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,
@@ -329,10 +444,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) |
@@ -343,11 +458,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())
-- 
1.7.4.1


Texas Instruments Oy, Porkkalankatu 22, 00180 Helsinki, Finland. Business ID: 0115040-6. Domicile: Helsinki
 


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

* [PATCHv3 07/11] omap3+: vp: use new vp_params for calculating vddmin and vddmax
  2011-10-05 17:17 [PATCHv3 00/11] voltage domain cleanup Tero Kristo
                   ` (5 preceding siblings ...)
  2011-10-05 17:17 ` [PATCHv3 06/11] omap3+: vc: use new vc_params and vp_params in parameter calculations Tero Kristo
@ 2011-10-05 17:17 ` Tero Kristo
  2011-11-04 21:13   ` Kevin Hilman
  2011-10-05 17:17 ` [PATCHv3 08/11] omap3+: voltage: remove obsolete parameters Tero Kristo
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 24+ messages in thread
From: Tero Kristo @ 2011-10-05 17:17 UTC (permalink / raw)
  To: linux-omap

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 |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c
index 16cb6d4..fd3f43c 100644
--- a/arch/arm/mach-omap2/vp.c
+++ b/arch/arm/mach-omap2/vp.c
@@ -53,8 +53,12 @@ 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 = voltdm->vp_param->vddmin > voltdm->pmic->vp_vddmin ?
+		voltdm->vp_param->vddmin : voltdm->pmic->vp_vddmin;
+	vddmax = voltdm->vp_param->vddmax < voltdm->pmic->vp_vddmax ?
+		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


Texas Instruments Oy, Porkkalankatu 22, 00180 Helsinki, Finland. Business ID: 0115040-6. Domicile: Helsinki
 


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

* [PATCHv3 08/11] omap3+: voltage: remove obsolete parameters
  2011-10-05 17:17 [PATCHv3 00/11] voltage domain cleanup Tero Kristo
                   ` (6 preceding siblings ...)
  2011-10-05 17:17 ` [PATCHv3 07/11] omap3+: vp: use new vp_params for calculating vddmin and vddmax Tero Kristo
@ 2011-10-05 17:17 ` Tero Kristo
  2011-11-04 21:17   ` Kevin Hilman
  2011-10-05 17:17 ` [PATCHv3 09/11] omap4: twl: added pmic startup / shutdown times Tero Kristo
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 24+ messages in thread
From: Tero Kristo @ 2011-10-05 17:17 UTC (permalink / raw)
  To: linux-omap

Voltages for different operating modes are now provided by vc_params.
Oscillator setup times are handled as board specific.

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

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/vc.h b/arch/arm/mach-omap2/vc.h
index ec50643..e6fdd23 100644
--- a/arch/arm/mach-omap2/vc.h
+++ b/arch/arm/mach-omap2/vc.h
@@ -80,7 +80,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;
 
-- 
1.7.4.1


Texas Instruments Oy, Porkkalankatu 22, 00180 Helsinki, Finland. Business ID: 0115040-6. Domicile: Helsinki
 


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

* [PATCHv3 09/11] omap4: twl: added pmic startup / shutdown times
  2011-10-05 17:17 [PATCHv3 00/11] voltage domain cleanup Tero Kristo
                   ` (7 preceding siblings ...)
  2011-10-05 17:17 ` [PATCHv3 08/11] omap3+: voltage: remove obsolete parameters Tero Kristo
@ 2011-10-05 17:17 ` Tero Kristo
  2011-11-04 21:21   ` Kevin Hilman
  2011-11-04 21:21   ` Kevin Hilman
  2011-10-05 17:17 ` [PATCHv3 10/11] omap3+: use lp params for calculating clock setup times Tero Kristo
  2011-10-05 17:17 ` [PATCHv3 11/11] omap4: use lp params for calculating pmic " Tero Kristo
  10 siblings, 2 replies; 24+ messages in thread
From: Tero Kristo @ 2011-10-05 17:17 UTC (permalink / raw)
  To: linux-omap

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

diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c
index 62ed050..c095cf2 100644
--- a/arch/arm/mach-omap2/omap_twl.c
+++ b/arch/arm/mach-omap2/omap_twl.c
@@ -55,6 +55,13 @@ static bool __initdata twl_sr_enable_autoinit;
 #define REG_SMPS_OFFSET         0xE0
 #define SMARTREFLEX_ENABLE     BIT(3)
 
+struct twl_lp_description {
+	u32 osc_shut_time;
+	u32 osc_start_time;
+	u32 pmic_shut_time;
+	u32 pmic_start_time;
+};
+
 static unsigned long twl4030_vsel_to_uv(const u8 vsel)
 {
 	return (((vsel * 125) + 6000)) * 100;
@@ -220,9 +227,15 @@ static struct omap_voltdm_pmic omap4_core_pmic = {
 	.uv_to_vsel		= twl6030_uv_to_vsel,
 };
 
+static struct twl_lp_description omap4_pmic_lp_desc = {
+	.pmic_shut_time		= 500,
+	.pmic_start_time	= 500,
+};
+
 int __init omap4_twl_init(void)
 {
 	struct voltagedomain *voltdm;
+	struct twl_lp_description *desc;
 
 	if (!cpu_is_omap44xx())
 		return -ENODEV;
@@ -236,6 +249,10 @@ int __init omap4_twl_init(void)
 	voltdm = voltdm_lookup("core");
 	omap_voltage_register_pmic(voltdm, &omap4_core_pmic);
 
+	desc = &omap4_pmic_lp_desc;
+
+	omap_pm_set_pmic_lp_time(desc->pmic_start_time, desc->pmic_shut_time);
+
 	return 0;
 }
 
-- 
1.7.4.1


Texas Instruments Oy, Porkkalankatu 22, 00180 Helsinki, Finland. Business ID: 0115040-6. Domicile: Helsinki
 


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

* [PATCHv3 10/11] omap3+: use lp params for calculating clock setup times
  2011-10-05 17:17 [PATCHv3 00/11] voltage domain cleanup Tero Kristo
                   ` (8 preceding siblings ...)
  2011-10-05 17:17 ` [PATCHv3 09/11] omap4: twl: added pmic startup / shutdown times Tero Kristo
@ 2011-10-05 17:17 ` Tero Kristo
  2011-11-04 21:38   ` Kevin Hilman
  2011-10-05 17:17 ` [PATCHv3 11/11] omap4: use lp params for calculating pmic " Tero Kristo
  10 siblings, 1 reply; 24+ messages in thread
From: Tero Kristo @ 2011-10-05 17:17 UTC (permalink / raw)
  To: linux-omap

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

diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
index c50e598..ee0edf3 100644
--- a/arch/arm/mach-omap2/vc.c
+++ b/arch/arm/mach-omap2/vc.c
@@ -4,6 +4,8 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 
+#include <asm/div64.h>
+
 #include <plat/cpu.h>
 #include <plat/prcm.h>
 
@@ -13,6 +15,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
@@ -198,12 +201,28 @@ 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)
+{
+	omap3_prm_vcvp_write(omap_usec_to_32k(usec), OMAP3_PRM_CLKSETUP_OFFSET);
+}
+
 static void omap3_set_ret_timings(struct voltagedomain *voltdm)
 {
 	unsigned long voltsetup1;
 	struct clk *sys_ck;
 	u32 sys_clk_rate;
 
+	/* In retention oscillator is not shut down */
+	omap3_set_clksetup(1);
+
 	sys_ck = clk_get(NULL, "sys_ck");
 	if (IS_ERR(sys_ck)) {
 		pr_warning("%s: unable to get sys_ck to calculate "
@@ -229,6 +248,10 @@ static void omap3_set_off_timings(struct voltagedomain *voltdm)
 {
 	unsigned long clksetup;
 	unsigned long voltsetup2;
+	u32 tstart, tshut;
+
+	omap_pm_get_osc_lp_time(&tstart, &tshut);
+	omap3_set_clksetup(tstart);
 
 	clksetup = voltdm->read(OMAP3_PRM_CLKSETUP_OFFSET);
 
@@ -236,7 +259,7 @@ static void omap3_set_off_timings(struct voltagedomain *voltdm)
 	voltsetup2 = voltdm->vc_param->on / voltdm->pmic->slew_rate;
 
 	/* convert to 32k clk cycles */
-	voltsetup2 = voltsetup2 * 32768 / 1000000 + 1;
+	voltsetup2 = DIV_ROUND_UP(voltsetup2 * 32768, 1000000);
 
 	voltdm->write(voltsetup2, OMAP3_PRM_VOLTSETUP2_OFFSET);
 
@@ -300,12 +323,25 @@ 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;
+
+	if (val > mask)
+		val = mask;
+
+	return val;
+}
+
 static void omap4_set_timings(struct voltagedomain *voltdm, bool off_mode)
 {
 	struct clk *sys_ck;
 	u32 sys_clk_rate;
 	u32 val;
 	u32 ramp;
+	u32 tstart, tshut;
 
 	sys_ck = clk_get(NULL, "sys_clkin_ck");
 	if (IS_ERR(sys_ck)) {
@@ -336,6 +372,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_osc_lp_time(&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


Texas Instruments Oy, Porkkalankatu 22, 00180 Helsinki, Finland. Business ID: 0115040-6. Domicile: Helsinki
 


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

* [PATCHv3 11/11] omap4: use lp params for calculating pmic setup times
  2011-10-05 17:17 [PATCHv3 00/11] voltage domain cleanup Tero Kristo
                   ` (9 preceding siblings ...)
  2011-10-05 17:17 ` [PATCHv3 10/11] omap3+: use lp params for calculating clock setup times Tero Kristo
@ 2011-10-05 17:17 ` Tero Kristo
  2011-11-04 20:49   ` Kevin Hilman
  10 siblings, 1 reply; 24+ messages in thread
From: Tero Kristo @ 2011-10-05 17:17 UTC (permalink / raw)
  To: linux-omap

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

diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
index ee0edf3..badf28b 100644
--- a/arch/arm/mach-omap2/vc.c
+++ b/arch/arm/mach-omap2/vc.c
@@ -381,6 +381,15 @@ static void omap4_set_timings(struct voltagedomain *voltdm, bool off_mode)
 		OMAP4_DOWNTIME_MASK);
 
 	__raw_writel(val, OMAP4_SCRM_CLKSETUPTIME);
+
+	omap_pm_get_pmic_lp_time(&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


Texas Instruments Oy, Porkkalankatu 22, 00180 Helsinki, Finland. Business ID: 0115040-6. Domicile: Helsinki
 


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

* Re: [PATCHv3 03/11] omap3: add vp and vc parameter data
  2011-10-05 17:17 ` [PATCHv3 03/11] omap3: add vp and vc parameter data Tero Kristo
@ 2011-11-04 20:22   ` Kevin Hilman
  0 siblings, 0 replies; 24+ messages in thread
From: Kevin Hilman @ 2011-11-04 20:22 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap

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

> Signed-off-by: Tero Kristo <t-kristo@ti.com>

Missing descriptive changelog.

In particular, mentioning the spec where these voltages came from would
be most helpful for future reference.

Kevin

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

* Re: [PATCHv3 04/11] omap4: add vp and vc parameter data
  2011-10-05 17:17 ` [PATCHv3 04/11] omap4: " Tero Kristo
@ 2011-11-04 20:22   ` Kevin Hilman
  0 siblings, 0 replies; 24+ messages in thread
From: Kevin Hilman @ 2011-11-04 20:22 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap

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

> Signed-off-by: Tero Kristo <t-kristo@ti.com>

Missing descriptive changelog.

Kevin

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

* Re: [PATCHv3 11/11] omap4: use lp params for calculating pmic setup times
  2011-10-05 17:17 ` [PATCHv3 11/11] omap4: use lp params for calculating pmic " Tero Kristo
@ 2011-11-04 20:49   ` Kevin Hilman
  0 siblings, 0 replies; 24+ messages in thread
From: Kevin Hilman @ 2011-11-04 20:49 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap

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

> Signed-off-by: Tero Kristo <t-kristo@ti.com>

Missing descriptive changelog.

Why are the PMIC timings not relevant for OMAP3?

Kevin

> ---
>  arch/arm/mach-omap2/vc.c |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
> index ee0edf3..badf28b 100644
> --- a/arch/arm/mach-omap2/vc.c
> +++ b/arch/arm/mach-omap2/vc.c
> @@ -381,6 +381,15 @@ static void omap4_set_timings(struct voltagedomain *voltdm, bool off_mode)
>  		OMAP4_DOWNTIME_MASK);
>  
>  	__raw_writel(val, OMAP4_SCRM_CLKSETUPTIME);
> +
> +	omap_pm_get_pmic_lp_time(&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 */

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

* Re: [PATCHv3 05/11] OMAP2+: PM: provide mechanism to describe overall behavior of osc and PMIC.
  2011-10-05 17:17 ` [PATCHv3 05/11] OMAP2+: PM: provide mechanism to describe overall behavior of osc and PMIC Tero Kristo
@ 2011-11-04 21:02   ` Kevin Hilman
  0 siblings, 0 replies; 24+ messages in thread
From: Kevin Hilman @ 2011-11-04 21:02 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap, Nishanth Menon

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

> From: Nishanth Menon <nm@ti.com>
>
> We currently have mechanisms in place to describe the PMIC per
> rail, however we also need to configure the system for situations
> such as OFF mode, where, oscillator switch off and on time, and
> similar durations for PMIC also tends to play a major factor.
> Introduce a few apis to OMAP2's pm framework to use these. OMAP1
> does'nt seem to need this at the moment, hence not a OMAP generic
> framework. The set functions are meant to be used by initialization
> code.
>
> The OMAP specific implementation would need to use this ofcourse.
>
> Signed-off-by: Nishanth Menon <nm@ti.com>

> ---
>  arch/arm/mach-omap2/pm.c |  122 ++++++++++++++++++++++++++++++++++++++++++++++
>  arch/arm/mach-omap2/pm.h |   18 +++++++
>  2 files changed, 140 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
> index 659e400..e130d92 100644
> --- a/arch/arm/mach-omap2/pm.c
> +++ b/arch/arm/mach-omap2/pm.c
> @@ -24,6 +24,52 @@
>  #include "clockdomain.h"
>  #include "pm.h"
>  
> +/**
> + * struct omap2_pm_lp_description - Describe low power behavior of the system
> + * @oscillator_startup_time:	Time rounded up to uSec for the oscillator to
> + *				provide a stable clock from power on.
> + * @oscillator_shutdown_time:	Time rounded up to uSec for oscillator to safely
> + *				switch off.
> + * @pmic_startup_time:		Time rounded up to uSec for the PMIC to
> + *				provide be ready for operation from low power
> + *				state. Note: this is not the same as voltage
> + *				rampup time, instead, consider the PMIC to be
> + *				in lowest power state(say OFF), this is the time
> + *				required for it to become ready for it's DCDCs
> + *				or LDOs to start operation.
> + * @pmic_shutdown_time:		Time rounded up to uSec for the PMIC to
> + *				go to low power after the LDOs are pulled to
> + *				appropriate state. Note: this is not the same as
> + *				voltage rampdown time, instead, consider the
> + *				PMIC to have switched it's LDOs down, this is
> + *				time taken to reach it's lowest power state(say
> + *				sleep/OFF).

IMO, These PMIC times should be part of the existing struct that
describes all the configurable PMIC settings.

Kevin

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

* Re: [PATCHv3 06/11] omap3+: vc: use new vc_params and vp_params in parameter calculations
  2011-10-05 17:17 ` [PATCHv3 06/11] omap3+: vc: use new vc_params and vp_params in parameter calculations Tero Kristo
@ 2011-11-04 21:11   ` Kevin Hilman
  0 siblings, 0 replies; 24+ messages in thread
From: Kevin Hilman @ 2011-11-04 21:11 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap

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

> Signed-off-by: Tero Kristo <t-kristo@ti.com>

Missing descriptive changelog.

Some minor comments below...

Also, all of these timing calculations would benefit from a few more
pairs of eyes looking at this stuff, as I'm not the expert here.   In
particular, I'd like to see a reviewed-by/acked-by on this stuff from
Nishanth Menon and anyone else who is familiar with the various timing
calculations.

> ---
>  arch/arm/mach-omap2/vc.c |  166 ++++++++++++++++++++++++++++++++++++++--------
>  1 files changed, 138 insertions(+), 28 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
> index 16fa912..c50e598 100644
> --- a/arch/arm/mach-omap2/vc.c
> +++ b/arch/arm/mach-omap2/vc.c
> @@ -1,14 +1,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
> @@ -194,44 +198,156 @@ int omap_vc_bypass_scale(struct voltagedomain *voltdm,
>  	return 0;
>  }
>  
> -static void __init omap3_vfsm_init(struct voltagedomain *voltdm)
> +static void omap3_set_ret_timings(struct voltagedomain *voltdm)
>  {
> -	/*
> -	 * Voltage Manager FSM parameters init
> -	 * XXX This data should be passed in from the board file
> -	 */
> -	voltdm->write(OMAP3_CLKSETUP, OMAP3_PRM_CLKSETUP_OFFSET);
> -	voltdm->write(OMAP3_VOLTOFFSET, OMAP3_PRM_VOLTOFFSET_OFFSET);
> -	voltdm->write(OMAP3_VOLTSETUP2, OMAP3_PRM_VOLTSETUP2_OFFSET);
> +	unsigned long voltsetup1;
> +	struct clk *sys_ck;
> +	u32 sys_clk_rate;
> +
> +	sys_ck = clk_get(NULL, "sys_ck");
> +	if (IS_ERR(sys_ck)) {
> +		pr_warning("%s: unable to get sys_ck to calculate "
> +			"vdd_%s timings\n", __func__, voltdm->name);
> +		return;
> +	}
> +	sys_clk_rate = clk_get_rate(sys_ck);
> +	clk_put(sys_ck);

sys_clk_rate is already available in voltdm->sys_clk.rate, initialized
in late_init.

> +	voltsetup1 = (voltdm->vc_param->on - voltdm->vc_param->ret) /
> +			voltdm->pmic->slew_rate;
> +
> +	voltsetup1 = voltsetup1 * sys_clk_rate / 8 / 1000000 + 1;
> +	voltdm->rmw(voltdm->vfsm->voltsetup_mask,
> +		voltsetup1 << __ffs(voltdm->vfsm->voltsetup_mask),
> +		voltdm->vfsm->voltsetup_reg);
> +
> +	/* set voltsetup 2 to 0 */

Comment is not helpful.  Either describe why, or remove the comment
(preferably the former.)

> +	voltdm->write(0, OMAP3_PRM_VOLTSETUP2_OFFSET);
> +}
> +
> +static void omap3_set_off_timings(struct voltagedomain *voltdm)
> +{
> +	unsigned long clksetup;
> +	unsigned long voltsetup2;
> +
> +	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 = voltsetup2 * 32768 / 1000000 + 1;
> +
> +	voltdm->write(voltsetup2, OMAP3_PRM_VOLTSETUP2_OFFSET);
> +
> +	/* set voltsetup1 to 0 */
> +	voltdm->rmw(voltdm->vfsm->voltsetup_mask, 0,
> +		voltdm->vfsm->voltsetup_reg);
> +
> +	/* set voltoffset */

comment not helpful

> +	voltdm->write(clksetup - voltsetup2, OMAP3_PRM_VOLTOFFSET_OFFSET);
>  }
>  
>  static void __init omap3_vc_init_channel(struct voltagedomain *voltdm)
>  {
> -	static bool is_initialized;
> +	omap3_set_off_timings(voltdm);
> +}
>  
> -	if (is_initialized)
> -		return;
> +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;
> +
> +	cycles /= 64;
> +	prescaler = 0;
> +
> +	/* shift to next prescaler until no overflow */
> +
> +	/* scale for div 256 = 64 * 4 */
> +	if (cycles > 63) {
> +		cycles /= 4;
> +		prescaler++;
> +	}
> +
> +	/* scale for div 512 = 256 * 2 */
> +	if (cycles > 63) {
> +		cycles /= 2;
> +		prescaler++;
> +	}
> +
> +	/* scale for div 2048 = 512 * 4 */
> +	if (cycles > 63) {
> +		cycles /= 4;
> +		prescaler++;
> +	}
> +
> +	/* check for overflow => invalid ramp time */
> +	if (cycles > 63) {
> +		pr_warning("%s: invalid setuptime for vdd_%s\n", __func__,
> +			voltdm->name);
> +		return 0;
> +	}
>  
> -	omap3_vfsm_init(voltdm);
> +	cycles++;
>  
> -	is_initialized = true;
> +	return (prescaler << OMAP4430_RAMP_UP_PRESCAL_SHIFT) |
> +		(cycles << OMAP4430_RAMP_UP_COUNT_SHIFT);
>  }
>  
> +static void omap4_set_timings(struct voltagedomain *voltdm, bool off_mode)
> +{
> +	struct clk *sys_ck;
> +	u32 sys_clk_rate;
> +	u32 val;
> +	u32 ramp;
> +
> +	sys_ck = clk_get(NULL, "sys_clkin_ck");
> +	if (IS_ERR(sys_ck)) {
> +		pr_warning("%s: unable to get sys_ck to calculate "
> +			"vdd_%s timings\n", __func__, voltdm->name);
> +		return;
> +	}
> +	sys_clk_rate = clk_get_rate(sys_ck);
> +	clk_put(sys_ck);
> +
> +	/* 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,
> +			sys_clk_rate);
> +	else
> +		ramp = omap4_calc_volt_ramp(voltdm,
> +			voltdm->vc_param->on - voltdm->vc_param->ret,
> +			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);

Why the 2nd argument (off_mode)?   Is it planned to change the timings
at runtime later?

>  	/* 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;
>  }
>  
>  /**
> @@ -305,7 +421,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,
> @@ -329,10 +444,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) |
> @@ -343,11 +458,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())

Kevin

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

* Re: [PATCHv3 07/11] omap3+: vp: use new vp_params for calculating vddmin and vddmax
  2011-10-05 17:17 ` [PATCHv3 07/11] omap3+: vp: use new vp_params for calculating vddmin and vddmax Tero Kristo
@ 2011-11-04 21:13   ` Kevin Hilman
  0 siblings, 0 replies; 24+ messages in thread
From: Kevin Hilman @ 2011-11-04 21:13 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap

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

> 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 |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c
> index 16cb6d4..fd3f43c 100644
> --- a/arch/arm/mach-omap2/vp.c
> +++ b/arch/arm/mach-omap2/vp.c
> @@ -53,8 +53,12 @@ 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 = voltdm->vp_param->vddmin > voltdm->pmic->vp_vddmin ?
> +		voltdm->vp_param->vddmin : voltdm->pmic->vp_vddmin;
> +	vddmax = voltdm->vp_param->vddmax < voltdm->pmic->vp_vddmax ?
> +		voltdm->vp_param->vddmax : voltdm->pmic->vp_vddmax;

For better readability, please use the min() and max() macros here.

Kevin

> +	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;

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

* Re: [PATCHv3 08/11] omap3+: voltage: remove obsolete parameters
  2011-10-05 17:17 ` [PATCHv3 08/11] omap3+: voltage: remove obsolete parameters Tero Kristo
@ 2011-11-04 21:17   ` Kevin Hilman
  0 siblings, 0 replies; 24+ messages in thread
From: Kevin Hilman @ 2011-11-04 21:17 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap

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

> Voltages for different operating modes are now provided by vc_params.
> Oscillator setup times are handled as board specific.
>
> Signed-off-by: Tero Kristo <t-kristo@ti.com>

These should be removed in the previous patches.

That gets at a bigger problem with this series in that it's not
bisectable.  For example, these fields are removed in PATCH 2/11 but
their usage isn't removed until here.  That means that after 2/11,
things will no longer compile.

Probably the best way to do this is to just combine patches 2, 3, 4 and
this one.    That way it's also obvious that the voltage values added in
patches 3 & 4 are just being moved, and not being invented out of thin air.

Kevin

> ---
>  arch/arm/mach-omap2/omap_twl.c |   25 -------------------------
>  arch/arm/mach-omap2/vc.h       |    1 -
>  2 files changed, 0 insertions(+), 26 deletions(-)
>
> 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/vc.h b/arch/arm/mach-omap2/vc.h
> index ec50643..e6fdd23 100644
> --- a/arch/arm/mach-omap2/vc.h
> +++ b/arch/arm/mach-omap2/vc.h
> @@ -80,7 +80,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;

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

* Re: [PATCHv3 09/11] omap4: twl: added pmic startup / shutdown times
  2011-10-05 17:17 ` [PATCHv3 09/11] omap4: twl: added pmic startup / shutdown times Tero Kristo
@ 2011-11-04 21:21   ` Kevin Hilman
  2011-11-04 21:21   ` Kevin Hilman
  1 sibling, 0 replies; 24+ messages in thread
From: Kevin Hilman @ 2011-11-04 21:21 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap

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

> Signed-off-by: Tero Kristo <t-kristo@ti.com>

Missing descriptive changelog.

> ---
>  arch/arm/mach-omap2/omap_twl.c |   17 +++++++++++++++++
>  1 files changed, 17 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c
> index 62ed050..c095cf2 100644
> --- a/arch/arm/mach-omap2/omap_twl.c
> +++ b/arch/arm/mach-omap2/omap_twl.c
> @@ -55,6 +55,13 @@ static bool __initdata twl_sr_enable_autoinit;
>  #define REG_SMPS_OFFSET         0xE0
>  #define SMARTREFLEX_ENABLE     BIT(3)
>  
> +struct twl_lp_description {
> +	u32 osc_shut_time;
> +	u32 osc_start_time;

These are unused.

Also, how are oscillator setup/shutdown times related to the PMIC?

> +	u32 pmic_shut_time;
> +	u32 pmic_start_time;
> +};
> +
>  static unsigned long twl4030_vsel_to_uv(const u8 vsel)
>  {
>  	return (((vsel * 125) + 6000)) * 100;
> @@ -220,9 +227,15 @@ static struct omap_voltdm_pmic omap4_core_pmic = {
>  	.uv_to_vsel		= twl6030_uv_to_vsel,
>  };
>  
> +static struct twl_lp_description omap4_pmic_lp_desc = {
> +	.pmic_shut_time		= 500,
> +	.pmic_start_time	= 500,
> +};
> +
>  int __init omap4_twl_init(void)
>  {
>  	struct voltagedomain *voltdm;
> +	struct twl_lp_description *desc;
>  
>  	if (!cpu_is_omap44xx())
>  		return -ENODEV;
> @@ -236,6 +249,10 @@ int __init omap4_twl_init(void)
>  	voltdm = voltdm_lookup("core");
>  	omap_voltage_register_pmic(voltdm, &omap4_core_pmic);
>  
> +	desc = &omap4_pmic_lp_desc;
> +
> +	omap_pm_set_pmic_lp_time(desc->pmic_start_time, desc->pmic_shut_time);
> +
>  	return 0;
>  }

See comment on 5/11.  IMO, the PMIC timings should just be going into
omap_voltdm_pmic along with slew_rate, step_size etc.  I don't follow
why we need a different mechanism to customize these timings that is
different from the rest of the PMIC settings.

Kevin

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

* Re: [PATCHv3 09/11] omap4: twl: added pmic startup / shutdown times
  2011-10-05 17:17 ` [PATCHv3 09/11] omap4: twl: added pmic startup / shutdown times Tero Kristo
  2011-11-04 21:21   ` Kevin Hilman
@ 2011-11-04 21:21   ` Kevin Hilman
  1 sibling, 0 replies; 24+ messages in thread
From: Kevin Hilman @ 2011-11-04 21:21 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap

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

[...]

> +static struct twl_lp_description omap4_pmic_lp_desc = {
> +	.pmic_shut_time		= 500,
> +	.pmic_start_time	= 500,
> +};

Also, please note where these timings come from (TRM, data sheet, etc.)

Kevin

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

* Re: [PATCHv3 10/11] omap3+: use lp params for calculating clock setup times
  2011-10-05 17:17 ` [PATCHv3 10/11] omap3+: use lp params for calculating clock setup times Tero Kristo
@ 2011-11-04 21:38   ` Kevin Hilman
  2011-11-15 17:22     ` Tero Kristo
  0 siblings, 1 reply; 24+ messages in thread
From: Kevin Hilman @ 2011-11-04 21:38 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap

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

> Signed-off-by: Tero Kristo <t-kristo@ti.com>

Missing descriptive changelog.

> ---
>  arch/arm/mach-omap2/vc.c |   47 +++++++++++++++++++++++++++++++++++++++++++++-
>  1 files changed, 46 insertions(+), 1 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
> index c50e598..ee0edf3 100644
> --- a/arch/arm/mach-omap2/vc.c
> +++ b/arch/arm/mach-omap2/vc.c
> @@ -4,6 +4,8 @@
>  #include <linux/clk.h>
>  #include <linux/io.h>
>  
> +#include <asm/div64.h>
> +
>  #include <plat/cpu.h>
>  #include <plat/prcm.h>
>  
> @@ -13,6 +15,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
> @@ -198,12 +201,28 @@ 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)
> +{
> +	omap3_prm_vcvp_write(omap_usec_to_32k(usec), OMAP3_PRM_CLKSETUP_OFFSET);

Please pass in voltdm and use voltdm->write()

> +}
> +
>  static void omap3_set_ret_timings(struct voltagedomain *voltdm)
>  {
>  	unsigned long voltsetup1;
>  	struct clk *sys_ck;
>  	u32 sys_clk_rate;
>  
> +	/* In retention oscillator is not shut down */
> +	omap3_set_clksetup(1);
> +
>  	sys_ck = clk_get(NULL, "sys_ck");
>  	if (IS_ERR(sys_ck)) {
>  		pr_warning("%s: unable to get sys_ck to calculate "
> @@ -229,6 +248,10 @@ static void omap3_set_off_timings(struct voltagedomain *voltdm)
>  {
>  	unsigned long clksetup;
>  	unsigned long voltsetup2;
> +	u32 tstart, tshut;
> +
> +	omap_pm_get_osc_lp_time(&tstart, &tshut);
> +	omap3_set_clksetup(tstart);
>  
>  	clksetup = voltdm->read(OMAP3_PRM_CLKSETUP_OFFSET);
>  
> @@ -236,7 +259,7 @@ static void omap3_set_off_timings(struct voltagedomain *voltdm)
>  	voltsetup2 = voltdm->vc_param->on / voltdm->pmic->slew_rate;
>  
>  	/* convert to 32k clk cycles */
> -	voltsetup2 = voltsetup2 * 32768 / 1000000 + 1;
> +	voltsetup2 = DIV_ROUND_UP(voltsetup2 * 32768, 1000000);
>  
>  	voltdm->write(voltsetup2, OMAP3_PRM_VOLTSETUP2_OFFSET);
>  
> @@ -300,12 +323,25 @@ 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;
> +
> +	if (val > mask)
> +		val = mask;

This isn't entirely obvious.  At first I thought it should just be 
'val &= mask', but staring at it for awhile I think I understand now.
Adding a comment above with a description would be helpful.

> +	return val;
> +}
> +
>  static void omap4_set_timings(struct voltagedomain *voltdm, bool off_mode)
>  {
>  	struct clk *sys_ck;
>  	u32 sys_clk_rate;
>  	u32 val;
>  	u32 ramp;
> +	u32 tstart, tshut;
>  
>  	sys_ck = clk_get(NULL, "sys_clkin_ck");
>  	if (IS_ERR(sys_ck)) {
> @@ -336,6 +372,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_osc_lp_time(&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 */

Kevin

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

* Re: [PATCHv3 10/11] omap3+: use lp params for calculating clock setup times
  2011-11-04 21:38   ` Kevin Hilman
@ 2011-11-15 17:22     ` Tero Kristo
  2011-11-17  0:10       ` Kevin Hilman
  0 siblings, 1 reply; 24+ messages in thread
From: Tero Kristo @ 2011-11-15 17:22 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: linux-omap

Hi Kevin,

Thanks for the comments and sorry for a bit late reply. I was busy with
other stuff but can work on this again.

Anyway, all your comments to all of the patches make sense, and I will
apply the changes to the next version of the set, also merging some of
the patches back together again. One question though, do you want to
have the auto_ret / auto_off support along with these changes? Some of
the code in this set is only used when the auto_ret / auto_off is in,
and it also makes it a bit more easier to test the resulting stuff.

-Tero




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

* Re: [PATCHv3 10/11] omap3+: use lp params for calculating clock setup times
  2011-11-15 17:22     ` Tero Kristo
@ 2011-11-17  0:10       ` Kevin Hilman
  0 siblings, 0 replies; 24+ messages in thread
From: Kevin Hilman @ 2011-11-17  0:10 UTC (permalink / raw)
  To: t-kristo; +Cc: linux-omap

Hi Tero,

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

[...]

> One question though, do you want to have the auto_ret / auto_off
> support along with these changes? Some of the code in this set is only
> used when the auto_ret / auto_off is in, and it also makes it a bit
> more easier to test the resulting stuff.

Yes, it would be helpful to include that for better testing.  You can
add that as separate patches at the end of the series.

Thanks,

Kevin

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

end of thread, other threads:[~2011-11-17  0:10 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-05 17:17 [PATCHv3 00/11] voltage domain cleanup Tero Kristo
2011-10-05 17:17 ` [PATCHv3 01/11] OMAP3+: PM: VP: use uV for max and min voltage limits Tero Kristo
2011-10-05 17:17 ` [PATCHv3 02/11] omap: voltage: add definitions for omap_vp_param and omap_vc_param Tero Kristo
2011-10-05 17:17 ` [PATCHv3 03/11] omap3: add vp and vc parameter data Tero Kristo
2011-11-04 20:22   ` Kevin Hilman
2011-10-05 17:17 ` [PATCHv3 04/11] omap4: " Tero Kristo
2011-11-04 20:22   ` Kevin Hilman
2011-10-05 17:17 ` [PATCHv3 05/11] OMAP2+: PM: provide mechanism to describe overall behavior of osc and PMIC Tero Kristo
2011-11-04 21:02   ` Kevin Hilman
2011-10-05 17:17 ` [PATCHv3 06/11] omap3+: vc: use new vc_params and vp_params in parameter calculations Tero Kristo
2011-11-04 21:11   ` Kevin Hilman
2011-10-05 17:17 ` [PATCHv3 07/11] omap3+: vp: use new vp_params for calculating vddmin and vddmax Tero Kristo
2011-11-04 21:13   ` Kevin Hilman
2011-10-05 17:17 ` [PATCHv3 08/11] omap3+: voltage: remove obsolete parameters Tero Kristo
2011-11-04 21:17   ` Kevin Hilman
2011-10-05 17:17 ` [PATCHv3 09/11] omap4: twl: added pmic startup / shutdown times Tero Kristo
2011-11-04 21:21   ` Kevin Hilman
2011-11-04 21:21   ` Kevin Hilman
2011-10-05 17:17 ` [PATCHv3 10/11] omap3+: use lp params for calculating clock setup times Tero Kristo
2011-11-04 21:38   ` Kevin Hilman
2011-11-15 17:22     ` Tero Kristo
2011-11-17  0:10       ` Kevin Hilman
2011-10-05 17:17 ` [PATCHv3 11/11] omap4: use lp params for calculating pmic " Tero Kristo
2011-11-04 20:49   ` Kevin Hilman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox