Skip to contentSkip to conversation

OMAP4 static dependency support

PATCH New Rajendra Nayak 2 participants 16 messages Feb 7, 2011 – Feb 14, 2011

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover OMAP4 static dependency support

OMAP4 supports 2 type of domain dependency between clock domains.

-1- Static dependency

Given a domain dependency from clockdomain A to another clockdomain B, static dependency consists in constraining domain B to become or stay active, as soon as and as long as there exists atleast one system initiator of domain A willing to access domain B.

This is very similar to what was supported on OMAP3, except for the fact that there is no distinction between a sleep and a wakeup dependency. A static dependency here means both.

-2- Dynamic dependency

Given a domain dependency from clock domain A to another clockdomain B, dynamic dependency consists in constraining domain B to become or stay active, as soon as and as long as OCP traffic is ongoing or pending from domain A to domain B. A sliding window (configurable in software) is used to determine if a OCP transaction is ongoing or stopped.

This is newly supported in OMAP4 and did not exist on any of the older OMAPs.
All Dynamic dependencies are hardwired and cannot be enabled/disabled in software.

This patch series adds support only for static dependency configuration in clockdomain framework.

The series is dependent on the clockdomain-split series posted here
http://marc.info/?l=linux-omap&m=129595632429995&w=2
and hence is based on the 'pwrdm_clkdm_a_2.6.39' branch of git://git.pwsan.com/linux-2.6

Rajendra Nayak (3):
OMAP4: clockdomain: Add clkmd static dependency srcs
OMAP4: CM: Add CM accesor api for bitwise control
OMAP4: clockdomain: Add wkup/sleep dependency support

 arch/arm/mach-omap2/clockdomain44xx.c       |   59 ++++
 arch/arm/mach-omap2/clockdomains44xx_data.c |  390 ++++++++++++++++++++++++++-
 arch/arm/mach-omap2/cm44xx.h                |    1 +
 arch/arm/mach-omap2/cminst44xx.c            |   21 ++
 arch/arm/mach-omap2/cminst44xx.h            |    6 +
 5 files changed, 472 insertions(+), 5 deletions(-)
#1 lore raw

PATCH 1/3 OMAP4: clockdomain: Add clkdm static dependency srcs

OMAP4 supports static dependencies and dynamic dependencies between clock domains. Static dependencies imply both wakeup as well as sleep dependencies.
Generate all clockdomain static dependency sources. (Dynamic dependency sources are hardwired and cannot to controlled from software).

The autogen scripts are updated to generate the contents of this patch.

---
 arch/arm/mach-omap2/clockdomains44xx_data.c |  390 ++++++++++++++++++++++++++-
 1 files changed, 385 insertions(+), 5 deletions(-)
arch/arm/mach-omap2/clockdomains44xx_data.c +385 -5
index 2fe1570..7df8001 100644
@@ -18,11 +18,6 @@
  * published by the Free Software Foundation.
  */
 
-/*
- * To-Do List
- * -> Populate the Sleep/Wakeup dependencies for the domains
- */
-
 #include <linux/kernel.h>
 #include <linux/io.h>
 
@@ -37,6 +32,355 @@
 #include "prcm44xx.h"
 #include "prcm_mpu44xx.h"
 
