All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] ARM: OMAP4+: powerdomain fixes
@ 2014-08-22 13:49 ` Nishanth Menon
  0 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-22 13:49 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Kevin Hilman, Tero Kristo, Paul Walmsley, linux-arm-kernel,
	linux-omap, linux-kernel, Keerthy, Benoît Cousson,
	Santosh Shilimkar, Nishanth Menon

Hi,

The following series are various fixes and improvements for
powerdomain support in OMAP4+.

This is part 1/6 series which eventually enables framework for
suspend-to-ram and cpuidle for OMAP5 and DRA7

Each of series is based on v3.17-rc1 and this specific series is available:
weblink: https://github.com/nmenon/linux-2.6-playground/commits/push/v3.17/powerdomain-fixes

git repo: https://github.com/nmenon/linux-2.6-playground.git push/v3.17/powerdomain-fixes

An complete integrated branch is available here: https://github.com/nmenon/linux-2.6-playground/commits/testing/v3.17/cpu-idle-suspend-dra7-omap5-framework

Nishanth Menon (7):
  ARM: OMAP: DRA7: powerdomain data: fix powerdomain powerstate
  ARM: OMAP5: powerdomain data: fix powerdomain powerstate
  ARM: OMAP2+: powerdomain: pwrdm_for_each_clkdm iterate only valid
    clkdms
  ARM: OMAP2+: powerdomain: introduce logic for finding valid power
    domain
  ARM: OMAP4+: PM: Make logic state programmable
  ARM: OMAP4+: PM: use only valid low power state for suspend
  ARM: OMAP4+: PM: Use only valid low power state for CPU hotplug

 arch/arm/mach-omap2/omap-mpuss-lowpower.c   |    4 ++
 arch/arm/mach-omap2/pm44xx.c                |    9 +++-
 arch/arm/mach-omap2/powerdomain.c           |   76 ++++++++++++++++++++++++++-
 arch/arm/mach-omap2/powerdomain.h           |    4 ++
 arch/arm/mach-omap2/powerdomains54xx_data.c |   12 ++---
 arch/arm/mach-omap2/powerdomains7xx_data.c  |   14 ++---
 6 files changed, 103 insertions(+), 16 deletions(-)

-- 
1.7.9.5


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

* [PATCH 0/7] ARM: OMAP4+: powerdomain fixes
@ 2014-08-22 13:49 ` Nishanth Menon
  0 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-22 13:49 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Nishanth Menon, Paul Walmsley, Kevin Hilman, Keerthy,
	linux-kernel, Tero Kristo, Santosh Shilimkar,
	Benoît Cousson, linux-omap, linux-arm-kernel

Hi,

The following series are various fixes and improvements for
powerdomain support in OMAP4+.

This is part 1/6 series which eventually enables framework for
suspend-to-ram and cpuidle for OMAP5 and DRA7

Each of series is based on v3.17-rc1 and this specific series is available:
weblink: https://github.com/nmenon/linux-2.6-playground/commits/push/v3.17/powerdomain-fixes

git repo: https://github.com/nmenon/linux-2.6-playground.git push/v3.17/powerdomain-fixes

An complete integrated branch is available here: https://github.com/nmenon/linux-2.6-playground/commits/testing/v3.17/cpu-idle-suspend-dra7-omap5-framework

Nishanth Menon (7):
  ARM: OMAP: DRA7: powerdomain data: fix powerdomain powerstate
  ARM: OMAP5: powerdomain data: fix powerdomain powerstate
  ARM: OMAP2+: powerdomain: pwrdm_for_each_clkdm iterate only valid
    clkdms
  ARM: OMAP2+: powerdomain: introduce logic for finding valid power
    domain
  ARM: OMAP4+: PM: Make logic state programmable
  ARM: OMAP4+: PM: use only valid low power state for suspend
  ARM: OMAP4+: PM: Use only valid low power state for CPU hotplug

 arch/arm/mach-omap2/omap-mpuss-lowpower.c   |    4 ++
 arch/arm/mach-omap2/pm44xx.c                |    9 +++-
 arch/arm/mach-omap2/powerdomain.c           |   76 ++++++++++++++++++++++++++-
 arch/arm/mach-omap2/powerdomain.h           |    4 ++
 arch/arm/mach-omap2/powerdomains54xx_data.c |   12 ++---
 arch/arm/mach-omap2/powerdomains7xx_data.c  |   14 ++---
 6 files changed, 103 insertions(+), 16 deletions(-)

-- 
1.7.9.5

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

* [PATCH 0/7] ARM: OMAP4+: powerdomain fixes
@ 2014-08-22 13:49 ` Nishanth Menon
  0 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-22 13:49 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

The following series are various fixes and improvements for
powerdomain support in OMAP4+.

This is part 1/6 series which eventually enables framework for
suspend-to-ram and cpuidle for OMAP5 and DRA7

Each of series is based on v3.17-rc1 and this specific series is available:
weblink: https://github.com/nmenon/linux-2.6-playground/commits/push/v3.17/powerdomain-fixes

git repo: https://github.com/nmenon/linux-2.6-playground.git push/v3.17/powerdomain-fixes

An complete integrated branch is available here: https://github.com/nmenon/linux-2.6-playground/commits/testing/v3.17/cpu-idle-suspend-dra7-omap5-framework

Nishanth Menon (7):
  ARM: OMAP: DRA7: powerdomain data: fix powerdomain powerstate
  ARM: OMAP5: powerdomain data: fix powerdomain powerstate
  ARM: OMAP2+: powerdomain: pwrdm_for_each_clkdm iterate only valid
    clkdms
  ARM: OMAP2+: powerdomain: introduce logic for finding valid power
    domain
  ARM: OMAP4+: PM: Make logic state programmable
  ARM: OMAP4+: PM: use only valid low power state for suspend
  ARM: OMAP4+: PM: Use only valid low power state for CPU hotplug

 arch/arm/mach-omap2/omap-mpuss-lowpower.c   |    4 ++
 arch/arm/mach-omap2/pm44xx.c                |    9 +++-
 arch/arm/mach-omap2/powerdomain.c           |   76 ++++++++++++++++++++++++++-
 arch/arm/mach-omap2/powerdomain.h           |    4 ++
 arch/arm/mach-omap2/powerdomains54xx_data.c |   12 ++---
 arch/arm/mach-omap2/powerdomains7xx_data.c  |   14 ++---
 6 files changed, 103 insertions(+), 16 deletions(-)

-- 
1.7.9.5

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

* [PATCH 1/7] ARM: OMAP: DRA7: powerdomain data: fix powerdomain powerstate
  2014-08-22 13:49 ` Nishanth Menon
@ 2014-08-22 13:49   ` Nishanth Menon
  -1 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-22 13:49 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Kevin Hilman, Tero Kristo, Paul Walmsley, linux-arm-kernel,
	linux-omap, linux-kernel, Keerthy, Benoît Cousson,
	Santosh Shilimkar, Nishanth Menon

DRA7 supports only CSWR for CPU, MPU power domains. Core power domain
supports upto INA.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-omap2/powerdomain.h          |    1 +
 arch/arm/mach-omap2/powerdomains7xx_data.c |   14 +++++++-------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h
index f472711..a754c82 100644
--- a/arch/arm/mach-omap2/powerdomain.h
+++ b/arch/arm/mach-omap2/powerdomain.h
@@ -39,6 +39,7 @@
 #define PWRSTS_OFF_RET		(PWRSTS_OFF | PWRSTS_RET)
 #define PWRSTS_RET_ON		(PWRSTS_RET | PWRSTS_ON)
 #define PWRSTS_OFF_RET_ON	(PWRSTS_OFF_RET | PWRSTS_ON)
+#define PWRSTS_INA_ON		(PWRSTS_INACTIVE | PWRSTS_ON)
 
 
 /*
diff --git a/arch/arm/mach-omap2/powerdomains7xx_data.c b/arch/arm/mach-omap2/powerdomains7xx_data.c
index 48151d1..287a203 100644
--- a/arch/arm/mach-omap2/powerdomains7xx_data.c
+++ b/arch/arm/mach-omap2/powerdomains7xx_data.c
@@ -160,8 +160,8 @@ static struct powerdomain core_7xx_pwrdm = {
 	.name		  = "core_pwrdm",
 	.prcm_offs	  = DRA7XX_PRM_CORE_INST,
 	.prcm_partition	  = DRA7XX_PRM_PARTITION,
-	.pwrsts		  = PWRSTS_RET_ON,
-	.pwrsts_logic_ret = PWRSTS_OFF_RET,
+	.pwrsts		  = PWRSTS_INA_ON,
+	.pwrsts_logic_ret = PWRSTS_RET,
 	.banks		  = 5,
 	.pwrsts_mem_ret	= {
 		[0] = PWRSTS_OFF_RET,	/* core_nret_bank */
@@ -193,8 +193,8 @@ static struct powerdomain cpu0_7xx_pwrdm = {
 	.name		  = "cpu0_pwrdm",
 	.prcm_offs	  = DRA7XX_MPU_PRCM_PRM_C0_INST,
 	.prcm_partition	  = DRA7XX_MPU_PRCM_PARTITION,
-	.pwrsts		  = PWRSTS_OFF_RET_ON,
-	.pwrsts_logic_ret = PWRSTS_OFF_RET,
+	.pwrsts		  = PWRSTS_RET_ON,
+	.pwrsts_logic_ret = PWRSTS_RET,
 	.banks		  = 1,
 	.pwrsts_mem_ret	= {
 		[0] = PWRSTS_OFF_RET,	/* cpu0_l1 */
@@ -209,8 +209,8 @@ static struct powerdomain cpu1_7xx_pwrdm = {
 	.name		  = "cpu1_pwrdm",
 	.prcm_offs	  = DRA7XX_MPU_PRCM_PRM_C1_INST,
 	.prcm_partition	  = DRA7XX_MPU_PRCM_PARTITION,
-	.pwrsts		  = PWRSTS_OFF_RET_ON,
-	.pwrsts_logic_ret = PWRSTS_OFF_RET,
+	.pwrsts		  = PWRSTS_RET_ON,
+	.pwrsts_logic_ret = PWRSTS_RET,
 	.banks		  = 1,
 	.pwrsts_mem_ret	= {
 		[0] = PWRSTS_OFF_RET,	/* cpu1_l1 */
@@ -243,7 +243,7 @@ static struct powerdomain mpu_7xx_pwrdm = {
 	.prcm_offs	  = DRA7XX_PRM_MPU_INST,
 	.prcm_partition	  = DRA7XX_PRM_PARTITION,
 	.pwrsts		  = PWRSTS_RET_ON,
-	.pwrsts_logic_ret = PWRSTS_OFF_RET,
+	.pwrsts_logic_ret = PWRSTS_RET,
 	.banks		  = 2,
 	.pwrsts_mem_ret	= {
 		[0] = PWRSTS_OFF_RET,	/* mpu_l2 */
-- 
1.7.9.5


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

* [PATCH 1/7] ARM: OMAP: DRA7: powerdomain data: fix powerdomain powerstate
@ 2014-08-22 13:49   ` Nishanth Menon
  0 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-22 13:49 UTC (permalink / raw)
  To: linux-arm-kernel

DRA7 supports only CSWR for CPU, MPU power domains. Core power domain
supports upto INA.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-omap2/powerdomain.h          |    1 +
 arch/arm/mach-omap2/powerdomains7xx_data.c |   14 +++++++-------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h
index f472711..a754c82 100644
--- a/arch/arm/mach-omap2/powerdomain.h
+++ b/arch/arm/mach-omap2/powerdomain.h
@@ -39,6 +39,7 @@
 #define PWRSTS_OFF_RET		(PWRSTS_OFF | PWRSTS_RET)
 #define PWRSTS_RET_ON		(PWRSTS_RET | PWRSTS_ON)
 #define PWRSTS_OFF_RET_ON	(PWRSTS_OFF_RET | PWRSTS_ON)
+#define PWRSTS_INA_ON		(PWRSTS_INACTIVE | PWRSTS_ON)
 
 
 /*
diff --git a/arch/arm/mach-omap2/powerdomains7xx_data.c b/arch/arm/mach-omap2/powerdomains7xx_data.c
index 48151d1..287a203 100644
--- a/arch/arm/mach-omap2/powerdomains7xx_data.c
+++ b/arch/arm/mach-omap2/powerdomains7xx_data.c
@@ -160,8 +160,8 @@ static struct powerdomain core_7xx_pwrdm = {
 	.name		  = "core_pwrdm",
 	.prcm_offs	  = DRA7XX_PRM_CORE_INST,
 	.prcm_partition	  = DRA7XX_PRM_PARTITION,
-	.pwrsts		  = PWRSTS_RET_ON,
-	.pwrsts_logic_ret = PWRSTS_OFF_RET,
+	.pwrsts		  = PWRSTS_INA_ON,
+	.pwrsts_logic_ret = PWRSTS_RET,
 	.banks		  = 5,
 	.pwrsts_mem_ret	= {
 		[0] = PWRSTS_OFF_RET,	/* core_nret_bank */
