Skip to contentSkip to conversation

Clockdomain split series

PATCH New Rajendra Nayak 2 participants 9 messages Jan 25, 2011 – Feb 11, 2011

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

v2 cover Clockdomain split series

This patch series is an effort to split the clockdomain framework into platform independent and platform specific parts as was done for the powerdomain framework.

This certainlly helps remove the various cpu_is_* checks which exist today in the framework and makes the code more maintainable and readable.

The series is boot tested on OMAP2430/3430/4430SDP platforms. Also on OMAP3430SDP, OFF mode in suspend path is validated using the omap3_pm_defconfig.

This series is based on mainline 2.6.38-rc2 and
can be found here
git://gitorious.org/omap-pm/linux.git clockdomain-split-v2-rc2

Version History
---------------
v2
-1- removed wrongly populated sleepdep support for OMAP2 -2- Fixed error handling in apis

For a wider review, posting this series with linux-arm-kernel list copied.
This version has no functional diff with the
earlier one posted here
http://www.mail-archive.com/linux-omap at vger.kernel.org/msg42570.html

Rajendra Nayak (5):
OMAP: clockdomain: Infrastructure to put arch specific code
OMAP: clockdomain: Arch specific funcs to handle deps
OMAP: clockdomain: Arch specific funcs for sleep/wakeup of clkdm
OMAP: clockdomain: Arch specific funcs for hwsup control of clkdm
OMAP: clockdomain: Arch specific funcs for clkdm_clk_enable/disable

 arch/arm/mach-omap2/Makefile                     |    3 +
 arch/arm/mach-omap2/clock.c                      |    6 +-
 arch/arm/mach-omap2/clockdomain.c                |  410 +++++++---------------
 arch/arm/mach-omap2/clockdomain.h                |   58 +++-
 arch/arm/mach-omap2/clockdomain2xxx_3xxx.c       |  270 ++++++++++++++
 arch/arm/mach-omap2/clockdomain44xx.c            |   77 ++++
 arch/arm/mach-omap2/clockdomains2xxx_3xxx_data.c |    9 +-
 arch/arm/mach-omap2/clockdomains44xx_data.c      |    2 +-
 arch/arm/mach-omap2/cpuidle34xx.c                |    4 +-
 arch/arm/mach-omap2/io.c                         |    6 +-
 arch/arm/mach-omap2/pm.c                         |    6 +-
 arch/arm/mach-omap2/pm24xx.c                     |    8 +-
 arch/arm/mach-omap2/pm34xx.c                     |    6 +-
 13 files changed, 557 insertions(+), 308 deletions(-)
 create mode 100644 arch/arm/mach-omap2/clockdomain2xxx_3xxx.c
 create mode 100644 arch/arm/mach-omap2/clockdomain44xx.c
#1 lore raw

PATCH v2 1/5 OMAP: clockdomain: Infrastructure to put arch specific code

Put infrastructure in place, so arch specific func pointers can be hooked up to the platform-independent part of the framework.
This is in preparation of splitting the clockdomain framework into platform-independent part (for all omaps) and platform-specific parts.

---
 arch/arm/mach-omap2/clockdomain.c                |   10 +++++-
 arch/arm/mach-omap2/clockdomain.h                |   37 +++++++++++++++++++++-
 arch/arm/mach-omap2/clockdomains2xxx_3xxx_data.c |    2 +-
 arch/arm/mach-omap2/clockdomains44xx_data.c      |    2 +-
 4 files changed, 47 insertions(+), 4 deletions(-)
arch/arm/mach-omap2/clockdomain.c +9 -1
index e20b986..3e40184 100644
@@ -44,6 +44,7 @@ static LIST_HEAD(clkdm_list);
 /* array of clockdomain deps to be added/removed when clkdm in hwsup mode */
 static struct clkdm_autodep *autodeps;
 
+static struct clkdm_ops *arch_clkdm;
 
 /* Private functions */
 
@@ -292,6 +293,7 @@ static void _disable_hwsup(struct clockdomain *clkdm)
  * clkdm_init - set up the clockdomain layer
  * @clkdms: optional pointer to an array of clockdomains to register
  * @init_autodeps: optional pointer to an array of autodeps to register
+ * @custom_funcs: func pointers for arch specfic implementations
  *
  * Set up internal state.  If a pointer to an array of clockdomains
  * @clkdms was supplied, loop through the list of clockdomains,