+/* Static Dependencies for OMAP4 Clock Domains */
+
+static struct clkdm_dep ducati_wkup_sleep_deps[] = {
+	{
+		.clkdm_name	 = "abe_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "ivahd_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_1_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_2_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_dss_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_emif_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_gfx_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_init_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l4_cfg_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l4_per_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l4_secure_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l4_wkup_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "tesla_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{ NULL },
+};
+
+static struct clkdm_dep iss_wkup_sleep_deps[] = {
+	{
+		.clkdm_name	 = "ivahd_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_1_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_emif_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{ NULL },
+};
+
+static struct clkdm_dep ivahd_wkup_sleep_deps[] = {
+	{
+		.clkdm_name	 = "l3_1_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_emif_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{ NULL },
+};
+
+static struct clkdm_dep l3_d2d_wkup_sleep_deps[] = {
+	{
+		.clkdm_name	 = "abe_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "ivahd_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_1_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_2_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_emif_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_init_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l4_cfg_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l4_per_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{ NULL },
+};
+
+static struct clkdm_dep l3_dma_wkup_sleep_deps[] = {
+	{
+		.clkdm_name	 = "abe_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "ducati_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "ivahd_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_1_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_dss_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_emif_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_init_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l4_cfg_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l4_per_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l4_secure_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l4_wkup_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{ NULL },
+};
+
+static struct clkdm_dep l3_dss_wkup_sleep_deps[] = {
+	{
+		.clkdm_name	 = "ivahd_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_2_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_emif_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{ NULL },
+};
+
+static struct clkdm_dep l3_gfx_wkup_sleep_deps[] = {
+	{
+		.clkdm_name	 = "ivahd_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_1_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_emif_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{ NULL },
+};
+
+static struct clkdm_dep l3_init_wkup_sleep_deps[] = {
+	{
+		.clkdm_name	 = "abe_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "ivahd_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_emif_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l4_cfg_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l4_per_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l4_secure_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l4_wkup_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{ NULL },
+};
+
+static struct clkdm_dep l4_secure_wkup_sleep_deps[] = {
+	{
+		.clkdm_name	 = "l3_1_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_emif_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l4_per_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{ NULL },
+};
+
+static struct clkdm_dep mpuss_wkup_sleep_deps[] = {
+	{
+		.clkdm_name	 = "abe_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "ducati_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "ivahd_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_1_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_2_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_dss_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_emif_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_gfx_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_init_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l4_cfg_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l4_per_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l4_secure_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l4_wkup_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "tesla_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{ NULL },
+};
+
+static struct clkdm_dep tesla_wkup_sleep_deps[] = {
+	{
+		.clkdm_name	 = "abe_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "ivahd_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_1_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_2_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_emif_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l3_init_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l4_cfg_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l4_per_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{
+		.clkdm_name	 = "l4_wkup_clkdm",
+		.omap_chip	 = OMAP_CHIP_INIT(CHIP_IS_OMAP4430)
+	},
+	{ NULL },
+};
 
 static struct clockdomain l4_cefuse_44xx_clkdm = {
 	.name		  = "l4_cefuse_clkdm",
@@ -54,6 +398,7 @@ static struct clockdomain l4_cfg_44xx_clkdm = {
 	.prcm_partition	  = OMAP4430_CM2_PARTITION,
 	.cm_inst	  = OMAP4430_CM2_CORE_INST,
 	.clkdm_offs	  = OMAP4430_CM2_CORE_L4CFG_CDOFFS,
+	.dep_bit	  = OMAP4430_L4CFG_STATDEP_SHIFT,
 	.flags		  = CLKDM_CAN_HWSUP,
 	.omap_chip	  = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
 };
@@ -64,6 +409,9 @@ static struct clockdomain tesla_44xx_clkdm = {
 	.prcm_partition	  = OMAP4430_CM1_PARTITION,
 	.cm_inst	  = OMAP4430_CM1_TESLA_INST,
 	.clkdm_offs	  = OMAP4430_CM1_TESLA_TESLA_CDOFFS,
+	.dep_bit	  = OMAP4430_TESLA_STATDEP_SHIFT,
+	.wkdep_srcs	  = tesla_wkup_sleep_deps,
+	.sleepdep_srcs	  = tesla_wkup_sleep_deps,
 	.flags		  = CLKDM_CAN_HWSUP_SWSUP,
 	.omap_chip	  = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
 };
@@ -74,6 +422,9 @@ static struct clockdomain l3_gfx_44xx_clkdm = {
 	.prcm_partition	  = OMAP4430_CM2_PARTITION,
 	.cm_inst	  = OMAP4430_CM2_GFX_INST,
 	.clkdm_offs	  = OMAP4430_CM2_GFX_GFX_CDOFFS,
+	.dep_bit	  = OMAP4430_GFX_STATDEP_SHIFT,
+	.wkdep_srcs	  = l3_gfx_wkup_sleep_deps,
+	.sleepdep_srcs	  = l3_gfx_wkup_sleep_deps,
 	.flags		  = CLKDM_CAN_HWSUP_SWSUP,
 	.omap_chip	  = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
 };
@@ -84,6 +435,9 @@ static struct clockdomain ivahd_44xx_clkdm = {
 	.prcm_partition	  = OMAP4430_CM2_PARTITION,
 	.cm_inst	  = OMAP4430_CM2_IVAHD_INST,
 	.clkdm_offs	  = OMAP4430_CM2_IVAHD_IVAHD_CDOFFS,
+	.dep_bit	  = OMAP4430_IVAHD_STATDEP_SHIFT,
+	.wkdep_srcs	  = ivahd_wkup_sleep_deps,
+	.sleepdep_srcs	  = ivahd_wkup_sleep_deps,
 	.flags		  = CLKDM_CAN_HWSUP_SWSUP,
 	.omap_chip	  = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
 };
@@ -94,6 +448,9 @@ static struct clockdomain l4_secure_44xx_clkdm = {
 	.prcm_partition	  = OMAP4430_CM2_PARTITION,
 	.cm_inst	  = OMAP4430_CM2_L4PER_INST,
 	.clkdm_offs	  = OMAP4430_CM2_L4PER_L4SEC_CDOFFS,
+	.dep_bit	  = OMAP4430_L4SEC_STATDEP_SHIFT,
+	.wkdep_srcs	  = l4_secure_wkup_sleep_deps,
+	.sleepdep_srcs	  = l4_secure_wkup_sleep_deps,
 	.flags		  = CLKDM_CAN_HWSUP_SWSUP,
 	.omap_chip	  = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
 };
@@ -104,6 +461,7 @@ static struct clockdomain l4_per_44xx_clkdm = {
 	.prcm_partition	  = OMAP4430_CM2_PARTITION,
 	.cm_inst	  = OMAP4430_CM2_L4PER_INST,
 	.clkdm_offs	  = OMAP4430_CM2_L4PER_L4PER_CDOFFS,
+	.dep_bit	  = OMAP4430_L4PER_STATDEP_SHIFT,
 	.flags		  = CLKDM_CAN_HWSUP_SWSUP,
 	.omap_chip	  = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
 };
@@ -114,6 +472,7 @@ static struct clockdomain abe_44xx_clkdm = {
 	.prcm_partition	  = OMAP4430_CM1_PARTITION,
 	.cm_inst	  = OMAP4430_CM1_ABE_INST,
 	.clkdm_offs	  = OMAP4430_CM1_ABE_ABE_CDOFFS,
+	.dep_bit	  = OMAP4430_ABE_STATDEP_SHIFT,
 	.flags		  = CLKDM_CAN_HWSUP_SWSUP,
 	.omap_chip	  = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
 };
@@ -133,6 +492,9 @@ static struct clockdomain l3_init_44xx_clkdm = {
 	.prcm_partition	  = OMAP4430_CM2_PARTITION,
 	.cm_inst	  = OMAP4430_CM2_L3INIT_INST,
 	.clkdm_offs	  = OMAP4430_CM2_L3INIT_L3INIT_CDOFFS,
+	.dep_bit	  = OMAP4430_L3INIT_STATDEP_SHIFT,
+	.wkdep_srcs	  = l3_init_wkup_sleep_deps,
+	.sleepdep_srcs	  = l3_init_wkup_sleep_deps,
 	.flags		  = CLKDM_CAN_HWSUP_SWSUP,
 	.omap_chip	  = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
 };
@@ -143,6 +505,8 @@ static struct clockdomain mpuss_44xx_clkdm = {
 	.prcm_partition	  = OMAP4430_CM1_PARTITION,
 	.cm_inst	  = OMAP4430_CM1_MPU_INST,
 	.clkdm_offs	  = OMAP4430_CM1_MPU_MPU_CDOFFS,
+	.wkdep_srcs	  = mpuss_wkup_sleep_deps,
+	.sleepdep_srcs	  = mpuss_wkup_sleep_deps,
 	.flags		  = CLKDM_CAN_FORCE_WAKEUP | CLKDM_CAN_HWSUP,
 	.omap_chip	  = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
 };
@@ -173,6 +537,7 @@ static struct clockdomain l3_emif_44xx_clkdm = {
 	.prcm_partition	  = OMAP4430_CM2_PARTITION,
 	.cm_inst	  = OMAP4430_CM2_CORE_INST,
 	.clkdm_offs	  = OMAP4430_CM2_CORE_MEMIF_CDOFFS,
+	.dep_bit	  = OMAP4430_MEMIF_STATDEP_SHIFT,
 	.flags		  = CLKDM_CAN_FORCE_WAKEUP | CLKDM_CAN_HWSUP,
 	.omap_chip	  = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
 };
@@ -193,6 +558,9 @@ static struct clockdomain ducati_44xx_clkdm = {
 	.prcm_partition	  = OMAP4430_CM2_PARTITION,
 	.cm_inst	  = OMAP4430_CM2_CORE_INST,
 	.clkdm_offs	  = OMAP4430_CM2_CORE_DUCATI_CDOFFS,
+	.dep_bit	  = OMAP4430_DUCATI_STATDEP_SHIFT,
+	.wkdep_srcs	  = ducati_wkup_sleep_deps,
+	.sleepdep_srcs	  = ducati_wkup_sleep_deps,
 	.flags		  = CLKDM_CAN_HWSUP_SWSUP,
 	.omap_chip	  = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
 };
@@ -203,6 +571,7 @@ static struct clockdomain l3_2_44xx_clkdm = {
 	.prcm_partition	  = OMAP4430_CM2_PARTITION,
 	.cm_inst	  = OMAP4430_CM2_CORE_INST,
 	.clkdm_offs	  = OMAP4430_CM2_CORE_L3_2_CDOFFS,
+	.dep_bit	  = OMAP4430_L3_2_STATDEP_SHIFT,
 	.flags		  = CLKDM_CAN_HWSUP,
 	.omap_chip	  = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
 };
@@ -213,6 +582,7 @@ static struct clockdomain l3_1_44xx_clkdm = {
 	.prcm_partition	  = OMAP4430_CM2_PARTITION,
 	.cm_inst	  = OMAP4430_CM2_CORE_INST,
 	.clkdm_offs	  = OMAP4430_CM2_CORE_L3_1_CDOFFS,
+	.dep_bit	  = OMAP4430_L3_1_STATDEP_SHIFT,
 	.flags		  = CLKDM_CAN_HWSUP,
 	.omap_chip	  = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
 };
@@ -223,6 +593,8 @@ static struct clockdomain l3_d2d_44xx_clkdm = {
 	.prcm_partition	  = OMAP4430_CM2_PARTITION,
 	.cm_inst	  = OMAP4430_CM2_CORE_INST,
 	.clkdm_offs	  = OMAP4430_CM2_CORE_D2D_CDOFFS,
+	.wkdep_srcs	  = l3_d2d_wkup_sleep_deps,
+	.sleepdep_srcs	  = l3_d2d_wkup_sleep_deps,
 	.flags		  = CLKDM_CAN_FORCE_WAKEUP | CLKDM_CAN_HWSUP,
 	.omap_chip	  = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
 };
@@ -233,6 +605,8 @@ static struct clockdomain iss_44xx_clkdm = {
 	.prcm_partition	  = OMAP4430_CM2_PARTITION,
 	.cm_inst	  = OMAP4430_CM2_CAM_INST,
 	.clkdm_offs	  = OMAP4430_CM2_CAM_CAM_CDOFFS,
+	.wkdep_srcs	  = iss_wkup_sleep_deps,
+	.sleepdep_srcs	  = iss_wkup_sleep_deps,
 	.flags		  = CLKDM_CAN_HWSUP_SWSUP,
 	.omap_chip	  = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
 };
@@ -243,6 +617,9 @@ static struct clockdomain l3_dss_44xx_clkdm = {
 	.prcm_partition	  = OMAP4430_CM2_PARTITION,
 	.cm_inst	  = OMAP4430_CM2_DSS_INST,
 	.clkdm_offs	  = OMAP4430_CM2_DSS_DSS_CDOFFS,
+	.dep_bit	  = OMAP4430_DSS_STATDEP_SHIFT,
+	.wkdep_srcs	  = l3_dss_wkup_sleep_deps,
+	.sleepdep_srcs	  = l3_dss_wkup_sleep_deps,
 	.flags		  = CLKDM_CAN_HWSUP_SWSUP,
 	.omap_chip	  = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
 };
@@ -253,6 +630,7 @@ static struct clockdomain l4_wkup_44xx_clkdm = {
 	.prcm_partition	  = OMAP4430_PRM_PARTITION,
 	.cm_inst	  = OMAP4430_PRM_WKUP_CM_INST,
 	.clkdm_offs	  = OMAP4430_PRM_WKUP_CM_WKUP_CDOFFS,
+	.dep_bit	  = OMAP4430_L4WKUP_STATDEP_SHIFT,
 	.flags		  = CLKDM_CAN_HWSUP,
 	.omap_chip	  = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
 };
@@ -273,6 +651,8 @@ static struct clockdomain l3_dma_44xx_clkdm = {
 	.prcm_partition	  = OMAP4430_CM2_PARTITION,
 	.cm_inst	  = OMAP4430_CM2_CORE_INST,
 	.clkdm_offs	  = OMAP4430_CM2_CORE_SDMA_CDOFFS,
+	.wkdep_srcs	  = l3_dma_wkup_sleep_deps,
+	.sleepdep_srcs	  = l3_dma_wkup_sleep_deps,
 	.flags		  = CLKDM_CAN_FORCE_WAKEUP | CLKDM_CAN_HWSUP,
 	.omap_chip	  = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
 };
Signature · 1 line
1.7.0.4
#2 lore raw

PATCH 2/3 OMAP4: CM: Add CM accesor api for bitwise control

Add new OMAP4 CM accesor apis to set/clear and read bitfields (based on mask) from CM registers.

---
 arch/arm/mach-omap2/cminst44xx.c |   21 +++++++++++++++++++++
 arch/arm/mach-omap2/cminst44xx.h |    6 ++++++
 2 files changed, 27 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/cminst44xx.c +21 -0
index c04bbbe..a482bfa 100644
@@ -73,6 +73,27 @@ u32 omap4_cminst_rmw_inst_reg_bits(u32 mask, u32 bits, u8 part, s16 inst,
 	return v;
 }
 
+u32 omap4_cminst_set_inst_reg_bits(u32 bits, u8 part, s16 inst, s16 idx)
+{
+	return omap4_cminst_rmw_inst_reg_bits(bits, bits, part, inst, idx);
+}
+
+u32 omap4_cminst_clear_inst_reg_bits(u32 bits, u8 part, s16 inst, s16 idx)
+{
+	return omap4_cminst_rmw_inst_reg_bits(bits, 0x0, part, inst, idx);
+}
+
+u32 omap4_cminst_read_inst_reg_bits(u8 part, u16 inst, s16 idx, u32 mask)
+{
+	u32 v;
+
+	v = omap4_cminst_read_inst_reg(part, inst, idx);
+	v &= mask;
+	v >>= __ffs(mask);
+
+	return v;
+}
+
 /*
  *
  */
arch/arm/mach-omap2/cminst44xx.h +6 -0
index a6abd0a..2b32c18 100644
@@ -25,6 +25,12 @@ extern u32 omap4_cminst_read_inst_reg(u8 part, s16 inst, u16 idx);
 extern void omap4_cminst_write_inst_reg(u32 val, u8 part, s16 inst, u16 idx);
 extern u32 omap4_cminst_rmw_inst_reg_bits(u32 mask, u32 bits, u8 part,
 					   s16 inst, s16 idx);
+extern u32 omap4_cminst_set_inst_reg_bits(u32 bits, u8 part, s16 inst,
+					   s16 idx);
+extern u32 omap4_cminst_clear_inst_reg_bits(u32 bits, u8 part, s16 inst,
+					   s16 idx);
+extern u32 omap4_cminst_read_inst_reg_bits(u8 part, u16 inst, s16 idx,
+					   u32 mask);
 
 extern int omap4_cm_wait_module_ready(void __iomem *clkctrl_reg);
 
Signature · 1 line
1.7.0.4
#3 lore raw

PATCH 3/3 OMAP4: clockdomain: Add wkup/sleep dependency support

Add OMAP4 platform specific implementation to support clkdm wkup and sleep dependencies a.k.a static dependencies.

---
 arch/arm/mach-omap2/clockdomain44xx.c |   59 +++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/cm44xx.h          |    1 +
 2 files changed, 60 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/clockdomain44xx.c +59 -0
index c0ccc47..87e690f 100644
@@ -12,8 +12,59 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/kernel.h>
 #include "clockdomain.h"
 #include "cminst44xx.h"
+#include "cm44xx.h"
+
+static int omap4_clkdm_add_wkup_sleep_dep(struct clockdomain *clkdm1,
+					struct clockdomain *clkdm2)
+{
+	omap4_cminst_set_inst_reg_bits((1 << clkdm2->dep_bit),
+					clkdm1->prcm_partition,
+					clkdm1->cm_inst, clkdm1->clkdm_offs +
+					OMAP4_CM_STATICDEP);
+	return 0;
+}
+
+static int omap4_clkdm_del_wkup_sleep_dep(struct clockdomain *clkdm1,
+					struct clockdomain *clkdm2)
+{
+	omap4_cminst_clear_inst_reg_bits((1 << clkdm2->dep_bit),
+					clkdm1->prcm_partition,
+					clkdm1->cm_inst, clkdm1->clkdm_offs +
+					OMAP4_CM_STATICDEP);
+	return 0;
+}
+
+static int omap4_clkdm_read_wkup_sleep_dep(struct clockdomain *clkdm1,
+					struct clockdomain *clkdm2)
+{
+	return omap4_cminst_read_inst_reg_bits(clkdm1->prcm_partition,
+					clkdm1->cm_inst, clkdm1->clkdm_offs +
+					OMAP4_CM_STATICDEP,
+					(1 << clkdm2->dep_bit));
+}
+
+static int omap4_clkdm_clear_all_wkup_sleep_deps(struct clockdomain *clkdm)
+{
+	struct clkdm_dep *cd;
+	u32 mask = 0;
+
+	for (cd = clkdm->wkdep_srcs; cd && cd->clkdm; cd++) {
+		if (!omap_chip_is(cd->omap_chip))
+			continue;
+
+		/* PRM accesses are slow, so minimize them */
+		mask |= 1 << cd->clkdm->dep_bit;
+		atomic_set(&cd->wkdep_usecount, 0);
+	}
+
+	omap4_cminst_clear_inst_reg_bits(mask, clkdm->prcm_partition,
+					clkdm->cm_inst, clkdm->clkdm_offs +
+					OMAP4_CM_STATICDEP);
+	return 0;
+}
 
 static int omap4_clkdm_sleep(struct clockdomain *clkdm)
 {
@@ -68,6 +119,14 @@ static int omap4_clkdm_clk_disable(struct clockdomain *clkdm)
 }
 
 struct clkdm_ops omap4_clkdm_operations = {
+	.clkdm_add_wkdep	= omap4_clkdm_add_wkup_sleep_dep,
+	.clkdm_del_wkdep	= omap4_clkdm_del_wkup_sleep_dep,
+	.clkdm_read_wkdep	= omap4_clkdm_read_wkup_sleep_dep,
+	.clkdm_clear_all_wkdeps	= omap4_clkdm_clear_all_wkup_sleep_deps,
+	.clkdm_add_sleepdep	= omap4_clkdm_add_wkup_sleep_dep,
+	.clkdm_del_sleepdep	= omap4_clkdm_del_wkup_sleep_dep,
+	.clkdm_read_sleepdep	= omap4_clkdm_read_wkup_sleep_dep,
+	.clkdm_clear_all_sleepdeps	= omap4_clkdm_clear_all_wkup_sleep_deps,
 	.clkdm_sleep		= omap4_clkdm_sleep,
 	.clkdm_wakeup		= omap4_clkdm_wakeup,
 	.clkdm_allow_idle	= omap4_clkdm_allow_idle,
arch/arm/mach-omap2/cm44xx.h +1 -0
index 48fc3f4..4d0cfd3 100644
@@ -21,6 +21,7 @@
 #include "cm.h"
 
 #define OMAP4_CM_CLKSTCTRL				0x0000
+#define OMAP4_CM_STATICDEP				0x4
 
 /* Function prototypes */
 # ifndef __ASSEMBLER__
Signature · 1 line
1.7.0.4
maintainer
#15 lore raw

cover OMAP4 static dependency support

In reply to Rajendra Nayak
Quoted 2 lines · Rajendra Nayak

OMAP4 supports 2 type of domain dependency between clock domains.

Thanks, queued for 2.6.39 in the 'clkdm_statdep_omap4_2.6.39' branch of
git://git.pwsan.com/linux-2.6

I made a few minor changes to patch 3/3, will post those in reply to that patch.

These patches are also added as part of the current integration branch 'integration-2.6.39' of git://git.pwsan.com/linux-integration - a stable tag with these changes is tag 'integration-2.6.39-20110208-007'.

- Paul

maintainer
#4 lore raw

PATCH 3/3 OMAP4: clockdomain: Add wkup/sleep dependency support

In reply to Rajendra Nayak
Quoted 4 lines · Rajendra Nayak

Add OMAP4 platform specific implementation to support clkdm wkup and sleep dependencies a.k.a static dependencies.

I made two minor changes to this before merging: one to keep the formatting of the OMAP4_CM_STATICDEP macro value consistent with the previous value; the other to remove the comment referring to the PRM. The revised patch is below.

- Paul

From: Rajendra Nayak <[email protected]>
Date: Tue, 8 Feb 2011 14:28:22 -0700
Subject: [PATCH] OMAP4: clockdomain: Add wkup/sleep dependency support

Add OMAP4 platform specific implementation to support clkdm wkup and sleep dependencies a.k.a static dependencies.

[paul at pwsan.com: removed comment about PRM; zero-prefixed STATICDEP
register offset]

---
 arch/arm/mach-omap2/clockdomain44xx.c |   58 +++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/cm44xx.h          |    1 +
 2 files changed, 59 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/clockdomain44xx.c +58 -0
index c0ccc47..e3c6522 100644
@@ -12,8 +12,58 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/kernel.h>
 #include "clockdomain.h"
 #include "cminst44xx.h"
+#include "cm44xx.h"
+
+static int omap4_clkdm_add_wkup_sleep_dep(struct clockdomain *clkdm1,
+					struct clockdomain *clkdm2)
+{
+	omap4_cminst_set_inst_reg_bits((1 << clkdm2->dep_bit),
+					clkdm1->prcm_partition,
+					clkdm1->cm_inst, clkdm1->clkdm_offs +
+					OMAP4_CM_STATICDEP);
+	return 0;
+}
+
+static int omap4_clkdm_del_wkup_sleep_dep(struct clockdomain *clkdm1,
+					struct clockdomain *clkdm2)
+{
+	omap4_cminst_clear_inst_reg_bits((1 << clkdm2->dep_bit),
+					clkdm1->prcm_partition,
+					clkdm1->cm_inst, clkdm1->clkdm_offs +
+					OMAP4_CM_STATICDEP);
+	return 0;
+}
+
+static int omap4_clkdm_read_wkup_sleep_dep(struct clockdomain *clkdm1,
+					struct clockdomain *clkdm2)
+{
+	return omap4_cminst_read_inst_reg_bits(clkdm1->prcm_partition,
+					clkdm1->cm_inst, clkdm1->clkdm_offs +
+					OMAP4_CM_STATICDEP,
+					(1 << clkdm2->dep_bit));
+}
+
+static int omap4_clkdm_clear_all_wkup_sleep_deps(struct clockdomain *clkdm)
+{
+	struct clkdm_dep *cd;
+	u32 mask = 0;
+
+	for (cd = clkdm->wkdep_srcs; cd && cd->clkdm; cd++) {
+		if (!omap_chip_is(cd->omap_chip))
+			continue;
+
+		mask |= 1 << cd->clkdm->dep_bit;
+		atomic_set(&cd->wkdep_usecount, 0);
+	}
+
+	omap4_cminst_clear_inst_reg_bits(mask, clkdm->prcm_partition,
+					clkdm->cm_inst, clkdm->clkdm_offs +
+					OMAP4_CM_STATICDEP);
+	return 0;
+}
 
 static int omap4_clkdm_sleep(struct clockdomain *clkdm)
 {
@@ -68,6 +118,14 @@ static int omap4_clkdm_clk_disable(struct clockdomain *clkdm)
 }
 
 struct clkdm_ops omap4_clkdm_operations = {
+	.clkdm_add_wkdep	= omap4_clkdm_add_wkup_sleep_dep,
+	.clkdm_del_wkdep	= omap4_clkdm_del_wkup_sleep_dep,
+	.clkdm_read_wkdep	= omap4_clkdm_read_wkup_sleep_dep,
+	.clkdm_clear_all_wkdeps	= omap4_clkdm_clear_all_wkup_sleep_deps,
+	.clkdm_add_sleepdep	= omap4_clkdm_add_wkup_sleep_dep,
+	.clkdm_del_sleepdep	= omap4_clkdm_del_wkup_sleep_dep,
+	.clkdm_read_sleepdep	= omap4_clkdm_read_wkup_sleep_dep,
+	.clkdm_clear_all_sleepdeps	= omap4_clkdm_clear_all_wkup_sleep_deps,
 	.clkdm_sleep		= omap4_clkdm_sleep,
 	.clkdm_wakeup		= omap4_clkdm_wakeup,
 	.clkdm_allow_idle	= omap4_clkdm_allow_idle,
arch/arm/mach-omap2/cm44xx.h +1 -0
index 48fc3f4..0b87ec8 100644
@@ -21,6 +21,7 @@
 #include "cm.h"
 
 #define OMAP4_CM_CLKSTCTRL				0x0000
+#define OMAP4_CM_STATICDEP				0x0004
 
 /* Function prototypes */
 # ifndef __ASSEMBLER__
Signature · 1 line
1.7.2.3
maintainer
#5 lore raw

PATCH 3/3 OMAP4: clockdomain: Add wkup/sleep dependency support

In reply to Rajendra Nayak

Hi

Quoted 4 lines · Rajendra Nayak

Add OMAP4 platform specific implementation to support clkdm wkup and sleep dependencies a.k.a static dependencies.

This patch had a similar bug to the OMAP2/3 variants; updated patch follows -

- Paul

From: Rajendra Nayak <[email protected]>
Date: Thu, 10 Feb 2011 18:58:04 -0700
Subject: [PATCH] OMAP4: clockdomain: Add wkup/sleep dependency support

Add OMAP4 platform specific implementation to support clkdm wkup and sleep dependencies a.k.a static dependencies.

[paul at pwsan.com: removed comment about PRM; zero-prefixed STATICDEP
register offset; fixed loop termination condition in omap4_clkdm_clear_all_wkup_sleep_deps(); thanks to Kevin Hilman for finding and helping fix this bug]

---
 arch/arm/mach-omap2/clockdomain44xx.c |   58 +++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/cm44xx.h          |    1 +
 2 files changed, 59 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/clockdomain44xx.c +58 -0
index c0ccc47..e6fd8da 100644
@@ -12,8 +12,58 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/kernel.h>
 #include "clockdomain.h"
 #include "cminst44xx.h"
+#include "cm44xx.h"
+
+static int omap4_clkdm_add_wkup_sleep_dep(struct clockdomain *clkdm1,
+					struct clockdomain *clkdm2)
+{
+	omap4_cminst_set_inst_reg_bits((1 << clkdm2->dep_bit),
+					clkdm1->prcm_partition,
+					clkdm1->cm_inst, clkdm1->clkdm_offs +
+					OMAP4_CM_STATICDEP);
+	return 0;
+}
+
+static int omap4_clkdm_del_wkup_sleep_dep(struct clockdomain *clkdm1,
+					struct clockdomain *clkdm2)
+{
+	omap4_cminst_clear_inst_reg_bits((1 << clkdm2->dep_bit),
+					clkdm1->prcm_partition,
+					clkdm1->cm_inst, clkdm1->clkdm_offs +
+					OMAP4_CM_STATICDEP);
+	return 0;
+}
+
+static int omap4_clkdm_read_wkup_sleep_dep(struct clockdomain *clkdm1,
+					struct clockdomain *clkdm2)
+{
+	return omap4_cminst_read_inst_reg_bits(clkdm1->prcm_partition,
+					clkdm1->cm_inst, clkdm1->clkdm_offs +
+					OMAP4_CM_STATICDEP,
+					(1 << clkdm2->dep_bit));
+}
+
+static int omap4_clkdm_clear_all_wkup_sleep_deps(struct clockdomain *clkdm)
+{
+	struct clkdm_dep *cd;
+	u32 mask = 0;
+
+	for (cd = clkdm->wkdep_srcs; cd && cd->clkdm_name; cd++) {
+		if (!omap_chip_is(cd->omap_chip))
+			continue;
+
+		mask |= 1 << cd->clkdm->dep_bit;
+		atomic_set(&cd->wkdep_usecount, 0);
+	}
+
+	omap4_cminst_clear_inst_reg_bits(mask, clkdm->prcm_partition,
+					clkdm->cm_inst, clkdm->clkdm_offs +
+					OMAP4_CM_STATICDEP);
+	return 0;
+}
 
 static int omap4_clkdm_sleep(struct clockdomain *clkdm)
 {
@@ -68,6 +118,14 @@ static int omap4_clkdm_clk_disable(struct clockdomain *clkdm)
 }
 
 struct clkdm_ops omap4_clkdm_operations = {
+	.clkdm_add_wkdep	= omap4_clkdm_add_wkup_sleep_dep,
+	.clkdm_del_wkdep	= omap4_clkdm_del_wkup_sleep_dep,
+	.clkdm_read_wkdep	= omap4_clkdm_read_wkup_sleep_dep,
+	.clkdm_clear_all_wkdeps	= omap4_clkdm_clear_all_wkup_sleep_deps,
+	.clkdm_add_sleepdep	= omap4_clkdm_add_wkup_sleep_dep,
+	.clkdm_del_sleepdep	= omap4_clkdm_del_wkup_sleep_dep,
+	.clkdm_read_sleepdep	= omap4_clkdm_read_wkup_sleep_dep,
+	.clkdm_clear_all_sleepdeps	= omap4_clkdm_clear_all_wkup_sleep_deps,
 	.clkdm_sleep		= omap4_clkdm_sleep,
 	.clkdm_wakeup		= omap4_clkdm_wakeup,
 	.clkdm_allow_idle	= omap4_clkdm_allow_idle,
arch/arm/mach-omap2/cm44xx.h +1 -0
index 48fc3f4..0b87ec8 100644
@@ -21,6 +21,7 @@
 #include "cm.h"
 
 #define OMAP4_CM_CLKSTCTRL				0x0000
+#define OMAP4_CM_STATICDEP				0x0004
 
 /* Function prototypes */
 # ifndef __ASSEMBLER__
Signature · 1 line
1.7.2.3
#6 lore raw

PATCH 3/3 OMAP4: clockdomain: Add wkup/sleep dependency support

Hi Kevin/Paul,

Quoted 5 lines

-----Original Message-----
From: Paul Walmsley [mailto:paul at pwsan.com]
Sent: Friday, February 11, 2011 7:36 AM
To: Rajendra Nayak
Cc: linux-omap at vger.kernel.org; khilman at ti.com; b-cousson at ti.com;

linux-arm-kernel at lists.infradead.org

Quoted 1 line

Subject: Re: [PATCH 3/3] OMAP4: clockdomain: Add wkup/sleep dependency

support

Quoted 5 lines

Hi

On Mon, 7 Feb 2011, Rajendra Nayak wrote:

Quoted 7 lines
Quoted 4 lines

Add OMAP4 platform specific implementation to support clkdm wkup and sleep dependencies a.k.a static dependencies.

This patch had a similar bug to the OMAP2/3 variants; updated patch follows -

Thanks for fixing this. I have one comment below...

Quoted 8 lines

- Paul

From: Rajendra Nayak <[email protected]>
Date: Thu, 10 Feb 2011 18:58:04 -0700
Subject: [PATCH] OMAP4: clockdomain: Add wkup/sleep dependency support

Quoted 7 lines

Add OMAP4 platform specific implementation to support clkdm wkup and sleep dependencies a.k.a static dependencies.

[paul at pwsan.com: removed comment about PRM; zero-prefixed STATICDEP
register offset; fixed loop termination condition in omap4_clkdm_clear_all_wkup_sleep_deps(); thanks to Kevin Hilman for

finding

Quoted 5 lines

and helping fix this bug]

---
 arch/arm/mach-omap2/clockdomain44xx.c |   58

+++++++++++++++++++++++++++++++++

Review

Quoted 4 lines
 arch/arm/mach-omap2/cm44xx.h          |    1 +
 2 files changed, 59 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

b/arch/arm/mach-omap2/clockdomain44xx.c

Quoted 8 lines

index c0ccc47..e6fd8da 100644

arch/arm/mach-omap2/clockdomain44xx.c +1 -0
@@ -12,8 +12,58 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/kernel.h>

arch/arm/mach-omap2/clockdomain44xx.c line 25

Quoted 10 lines
arch/arm/mach-omap2/clockdomain44xx.c +8 -0
 #include "clockdomain.h"
 #include "cminst44xx.h"
+#include "cm44xx.h"
+
+static int omap4_clkdm_add_wkup_sleep_dep(struct clockdomain *clkdm1,
+					struct clockdomain *clkdm2)
+{
+	omap4_cminst_set_inst_reg_bits((1 << clkdm2->dep_bit),
+					clkdm1->prcm_partition,
+					clkdm1->cm_inst,

clkdm1->clkdm_offs +

arch/arm/mach-omap2/clockdomain44xx.c

Quoted 10 lines
arch/arm/mach-omap2/clockdomain44xx.c +10 -0
+					OMAP4_CM_STATICDEP);
+	return 0;
+}
+
+static int omap4_clkdm_del_wkup_sleep_dep(struct clockdomain *clkdm1,
+					struct clockdomain *clkdm2)
+{
+	omap4_cminst_clear_inst_reg_bits((1 << clkdm2->dep_bit),
+					clkdm1->prcm_partition,
+					clkdm1->cm_inst,

clkdm1->clkdm_offs +

arch/arm/mach-omap2/clockdomain44xx.c

Quoted 9 lines
arch/arm/mach-omap2/clockdomain44xx.c +9 -0
+					OMAP4_CM_STATICDEP);
+	return 0;
+}
+
+static int omap4_clkdm_read_wkup_sleep_dep(struct clockdomain *clkdm1,
+					struct clockdomain *clkdm2)
+{
+	return omap4_cminst_read_inst_reg_bits(clkdm1->prcm_partition,
+					clkdm1->cm_inst,

clkdm1->clkdm_offs +

arch/arm/mach-omap2/clockdomain44xx.c

Quoted 5 lines
arch/arm/mach-omap2/clockdomain44xx.c +5 -0
+					OMAP4_CM_STATICDEP,
+					(1 << clkdm2->dep_bit));
+}
+
+static int omap4_clkdm_clear_all_wkup_sleep_deps(struct clockdomain

*clkdm)

arch/arm/mach-omap2/clockdomain44xx.c line 54

Quoted 5 lines
arch/arm/mach-omap2/clockdomain44xx.c +5 -0
+{
+	struct clkdm_dep *cd;
+	u32 mask = 0;
+
+	for (cd = clkdm->wkdep_srcs; cd && cd->clkdm_name; cd++) {

My initial version actually did have a check for cd->clkdm_name instead of cd->clkdm, and then I ran into aborts when a clkdm, though belonging to the right chip version, failed lookup (in clkdm_init) and left
the cd->clkdm pointer NULL. This however was due to the fact that the clkdm_name populated was'nt matching the actual name, but that got me thinking if its better to look for populated pointers instead of names. I however seemed to have missed the point that there also could be a cd->clkdm populated as NULL for non supported CHIP rev's.

arch/arm/mach-omap2/clockdomain44xx.c line 57

Quoted 3 lines
arch/arm/mach-omap2/clockdomain44xx.c +3 -0
+		if (!omap_chip_is(cd->omap_chip))
+			continue;
+

Would it make sense to add an additional check here to avoid an abort in case of mismatches in clkdm_name populated and lookup's failing in clkdm_init?

Something like...

		If (cd->clkdm) {
			|= 1 << cd->clkdm->dep_bit;
			atomic_set(&cd->wkdep_usecount, 0);
		}

Regards
Rajendra

arch/arm/mach-omap2/clockdomain44xx.c

Quoted 6 lines
arch/arm/mach-omap2/clockdomain44xx.c +6 -0
+		mask |= 1 << cd->clkdm->dep_bit;
+		atomic_set(&cd->wkdep_usecount, 0);
+	}
+
+	omap4_cminst_clear_inst_reg_bits(mask, clkdm->prcm_partition,
+					clkdm->cm_inst, clkdm->clkdm_offs

+

arch/arm/mach-omap2/clockdomain44xx.c static int omap4_clkdm_clk_disable(struct

Quoted 7 lines
arch/arm/mach-omap2/clockdomain44xx.c +3 -0
+					OMAP4_CM_STATICDEP);
+	return 0;
+}
 
 static int omap4_clkdm_sleep(struct clockdomain *clkdm)
 {
@@ -68,6 +118,14 @@ static int omap4_clkdm_clk_disable(struct

clockdomain *clkdm)

arch/arm/mach-omap2/clockdomain44xx.c static int omap4_clkdm_clk_disable(struct clockdomain *clkdm)

Quoted 11 lines
arch/arm/mach-omap2/clockdomain44xx.c +8 -0
 }
 
 struct clkdm_ops omap4_clkdm_operations = {
+	.clkdm_add_wkdep	= omap4_clkdm_add_wkup_sleep_dep,
+	.clkdm_del_wkdep	= omap4_clkdm_del_wkup_sleep_dep,
+	.clkdm_read_wkdep	= omap4_clkdm_read_wkup_sleep_dep,
+	.clkdm_clear_all_wkdeps	= omap4_clkdm_clear_all_wkup_sleep_deps,
+	.clkdm_add_sleepdep	= omap4_clkdm_add_wkup_sleep_dep,
+	.clkdm_del_sleepdep	= omap4_clkdm_del_wkup_sleep_dep,
+	.clkdm_read_sleepdep	= omap4_clkdm_read_wkup_sleep_dep,
+	.clkdm_clear_all_sleepdeps	=

omap4_clkdm_clear_all_wkup_sleep_deps,

Quoted 17 lines
arch/arm/mach-omap2/clockdomain44xx.c +0 -0
 	.clkdm_sleep		= omap4_clkdm_sleep,
 	.clkdm_wakeup		= omap4_clkdm_wakeup,
 	.clkdm_allow_idle	= omap4_clkdm_allow_idle,
arch/arm/mach-omap2/cm44xx.h +1 -1
index 48fc3f4..0b87ec8 100644
@@ -21,6 +21,7 @@
 #include "cm.h"
 
 #define OMAP4_CM_CLKSTCTRL				0x0000
+#define OMAP4_CM_STATICDEP				0x0004
 
 /* Function prototypes */
 # ifndef __ASSEMBLER__
--

1.7.2.3

maintainer
#7 lore raw

PATCH 3/3 OMAP4: clockdomain: Add wkup/sleep dependency support

Quoted 5 lines · Rajendra Nayak

My initial version actually did have a check for cd->clkdm_name instead of cd->clkdm, and then I ran into aborts when a clkdm, though belonging to the right chip version, failed lookup (in clkdm_init) and left the cd->clkdm pointer NULL. This however was due to the fact that the clkdm_name populated was'nt matching the actual name,

So those aborts were due to clockdomain or clockdomain dependency data that had errors that caused it not to have referential integrity?

Quoted 10 lines

Would it make sense to add an additional check here to avoid an abort in case of mismatches in clkdm_name populated and lookup's failing in clkdm_init?

Something like...

		If (cd->clkdm) {
			|= 1 << cd->clkdm->dep_bit;
			atomic_set(&cd->wkdep_usecount, 0);
		}

That is going to fail silently. If I'm understanding the problem that you're referring to correctly, it seems to me that in these circumstances, we want to fail loudly. Especially now that all that data is supposed to be autogenerated. It is a symptom of a more profound problem that the end user should never see, no?

- Paul

#8 lore raw

PATCH 3/3 OMAP4: clockdomain: Add wkup/sleep dependency support

Quoted 5 lines

-----Original Message-----
From: Paul Walmsley [mailto:paul at pwsan.com]
Sent: Friday, February 11, 2011 10:08 AM
To: Rajendra Nayak
Cc: linux-omap at vger.kernel.org; Kevin Hilman; Benoit Cousson;

linux-arm-kernel at lists.infradead.org

Quoted 1 line

Subject: RE: [PATCH 3/3] OMAP4: clockdomain: Add wkup/sleep dependency

support

Quoted 4 lines · Rajendra Nayak
Quoted 2 lines

My initial version actually did have a check for cd->clkdm_name

instead

Quoted 1 line
Quoted 1 line

of cd->clkdm, and then I ran into aborts when a clkdm, though

belonging

Quoted 6 lines
Quoted 3 lines

to the right chip version, failed lookup (in clkdm_init) and left the cd->clkdm pointer NULL. This however was due to the fact that the clkdm_name populated was'nt matching the actual name,

So those aborts were due to clockdomain or clockdomain dependency data that had errors that caused it not to have referential integrity?

Yes, I specifically found it when my script updates were actually generating some non-matching (and hence wrong) clkdm_names. The aborts actually helped me fix it...

Quoted 7 lines
Quoted 7 lines

Would it make sense to add an additional check here to avoid an abort in case of mismatches in clkdm_name populated and lookup's failing in clkdm_init?

Something like...

Quoted 8 lines
Quoted 4 lines
		If (cd->clkdm) {
			|= 1 << cd->clkdm->dep_bit;
			atomic_set(&cd->wkdep_usecount, 0);
		}

That is going to fail silently. If I'm understanding the problem that you're referring to correctly, it seems to me that in these circumstances, we want to fail loudly. Especially now that all that

data

Quoted 2 lines

is supposed to be autogenerated. It is a symptom of a more profound problem that the end user should never see, no?

... so you are right. Failing silently is going to make it more difficult to identify and fix. Maybe a WARN in else?

	if (cd->clkdm) {
		...
	} else
		WARN()
Quoted 3 lines

- Paul

maintainer
#9 lore raw

PATCH 3/3 OMAP4: clockdomain: Add wkup/sleep dependency support

Hi Rajendra

Quoted 7 lines · Rajendra Nayak

Failing silently is going to make it more difficult to identify and fix. Maybe a WARN in else?

	if (cd->clkdm) {
		...
	} else
		WARN()

I was thinking it might be nice to put it right next to the _clkdm_lookup()s in clkdm_init(), since the _clkdm_lookup is what is actually failing. Then we could do a

if (!cd->clkdm)

	continue;

in the SoC-specific *_all_wkdep/sleepdep* code, just to keep the system from crashing...

Does that sound okay to you?

- Paul

#10 lore raw

PATCH 3/3 OMAP4: clockdomain: Add wkup/sleep dependency support

Quoted 5 lines

-----Original Message-----
From: Paul Walmsley [mailto:paul at pwsan.com]
Sent: Friday, February 11, 2011 10:44 AM
To: Rajendra Nayak
Cc: linux-omap at vger.kernel.org; Kevin Hilman; Benoit Cousson;

linux-arm-kernel at lists.infradead.org

Quoted 1 line

Subject: RE: [PATCH 3/3] OMAP4: clockdomain: Add wkup/sleep dependency

support

Quoted 6 lines

Hi Rajendra

Quoted 1 line · Rajendra Nayak

Failing silently is going to make it more difficult to identify and

fix.

Quoted 11 lines
Quoted 6 lines

Maybe a WARN in else?

	if (cd->clkdm) {
		...
	} else
		WARN()

I was thinking it might be nice to put it right next to the _clkdm_lookup()s in clkdm_init(), since the _clkdm_lookup is what is actually failing. Then we could do a

Quoted 7 lines

if (!cd->clkdm)

	continue;

in the SoC-specific *_all_wkdep/sleepdep* code, just to keep the system from crashing...

Does that sound okay to you?

Yep, that sounds better.

Thanks,
Rajendra

Quoted 3 lines

- Paul

maintainer
#11 lore raw

PATCH 3/3 OMAP4: clockdomain: Add wkup/sleep dependency support

Quoted 3 lines · Rajendra Nayak
Quoted 1 line

Does that sound okay to you?

Yep, that sounds better.

Here's an updated patch for the main code and the OMAP2/3 implementation. Comments, testing welcome.

The stable integration tag with this change is 'integration-2.6.39-20110212-001' of git://git.pwsan.com/linux-integration

- Paul

From: Rajendra Nayak <[email protected]>
Date: Tue, 8 Feb 2011 14:25:34 -0700
Subject: [PATCH] OMAP: clockdomain: Arch specific funcs to handle deps

Define the following architecture specific funtions for omap2/3 .clkdm_add_wkdep
.clkdm_del_wkdep
.clkdm_read_wkdep
.clkdm_clear_all_wkdeps
.clkdm_add_sleepdep
.clkdm_del_sleepdep
.clkdm_read_sleepdep
.clkdm_clear_all_sleepdeps

Convert the platform-independent framework to call these functions. With this also move the clkdm lookups for all wkdep_srcs and sleepdep_srcs at clkdm_init.

[paul at pwsan.com: fixed loop termination conditions in omap*_clkdm_clear_all_*();
thanks to Kevin Hilman for finding and helping fix those bugs; also avoid re-resolving clockdomains during init; abstracted out clkdm_dep walk]

---
 arch/arm/mach-omap2/Makefile                     |    2 +
 arch/arm/mach-omap2/clockdomain.c                |  177 ++++++++++++----------
 arch/arm/mach-omap2/clockdomain.h                |    6 +-
 arch/arm/mach-omap2/clockdomain2xxx_3xxx.c       |  130 ++++++++++++++++
 arch/arm/mach-omap2/clockdomains2xxx_3xxx_data.c |    9 +-
 arch/arm/mach-omap2/io.c                         |    6 +-
 6 files changed, 246 insertions(+), 84 deletions(-)
 create mode 100644 arch/arm/mach-omap2/clockdomain2xxx_3xxx.c
arch/arm/mach-omap2/Makefile +2 -0
index 1c0c2b0..6b2824d 100644
@@ -102,8 +102,10 @@ obj-$(CONFIG_ARCH_OMAP4)		+= $(powerdomain-common) \
 
 # PRCM clockdomain control
 obj-$(CONFIG_ARCH_OMAP2)		+= clockdomain.o \
+					   clockdomain2xxx_3xxx.o \
 					   clockdomains2xxx_3xxx_data.o
 obj-$(CONFIG_ARCH_OMAP3)		+= clockdomain.o \
+					   clockdomain2xxx_3xxx.o \
 					   clockdomains2xxx_3xxx_data.o
 obj-$(CONFIG_ARCH_OMAP4)		+= clockdomain.o \
 					   clockdomains44xx_data.o
arch/arm/mach-omap2/clockdomain.c +99 -78

335 lines not on this page · raw message

arch/arm/mach-omap2/clockdomain.h +5 -1
index 71ad265..90b6d6a 100644
@@ -176,7 +176,11 @@ int omap2_clkdm_sleep(struct clockdomain *clkdm);
 int omap2_clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk);
 int omap2_clkdm_clk_disable(struct clockdomain *clkdm, struct clk *clk);
 
-extern void __init omap2_clockdomains_init(void);
+extern void __init omap2xxx_clockdomains_init(void);
+extern void __init omap3xxx_clockdomains_init(void);
 extern void __init omap44xx_clockdomains_init(void);
 
+extern struct clkdm_ops omap2_clkdm_operations;
+extern struct clkdm_ops omap3_clkdm_operations;
+
 #endif
arch/arm/mach-omap2/clockdomain2xxx_3xxx.c new file +130 -0

130 lines not on this page · raw message

arch/arm/mach-omap2/clockdomains2xxx_3xxx_data.c +7 -2
index 8cab07a..f85de72 100644
@@ -854,7 +854,12 @@ static struct clockdomain *clockdomains_omap2[] __initdata = {
 	NULL,
 };
 
-void __init omap2_clockdomains_init(void)
+void __init omap2xxx_clockdomains_init(void)
 {
-	clkdm_init(clockdomains_omap2, clkdm_autodeps, NULL);
+	clkdm_init(clockdomains_omap2, clkdm_autodeps, &omap2_clkdm_operations);
+}
+
+void __init omap3xxx_clockdomains_init(void)
+{
+	clkdm_init(clockdomains_omap2, clkdm_autodeps, &omap3_clkdm_operations);
 }
arch/arm/mach-omap2/io.c +3 -3
index c203204..89cbba2 100644
@@ -337,15 +337,15 @@ void __init omap2_init_common_infrastructure(void)
 
 	if (cpu_is_omap242x()) {
 		omap2xxx_powerdomains_init();
-		omap2_clockdomains_init();
+		omap2xxx_clockdomains_init();
 		omap2420_hwmod_init();
 	} else if (cpu_is_omap243x()) {
 		omap2xxx_powerdomains_init();
-		omap2_clockdomains_init();
+		omap2xxx_clockdomains_init();
 		omap2430_hwmod_init();
 	} else if (cpu_is_omap34xx()) {
 		omap3xxx_powerdomains_init();
-		omap2_clockdomains_init();
+		omap3xxx_clockdomains_init();
 		omap3xxx_hwmod_init();
 	} else if (cpu_is_omap44xx()) {
 		omap44xx_powerdomains_init();
Signature · 1 line
1.7.2.3
maintainer
#14 lore raw

PATCH 3/3 OMAP4: clockdomain: Add wkup/sleep dependency support

In reply to Rajendra Nayak

Here's the updated OMAP4 version.

The stable integration tag with this change is 'integration-2.6.39-20110212-002' of git://git.pwsan.com/linux-integration

- Paul

From: Rajendra Nayak <[email protected]>
Date: Sat, 12 Feb 2011 15:32:47 -0700
Subject: [PATCH] OMAP4: clockdomain: Add wkup/sleep dependency support

Add OMAP4 platform specific implementation to support clkdm wkup and sleep dependencies a.k.a static dependencies.

[paul at pwsan.com: removed comment about PRM; zero-prefixed STATICDEP
register offset; fixed loop termination condition in omap4_clkdm_clear_all_wkup_sleep_deps(); thanks to Kevin Hilman for finding and helping fix this bug]

---
 arch/arm/mach-omap2/clockdomain44xx.c |   60 +++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/cm44xx.h          |    1 +
 2 files changed, 61 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/clockdomain44xx.c +60 -0
index c0ccc47..a1a4ecd 100644
@@ -12,8 +12,60 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/kernel.h>
 #include "clockdomain.h"
 #include "cminst44xx.h"
+#include "cm44xx.h"
+
+static int omap4_clkdm_add_wkup_sleep_dep(struct clockdomain *clkdm1,
+					struct clockdomain *clkdm2)
+{
+	omap4_cminst_set_inst_reg_bits((1 << clkdm2->dep_bit),
+					clkdm1->prcm_partition,
+					clkdm1->cm_inst, clkdm1->clkdm_offs +
+					OMAP4_CM_STATICDEP);
+	return 0;
+}
+
+static int omap4_clkdm_del_wkup_sleep_dep(struct clockdomain *clkdm1,
+					struct clockdomain *clkdm2)
+{
+	omap4_cminst_clear_inst_reg_bits((1 << clkdm2->dep_bit),
+					clkdm1->prcm_partition,
+					clkdm1->cm_inst, clkdm1->clkdm_offs +
+					OMAP4_CM_STATICDEP);
+	return 0;
+}
+
+static int omap4_clkdm_read_wkup_sleep_dep(struct clockdomain *clkdm1,
+					struct clockdomain *clkdm2)
+{
+	return omap4_cminst_read_inst_reg_bits(clkdm1->prcm_partition,
+					clkdm1->cm_inst, clkdm1->clkdm_offs +
+					OMAP4_CM_STATICDEP,
+					(1 << clkdm2->dep_bit));
+}
+
+static int omap4_clkdm_clear_all_wkup_sleep_deps(struct clockdomain *clkdm)
+{
+	struct clkdm_dep *cd;
+	u32 mask = 0;
+
+	for (cd = clkdm->wkdep_srcs; cd && cd->clkdm_name; cd++) {
+		if (!omap_chip_is(cd->omap_chip))
+			continue;
+		if (!cd->clkdm)
+			continue; /* only happens if data is erroneous */
+
+		mask |= 1 << cd->clkdm->dep_bit;
+		atomic_set(&cd->wkdep_usecount, 0);
+	}
+
+	omap4_cminst_clear_inst_reg_bits(mask, clkdm->prcm_partition,
+					clkdm->cm_inst, clkdm->clkdm_offs +
+					OMAP4_CM_STATICDEP);
+	return 0;
+}
 
 static int omap4_clkdm_sleep(struct clockdomain *clkdm)
 {
@@ -68,6 +120,14 @@ static int omap4_clkdm_clk_disable(struct clockdomain *clkdm)
 }
 
 struct clkdm_ops omap4_clkdm_operations = {
+	.clkdm_add_wkdep	= omap4_clkdm_add_wkup_sleep_dep,
+	.clkdm_del_wkdep	= omap4_clkdm_del_wkup_sleep_dep,
+	.clkdm_read_wkdep	= omap4_clkdm_read_wkup_sleep_dep,
+	.clkdm_clear_all_wkdeps	= omap4_clkdm_clear_all_wkup_sleep_deps,
+	.clkdm_add_sleepdep	= omap4_clkdm_add_wkup_sleep_dep,
+	.clkdm_del_sleepdep	= omap4_clkdm_del_wkup_sleep_dep,
+	.clkdm_read_sleepdep	= omap4_clkdm_read_wkup_sleep_dep,
+	.clkdm_clear_all_sleepdeps	= omap4_clkdm_clear_all_wkup_sleep_deps,
 	.clkdm_sleep		= omap4_clkdm_sleep,
 	.clkdm_wakeup		= omap4_clkdm_wakeup,
 	.clkdm_allow_idle	= omap4_clkdm_allow_idle,
arch/arm/mach-omap2/cm44xx.h +1 -0
index 48fc3f4..0b87ec8 100644
@@ -21,6 +21,7 @@
 #include "cm.h"
 
 #define OMAP4_CM_CLKSTCTRL				0x0000
+#define OMAP4_CM_STATICDEP				0x0004
 
 /* Function prototypes */
 # ifndef __ASSEMBLER__
Signature · 1 line
1.7.2.3
#12 lore raw

PATCH 3/3 OMAP4: clockdomain: Add wkup/sleep dependency support

In reply to Paul Walmsley

Hi Paul,

Quoted 5 lines

-----Original Message-----
From: Paul Walmsley [mailto:paul at pwsan.com]
Sent: Sunday, February 13, 2011 4:27 AM
To: Rajendra Nayak
Cc: linux-omap at vger.kernel.org; Kevin Hilman; Benoit Cousson;

linux-arm-kernel at lists.infradead.org

Quoted 1 line

Subject: RE: [PATCH 3/3] OMAP4: clockdomain: Add wkup/sleep dependency

support

Quoted 8 lines · Rajendra Nayak
Quoted 4 lines
Quoted 2 lines

Does that sound okay to you?

Yep, that sounds better.

Here's an updated patch for the main code and the OMAP2/3

implementation.

Quoted 4 lines

Comments, testing welcome.

The stable integration tag with this change is
'integration-2.6.39-20110212-001' of

git://git.pwsan.com/linux-integration

Thanks for the changes. I used the 'integration-2.6.39-20110212-002' tag (with the OMAP4 changes as well) and tested OFF mode in suspend on my 3430sdp.
Also boot tested (making sure all static deps are cleared at boot) on my 4430sdp.
There were however, still some prints stating wkup dependencies not yet being supported on OMAP4, which I removed as part of the patch which I posted here..
http://marc.info/?l=linux-omap&m=129768517726431&w=2

regards,
Rajendra

Quoted 19 lines

- Paul

From: Rajendra Nayak <[email protected]>
Date: Tue, 8 Feb 2011 14:25:34 -0700
Subject: [PATCH] OMAP: clockdomain: Arch specific funcs to handle deps

Define the following architecture specific funtions for omap2/3 .clkdm_add_wkdep
.clkdm_del_wkdep
.clkdm_read_wkdep
.clkdm_clear_all_wkdeps
.clkdm_add_sleepdep
.clkdm_del_sleepdep
.clkdm_read_sleepdep
.clkdm_clear_all_sleepdeps

Quoted 6 lines

Convert the platform-independent framework to call these functions. With this also move the clkdm lookups for all wkdep_srcs and sleepdep_srcs at clkdm_init.

[paul at pwsan.com: fixed loop termination conditions in

omap*_clkdm_clear_all_*();

Quoted 2 lines

thanks to Kevin Hilman for finding and helping fix those bugs; also avoid re-resolving clockdomains during init; abstracted out clkdm_dep

walk]

Quoted 5 lines
---
 arch/arm/mach-omap2/Makefile                     |    2 +
 arch/arm/mach-omap2/clockdomain.c                |  177

++++++++++++----------

Quoted 2 lines
 arch/arm/mach-omap2/clockdomain.h                |    6 +-
 arch/arm/mach-omap2/clockdomain2xxx_3xxx.c       |  130

++++++++++++++++

arch/arm/mach-omap2/Makefile obj-$(CONFIG_ARCH_OMAP4) +=

Quoted 10 lines
 arch/arm/mach-omap2/clockdomains2xxx_3xxx_data.c |    9 +-
 arch/arm/mach-omap2/io.c                         |    6 +-
 6 files changed, 246 insertions(+), 84 deletions(-)
 create mode 100644 arch/arm/mach-omap2/clockdomain2xxx_3xxx.c
arch/arm/mach-omap2/Makefile +0 -0
index 1c0c2b0..6b2824d 100644
@@ -102,8 +102,10 @@ obj-$(CONFIG_ARCH_OMAP4)		+=

$(powerdomain-common) \

Review

Quoted 11 lines
arch/arm/mach-omap2/Makefile +2 -0
 # PRCM clockdomain control
 obj-$(CONFIG_ARCH_OMAP2)		+= clockdomain.o \
+					   clockdomain2xxx_3xxx.o \
 					   clockdomains2xxx_3xxx_data.o
 obj-$(CONFIG_ARCH_OMAP3)		+= clockdomain.o \
+					   clockdomain2xxx_3xxx.o \
 					   clockdomains2xxx_3xxx_data.o
 obj-$(CONFIG_ARCH_OMAP4)		+= clockdomain.o \
 					   clockdomains44xx_data.o
(quoted diff) +0 -0

b/arch/arm/mach-omap2/clockdomain.c

arch/arm/mach-omap2/clockdomain.c static void _disable_hwsup(struct clockdomain

Quoted 4 lines

index f70b06a..895c153 100644

arch/arm/mach-omap2/clockdomain.c +0 -0
@@ -287,6 +287,32 @@ static void _disable_hwsup(struct clockdomain

*clkdm)

arch/arm/mach-omap2/clockdomain.c static void _disable_hwsup(struct clockdomain *clkdm)

Quoted 9 lines
arch/arm/mach-omap2/clockdomain.c +6 -0
 		BUG();
 }
 
+/**
+ * _resolve_clkdm_deps() - resolve clkdm_names in @clkdm_deps to clkdms
+ * @clkdm: clockdomain that we are resolving dependencies for
+ * @clkdm_deps: ptr to array of struct clkdm_deps to resolve
+ *
+ * Iterates through @clkdm_deps, looking up the struct clockdomain

named by

arch/arm/mach-omap2/clockdomain.c static void _disable_hwsup(struct clockdomain · line 296

Quoted 1 line
arch/arm/mach-omap2/clockdomain.c +1 -0
+ * clkdm_name and storing the clockdomain pointer in the struct

clkdm_dep.

Quoted 5 lines
arch/arm/mach-omap2/clockdomain.c +5 -0
+ * No return value.
+ */
+static void _resolve_clkdm_deps(struct clockdomain *clkdm,
+				struct clkdm_dep *clkdm_deps)
+{

arch/arm/mach-omap2/clockdomain.c static void _disable_hwsup(struct clockdomain *clkdm)

Quoted 10 lines
arch/arm/mach-omap2/clockdomain.c +10 -0
+	struct clkdm_dep *cd;
+
+	for (cd = clkdm_deps; cd && cd->clkdm_name; cd++) {
+		if (!omap_chip_is(cd->omap_chip))
+			continue;
+		if (cd->clkdm)
+			continue;
+		cd->clkdm = _clkdm_lookup(cd->clkdm_name);
+
+		WARN(!cd->clkdm, "clockdomain: %s: could not find clkdm %s

while resolving dependencies - should

arch/arm/mach-omap2/clockdomain.c struct powerdomain *clkdm_get_pwrdm(struct

Quoted 20 lines
arch/arm/mach-omap2/clockdomain.c +4 -0
 never happen",
+		     clkdm->name, cd->clkdm_name);
+	}
+}
+
 /* Public functions */
 

/**

arch/arm/mach-omap2/clockdomain.c +3 -0
@@ -333,7 +359,10 @@ void clkdm_init(struct clockdomain **clkdms,
 		else if (clkdm->flags & CLKDM_CAN_DISABLE_AUTO)
 			omap2_clkdm_deny_idle(clkdm);
 
+		_resolve_clkdm_deps(clkdm, clkdm->wkdep_srcs);
 		clkdm_clear_all_wkdeps(clkdm);
+
+		_resolve_clkdm_deps(clkdm, clkdm->sleepdep_srcs);
 		clkdm_clear_all_sleepdeps(clkdm);
 	}
 }
@@ -430,6 +459,7 @@ struct powerdomain *clkdm_get_pwrdm(struct

clockdomain *clkdm)

arch/arm/mach-omap2/clockdomain.c struct powerdomain *clkdm_get_pwrdm(struct · line 459

Quoted 1 line
arch/arm/mach-omap2/clockdomain.c +0 -0
 int clkdm_add_wkdep(struct clockdomain *clkdm1, struct clockdomain

*clkdm2)

arch/arm/mach-omap2/clockdomain.c int clkdm_add_wkdep(struct clockdomain *clkdm1,

Quoted 7 lines
arch/arm/mach-omap2/clockdomain.c +1 -0
 {
 	struct clkdm_dep *cd;
+	int ret = 0;
 
 	if (!cpu_is_omap24xx() && !cpu_is_omap34xx()) {
 		pr_err("clockdomain: %s/%s: %s: not yet implemented\n",
@@ -441,21 +471,26 @@ int clkdm_add_wkdep(struct clockdomain *clkdm1,

struct clockdomain *clkdm2)

arch/arm/mach-omap2/clockdomain.c int clkdm_add_wkdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2)

Quoted 12 lines
arch/arm/mach-omap2/clockdomain.c +7 -1
 		return -EINVAL;
 
 	cd = _clkdm_deps_lookup(clkdm2, clkdm1->wkdep_srcs);
-	if (IS_ERR(cd)) {
+	if (IS_ERR(cd))
+		ret = PTR_ERR(cd);
+
+	if (!arch_clkdm || !arch_clkdm->clkdm_add_wkdep)
+		ret = -EINVAL;
+
+	if (ret) {
 		pr_debug("clockdomain: hardware cannot set/clear wake up

of "

arch/arm/mach-omap2/clockdomain.c int clkdm_add_wkdep(struct clockdomain *clkdm1, · line 482

Quoted 1 line
arch/arm/mach-omap2/clockdomain.c +0 -0
 			 "%s when %s wakes up\n", clkdm1->name,

clkdm2->name);

arch/arm/mach-omap2/clockdomain.c int clkdm_add_wkdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2)

Quoted 6 lines
arch/arm/mach-omap2/clockdomain.c +1 -1
-		return PTR_ERR(cd);
+		return ret;
 	}
 
 	if (atomic_inc_return(&cd->wkdep_usecount) == 1) {
 		pr_debug("clockdomain: hardware will wake up %s when %s

wakes "

arch/arm/mach-omap2/clockdomain.c int clkdm_add_wkdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2)

Quoted 4 lines
arch/arm/mach-omap2/clockdomain.c +0 -2
 			 "up\n", clkdm1->name, clkdm2->name);
 
-		omap2_prm_set_mod_reg_bits((1 << clkdm2->dep_bit),
-				     clkdm1->pwrdm.ptr->prcm_offs,

PM_WKDEP);

arch/arm/mach-omap2/clockdomain.c int clkdm_add_wkdep(struct clockdomain *clkdm1,

Quoted 9 lines
arch/arm/mach-omap2/clockdomain.c +2 -1
+		ret = arch_clkdm->clkdm_add_wkdep(clkdm1, clkdm2);
 	}
 
-	return 0;
+	return ret;
 }
 
 /**
@@ -471,6 +506,7 @@ int clkdm_add_wkdep(struct clockdomain *clkdm1,

struct clockdomain *clkdm2)

arch/arm/mach-omap2/clockdomain.c int clkdm_add_wkdep(struct clockdomain *clkdm1, · line 506

Quoted 1 line
arch/arm/mach-omap2/clockdomain.c +0 -0
 int clkdm_del_wkdep(struct clockdomain *clkdm1, struct clockdomain

*clkdm2)

arch/arm/mach-omap2/clockdomain.c int clkdm_del_wkdep(struct clockdomain *clkdm1,

Quoted 7 lines
arch/arm/mach-omap2/clockdomain.c +1 -0
 {
 	struct clkdm_dep *cd;
+	int ret = 0;
 
 	if (!cpu_is_omap24xx() && !cpu_is_omap34xx()) {
 		pr_err("clockdomain: %s/%s: %s: not yet implemented\n",
@@ -482,21 +518,26 @@ int clkdm_del_wkdep(struct clockdomain *clkdm1,

struct clockdomain *clkdm2)

arch/arm/mach-omap2/clockdomain.c int clkdm_del_wkdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2)

Quoted 12 lines
arch/arm/mach-omap2/clockdomain.c +7 -1
 		return -EINVAL;
 
 	cd = _clkdm_deps_lookup(clkdm2, clkdm1->wkdep_srcs);
-	if (IS_ERR(cd)) {
+	if (IS_ERR(cd))
+		ret = PTR_ERR(cd);
+
+	if (!arch_clkdm || !arch_clkdm->clkdm_del_wkdep)
+		ret = -EINVAL;
+
+	if (ret) {
 		pr_debug("clockdomain: hardware cannot set/clear wake up

of "

arch/arm/mach-omap2/clockdomain.c int clkdm_del_wkdep(struct clockdomain *clkdm1, · line 529

Quoted 1 line
arch/arm/mach-omap2/clockdomain.c +0 -0
 			 "%s when %s wakes up\n", clkdm1->name,

clkdm2->name);

arch/arm/mach-omap2/clockdomain.c int clkdm_del_wkdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2)

Quoted 6 lines
arch/arm/mach-omap2/clockdomain.c +1 -1
-		return PTR_ERR(cd);
+		return ret;
 	}
 
 	if (atomic_dec_return(&cd->wkdep_usecount) == 0) {
 		pr_debug("clockdomain: hardware will no longer wake up %s

"

arch/arm/mach-omap2/clockdomain.c int clkdm_del_wkdep(struct clockdomain *clkdm1, · line 535

Quoted 1 line
arch/arm/mach-omap2/clockdomain.c +0 -0
 			 "after %s wakes up\n", clkdm1->name,

clkdm2->name);

arch/arm/mach-omap2/clockdomain.c int clkdm_del_wkdep(struct clockdomain *clkdm1, · line 495

Quoted 3 lines
arch/arm/mach-omap2/clockdomain.c +0 -2
-		omap2_prm_clear_mod_reg_bits((1 << clkdm2->dep_bit),
-				       clkdm1->pwrdm.ptr->prcm_offs,

PM_WKDEP);

arch/arm/mach-omap2/clockdomain.c int clkdm_del_wkdep(struct clockdomain *clkdm1,

Quoted 9 lines
arch/arm/mach-omap2/clockdomain.c +2 -1
+		ret = arch_clkdm->clkdm_del_wkdep(clkdm1, clkdm2);
 	}
 
-	return 0;
+	return ret;
 }
 
 /**
@@ -516,6 +557,7 @@ int clkdm_del_wkdep(struct clockdomain *clkdm1,

struct clockdomain *clkdm2)

arch/arm/mach-omap2/clockdomain.c int clkdm_del_wkdep(struct clockdomain *clkdm1, · line 557

Quoted 1 line
arch/arm/mach-omap2/clockdomain.c +0 -0
 int clkdm_read_wkdep(struct clockdomain *clkdm1, struct clockdomain

*clkdm2)

arch/arm/mach-omap2/clockdomain.c int clkdm_read_wkdep(struct clockdomain *clkdm1,

Quoted 7 lines
arch/arm/mach-omap2/clockdomain.c +1 -0
 {
 	struct clkdm_dep *cd;
+	int ret = 0;
 
 	if (!clkdm1 || !clkdm2)
 		return -EINVAL;
@@ -527,15 +569,20 @@ int clkdm_read_wkdep(struct clockdomain *clkdm1,

struct clockdomain *clkdm2)

arch/arm/mach-omap2/clockdomain.c int clkdm_read_wkdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2)

Quoted 12 lines
arch/arm/mach-omap2/clockdomain.c +7 -1
 	}
 
 	cd = _clkdm_deps_lookup(clkdm2, clkdm1->wkdep_srcs);
-	if (IS_ERR(cd)) {
+	if (IS_ERR(cd))
+		ret = PTR_ERR(cd);
+
+	if (!arch_clkdm || !arch_clkdm->clkdm_read_wkdep)
+		ret = -EINVAL;
+
+	if (ret) {
 		pr_debug("clockdomain: hardware cannot set/clear wake up

of "

arch/arm/mach-omap2/clockdomain.c int clkdm_read_wkdep(struct clockdomain *clkdm1, · line 580

Quoted 1 line
arch/arm/mach-omap2/clockdomain.c +0 -0
 			 "%s when %s wakes up\n", clkdm1->name,

clkdm2->name);

arch/arm/mach-omap2/clockdomain.c int clkdm_read_wkdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2)

Quoted 6 lines
arch/arm/mach-omap2/clockdomain.c +1 -2
-		return PTR_ERR(cd);
+		return ret;
 	}
 
 	/* XXX It's faster to return the atomic wkdep_usecount */
-	return omap2_prm_read_mod_bits_shift(clkdm1->pwrdm.ptr->prcm_offs,

PM_WKDEP,

arch/arm/mach-omap2/clockdomain.c int clkdm_read_wkdep(struct clockdomain *clkdm1,

Quoted 6 lines
arch/arm/mach-omap2/clockdomain.c +1 -1
-				       (1 << clkdm2->dep_bit));
+	return arch_clkdm->clkdm_read_wkdep(clkdm1, clkdm2);
 }
 
 /**
@@ -550,9 +597,6 @@ int clkdm_read_wkdep(struct clockdomain *clkdm1,

struct clockdomain *clkdm2)

arch/arm/mach-omap2/clockdomain.c int clkdm_clear_all_wkdeps(struct clockdomain

Quoted 10 lines
arch/arm/mach-omap2/clockdomain.c +0 -3
  */
 int clkdm_clear_all_wkdeps(struct clockdomain *clkdm)
 {
-	struct clkdm_dep *cd;
-	u32 mask = 0;
-
 	if (!cpu_is_omap24xx() && !cpu_is_omap34xx()) {
 		pr_err("clockdomain: %s: %s: not yet implemented\n",
 		       clkdm->name, __func__);
@@ -562,21 +606,10 @@ int clkdm_clear_all_wkdeps(struct clockdomain

*clkdm)

Quoted 6 lines
arch/arm/mach-omap2/clockdomain.c +0 -3
 	if (!clkdm)
 		return -EINVAL;
 
-	for (cd = clkdm->wkdep_srcs; cd && cd->clkdm_name; cd++) {
-		if (!omap_chip_is(cd->omap_chip))
-			continue;

arch/arm/mach-omap2/clockdomain.c int clkdm_clear_all_wkdeps(struct clockdomain *clkdm)

Quoted 10 lines
arch/arm/mach-omap2/clockdomain.c +0 -10
-
-		if (!cd->clkdm && cd->clkdm_name)
-			cd->clkdm = _clkdm_lookup(cd->clkdm_name);
-
-		/* PRM accesses are slow, so minimize them */
-		mask |= 1 << cd->clkdm->dep_bit;
-		atomic_set(&cd->wkdep_usecount, 0);
-	}
-
-	omap2_prm_clear_mod_reg_bits(mask, clkdm->pwrdm.ptr->prcm_offs,

PM_WKDEP);

arch/arm/mach-omap2/clockdomain.c int clkdm_clear_all_wkdeps(struct clockdomain

Quoted 9 lines
arch/arm/mach-omap2/clockdomain.c +3 -1
+	if (!arch_clkdm || !arch_clkdm->clkdm_clear_all_wkdeps)
+		return -EINVAL;
 
-	return 0;
+	return arch_clkdm->clkdm_clear_all_wkdeps(clkdm);
 }
 
 /**
@@ -594,31 +627,33 @@ int clkdm_clear_all_wkdeps(struct clockdomain

*clkdm)

arch/arm/mach-omap2/clockdomain.c int clkdm_clear_all_wkdeps(struct clockdomain · line 627

Quoted 1 line
arch/arm/mach-omap2/clockdomain.c +0 -0
 int clkdm_add_sleepdep(struct clockdomain *clkdm1, struct clockdomain

*clkdm2)

Quoted 11 lines
arch/arm/mach-omap2/clockdomain.c +1 -3
 {
 	struct clkdm_dep *cd;
-
-	if (!cpu_is_omap34xx())
-		return -EINVAL;
+	int ret = 0;
 
 	if (!clkdm1 || !clkdm2)
 		return -EINVAL;
 
 	cd = _clkdm_deps_lookup(clkdm2, clkdm1->sleepdep_srcs);

arch/arm/mach-omap2/clockdomain.c int clkdm_clear_all_wkdeps(struct clockdomain *clkdm)

Quoted 10 lines
arch/arm/mach-omap2/clockdomain.c +7 -1
-	if (IS_ERR(cd)) {
+	if (IS_ERR(cd))
+		ret = PTR_ERR(cd);
+
+	if (!arch_clkdm || !arch_clkdm->clkdm_add_sleepdep)
+		ret = -EINVAL;
+
+	if (ret) {
 		pr_debug("clockdomain: hardware cannot set/clear sleep "
 			 "dependency affecting %s from %s\n",

clkdm1->name,

arch/arm/mach-omap2/clockdomain.c int clkdm_clear_all_wkdeps(struct clockdomain *clkdm)

Quoted 7 lines
arch/arm/mach-omap2/clockdomain.c +1 -1
 			 clkdm2->name);
-		return PTR_ERR(cd);
+		return ret;
 	}
 
 	if (atomic_inc_return(&cd->sleepdep_usecount) == 1) {
 		pr_debug("clockdomain: will prevent %s from sleeping if %s

"

arch/arm/mach-omap2/clockdomain.c int clkdm_add_sleepdep(struct clockdomain *clkdm1,

Quoted 14 lines
arch/arm/mach-omap2/clockdomain.c +2 -4
 			 "is active\n", clkdm1->name, clkdm2->name);
 
-		omap2_cm_set_mod_reg_bits((1 << clkdm2->dep_bit),
-				    clkdm1->pwrdm.ptr->prcm_offs,
-				    OMAP3430_CM_SLEEPDEP);
+		ret = arch_clkdm->clkdm_add_sleepdep(clkdm1, clkdm2);
 	}
 
-	return 0;
+	return ret;
 }
 
 /**
@@ -636,19 +671,23 @@ int clkdm_add_sleepdep(struct clockdomain *clkdm1,

struct clockdomain *clkdm2)

arch/arm/mach-omap2/clockdomain.c int clkdm_add_sleepdep(struct clockdomain *clkdm1, · line 671

Quoted 1 line
arch/arm/mach-omap2/clockdomain.c +0 -0
 int clkdm_del_sleepdep(struct clockdomain *clkdm1, struct clockdomain

*clkdm2)

Quoted 11 lines
arch/arm/mach-omap2/clockdomain.c +1 -3
 {
 	struct clkdm_dep *cd;
-
-	if (!cpu_is_omap34xx())
-		return -EINVAL;
+	int ret = 0;
 
 	if (!clkdm1 || !clkdm2)
 		return -EINVAL;
 
 	cd = _clkdm_deps_lookup(clkdm2, clkdm1->sleepdep_srcs);

arch/arm/mach-omap2/clockdomain.c int clkdm_add_sleepdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2)

Quoted 10 lines
arch/arm/mach-omap2/clockdomain.c +7 -1
-	if (IS_ERR(cd)) {
+	if (IS_ERR(cd))
+		ret = PTR_ERR(cd);
+
+	if (!arch_clkdm || !arch_clkdm->clkdm_del_sleepdep)
+		ret = -EINVAL;
+
+	if (ret) {
 		pr_debug("clockdomain: hardware cannot set/clear sleep "
 			 "dependency affecting %s from %s\n",

clkdm1->name,

arch/arm/mach-omap2/clockdomain.c int clkdm_del_sleepdep(struct clockdomain *clkdm1,

Quoted 7 lines
arch/arm/mach-omap2/clockdomain.c +1 -1
 			 clkdm2->name);
-		return PTR_ERR(cd);
+		return ret;
 	}
 
 	if (atomic_dec_return(&cd->sleepdep_usecount) == 0) {
@@ -656,12 +695,10 @@ int clkdm_del_sleepdep(struct clockdomain *clkdm1,

struct clockdomain *clkdm2)

arch/arm/mach-omap2/clockdomain.c int clkdm_del_sleepdep(struct clockdomain *clkdm1,

Quoted 15 lines
arch/arm/mach-omap2/clockdomain.c +2 -4
 			 "sleeping if %s is active\n", clkdm1->name,
 			 clkdm2->name);
 
-		omap2_cm_clear_mod_reg_bits((1 << clkdm2->dep_bit),
-				      clkdm1->pwrdm.ptr->prcm_offs,
-				      OMAP3430_CM_SLEEPDEP);
+		ret = arch_clkdm->clkdm_del_sleepdep(clkdm1, clkdm2);
 	}
 
-	return 0;
+	return ret;
 }
 
 /**
@@ -683,25 +720,27 @@ int clkdm_del_sleepdep(struct clockdomain *clkdm1,

struct clockdomain *clkdm2)

arch/arm/mach-omap2/clockdomain.c int clkdm_del_sleepdep(struct clockdomain *clkdm1, · line 720

Quoted 1 line
arch/arm/mach-omap2/clockdomain.c +0 -0
 int clkdm_read_sleepdep(struct clockdomain *clkdm1, struct clockdomain

*clkdm2)

Quoted 11 lines
arch/arm/mach-omap2/clockdomain.c +1 -3
 {
 	struct clkdm_dep *cd;
-
-	if (!cpu_is_omap34xx())
-		return -EINVAL;
+	int ret = 0;
 
 	if (!clkdm1 || !clkdm2)
 		return -EINVAL;
 
 	cd = _clkdm_deps_lookup(clkdm2, clkdm1->sleepdep_srcs);

arch/arm/mach-omap2/clockdomain.c int clkdm_del_sleepdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2)

Quoted 10 lines
arch/arm/mach-omap2/clockdomain.c +7 -1
-	if (IS_ERR(cd)) {
+	if (IS_ERR(cd))
+		ret = PTR_ERR(cd);
+
+	if (!arch_clkdm || !arch_clkdm->clkdm_read_sleepdep)
+		ret = -EINVAL;
+
+	if (ret) {
 		pr_debug("clockdomain: hardware cannot set/clear sleep "
 			 "dependency affecting %s from %s\n",

clkdm1->name,

arch/arm/mach-omap2/clockdomain.c int clkdm_read_sleepdep(struct clockdomain

Quoted 14 lines
arch/arm/mach-omap2/clockdomain.c +2 -4
 			 clkdm2->name);
-		return PTR_ERR(cd);
+		return ret;
 	}
 
 	/* XXX It's faster to return the atomic sleepdep_usecount */
-	return omap2_prm_read_mod_bits_shift(clkdm1->pwrdm.ptr->prcm_offs,
-				       OMAP3430_CM_SLEEPDEP,
-				       (1 << clkdm2->dep_bit));
+	return arch_clkdm->clkdm_read_sleepdep(clkdm1, clkdm2);
 }
 
 /**
@@ -716,31 +755,13 @@ int clkdm_read_sleepdep(struct clockdomain

*clkdm1, struct clockdomain *clkdm2)

Review

Quoted 35 lines
arch/arm/mach-omap2/clockdomain.c +3 -21
  */
 int clkdm_clear_all_sleepdeps(struct clockdomain *clkdm)
 {
-	struct clkdm_dep *cd;
-	u32 mask = 0;
-
-	if (!cpu_is_omap34xx())
-		return -EINVAL;
-
 	if (!clkdm)
 		return -EINVAL;
 
-	for (cd = clkdm->sleepdep_srcs; cd && cd->clkdm_name; cd++) {
-		if (!omap_chip_is(cd->omap_chip))
-			continue;
-
-		if (!cd->clkdm && cd->clkdm_name)
-			cd->clkdm = _clkdm_lookup(cd->clkdm_name);
-
-		/* PRM accesses are slow, so minimize them */
-		mask |= 1 << cd->clkdm->dep_bit;
-		atomic_set(&cd->sleepdep_usecount, 0);
-	}
-
-	omap2_prm_clear_mod_reg_bits(mask, clkdm->pwrdm.ptr->prcm_offs,
-			       OMAP3430_CM_SLEEPDEP);
+	if (!arch_clkdm || !arch_clkdm->clkdm_clear_all_sleepdeps)
+		return -EINVAL;
 
-	return 0;
+	return arch_clkdm->clkdm_clear_all_sleepdeps(clkdm);
 }
 
 /**
(quoted diff) +0 -0

b/arch/arm/mach-omap2/clockdomain.h

arch/arm/mach-omap2/clockdomain.h int omap2_clkdm_sleep(struct clockdomain *clkdm); · line 177

Quoted 6 lines

index 71ad265..90b6d6a 100644

arch/arm/mach-omap2/clockdomain.h +0 -0
@@ -176,7 +176,11 @@ int omap2_clkdm_sleep(struct clockdomain *clkdm);
 int omap2_clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk);
 int omap2_clkdm_clk_disable(struct clockdomain *clkdm, struct clk

*clk);

Review

Quoted 11 lines
arch/arm/mach-omap2/clockdomain.h +5 -1
-extern void __init omap2_clockdomains_init(void);
+extern void __init omap2xxx_clockdomains_init(void);
+extern void __init omap3xxx_clockdomains_init(void);
 extern void __init omap44xx_clockdomains_init(void);
 
+extern struct clkdm_ops omap2_clkdm_operations;
+extern struct clkdm_ops omap3_clkdm_operations;
+
 #endif
(quoted diff) +0 -0

b/arch/arm/mach-omap2/clockdomain2xxx_3xxx.c

Quoted 21 lines

new file mode 100644
index 0000000..a1fd6fd

arch/arm/mach-omap2/clockdomain2xxx_3xxx.c new file +16 -0
@@ -0,0 +1,130 @@
+/*
+ * OMAP2 and OMAP3 clockdomain control
+ *
+ * Copyright (C) 2008-2010 Texas Instruments, Inc.
+ * Copyright (C) 2008-2010 Nokia Corporation
+ *
+ * Derived from mach-omap2/clockdomain.c written by Paul Walmsley
+ * Rajendra Nayak <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/types.h>
+#include <plat/prcm.h>

arch/arm/mach-omap2/clockdomain2xxx_3xxx.c line 26

Quoted 10 lines
arch/arm/mach-omap2/clockdomain2xxx_3xxx.c new file +10 -0
+#include "prm.h"
+#include "prm2xxx_3xxx.h"
+#include "cm.h"
+#include "cm2xxx_3xxx.h"
+#include "cm-regbits-24xx.h"
+#include "cm-regbits-34xx.h"
+#include "clockdomain.h"
+
+static int omap2_clkdm_add_wkdep(struct clockdomain *clkdm1,
+						struct clockdomain

*clkdm2)

arch/arm/mach-omap2/clockdomain2xxx_3xxx.c

Quoted 8 lines
arch/arm/mach-omap2/clockdomain2xxx_3xxx.c new file +8 -0
+{
+	omap2_prm_set_mod_reg_bits((1 << clkdm2->dep_bit),
+				clkdm1->pwrdm.ptr->prcm_offs, PM_WKDEP);
+	return 0;
+}
+
+static int omap2_clkdm_del_wkdep(struct clockdomain *clkdm1,
+						 struct clockdomain

*clkdm2)

arch/arm/mach-omap2/clockdomain2xxx_3xxx.c

Quoted 8 lines
arch/arm/mach-omap2/clockdomain2xxx_3xxx.c new file +8 -0
+{
+	omap2_prm_clear_mod_reg_bits((1 << clkdm2->dep_bit),
+				clkdm1->pwrdm.ptr->prcm_offs, PM_WKDEP);
+	return 0;
+}
+
+static int omap2_clkdm_read_wkdep(struct clockdomain *clkdm1,
+						 struct clockdomain

*clkdm2)

Quoted 18 lines
arch/arm/mach-omap2/clockdomain2xxx_3xxx.c new file +18 -0
+{
+	return omap2_prm_read_mod_bits_shift(clkdm1->pwrdm.ptr->prcm_offs,
+				PM_WKDEP, (1 << clkdm2->dep_bit));
+}
+
+static int omap2_clkdm_clear_all_wkdeps(struct clockdomain *clkdm)
+{
+	struct clkdm_dep *cd;
+	u32 mask = 0;
+
+	for (cd = clkdm->wkdep_srcs; cd && cd->clkdm_name; cd++) {
+		if (!omap_chip_is(cd->omap_chip))
+			continue;
+		if (!cd->clkdm)
+			continue; /* only happens if data is erroneous */
+
+		/* PRM accesses are slow, so minimize them */
+		mask |= 1 << cd->clkdm->dep_bit;

arch/arm/mach-omap2/clockdomain2xxx_3xxx.c

Quoted 10 lines
arch/arm/mach-omap2/clockdomain2xxx_3xxx.c new file +10 -0
+		atomic_set(&cd->wkdep_usecount, 0);
+	}
+
+	omap2_prm_clear_mod_reg_bits(mask, clkdm->pwrdm.ptr->prcm_offs,
+				 PM_WKDEP);
+	return 0;
+}
+
+static int omap3_clkdm_add_sleepdep(struct clockdomain *clkdm1,
+						 struct clockdomain

*clkdm2)

arch/arm/mach-omap2/clockdomain2xxx_3xxx.c

Quoted 9 lines
arch/arm/mach-omap2/clockdomain2xxx_3xxx.c new file +9 -0
+{
+	omap2_cm_set_mod_reg_bits((1 << clkdm2->dep_bit),
+				clkdm1->pwrdm.ptr->prcm_offs,
+				OMAP3430_CM_SLEEPDEP);
+	return 0;
+}
+
+static int omap3_clkdm_del_sleepdep(struct clockdomain *clkdm1,
+						 struct clockdomain

*clkdm2)

arch/arm/mach-omap2/clockdomain2xxx_3xxx.c

Quoted 9 lines
arch/arm/mach-omap2/clockdomain2xxx_3xxx.c new file +9 -0
+{
+	omap2_cm_clear_mod_reg_bits((1 << clkdm2->dep_bit),
+				clkdm1->pwrdm.ptr->prcm_offs,
+				OMAP3430_CM_SLEEPDEP);
+	return 0;
+}
+
+static int omap3_clkdm_read_sleepdep(struct clockdomain *clkdm1,
+						 struct clockdomain

*clkdm2)

arch/arm/mach-omap2/clockdomain2xxx_3xxx.c

Quoted 3 lines
arch/arm/mach-omap2/clockdomain2xxx_3xxx.c new file +3 -0
+{
+	return omap2_prm_read_mod_bits_shift(clkdm1->pwrdm.ptr->prcm_offs,
+				OMAP3430_CM_SLEEPDEP, (1 <<

clkdm2->dep_bit));

Review

Quoted 40 lines
arch/arm/mach-omap2/clockdomain2xxx_3xxx.c new file +39 -0
+}
+
+static int omap3_clkdm_clear_all_sleepdeps(struct clockdomain *clkdm)
+{
+	struct clkdm_dep *cd;
+	u32 mask = 0;
+
+	for (cd = clkdm->sleepdep_srcs; cd && cd->clkdm_name; cd++) {
+		if (!omap_chip_is(cd->omap_chip))
+			continue;
+		if (!cd->clkdm)
+			continue; /* only happens if data is erroneous */
+
+		/* PRM accesses are slow, so minimize them */
+		mask |= 1 << cd->clkdm->dep_bit;
+		atomic_set(&cd->sleepdep_usecount, 0);
+	}
+	omap2_prm_clear_mod_reg_bits(mask, clkdm->pwrdm.ptr->prcm_offs,
+				OMAP3430_CM_SLEEPDEP);
+	return 0;
+}
+
+struct clkdm_ops omap2_clkdm_operations = {
+	.clkdm_add_wkdep	= omap2_clkdm_add_wkdep,
+	.clkdm_del_wkdep	= omap2_clkdm_del_wkdep,
+	.clkdm_read_wkdep	= omap2_clkdm_read_wkdep,
+	.clkdm_clear_all_wkdeps	= omap2_clkdm_clear_all_wkdeps,
+};
+
+struct clkdm_ops omap3_clkdm_operations = {
+	.clkdm_add_wkdep	= omap2_clkdm_add_wkdep,
+	.clkdm_del_wkdep	= omap2_clkdm_del_wkdep,
+	.clkdm_read_wkdep	= omap2_clkdm_read_wkdep,
+	.clkdm_clear_all_wkdeps	= omap2_clkdm_clear_all_wkdeps,
+	.clkdm_add_sleepdep	= omap3_clkdm_add_sleepdep,
+	.clkdm_del_sleepdep	= omap3_clkdm_del_sleepdep,
+	.clkdm_read_sleepdep	= omap3_clkdm_read_sleepdep,
+	.clkdm_clear_all_sleepdeps	= omap3_clkdm_clear_all_sleepdeps,
+};
(quoted diff) +0 -0

b/arch/arm/mach-

arch/arm/mach-omap2/clockdomains2xxx_3xxx_data.c static struct clockdomain *clockdomains_omap2[]

Quoted 5 lines

omap2/clockdomains2xxx_3xxx_data.c
index 8cab07a..f85de72 100644

arch/arm/mach-omap2/clockdomains2xxx_3xxx_data.c +0 -0
@@ -854,7 +854,12 @@ static struct clockdomain *clockdomains_omap2[]

__initdata = {

arch/arm/mach-omap2/clockdomains2xxx_3xxx_data.c static struct clockdomain *clockdomains_omap2[] __initdata = {

Quoted 8 lines
arch/arm/mach-omap2/clockdomains2xxx_3xxx_data.c +2 -2
 	NULL,
 };
 
-void __init omap2_clockdomains_init(void)
+void __init omap2xxx_clockdomains_init(void)
 {
-	clkdm_init(clockdomains_omap2, clkdm_autodeps, NULL);
+	clkdm_init(clockdomains_omap2, clkdm_autodeps,

&omap2_clkdm_operations);

arch/arm/mach-omap2/clockdomains2xxx_3xxx_data.c static struct clockdomain *clockdomains_omap2[] __initdata = {

Quoted 5 lines
arch/arm/mach-omap2/clockdomains2xxx_3xxx_data.c +5 -0
+}
+
+void __init omap3xxx_clockdomains_init(void)
+{
+	clkdm_init(clockdomains_omap2, clkdm_autodeps,

&omap3_clkdm_operations);

Quoted 26 lines
arch/arm/mach-omap2/clockdomains2xxx_3xxx_data.c +0 -0
 }
arch/arm/mach-omap2/io.c +3 -4
index c203204..89cbba2 100644
@@ -337,15 +337,15 @@ void __init omap2_init_common_infrastructure(void)
 
 	if (cpu_is_omap242x()) {
 		omap2xxx_powerdomains_init();
-		omap2_clockdomains_init();
+		omap2xxx_clockdomains_init();
 		omap2420_hwmod_init();
 	} else if (cpu_is_omap243x()) {
 		omap2xxx_powerdomains_init();
-		omap2_clockdomains_init();
+		omap2xxx_clockdomains_init();
 		omap2430_hwmod_init();
 	} else if (cpu_is_omap34xx()) {
 		omap3xxx_powerdomains_init();
-		omap2_clockdomains_init();
+		omap3xxx_clockdomains_init();
 		omap3xxx_hwmod_init();
 	} else if (cpu_is_omap44xx()) {
 		omap44xx_powerdomains_init();
--

1.7.2.3

maintainer
#13 lore raw

PATCH 3/3 OMAP4: clockdomain: Add wkup/sleep dependency support

Quoted 5 lines · Rajendra Nayak

Thanks for the changes. I used the 'integration-2.6.39-20110212-002' tag (with the OMAP4 changes as well) and tested OFF mode in suspend on my 3430sdp.
Also boot tested (making sure all static deps are cleared at boot) on my 4430sdp.

Sounds good, thanks for the tests.

- Paul