@@ -193,8 +193,8 @@ static struct powerdomain cpu0_7xx_pwrdm = {
 	.name		  = "cpu0_pwrdm",
 	.prcm_offs	  = DRA7XX_MPU_PRCM_PRM_C0_INST,
 	.prcm_partition	  = DRA7XX_MPU_PRCM_PARTITION,
-	.pwrsts		  = PWRSTS_OFF_RET_ON,
-	.pwrsts_logic_ret = PWRSTS_OFF_RET,
+	.pwrsts		  = PWRSTS_RET_ON,
+	.pwrsts_logic_ret = PWRSTS_RET,
 	.banks		  = 1,
 	.pwrsts_mem_ret	= {
 		[0] = PWRSTS_OFF_RET,	/* cpu0_l1 */
@@ -209,8 +209,8 @@ static struct powerdomain cpu1_7xx_pwrdm = {
 	.name		  = "cpu1_pwrdm",
 	.prcm_offs	  = DRA7XX_MPU_PRCM_PRM_C1_INST,
 	.prcm_partition	  = DRA7XX_MPU_PRCM_PARTITION,
-	.pwrsts		  = PWRSTS_OFF_RET_ON,
-	.pwrsts_logic_ret = PWRSTS_OFF_RET,
+	.pwrsts		  = PWRSTS_RET_ON,
+	.pwrsts_logic_ret = PWRSTS_RET,
 	.banks		  = 1,
 	.pwrsts_mem_ret	= {
 		[0] = PWRSTS_OFF_RET,	/* cpu1_l1 */
@@ -243,7 +243,7 @@ static struct powerdomain mpu_7xx_pwrdm = {
 	.prcm_offs	  = DRA7XX_PRM_MPU_INST,
 	.prcm_partition	  = DRA7XX_PRM_PARTITION,
 	.pwrsts		  = PWRSTS_RET_ON,
-	.pwrsts_logic_ret = PWRSTS_OFF_RET,
+	.pwrsts_logic_ret = PWRSTS_RET,
 	.banks		  = 2,
 	.pwrsts_mem_ret	= {
 		[0] = PWRSTS_OFF_RET,	/* mpu_l2 */
-- 
1.7.9.5

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

* [PATCH 2/7] ARM: OMAP5: powerdomain data: fix powerdomain powerstate
  2014-08-22 13:49 ` Nishanth Menon
@ 2014-08-22 13:49   ` Nishanth Menon
  -1 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-22 13:49 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Kevin Hilman, Tero Kristo, Paul Walmsley, linux-arm-kernel,
	linux-omap, linux-kernel, Keerthy, Benoît Cousson,
	Santosh Shilimkar, Nishanth Menon

Update the power domain power states for final production chip
capability. OFF mode, OSWR etc have been descoped for various domains.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-omap2/powerdomains54xx_data.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/powerdomains54xx_data.c b/arch/arm/mach-omap2/powerdomains54xx_data.c
index ce1d752..60d7ed8 100644
--- a/arch/arm/mach-omap2/powerdomains54xx_data.c
+++ b/arch/arm/mach-omap2/powerdomains54xx_data.c
@@ -35,7 +35,7 @@ static struct powerdomain core_54xx_pwrdm = {
 	.prcm_offs	  = OMAP54XX_PRM_CORE_INST,
 	.prcm_partition	  = OMAP54XX_PRM_PARTITION,
 	.pwrsts		  = PWRSTS_RET_ON,
-	.pwrsts_logic_ret = PWRSTS_OFF_RET,
+	.pwrsts_logic_ret = PWRSTS_RET,
 	.banks		  = 5,
 	.pwrsts_mem_ret	= {
 		[0] = PWRSTS_OFF_RET,	/* core_nret_bank */
@@ -107,8 +107,8 @@ static struct powerdomain cpu0_54xx_pwrdm = {
 	.voltdm		  = { .name = "mpu" },
 	.prcm_offs	  = OMAP54XX_PRCM_MPU_PRM_C0_INST,
 	.prcm_partition	  = OMAP54XX_PRCM_MPU_PARTITION,
-	.pwrsts		  = PWRSTS_OFF_RET_ON,
-	.pwrsts_logic_ret = PWRSTS_OFF_RET,
+	.pwrsts		  = PWRSTS_RET_ON,
+	.pwrsts_logic_ret = PWRSTS_RET,
 	.banks		  = 1,
 	.pwrsts_mem_ret	= {
 		[0] = PWRSTS_OFF_RET,	/* cpu0_l1 */
@@ -124,8 +124,8 @@ static struct powerdomain cpu1_54xx_pwrdm = {
 	.voltdm		  = { .name = "mpu" },
 	.prcm_offs	  = OMAP54XX_PRCM_MPU_PRM_C1_INST,
 	.prcm_partition	  = OMAP54XX_PRCM_MPU_PARTITION,
-	.pwrsts		  = PWRSTS_OFF_RET_ON,
-	.pwrsts_logic_ret = PWRSTS_OFF_RET,
+	.pwrsts		  = PWRSTS_RET_ON,
+	.pwrsts_logic_ret = PWRSTS_RET,
 	.banks		  = 1,
 	.pwrsts_mem_ret	= {
 		[0] = PWRSTS_OFF_RET,	/* cpu1_l1 */
@@ -158,7 +158,7 @@ static struct powerdomain mpu_54xx_pwrdm = {
 	.prcm_offs	  = OMAP54XX_PRM_MPU_INST,
 	.prcm_partition	  = OMAP54XX_PRM_PARTITION,
 	.pwrsts		  = PWRSTS_RET_ON,
-	.pwrsts_logic_ret = PWRSTS_OFF_RET,
+	.pwrsts_logic_ret = PWRSTS_RET,
 	.banks		  = 2,
 	.pwrsts_mem_ret	= {
 		[0] = PWRSTS_OFF_RET,	/* mpu_l2 */
-- 
1.7.9.5


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

* [PATCH 2/7] ARM: OMAP5: powerdomain data: fix powerdomain powerstate
@ 2014-08-22 13:49   ` Nishanth Menon
  0 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-22 13:49 UTC (permalink / raw)
  To: linux-arm-kernel

Update the power domain power states for final production chip
capability. OFF mode, OSWR etc have been descoped for various domains.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-omap2/powerdomains54xx_data.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/powerdomains54xx_data.c b/arch/arm/mach-omap2/powerdomains54xx_data.c
index ce1d752..60d7ed8 100644
--- a/arch/arm/mach-omap2/powerdomains54xx_data.c
+++ b/arch/arm/mach-omap2/powerdomains54xx_data.c
@@ -35,7 +35,7 @@ static struct powerdomain core_54xx_pwrdm = {
 	.prcm_offs	  = OMAP54XX_PRM_CORE_INST,
 	.prcm_partition	  = OMAP54XX_PRM_PARTITION,
 	.pwrsts		  = PWRSTS_RET_ON,
-	.pwrsts_logic_ret = PWRSTS_OFF_RET,
+	.pwrsts_logic_ret = PWRSTS_RET,
 	.banks		  = 5,
 	.pwrsts_mem_ret	= {
 		[0] = PWRSTS_OFF_RET,	/* core_nret_bank */
@@ -107,8 +107,8 @@ static struct powerdomain cpu0_54xx_pwrdm = {
 	.voltdm		  = { .name = "mpu" },
 	.prcm_offs	  = OMAP54XX_PRCM_MPU_PRM_C0_INST,
 	.prcm_partition	  = OMAP54XX_PRCM_MPU_PARTITION,
-	.pwrsts		  = PWRSTS_OFF_RET_ON,
-	.pwrsts_logic_ret = PWRSTS_OFF_RET,
+	.pwrsts		  = PWRSTS_RET_ON,
+	.pwrsts_logic_ret = PWRSTS_RET,
 	.banks		  = 1,
 	.pwrsts_mem_ret	= {
 		[0] = PWRSTS_OFF_RET,	/* cpu0_l1 */
@@ -124,8 +124,8 @@ static struct powerdomain cpu1_54xx_pwrdm = {
 	.voltdm		  = { .name = "mpu" },
 	.prcm_offs	  = OMAP54XX_PRCM_MPU_PRM_C1_INST,
 	.prcm_partition	  = OMAP54XX_PRCM_MPU_PARTITION,
-	.pwrsts		  = PWRSTS_OFF_RET_ON,
-	.pwrsts_logic_ret = PWRSTS_OFF_RET,
+	.pwrsts		  = PWRSTS_RET_ON,
+	.pwrsts_logic_ret = PWRSTS_RET,
 	.banks		  = 1,
 	.pwrsts_mem_ret	= {
 		[0] = PWRSTS_OFF_RET,	/* cpu1_l1 */
@@ -158,7 +158,7 @@ static struct powerdomain mpu_54xx_pwrdm = {
 	.prcm_offs	  = OMAP54XX_PRM_MPU_INST,
 	.prcm_partition	  = OMAP54XX_PRM_PARTITION,
 	.pwrsts		  = PWRSTS_RET_ON,
-	.pwrsts_logic_ret = PWRSTS_OFF_RET,
+	.pwrsts_logic_ret = PWRSTS_RET,
 	.banks		  = 2,
 	.pwrsts_mem_ret	= {
 		[0] = PWRSTS_OFF_RET,	/* mpu_l2 */
-- 
1.7.9.5

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

* [PATCH 3/7] ARM: OMAP2+: powerdomain: pwrdm_for_each_clkdm iterate only valid clkdms
  2014-08-22 13:49 ` Nishanth Menon
  (?)
@ 2014-08-22 13:49   ` Nishanth Menon
  -1 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-22 13:49 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Kevin Hilman, Tero Kristo, Paul Walmsley, linux-arm-kernel,
	linux-omap, linux-kernel, Keerthy, Benoît Cousson,
	Santosh Shilimkar, Nishanth Menon

No need to invoke callback when the clkdm pointer is NULL.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-omap2/powerdomain.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
index faebd5f..f391948 100644
--- a/arch/arm/mach-omap2/powerdomain.c
+++ b/arch/arm/mach-omap2/powerdomain.c
@@ -546,7 +546,8 @@ int pwrdm_for_each_clkdm(struct powerdomain *pwrdm,
 		return -EINVAL;
 
 	for (i = 0; i < PWRDM_MAX_CLKDMS && !ret; i++)
-		ret = (*fn)(pwrdm, pwrdm->pwrdm_clkdms[i]);
+		if (pwrdm->pwrdm_clkdms[i])
+			ret = (*fn)(pwrdm, pwrdm->pwrdm_clkdms[i]);
 
 	return ret;
 }
-- 
1.7.9.5


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

* [PATCH 3/7] ARM: OMAP2+: powerdomain: pwrdm_for_each_clkdm iterate only valid clkdms
@ 2014-08-22 13:49   ` Nishanth Menon
  0 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-22 13:49 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Nishanth Menon, Paul Walmsley, Kevin Hilman, Keerthy,
	linux-kernel, Tero Kristo, Santosh Shilimkar,
	Benoît Cousson, linux-omap, linux-arm-kernel

No need to invoke callback when the clkdm pointer is NULL.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-omap2/powerdomain.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
index faebd5f..f391948 100644
--- a/arch/arm/mach-omap2/powerdomain.c
+++ b/arch/arm/mach-omap2/powerdomain.c
@@ -546,7 +546,8 @@ int pwrdm_for_each_clkdm(struct powerdomain *pwrdm,
 		return -EINVAL;
 
 	for (i = 0; i < PWRDM_MAX_CLKDMS && !ret; i++)
-		ret = (*fn)(pwrdm, pwrdm->pwrdm_clkdms[i]);
+		if (pwrdm->pwrdm_clkdms[i])
+			ret = (*fn)(pwrdm, pwrdm->pwrdm_clkdms[i]);
 
 	return ret;
 }
-- 
1.7.9.5

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

* [PATCH 3/7] ARM: OMAP2+: powerdomain: pwrdm_for_each_clkdm iterate only valid clkdms
@ 2014-08-22 13:49   ` Nishanth Menon
  0 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-22 13:49 UTC (permalink / raw)
  To: linux-arm-kernel

No need to invoke callback when the clkdm pointer is NULL.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-omap2/powerdomain.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
index faebd5f..f391948 100644
--- a/arch/arm/mach-omap2/powerdomain.c
+++ b/arch/arm/mach-omap2/powerdomain.c
@@ -546,7 +546,8 @@ int pwrdm_for_each_clkdm(struct powerdomain *pwrdm,
 		return -EINVAL;
 
 	for (i = 0; i < PWRDM_MAX_CLKDMS && !ret; i++)
-		ret = (*fn)(pwrdm, pwrdm->pwrdm_clkdms[i]);
+		if (pwrdm->pwrdm_clkdms[i])
+			ret = (*fn)(pwrdm, pwrdm->pwrdm_clkdms[i]);
 
 	return ret;
 }
-- 
1.7.9.5

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

* [PATCH 4/7] ARM: OMAP2+: powerdomain: introduce logic for finding valid power domain
  2014-08-22 13:49 ` Nishanth Menon
  (?)
@ 2014-08-22 13:49   ` Nishanth Menon
  -1 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-22 13:49 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Kevin Hilman, Tero Kristo, Paul Walmsley, linux-arm-kernel,
	linux-omap, linux-kernel, Keerthy, Benoît Cousson,
	Santosh Shilimkar, Nishanth Menon

powerdomain configuration in OMAP is done using PWRSTCTRL register for
each power domain. However, PRCM lets us write any value we'd like to
the logic and power domain target states, however the SoC integration
tends to actually function only at a few discrete states. These valid
states are already in our powerdomains_xxx_data.c file.

So, provide a function to easily query valid low power state that the
power domain is allowed to go to.

Based on work originally done by Jean Pihet <j-pihet@ti.com>
https://patchwork.kernel.org/patch/1325091/ . There is no attempt to
create a new powerdomain solution here, except fixing issues seen
attempting invalid programming attempts. Future consolidation to the
generic powerdomain framework should consider this requirement as
well.

Similar solutions have been done in product kernels in the past such
as:
https://android.googlesource.com/kernel/omap.git/+blame/android-omap-panda-3.0/arch/arm/mach-omap2/pm44xx.c

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-omap2/powerdomain.c |   73 +++++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/powerdomain.h |    3 ++
 2 files changed, 76 insertions(+)

diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
index f391948..831a2bc 100644
--- a/arch/arm/mach-omap2/powerdomain.c
+++ b/arch/arm/mach-omap2/powerdomain.c
@@ -1081,6 +1081,79 @@ int pwrdm_post_transition(struct powerdomain *pwrdm)
 }
 
 /**
+ * pwrdm_get_valid_lp_state() - Find best match deep power state
+ * @pwrdm:	power domain for which we want to find best match
+ * @is_logic_state: Are we looking for logic state match here? Should
+ *		    be one of PWRDM_xxx macro values
+ * @req_state:	requested power state
+ *
+ * Returns: closest match for requested power state. default fallback
+ * is RET for logic state and ON for power state.
+ *
+ * This does a search from the power domain data looking for the
+ * closest valid power domain state that the hardware can achieve.
+ * PRCM definitions for PWRSTCTRL allows us to program whatever
+ * configuration we'd like, and PRCM will actually attempt such
+ * a transition, however if the powerdomain does not actually support it,
+ * we endup with a hung system. The valid power domain states are already
+ * available in our powerdomain data files. So this function tries to do
+ * the following:
+ * a) find if we have an exact match to the request - no issues.
+ * b) else find if a deeper power state is possible.
+ * c) failing which, it tries to find closest higher power state for the
+ * request.
+ */
+u8 pwrdm_get_valid_lp_state(struct powerdomain *pwrdm,
+			    bool is_logic_state, u8 req_state)
+{
+	u8 pwrdm_states = is_logic_state ? pwrdm->pwrsts_logic_ret :
+			pwrdm->pwrsts;
+	/* For logic, ret is highest and others, ON is highest */
+	u8 default_pwrst = is_logic_state ? PWRDM_POWER_RET : PWRDM_POWER_ON;
+	u8 new_pwrst;
+	bool found;
+
+	/* If it is already supported, nothing to search */
+	if (pwrdm_states & BIT(req_state))
+		return req_state;
+
+	if (!req_state)
+		goto up_search;
+
+	/*
+	 * So, we dont have a exact match
+	 * Can we get a deeper power state match?
+	 */
+	new_pwrst = req_state - 1;
+	found = true;
+	while (!(pwrdm_states & BIT(new_pwrst))) {
+		/* No match even at OFF? Not available */
+		if (new_pwrst == PWRDM_POWER_OFF) {
+			found = false;
+			break;
+		}
+		new_pwrst--;
+	}
+
+	if (found)
+		goto done;
+
+up_search:
+	/* OK, no deeper ones, can we get a higher match? */
+	new_pwrst = req_state + 1;
+	while (!(pwrdm_states & BIT(new_pwrst))) {
+		/* BUG if we have messed up database */
+		BUG_ON(new_pwrst > PWRDM_POWER_ON);
+
+		if (new_pwrst == default_pwrst)
+			break;
+		new_pwrst++;
+	}
+done:
+	return new_pwrst;
+}
+
+/**
  * omap_set_pwrdm_state - change a powerdomain's current power state
  * @pwrdm: struct powerdomain * to change the power state of
  * @pwrst: power state to change to
diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h
index a754c82..11bd4dd 100644
--- a/arch/arm/mach-omap2/powerdomain.h
+++ b/arch/arm/mach-omap2/powerdomain.h
@@ -220,6 +220,9 @@ struct voltagedomain *pwrdm_get_voltdm(struct powerdomain *pwrdm);
 
 int pwrdm_get_mem_bank_count(struct powerdomain *pwrdm);
 
+u8 pwrdm_get_valid_lp_state(struct powerdomain *pwrdm,
+			    bool is_logic_state, u8 req_state);
+
 int pwrdm_set_next_pwrst(struct powerdomain *pwrdm, u8 pwrst);
 int pwrdm_read_next_pwrst(struct powerdomain *pwrdm);
 int pwrdm_read_pwrst(struct powerdomain *pwrdm);
-- 
1.7.9.5


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

* [PATCH 4/7] ARM: OMAP2+: powerdomain: introduce logic for finding valid power domain
@ 2014-08-22 13:49   ` Nishanth Menon
  0 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-22 13:49 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Nishanth Menon, Paul Walmsley, Kevin Hilman, Keerthy,
	linux-kernel, Tero Kristo, Santosh Shilimkar,
	Benoît Cousson, linux-omap, linux-arm-kernel

powerdomain configuration in OMAP is done using PWRSTCTRL register for
each power domain. However, PRCM lets us write any value we'd like to
the logic and power domain target states, however the SoC integration
tends to actually function only at a few discrete states. These valid
states are already in our powerdomains_xxx_data.c file.

So, provide a function to easily query valid low power state that the
power domain is allowed to go to.

Based on work originally done by Jean Pihet <j-pihet@ti.com>
https://patchwork.kernel.org/patch/1325091/ . There is no attempt to
create a new powerdomain solution here, except fixing issues seen
attempting invalid programming attempts. Future consolidation to the
generic powerdomain framework should consider this requirement as
well.

Similar solutions have been done in product kernels in the past such
as:
https://android.googlesource.com/kernel/omap.git/+blame/android-omap-panda-3.0/arch/arm/mach-omap2/pm44xx.c

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-omap2/powerdomain.c |   73 +++++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/powerdomain.h |    3 ++
 2 files changed, 76 insertions(+)

diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
index f391948..831a2bc 100644
--- a/arch/arm/mach-omap2/powerdomain.c
+++ b/arch/arm/mach-omap2/powerdomain.c
@@ -1081,6 +1081,79 @@ int pwrdm_post_transition(struct powerdomain *pwrdm)
 }
 
 /**
+ * pwrdm_get_valid_lp_state() - Find best match deep power state
+ * @pwrdm:	power domain for which we want to find best match
+ * @is_logic_state: Are we looking for logic state match here? Should
+ *		    be one of PWRDM_xxx macro values
+ * @req_state:	requested power state
+ *
+ * Returns: closest match for requested power state. default fallback
+ * is RET for logic state and ON for power state.
+ *
+ * This does a search from the power domain data looking for the
+ * closest valid power domain state that the hardware can achieve.
+ * PRCM definitions for PWRSTCTRL allows us to program whatever
+ * configuration we'd like, and PRCM will actually attempt such
+ * a transition, however if the powerdomain does not actually support it,
+ * we endup with a hung system. The valid power domain states are already
+ * available in our powerdomain data files. So this function tries to do
+ * the following:
+ * a) find if we have an exact match to the request - no issues.
+ * b) else find if a deeper power state is possible.
+ * c) failing which, it tries to find closest higher power state for the
+ * request.
+ */
+u8 pwrdm_get_valid_lp_state(struct powerdomain *pwrdm,
+			    bool is_logic_state, u8 req_state)
+{
+	u8 pwrdm_states = is_logic_state ? pwrdm->pwrsts_logic_ret :
+			pwrdm->pwrsts;
+	/* For logic, ret is highest and others, ON is highest */
+	u8 default_pwrst = is_logic_state ? PWRDM_POWER_RET : PWRDM_POWER_ON;
+	u8 new_pwrst;
+	bool found;
+
+	/* If it is already supported, nothing to search */
+	if (pwrdm_states & BIT(req_state))
+		return req_state;
+
+	if (!req_state)
+		goto up_search;
+
+	/*
+	 * So, we dont have a exact match
+	 * Can we get a deeper power state match?
+	 */
+	new_pwrst = req_state - 1;
+	found = true;
+	while (!(pwrdm_states & BIT(new_pwrst))) {
+		/* No match even at OFF? Not available */
+		if (new_pwrst == PWRDM_POWER_OFF) {
+			found = false;
+			break;
+		}
+		new_pwrst--;
+	}
+
+	if (found)
+		goto done;
+
+up_search:
+	/* OK, no deeper ones, can we get a higher match? */
+	new_pwrst = req_state + 1;
+	while (!(pwrdm_states & BIT(new_pwrst))) {
+		/* BUG if we have messed up database */
+		BUG_ON(new_pwrst > PWRDM_POWER_ON);
+
+		if (new_pwrst == default_pwrst)
+			break;
+		new_pwrst++;
+	}
+done:
+	return new_pwrst;
+}
+
+/**
  * omap_set_pwrdm_state - change a powerdomain's current power state
  * @pwrdm: struct powerdomain * to change the power state of
  * @pwrst: power state to change to
diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h
index a754c82..11bd4dd 100644
--- a/arch/arm/mach-omap2/powerdomain.h
+++ b/arch/arm/mach-omap2/powerdomain.h
@@ -220,6 +220,9 @@ struct voltagedomain *pwrdm_get_voltdm(struct powerdomain *pwrdm);
 
 int pwrdm_get_mem_bank_count(struct powerdomain *pwrdm);
 
+u8 pwrdm_get_valid_lp_state(struct powerdomain *pwrdm,
+			    bool is_logic_state, u8 req_state);
+
 int pwrdm_set_next_pwrst(struct powerdomain *pwrdm, u8 pwrst);
 int pwrdm_read_next_pwrst(struct powerdomain *pwrdm);
 int pwrdm_read_pwrst(struct powerdomain *pwrdm);
-- 
1.7.9.5

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

* [PATCH 4/7] ARM: OMAP2+: powerdomain: introduce logic for finding valid power domain
@ 2014-08-22 13:49   ` Nishanth Menon
  0 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-22 13:49 UTC (permalink / raw)
  To: linux-arm-kernel

powerdomain configuration in OMAP is done using PWRSTCTRL register for
each power domain. However, PRCM lets us write any value we'd like to
the logic and power domain target states, however the SoC integration
tends to actually function only at a few discrete states. These valid
states are already in our powerdomains_xxx_data.c file.

So, provide a function to easily query valid low power state that the
power domain is allowed to go to.

Based on work originally done by Jean Pihet <j-pihet@ti.com>
https://patchwork.kernel.org/patch/1325091/ . There is no attempt to
create a new powerdomain solution here, except fixing issues seen
attempting invalid programming attempts. Future consolidation to the
generic powerdomain framework should consider this requirement as
well.

Similar solutions have been done in product kernels in the past such
as:
https://android.googlesource.com/kernel/omap.git/+blame/android-omap-panda-3.0/arch/arm/mach-omap2/pm44xx.c

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-omap2/powerdomain.c |   73 +++++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/powerdomain.h |    3 ++
 2 files changed, 76 insertions(+)

diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
index f391948..831a2bc 100644
--- a/arch/arm/mach-omap2/powerdomain.c
+++ b/arch/arm/mach-omap2/powerdomain.c
@@ -1081,6 +1081,79 @@ int pwrdm_post_transition(struct powerdomain *pwrdm)
 }
 
 /**
+ * pwrdm_get_valid_lp_state() - Find best match deep power state
+ * @pwrdm:	power domain for which we want to find best match
+ * @is_logic_state: Are we looking for logic state match here? Should
+ *		    be one of PWRDM_xxx macro values
+ * @req_state:	requested power state
+ *
+ * Returns: closest match for requested power state. default fallback
+ * is RET for logic state and ON for power state.
+ *
+ * This does a search from the power domain data looking for the
+ * closest valid power domain state that the hardware can achieve.
+ * PRCM definitions for PWRSTCTRL allows us to program whatever
+ * configuration we'd like, and PRCM will actually attempt such
+ * a transition, however if the powerdomain does not actually support it,
+ * we endup with a hung system. The valid power domain states are already
+ * available in our powerdomain data files. So this function tries to do
+ * the following:
+ * a) find if we have an exact match to the request - no issues.
+ * b) else find if a deeper power state is possible.
+ * c) failing which, it tries to find closest higher power state for the
+ * request.
+ */
+u8 pwrdm_get_valid_lp_state(struct powerdomain *pwrdm,
+			    bool is_logic_state, u8 req_state)
+{
+	u8 pwrdm_states = is_logic_state ? pwrdm->pwrsts_logic_ret :
+			pwrdm->pwrsts;
+	/* For logic, ret is highest and others, ON is highest */
+	u8 default_pwrst = is_logic_state ? PWRDM_POWER_RET : PWRDM_POWER_ON;
+	u8 new_pwrst;
+	bool found;
+
+	/* If it is already supported, nothing to search */
+	if (pwrdm_states & BIT(req_state))
+		return req_state;
+
+	if (!req_state)
+		goto up_search;
+
+	/*
+	 * So, we dont have a exact match
+	 * Can we get a deeper power state match?
+	 */
+	new_pwrst = req_state - 1;
+	found = true;
+	while (!(pwrdm_states & BIT(new_pwrst))) {
+		/* No match even at OFF? Not available */
+		if (new_pwrst == PWRDM_POWER_OFF) {
+			found = false;
+			break;
+		}
+		new_pwrst--;
+	}
+
+	if (found)
+		goto done;
+
+up_search:
+	/* OK, no deeper ones, can we get a higher match? */
+	new_pwrst = req_state + 1;
+	while (!(pwrdm_states & BIT(new_pwrst))) {
+		/* BUG if we have messed up database */
+		BUG_ON(new_pwrst > PWRDM_POWER_ON);
+
+		if (new_pwrst == default_pwrst)
+			break;
+		new_pwrst++;
+	}
+done:
+	return new_pwrst;
+}
+
+/**
  * omap_set_pwrdm_state - change a powerdomain's current power state
  * @pwrdm: struct powerdomain * to change the power state of
  * @pwrst: power state to change to
diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h
index a754c82..11bd4dd 100644
--- a/arch/arm/mach-omap2/powerdomain.h
+++ b/arch/arm/mach-omap2/powerdomain.h
@@ -220,6 +220,9 @@ struct voltagedomain *pwrdm_get_voltdm(struct powerdomain *pwrdm);
 
 int pwrdm_get_mem_bank_count(struct powerdomain *pwrdm);
 
+u8 pwrdm_get_valid_lp_state(struct powerdomain *pwrdm,
+			    bool is_logic_state, u8 req_state);
+
 int pwrdm_set_next_pwrst(struct powerdomain *pwrdm, u8 pwrst);
 int pwrdm_read_next_pwrst(struct powerdomain *pwrdm);
 int pwrdm_read_pwrst(struct powerdomain *pwrdm);
-- 
1.7.9.5

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

* [PATCH 5/7] ARM: OMAP4+: PM: Make logic state programmable
  2014-08-22 13:49 ` Nishanth Menon
@ 2014-08-22 13:49   ` Nishanth Menon
  -1 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-22 13:49 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Kevin Hilman, Tero Kristo, Paul Walmsley, linux-arm-kernel,
	linux-omap, linux-kernel, Keerthy, Benoît Cousson,
	Santosh Shilimkar, Nishanth Menon

Move the logic state as different for each power domain. This allows us
to customize the deepest power state we should target over all for each
powerdomain in the follow on patches.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-omap2/pm44xx.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-omap2/pm44xx.c b/arch/arm/mach-omap2/pm44xx.c
index 0dda6cf..b377b03 100644
--- a/arch/arm/mach-omap2/pm44xx.c
+++ b/arch/arm/mach-omap2/pm44xx.c
@@ -29,6 +29,7 @@ u16 pm44xx_errata;
 struct power_state {
 	struct powerdomain *pwrdm;
 	u32 next_state;
+	u32 next_logic_state;
 #ifdef CONFIG_SUSPEND
 	u32 saved_state;
 	u32 saved_logic_state;
@@ -54,7 +55,7 @@ static int omap4_pm_suspend(void)
 	/* Set targeted power domain states by suspend */
 	list_for_each_entry(pwrst, &pwrst_list, node) {
 		omap_set_pwrdm_state(pwrst->pwrdm, pwrst->next_state);
-		pwrdm_set_logic_retst(pwrst->pwrdm, PWRDM_POWER_OFF);
+		pwrdm_set_logic_retst(pwrst->pwrdm, pwrst->next_logic_state);
 	}
 
 	/*
@@ -121,6 +122,8 @@ static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
 
 	pwrst->pwrdm = pwrdm;
 	pwrst->next_state = PWRDM_POWER_RET;
+	pwrst->next_logic_state = PWRDM_POWER_OFF;
+
 	list_add(&pwrst->node, &pwrst_list);
 
 	return omap_set_pwrdm_state(pwrst->pwrdm, pwrst->next_state);
-- 
1.7.9.5


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

* [PATCH 5/7] ARM: OMAP4+: PM: Make logic state programmable
@ 2014-08-22 13:49   ` Nishanth Menon
  0 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-22 13:49 UTC (permalink / raw)
  To: linux-arm-kernel

Move the logic state as different for each power domain. This allows us
to customize the deepest power state we should target over all for each
powerdomain in the follow on patches.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-omap2/pm44xx.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-omap2/pm44xx.c b/arch/arm/mach-omap2/pm44xx.c
index 0dda6cf..b377b03 100644
--- a/arch/arm/mach-omap2/pm44xx.c
+++ b/arch/arm/mach-omap2/pm44xx.c
@@ -29,6 +29,7 @@ u16 pm44xx_errata;
 struct power_state {
 	struct powerdomain *pwrdm;
 	u32 next_state;
+	u32 next_logic_state;
 #ifdef CONFIG_SUSPEND
 	u32 saved_state;
 	u32 saved_logic_state;
@@ -54,7 +55,7 @@ static int omap4_pm_suspend(void)
 	/* Set targeted power domain states by suspend */
 	list_for_each_entry(pwrst, &pwrst_list, node) {
 		omap_set_pwrdm_state(pwrst->pwrdm, pwrst->next_state);
-		pwrdm_set_logic_retst(pwrst->pwrdm, PWRDM_POWER_OFF);
+		pwrdm_set_logic_retst(pwrst->pwrdm, pwrst->next_logic_state);
 	}
 
 	/*
@@ -121,6 +122,8 @@ static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
 
 	pwrst->pwrdm = pwrdm;
 	pwrst->next_state = PWRDM_POWER_RET;
+	pwrst->next_logic_state = PWRDM_POWER_OFF;
+
 	list_add(&pwrst->node, &pwrst_list);
 
 	return omap_set_pwrdm_state(pwrst->pwrdm, pwrst->next_state);
-- 
1.7.9.5

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

* [PATCH 6/7] ARM: OMAP4+: PM: use only valid low power state for suspend
  2014-08-22 13:49 ` Nishanth Menon
  (?)
@ 2014-08-22 13:49   ` Nishanth Menon
  -1 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-22 13:49 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Kevin Hilman, Tero Kristo, Paul Walmsley, linux-arm-kernel,
	linux-omap, linux-kernel, Keerthy, Benoît Cousson,
	Santosh Shilimkar, Nishanth Menon

We are using power domain state as RET and logic state as OFF. This
state is OSWR. This may not always be supported on ALL power domains. In
fact, on certain power domains, this might result in a hang on certain
platforms. Instead, depend on powerdomain data to provide accurate
information about the supported powerdomain states and use the
appropriate function to query and use it as part of suspend path.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-omap2/pm44xx.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/pm44xx.c b/arch/arm/mach-omap2/pm44xx.c
index b377b03..0bfce38 100644
--- a/arch/arm/mach-omap2/pm44xx.c
+++ b/arch/arm/mach-omap2/pm44xx.c
@@ -121,8 +121,10 @@ static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
 		return -ENOMEM;
 
 	pwrst->pwrdm = pwrdm;
-	pwrst->next_state = PWRDM_POWER_RET;
-	pwrst->next_logic_state = PWRDM_POWER_OFF;
+	pwrst->next_state = pwrdm_get_valid_lp_state(pwrdm, false,
+						     PWRDM_POWER_RET);
+	pwrst->next_logic_state = pwrdm_get_valid_lp_state(pwrdm, true,
+							   PWRDM_POWER_OFF);
 
 	list_add(&pwrst->node, &pwrst_list);
 
-- 
1.7.9.5


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

* [PATCH 6/7] ARM: OMAP4+: PM: use only valid low power state for suspend
@ 2014-08-22 13:49   ` Nishanth Menon
  0 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-22 13:49 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Nishanth Menon, Paul Walmsley, Kevin Hilman, Keerthy,
	linux-kernel, Tero Kristo, Santosh Shilimkar,
	Benoît Cousson, linux-omap, linux-arm-kernel

We are using power domain state as RET and logic state as OFF. This
state is OSWR. This may not always be supported on ALL power domains. In
fact, on certain power domains, this might result in a hang on certain
platforms. Instead, depend on powerdomain data to provide accurate
information about the supported powerdomain states and use the
appropriate function to query and use it as part of suspend path.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-omap2/pm44xx.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/pm44xx.c b/arch/arm/mach-omap2/pm44xx.c
index b377b03..0bfce38 100644
--- a/arch/arm/mach-omap2/pm44xx.c
+++ b/arch/arm/mach-omap2/pm44xx.c
@@ -121,8 +121,10 @@ static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
 		return -ENOMEM;
 
 	pwrst->pwrdm = pwrdm;
-	pwrst->next_state = PWRDM_POWER_RET;
-	pwrst->next_logic_state = PWRDM_POWER_OFF;
+	pwrst->next_state = pwrdm_get_valid_lp_state(pwrdm, false,
+						     PWRDM_POWER_RET);
+	pwrst->next_logic_state = pwrdm_get_valid_lp_state(pwrdm, true,
+							   PWRDM_POWER_OFF);
 
 	list_add(&pwrst->node, &pwrst_list);
 
-- 
1.7.9.5

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

* [PATCH 6/7] ARM: OMAP4+: PM: use only valid low power state for suspend
@ 2014-08-22 13:49   ` Nishanth Menon
  0 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-22 13:49 UTC (permalink / raw)
  To: linux-arm-kernel

We are using power domain state as RET and logic state as OFF. This
state is OSWR. This may not always be supported on ALL power domains. In
fact, on certain power domains, this might result in a hang on certain
platforms. Instead, depend on powerdomain data to provide accurate
information about the supported powerdomain states and use the
appropriate function to query and use it as part of suspend path.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-omap2/pm44xx.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/pm44xx.c b/arch/arm/mach-omap2/pm44xx.c
index b377b03..0bfce38 100644
--- a/arch/arm/mach-omap2/pm44xx.c
+++ b/arch/arm/mach-omap2/pm44xx.c
@@ -121,8 +121,10 @@ static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
 		return -ENOMEM;
 
 	pwrst->pwrdm = pwrdm;
-	pwrst->next_state = PWRDM_POWER_RET;
-	pwrst->next_logic_state = PWRDM_POWER_OFF;
+	pwrst->next_state = pwrdm_get_valid_lp_state(pwrdm, false,
+						     PWRDM_POWER_RET);
+	pwrst->next_logic_state = pwrdm_get_valid_lp_state(pwrdm, true,
+							   PWRDM_POWER_OFF);
 
 	list_add(&pwrst->node, &pwrst_list);
 
-- 
1.7.9.5

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

* [PATCH 7/7] ARM: OMAP4+: PM: Use only valid low power state for CPU hotplug
  2014-08-22 13:49 ` Nishanth Menon
  (?)
@ 2014-08-22 13:49   ` Nishanth Menon
  -1 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-22 13:49 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Kevin Hilman, Tero Kristo, Paul Walmsley, linux-arm-kernel,
	linux-omap, linux-kernel, Keerthy, Benoît Cousson,
	Santosh Shilimkar, Nishanth Menon

Not all SoCs support OFF mode - for example DRA74/72. So, use valid
power state during CPU hotplug.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-omap2/omap-mpuss-lowpower.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
index 4001325..e9cdacf 100644
--- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
+++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
@@ -298,6 +298,10 @@ int omap4_hotplug_cpu(unsigned int cpu, unsigned int power_state)
 	if (omap_rev() == OMAP4430_REV_ES1_0)
 		return -ENXIO;
 
+	/* Use the achievable power state for the domain */
+	power_state = pwrdm_get_valid_lp_state(pm_info->pwrdm,
+					       false, power_state);
+
 	if (power_state == PWRDM_POWER_OFF)
 		cpu_state = 1;
 
-- 
1.7.9.5


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

* [PATCH 7/7] ARM: OMAP4+: PM: Use only valid low power state for CPU hotplug
@ 2014-08-22 13:49   ` Nishanth Menon
  0 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-22 13:49 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Nishanth Menon, Paul Walmsley, Kevin Hilman, Keerthy,
	linux-kernel, Tero Kristo, Santosh Shilimkar,
	Benoît Cousson, linux-omap, linux-arm-kernel

Not all SoCs support OFF mode - for example DRA74/72. So, use valid
power state during CPU hotplug.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-omap2/omap-mpuss-lowpower.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
index 4001325..e9cdacf 100644
--- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
+++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
@@ -298,6 +298,10 @@ int omap4_hotplug_cpu(unsigned int cpu, unsigned int power_state)
 	if (omap_rev() == OMAP4430_REV_ES1_0)
 		return -ENXIO;
 
+	/* Use the achievable power state for the domain */
+	power_state = pwrdm_get_valid_lp_state(pm_info->pwrdm,
+					       false, power_state);
+
 	if (power_state == PWRDM_POWER_OFF)
 		cpu_state = 1;
 
-- 
1.7.9.5

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

* [PATCH 7/7] ARM: OMAP4+: PM: Use only valid low power state for CPU hotplug
@ 2014-08-22 13:49   ` Nishanth Menon
  0 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-22 13:49 UTC (permalink / raw)
  To: linux-arm-kernel

Not all SoCs support OFF mode - for example DRA74/72. So, use valid
power state during CPU hotplug.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-omap2/omap-mpuss-lowpower.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
index 4001325..e9cdacf 100644
--- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
+++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
@@ -298,6 +298,10 @@ int omap4_hotplug_cpu(unsigned int cpu, unsigned int power_state)
 	if (omap_rev() == OMAP4430_REV_ES1_0)
 		return -ENXIO;
 
+	/* Use the achievable power state for the domain */
+	power_state = pwrdm_get_valid_lp_state(pm_info->pwrdm,
+					       false, power_state);
+
 	if (power_state == PWRDM_POWER_OFF)
 		cpu_state = 1;
 
-- 
1.7.9.5

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

* Re: [PATCH 4/7] ARM: OMAP2+: powerdomain: introduce logic for finding valid power domain
  2014-08-22 13:49   ` Nishanth Menon
@ 2014-08-27 18:27     ` Kevin Hilman
  -1 siblings, 0 replies; 37+ messages in thread
From: Kevin Hilman @ 2014-08-27 18:27 UTC (permalink / raw)
  To: Nishanth Menon
  Cc: Tony Lindgren, Tero Kristo, Paul Walmsley, linux-arm-kernel,
	linux-omap, linux-kernel, Keerthy, Benoît Cousson,
	Santosh Shilimkar

Nishanth Menon <nm@ti.com> writes:

> powerdomain configuration in OMAP is done using PWRSTCTRL register for
> each power domain. However, PRCM lets us write any value we'd like to
> the logic and power domain target states, however the SoC integration
> tends to actually function only at a few discrete states. These valid
> states are already in our powerdomains_xxx_data.c file.
>
> So, provide a function to easily query valid low power state that the
> power domain is allowed to go to.
>
> Based on work originally done by Jean Pihet <j-pihet@ti.com>
> https://patchwork.kernel.org/patch/1325091/ . There is no attempt to
> create a new powerdomain solution here, except fixing issues seen
> attempting invalid programming attempts. Future consolidation to the
> generic powerdomain framework should consider this requirement as
> well.
>
> Similar solutions have been done in product kernels in the past such
> as:
> https://android.googlesource.com/kernel/omap.git/+blame/android-omap-panda-3.0/arch/arm/mach-omap2/pm44xx.c
>
> Signed-off-by: Nishanth Menon <nm@ti.com>
> ---

nit: this is part of a fixes series, but it's more of a new feature.

That being said, the feature is needed and looks OK, except for...

> +up_search:
> +	/* OK, no deeper ones, can we get a higher match? */
> +	new_pwrst = req_state + 1;
> +	while (!(pwrdm_states & BIT(new_pwrst))) {
> +		/* BUG if we have messed up database */
> +		BUG_ON(new_pwrst > PWRDM_POWER_ON);

I don't think this is BUG() worthy, and should have a saner way to recover.

Kevin

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

* [PATCH 4/7] ARM: OMAP2+: powerdomain: introduce logic for finding valid power domain
@ 2014-08-27 18:27     ` Kevin Hilman
  0 siblings, 0 replies; 37+ messages in thread
From: Kevin Hilman @ 2014-08-27 18:27 UTC (permalink / raw)
  To: linux-arm-kernel

Nishanth Menon <nm@ti.com> writes:

> powerdomain configuration in OMAP is done using PWRSTCTRL register for
> each power domain. However, PRCM lets us write any value we'd like to
> the logic and power domain target states, however the SoC integration
> tends to actually function only at a few discrete states. These valid
> states are already in our powerdomains_xxx_data.c file.
>
> So, provide a function to easily query valid low power state that the
> power domain is allowed to go to.
>
> Based on work originally done by Jean Pihet <j-pihet@ti.com>
> https://patchwork.kernel.org/patch/1325091/ . There is no attempt to
> create a new powerdomain solution here, except fixing issues seen
> attempting invalid programming attempts. Future consolidation to the
> generic powerdomain framework should consider this requirement as
> well.
>
> Similar solutions have been done in product kernels in the past such
> as:
> https://android.googlesource.com/kernel/omap.git/+blame/android-omap-panda-3.0/arch/arm/mach-omap2/pm44xx.c
>
> Signed-off-by: Nishanth Menon <nm@ti.com>
> ---

nit: this is part of a fixes series, but it's more of a new feature.

That being said, the feature is needed and looks OK, except for...

> +up_search:
> +	/* OK, no deeper ones, can we get a higher match? */
> +	new_pwrst = req_state + 1;
> +	while (!(pwrdm_states & BIT(new_pwrst))) {
> +		/* BUG if we have messed up database */
> +		BUG_ON(new_pwrst > PWRDM_POWER_ON);

I don't think this is BUG() worthy, and should have a saner way to recover.

Kevin

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

* Re: [PATCH 0/7] ARM: OMAP4+: powerdomain fixes
  2014-08-22 13:49 ` Nishanth Menon
@ 2014-08-27 18:30   ` Kevin Hilman
  -1 siblings, 0 replies; 37+ messages in thread
From: Kevin Hilman @ 2014-08-27 18:30 UTC (permalink / raw)
  To: Nishanth Menon
  Cc: Tony Lindgren, Tero Kristo, Paul Walmsley, linux-arm-kernel,
	linux-omap, linux-kernel, Keerthy, Benoît Cousson,
	Santosh Shilimkar

Nishanth Menon <nm@ti.com> writes:

> The following series are various fixes and improvements for
> powerdomain support in OMAP4+.

Ah, here I see "fixes and improvements" since I was about to nipick that
the series contains more than just fixes.

Anyways, the series looks good to me.  After fixing up the BUG_ON issue,
feel free to add

Reviewed-by: Kevin Hilman <khilman@linaro.org>

> This is part 1/6 series which eventually enables framework for
> suspend-to-ram and cpuidle for OMAP5 and DRA7
>
> Each of series is based on v3.17-rc1 and this specific series is available:
> weblink: https://github.com/nmenon/linux-2.6-playground/commits/push/v3.17/powerdomain-fixes
>
> git repo: https://github.com/nmenon/linux-2.6-playground.git push/v3.17/powerdomain-fixes
>
> An complete integrated branch is available here: https://github.com/nmenon/linux-2.6-playground/commits/testing/v3.17/cpu-idle-suspend-dra7-omap5-framework
>
> Nishanth Menon (7):
>   ARM: OMAP: DRA7: powerdomain data: fix powerdomain powerstate
>   ARM: OMAP5: powerdomain data: fix powerdomain powerstate
>   ARM: OMAP2+: powerdomain: pwrdm_for_each_clkdm iterate only valid
>     clkdms
>   ARM: OMAP2+: powerdomain: introduce logic for finding valid power
>     domain
>   ARM: OMAP4+: PM: Make logic state programmable
>   ARM: OMAP4+: PM: use only valid low power state for suspend
>   ARM: OMAP4+: PM: Use only valid low power state for CPU hotplug
>
>  arch/arm/mach-omap2/omap-mpuss-lowpower.c   |    4 ++
>  arch/arm/mach-omap2/pm44xx.c                |    9 +++-
>  arch/arm/mach-omap2/powerdomain.c           |   76 ++++++++++++++++++++++++++-
>  arch/arm/mach-omap2/powerdomain.h           |    4 ++
>  arch/arm/mach-omap2/powerdomains54xx_data.c |   12 ++---
>  arch/arm/mach-omap2/powerdomains7xx_data.c  |   14 ++---
>  6 files changed, 103 insertions(+), 16 deletions(-)

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

* [PATCH 0/7] ARM: OMAP4+: powerdomain fixes
@ 2014-08-27 18:30   ` Kevin Hilman
  0 siblings, 0 replies; 37+ messages in thread
From: Kevin Hilman @ 2014-08-27 18:30 UTC (permalink / raw)
  To: linux-arm-kernel

Nishanth Menon <nm@ti.com> writes:

> The following series are various fixes and improvements for
> powerdomain support in OMAP4+.

Ah, here I see "fixes and improvements" since I was about to nipick that
the series contains more than just fixes.

Anyways, the series looks good to me.  After fixing up the BUG_ON issue,
feel free to add

Reviewed-by: Kevin Hilman <khilman@linaro.org>

> This is part 1/6 series which eventually enables framework for
> suspend-to-ram and cpuidle for OMAP5 and DRA7
>
> Each of series is based on v3.17-rc1 and this specific series is available:
> weblink: https://github.com/nmenon/linux-2.6-playground/commits/push/v3.17/powerdomain-fixes
>
> git repo: https://github.com/nmenon/linux-2.6-playground.git push/v3.17/powerdomain-fixes
>
> An complete integrated branch is available here: https://github.com/nmenon/linux-2.6-playground/commits/testing/v3.17/cpu-idle-suspend-dra7-omap5-framework
>
> Nishanth Menon (7):
>   ARM: OMAP: DRA7: powerdomain data: fix powerdomain powerstate
>   ARM: OMAP5: powerdomain data: fix powerdomain powerstate
>   ARM: OMAP2+: powerdomain: pwrdm_for_each_clkdm iterate only valid
>     clkdms
>   ARM: OMAP2+: powerdomain: introduce logic for finding valid power
>     domain
>   ARM: OMAP4+: PM: Make logic state programmable
>   ARM: OMAP4+: PM: use only valid low power state for suspend
>   ARM: OMAP4+: PM: Use only valid low power state for CPU hotplug
>
>  arch/arm/mach-omap2/omap-mpuss-lowpower.c   |    4 ++
>  arch/arm/mach-omap2/pm44xx.c                |    9 +++-
>  arch/arm/mach-omap2/powerdomain.c           |   76 ++++++++++++++++++++++++++-
>  arch/arm/mach-omap2/powerdomain.h           |    4 ++
>  arch/arm/mach-omap2/powerdomains54xx_data.c |   12 ++---
>  arch/arm/mach-omap2/powerdomains7xx_data.c  |   14 ++---
>  6 files changed, 103 insertions(+), 16 deletions(-)

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

* Re: [PATCH 4/7] ARM: OMAP2+: powerdomain: introduce logic for finding valid power domain
  2014-08-27 18:27     ` Kevin Hilman
@ 2014-08-27 18:35       ` Nishanth Menon
  -1 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-27 18:35 UTC (permalink / raw)
  To: Kevin Hilman
  Cc: Paul Walmsley, Tony Lindgren, Keerthy, lkml, Tero Kristo,
	Santosh Shilimkar, Benoît Cousson, linux-omap,
	linux-arm-kernel

On Wed, Aug 27, 2014 at 1:27 PM, Kevin Hilman
<khilman@deeprootsystems.com> wrote:
> Nishanth Menon <nm@ti.com> writes:
>
>> powerdomain configuration in OMAP is done using PWRSTCTRL register for
>> each power domain. However, PRCM lets us write any value we'd like to
>> the logic and power domain target states, however the SoC integration
>> tends to actually function only at a few discrete states. These valid
>> states are already in our powerdomains_xxx_data.c file.
>>
>> So, provide a function to easily query valid low power state that the
>> power domain is allowed to go to.
>>
>> Based on work originally done by Jean Pihet <j-pihet@ti.com>
>> https://patchwork.kernel.org/patch/1325091/ . There is no attempt to
>> create a new powerdomain solution here, except fixing issues seen
>> attempting invalid programming attempts. Future consolidation to the
>> generic powerdomain framework should consider this requirement as
>> well.
>>
>> Similar solutions have been done in product kernels in the past such
>> as:
>> https://android.googlesource.com/kernel/omap.git/+blame/android-omap-panda-3.0/arch/arm/mach-omap2/pm44xx.c
>>
>> Signed-off-by: Nishanth Menon <nm@ti.com>
>> ---
>
> nit: this is part of a fixes series, but it's more of a new feature.
>
> That being said, the feature is needed and looks OK, except for...
>
>> +up_search:
>> +     /* OK, no deeper ones, can we get a higher match? */
>> +     new_pwrst = req_state + 1;
>> +     while (!(pwrdm_states & BIT(new_pwrst))) {
>> +             /* BUG if we have messed up database */
>> +             BUG_ON(new_pwrst > PWRDM_POWER_ON);
>
> I don't think this is BUG() worthy, and should have a saner way to recover.

it is not even a legal value to have a power state higher than ON. I
mean, yeah, we can do
if (new_pwrst > PWRDM_POWER_ON) {
         pr_debug("powerdomain: %s: fix my powerdomain max to ON\n",
pwrdm->name);
         return PWRDM_POWER_ON;
}

if that is your suggestion here, personally, I would use a WARN at least here..

-- 
---
Regards,
Nishanth Menon

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

* [PATCH 4/7] ARM: OMAP2+: powerdomain: introduce logic for finding valid power domain
@ 2014-08-27 18:35       ` Nishanth Menon
  0 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-27 18:35 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Aug 27, 2014 at 1:27 PM, Kevin Hilman
<khilman@deeprootsystems.com> wrote:
> Nishanth Menon <nm@ti.com> writes:
>
>> powerdomain configuration in OMAP is done using PWRSTCTRL register for
>> each power domain. However, PRCM lets us write any value we'd like to
>> the logic and power domain target states, however the SoC integration
>> tends to actually function only at a few discrete states. These valid
>> states are already in our powerdomains_xxx_data.c file.
>>
>> So, provide a function to easily query valid low power state that the
>> power domain is allowed to go to.
>>
>> Based on work originally done by Jean Pihet <j-pihet@ti.com>
>> https://patchwork.kernel.org/patch/1325091/ . There is no attempt to
>> create a new powerdomain solution here, except fixing issues seen
>> attempting invalid programming attempts. Future consolidation to the
>> generic powerdomain framework should consider this requirement as
>> well.
>>
>> Similar solutions have been done in product kernels in the past such
>> as:
>> https://android.googlesource.com/kernel/omap.git/+blame/android-omap-panda-3.0/arch/arm/mach-omap2/pm44xx.c
>>
>> Signed-off-by: Nishanth Menon <nm@ti.com>
>> ---
>
> nit: this is part of a fixes series, but it's more of a new feature.
>
> That being said, the feature is needed and looks OK, except for...
>
>> +up_search:
>> +     /* OK, no deeper ones, can we get a higher match? */
>> +     new_pwrst = req_state + 1;
>> +     while (!(pwrdm_states & BIT(new_pwrst))) {
>> +             /* BUG if we have messed up database */
>> +             BUG_ON(new_pwrst > PWRDM_POWER_ON);
>
> I don't think this is BUG() worthy, and should have a saner way to recover.

it is not even a legal value to have a power state higher than ON. I
mean, yeah, we can do
if (new_pwrst > PWRDM_POWER_ON) {
         pr_debug("powerdomain: %s: fix my powerdomain max to ON\n",
pwrdm->name);
         return PWRDM_POWER_ON;
}

if that is your suggestion here, personally, I would use a WARN at least here..

-- 
---
Regards,
Nishanth Menon

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

* Re: [PATCH 0/7] ARM: OMAP4+: powerdomain fixes
  2014-08-22 13:49 ` Nishanth Menon
@ 2014-08-27 18:37   ` Santosh Shilimkar
  -1 siblings, 0 replies; 37+ messages in thread
From: Santosh Shilimkar @ 2014-08-27 18:37 UTC (permalink / raw)
  To: Nishanth Menon, Tony Lindgren
  Cc: Kevin Hilman, Tero Kristo, Paul Walmsley, linux-arm-kernel,
	linux-omap, linux-kernel, Keerthy, Benoît Cousson

On Friday 22 August 2014 09:49 AM, Nishanth Menon wrote:
> Hi,
> 
> The following series are various fixes and improvements for
> powerdomain support in OMAP4+.
> 
> This is part 1/6 series which eventually enables framework for
> suspend-to-ram and cpuidle for OMAP5 and DRA7
> 
> Each of series is based on v3.17-rc1 and this specific series is available:
> weblink: https://github.com/nmenon/linux-2.6-playground/commits/push/v3.17/powerdomain-fixes
>
Series looks good to me. The achievable power state doesn't apeal much but with so many
variations of SOCs, descopes etc, it probably makes sense.

Once you update Kevin's BUG() comments, feel free to add my ack.

Regards,
Santosh
 


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

* [PATCH 0/7] ARM: OMAP4+: powerdomain fixes
@ 2014-08-27 18:37   ` Santosh Shilimkar
  0 siblings, 0 replies; 37+ messages in thread
From: Santosh Shilimkar @ 2014-08-27 18:37 UTC (permalink / raw)
  To: linux-arm-kernel

On Friday 22 August 2014 09:49 AM, Nishanth Menon wrote:
> Hi,
> 
> The following series are various fixes and improvements for
> powerdomain support in OMAP4+.
> 
> This is part 1/6 series which eventually enables framework for
> suspend-to-ram and cpuidle for OMAP5 and DRA7
> 
> Each of series is based on v3.17-rc1 and this specific series is available:
> weblink: https://github.com/nmenon/linux-2.6-playground/commits/push/v3.17/powerdomain-fixes
>
Series looks good to me. The achievable power state doesn't apeal much but with so many
variations of SOCs, descopes etc, it probably makes sense.

Once you update Kevin's BUG() comments, feel free to add my ack.

Regards,
Santosh
 

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

* Re: [PATCH 4/7] ARM: OMAP2+: powerdomain: introduce logic for finding valid power domain
  2014-08-27 18:35       ` Nishanth Menon
@ 2014-08-27 18:39         ` Kevin Hilman
  -1 siblings, 0 replies; 37+ messages in thread
From: Kevin Hilman @ 2014-08-27 18:39 UTC (permalink / raw)
  To: Nishanth Menon
  Cc: Paul Walmsley, Tony Lindgren, Keerthy, lkml, Tero Kristo,
	Santosh Shilimkar, Benoît Cousson, linux-omap,
	linux-arm-kernel

On Wed, Aug 27, 2014 at 11:35 AM, Nishanth Menon <nm@ti.com> wrote:
> On Wed, Aug 27, 2014 at 1:27 PM, Kevin Hilman
> <khilman@deeprootsystems.com> wrote:
>> Nishanth Menon <nm@ti.com> writes:
>>
>>> powerdomain configuration in OMAP is done using PWRSTCTRL register for
>>> each power domain. However, PRCM lets us write any value we'd like to
>>> the logic and power domain target states, however the SoC integration
>>> tends to actually function only at a few discrete states. These valid
>>> states are already in our powerdomains_xxx_data.c file.
>>>
>>> So, provide a function to easily query valid low power state that the
>>> power domain is allowed to go to.
>>>
>>> Based on work originally done by Jean Pihet <j-pihet@ti.com>
>>> https://patchwork.kernel.org/patch/1325091/ . There is no attempt to
>>> create a new powerdomain solution here, except fixing issues seen
>>> attempting invalid programming attempts. Future consolidation to the
>>> generic powerdomain framework should consider this requirement as
>>> well.
>>>
>>> Similar solutions have been done in product kernels in the past such
>>> as:
>>> https://android.googlesource.com/kernel/omap.git/+blame/android-omap-panda-3.0/arch/arm/mach-omap2/pm44xx.c
>>>
>>> Signed-off-by: Nishanth Menon <nm@ti.com>
>>> ---
>>
>> nit: this is part of a fixes series, but it's more of a new feature.
>>
>> That being said, the feature is needed and looks OK, except for...
>>
>>> +up_search:
>>> +     /* OK, no deeper ones, can we get a higher match? */
>>> +     new_pwrst = req_state + 1;
>>> +     while (!(pwrdm_states & BIT(new_pwrst))) {
>>> +             /* BUG if we have messed up database */
>>> +             BUG_ON(new_pwrst > PWRDM_POWER_ON);
>>
>> I don't think this is BUG() worthy, and should have a saner way to recover.
>
> it is not even a legal value to have a power state higher than ON. I
> mean, yeah, we can do
> if (new_pwrst > PWRDM_POWER_ON) {
>          pr_debug("powerdomain: %s: fix my powerdomain max to ON\n",
> pwrdm->name);
>          return PWRDM_POWER_ON;
> }
>
> if that is your suggestion here, personally, I would use a WARN at least here..

WARN, pr_warn() as you like.

The point is that BUG* calls panic() and locks up the system tight.
As what your'e adding is not fatal to the entire system, you should
not be using bug.  From asm-generic/bug.h:

*
 * Don't use BUG() or BUG_ON() unless there's really no way out; one
 * example might be detecting data structure corruption in the middle
 * of an operation that can't be backed out of.  If the (sub)system
 * can somehow continue operating, perhaps with reduced functionality,
 * it's probably not BUG-worthy.
 *
 * If you're tempted to BUG(), think again:  is completely giving up
 * really the *only* solution?  There are usually better options, where
 * users don't need to reboot ASAP and can mostly shut down cleanly.
 */

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

* [PATCH 4/7] ARM: OMAP2+: powerdomain: introduce logic for finding valid power domain
@ 2014-08-27 18:39         ` Kevin Hilman
  0 siblings, 0 replies; 37+ messages in thread
From: Kevin Hilman @ 2014-08-27 18:39 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Aug 27, 2014 at 11:35 AM, Nishanth Menon <nm@ti.com> wrote:
> On Wed, Aug 27, 2014 at 1:27 PM, Kevin Hilman
> <khilman@deeprootsystems.com> wrote:
>> Nishanth Menon <nm@ti.com> writes:
>>
>>> powerdomain configuration in OMAP is done using PWRSTCTRL register for
>>> each power domain. However, PRCM lets us write any value we'd like to
>>> the logic and power domain target states, however the SoC integration
>>> tends to actually function only at a few discrete states. These valid
>>> states are already in our powerdomains_xxx_data.c file.
>>>
>>> So, provide a function to easily query valid low power state that the
>>> power domain is allowed to go to.
>>>
>>> Based on work originally done by Jean Pihet <j-pihet@ti.com>
>>> https://patchwork.kernel.org/patch/1325091/ . There is no attempt to
>>> create a new powerdomain solution here, except fixing issues seen
>>> attempting invalid programming attempts. Future consolidation to the
>>> generic powerdomain framework should consider this requirement as
>>> well.
>>>
>>> Similar solutions have been done in product kernels in the past such
>>> as:
>>> https://android.googlesource.com/kernel/omap.git/+blame/android-omap-panda-3.0/arch/arm/mach-omap2/pm44xx.c
>>>
>>> Signed-off-by: Nishanth Menon <nm@ti.com>
>>> ---
>>
>> nit: this is part of a fixes series, but it's more of a new feature.
>>
>> That being said, the feature is needed and looks OK, except for...
>>
>>> +up_search:
>>> +     /* OK, no deeper ones, can we get a higher match? */
>>> +     new_pwrst = req_state + 1;
>>> +     while (!(pwrdm_states & BIT(new_pwrst))) {
>>> +             /* BUG if we have messed up database */
>>> +             BUG_ON(new_pwrst > PWRDM_POWER_ON);
>>
>> I don't think this is BUG() worthy, and should have a saner way to recover.
>
> it is not even a legal value to have a power state higher than ON. I
> mean, yeah, we can do
> if (new_pwrst > PWRDM_POWER_ON) {
>          pr_debug("powerdomain: %s: fix my powerdomain max to ON\n",
> pwrdm->name);
>          return PWRDM_POWER_ON;
> }
>
> if that is your suggestion here, personally, I would use a WARN at least here..

WARN, pr_warn() as you like.

The point is that BUG* calls panic() and locks up the system tight.
As what your'e adding is not fatal to the entire system, you should
not be using bug.  From asm-generic/bug.h:

*
 * Don't use BUG() or BUG_ON() unless there's really no way out; one
 * example might be detecting data structure corruption in the middle
 * of an operation that can't be backed out of.  If the (sub)system
 * can somehow continue operating, perhaps with reduced functionality,
 * it's probably not BUG-worthy.
 *
 * If you're tempted to BUG(), think again:  is completely giving up
 * really the *only* solution?  There are usually better options, where
 * users don't need to reboot ASAP and can mostly shut down cleanly.
 */

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

* [PATCH V2 4/7] ARM: OMAP2+: powerdomain: introduce logic for finding valid power domain
  2014-08-22 13:49 ` Nishanth Menon
  (?)
@ 2014-08-27 18:54   ` Nishanth Menon
  -1 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-27 18:54 UTC (permalink / raw)
  To: Tony Lindgren, Kevin Hilman, Santosh Shilimkar
  Cc: Paul Walmsley, Tero Kristo, linux-arm-kernel, linux-omap,
	linux-kernel, j-keerthy, bcousson, Nishanth Menon

powerdomain configuration in OMAP is done using PWRSTCTRL register for
each power domain. However, PRCM lets us write any value we'd like to
the logic and power domain target states, however the SoC integration
tends to actually function only at a few discrete states. These valid
states are already in our powerdomains_xxx_data.c file.

So, provide a function to easily query valid low power state that the
power domain is allowed to go to.

Based on work originally done by Jean Pihet <j-pihet@ti.com>
https://patchwork.kernel.org/patch/1325091/ . There is no attempt to
create a new powerdomain solution here, except fixing issues seen
attempting invalid programming attempts. Future consolidation to the
generic powerdomain framework should consider this requirement as
well.

Similar solutions have been done in product kernels in the past such
as:
https://android.googlesource.com/kernel/omap.git/+blame/android-omap-panda-3.0/arch/arm/mach-omap2/pm44xx.c

Reviewed-by: Kevin Hilman <khilman@linaro.org>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
---

Not posting the entire series again and updating just this patch..

V2: drop BUG in favor of WARN, picked up Santosh and Kevin's acks.

V1: https://patchwork.kernel.org/patch/4764131/

 arch/arm/mach-omap2/powerdomain.c |   76 +++++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/powerdomain.h |    3 ++
 2 files changed, 79 insertions(+)

diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
index f391948..7fb033e 100644
--- a/arch/arm/mach-omap2/powerdomain.c
+++ b/arch/arm/mach-omap2/powerdomain.c
@@ -1081,6 +1081,82 @@ int pwrdm_post_transition(struct powerdomain *pwrdm)
 }
 
 /**
+ * pwrdm_get_valid_lp_state() - Find best match deep power state
+ * @pwrdm:	power domain for which we want to find best match
+ * @is_logic_state: Are we looking for logic state match here? Should
+ *		    be one of PWRDM_xxx macro values
+ * @req_state:	requested power state
+ *
+ * Returns: closest match for requested power state. default fallback
+ * is RET for logic state and ON for power state.
+ *
+ * This does a search from the power domain data looking for the
+ * closest valid power domain state that the hardware can achieve.
+ * PRCM definitions for PWRSTCTRL allows us to program whatever
+ * configuration we'd like, and PRCM will actually attempt such
+ * a transition, however if the powerdomain does not actually support it,
+ * we endup with a hung system. The valid power domain states are already
+ * available in our powerdomain data files. So this function tries to do
+ * the following:
+ * a) find if we have an exact match to the request - no issues.
+ * b) else find if a deeper power state is possible.
+ * c) failing which, it tries to find closest higher power state for the
+ * request.
+ */
+u8 pwrdm_get_valid_lp_state(struct powerdomain *pwrdm,
+			    bool is_logic_state, u8 req_state)
+{
+	u8 pwrdm_states = is_logic_state ? pwrdm->pwrsts_logic_ret :
+			pwrdm->pwrsts;
+	/* For logic, ret is highest and others, ON is highest */
+	u8 default_pwrst = is_logic_state ? PWRDM_POWER_RET : PWRDM_POWER_ON;
+	u8 new_pwrst;
+	bool found;
+
+	/* If it is already supported, nothing to search */
+	if (pwrdm_states & BIT(req_state))
+		return req_state;
+
+	if (!req_state)
+		goto up_search;
+
+	/*
+	 * So, we dont have a exact match
+	 * Can we get a deeper power state match?
+	 */
+	new_pwrst = req_state - 1;
+	found = true;
+	while (!(pwrdm_states & BIT(new_pwrst))) {
+		/* No match even at OFF? Not available */
+		if (new_pwrst == PWRDM_POWER_OFF) {
+			found = false;
+			break;
+		}
+		new_pwrst--;
+	}
+
+	if (found)
+		goto done;
+
+up_search:
+	/* OK, no deeper ones, can we get a higher match? */
+	new_pwrst = req_state + 1;
+	while (!(pwrdm_states & BIT(new_pwrst))) {
+		if (new_pwrst > PWRDM_POWER_ON) {
+			WARN(1, "powerdomain: %s: Fix max powerstate to ON\n",
+			     pwrdm->name);
+			return PWRDM_POWER_ON;
+		}
+
+		if (new_pwrst == default_pwrst)
+			break;
+		new_pwrst++;
+	}
+done:
+	return new_pwrst;
+}
+
+/**
  * omap_set_pwrdm_state - change a powerdomain's current power state
  * @pwrdm: struct powerdomain * to change the power state of
  * @pwrst: power state to change to
diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h
index a754c82..11bd4dd 100644
--- a/arch/arm/mach-omap2/powerdomain.h
+++ b/arch/arm/mach-omap2/powerdomain.h
@@ -220,6 +220,9 @@ struct voltagedomain *pwrdm_get_voltdm(struct powerdomain *pwrdm);
 
 int pwrdm_get_mem_bank_count(struct powerdomain *pwrdm);
 
+u8 pwrdm_get_valid_lp_state(struct powerdomain *pwrdm,
+			    bool is_logic_state, u8 req_state);
+
 int pwrdm_set_next_pwrst(struct powerdomain *pwrdm, u8 pwrst);
 int pwrdm_read_next_pwrst(struct powerdomain *pwrdm);
 int pwrdm_read_pwrst(struct powerdomain *pwrdm);
-- 
1.7.9.5


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

* [PATCH V2 4/7] ARM: OMAP2+: powerdomain: introduce logic for finding valid power domain
@ 2014-08-27 18:54   ` Nishanth Menon
  0 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-27 18:54 UTC (permalink / raw)
  To: Tony Lindgren, Kevin Hilman, Santosh Shilimkar
  Cc: Paul Walmsley, Tero Kristo, linux-arm-kernel, linux-omap,
	linux-kernel, j-keerthy, bcousson, Nishanth Menon

powerdomain configuration in OMAP is done using PWRSTCTRL register for
each power domain. However, PRCM lets us write any value we'd like to
the logic and power domain target states, however the SoC integration
tends to actually function only at a few discrete states. These valid
states are already in our powerdomains_xxx_data.c file.

So, provide a function to easily query valid low power state that the
power domain is allowed to go to.

Based on work originally done by Jean Pihet <j-pihet@ti.com>
https://patchwork.kernel.org/patch/1325091/ . There is no attempt to
create a new powerdomain solution here, except fixing issues seen
attempting invalid programming attempts. Future consolidation to the
generic powerdomain framework should consider this requirement as
well.

Similar solutions have been done in product kernels in the past such
as:
https://android.googlesource.com/kernel/omap.git/+blame/android-omap-panda-3.0/arch/arm/mach-omap2/pm44xx.c

Reviewed-by: Kevin Hilman <khilman@linaro.org>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
---

Not posting the entire series again and updating just this patch..

V2: drop BUG in favor of WARN, picked up Santosh and Kevin's acks.

V1: https://patchwork.kernel.org/patch/4764131/

 arch/arm/mach-omap2/powerdomain.c |   76 +++++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/powerdomain.h |    3 ++
 2 files changed, 79 insertions(+)

diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
index f391948..7fb033e 100644
--- a/arch/arm/mach-omap2/powerdomain.c
+++ b/arch/arm/mach-omap2/powerdomain.c
@@ -1081,6 +1081,82 @@ int pwrdm_post_transition(struct powerdomain *pwrdm)
 }
 
 /**
+ * pwrdm_get_valid_lp_state() - Find best match deep power state
+ * @pwrdm:	power domain for which we want to find best match
+ * @is_logic_state: Are we looking for logic state match here? Should
+ *		    be one of PWRDM_xxx macro values
+ * @req_state:	requested power state
+ *
+ * Returns: closest match for requested power state. default fallback
+ * is RET for logic state and ON for power state.
+ *
+ * This does a search from the power domain data looking for the
+ * closest valid power domain state that the hardware can achieve.
+ * PRCM definitions for PWRSTCTRL allows us to program whatever
+ * configuration we'd like, and PRCM will actually attempt such
+ * a transition, however if the powerdomain does not actually support it,
+ * we endup with a hung system. The valid power domain states are already
+ * available in our powerdomain data files. So this function tries to do
+ * the following:
+ * a) find if we have an exact match to the request - no issues.
+ * b) else find if a deeper power state is possible.
+ * c) failing which, it tries to find closest higher power state for the
+ * request.
+ */
+u8 pwrdm_get_valid_lp_state(struct powerdomain *pwrdm,
+			    bool is_logic_state, u8 req_state)
+{
+	u8 pwrdm_states = is_logic_state ? pwrdm->pwrsts_logic_ret :
+			pwrdm->pwrsts;
+	/* For logic, ret is highest and others, ON is highest */
+	u8 default_pwrst = is_logic_state ? PWRDM_POWER_RET : PWRDM_POWER_ON;
+	u8 new_pwrst;
+	bool found;
+
+	/* If it is already supported, nothing to search */
+	if (pwrdm_states & BIT(req_state))
+		return req_state;
+
+	if (!req_state)
+		goto up_search;
+
+	/*
+	 * So, we dont have a exact match
+	 * Can we get a deeper power state match?
+	 */
+	new_pwrst = req_state - 1;
+	found = true;
+	while (!(pwrdm_states & BIT(new_pwrst))) {
+		/* No match even at OFF? Not available */
+		if (new_pwrst == PWRDM_POWER_OFF) {
+			found = false;
+			break;
+		}
+		new_pwrst--;
+	}
+
+	if (found)
+		goto done;
+
+up_search:
+	/* OK, no deeper ones, can we get a higher match? */
+	new_pwrst = req_state + 1;
+	while (!(pwrdm_states & BIT(new_pwrst))) {
+		if (new_pwrst > PWRDM_POWER_ON) {
+			WARN(1, "powerdomain: %s: Fix max powerstate to ON\n",
+			     pwrdm->name);
+			return PWRDM_POWER_ON;
+		}
+
+		if (new_pwrst == default_pwrst)
+			break;
+		new_pwrst++;
+	}
+done:
+	return new_pwrst;
+}
+
+/**
  * omap_set_pwrdm_state - change a powerdomain's current power state
  * @pwrdm: struct powerdomain * to change the power state of
  * @pwrst: power state to change to
diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h
index a754c82..11bd4dd 100644
--- a/arch/arm/mach-omap2/powerdomain.h
+++ b/arch/arm/mach-omap2/powerdomain.h
@@ -220,6 +220,9 @@ struct voltagedomain *pwrdm_get_voltdm(struct powerdomain *pwrdm);
 
 int pwrdm_get_mem_bank_count(struct powerdomain *pwrdm);
 
+u8 pwrdm_get_valid_lp_state(struct powerdomain *pwrdm,
+			    bool is_logic_state, u8 req_state);
+
 int pwrdm_set_next_pwrst(struct powerdomain *pwrdm, u8 pwrst);
 int pwrdm_read_next_pwrst(struct powerdomain *pwrdm);
 int pwrdm_read_pwrst(struct powerdomain *pwrdm);
-- 
1.7.9.5


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

* [PATCH V2 4/7] ARM: OMAP2+: powerdomain: introduce logic for finding valid power domain
@ 2014-08-27 18:54   ` Nishanth Menon
  0 siblings, 0 replies; 37+ messages in thread
From: Nishanth Menon @ 2014-08-27 18:54 UTC (permalink / raw)
  To: linux-arm-kernel

powerdomain configuration in OMAP is done using PWRSTCTRL register for
each power domain. However, PRCM lets us write any value we'd like to
the logic and power domain target states, however the SoC integration
tends to actually function only at a few discrete states. These valid
states are already in our powerdomains_xxx_data.c file.

So, provide a function to easily query valid low power state that the
power domain is allowed to go to.

Based on work originally done by Jean Pihet <j-pihet@ti.com>
https://patchwork.kernel.org/patch/1325091/ . There is no attempt to
create a new powerdomain solution here, except fixing issues seen
attempting invalid programming attempts. Future consolidation to the
generic powerdomain framework should consider this requirement as
well.

Similar solutions have been done in product kernels in the past such
as:
https://android.googlesource.com/kernel/omap.git/+blame/android-omap-panda-3.0/arch/arm/mach-omap2/pm44xx.c

Reviewed-by: Kevin Hilman <khilman@linaro.org>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
---

Not posting the entire series again and updating just this patch..

V2: drop BUG in favor of WARN, picked up Santosh and Kevin's acks.

V1: https://patchwork.kernel.org/patch/4764131/

 arch/arm/mach-omap2/powerdomain.c |   76 +++++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/powerdomain.h |    3 ++
 2 files changed, 79 insertions(+)

diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
index f391948..7fb033e 100644
--- a/arch/arm/mach-omap2/powerdomain.c
+++ b/arch/arm/mach-omap2/powerdomain.c
@@ -1081,6 +1081,82 @@ int pwrdm_post_transition(struct powerdomain *pwrdm)
 }
 
 /**
+ * pwrdm_get_valid_lp_state() - Find best match deep power state
+ * @pwrdm:	power domain for which we want to find best match
+ * @is_logic_state: Are we looking for logic state match here? Should
+ *		    be one of PWRDM_xxx macro values
+ * @req_state:	requested power state
+ *
+ * Returns: closest match for requested power state. default fallback
+ * is RET for logic state and ON for power state.
+ *
+ * This does a search from the power domain data looking for the
+ * closest valid power domain state that the hardware can achieve.
+ * PRCM definitions for PWRSTCTRL allows us to program whatever
+ * configuration we'd like, and PRCM will actually attempt such
+ * a transition, however if the powerdomain does not actually support it,
+ * we endup with a hung system. The valid power domain states are already
+ * available in our powerdomain data files. So this function tries to do
+ * the following:
+ * a) find if we have an exact match to the request - no issues.
+ * b) else find if a deeper power state is possible.
+ * c) failing which, it tries to find closest higher power state for the
+ * request.
+ */
+u8 pwrdm_get_valid_lp_state(struct powerdomain *pwrdm,
+			    bool is_logic_state, u8 req_state)
+{
+	u8 pwrdm_states = is_logic_state ? pwrdm->pwrsts_logic_ret :
+			pwrdm->pwrsts;
+	/* For logic, ret is highest and others, ON is highest */
+	u8 default_pwrst = is_logic_state ? PWRDM_POWER_RET : PWRDM_POWER_ON;
+	u8 new_pwrst;
+	bool found;
+
+	/* If it is already supported, nothing to search */
+	if (pwrdm_states & BIT(req_state))
+		return req_state;
+
+	if (!req_state)
+		goto up_search;
+
+	/*
+	 * So, we dont have a exact match
+	 * Can we get a deeper power state match?
+	 */
+	new_pwrst = req_state - 1;
+	found = true;
+	while (!(pwrdm_states & BIT(new_pwrst))) {
+		/* No match even at OFF? Not available */
+		if (new_pwrst == PWRDM_POWER_OFF) {
+			found = false;
+			break;
+		}
+		new_pwrst--;
+	}
+
+	if (found)
+		goto done;
+
+up_search:
+	/* OK, no deeper ones, can we get a higher match? */
+	new_pwrst = req_state + 1;
+	while (!(pwrdm_states & BIT(new_pwrst))) {
+		if (new_pwrst > PWRDM_POWER_ON) {
+			WARN(1, "powerdomain: %s: Fix max powerstate to ON\n",
+			     pwrdm->name);
+			return PWRDM_POWER_ON;
+		}
+
+		if (new_pwrst == default_pwrst)
+			break;
+		new_pwrst++;
+	}
+done:
+	return new_pwrst;
+}
+
+/**
  * omap_set_pwrdm_state - change a powerdomain's current power state
  * @pwrdm: struct powerdomain * to change the power state of
  * @pwrst: power state to change to
diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h
index a754c82..11bd4dd 100644
--- a/arch/arm/mach-omap2/powerdomain.h
+++ b/arch/arm/mach-omap2/powerdomain.h
@@ -220,6 +220,9 @@ struct voltagedomain *pwrdm_get_voltdm(struct powerdomain *pwrdm);
 
 int pwrdm_get_mem_bank_count(struct powerdomain *pwrdm);
 
+u8 pwrdm_get_valid_lp_state(struct powerdomain *pwrdm,
+			    bool is_logic_state, u8 req_state);
+
 int pwrdm_set_next_pwrst(struct powerdomain *pwrdm, u8 pwrst);
 int pwrdm_read_next_pwrst(struct powerdomain *pwrdm);
 int pwrdm_read_pwrst(struct powerdomain *pwrdm);
-- 
1.7.9.5

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

* Re: [PATCH V2 4/7] ARM: OMAP2+: powerdomain: introduce logic for finding valid power domain
  2014-08-27 18:54   ` Nishanth Menon
  (?)
@ 2014-08-27 20:25     ` Kevin Hilman
  -1 siblings, 0 replies; 37+ messages in thread
From: Kevin Hilman @ 2014-08-27 20:25 UTC (permalink / raw)
  To: Nishanth Menon
  Cc: Tony Lindgren, Santosh Shilimkar, Paul Walmsley, Tero Kristo,
	linux-arm-kernel, linux-omap, linux-kernel, j-keerthy, bcousson

Nishanth Menon <nm@ti.com> writes:

> powerdomain configuration in OMAP is done using PWRSTCTRL register for
> each power domain. However, PRCM lets us write any value we'd like to
> the logic and power domain target states, however the SoC integration
> tends to actually function only at a few discrete states. These valid
> states are already in our powerdomains_xxx_data.c file.
>
> So, provide a function to easily query valid low power state that the
> power domain is allowed to go to.
>
> Based on work originally done by Jean Pihet <j-pihet@ti.com>
> https://patchwork.kernel.org/patch/1325091/ . There is no attempt to
> create a new powerdomain solution here, except fixing issues seen
> attempting invalid programming attempts. Future consolidation to the
> generic powerdomain framework should consider this requirement as
> well.
>
> Similar solutions have been done in product kernels in the past such
> as:
> https://android.googlesource.com/kernel/omap.git/+blame/android-omap-panda-3.0/arch/arm/mach-omap2/pm44xx.c
>
> Reviewed-by: Kevin Hilman <khilman@linaro.org>
> Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Signed-off-by: Nishanth Menon <nm@ti.com>
> ---
>
> Not posting the entire series again and updating just this patch..
>
> V2: drop BUG in favor of WARN, picked up Santosh and Kevin's acks.

Looks good, thanks,

Kevin

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

* Re: [PATCH V2 4/7] ARM: OMAP2+: powerdomain: introduce logic for finding valid power domain
@ 2014-08-27 20:25     ` Kevin Hilman
  0 siblings, 0 replies; 37+ messages in thread
From: Kevin Hilman @ 2014-08-27 20:25 UTC (permalink / raw)
  To: Nishanth Menon
  Cc: Tony Lindgren, Santosh Shilimkar, Paul Walmsley, Tero Kristo,
	linux-arm-kernel, linux-omap, linux-kernel, j-keerthy, bcousson

Nishanth Menon <nm@ti.com> writes:

> powerdomain configuration in OMAP is done using PWRSTCTRL register for
> each power domain. However, PRCM lets us write any value we'd like to
> the logic and power domain target states, however the SoC integration
> tends to actually function only at a few discrete states. These valid
> states are already in our powerdomains_xxx_data.c file.
>
> So, provide a function to easily query valid low power state that the
> power domain is allowed to go to.
>
> Based on work originally done by Jean Pihet <j-pihet@ti.com>
> https://patchwork.kernel.org/patch/1325091/ . There is no attempt to
> create a new powerdomain solution here, except fixing issues seen
> attempting invalid programming attempts. Future consolidation to the
> generic powerdomain framework should consider this requirement as
> well.
>
> Similar solutions have been done in product kernels in the past such
> as:
> https://android.googlesource.com/kernel/omap.git/+blame/android-omap-panda-3.0/arch/arm/mach-omap2/pm44xx.c
>
> Reviewed-by: Kevin Hilman <khilman@linaro.org>
> Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Signed-off-by: Nishanth Menon <nm@ti.com>
> ---
>
> Not posting the entire series again and updating just this patch..
>
> V2: drop BUG in favor of WARN, picked up Santosh and Kevin's acks.

Looks good, thanks,

Kevin

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

* [PATCH V2 4/7] ARM: OMAP2+: powerdomain: introduce logic for finding valid power domain
@ 2014-08-27 20:25     ` Kevin Hilman
  0 siblings, 0 replies; 37+ messages in thread
From: Kevin Hilman @ 2014-08-27 20:25 UTC (permalink / raw)
  To: linux-arm-kernel

Nishanth Menon <nm@ti.com> writes:

> powerdomain configuration in OMAP is done using PWRSTCTRL register for
> each power domain. However, PRCM lets us write any value we'd like to
> the logic and power domain target states, however the SoC integration
> tends to actually function only at a few discrete states. These valid
> states are already in our powerdomains_xxx_data.c file.
>
> So, provide a function to easily query valid low power state that the
> power domain is allowed to go to.
>
> Based on work originally done by Jean Pihet <j-pihet@ti.com>
> https://patchwork.kernel.org/patch/1325091/ . There is no attempt to
> create a new powerdomain solution here, except fixing issues seen
> attempting invalid programming attempts. Future consolidation to the
> generic powerdomain framework should consider this requirement as
> well.
>
> Similar solutions have been done in product kernels in the past such
> as:
> https://android.googlesource.com/kernel/omap.git/+blame/android-omap-panda-3.0/arch/arm/mach-omap2/pm44xx.c
>
> Reviewed-by: Kevin Hilman <khilman@linaro.org>
> Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Signed-off-by: Nishanth Menon <nm@ti.com>
> ---
>
> Not posting the entire series again and updating just this patch..
>
> V2: drop BUG in favor of WARN, picked up Santosh and Kevin's acks.

Looks good, thanks,

Kevin

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

end of thread, other threads:[~2014-08-27 20:25 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-22 13:49 [PATCH 0/7] ARM: OMAP4+: powerdomain fixes Nishanth Menon
2014-08-22 13:49 ` Nishanth Menon
2014-08-22 13:49 ` Nishanth Menon
2014-08-22 13:49 ` [PATCH 1/7] ARM: OMAP: DRA7: powerdomain data: fix powerdomain powerstate Nishanth Menon
2014-08-22 13:49   ` Nishanth Menon
2014-08-22 13:49 ` [PATCH 2/7] ARM: OMAP5: " Nishanth Menon
2014-08-22 13:49   ` Nishanth Menon
2014-08-22 13:49 ` [PATCH 3/7] ARM: OMAP2+: powerdomain: pwrdm_for_each_clkdm iterate only valid clkdms Nishanth Menon
2014-08-22 13:49   ` Nishanth Menon
2014-08-22 13:49   ` Nishanth Menon
2014-08-22 13:49 ` [PATCH 4/7] ARM: OMAP2+: powerdomain: introduce logic for finding valid power domain Nishanth Menon
2014-08-22 13:49   ` Nishanth Menon
2014-08-22 13:49   ` Nishanth Menon
2014-08-27 18:27   ` Kevin Hilman
2014-08-27 18:27     ` Kevin Hilman
2014-08-27 18:35     ` Nishanth Menon
2014-08-27 18:35       ` Nishanth Menon
2014-08-27 18:39       ` Kevin Hilman
2014-08-27 18:39         ` Kevin Hilman
2014-08-22 13:49 ` [PATCH 5/7] ARM: OMAP4+: PM: Make logic state programmable Nishanth Menon
2014-08-22 13:49   ` Nishanth Menon
2014-08-22 13:49 ` [PATCH 6/7] ARM: OMAP4+: PM: use only valid low power state for suspend Nishanth Menon
2014-08-22 13:49   ` Nishanth Menon
2014-08-22 13:49   ` Nishanth Menon
2014-08-22 13:49 ` [PATCH 7/7] ARM: OMAP4+: PM: Use only valid low power state for CPU hotplug Nishanth Menon
2014-08-22 13:49   ` Nishanth Menon
2014-08-22 13:49   ` Nishanth Menon
2014-08-27 18:30 ` [PATCH 0/7] ARM: OMAP4+: powerdomain fixes Kevin Hilman
2014-08-27 18:30   ` Kevin Hilman
2014-08-27 18:37 ` Santosh Shilimkar
2014-08-27 18:37   ` Santosh Shilimkar
2014-08-27 18:54 ` [PATCH V2 4/7] ARM: OMAP2+: powerdomain: introduce logic for finding valid power domain Nishanth Menon
2014-08-27 18:54   ` Nishanth Menon
2014-08-27 18:54   ` Nishanth Menon
2014-08-27 20:25   ` Kevin Hilman
2014-08-27 20:25     ` Kevin Hilman
2014-08-27 20:25     ` Kevin Hilman

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.