@@ -300,12 +302,18 @@ static void _disable_hwsup(struct clockdomain *clkdm)
  * @init_autodeps was provided, register those.  No return value.
  */
 void clkdm_init(struct clockdomain **clkdms,
-		struct clkdm_autodep *init_autodeps)
+		struct clkdm_autodep *init_autodeps,
+		struct clkdm_ops *custom_funcs)
 {
 	struct clockdomain **c = NULL;
 	struct clockdomain *clkdm;
 	struct clkdm_autodep *autodep = NULL;
 
+	if (!custom_funcs)
+		WARN(1, "No custom clkdm functions registered\n");
+	else
+		arch_clkdm = custom_funcs;
+
 	if (clkdms)
 		for (c = clkdms; *c; c++)
 			_clkdm_register(*c);
arch/arm/mach-omap2/clockdomain.h +36 -1
index 9b459c2..71ad265 100644
@@ -116,7 +116,42 @@ struct clockdomain {
 	struct list_head node;
 };
 
-void clkdm_init(struct clockdomain **clkdms, struct clkdm_autodep *autodeps);
+/**
+ * struct clkdm_ops - Arch specfic function implementations
+ * @clkdm_add_wkdep: Add a wakeup dependency between clk domains
+ * @clkdm_del_wkdep: Delete a wakeup dependency between clk domains
+ * @clkdm_read_wkdep: Read wakeup dependency state between clk domains
+ * @clkdm_clear_all_wkdeps: Remove all wakeup dependencies from the clk domain
+ * @clkdm_add_sleepdep: Add a sleep dependency between clk domains
+ * @clkdm_del_sleepdep: Delete a sleep dependency between clk domains
+ * @clkdm_read_sleepdep: Read sleep dependency state between clk domains
+ * @clkdm_clear_all_sleepdeps: Remove all sleep dependencies from the clk domain
+ * @clkdm_sleep: Force a clockdomain to sleep
+ * @clkdm_wakeup: Force a clockdomain to wakeup
+ * @clkdm_allow_idle: Enable hw supervised idle transitions for clock domain
+ * @clkdm_deny_idle: Disable hw supervised idle transitions for clock domain
+ * @clkdm_clk_enable: Put the clkdm in right state for a clock enable
+ * @clkdm_clk_disable: Put the clkdm in right state for a clock disable
+ */
+struct clkdm_ops {
+	int	(*clkdm_add_wkdep)(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
+	int	(*clkdm_del_wkdep)(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
+	int	(*clkdm_read_wkdep)(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
+	int	(*clkdm_clear_all_wkdeps)(struct clockdomain *clkdm);
+	int	(*clkdm_add_sleepdep)(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
+	int	(*clkdm_del_sleepdep)(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
+	int	(*clkdm_read_sleepdep)(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
+	int	(*clkdm_clear_all_sleepdeps)(struct clockdomain *clkdm);
+	int	(*clkdm_sleep)(struct clockdomain *clkdm);
+	int	(*clkdm_wakeup)(struct clockdomain *clkdm);
+	void	(*clkdm_allow_idle)(struct clockdomain *clkdm);
+	void	(*clkdm_deny_idle)(struct clockdomain *clkdm);
+	int	(*clkdm_clk_enable)(struct clockdomain *clkdm);
+	int	(*clkdm_clk_disable)(struct clockdomain *clkdm);
+};
+
+void clkdm_init(struct clockdomain **clkdms, struct clkdm_autodep *autodeps,
+			struct clkdm_ops *custom_funcs);
 struct clockdomain *clkdm_lookup(const char *name);
 
 int clkdm_for_each(int (*fn)(struct clockdomain *clkdm, void *user),
arch/arm/mach-omap2/clockdomains2xxx_3xxx_data.c +1 -1
index e4a7133..8cab07a 100644
@@ -856,5 +856,5 @@ static struct clockdomain *clockdomains_omap2[] __initdata = {
 
 void __init omap2_clockdomains_init(void)
 {
-	clkdm_init(clockdomains_omap2, clkdm_autodeps);
+	clkdm_init(clockdomains_omap2, clkdm_autodeps, NULL);
 }
arch/arm/mach-omap2/clockdomains44xx_data.c +1 -1
index 51920fc..f04abc5 100644
@@ -307,5 +307,5 @@ static struct clockdomain *clockdomains_omap44xx[] __initdata = {
 
 void __init omap44xx_clockdomains_init(void)
 {
-	clkdm_init(clockdomains_omap44xx, NULL);
+	clkdm_init(clockdomains_omap44xx, NULL, NULL);
 }
Signature · 1 line
1.7.0.4
#2 lore raw

PATCH v2 2/5 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.

---
 arch/arm/mach-omap2/Makefile                     |    2 +
 arch/arm/mach-omap2/clockdomain.c                |  160 +++++++++++-----------
 arch/arm/mach-omap2/clockdomain.h                |    6 +-
 arch/arm/mach-omap2/clockdomain2xxx_3xxx.c       |  126 +++++++++++++++++
 arch/arm/mach-omap2/clockdomains2xxx_3xxx_data.c |    9 +-
 arch/arm/mach-omap2/io.c                         |    6 +-
 6 files changed, 225 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 +82 -78

312 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 +126 -0

126 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 e66687b..e1c5e76 100644
@@ -339,15 +339,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.0.4
#3 lore raw

PATCH v2 3/5 OMAP: clockdomain: Arch specific funcs for sleep/wakeup of clkdm

Define the following architecture specific funtions for omap2/3/4 .clkdm_sleep
.clkdm_wakeup

Convert the platform-independent framework to call these functions. Also rename the api's by removing the omap2_ preamble. Hence call omap2_clkdm_wakeup as clkdm_wakeup and omap2_clkdm_sleep as clkdm_sleep.

---
 arch/arm/mach-omap2/Makefile                |    1 +
 arch/arm/mach-omap2/clockdomain.c           |   64 ++++++--------------------
 arch/arm/mach-omap2/clockdomain.h           |    5 +-
 arch/arm/mach-omap2/clockdomain2xxx_3xxx.c  |   35 +++++++++++++++
 arch/arm/mach-omap2/clockdomain44xx.c       |   35 +++++++++++++++
 arch/arm/mach-omap2/clockdomains44xx_data.c |    2 +-
 arch/arm/mach-omap2/pm.c                    |    4 +-
 arch/arm/mach-omap2/pm24xx.c                |    6 +-
 arch/arm/mach-omap2/pm34xx.c                |    2 +-
 9 files changed, 96 insertions(+), 58 deletions(-)
 create mode 100644 arch/arm/mach-omap2/clockdomain44xx.c
arch/arm/mach-omap2/Makefile +1 -0
index 6b2824d..72f2891 100644
@@ -108,6 +108,7 @@ obj-$(CONFIG_ARCH_OMAP3)		+= clockdomain.o \
 					   clockdomain2xxx_3xxx.o \
 					   clockdomains2xxx_3xxx_data.o
 obj-$(CONFIG_ARCH_OMAP4)		+= clockdomain.o \
+					   clockdomain44xx.o \
 					   clockdomains44xx_data.o
 # Clock framework
 obj-$(CONFIG_ARCH_OMAP2)		+= $(clock-common) clock2xxx.o \
arch/arm/mach-omap2/clockdomain.c +15 -49

119 lines not on this page · raw message

arch/arm/mach-omap2/clockdomain.h +3 -2
index 90b6d6a..7a5cb5c 100644
@@ -170,8 +170,8 @@ int clkdm_clear_all_sleepdeps(struct clockdomain *clkdm);
 void omap2_clkdm_allow_idle(struct clockdomain *clkdm);
 void omap2_clkdm_deny_idle(struct clockdomain *clkdm);
 
-int omap2_clkdm_wakeup(struct clockdomain *clkdm);
-int omap2_clkdm_sleep(struct clockdomain *clkdm);
+int clkdm_wakeup(struct clockdomain *clkdm);
+int 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);
@@ -182,5 +182,6 @@ extern void __init omap44xx_clockdomains_init(void);
 
 extern struct clkdm_ops omap2_clkdm_operations;
 extern struct clkdm_ops omap3_clkdm_operations;
+extern struct clkdm_ops omap4_clkdm_operations;
 
 #endif
arch/arm/mach-omap2/clockdomain2xxx_3xxx.c +35 -0
index 58b0626..2b90e91 100644
@@ -20,6 +20,7 @@
 #include "cm2xxx_3xxx.h"
 #include "cm-regbits-24xx.h"
 #include "cm-regbits-34xx.h"
+#include "prm-regbits-24xx.h"
 #include "clockdomain.h"
 
 static int omap2_clkdm_add_wkdep(struct clockdomain *clkdm1,
@@ -107,11 +108,43 @@ static int omap3_clkdm_clear_all_sleepdeps(struct clockdomain *clkdm)
 	return 0;
 }
 
+static int omap2_clkdm_sleep(struct clockdomain *clkdm)
+{
+	omap2_cm_set_mod_reg_bits(OMAP24XX_FORCESTATE_MASK,
+				clkdm->pwrdm.ptr->prcm_offs,
+				OMAP2_PM_PWSTCTRL);
+	return 0;
+}
+
+static int omap2_clkdm_wakeup(struct clockdomain *clkdm)
+{
+	omap2_cm_clear_mod_reg_bits(OMAP24XX_FORCESTATE_MASK,
+				clkdm->pwrdm.ptr->prcm_offs,
+				OMAP2_PM_PWSTCTRL);
+	return 0;
+}
+
+static int omap3_clkdm_sleep(struct clockdomain *clkdm)
+{
+	omap3xxx_cm_clkdm_force_sleep(clkdm->pwrdm.ptr->prcm_offs,
+				clkdm->clktrctrl_mask);
+	return 0;
+}
+
+static int omap3_clkdm_wakeup(struct clockdomain *clkdm)
+{
+	omap3xxx_cm_clkdm_force_wakeup(clkdm->pwrdm.ptr->prcm_offs,
+				clkdm->clktrctrl_mask);
+	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,
+	.clkdm_sleep		= omap2_clkdm_sleep,
+	.clkdm_wakeup		= omap2_clkdm_wakeup,
 };
 
 struct clkdm_ops omap3_clkdm_operations = {
@@ -123,4 +156,6 @@ struct clkdm_ops omap3_clkdm_operations = {
 	.clkdm_del_sleepdep	= omap3_clkdm_del_sleepdep,
 	.clkdm_read_sleepdep	= omap3_clkdm_read_sleepdep,
 	.clkdm_clear_all_sleepdeps	= omap3_clkdm_clear_all_sleepdeps,
+	.clkdm_sleep		= omap3_clkdm_sleep,
+	.clkdm_wakeup		= omap3_clkdm_wakeup,
 };
arch/arm/mach-omap2/clockdomain44xx.c new file +35 -0
new file mode 100644
index 0000000..9ccb406
@@ -0,0 +1,35 @@
+/*
+ * OMAP4 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 "clockdomain.h"
+#include "cminst44xx.h"
+
+static int omap4_clkdm_sleep(struct clockdomain *clkdm)
+{
+	omap4_cminst_clkdm_force_sleep(clkdm->prcm_partition,
+					clkdm->cm_inst, clkdm->clkdm_offs);
+	return 0;
+}
+
+static int omap4_clkdm_wakeup(struct clockdomain *clkdm)
+{
+	omap4_cminst_clkdm_force_wakeup(clkdm->prcm_partition,
+					clkdm->cm_inst, clkdm->clkdm_offs);
+	return 0;
+}
+
+struct clkdm_ops omap4_clkdm_operations = {
+	.clkdm_sleep		= omap4_clkdm_sleep,
+	.clkdm_wakeup		= omap4_clkdm_wakeup,
+};
arch/arm/mach-omap2/clockdomains44xx_data.c +1 -1
index f04abc5..2fe1570 100644
@@ -307,5 +307,5 @@ static struct clockdomain *clockdomains_omap44xx[] __initdata = {
 
 void __init omap44xx_clockdomains_init(void)
 {
-	clkdm_init(clockdomains_omap44xx, NULL, NULL);
+	clkdm_init(clockdomains_omap44xx, NULL, &omap4_clkdm_operations);
 }
arch/arm/mach-omap2/pm.c +2 -2
index d5a102c..74c3100 100644
@@ -124,7 +124,7 @@ int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state)
 			(pwrdm->flags & PWRDM_HAS_LOWPOWERSTATECHANGE)) {
 			sleep_switch = LOWPOWERSTATE_SWITCH;
 		} else {
-			omap2_clkdm_wakeup(pwrdm->pwrdm_clkdms[0]);
+			clkdm_wakeup(pwrdm->pwrdm_clkdms[0]);
 			pwrdm_wait_transition(pwrdm);
 			sleep_switch = FORCEWAKEUP_SWITCH;
 		}
@@ -142,7 +142,7 @@ int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state)
 		if (pwrdm->pwrdm_clkdms[0]->flags & CLKDM_CAN_ENABLE_AUTO)
 			omap2_clkdm_allow_idle(pwrdm->pwrdm_clkdms[0]);
 		else
-			omap2_clkdm_sleep(pwrdm->pwrdm_clkdms[0]);
+			clkdm_sleep(pwrdm->pwrdm_clkdms[0]);
 		break;
 	case LOWPOWERSTATE_SWITCH:
 		pwrdm_set_lowpwrstchange(pwrdm);
arch/arm/mach-omap2/pm24xx.c +3 -3
index 9e5dc8e..5c32f5f 100644
@@ -370,7 +370,7 @@ static int __init clkdms_setup(struct clockdomain *clkdm, void *unused)
 		omap2_clkdm_allow_idle(clkdm);
 	else if (clkdm->flags & CLKDM_CAN_FORCE_SLEEP &&
 		 atomic_read(&clkdm->usecount) == 0)
-		omap2_clkdm_sleep(clkdm);
+		clkdm_sleep(clkdm);
 	return 0;
 }
 
@@ -405,11 +405,11 @@ static void __init prcm_setup_regs(void)
 
 	pwrdm = clkdm_get_pwrdm(dsp_clkdm);
 	pwrdm_set_next_pwrst(pwrdm, PWRDM_POWER_OFF);
-	omap2_clkdm_sleep(dsp_clkdm);
+	clkdm_sleep(dsp_clkdm);
 
 	pwrdm = clkdm_get_pwrdm(gfx_clkdm);
 	pwrdm_set_next_pwrst(pwrdm, PWRDM_POWER_OFF);
-	omap2_clkdm_sleep(gfx_clkdm);
+	clkdm_sleep(gfx_clkdm);
 
 	/*
 	 * Clear clockdomain wakeup dependencies and enable
arch/arm/mach-omap2/pm34xx.c +1 -1
index 8cbbead..b954b6f 100644
@@ -992,7 +992,7 @@ static int __init clkdms_setup(struct clockdomain *clkdm, void *unused)
 		omap2_clkdm_allow_idle(clkdm);
 	else if (clkdm->flags & CLKDM_CAN_FORCE_SLEEP &&
 		 atomic_read(&clkdm->usecount) == 0)
-		omap2_clkdm_sleep(clkdm);
+		clkdm_sleep(clkdm);
 	return 0;
 }
 
Signature · 1 line
1.7.0.4
#4 lore raw

PATCH v2 4/5 OMAP: clockdomain: Arch specific funcs for hwsup control of clkdm

Define the following architecture specific funtions for omap2/3/4 .clkdm_allow_idle
.clkdm_deny_idle

Convert the platform-independent framework to call these functions. Also rename the api's by removing the omap2_ preamble. Hence call omap2_clkdm_allow_idle as clkdm_allow_idle and omap2_clkdm_deny_idle as clkdm_deny_idle.

Make the _clkdm_add_autodeps and _clkdm_del_autodeps as non-static so they can be accessed from OMAP2/3 platform specific code.

---
 arch/arm/mach-omap2/clockdomain.c          |   49 ++++++++-------------------
 arch/arm/mach-omap2/clockdomain.h          |    6 ++-
 arch/arm/mach-omap2/clockdomain2xxx_3xxx.c |   40 ++++++++++++++++++++++
 arch/arm/mach-omap2/clockdomain44xx.c      |   14 ++++++++
 arch/arm/mach-omap2/cpuidle34xx.c          |    4 +-
 arch/arm/mach-omap2/pm.c                   |    2 +-
 arch/arm/mach-omap2/pm24xx.c               |    2 +-
 arch/arm/mach-omap2/pm34xx.c               |    4 +-
 8 files changed, 79 insertions(+), 42 deletions(-)
arch/arm/mach-omap2/clockdomain.c +15 -34
index 9beccc7..9f1f37b 100644
@@ -178,7 +178,7 @@ static void _autodep_lookup(struct clkdm_autodep *autodep)
  * XXX autodeps are deprecated and should be removed at the earliest
  * opportunity
  */
-static void _clkdm_add_autodeps(struct clockdomain *clkdm)
+void _clkdm_add_autodeps(struct clockdomain *clkdm)
 {
 	struct clkdm_autodep *autodep;
 
@@ -212,7 +212,7 @@ static void _clkdm_add_autodeps(struct clockdomain *clkdm)
  * XXX autodeps are deprecated and should be removed at the earliest
  * opportunity
  */
-static void _clkdm_del_autodeps(struct clockdomain *clkdm)
+void _clkdm_del_autodeps(struct clockdomain *clkdm)
 {
 	struct clkdm_autodep *autodep;
 
@@ -332,7 +332,7 @@ void clkdm_init(struct clockdomain **clkdms,
 		if (clkdm->flags & CLKDM_CAN_FORCE_WAKEUP)
 			clkdm_wakeup(clkdm);
 		else if (clkdm->flags & CLKDM_CAN_DISABLE_AUTO)
-			omap2_clkdm_deny_idle(clkdm);
+			clkdm_deny_idle(clkdm);
 
 		for (cd = clkdm->wkdep_srcs; cd && cd->clkdm_name; cd++) {
 			if (!omap_chip_is(cd->omap_chip))
@@ -780,7 +780,7 @@ int clkdm_wakeup(struct clockdomain *clkdm)
 }
 
 /**
- * omap2_clkdm_allow_idle - enable hwsup idle transitions for clkdm
+ * clkdm_allow_idle - enable hwsup idle transitions for clkdm
  * @clkdm: struct clockdomain *
  *
  * Allow the hardware to automatically switch the clockdomain @clkdm into
@@ -789,7 +789,7 @@ int clkdm_wakeup(struct clockdomain *clkdm)
  * framework, wkdep/sleepdep autodependencies are added; this is so
  * device drivers can read and write to the device.  No return value.
  */
-void omap2_clkdm_allow_idle(struct clockdomain *clkdm)
+void clkdm_allow_idle(struct clockdomain *clkdm)
 {
 	if (!clkdm)
 		return;
@@ -800,28 +800,18 @@ void omap2_clkdm_allow_idle(struct clockdomain *clkdm)
 		return;
 	}
 
+	if (!arch_clkdm || !arch_clkdm->clkdm_allow_idle)
+		return;
+
 	pr_debug("clockdomain: enabling automatic idle transitions for %s\n",
 		 clkdm->name);
 
-	/*
-	 * XXX This should be removed once TI adds wakeup/sleep
-	 * dependency code and data for OMAP4.
-	 */
-	if (cpu_is_omap44xx()) {
-		WARN_ONCE(1, "clockdomain: OMAP4 wakeup/sleep dependency "
-			  "support is not yet implemented\n");
-	} else {
-		if (atomic_read(&clkdm->usecount) > 0)
-			_clkdm_add_autodeps(clkdm);
-	}
-
-	_enable_hwsup(clkdm);
-
+	arch_clkdm->clkdm_allow_idle(clkdm);
 	pwrdm_clkdm_state_switch(clkdm);
 }
 
 /**
- * omap2_clkdm_deny_idle - disable hwsup idle transitions for clkdm
+ * clkdm_deny_idle - disable hwsup idle transitions for clkdm
  * @clkdm: struct clockdomain *
  *
  * Prevent the hardware from automatically switching the clockdomain
@@ -829,7 +819,7 @@ void omap2_clkdm_allow_idle(struct clockdomain *clkdm)
  * downstream clocks enabled in the clock framework, wkdep/sleepdep
  * autodependencies are removed.  No return value.
  */
-void omap2_clkdm_deny_idle(struct clockdomain *clkdm)
+void clkdm_deny_idle(struct clockdomain *clkdm)
 {
 	if (!clkdm)
 		return;
@@ -840,22 +830,13 @@ void omap2_clkdm_deny_idle(struct clockdomain *clkdm)
 		return;
 	}
 
+	if (!arch_clkdm || !arch_clkdm->clkdm_deny_idle)
+		return;
+
 	pr_debug("clockdomain: disabling automatic idle transitions for %s\n",
 		 clkdm->name);
 
-	_disable_hwsup(clkdm);
-
-	/*
-	 * XXX This should be removed once TI adds wakeup/sleep
-	 * dependency code and data for OMAP4.
-	 */
-	if (cpu_is_omap44xx()) {
-		WARN_ONCE(1, "clockdomain: OMAP4 wakeup/sleep dependency "
-			  "support is not yet implemented\n");
-	} else {
-		if (atomic_read(&clkdm->usecount) > 0)
-			_clkdm_del_autodeps(clkdm);
-	}
+	arch_clkdm->clkdm_deny_idle(clkdm);
 }
 
 
arch/arm/mach-omap2/clockdomain.h +4 -2
index 7a5cb5c..7126658 100644
@@ -167,8 +167,8 @@ int clkdm_del_sleepdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
 int clkdm_read_sleepdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
 int clkdm_clear_all_sleepdeps(struct clockdomain *clkdm);
 
-void omap2_clkdm_allow_idle(struct clockdomain *clkdm);
-void omap2_clkdm_deny_idle(struct clockdomain *clkdm);
+void clkdm_allow_idle(struct clockdomain *clkdm);
+void clkdm_deny_idle(struct clockdomain *clkdm);
 
 int clkdm_wakeup(struct clockdomain *clkdm);
 int clkdm_sleep(struct clockdomain *clkdm);
@@ -179,6 +179,8 @@ int omap2_clkdm_clk_disable(struct clockdomain *clkdm, struct clk *clk);
 extern void __init omap2xxx_clockdomains_init(void);
 extern void __init omap3xxx_clockdomains_init(void);
 extern void __init omap44xx_clockdomains_init(void);
+extern void _clkdm_add_autodeps(struct clockdomain *clkdm);
+extern void _clkdm_del_autodeps(struct clockdomain *clkdm);
 
 extern struct clkdm_ops omap2_clkdm_operations;
 extern struct clkdm_ops omap3_clkdm_operations;
arch/arm/mach-omap2/clockdomain2xxx_3xxx.c +40 -0
index 2b90e91..54b0ca9 100644
@@ -124,6 +124,24 @@ static int omap2_clkdm_wakeup(struct clockdomain *clkdm)
 	return 0;
 }
 
+static void omap2_clkdm_allow_idle(struct clockdomain *clkdm)
+{
+	if (atomic_read(&clkdm->usecount) > 0)
+		_clkdm_add_autodeps(clkdm);
+
+	omap2xxx_cm_clkdm_enable_hwsup(clkdm->pwrdm.ptr->prcm_offs,
+				clkdm->clktrctrl_mask);
+}
+
+static void omap2_clkdm_deny_idle(struct clockdomain *clkdm)
+{
+	omap2xxx_cm_clkdm_disable_hwsup(clkdm->pwrdm.ptr->prcm_offs,
+				clkdm->clktrctrl_mask);
+
+	if (atomic_read(&clkdm->usecount) > 0)
+		_clkdm_del_autodeps(clkdm);
+}
+
 static int omap3_clkdm_sleep(struct clockdomain *clkdm)
 {
 	omap3xxx_cm_clkdm_force_sleep(clkdm->pwrdm.ptr->prcm_offs,
@@ -138,6 +156,24 @@ static int omap3_clkdm_wakeup(struct clockdomain *clkdm)
 	return 0;
 }
 
+static void omap3_clkdm_allow_idle(struct clockdomain *clkdm)
+{
+	if (atomic_read(&clkdm->usecount) > 0)
+		_clkdm_add_autodeps(clkdm);
+
+	omap3xxx_cm_clkdm_enable_hwsup(clkdm->pwrdm.ptr->prcm_offs,
+				clkdm->clktrctrl_mask);
+}
+
+static void omap3_clkdm_deny_idle(struct clockdomain *clkdm)
+{
+	omap3xxx_cm_clkdm_disable_hwsup(clkdm->pwrdm.ptr->prcm_offs,
+				clkdm->clktrctrl_mask);
+
+	if (atomic_read(&clkdm->usecount) > 0)
+		_clkdm_del_autodeps(clkdm);
+}
+
 struct clkdm_ops omap2_clkdm_operations = {
 	.clkdm_add_wkdep	= omap2_clkdm_add_wkdep,
 	.clkdm_del_wkdep	= omap2_clkdm_del_wkdep,
@@ -145,6 +181,8 @@ struct clkdm_ops omap2_clkdm_operations = {
 	.clkdm_clear_all_wkdeps	= omap2_clkdm_clear_all_wkdeps,
 	.clkdm_sleep		= omap2_clkdm_sleep,
 	.clkdm_wakeup		= omap2_clkdm_wakeup,
+	.clkdm_allow_idle	= omap2_clkdm_allow_idle,
+	.clkdm_deny_idle	= omap2_clkdm_deny_idle,
 };
 
 struct clkdm_ops omap3_clkdm_operations = {
@@ -158,4 +196,6 @@ struct clkdm_ops omap3_clkdm_operations = {
 	.clkdm_clear_all_sleepdeps	= omap3_clkdm_clear_all_sleepdeps,
 	.clkdm_sleep		= omap3_clkdm_sleep,
 	.clkdm_wakeup		= omap3_clkdm_wakeup,
+	.clkdm_allow_idle	= omap3_clkdm_allow_idle,
+	.clkdm_deny_idle	= omap3_clkdm_deny_idle,
 };
arch/arm/mach-omap2/clockdomain44xx.c +14 -0
index 9ccb406..a46125f 100644
@@ -29,7 +29,21 @@ static int omap4_clkdm_wakeup(struct clockdomain *clkdm)
 	return 0;
 }
 
+static void omap4_clkdm_allow_idle(struct clockdomain *clkdm)
+{
+	omap4_cminst_clkdm_enable_hwsup(clkdm->prcm_partition,
+					clkdm->cm_inst, clkdm->clkdm_offs);
+}
+
+static void omap4_clkdm_deny_idle(struct clockdomain *clkdm)
+{
+	omap4_cminst_clkdm_disable_hwsup(clkdm->prcm_partition,
+					clkdm->cm_inst, clkdm->clkdm_offs);
+}
+
 struct clkdm_ops omap4_clkdm_operations = {
 	.clkdm_sleep		= omap4_clkdm_sleep,
 	.clkdm_wakeup		= omap4_clkdm_wakeup,
+	.clkdm_allow_idle	= omap4_clkdm_allow_idle,
+	.clkdm_deny_idle	= omap4_clkdm_deny_idle,
 };
arch/arm/mach-omap2/cpuidle34xx.c +2 -2
index f7b22a1..7cc8071 100644
@@ -99,14 +99,14 @@ static int omap3_idle_bm_check(void)
 static int _cpuidle_allow_idle(struct powerdomain *pwrdm,
 				struct clockdomain *clkdm)
 {
-	omap2_clkdm_allow_idle(clkdm);
+	clkdm_allow_idle(clkdm);
 	return 0;
 }
 
 static int _cpuidle_deny_idle(struct powerdomain *pwrdm,
 				struct clockdomain *clkdm)
 {
-	omap2_clkdm_deny_idle(clkdm);
+	clkdm_deny_idle(clkdm);
 	return 0;
 }
 
arch/arm/mach-omap2/pm.c +1 -1
index 74c3100..7bb64d8 100644
@@ -140,7 +140,7 @@ int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state)
 	switch (sleep_switch) {
 	case FORCEWAKEUP_SWITCH:
 		if (pwrdm->pwrdm_clkdms[0]->flags & CLKDM_CAN_ENABLE_AUTO)
-			omap2_clkdm_allow_idle(pwrdm->pwrdm_clkdms[0]);
+			clkdm_allow_idle(pwrdm->pwrdm_clkdms[0]);
 		else
 			clkdm_sleep(pwrdm->pwrdm_clkdms[0]);
 		break;
arch/arm/mach-omap2/pm24xx.c +1 -1
index 5c32f5f..ebda2ea 100644
@@ -367,7 +367,7 @@ static int __init clkdms_setup(struct clockdomain *clkdm, void *unused)
 	clkdm_clear_all_sleepdeps(clkdm);
 
 	if (clkdm->flags & CLKDM_CAN_ENABLE_AUTO)
-		omap2_clkdm_allow_idle(clkdm);
+		clkdm_allow_idle(clkdm);
 	else if (clkdm->flags & CLKDM_CAN_FORCE_SLEEP &&
 		 atomic_read(&clkdm->usecount) == 0)
 		clkdm_sleep(clkdm);
arch/arm/mach-omap2/pm34xx.c +2 -2
index b954b6f..78e1aa5 100644
@@ -495,7 +495,7 @@ console_still_active:
 
 	pwrdm_post_transition();
 
-	omap2_clkdm_allow_idle(mpu_pwrdm->pwrdm_clkdms[0]);
+	clkdm_allow_idle(mpu_pwrdm->pwrdm_clkdms[0]);
 }
 
 int omap3_can_sleep(void)
@@ -989,7 +989,7 @@ static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
 static int __init clkdms_setup(struct clockdomain *clkdm, void *unused)
 {
 	if (clkdm->flags & CLKDM_CAN_ENABLE_AUTO)
-		omap2_clkdm_allow_idle(clkdm);
+		clkdm_allow_idle(clkdm);
 	else if (clkdm->flags & CLKDM_CAN_FORCE_SLEEP &&
 		 atomic_read(&clkdm->usecount) == 0)
 		clkdm_sleep(clkdm);
Signature · 1 line
1.7.0.4
#5 lore raw

PATCH v2 5/5 OMAP: clockdomain: Arch specific funcs for clkdm_clk_enable/disable

Define the following architecture specific funtions for omap2/3/4 .clkdm_clk_enable
.clkdm_clk_disable

Convert the platform-independent framework to call these functions. Also rename the api's by removing the omap2_ preamble. Hence call omap2_clkdm_k_enable as clkdm_clk_enable and omap2_clkdm_clk_disable as clkdm_clk_disable.a

Remove unused functions (_enable/_disable_hwsup) and unsed headers from clockdomain.c file.

---
 arch/arm/mach-omap2/clock.c                |    6 +-
 arch/arm/mach-omap2/clockdomain.c          |  131 +++-------------------------
 arch/arm/mach-omap2/clockdomain.h          |    4 +-
 arch/arm/mach-omap2/clockdomain2xxx_3xxx.c |   69 +++++++++++++++
 arch/arm/mach-omap2/clockdomain44xx.c      |   28 ++++++
 5 files changed, 114 insertions(+), 124 deletions(-)
arch/arm/mach-omap2/clock.c +3 -3
index 2a2f152..e9625fc 100644
@@ -264,7 +264,7 @@ void omap2_clk_disable(struct clk *clk)
 	clk->ops->disable(clk);
 
 	if (clk->clkdm)
-		omap2_clkdm_clk_disable(clk->clkdm, clk);
+		clkdm_clk_disable(clk->clkdm, clk);
 
 	if (clk->parent)
 		omap2_clk_disable(clk->parent);
@@ -304,7 +304,7 @@ int omap2_clk_enable(struct clk *clk)
 	}
 
 	if (clk->clkdm) {
-		ret = omap2_clkdm_clk_enable(clk->clkdm, clk);
+		ret = clkdm_clk_enable(clk->clkdm, clk);
 		if (ret) {
 			WARN(1, "clock: %s: could not enable clockdomain %s: "
 			     "%d\n", clk->name, clk->clkdm->name, ret);
@@ -322,7 +322,7 @@ int omap2_clk_enable(struct clk *clk)
 
 oce_err3:
 	if (clk->clkdm)
-		omap2_clkdm_clk_disable(clk->clkdm, clk);
+		clkdm_clk_disable(clk->clkdm, clk);
 oce_err2:
 	if (clk->parent)
 		omap2_clk_disable(clk->parent);
arch/arm/mach-omap2/clockdomain.c +12 -119

195 lines not on this page · raw message

arch/arm/mach-omap2/clockdomain.h +2 -2
index 7126658..de52f05 100644
@@ -173,8 +173,8 @@ void clkdm_deny_idle(struct clockdomain *clkdm);
 int clkdm_wakeup(struct clockdomain *clkdm);
 int 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);
+int clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk);
+int clkdm_clk_disable(struct clockdomain *clkdm, struct clk *clk);
 
 extern void __init omap2xxx_clockdomains_init(void);
 extern void __init omap3xxx_clockdomains_init(void);
arch/arm/mach-omap2/clockdomain2xxx_3xxx.c +69 -0

85 lines not on this page · raw message

arch/arm/mach-omap2/clockdomain44xx.c +28 -0
index a46125f..c0ccc47 100644
@@ -41,9 +41,37 @@ static void omap4_clkdm_deny_idle(struct clockdomain *clkdm)
 					clkdm->cm_inst, clkdm->clkdm_offs);
 }
 
+static int omap4_clkdm_clk_enable(struct clockdomain *clkdm)
+{
+	bool hwsup = false;
+
+	hwsup = omap4_cminst_is_clkdm_in_hwsup(clkdm->prcm_partition,
+					clkdm->cm_inst, clkdm->clkdm_offs);
+
+	if (!hwsup)
+		clkdm_wakeup(clkdm);
+
+	return 0;
+}
+
+static int omap4_clkdm_clk_disable(struct clockdomain *clkdm)
+{
+	bool hwsup = false;
+
+	hwsup = omap4_cminst_is_clkdm_in_hwsup(clkdm->prcm_partition,
+					clkdm->cm_inst, clkdm->clkdm_offs);
+
+	if (!hwsup)
+		clkdm_sleep(clkdm);
+
+	return 0;
+}
+
 struct clkdm_ops omap4_clkdm_operations = {
 	.clkdm_sleep		= omap4_clkdm_sleep,
 	.clkdm_wakeup		= omap4_clkdm_wakeup,
 	.clkdm_allow_idle	= omap4_clkdm_allow_idle,
 	.clkdm_deny_idle	= omap4_clkdm_deny_idle,
+	.clkdm_clk_enable	= omap4_clkdm_clk_enable,
+	.clkdm_clk_disable	= omap4_clkdm_clk_disable,
 };
Signature · 1 line
1.7.0.4
maintainer
#6 lore raw

PATCH v2 2/5 OMAP: clockdomain: Arch specific funcs to handle deps

In reply to Rajendra Nayak

Hi

Kevin caught a couple of bugs in this code during his testing that were unmasked by "[PATCH] OMAP2/3: PM: remove unnecessary wakeup/sleep dependency clear":

http://www.spinics.net/lists/arm-kernel/msg112417.html

Symptoms here:

http://www.spinics.net/lists/arm-kernel/msg113991.html

On Tue, 25 Jan 2011, Rajendra Nayak wrote:

+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; cd++) {

cd->clkdm should be cd->clkdm_name; otherwise, any wkdep_src that does not apply to the current chip will terminate the loop early (since cd->clkdm will be NULL in that case)

Review

Quoted 6 lines
(quoted diff) +6 -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; cd++) {

Same thing here.

Updated patch follows,

- 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]

---
 arch/arm/mach-omap2/Makefile                     |    2 +
 arch/arm/mach-omap2/clockdomain.c                |  160 +++++++++++-----------
 arch/arm/mach-omap2/clockdomain.h                |    6 +-
 arch/arm/mach-omap2/clockdomain2xxx_3xxx.c       |  126 +++++++++++++++++
 arch/arm/mach-omap2/clockdomains2xxx_3xxx_data.c |    9 +-
 arch/arm/mach-omap2/io.c                         |    6 +-
 6 files changed, 225 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 +82 -78

318 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 +126 -0

126 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
#7 lore raw

PATCH v2 2/5 OMAP: clockdomain: Arch specific funcs to handle deps

One other minor change; also modified the wkdep_src/sleepdep_src clkdm resolve loops in clkdm_init() to avoid re-resolving clockdomains that have already been looked up. Updated patch follows.

- Paul

#8 lore raw

PATCH v2 2/5 OMAP: clockdomain: Arch specific funcs to handle deps

Quoted 5 lines

-----Original Message-----
From: Paul Walmsley [mailto:paul at pwsan.com]
Sent: Friday, February 11, 2011 7:40 AM
To: Rajendra Nayak
Cc: linux-omap at vger.kernel.org; linux-arm-kernel at lists.infradead.org;

khilman at ti.com; b-cousson at ti.com

Quoted 1 line

Subject: Re: [PATCH v2 2/5] OMAP: clockdomain: Arch specific funcs to

handle deps

Quoted 4 lines

One other minor change; also modified the wkdep_src/sleepdep_src clkdm resolve loops in clkdm_init() to avoid re-resolving clockdomains that

have

Quoted 1 line

already been looked up. Updated patch follows.

Thanks, looks good.

Quoted 20 lines

- Paul

From 22e63ae70ee061de0171c99ee336957b5e9a11ea Mon Sep 17 00:00:00 2001
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 7 lines

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

---
 arch/arm/mach-omap2/Makefile                     |    2 +
 arch/arm/mach-omap2/clockdomain.c                |  164

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

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

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

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, 229 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

Quoted 15 lines

index f70b06a..ee73927 100644

arch/arm/mach-omap2/clockdomain.c +1 -0
@@ -308,6 +308,7 @@ void clkdm_init(struct clockdomain **clkdms,
 	struct clockdomain **c = NULL;
 	struct clockdomain *clkdm;
 	struct clkdm_autodep *autodep = NULL;
+	struct clkdm_dep *cd;
 
 	if (!custom_funcs)
 		WARN(1, "No custom clkdm functions registered\n");
@@ -333,7 +334,22 @@ void clkdm_init(struct clockdomain **clkdms,
 		else if (clkdm->flags & CLKDM_CAN_DISABLE_AUTO)
 			omap2_clkdm_deny_idle(clkdm);
 

arch/arm/mach-omap2/clockdomain.c void clkdm_init(struct clockdomain **clkdms, · line 346

Quoted 10 lines
arch/arm/mach-omap2/clockdomain.c +9 -0
+		for (cd = clkdm->wkdep_srcs; cd && cd->clkdm_name; cd++) {
+			if (!omap_chip_is(cd->omap_chip))
+				continue;
+			if (cd->clkdm)
+				continue;
+			cd->clkdm = _clkdm_lookup(cd->clkdm_name);
+		}
 		clkdm_clear_all_wkdeps(clkdm);
+
+		for (cd = clkdm->sleepdep_srcs; cd && cd->clkdm_name;

cd++) {

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

Quoted 10 lines
arch/arm/mach-omap2/clockdomain.c +6 -0
+			if (!omap_chip_is(cd->omap_chip))
+				continue;
+			if (cd->clkdm)
+				continue;
+			cd->clkdm = _clkdm_lookup(cd->clkdm_name);
+		}
 		clkdm_clear_all_sleepdeps(clkdm);
 	}
 }
@@ -430,6 +446,7 @@ struct powerdomain *clkdm_get_pwrdm(struct

clockdomain *clkdm)

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

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 +458,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 469

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 +493,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 493

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 +505,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 516

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 522

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 +544,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 544

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 +556,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 567

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 +584,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 +593,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 +614,33 @@ int clkdm_clear_all_wkdeps(struct clockdomain

*clkdm)

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

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 +658,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 658

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 +682,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 +707,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 707

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 +742,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..38dd903

arch/arm/mach-omap2/clockdomain2xxx_3xxx.c new file +16 -0
@@ -0,0 +1,126 @@
+/*
+ * 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 16 lines
arch/arm/mach-omap2/clockdomain2xxx_3xxx.c new file +16 -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;
+
+		/* 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 38 lines
arch/arm/mach-omap2/clockdomain2xxx_3xxx.c new file +37 -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;
+
+		/* 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