All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC/PATCH 00/13] OMAP2+: PM: isolate PM code in modules
@ 2011-05-18 17:32 jean.pihet
  2011-05-18 17:32 ` [PATCH 01/13] perf: export power_start and power_end tracepoints jean.pihet
                   ` (13 more replies)
  0 siblings, 14 replies; 27+ messages in thread
From: jean.pihet @ 2011-05-18 17:32 UTC (permalink / raw)
  To: linux-omap

From: Jean Pihet <j-pihet@ti.com>

First attempt at isolation of the OMAP2+ PM code

RFC quality code but successfully tested on board as a proof
of concept

1) provide PM functionality as modules

To allow for the PM functionality to be built and used as modules a
clean-up and isolation task first has been performed ('spaghetti
unwinding') because there are a lot of cross calls between various parts
of the PM code (core, platform specific, cpuidle ...).

Since the option CONFIG_PM is always set for OMAP chips and since
CONFIG_PM cannot be set to 'm', a new config option CONFIG_OMAP_PM is defined.
This option allows for the OMAP2+ PM code to be enabled, disabled or
built as modules.

Furthermore CONFIG_PM is used to completely enable or disable the whole
PM code.

The PM functionality is split into the following modules:
 - omap_pm_debug
 - omap2_pm
 - omap3_pm
 - omap4_pm

The following functionality is moved to the modules:
 - platform specific PM core
 - suspend
 - cpuidle
 - PM debug
    
The following functionality is needed at boot time and so is left
in the PM core code (i.e. not built as modules):
 - PRCM
 - clock domains
 - power domains
 - voltage domains
 - hwmod
 - smart reflex
 - per-platform PRCM data
 - per-platform clock data
 - per-platform power domains data
 - per-platform hwmod data
 - per-platform OPP data

2) Addition of EXPORT_SYMBOL for functions and variables used by
the code in PM modules. Lots of (too many?) symbols need to exported
to the PM modules.

3) Clean-up of used resources to allow clean insertion and removal
of the PM modules. This allows insmod/rmmod of the PM modules
to work.


Questions/concerns
------------------
- IMHO too many symbols are exported from various layers to the PM modules, e.g.
cpu_init, flush_tlb_all, omap_irq_pending, v7_flush_dcache_all ...) in patches
10/13, 12/13. Is that OK?

- v7_flush_dcache_all which is implemented in assembly is exported using
EXPORT_SYMBOL in pm.c, or by using a C stub function. That obvioulsy looks wrong
but no cleaner way has been found yet.

- export suspend_set_ops to PM modules hack (patch 09/13): a stub is needed
because the suspend_set_ops functions are not exported by the kernel.
Could that be done?

- the most worrysome piece of code to isolate is pm-debug.c aka 'the octopus'.
The main problem is that pm-debug is needed for a useful PM. The reason is
that most of the PM control knobs (enable_off_mode, sleep_while_idle ...)
are controlled by pm-debug via debugfs and are disabled by default.
This patch series is moving the variables and functions from pm-debug to
mach-omap2/pm.c but not the control mechanism.
More clean-up effort is needed.


Tested on OMAP3 Beagleboard with cpuidle in RET mode.

ToDo:
- suspend not tested
- OFF mode in cpuidle not working (console garbage + reboot), investigation on-going
- power domains timer stats initialized with weird values (i.e. not 0), investigation
on-going


Jean Pihet (13):
  perf: export power_start and power_end tracepoints
  OMAP2+: PM: isolate PM code
  OMAP2+: PM: clean up usage of SRAM functions
  OMAP2+: cpuidle: register the board specific C-states table
  OMAP2+: PM: move common code from pm-debug.c to pm.c
  OMAP2+: PM: isolate the scratchpad save function from the PM code
  OMAP2+: PM: move the powerdomains time stats to powerdomain code
  OMAP2+: PM: provide the next timer event API to PM modules
  OMAP2+: PM: export suspend_set_ops to PM modules
  OMAP3: PM: export the v7_flush_dcache_all API to modules
  OMAP2+: PM: implement modules insertion and removal code
  OMAP2+: PM: export functions and variables to PM modules
  OMAP2+: PM: build PM functionality as modules

 arch/arm/kernel/setup.c            |    1 +
 arch/arm/kernel/smp_tlb.c          |    2 +
 arch/arm/mach-omap2/Makefile       |   77 +++++++++++++++++++++-------------
 arch/arm/mach-omap2/clockdomain.c  |    7 +++
 arch/arm/mach-omap2/cm2xxx_3xxx.c  |    7 +++
 arch/arm/mach-omap2/control.c      |   36 ++++++++--------
 arch/arm/mach-omap2/control.h      |    6 +--
 arch/arm/mach-omap2/cpuidle34xx.c  |   27 +++++++++---
 arch/arm/mach-omap2/gpmc.c         |    2 +
 arch/arm/mach-omap2/id.c           |    1 +
 arch/arm/mach-omap2/irq.c          |    7 +++
 arch/arm/mach-omap2/pm-debug.c     |   80 ++++++++++++------------------------
 arch/arm/mach-omap2/pm.c           |   79 +++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/pm.h           |   33 +++++++++++----
 arch/arm/mach-omap2/pm24xx.c       |   33 ++++++++++++--
 arch/arm/mach-omap2/pm34xx.c       |   74 +++++++++++++++++++++++++++++++--
 arch/arm/mach-omap2/pm44xx.c       |   27 +++++++++++-
 arch/arm/mach-omap2/powerdomain.c  |   41 ++++++++++++++++++-
 arch/arm/mach-omap2/powerdomain.h  |    3 +
 arch/arm/mach-omap2/prm2xxx_3xxx.c |    6 +++
 arch/arm/mach-omap2/sdrc.c         |    2 +
 arch/arm/mach-omap2/serial.c       |    5 ++
 arch/arm/mach-omap2/timer-gp.c     |    1 +
 arch/arm/plat-omap/Kconfig         |    9 ++++
 arch/arm/plat-omap/common.c        |    1 +
 arch/arm/plat-omap/dma.c           |    3 +
 arch/arm/plat-omap/gpio.c          |    4 ++
 arch/arm/plat-omap/omap-pm-noop.c  |    2 +
 arch/arm/plat-omap/omap_device.c   |    1 +
 arch/arm/plat-omap/sram.c          |    4 +-
 kernel/trace/power-traces.c        |    3 +-
 31 files changed, 446 insertions(+), 138 deletions(-)

-- 
1.7.4.1


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

* [PATCH 01/13] perf: export power_start and power_end tracepoints
  2011-05-18 17:32 [RFC/PATCH 00/13] OMAP2+: PM: isolate PM code in modules jean.pihet
@ 2011-05-18 17:32 ` jean.pihet
  2011-05-18 17:32 ` [PATCH 02/13] OMAP2+: PM: isolate PM code jean.pihet
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 27+ messages in thread
From: jean.pihet @ 2011-05-18 17:32 UTC (permalink / raw)
  To: linux-omap

From: Jean Pihet <j-pihet@ti.com>

If used in a module both tracepoints need to be exported by the
kernel.
Fixed a typo in CONFIG_EVENT_POWER_TRACING_DEPRECATED to really
export the tracepoints.

Signed-off-by: Jean Pihet <j-pihet@ti.com>
Acked-by: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Renninger <trenn@suse.de>
---
 kernel/trace/power-traces.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/kernel/trace/power-traces.c b/kernel/trace/power-traces.c
index f55fcf6..29b60f2 100644
--- a/kernel/trace/power-traces.c
+++ b/kernel/trace/power-traces.c
@@ -13,8 +13,9 @@
 #define CREATE_TRACE_POINTS
 #include <trace/events/power.h>
 
-#ifdef EVENT_POWER_TRACING_DEPRECATED
+#ifdef CONFIG_EVENT_POWER_TRACING_DEPRECATED
 EXPORT_TRACEPOINT_SYMBOL_GPL(power_start);
+EXPORT_TRACEPOINT_SYMBOL_GPL(power_end);
 #endif
 EXPORT_TRACEPOINT_SYMBOL_GPL(cpu_idle);
 
-- 
1.7.4.1


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

* [PATCH 02/13] OMAP2+: PM: isolate PM code
  2011-05-18 17:32 [RFC/PATCH 00/13] OMAP2+: PM: isolate PM code in modules jean.pihet
  2011-05-18 17:32 ` [PATCH 01/13] perf: export power_start and power_end tracepoints jean.pihet
@ 2011-05-18 17:32 ` jean.pihet
  2011-05-18 17:32 ` [PATCH 03/13] OMAP2+: PM: clean up usage of SRAM functions jean.pihet
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 27+ messages in thread
From: jean.pihet @ 2011-05-18 17:32 UTC (permalink / raw)
  To: linux-omap

From: Jean Pihet <j-pihet@ti.com>

Isolate the PM code under CONFIG_PM. This includes the following:
- core PM,
- powerdomain,
- clockdomain,
- smartreflex,
- voltagedomain,
- OPP.

This cleans up the PM code in order to allow it to be built as a
module.

Signed-off-by: Jean Pihet <j-pihet@ti.com>
---
 arch/arm/mach-omap2/Makefile |   45 +++++++++++++++++++++--------------------
 1 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 43c5c22..0fe8a5b 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -49,14 +49,9 @@ obj-$(CONFIG_ARCH_OMAP4)		+= mux44xx.o
 obj-$(CONFIG_ARCH_OMAP2)		+= sdrc2xxx.o
 # obj-$(CONFIG_ARCH_OMAP3)		+= sdrc3xxx.o
 
-# OPP table initialization
-ifeq ($(CONFIG_PM_OPP),y)
-obj-y					+= opp.o
-obj-$(CONFIG_ARCH_OMAP3)		+= opp3xxx_data.o
-obj-$(CONFIG_ARCH_OMAP4)		+= opp4xxx_data.o
-endif
 
 # Power Management
+#  Includes core PM, powerdomain, clockdomain, smartreflex, voltagedomain, OPP
 ifeq ($(CONFIG_PM),y)
 obj-$(CONFIG_ARCH_OMAP2)		+= pm24xx.o
 obj-$(CONFIG_ARCH_OMAP2)		+= sleep24xx.o pm_bus.o
@@ -74,29 +69,13 @@ ifeq ($(CONFIG_PM_VERBOSE),y)
 CFLAGS_pm_bus.o				+= -DDEBUG
 endif
 
-endif
-
-# PRCM
-obj-$(CONFIG_ARCH_OMAP2)		+= prcm.o cm2xxx_3xxx.o prm2xxx_3xxx.o
-obj-$(CONFIG_ARCH_OMAP3)		+= prcm.o cm2xxx_3xxx.o prm2xxx_3xxx.o \
-					   vc3xxx_data.o vp3xxx_data.o
-# XXX The presence of cm2xxx_3xxx.o on the line below is temporary and
-# will be removed once the OMAP4 part of the codebase is converted to
-# use OMAP4-specific PRCM functions.
-obj-$(CONFIG_ARCH_OMAP4)		+= prcm.o cm2xxx_3xxx.o cminst44xx.o \
-					   cm44xx.o prcm_mpu44xx.o \
-					   prminst44xx.o vc44xx_data.o \
-					   vp44xx_data.o
-
 # OMAP voltage domains
-ifeq ($(CONFIG_PM),y)
 voltagedomain-common			:= voltage.o
 obj-$(CONFIG_ARCH_OMAP2)		+= $(voltagedomain-common)
 obj-$(CONFIG_ARCH_OMAP3)		+= $(voltagedomain-common) \
 					   voltagedomains3xxx_data.o
 obj-$(CONFIG_ARCH_OMAP4)		+= $(voltagedomain-common) \
 					   voltagedomains44xx_data.o
-endif
 
 # OMAP powerdomain framework
 powerdomain-common			+= powerdomain.o powerdomain-common.o
@@ -140,10 +119,32 @@ obj-$(CONFIG_ARCH_OMAP3)		+= $(clock-common) clock3xxx.o \
 obj-$(CONFIG_ARCH_OMAP4)		+= $(clock-common) clock44xx_data.o \
 					   dpll3xxx.o dpll44xx.o
 
+# OPP table initialization
+ifeq ($(CONFIG_PM_OPP),y)
+obj-y					+= opp.o
+obj-$(CONFIG_ARCH_OMAP3)		+= opp3xxx_data.o
+obj-$(CONFIG_ARCH_OMAP4)		+= opp4xxx_data.o
+endif
+
 # OMAP2 clock rate set data (old "OPP" data)
 obj-$(CONFIG_SOC_OMAP2420)		+= opp2420_data.o
 obj-$(CONFIG_SOC_OMAP2430)		+= opp2430_data.o
 
+endif
+# end of CONFIG_PM
+
+# PRCM
+obj-$(CONFIG_ARCH_OMAP2)		+= prcm.o cm2xxx_3xxx.o prm2xxx_3xxx.o
+obj-$(CONFIG_ARCH_OMAP3)		+= prcm.o cm2xxx_3xxx.o prm2xxx_3xxx.o \
+					   vc3xxx_data.o vp3xxx_data.o
+# XXX The presence of cm2xxx_3xxx.o on the line below is temporary and
+# will be removed once the OMAP4 part of the codebase is converted to
+# use OMAP4-specific PRCM functions.
+obj-$(CONFIG_ARCH_OMAP4)		+= prcm.o cm2xxx_3xxx.o cminst44xx.o \
+					   cm44xx.o prcm_mpu44xx.o \
+					   prminst44xx.o vc44xx_data.o \
+					   vp44xx_data.o
+
 # hwmod data
 obj-$(CONFIG_SOC_OMAP2420)		+= omap_hwmod_2420_data.o
 obj-$(CONFIG_SOC_OMAP2430)		+= omap_hwmod_2430_data.o
-- 
1.7.4.1


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

* [PATCH 03/13] OMAP2+: PM: clean up usage of SRAM functions
  2011-05-18 17:32 [RFC/PATCH 00/13] OMAP2+: PM: isolate PM code in modules jean.pihet
  2011-05-18 17:32 ` [PATCH 01/13] perf: export power_start and power_end tracepoints jean.pihet
  2011-05-18 17:32 ` [PATCH 02/13] OMAP2+: PM: isolate PM code jean.pihet
@ 2011-05-18 17:32 ` jean.pihet
  2011-05-26 20:34   ` Kevin Hilman
  2011-05-18 17:32 ` [PATCH 04/13] OMAP2+: cpuidle: register the board specific C-states table jean.pihet
                   ` (10 subsequent siblings)
  13 siblings, 1 reply; 27+ messages in thread
From: jean.pihet @ 2011-05-18 17:32 UTC (permalink / raw)
  To: linux-omap

From: Jean Pihet <j-pihet@ti.com>

Clean-up SRAM functions usage to better isolate PM code, in order
to allow it to be used as a module.

Signed-off-by: Jean Pihet <j-pihet@ti.com>
---
 arch/arm/mach-omap2/pm34xx.c |    1 +
 arch/arm/plat-omap/sram.c    |    2 --
 2 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 0c5e3a4..74169a2 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -456,6 +456,7 @@ void omap_sram_idle(void)
 			omap3_core_restore_context();
 			omap3_cm_restore_context();
 			omap3_sram_restore_context();
+			omap_push_sram_idle();
 			omap2_sms_restore_context();
 		}
 		omap_uart_resume_idle(0);
diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
index a3f50b3..f1a54bb 100644
--- a/arch/arm/plat-omap/sram.c
+++ b/arch/arm/plat-omap/sram.c
@@ -390,7 +390,6 @@ void omap3_sram_restore_context(void)
 	_omap3_sram_configure_core_dpll =
 		omap_sram_push(omap3_sram_configure_core_dpll,
 			       omap3_sram_configure_core_dpll_sz);
-	omap_push_sram_idle();
 }
 #endif /* CONFIG_PM */
 
@@ -399,7 +398,6 @@ static int __init omap34xx_sram_init(void)
 	_omap3_sram_configure_core_dpll =
 		omap_sram_push(omap3_sram_configure_core_dpll,
 			       omap3_sram_configure_core_dpll_sz);
-	omap_push_sram_idle();
 	return 0;
 }
 #else
-- 
1.7.4.1


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

* [PATCH 04/13] OMAP2+: cpuidle: register the board specific C-states table
  2011-05-18 17:32 [RFC/PATCH 00/13] OMAP2+: PM: isolate PM code in modules jean.pihet
                   ` (2 preceding siblings ...)
  2011-05-18 17:32 ` [PATCH 03/13] OMAP2+: PM: clean up usage of SRAM functions jean.pihet
@ 2011-05-18 17:32 ` jean.pihet
  2011-05-18 17:32 ` [PATCH 05/13] OMAP2+: PM: move common code from pm-debug.c to pm.c jean.pihet
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 27+ messages in thread
From: jean.pihet @ 2011-05-18 17:32 UTC (permalink / raw)
  To: linux-omap

From: Jean Pihet <j-pihet@ti.com>

Register the board specific cpuidle C-states table for the cpuidle driver
to use it later at cpuidle init time.

This also cleans up the cpuidle code, in order to allow it to be used
as a module.

Signed-off-by: Jean Pihet <j-pihet@ti.com>
---
 arch/arm/mach-omap2/cpuidle34xx.c |   13 +++++++------
 arch/arm/mach-omap2/pm.c          |   15 +++++++++++++++
 arch/arm/mach-omap2/pm.h          |    6 ++----
 3 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx.c
index 1c240ef..df92f4a 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -320,22 +320,22 @@ void omap3_cpuidle_update_states(u32 mpu_deepest_state, u32 core_deepest_state)
 	}
 }
 
-void omap3_pm_init_cpuidle(struct cpuidle_params *cpuidle_board_params)
+static void omap3_pm_override_cpuidle_states(void)
 {
 	int i;
 
-	if (!cpuidle_board_params)
+	if (!cpuidle_params_override_table)
 		return;
 
 	for (i = OMAP3_STATE_C1; i < OMAP3_MAX_STATES; i++) {
 		cpuidle_params_table[i].valid =
-			cpuidle_board_params[i].valid;
+			cpuidle_params_override_table[i].valid;
 		cpuidle_params_table[i].sleep_latency =
-			cpuidle_board_params[i].sleep_latency;
+			cpuidle_params_override_table[i].sleep_latency;
 		cpuidle_params_table[i].wake_latency =
-			cpuidle_board_params[i].wake_latency;
+			cpuidle_params_override_table[i].wake_latency;
 		cpuidle_params_table[i].threshold =
-			cpuidle_board_params[i].threshold;
+			cpuidle_params_override_table[i].threshold;
 	}
 	return;
 }
@@ -500,6 +500,7 @@ int __init omap3_idle_init(void)
 	per_pd = pwrdm_lookup("per_pwrdm");
 	cam_pd = pwrdm_lookup("cam_pwrdm");
 
+	omap3_pm_override_cpuidle_states();
 	omap_init_power_states();
 	cpuidle_register_driver(&omap3_idle_driver);
 
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index 49486f5..84ef409 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -25,6 +25,9 @@
 #include "pm.h"
 
 static struct omap_device_pm_latency *pm_lats;
+#if defined(CONFIG_PM) && defined(CONFIG_CPU_IDLE)
+struct cpuidle_params *cpuidle_params_override_table;
+#endif
 
 static struct device *mpu_dev;
 static struct device *iva_dev;
@@ -268,3 +271,15 @@ static int __init omap2_common_pm_late_init(void)
 	return 0;
 }
 late_initcall(omap2_common_pm_late_init);
+
+#if defined(CONFIG_PM) && defined(CONFIG_CPU_IDLE)
+/*
+ * Used by the board code to override the default cpuidle C-states tables.
+ * Must be called before the cpuidle driver is registered in omap3_idle_init.
+ */
+void omap3_pm_init_cpuidle(struct cpuidle_params *cpuidle_board_params)
+{
+	cpuidle_params_override_table = cpuidle_board_params;
+}
+#endif
+
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index 797bfd1..3ed185c 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -44,7 +44,9 @@ struct cpuidle_params {
 };
 
 #if defined(CONFIG_PM) && defined(CONFIG_CPU_IDLE)
+extern struct cpuidle_params *cpuidle_params_override_table;
 extern void omap3_pm_init_cpuidle(struct cpuidle_params *cpuidle_board_params);
+extern void omap3_cpuidle_update_states(u32, u32);
 #else
 static
 inline void omap3_pm_init_cpuidle(struct cpuidle_params *cpuidle_board_params)
@@ -73,10 +75,6 @@ extern u32 sleep_while_idle;
 #define sleep_while_idle 0
 #endif
 
-#if defined(CONFIG_CPU_IDLE)
-extern void omap3_cpuidle_update_states(u32, u32);
-#endif
-
 #if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)
 extern void pm_dbg_update_time(struct powerdomain *pwrdm, int prev);
 extern int pm_dbg_regset_save(int reg_set);
-- 
1.7.4.1


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

* [PATCH 05/13] OMAP2+: PM: move common code from pm-debug.c to pm.c
  2011-05-18 17:32 [RFC/PATCH 00/13] OMAP2+: PM: isolate PM code in modules jean.pihet
                   ` (3 preceding siblings ...)
  2011-05-18 17:32 ` [PATCH 04/13] OMAP2+: cpuidle: register the board specific C-states table jean.pihet
@ 2011-05-18 17:32 ` jean.pihet
  2011-05-18 17:32 ` [PATCH 06/13] OMAP2+: PM: isolate the scratchpad save function from the PM code jean.pihet
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 27+ messages in thread
From: jean.pihet @ 2011-05-18 17:32 UTC (permalink / raw)
  To: linux-omap

From: Jean Pihet <j-pihet@ti.com>

Move variables and functions that are by the arch code to the common
pm.c code.

Moved:
. PM knobs variables:
  - enable_off_mode
  - omap2_pm_debug
  - sleep_while_idle
  - wakeup_timer_seconds
  - wakeup_timer_milliseconds

. omap2_pm_wakeup_on_timer function.

This also cleans up the core PM code, in order to allow it to be used
as a module.

Note: Some PM important knobs variables (enable_off_mode, sleep_while_idle)
are controlled by the PM debug code and so it mandates the use of the PM
debug code. The control of those variables shall be moved to the PM code.

Signed-off-by: Jean Pihet <j-pihet@ti.com>
---
 arch/arm/mach-omap2/pm-debug.c |   24 ------------------------
 arch/arm/mach-omap2/pm.c       |   26 ++++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c
index a5a83b3..98cc9ee 100644
--- a/arch/arm/mach-omap2/pm-debug.c
+++ b/arch/arm/mach-omap2/pm-debug.c
@@ -31,19 +31,12 @@
 #include <plat/board.h>
 #include "powerdomain.h"
 #include "clockdomain.h"
-#include <plat/dmtimer.h>
 #include <plat/omap-pm.h>
 
 #include "cm2xxx_3xxx.h"
 #include "prm2xxx_3xxx.h"
 #include "pm.h"
 
-int omap2_pm_debug;
-u32 enable_off_mode;
-u32 sleep_while_idle;
-u32 wakeup_timer_seconds;
-u32 wakeup_timer_milliseconds;
-
 #define DUMP_PRM_MOD_REG(mod, reg)    \
 	regs[reg_count].name = #mod "." #reg; \
 	regs[reg_count++].val = omap2_prm_read_mod_reg(mod, reg)
@@ -162,23 +155,6 @@ void omap2_pm_dump(int mode, int resume, unsigned int us)
 		printk(KERN_INFO "%-20s: 0x%08x\n", regs[i].name, regs[i].val);
 }
 
-void omap2_pm_wakeup_on_timer(u32 seconds, u32 milliseconds)
-{
-	u32 tick_rate, cycles;
-
-	if (!seconds && !milliseconds)
-		return;
-
-	tick_rate = clk_get_rate(omap_dm_timer_get_fclk(gptimer_wakeup));
-	cycles = tick_rate * seconds + tick_rate * milliseconds / 1000;
-	omap_dm_timer_stop(gptimer_wakeup);
-	omap_dm_timer_set_load_start(gptimer_wakeup, 0, 0xffffffff - cycles);
-
-	pr_info("PM: Resume timer in %u.%03u secs"
-		" (%d ticks at %d ticks/sec.)\n",
-		seconds, milliseconds, cycles, tick_rate);
-}
-
 #ifdef CONFIG_DEBUG_FS
 #include <linux/debugfs.h>
 #include <linux/seq_file.h>
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index 84ef409..37a4801 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -18,6 +18,7 @@
 #include <plat/omap-pm.h>
 #include <plat/omap_device.h>
 #include <plat/common.h>
+#include <plat/dmtimer.h>
 
 #include "voltage.h"
 #include "powerdomain.h"
@@ -29,6 +30,14 @@ static struct omap_device_pm_latency *pm_lats;
 struct cpuidle_params *cpuidle_params_override_table;
 #endif
 
+u32 enable_off_mode;
+EXPORT_SYMBOL(enable_off_mode);
+
+int omap2_pm_debug;
+u32 sleep_while_idle;
+u32 wakeup_timer_seconds;
+u32 wakeup_timer_milliseconds;
+
 static struct device *mpu_dev;
 static struct device *iva_dev;
 static struct device *l3_dev;
@@ -283,3 +292,20 @@ void omap3_pm_init_cpuidle(struct cpuidle_params *cpuidle_board_params)
 }
 #endif
 
+void omap2_pm_wakeup_on_timer(u32 seconds, u32 milliseconds)
+{
+	u32 tick_rate, cycles;
+
+	if (!seconds && !milliseconds)
+		return;
+
+	tick_rate = clk_get_rate(omap_dm_timer_get_fclk(gptimer_wakeup));
+	cycles = tick_rate * seconds + tick_rate * milliseconds / 1000;
+	omap_dm_timer_stop(gptimer_wakeup);
+	omap_dm_timer_set_load_start(gptimer_wakeup, 0, 0xffffffff - cycles);
+
+	pr_info("PM: Resume timer in %u.%03u secs"
+		" (%d ticks at %d ticks/sec.)\n",
+		seconds, milliseconds, cycles, tick_rate);
+}
+
-- 
1.7.4.1


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

* [PATCH 06/13] OMAP2+: PM: isolate the scratchpad save function from the PM code
  2011-05-18 17:32 [RFC/PATCH 00/13] OMAP2+: PM: isolate PM code in modules jean.pihet
                   ` (4 preceding siblings ...)
  2011-05-18 17:32 ` [PATCH 05/13] OMAP2+: PM: move common code from pm-debug.c to pm.c jean.pihet
@ 2011-05-18 17:32 ` jean.pihet
  2011-05-18 17:32 ` [PATCH 07/13] OMAP2+: PM: move the powerdomains time stats to powerdomain code jean.pihet
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 27+ messages in thread
From: jean.pihet @ 2011-05-18 17:32 UTC (permalink / raw)
  To: linux-omap

From: Jean Pihet <j-pihet@ti.com>

This patch provides the omap3_save_scratchpad_contents function as
a service from the common control code.
The PM code calls the service to store the appropriate data in the
scratchpad area, including the restore pointer from OFF/OSWR modes
and the secure RAM restore pointer.

This also cleans up the core PM code, in order to allow it to be used
as a module.

Signed-off-by: Jean Pihet <j-pihet@ti.com>
---
 arch/arm/mach-omap2/control.c |   23 +++++------------------
 arch/arm/mach-omap2/control.h |    6 ++----
 arch/arm/mach-omap2/pm.h      |    7 ++++++-
 arch/arm/mach-omap2/pm34xx.c  |   28 +++++++++++++++++++++++++++-
 4 files changed, 40 insertions(+), 24 deletions(-)

diff --git a/arch/arm/mach-omap2/control.c b/arch/arm/mach-omap2/control.c
index da53ba3..23b83bd 100644
--- a/arch/arm/mach-omap2/control.c
+++ b/arch/arm/mach-omap2/control.c
@@ -267,7 +267,8 @@ void omap3_clear_scratchpad_contents(void)
 }
 
 /* Populate the scratchpad structure with restore structure */
-void omap3_save_scratchpad_contents(void)
+void omap3_save_scratchpad_contents(u32 public_restore_ptr,
+				    u32 secure_ram_restore_ptr)
 {
 	void  __iomem *scratchpad_address;
 	u32 arm_context_addr;
@@ -278,27 +279,13 @@ void omap3_save_scratchpad_contents(void)
 	/*
 	 * Populate the Scratchpad contents
 	 *
-	 * The "get_*restore_pointer" functions are used to provide a
+	 * The public_restore_ptr field of the scratchpad data provides a
 	 * physical restore address where the ROM code jumps while waking
 	 * up from MPU OFF/OSWR state.
-	 * The restore pointer is stored into the scratchpad.
 	 */
 	scratchpad_contents.boot_config_ptr = 0x0;
-	if (cpu_is_omap3630())
-		scratchpad_contents.public_restore_ptr =
-			virt_to_phys(get_omap3630_restore_pointer());
-	else if (omap_rev() != OMAP3430_REV_ES3_0 &&
-					omap_rev() != OMAP3430_REV_ES3_1)
-		scratchpad_contents.public_restore_ptr =
-			virt_to_phys(get_restore_pointer());
-	else
-		scratchpad_contents.public_restore_ptr =
-			virt_to_phys(get_es3_restore_pointer());
-	if (omap_type() == OMAP2_DEVICE_TYPE_GP)
-		scratchpad_contents.secure_ram_restore_ptr = 0x0;
-	else
-		scratchpad_contents.secure_ram_restore_ptr =
-			(u32) __pa(omap3_secure_ram_storage);
+	scratchpad_contents.public_restore_ptr = public_restore_ptr;
+	scratchpad_contents.secure_ram_restore_ptr = secure_ram_restore_ptr;
 	scratchpad_contents.sdrc_module_semaphore = 0x0;
 	scratchpad_contents.prcm_block_offset = 0x2C;
 	scratchpad_contents.sdrc_block_offset = 0x64;
diff --git a/arch/arm/mach-omap2/control.h b/arch/arm/mach-omap2/control.h
index c2804c1..5f053a4 100644
--- a/arch/arm/mach-omap2/control.h
+++ b/arch/arm/mach-omap2/control.h
@@ -384,11 +384,9 @@ extern void omap_ctrl_writew(u16 val, u16 offset);
 extern void omap_ctrl_writel(u32 val, u16 offset);
 extern void omap4_ctrl_pad_writel(u32 val, u16 offset);
 
-extern void omap3_save_scratchpad_contents(void);
+extern void omap3_save_scratchpad_contents(u32 public_restore_ptr,
+					   u32 secure_ram_restore_ptr);
 extern void omap3_clear_scratchpad_contents(void);
-extern u32 *get_restore_pointer(void);
-extern u32 *get_es3_restore_pointer(void);
-extern u32 *get_omap3630_restore_pointer(void);
 extern u32 omap3_arm_context[128];
 extern void omap3_control_save_context(void);
 extern void omap3_control_restore_context(void);
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index 3ed185c..f36f79c 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -91,13 +91,18 @@ extern void omap24xx_cpu_suspend(u32 dll_ctrl, void __iomem *sdrc_dlla_ctrl,
 					void __iomem *sdrc_power);
 extern void omap34xx_cpu_suspend(u32 *addr, int save_state);
 extern int save_secure_ram_context(u32 *addr);
-extern void omap3_save_scratchpad_contents(void);
 
 extern unsigned int omap24xx_idle_loop_suspend_sz;
 extern unsigned int save_secure_ram_context_sz;
 extern unsigned int omap24xx_cpu_suspend_sz;
 extern unsigned int omap34xx_cpu_suspend_sz;
 
+#ifdef CONFIG_PM
+extern u32 *get_restore_pointer(void);
+extern u32 *get_es3_restore_pointer(void);
+extern u32 *get_omap3630_restore_pointer(void);
+#endif
+
 #define PM_RTA_ERRATUM_i608		(1 << 0)
 #define PM_SDRC_WAKEUP_ERRATUM_i583	(1 << 1)
 
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 74169a2..4c80861 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -885,6 +885,31 @@ static void __init pm_errata_configure(void)
 	}
 }
 
+/*
+ * The "get_*restore_pointer" functions are used to provide a
+ * physical restore address where the ROM code jumps while waking
+ * up from MPU OFF/OSWR state.
+ * The restore pointer is stored into the scratchpad.
+ */
+static inline u32 _get_public_restore_ptr(void)
+{
+	if (cpu_is_omap3630())
+		return virt_to_phys(get_omap3630_restore_pointer());
+	else if (omap_rev() != OMAP3430_REV_ES3_0 &&
+		 omap_rev() != OMAP3430_REV_ES3_1)
+		return virt_to_phys(get_restore_pointer());
+	else
+		return virt_to_phys(get_es3_restore_pointer());
+}
+
+static inline u32 _get_secure_ram_restore_ptr(void)
+{
+	if (omap_type() == OMAP2_DEVICE_TYPE_GP)
+		return 0x0;
+	else
+		return (u32) __pa(omap3_secure_ram_storage);
+}
+
 static int __init omap3_pm_init(void)
 {
 	struct power_state *pwrst, *tmp;
@@ -970,7 +995,8 @@ static int __init omap3_pm_init(void)
 		local_fiq_enable();
 	}
 
-	omap3_save_scratchpad_contents();
+	omap3_save_scratchpad_contents(_get_public_restore_ptr(),
+				       _get_secure_ram_restore_ptr());
 err1:
 	return ret;
 err2:
-- 
1.7.4.1


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

* [PATCH 07/13] OMAP2+: PM: move the powerdomains time stats to powerdomain code
  2011-05-18 17:32 [RFC/PATCH 00/13] OMAP2+: PM: isolate PM code in modules jean.pihet
                   ` (5 preceding siblings ...)
  2011-05-18 17:32 ` [PATCH 06/13] OMAP2+: PM: isolate the scratchpad save function from the PM code jean.pihet
@ 2011-05-18 17:32 ` jean.pihet
  2011-05-26 20:45   ` Kevin Hilman
  2011-05-18 17:32 ` [PATCH 08/13] OMAP2+: PM: provide the next timer event API to PM modules jean.pihet
                   ` (6 subsequent siblings)
  13 siblings, 1 reply; 27+ messages in thread
From: jean.pihet @ 2011-05-18 17:32 UTC (permalink / raw)
  To: linux-omap

From: Jean Pihet <j-pihet@ti.com>

Move the powerdomains time accounting code from in pm-debug to the
powerdomain code. The pm-debug code only displays the information on
request.

This also cleans up the core PM code, in order to allow it to be used
as a module.

Signed-off-by: Jean Pihet <j-pihet@ti.com>
---
 arch/arm/mach-omap2/pm-debug.c    |   26 +-------------------------
 arch/arm/mach-omap2/pm.h          |    2 --
 arch/arm/mach-omap2/powerdomain.c |   25 ++++++++++++++++++++++++-
 arch/arm/mach-omap2/powerdomain.h |    3 +++
 4 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c
index 98cc9ee..0b896d4 100644
--- a/arch/arm/mach-omap2/pm-debug.c
+++ b/arch/arm/mach-omap2/pm-debug.c
@@ -333,21 +333,6 @@ static const char pwrdm_state_names[][PWRDM_MAX_PWRSTS] = {
 	"ON"
 };
 
-void pm_dbg_update_time(struct powerdomain *pwrdm, int prev)
-{
-	s64 t;
-
-	if (!pm_dbg_init_done)
-		return ;
-
-	/* Update timer for previous state */
-	t = sched_clock();
-
-	pwrdm->state_timer[prev] += t - pwrdm->timer;
-
-	pwrdm->timer = t;
-}
-
 static int clkdm_dbg_show_counter(struct clockdomain *clkdm, void *user)
 {
 	struct seq_file *s = (struct seq_file *)user;
@@ -410,7 +395,7 @@ static int pwrdm_dbg_show_timer(struct powerdomain *pwrdm, void *user)
 	seq_printf(s, "%s (%s)", pwrdm->name,
 		pwrdm_state_names[pwrdm->state]);
 
-	for (i = 0; i < 4; i++)
+	for (i = 0; i < PWRDM_MAX_PWRSTS; i++)
 		seq_printf(s, ",%s:%lld", pwrdm_state_names[i],
 			pwrdm->state_timer[i]);
 
@@ -517,17 +502,8 @@ DEFINE_SIMPLE_ATTRIBUTE(pwrdm_suspend_fops, pwrdm_suspend_get,
 
 static int __init pwrdms_setup(struct powerdomain *pwrdm, void *dir)
 {
-	int i;
-	s64 t;
 	struct dentry *d;
 
-	t = sched_clock();
-
-	for (i = 0; i < 4; i++)
-		pwrdm->state_timer[i] = 0;
-
-	pwrdm->timer = t;
-
 	if (strncmp(pwrdm->name, "dpll", 4) == 0)
 		return 0;
 
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index f36f79c..03da7f8 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -76,11 +76,9 @@ extern u32 sleep_while_idle;
 #endif
 
 #if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)
-extern void pm_dbg_update_time(struct powerdomain *pwrdm, int prev);
 extern int pm_dbg_regset_save(int reg_set);
 extern int pm_dbg_regset_init(int reg_set);
 #else
-#define pm_dbg_update_time(pwrdm, prev) do {} while (0);
 #define pm_dbg_regset_save(reg_set) do {} while (0);
 #define pm_dbg_regset_init(reg_set) do {} while (0);
 #endif /* CONFIG_PM_DEBUG */
diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
index 9af0847..93a17c8 100644
--- a/arch/arm/mach-omap2/powerdomain.c
+++ b/arch/arm/mach-omap2/powerdomain.c
@@ -19,6 +19,7 @@
 #include <linux/list.h>
 #include <linux/errno.h>
 #include <linux/string.h>
+#include <linux/sched.h>
 #include <trace/events/power.h>
 
 #include "cm2xxx_3xxx.h"
@@ -77,6 +78,7 @@ static struct powerdomain *_pwrdm_lookup(const char *name)
 static int _pwrdm_register(struct powerdomain *pwrdm)
 {
 	int i;
+	s64 t;
 
 	if (!pwrdm || !pwrdm->name)
 		return -EINVAL;
@@ -100,6 +102,12 @@ static int _pwrdm_register(struct powerdomain *pwrdm)
 	for (i = 0; i < PWRDM_MAX_PWRSTS; i++)
 		pwrdm->state_counter[i] = 0;
 
+	/* Initialize the powerdomain's state timing stats */
+	t = sched_clock();
+	for (i = 0; i < PWRDM_MAX_PWRSTS; i++)
+		pwrdm->state_timer[i] = 0;
+	pwrdm->timer = t;
+
 	pwrdm->ret_logic_off_counter = 0;
 	for (i = 0; i < pwrdm->banks; i++)
 		pwrdm->ret_mem_off_counter[i] = 0;
@@ -171,7 +179,9 @@ static int _pwrdm_state_switch(struct powerdomain *pwrdm, int flag)
 	if (state != prev)
 		pwrdm->state_counter[state]++;
 
-	pm_dbg_update_time(pwrdm, prev);
+#ifdef CONFIG_PM_DEBUG
+	pwrdm_update_state_timer(pwrdm, prev);
+#endif
 
 	pwrdm->state = state;
 
@@ -999,3 +1009,16 @@ bool pwrdm_can_ever_lose_context(struct powerdomain *pwrdm)
 
 	return 0;
 }
+
+#ifdef CONFIG_PM_DEBUG
+void pwrdm_update_state_timer(struct powerdomain *pwrdm, int prev)
+{
+	s64 t;
+
+	/* Update timer for previous state */
+	t = sched_clock();
+	pwrdm->state_timer[prev] += t - pwrdm->timer;
+	pwrdm->timer = t;
+}
+#endif
+
diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h
index d23d979..abda68d 100644
--- a/arch/arm/mach-omap2/powerdomain.h
+++ b/arch/arm/mach-omap2/powerdomain.h
@@ -209,6 +209,9 @@ int pwrdm_post_transition(void);
 int pwrdm_set_lowpwrstchange(struct powerdomain *pwrdm);
 u32 pwrdm_get_context_loss_count(struct powerdomain *pwrdm);
 bool pwrdm_can_ever_lose_context(struct powerdomain *pwrdm);
+#ifdef CONFIG_PM_DEBUG
+void pwrdm_update_state_timer(struct powerdomain *pwrdm, int prev);
+#endif
 
 extern void omap2xxx_powerdomains_init(void);
 extern void omap3xxx_powerdomains_init(void);
-- 
1.7.4.1


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

* [PATCH 08/13] OMAP2+: PM: provide the next timer event API to PM modules
  2011-05-18 17:32 [RFC/PATCH 00/13] OMAP2+: PM: isolate PM code in modules jean.pihet
                   ` (6 preceding siblings ...)
  2011-05-18 17:32 ` [PATCH 07/13] OMAP2+: PM: move the powerdomains time stats to powerdomain code jean.pihet
@ 2011-05-18 17:32 ` jean.pihet
  2011-05-19  7:59   ` Santosh Shilimkar
  2011-05-26 23:00   ` Kevin Hilman
  2011-05-18 17:32 ` [PATCH 09/13] OMAP2+: PM: export suspend_set_ops " jean.pihet
                   ` (5 subsequent siblings)
  13 siblings, 2 replies; 27+ messages in thread
From: jean.pihet @ 2011-05-18 17:32 UTC (permalink / raw)
  To: linux-omap

From: Jean Pihet <j-pihet@ti.com>

Provide omap_pm_tick_nohz_get_sleep_length_us so that the code
from the OMAP PM modules can use it.

Signed-off-by: Jean Pihet <j-pihet@ti.com>
---
 arch/arm/mach-omap2/pm-debug.c |    7 ++++---
 arch/arm/mach-omap2/pm.c       |   15 +++++++++++++++
 arch/arm/mach-omap2/pm.h       |   12 ++++++++----
 3 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c
index 0b896d4..24e5c31 100644
--- a/arch/arm/mach-omap2/pm-debug.c
+++ b/arch/arm/mach-omap2/pm-debug.c
@@ -141,9 +141,10 @@ void omap2_pm_dump(int mode, int resume, unsigned int us)
 	if (!resume)
 #ifdef CONFIG_NO_HZ
 		printk(KERN_INFO
-		       "--- Going to %s %s (next timer after %u ms)\n", s1, s2,
-		       jiffies_to_msecs(get_next_timer_interrupt(jiffies) -
-					jiffies));
+		       "--- Going to %s %s (next timer after %lu ms)\n", s1, s2,
+		       DIV_ROUND_UP(omap_pm_tick_nohz_get_sleep_length_us(),
+				    1000)
+		      );
 #else
 		printk(KERN_INFO "--- Going to %s %s\n", s1, s2);
 #endif
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index 37a4801..0c451e3 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -14,6 +14,8 @@
 #include <linux/io.h>
 #include <linux/err.h>
 #include <linux/opp.h>
+#include <linux/hrtimer.h>
+#include <linux/tick.h>
 
 #include <plat/omap-pm.h>
 #include <plat/omap_device.h>
@@ -30,6 +32,7 @@ static struct omap_device_pm_latency *pm_lats;
 struct cpuidle_params *cpuidle_params_override_table;
 #endif
 
+#ifdef CONFIG_PM_DEBUG
 u32 enable_off_mode;
 EXPORT_SYMBOL(enable_off_mode);
 
@@ -37,6 +40,7 @@ int omap2_pm_debug;
 u32 sleep_while_idle;
 u32 wakeup_timer_seconds;
 u32 wakeup_timer_milliseconds;
+#endif
 
 static struct device *mpu_dev;
 static struct device *iva_dev;
@@ -292,6 +296,7 @@ void omap3_pm_init_cpuidle(struct cpuidle_params *cpuidle_board_params)
 }
 #endif
 
+#ifdef CONFIG_PM_DEBUG
 void omap2_pm_wakeup_on_timer(u32 seconds, u32 milliseconds)
 {
 	u32 tick_rate, cycles;
@@ -308,4 +313,14 @@ void omap2_pm_wakeup_on_timer(u32 seconds, u32 milliseconds)
 		" (%d ticks at %d ticks/sec.)\n",
 		seconds, milliseconds, cycles, tick_rate);
 }
+EXPORT_SYMBOL(omap2_pm_wakeup_on_timer);
+#endif
+
+#ifdef CONFIG_NO_HZ
+unsigned long omap_pm_tick_nohz_get_sleep_length_us(void)
+{
+	return ktime_to_us(tick_nohz_get_sleep_length());
+}
+EXPORT_SYMBOL(omap_pm_tick_nohz_get_sleep_length_us);
+#endif
 
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index 03da7f8..70eb80e 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -68,11 +68,15 @@ extern int omap2_pm_debug;
 extern u32 enable_off_mode;
 extern u32 sleep_while_idle;
 #else
-#define omap2_pm_dump(mode, resume, us)		do {} while (0);
+#define omap2_pm_dump(mode, resume, us)			do {} while (0);
 #define omap2_pm_wakeup_on_timer(seconds, milliseconds)	do {} while (0);
-#define omap2_pm_debug				0
-#define enable_off_mode 0
-#define sleep_while_idle 0
+#define omap2_pm_debug					0
+#define enable_off_mode					0
+#define sleep_while_idle				0
+#endif
+
+#ifdef CONFIG_NO_HZ
+extern unsigned long omap_pm_tick_nohz_get_sleep_length_us(void);
 #endif
 
 #if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)
-- 
1.7.4.1


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

* [PATCH 09/13] OMAP2+: PM: export suspend_set_ops to PM modules
  2011-05-18 17:32 [RFC/PATCH 00/13] OMAP2+: PM: isolate PM code in modules jean.pihet
                   ` (7 preceding siblings ...)
  2011-05-18 17:32 ` [PATCH 08/13] OMAP2+: PM: provide the next timer event API to PM modules jean.pihet
@ 2011-05-18 17:32 ` jean.pihet
  2011-05-26 23:09   ` Kevin Hilman
  2011-05-18 17:32 ` [PATCH 10/13] OMAP3: PM: export the v7_flush_dcache_all API to modules jean.pihet
                   ` (4 subsequent siblings)
  13 siblings, 1 reply; 27+ messages in thread
From: jean.pihet @ 2011-05-18 17:32 UTC (permalink / raw)
  To: linux-omap

From: Jean Pihet <j-pihet@ti.com>

Export the suspend_set_ops API as omap_pm_suspend_set_ops in the pm
generic code, under CONFIG_SUSPEND.

Note -hack warning-: since the 'suspend_valid_only_mem' function is
not exported to modules, fill the 'valid' field value of
'struct platform_suspend_ops' in the common code.

Signed-off-by: Jean Pihet <j-pihet@ti.com>
---
 arch/arm/mach-omap2/pm.c     |   10 ++++++++++
 arch/arm/mach-omap2/pm.h     |    5 +++++
 arch/arm/mach-omap2/pm24xx.c |    9 ++++-----
 arch/arm/mach-omap2/pm34xx.c |    5 ++---
 arch/arm/mach-omap2/pm44xx.c |    6 +++---
 5 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index 0c451e3..2e43fd6 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -16,6 +16,7 @@
 #include <linux/opp.h>
 #include <linux/hrtimer.h>
 #include <linux/tick.h>
+#include <linux/suspend.h>
 
 #include <plat/omap-pm.h>
 #include <plat/omap_device.h>
@@ -324,3 +325,12 @@ unsigned long omap_pm_tick_nohz_get_sleep_length_us(void)
 EXPORT_SYMBOL(omap_pm_tick_nohz_get_sleep_length_us);
 #endif
 
+#ifdef CONFIG_SUSPEND
+void omap_pm_suspend_set_ops(struct platform_suspend_ops *pm_ops)
+{
+	if (pm_ops)
+		pm_ops->valid = suspend_valid_only_mem;
+	suspend_set_ops((const struct platform_suspend_ops *) pm_ops);
+}
+EXPORT_SYMBOL(omap_pm_suspend_set_ops);
+#endif
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index 70eb80e..d1bc6a3 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -12,6 +12,7 @@
 #define __ARCH_ARM_MACH_OMAP2_PM_H
 
 #include <linux/err.h>
+#include <linux/suspend.h>
 
 #include "powerdomain.h"
 
@@ -79,6 +80,10 @@ extern u32 sleep_while_idle;
 extern unsigned long omap_pm_tick_nohz_get_sleep_length_us(void);
 #endif
 
+#ifdef CONFIG_SUSPEND
+extern void omap_pm_suspend_set_ops(struct platform_suspend_ops *pm_ops);
+#endif
+
 #if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)
 extern int pm_dbg_regset_save(int reg_set);
 extern int pm_dbg_regset_init(int reg_set);
diff --git a/arch/arm/mach-omap2/pm24xx.c b/arch/arm/mach-omap2/pm24xx.c
index df3ded6..340da03 100644
--- a/arch/arm/mach-omap2/pm24xx.c
+++ b/arch/arm/mach-omap2/pm24xx.c
@@ -350,14 +350,11 @@ static void omap2_pm_end(void)
 	enable_hlt();
 }
 
-static const struct platform_suspend_ops omap_pm_ops = {
+static struct platform_suspend_ops omap_pm_ops = {
 	.begin		= omap2_pm_begin,
 	.enter		= omap2_pm_enter,
 	.end		= omap2_pm_end,
-	.valid		= suspend_valid_only_mem,
 };
-#else
-static const struct platform_suspend_ops __initdata omap_pm_ops;
 #endif /* CONFIG_SUSPEND */
 
 /* XXX This function should be shareable between OMAP2xxx and OMAP3 */
@@ -515,7 +512,9 @@ static int __init omap2_pm_init(void)
 						    omap24xx_cpu_suspend_sz);
 	}
 
-	suspend_set_ops(&omap_pm_ops);
+#ifdef CONFIG_SUSPEND
+	omap_pm_suspend_set_ops(&omap_pm_ops);
+#endif
 	pm_idle = omap2_pm_idle;
 
 	return 0;
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 4c80861..967b931 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -609,11 +609,10 @@ static void omap3_pm_end(void)
 	return;
 }
 
-static const struct platform_suspend_ops omap_pm_ops = {
+static struct platform_suspend_ops omap_pm_ops = {
 	.begin		= omap3_pm_begin,
 	.end		= omap3_pm_end,
 	.enter		= omap3_pm_enter,
-	.valid		= suspend_valid_only_mem,
 };
 #endif /* CONFIG_SUSPEND */
 
@@ -962,7 +961,7 @@ static int __init omap3_pm_init(void)
 
 	omap_push_sram_idle();
 #ifdef CONFIG_SUSPEND
-	suspend_set_ops(&omap_pm_ops);
+	omap_pm_suspend_set_ops(&omap_pm_ops);
 #endif /* CONFIG_SUSPEND */
 
 	pm_idle = omap3_pm_idle;
diff --git a/arch/arm/mach-omap2/pm44xx.c b/arch/arm/mach-omap2/pm44xx.c
index 59a870b..3d6b991 100644
--- a/arch/arm/mach-omap2/pm44xx.c
+++ b/arch/arm/mach-omap2/pm44xx.c
@@ -18,6 +18,7 @@
 
 #include "powerdomain.h"
 #include <mach/omap4-common.h>
+#include "pm.h"
 
 struct power_state {
 	struct powerdomain *pwrdm;
@@ -65,11 +66,10 @@ static void omap4_pm_end(void)
 	return;
 }
 
-static const struct platform_suspend_ops omap_pm_ops = {
+static struct platform_suspend_ops omap_pm_ops = {
 	.begin		= omap4_pm_begin,
 	.end		= omap4_pm_end,
 	.enter		= omap4_pm_enter,
-	.valid		= suspend_valid_only_mem,
 };
 #endif /* CONFIG_SUSPEND */
 
@@ -112,7 +112,7 @@ static int __init omap4_pm_init(void)
 	}
 
 #ifdef CONFIG_SUSPEND
-	suspend_set_ops(&omap_pm_ops);
+	omap_pm_suspend_set_ops(&omap_pm_ops);
 #endif /* CONFIG_SUSPEND */
 
 err2:
-- 
1.7.4.1


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

* [PATCH 10/13] OMAP3: PM: export the v7_flush_dcache_all API to modules
  2011-05-18 17:32 [RFC/PATCH 00/13] OMAP2+: PM: isolate PM code in modules jean.pihet
                   ` (8 preceding siblings ...)
  2011-05-18 17:32 ` [PATCH 09/13] OMAP2+: PM: export suspend_set_ops " jean.pihet
@ 2011-05-18 17:32 ` jean.pihet
  2011-05-19  8:04   ` Santosh Shilimkar
  2011-05-18 17:32 ` [PATCH 11/13] OMAP2+: PM: implement modules insertion and removal code jean.pihet
                   ` (3 subsequent siblings)
  13 siblings, 1 reply; 27+ messages in thread
From: jean.pihet @ 2011-05-18 17:32 UTC (permalink / raw)
  To: linux-omap

From: Jean Pihet <j-pihet@ti.com>

Provide the the assembly function v7_flush_dcache_all to the
OMAP3 PM module, under CONFIG_CPU_V7.
v7_flush_dcache_all is used by the low level sleep code.

Signed-off-by: Jean Pihet <j-pihet@ti.com>
---
 arch/arm/mach-omap2/pm.c |    4 ++++
 arch/arm/mach-omap2/pm.h |    4 ++++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index 2e43fd6..ab69c5a 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -325,6 +325,10 @@ unsigned long omap_pm_tick_nohz_get_sleep_length_us(void)
 EXPORT_SYMBOL(omap_pm_tick_nohz_get_sleep_length_us);
 #endif
 
+#ifdef CONFIG_CPU_V7
+EXPORT_SYMBOL(v7_flush_dcache_all);
+#endif
+
 #ifdef CONFIG_SUSPEND
 void omap_pm_suspend_set_ops(struct platform_suspend_ops *pm_ops)
 {
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index d1bc6a3..194e883 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -80,6 +80,10 @@ extern u32 sleep_while_idle;
 extern unsigned long omap_pm_tick_nohz_get_sleep_length_us(void);
 #endif
 
+#ifdef CONFIG_CPU_V7
+extern void v7_flush_dcache_all(void);
+#endif
+
 #ifdef CONFIG_SUSPEND
 extern void omap_pm_suspend_set_ops(struct platform_suspend_ops *pm_ops);
 #endif
-- 
1.7.4.1


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

* [PATCH 11/13] OMAP2+: PM: implement modules insertion and removal code
  2011-05-18 17:32 [RFC/PATCH 00/13] OMAP2+: PM: isolate PM code in modules jean.pihet
                   ` (9 preceding siblings ...)
  2011-05-18 17:32 ` [PATCH 10/13] OMAP3: PM: export the v7_flush_dcache_all API to modules jean.pihet
@ 2011-05-18 17:32 ` jean.pihet
  2011-05-18 17:32 ` [PATCH 12/13] OMAP2+: PM: export functions and variables to PM modules jean.pihet
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 27+ messages in thread
From: jean.pihet @ 2011-05-18 17:32 UTC (permalink / raw)
  To: linux-omap

From: Jean Pihet <j-pihet@ti.com>

Clean-up of used resources to allow clean insertion and removal
of the PM modules.

Signed-off-by: Jean Pihet <j-pihet@ti.com>
---
 arch/arm/mach-omap2/cpuidle34xx.c |   14 +++++++++++++-
 arch/arm/mach-omap2/pm-debug.c    |   22 +++++++++++++++++++++-
 arch/arm/mach-omap2/pm.h          |    1 +
 arch/arm/mach-omap2/pm24xx.c      |   24 ++++++++++++++++++++++++
 arch/arm/mach-omap2/pm34xx.c      |   37 ++++++++++++++++++++++++++++++++++++-
 arch/arm/mach-omap2/pm44xx.c      |   21 +++++++++++++++++++++
 6 files changed, 116 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx.c
index df92f4a..233ff30 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -525,8 +525,11 @@ int __init omap3_idle_init(void)
 		count++;
 	}
 
-	if (!count)
+	if (!count) {
+		cpuidle_unregister_driver(&omap3_idle_driver);
 		return -EINVAL;
+	}
+
 	dev->state_count = count;
 
 	if (enable_off_mode)
@@ -542,6 +545,15 @@ int __init omap3_idle_init(void)
 
 	return 0;
 }
+
+void __exit omap3_idle_exit(void)
+{
+	struct cpuidle_device *dev;
+
+	dev = &per_cpu(omap3_idle_dev, smp_processor_id());
+	cpuidle_unregister_device(dev);
+	cpuidle_unregister_driver(&omap3_idle_driver);
+}
 #else
 int __init omap3_idle_init(void)
 {
diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c
index 24e5c31..4e81e8d 100644
--- a/arch/arm/mach-omap2/pm-debug.c
+++ b/arch/arm/mach-omap2/pm-debug.c
@@ -54,6 +54,8 @@
 	regs[reg_count++].val = \
 			 __raw_readl(OMAP2_L4_IO_ADDRESS(0x480fe000 + (off)))
 
+struct dentry *pm_debug_dentry;
+
 void omap2_pm_dump(int mode, int resume, unsigned int us)
 {
 	struct reg {
@@ -567,6 +569,7 @@ static int __init pm_dbg_init(void)
 	d = debugfs_create_dir("pm_debug", NULL);
 	if (IS_ERR(d))
 		return PTR_ERR(d);
+	pm_debug_dentry = d;
 
 	(void) debugfs_create_file("count", S_IRUGO,
 		d, (void *)DEBUG_FILE_COUNTERS, &debug_fops);
@@ -603,6 +606,23 @@ static int __init pm_dbg_init(void)
 
 	return 0;
 }
+
+static void __exit pm_dbg_exit(void)
+{
+	if (!cpu_is_omap34xx())
+		return;
+
+	debugfs_remove_recursive(pm_debug_dentry);
+	pm_debug_dentry = NULL;
+
+	pm_dbg_init_done = 0;
+}
+
 arch_initcall(pm_dbg_init);
+module_exit(pm_dbg_exit);
 
-#endif
+#endif /* CONFIG_DEBUG_FS */
+
+MODULE_AUTHOR("Texas Instruments, Inc.");
+MODULE_DESCRIPTION("OMAP2+ PM debug");
+MODULE_LICENSE("GPL");
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index 194e883..fe5d0dc 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -22,6 +22,7 @@ extern void omap_sram_idle(void);
 extern int omap3_can_sleep(void);
 extern int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state);
 extern int omap3_idle_init(void);
+extern void omap3_idle_exit(void);
 
 #if defined(CONFIG_PM_OPP)
 extern int omap3_opp_init(void);
diff --git a/arch/arm/mach-omap2/pm24xx.c b/arch/arm/mach-omap2/pm24xx.c
index 340da03..dd5a4989 100644
--- a/arch/arm/mach-omap2/pm24xx.c
+++ b/arch/arm/mach-omap2/pm24xx.c
@@ -53,6 +53,8 @@
 #include "powerdomain.h"
 #include "clockdomain.h"
 
+static void (*pm_idle_old)(void);
+
 #ifdef CONFIG_SUSPEND
 static suspend_state_t suspend_state = PM_SUSPEND_ON;
 static inline bool is_suspending(void)
@@ -515,9 +517,31 @@ static int __init omap2_pm_init(void)
 #ifdef CONFIG_SUSPEND
 	omap_pm_suspend_set_ops(&omap_pm_ops);
 #endif
+	pm_idle_old = pm_idle;
 	pm_idle = omap2_pm_idle;
 
 	return 0;
 }
 
+static void __exit omap2_pm_exit(void)
+{
+	if (!cpu_is_omap24xx())
+		return;
+
+	if (pm_idle_old)
+		pm_idle = pm_idle_old;
+
+	omap_pm_suspend_set_ops(NULL);
+
+	/* ToDo: reset PRCM registers to default values (non-PM) */
+
+	clk_put(emul_ck);
+	clk_put(osc_ck);
+}
+
 late_initcall(omap2_pm_init);
+module_exit(omap2_pm_exit);
+
+MODULE_AUTHOR("Texas Instruments, Inc.");
+MODULE_DESCRIPTION("OMAP2 PM");
+MODULE_LICENSE("GPL");
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 967b931..dd36e6d 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -51,6 +51,8 @@
 #include "sdrc.h"
 #include "control.h"
 
+static void (*pm_idle_old)(void);
+
 #ifdef CONFIG_SUSPEND
 static suspend_state_t suspend_state = PM_SUSPEND_ON;
 static inline bool is_suspending(void)
@@ -909,6 +911,31 @@ static inline u32 _get_secure_ram_restore_ptr(void)
 		return (u32) __pa(omap3_secure_ram_storage);
 }
 
+static void __exit omap3_pm_exit(void)
+{
+	struct power_state *pwrst, *tmp;
+
+	if (!cpu_is_omap34xx())
+		return;
+
+	omap3_idle_exit();
+	if (pm_idle_old)
+		pm_idle = pm_idle_old;
+
+	omap_pm_suspend_set_ops(NULL);
+
+	/* ToDo: configure clkdm back to default */
+
+	list_for_each_entry_safe(pwrst, tmp, &pwrst_list, node) {
+		list_del(&pwrst->node);
+		kfree(pwrst);
+	}
+
+	free_irq(INT_34XX_PRCM_MPU_IRQ, NULL);
+
+	/* ToDo: -reset PRCM registers to default values (non-PM) */
+}
+
 static int __init omap3_pm_init(void)
 {
 	struct power_state *pwrst, *tmp;
@@ -964,6 +991,7 @@ static int __init omap3_pm_init(void)
 	omap_pm_suspend_set_ops(&omap_pm_ops);
 #endif /* CONFIG_SUSPEND */
 
+	pm_idle_old = pm_idle;
 	pm_idle = omap3_pm_idle;
 	omap3_idle_init();
 
@@ -999,12 +1027,19 @@ static int __init omap3_pm_init(void)
 err1:
 	return ret;
 err2:
-	free_irq(INT_34XX_PRCM_MPU_IRQ, NULL);
 	list_for_each_entry_safe(pwrst, tmp, &pwrst_list, node) {
 		list_del(&pwrst->node);
 		kfree(pwrst);
 	}
+
+	free_irq(INT_34XX_PRCM_MPU_IRQ, NULL);
+
 	return ret;
 }
 
 late_initcall(omap3_pm_init);
+module_exit(omap3_pm_exit);
+
+MODULE_AUTHOR("Texas Instruments, Inc.");
+MODULE_DESCRIPTION("OMAP3 PM");
+MODULE_LICENSE("GPL");
diff --git a/arch/arm/mach-omap2/pm44xx.c b/arch/arm/mach-omap2/pm44xx.c
index 3d6b991..aea5b8d 100644
--- a/arch/arm/mach-omap2/pm44xx.c
+++ b/arch/arm/mach-omap2/pm44xx.c
@@ -118,4 +118,25 @@ static int __init omap4_pm_init(void)
 err2:
 	return ret;
 }
+
+static void __exit omap4_pm_exit(void)
+{
+	struct power_state *pwrst;
+
+	if (!cpu_is_omap44xx())
+		return;
+
+	omap_pm_suspend_set_ops(NULL);
+
+	list_for_each_entry(pwrst, &pwrst_list, node) {
+		list_del(&pwrst->node);
+		kfree(pwrst);
+	}
+}
+
 late_initcall(omap4_pm_init);
+module_exit(omap4_pm_exit);
+
+MODULE_AUTHOR("Texas Instruments, Inc.");
+MODULE_DESCRIPTION("OMAP4 PM");
+MODULE_LICENSE("GPL");
-- 
1.7.4.1


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

* [PATCH 12/13] OMAP2+: PM: export functions and variables to PM modules
  2011-05-18 17:32 [RFC/PATCH 00/13] OMAP2+: PM: isolate PM code in modules jean.pihet
                   ` (10 preceding siblings ...)
  2011-05-18 17:32 ` [PATCH 11/13] OMAP2+: PM: implement modules insertion and removal code jean.pihet
@ 2011-05-18 17:32 ` jean.pihet
  2011-05-19  8:32   ` Santosh Shilimkar
  2011-05-18 17:32 ` [PATCH 13/13] OMAP2+: PM: build PM functionality as modules jean.pihet
  2011-05-31  8:02 ` [RFC/PATCH 00/13] OMAP2+: PM: isolate PM code in modules Tony Lindgren
  13 siblings, 1 reply; 27+ messages in thread
From: jean.pihet @ 2011-05-18 17:32 UTC (permalink / raw)
  To: linux-omap

From: Jean Pihet <j-pihet@ti.com>

Addition of EXPORT_SYMBOL for functions and variables used by
the code in PM modules.

Signed-off-by: Jean Pihet <j-pihet@ti.com>
---
 arch/arm/kernel/setup.c            |    1 +
 arch/arm/kernel/smp_tlb.c          |    2 ++
 arch/arm/mach-omap2/clockdomain.c  |    7 +++++++
 arch/arm/mach-omap2/cm2xxx_3xxx.c  |    7 +++++++
 arch/arm/mach-omap2/control.c      |   13 +++++++++++++
 arch/arm/mach-omap2/gpmc.c         |    2 ++
 arch/arm/mach-omap2/id.c           |    1 +
 arch/arm/mach-omap2/irq.c          |    7 +++++++
 arch/arm/mach-omap2/pm-debug.c     |    1 +
 arch/arm/mach-omap2/pm.c           |    9 +++++++++
 arch/arm/mach-omap2/pm34xx.c       |    3 +++
 arch/arm/mach-omap2/powerdomain.c  |   16 ++++++++++++++++
 arch/arm/mach-omap2/prm2xxx_3xxx.c |    6 ++++++
 arch/arm/mach-omap2/sdrc.c         |    2 ++
 arch/arm/mach-omap2/serial.c       |    5 +++++
 arch/arm/mach-omap2/timer-gp.c     |    1 +
 arch/arm/plat-omap/common.c        |    1 +
 arch/arm/plat-omap/dma.c           |    3 +++
 arch/arm/plat-omap/gpio.c          |    4 ++++
 arch/arm/plat-omap/omap-pm-noop.c  |    2 ++
 arch/arm/plat-omap/omap_device.c   |    1 +
 arch/arm/plat-omap/sram.c          |    2 ++
 22 files changed, 96 insertions(+), 0 deletions(-)

diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 006c1e8..73ad7ae 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -438,6 +438,7 @@ void cpu_init(void)
 	      PLC (PSR_F_BIT | PSR_I_BIT | SVC_MODE)
 	    : "r14");
 }
+EXPORT_SYMBOL(cpu_init);
 
 static struct machine_desc * __init setup_machine(unsigned int nr)
 {
diff --git a/arch/arm/kernel/smp_tlb.c b/arch/arm/kernel/smp_tlb.c
index 7dcb352..2cfdefa 100644
--- a/arch/arm/kernel/smp_tlb.c
+++ b/arch/arm/kernel/smp_tlb.c
@@ -9,6 +9,7 @@
  */
 #include <linux/preempt.h>
 #include <linux/smp.h>
+#include <linux/module.h>
 
 #include <asm/smp_plat.h>
 #include <asm/tlbflush.h>
@@ -83,6 +84,7 @@ void flush_tlb_all(void)
 	else
 		local_flush_tlb_all();
 }
+EXPORT_SYMBOL(flush_tlb_all);
 
 void flush_tlb_mm(struct mm_struct *mm)
 {
diff --git a/arch/arm/mach-omap2/clockdomain.c b/arch/arm/mach-omap2/clockdomain.c
index 6cb6c03..fd38dd3 100644
--- a/arch/arm/mach-omap2/clockdomain.c
+++ b/arch/arm/mach-omap2/clockdomain.c
@@ -331,6 +331,7 @@ struct clockdomain *clkdm_lookup(const char *name)
 
 	return clkdm;
 }
+EXPORT_SYMBOL(clkdm_lookup);
 
 /**
  * clkdm_for_each - call function on each registered clockdomain
@@ -363,6 +364,7 @@ int clkdm_for_each(int (*fn)(struct clockdomain *clkdm, void *user),
 
 	return ret;
 }
+EXPORT_SYMBOL(clkdm_for_each);
 
 
 /**
@@ -379,6 +381,7 @@ struct powerdomain *clkdm_get_pwrdm(struct clockdomain *clkdm)
 
 	return clkdm->pwrdm.ptr;
 }
+EXPORT_SYMBOL(clkdm_get_pwrdm);
 
 
 /* Hardware clockdomain control */
@@ -425,6 +428,7 @@ int clkdm_add_wkdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2)
 
 	return ret;
 }
+EXPORT_SYMBOL(clkdm_add_wkdep);
 
 /**
  * clkdm_del_wkdep - remove a wakeup dependency from clkdm2 to clkdm1
@@ -706,6 +710,7 @@ int clkdm_sleep(struct clockdomain *clkdm)
 
 	return arch_clkdm->clkdm_sleep(clkdm);
 }
+EXPORT_SYMBOL(clkdm_sleep);
 
 /**
  * clkdm_wakeup - force clockdomain wakeup transition
@@ -765,6 +770,7 @@ void clkdm_allow_idle(struct clockdomain *clkdm)
 	arch_clkdm->clkdm_allow_idle(clkdm);
 	pwrdm_clkdm_state_switch(clkdm);
 }
+EXPORT_SYMBOL(clkdm_allow_idle);
 
 /**
  * clkdm_deny_idle - disable hwsup idle transitions for clkdm
@@ -794,6 +800,7 @@ void clkdm_deny_idle(struct clockdomain *clkdm)
 
 	arch_clkdm->clkdm_deny_idle(clkdm);
 }
+EXPORT_SYMBOL(clkdm_deny_idle);
 
 
 /* Clockdomain-to-clock framework interface code */
diff --git a/arch/arm/mach-omap2/cm2xxx_3xxx.c b/arch/arm/mach-omap2/cm2xxx_3xxx.c
index 38830d8..6516e30 100644
--- a/arch/arm/mach-omap2/cm2xxx_3xxx.c
+++ b/arch/arm/mach-omap2/cm2xxx_3xxx.c
@@ -41,11 +41,13 @@ u32 omap2_cm_read_mod_reg(s16 module, u16 idx)
 {
 	return __raw_readl(cm_base + module + idx);
 }
+EXPORT_SYMBOL(omap2_cm_read_mod_reg);
 
 void omap2_cm_write_mod_reg(u32 val, s16 module, u16 idx)
 {
 	__raw_writel(val, cm_base + module + idx);
 }
+EXPORT_SYMBOL(omap2_cm_write_mod_reg);
 
 /* Read-modify-write a register in a CM module. Caller must lock */
 u32 omap2_cm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx)
@@ -59,16 +61,19 @@ u32 omap2_cm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx)
 
 	return v;
 }
+EXPORT_SYMBOL(omap2_cm_rmw_mod_reg_bits);
 
 u32 omap2_cm_set_mod_reg_bits(u32 bits, s16 module, s16 idx)
 {
 	return omap2_cm_rmw_mod_reg_bits(bits, bits, module, idx);
 }
+EXPORT_SYMBOL(omap2_cm_set_mod_reg_bits);
 
 u32 omap2_cm_clear_mod_reg_bits(u32 bits, s16 module, s16 idx)
 {
 	return omap2_cm_rmw_mod_reg_bits(bits, 0x0, module, idx);
 }
+EXPORT_SYMBOL(omap2_cm_clear_mod_reg_bits);
 
 /*
  *
@@ -431,6 +436,7 @@ void omap3_cm_save_context(void)
 		omap2_cm_read_mod_reg(OMAP3430_CCR_MOD,
 				      OMAP3_CM_CLKOUT_CTRL_OFFSET);
 }
+EXPORT_SYMBOL(omap3_cm_save_context);
 
 void omap3_cm_restore_context(void)
 {
@@ -554,4 +560,5 @@ void omap3_cm_restore_context(void)
 	omap2_cm_write_mod_reg(cm_context.cm_clkout_ctrl, OMAP3430_CCR_MOD,
 			       OMAP3_CM_CLKOUT_CTRL_OFFSET);
 }
+EXPORT_SYMBOL(omap3_cm_restore_context);
 #endif
diff --git a/arch/arm/mach-omap2/control.c b/arch/arm/mach-omap2/control.c
index 23b83bd..b91aded 100644
--- a/arch/arm/mach-omap2/control.c
+++ b/arch/arm/mach-omap2/control.c
@@ -93,6 +93,7 @@ struct omap3_scratchpad_sdrc_block {
 };
 
 void *omap3_secure_ram_storage;
+EXPORT_SYMBOL(omap3_secure_ram_storage);
 
 /*
  * This is used to store ARM registers in SDRAM before attempting
@@ -101,6 +102,7 @@ void *omap3_secure_ram_storage;
  * during the restore path.
  */
 u32 omap3_arm_context[128];
+EXPORT_SYMBOL(omap3_arm_context);
 
 struct omap3_control_regs {
 	u32 sysconfig;
@@ -171,31 +173,37 @@ u8 omap_ctrl_readb(u16 offset)
 {
 	return __raw_readb(OMAP_CTRL_REGADDR(offset));
 }
+EXPORT_SYMBOL(omap_ctrl_readb);
 
 u16 omap_ctrl_readw(u16 offset)
 {
 	return __raw_readw(OMAP_CTRL_REGADDR(offset));
 }
+EXPORT_SYMBOL(omap_ctrl_readw);
 
 u32 omap_ctrl_readl(u16 offset)
 {
 	return __raw_readl(OMAP_CTRL_REGADDR(offset));
 }
+EXPORT_SYMBOL(omap_ctrl_readl);
 
 void omap_ctrl_writeb(u8 val, u16 offset)
 {
 	__raw_writeb(val, OMAP_CTRL_REGADDR(offset));
 }
+EXPORT_SYMBOL(omap_ctrl_writeb);
 
 void omap_ctrl_writew(u16 val, u16 offset)
 {
 	__raw_writew(val, OMAP_CTRL_REGADDR(offset));
 }
+EXPORT_SYMBOL(omap_ctrl_writew);
 
 void omap_ctrl_writel(u32 val, u16 offset)
 {
 	__raw_writel(val, OMAP_CTRL_REGADDR(offset));
 }
+EXPORT_SYMBOL(omap_ctrl_writel);
 
 /*
  * On OMAP4 control pad are not addressable from control
@@ -403,6 +411,7 @@ void omap3_save_scratchpad_contents(u32 public_restore_ptr,
 		scratchpad_contents.sdrc_block_offset +
 		sizeof(sdrc_block_contents), &arm_context_addr, 4);
 }
+EXPORT_SYMBOL(omap3_save_scratchpad_contents);
 
 void omap3_control_save_context(void)
 {
@@ -461,6 +470,7 @@ void omap3_control_save_context(void)
 		omap_ctrl_readl(OMAP343X_CONTROL_PADCONF_SYSNIRQ);
 	return;
 }
+EXPORT_SYMBOL(omap3_control_save_context);
 
 void omap3_control_restore_context(void)
 {
@@ -519,6 +529,7 @@ void omap3_control_restore_context(void)
 			 OMAP343X_CONTROL_PADCONF_SYSNIRQ);
 	return;
 }
+EXPORT_SYMBOL(omap3_control_restore_context);
 
 void omap3630_ctrl_disable_rta(void)
 {
@@ -526,6 +537,7 @@ void omap3630_ctrl_disable_rta(void)
 		return;
 	omap_ctrl_writel(OMAP36XX_RTA_DISABLE, OMAP36XX_CONTROL_MEM_RTA_CTRL);
 }
+EXPORT_SYMBOL(omap3630_ctrl_disable_rta);
 
 /**
  * omap3_ctrl_save_padconf - save padconf registers to scratchpad RAM
@@ -553,5 +565,6 @@ int omap3_ctrl_save_padconf(void)
 
 	return 0;
 }
+EXPORT_SYMBOL(omap3_ctrl_save_padconf);
 
 #endif /* CONFIG_ARCH_OMAP3 && CONFIG_PM */
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 130034b..55618bb 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -804,6 +804,7 @@ void omap3_gpmc_save_context(void)
 		}
 	}
 }
+EXPORT_SYMBOL(omap3_gpmc_save_context);
 
 void omap3_gpmc_restore_context(void)
 {
@@ -835,6 +836,7 @@ void omap3_gpmc_restore_context(void)
 		}
 	}
 }
+EXPORT_SYMBOL(omap3_gpmc_restore_context);
 #endif /* CONFIG_ARCH_OMAP3 */
 
 /**
diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c
index 2537090..62cbede 100644
--- a/arch/arm/mach-omap2/id.c
+++ b/arch/arm/mach-omap2/id.c
@@ -32,6 +32,7 @@ static struct omap_chip_id omap_chip;
 static unsigned int omap_revision;
 
 u32 omap3_features;
+EXPORT_SYMBOL(omap3_features);
 
 unsigned int omap_rev(void)
 {
diff --git a/arch/arm/mach-omap2/irq.c b/arch/arm/mach-omap2/irq.c
index 70528ea..5b52b5b 100644
--- a/arch/arm/mach-omap2/irq.c
+++ b/arch/arm/mach-omap2/irq.c
@@ -14,6 +14,7 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/module.h>
 #include <mach/hardware.h>
 #include <asm/mach/irq.h>
 
@@ -120,6 +121,7 @@ int omap_irq_pending(void)
 	}
 	return 0;
 }
+EXPORT_SYMBOL(omap_irq_pending);
 
 static __init void
 omap_alloc_gc(void __iomem *base, unsigned int irq_start, unsigned int num)
@@ -206,6 +208,7 @@ void omap_intc_save_context(void)
 				(0x20 * i));
 	}
 }
+EXPORT_SYMBOL(omap_intc_save_context);
 
 void omap_intc_restore_context(void)
 {
@@ -232,12 +235,14 @@ void omap_intc_restore_context(void)
 	}
 	/* MIRs are saved and restore with other PRCM registers */
 }
+EXPORT_SYMBOL(omap_intc_restore_context);
 
 void omap3_intc_suspend(void)
 {
 	/* A pending interrupt would prevent OMAP from entering suspend */
 	omap_ack_irq(0);
 }
+EXPORT_SYMBOL(omap3_intc_suspend);
 
 void omap3_intc_prepare_idle(void)
 {
@@ -247,10 +252,12 @@ void omap3_intc_prepare_idle(void)
 	 */
 	intc_bank_write_reg(0, &irq_banks[0], INTC_SYSCONFIG);
 }
+EXPORT_SYMBOL(omap3_intc_prepare_idle);
 
 void omap3_intc_resume_idle(void)
 {
 	/* Re-enable autoidle */
 	intc_bank_write_reg(1, &irq_banks[0], INTC_SYSCONFIG);
 }
+EXPORT_SYMBOL(omap3_intc_resume_idle);
 #endif /* CONFIG_ARCH_OMAP3 */
diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c
index 4e81e8d..fd93bc3 100644
--- a/arch/arm/mach-omap2/pm-debug.c
+++ b/arch/arm/mach-omap2/pm-debug.c
@@ -157,6 +157,7 @@ void omap2_pm_dump(int mode, int resume, unsigned int us)
 	for (i = 0; i < reg_count; i++)
 		printk(KERN_INFO "%-20s: 0x%08x\n", regs[i].name, regs[i].val);
 }
+EXPORT_SYMBOL(omap2_pm_dump);
 
 #ifdef CONFIG_DEBUG_FS
 #include <linux/debugfs.h>
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index ab69c5a..323870f 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -31,6 +31,7 @@
 static struct omap_device_pm_latency *pm_lats;
 #if defined(CONFIG_PM) && defined(CONFIG_CPU_IDLE)
 struct cpuidle_params *cpuidle_params_override_table;
+EXPORT_SYMBOL(cpuidle_params_override_table);
 #endif
 
 #ifdef CONFIG_PM_DEBUG
@@ -38,9 +39,16 @@ u32 enable_off_mode;
 EXPORT_SYMBOL(enable_off_mode);
 
 int omap2_pm_debug;
+EXPORT_SYMBOL(omap2_pm_debug);
+
 u32 sleep_while_idle;
+EXPORT_SYMBOL(sleep_while_idle);
+
 u32 wakeup_timer_seconds;
+EXPORT_SYMBOL(wakeup_timer_seconds);
+
 u32 wakeup_timer_milliseconds;
+EXPORT_SYMBOL(wakeup_timer_milliseconds);
 #endif
 
 static struct device *mpu_dev;
@@ -176,6 +184,7 @@ int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state)
 err:
 	return ret;
 }
+EXPORT_SYMBOL(omap_set_pwrdm_state);
 
 /*
  * This API is to be called during init to put the various voltage
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index dd36e6d..cd5530f 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -806,6 +806,7 @@ void omap3_pm_off_mode_enable(int enable)
 		omap_set_pwrdm_state(pwrst->pwrdm, pwrst->next_state);
 	}
 }
+EXPORT_SYMBOL(omap3_pm_off_mode_enable);
 
 int omap3_pm_get_suspend_state(struct powerdomain *pwrdm)
 {
@@ -817,6 +818,7 @@ int omap3_pm_get_suspend_state(struct powerdomain *pwrdm)
 	}
 	return -EINVAL;
 }
+EXPORT_SYMBOL(omap3_pm_get_suspend_state);
 
 int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state)
 {
@@ -830,6 +832,7 @@ int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state)
 	}
 	return -EINVAL;
 }
+EXPORT_SYMBOL(omap3_pm_set_suspend_state);
 
 static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
 {
diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
index 93a17c8..ec7d1b2 100644
--- a/arch/arm/mach-omap2/powerdomain.c
+++ b/arch/arm/mach-omap2/powerdomain.c
@@ -247,6 +247,7 @@ struct powerdomain *pwrdm_lookup(const char *name)
 
 	return pwrdm;
 }
+EXPORT_SYMBOL(pwrdm_lookup);
 
 /**
  * pwrdm_for_each - call function on each registered clockdomain
@@ -275,6 +276,7 @@ int pwrdm_for_each(int (*fn)(struct powerdomain *pwrdm, void *user),
 
 	return ret;
 }
+EXPORT_SYMBOL(pwrdm_for_each);
 
 /**
  * pwrdm_add_clkdm - add a clockdomain to a powerdomain
@@ -391,6 +393,7 @@ int pwrdm_for_each_clkdm(struct powerdomain *pwrdm,
 
 	return ret;
 }
+EXPORT_SYMBOL(pwrdm_for_each_clkdm);
 
 /**
  * pwrdm_get_mem_bank_count - get number of memory banks in this powerdomain
@@ -406,6 +409,7 @@ int pwrdm_get_mem_bank_count(struct powerdomain *pwrdm)
 
 	return pwrdm->banks;
 }
+EXPORT_SYMBOL(pwrdm_get_mem_bank_count);
 
 /**
  * pwrdm_set_next_pwrst - set next powerdomain power state
@@ -441,6 +445,7 @@ int pwrdm_set_next_pwrst(struct powerdomain *pwrdm, u8 pwrst)
 
 	return ret;
 }
+EXPORT_SYMBOL(pwrdm_set_next_pwrst);
 
 /**
  * pwrdm_read_next_pwrst - get next powerdomain power state
@@ -462,6 +467,7 @@ int pwrdm_read_next_pwrst(struct powerdomain *pwrdm)
 
 	return ret;
 }
+EXPORT_SYMBOL(pwrdm_read_next_pwrst);
 
 /**
  * pwrdm_read_pwrst - get current powerdomain power state
@@ -483,6 +489,7 @@ int pwrdm_read_pwrst(struct powerdomain *pwrdm)
 
 	return ret;
 }
+EXPORT_SYMBOL(pwrdm_read_pwrst);
 
 /**
  * pwrdm_read_prev_pwrst - get previous powerdomain power state
@@ -504,6 +511,7 @@ int pwrdm_read_prev_pwrst(struct powerdomain *pwrdm)
 
 	return ret;
 }
+EXPORT_SYMBOL(pwrdm_read_prev_pwrst);
 
 /**
  * pwrdm_set_logic_retst - set powerdomain logic power state upon retention
@@ -534,6 +542,7 @@ int pwrdm_set_logic_retst(struct powerdomain *pwrdm, u8 pwrst)
 
 	return ret;
 }
+EXPORT_SYMBOL(pwrdm_set_logic_retst);
 
 /**
  * pwrdm_set_mem_onst - set memory power state while powerdomain ON
@@ -609,6 +618,7 @@ int pwrdm_set_mem_retst(struct powerdomain *pwrdm, u8 bank, u8 pwrst)
 
 	return ret;
 }
+EXPORT_SYMBOL(pwrdm_set_mem_retst);
 
 /**
  * pwrdm_read_logic_pwrst - get current powerdomain logic retention power state
@@ -788,6 +798,7 @@ int pwrdm_clear_all_prev_pwrst(struct powerdomain *pwrdm)
 
 	return ret;
 }
+EXPORT_SYMBOL(pwrdm_clear_all_prev_pwrst);
 
 /**
  * pwrdm_enable_hdwr_sar - enable automatic hardware SAR for a pwrdm
@@ -818,6 +829,7 @@ int pwrdm_enable_hdwr_sar(struct powerdomain *pwrdm)
 
 	return ret;
 }
+EXPORT_SYMBOL(pwrdm_enable_hdwr_sar);
 
 /**
  * pwrdm_disable_hdwr_sar - disable automatic hardware SAR for a pwrdm
@@ -860,6 +872,7 @@ bool pwrdm_has_hdwr_sar(struct powerdomain *pwrdm)
 {
 	return (pwrdm && pwrdm->flags & PWRDM_HAS_HDWR_SAR) ? 1 : 0;
 }
+EXPORT_SYMBOL(pwrdm_has_hdwr_sar);
 
 /**
  * pwrdm_set_lowpwrstchange - Request a low power state change
@@ -917,6 +930,7 @@ int pwrdm_state_switch(struct powerdomain *pwrdm)
 {
 	return _pwrdm_state_switch(pwrdm, PWRDM_STATE_NOW);
 }
+EXPORT_SYMBOL(pwrdm_state_switch);
 
 int pwrdm_clkdm_state_switch(struct clockdomain *clkdm)
 {
@@ -933,12 +947,14 @@ int pwrdm_pre_transition(void)
 	pwrdm_for_each(_pwrdm_pre_transition_cb, NULL);
 	return 0;
 }
+EXPORT_SYMBOL(pwrdm_pre_transition);
 
 int pwrdm_post_transition(void)
 {
 	pwrdm_for_each(_pwrdm_post_transition_cb, NULL);
 	return 0;
 }
+EXPORT_SYMBOL(pwrdm_post_transition);
 
 /**
  * pwrdm_get_context_loss_count - get powerdomain's context loss count
diff --git a/arch/arm/mach-omap2/prm2xxx_3xxx.c b/arch/arm/mach-omap2/prm2xxx_3xxx.c
index 051213f..009f393 100644
--- a/arch/arm/mach-omap2/prm2xxx_3xxx.c
+++ b/arch/arm/mach-omap2/prm2xxx_3xxx.c
@@ -29,11 +29,13 @@ u32 omap2_prm_read_mod_reg(s16 module, u16 idx)
 {
 	return __raw_readl(prm_base + module + idx);
 }
+EXPORT_SYMBOL(omap2_prm_read_mod_reg);
 
 void omap2_prm_write_mod_reg(u32 val, s16 module, u16 idx)
 {
 	__raw_writel(val, prm_base + module + idx);
 }
+EXPORT_SYMBOL(omap2_prm_write_mod_reg);
 
 /* Read-modify-write a register in a PRM module. Caller must lock */
 u32 omap2_prm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx)
@@ -47,6 +49,7 @@ u32 omap2_prm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx)
 
 	return v;
 }
+EXPORT_SYMBOL(omap2_prm_rmw_mod_reg_bits);
 
 /* Read a PRM register, AND it, and shift the result down to bit 0 */
 u32 omap2_prm_read_mod_bits_shift(s16 domain, s16 idx, u32 mask)
@@ -59,16 +62,19 @@ u32 omap2_prm_read_mod_bits_shift(s16 domain, s16 idx, u32 mask)
 
 	return v;
 }
+EXPORT_SYMBOL(omap2_prm_read_mod_bits_shift);
 
 u32 omap2_prm_set_mod_reg_bits(u32 bits, s16 module, s16 idx)
 {
 	return omap2_prm_rmw_mod_reg_bits(bits, bits, module, idx);
 }
+EXPORT_SYMBOL(omap2_prm_set_mod_reg_bits);
 
 u32 omap2_prm_clear_mod_reg_bits(u32 bits, s16 module, s16 idx)
 {
 	return omap2_prm_rmw_mod_reg_bits(bits, 0x0, module, idx);
 }
+EXPORT_SYMBOL(omap2_prm_clear_mod_reg_bits);
 
 
 /**
diff --git a/arch/arm/mach-omap2/sdrc.c b/arch/arm/mach-omap2/sdrc.c
index da6f3a6..6096749 100644
--- a/arch/arm/mach-omap2/sdrc.c
+++ b/arch/arm/mach-omap2/sdrc.c
@@ -33,6 +33,7 @@
 static struct omap_sdrc_params *sdrc_init_params_cs0, *sdrc_init_params_cs1;
 
 void __iomem *omap2_sdrc_base;
+EXPORT_SYMBOL(omap2_sdrc_base);
 void __iomem *omap2_sms_base;
 
 struct omap2_sms_regs {
@@ -65,6 +66,7 @@ void omap2_sms_restore_context(void)
 {
 	sms_write_reg(sms_context.sms_sysconfig, SMS_SYSCONFIG);
 }
+EXPORT_SYMBOL(omap2_sms_restore_context);
 
 /**
  * omap2_sdrc_get_params - return SDRC register values for a given clock rate
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 1ac361b..cd0a7e9 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -400,6 +400,7 @@ void omap_uart_prepare_idle(int num)
 		}
 	}
 }
+EXPORT_SYMBOL(omap_uart_prepare_idle);
 
 void omap_uart_resume_idle(int num)
 {
@@ -424,6 +425,7 @@ void omap_uart_resume_idle(int num)
 		}
 	}
 }
+EXPORT_SYMBOL(omap_uart_resume_idle);
 
 void omap_uart_prepare_suspend(void)
 {
@@ -433,6 +435,7 @@ void omap_uart_prepare_suspend(void)
 		omap_uart_allow_sleep(uart);
 	}
 }
+EXPORT_SYMBOL(omap_uart_prepare_suspend);
 
 int omap_uart_can_sleep(void)
 {
@@ -454,6 +457,7 @@ int omap_uart_can_sleep(void)
 
 	return can_sleep;
 }
+EXPORT_SYMBOL(omap_uart_can_sleep);
 
 /**
  * omap_uart_interrupt()
@@ -571,6 +575,7 @@ void omap_uart_enable_irqs(int enable)
 		}
 	}
 }
+EXPORT_SYMBOL(omap_uart_enable_irqs);
 
 static ssize_t sleep_timeout_show(struct device *dev,
 				  struct device_attribute *attr,
diff --git a/arch/arm/mach-omap2/timer-gp.c b/arch/arm/mach-omap2/timer-gp.c
index 3b9cf85..d13656a 100644
--- a/arch/arm/mach-omap2/timer-gp.c
+++ b/arch/arm/mach-omap2/timer-gp.c
@@ -54,6 +54,7 @@ static struct clock_event_device clockevent_gpt;
 static u8 __initdata gptimer_id = 1;
 static u8 __initdata inited;
 struct omap_dm_timer *gptimer_wakeup;
+EXPORT_SYMBOL(gptimer_wakeup);
 
 static irqreturn_t omap2_gp_timer_interrupt(int irq, void *dev_id)
 {
diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
index d9f10a3..036235c 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -54,6 +54,7 @@ const void *__init __omap_get_config(u16 tag, size_t len, int nr)
 {
         return get_config(tag, len, nr, NULL);
 }
+EXPORT_SYMBOL(__omap_get_config);
 
 const void *__init omap_get_var_config(u16 tag, size_t *len)
 {
diff --git a/arch/arm/plat-omap/dma.c b/arch/arm/plat-omap/dma.c
index c22217c..7dd4150 100644
--- a/arch/arm/plat-omap/dma.c
+++ b/arch/arm/plat-omap/dma.c
@@ -1092,6 +1092,7 @@ int omap_dma_running(void)
 
 	return 0;
 }
+EXPORT_SYMBOL(omap_dma_running);
 
 /*
  * lch_queue DMA will start right after lch_head one is finished.
@@ -1945,6 +1946,7 @@ void omap_dma_global_context_save(void)
 		p->dma_read(OCP_SYSCONFIG, 0);
 	omap_dma_global_context.dma_gcr = p->dma_read(GCR, 0);
 }
+EXPORT_SYMBOL(omap_dma_global_context_save);
 
 void omap_dma_global_context_restore(void)
 {
@@ -1963,6 +1965,7 @@ void omap_dma_global_context_restore(void)
 		if (dma_chan[ch].dev_id != -1)
 			omap_clear_dma(ch);
 }
+EXPORT_SYMBOL(omap_dma_global_context_restore);
 
 static int __devinit omap_system_dma_probe(struct platform_device *pdev)
 {
diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c
index d2adcdd..8a7368f 100644
--- a/arch/arm/plat-omap/gpio.c
+++ b/arch/arm/plat-omap/gpio.c
@@ -1925,6 +1925,7 @@ void omap2_gpio_prepare_for_idle(int off_mode)
 	}
 	workaround_enabled = 1;
 }
+EXPORT_SYMBOL(omap2_gpio_prepare_for_idle);
 
 void omap2_gpio_resume_after_idle(void)
 {
@@ -2022,6 +2023,7 @@ void omap2_gpio_resume_after_idle(void)
 	}
 
 }
+EXPORT_SYMBOL(omap2_gpio_resume_after_idle);
 
 #endif
 
@@ -2056,6 +2058,7 @@ void omap_gpio_save_context(void)
 			__raw_readl(bank->base + OMAP24XX_GPIO_DATAOUT);
 	}
 }
+EXPORT_SYMBOL(omap_gpio_save_context);
 
 /* restore the required registers of bank 2-6 */
 void omap_gpio_restore_context(void)
@@ -2086,6 +2089,7 @@ void omap_gpio_restore_context(void)
 				bank->base + OMAP24XX_GPIO_DATAOUT);
 	}
 }
+EXPORT_SYMBOL(omap_gpio_restore_context);
 #endif
 
 static struct platform_driver omap_gpio_driver = {
diff --git a/arch/arm/plat-omap/omap-pm-noop.c b/arch/arm/plat-omap/omap-pm-noop.c
index b0471bb2..078d015 100644
--- a/arch/arm/plat-omap/omap-pm-noop.c
+++ b/arch/arm/plat-omap/omap-pm-noop.c
@@ -293,6 +293,7 @@ void omap_pm_enable_off_mode(void)
 {
 	off_mode_enabled = true;
 }
+EXPORT_SYMBOL(omap_pm_enable_off_mode);
 
 /**
  * omap_pm_disable_off_mode - notify OMAP PM that off-mode is disabled
@@ -304,6 +305,7 @@ void omap_pm_disable_off_mode(void)
 {
 	off_mode_enabled = false;
 }
+EXPORT_SYMBOL(omap_pm_disable_off_mode);
 
 /*
  * Device context loss tracking
diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c
index 9bbda9a..93e68ab 100644
--- a/arch/arm/plat-omap/omap_device.c
+++ b/arch/arm/plat-omap/omap_device.c
@@ -821,6 +821,7 @@ struct device omap_device_parent = {
 	.init_name	= "omap",
 	.parent         = &platform_bus,
 };
+EXPORT_SYMBOL(omap_device_parent);
 
 static int __init omap_device_init(void)
 {
diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
index f1a54bb..fa50c58 100644
--- a/arch/arm/plat-omap/sram.c
+++ b/arch/arm/plat-omap/sram.c
@@ -261,6 +261,7 @@ void *omap_sram_push_address(unsigned long size)
 
 	return (void *)omap_sram_ceil;
 }
+EXPORT_SYMBOL(omap_sram_push_address);
 
 #ifdef CONFIG_ARCH_OMAP1
 
@@ -391,6 +392,7 @@ void omap3_sram_restore_context(void)
 		omap_sram_push(omap3_sram_configure_core_dpll,
 			       omap3_sram_configure_core_dpll_sz);
 }
+EXPORT_SYMBOL(omap3_sram_restore_context);
 #endif /* CONFIG_PM */
 
 static int __init omap34xx_sram_init(void)
-- 
1.7.4.1


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

* [PATCH 13/13] OMAP2+: PM: build PM functionality as modules
  2011-05-18 17:32 [RFC/PATCH 00/13] OMAP2+: PM: isolate PM code in modules jean.pihet
                   ` (11 preceding siblings ...)
  2011-05-18 17:32 ` [PATCH 12/13] OMAP2+: PM: export functions and variables to PM modules jean.pihet
@ 2011-05-18 17:32 ` jean.pihet
  2011-05-31  8:02 ` [RFC/PATCH 00/13] OMAP2+: PM: isolate PM code in modules Tony Lindgren
  13 siblings, 0 replies; 27+ messages in thread
From: jean.pihet @ 2011-05-18 17:32 UTC (permalink / raw)
  To: linux-omap

From: Jean Pihet <j-pihet@ti.com>

A new config option CONFIG_OMAP_PM is defined. This option allows
for the whole OMAP2+ PM to completely enabled, disabled or be built
as modules.

The PM functionality is split into the following modules:
- omap_pm_debug
- omap2_pm
- omap3_pm
- omap4_pm

The following functionality is moved to the modules:
- platform specific PM core
- suspend
- cpuidle
- PM debug

The following functionality is needed at boot time and so is left
in the PM core code (i.e. not built as modules):
- PRCM
- clock domains
- power domains
- voltage domains
- hwmod
- smart reflex
- per-platform PRCM data
- per-platform clock data
- per-platform power domains data
- per-platform hwmod data
- per-platform OPP data

Signed-off-by: Jean Pihet <j-pihet@ti.com>
---
 arch/arm/mach-omap2/Makefile |   36 ++++++++++++++++++++++++++----------
 arch/arm/plat-omap/Kconfig   |    9 +++++++++
 2 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 0fe8a5b..29e0588 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -53,22 +53,38 @@ obj-$(CONFIG_ARCH_OMAP2)		+= sdrc2xxx.o
 # Power Management
 #  Includes core PM, powerdomain, clockdomain, smartreflex, voltagedomain, OPP
 ifeq ($(CONFIG_PM),y)
-obj-$(CONFIG_ARCH_OMAP2)		+= pm24xx.o
-obj-$(CONFIG_ARCH_OMAP2)		+= sleep24xx.o pm_bus.o
-obj-$(CONFIG_ARCH_OMAP3)		+= pm34xx.o sleep34xx.o \
-					   cpuidle34xx.o pm_bus.o
-obj-$(CONFIG_ARCH_OMAP4)		+= pm44xx.o pm_bus.o
-obj-$(CONFIG_PM_DEBUG)			+= pm-debug.o
+
+obj-y					+= pm_bus.o
+ifeq ($(CONFIG_PM_VERBOSE),y)
+CFLAGS_pm_bus.o				+= -DDEBUG
+endif
+
+ifeq ($(CONFIG_PM_DEBUG),y)
+obj-$(CONFIG_OMAP_PM)			+= omap_pm_debug.o
+omap_pm_debug-y				:= pm-debug.o
+endif
+
+ifeq ($(CONFIG_ARCH_OMAP2),y)
+obj-$(CONFIG_OMAP_PM)			+= omap2_pm.o
+omap2_pm-y				:= pm24xx.o sleep24xx.o
+endif
+
+ifeq ($(CONFIG_ARCH_OMAP3),y)
+obj-$(CONFIG_OMAP_PM)			+= omap3_pm.o
+omap3_pm-y				:= pm34xx.o sleep34xx.o cpuidle34xx.o
+endif
+
+ifeq ($(CONFIG_ARCH_OMAP4),y)
+obj-$(CONFIG_OMAP_PM)			+= omap4_pm.o
+omap4_pm-y				:= pm44xx.o
+endif
+
 obj-$(CONFIG_OMAP_SMARTREFLEX)          += sr_device.o smartreflex.o
 obj-$(CONFIG_OMAP_SMARTREFLEX_CLASS3)	+= smartreflex-class3.o
 
 AFLAGS_sleep24xx.o			:=-Wa,-march=armv6
 AFLAGS_sleep34xx.o			:=-Wa,-march=armv7-a$(plus_sec)
 
-ifeq ($(CONFIG_PM_VERBOSE),y)
-CFLAGS_pm_bus.o				+= -DDEBUG
-endif
-
 # OMAP voltage domains
 voltagedomain-common			:= voltage.o
 obj-$(CONFIG_ARCH_OMAP2)		+= $(voltagedomain-common)
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index cd5f993..28154db 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -204,6 +204,15 @@ config OMAP_SERIAL_WAKE
 	  to data on the serial RX line. This allows you to wake the
 	  system from serial console.
 
+config OMAP_PM
+	tristate "OMAP PM support"
+	depends on ARCH_OMAP2PLUS && PM
+	default y
+	help
+	  Select this option if you want to have OMAP2+ PM support enabled.
+	  Can also be set to 'm' for the whole OMAP2+ PM to be built
+	  as a module.
+
 choice
 	prompt "OMAP PM layer selection"
 	depends on ARCH_OMAP
-- 
1.7.4.1


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

* Re: [PATCH 08/13] OMAP2+: PM: provide the next timer event API to PM modules
  2011-05-18 17:32 ` [PATCH 08/13] OMAP2+: PM: provide the next timer event API to PM modules jean.pihet
@ 2011-05-19  7:59   ` Santosh Shilimkar
  2011-05-19 12:02     ` Jean Pihet
  2011-05-26 23:00   ` Kevin Hilman
  1 sibling, 1 reply; 27+ messages in thread
From: Santosh Shilimkar @ 2011-05-19  7:59 UTC (permalink / raw)
  To: jean.pihet; +Cc: linux-omap

Jean,

On 5/18/2011 11:02 PM, jean.pihet@newoldbits.com wrote:
> From: Jean Pihet<j-pihet@ti.com>
>
> Provide omap_pm_tick_nohz_get_sleep_length_us so that the code
> from the OMAP PM modules can use it.
>
> Signed-off-by: Jean Pihet<j-pihet@ti.com>
> ---
>   arch/arm/mach-omap2/pm-debug.c |    7 ++++---
>   arch/arm/mach-omap2/pm.c       |   15 +++++++++++++++
>   arch/arm/mach-omap2/pm.h       |   12 ++++++++----
>   3 files changed, 27 insertions(+), 7 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c
> index 0b896d4..24e5c31 100644
> --- a/arch/arm/mach-omap2/pm-debug.c
> +++ b/arch/arm/mach-omap2/pm-debug.c
> @@ -141,9 +141,10 @@ void omap2_pm_dump(int mode, int resume, unsigned int us)
>   	if (!resume)
>   #ifdef CONFIG_NO_HZ
>   		printk(KERN_INFO
> -		       "--- Going to %s %s (next timer after %u ms)\n", s1, s2,
> -		       jiffies_to_msecs(get_next_timer_interrupt(jiffies) -
> -					jiffies));
> +		       "--- Going to %s %s (next timer after %lu ms)\n", s1, s2,
> +		       DIV_ROUND_UP(omap_pm_tick_nohz_get_sleep_length_us(),
> +				    1000)
> +		      );
>   #else
>   		printk(KERN_INFO "--- Going to %s %s\n", s1, s2);
>   #endif
> diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
> index 37a4801..0c451e3 100644
> --- a/arch/arm/mach-omap2/pm.c
> +++ b/arch/arm/mach-omap2/pm.c
> @@ -14,6 +14,8 @@
>   #include<linux/io.h>
>   #include<linux/err.h>
>   #include<linux/opp.h>
> +#include<linux/hrtimer.h>
> +#include<linux/tick.h>
>
>   #include<plat/omap-pm.h>
>   #include<plat/omap_device.h>
> @@ -30,6 +32,7 @@ static struct omap_device_pm_latency *pm_lats;
>   struct cpuidle_params *cpuidle_params_override_table;
>   #endif
>
> +#ifdef CONFIG_PM_DEBUG
>   u32 enable_off_mode;
>   EXPORT_SYMBOL(enable_off_mode);
>
> @@ -37,6 +40,7 @@ int omap2_pm_debug;
>   u32 sleep_while_idle;
>   u32 wakeup_timer_seconds;
>   u32 wakeup_timer_milliseconds;
> +#endif
>
>   static struct device *mpu_dev;
>   static struct device *iva_dev;
> @@ -292,6 +296,7 @@ void omap3_pm_init_cpuidle(struct cpuidle_params *cpuidle_board_params)
>   }
>   #endif
>
> +#ifdef CONFIG_PM_DEBUG
>   void omap2_pm_wakeup_on_timer(u32 seconds, u32 milliseconds)
>   {
>   	u32 tick_rate, cycles;
> @@ -308,4 +313,14 @@ void omap2_pm_wakeup_on_timer(u32 seconds, u32 milliseconds)
>   		" (%d ticks at %d ticks/sec.)\n",
>   		seconds, milliseconds, cycles, tick_rate);
>   }
> +EXPORT_SYMBOL(omap2_pm_wakeup_on_timer);
> +#endif
> +
> +#ifdef CONFIG_NO_HZ
> +unsigned long omap_pm_tick_nohz_get_sleep_length_us(void)
> +{
> +	return ktime_to_us(tick_nohz_get_sleep_length());
> +}
> +EXPORT_SYMBOL(omap_pm_tick_nohz_get_sleep_length_us);
This wrapper seems to be un-necesssary. You can directly use
"ktime_to_us(tick_nohz_get_sleep_length())" instead.

Regards
Santosh

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

* Re: [PATCH 10/13] OMAP3: PM: export the v7_flush_dcache_all API to modules
  2011-05-18 17:32 ` [PATCH 10/13] OMAP3: PM: export the v7_flush_dcache_all API to modules jean.pihet
@ 2011-05-19  8:04   ` Santosh Shilimkar
  2011-05-25 12:21     ` Jean Pihet
  0 siblings, 1 reply; 27+ messages in thread
From: Santosh Shilimkar @ 2011-05-19  8:04 UTC (permalink / raw)
  To: jean.pihet; +Cc: linux-omap

On 5/18/2011 11:02 PM, jean.pihet@newoldbits.com wrote:
> From: Jean Pihet<j-pihet@ti.com>
>
> Provide the the assembly function v7_flush_dcache_all to the
> OMAP3 PM module, under CONFIG_CPU_V7.
> v7_flush_dcache_all is used by the low level sleep code.
>
> Signed-off-by: Jean Pihet<j-pihet@ti.com>
> ---
>   arch/arm/mach-omap2/pm.c |    4 ++++
>   arch/arm/mach-omap2/pm.h |    4 ++++
>   2 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
> index 2e43fd6..ab69c5a 100644
> --- a/arch/arm/mach-omap2/pm.c
> +++ b/arch/arm/mach-omap2/pm.c
> @@ -325,6 +325,10 @@ unsigned long omap_pm_tick_nohz_get_sleep_length_us(void)
>   EXPORT_SYMBOL(omap_pm_tick_nohz_get_sleep_length_us);
>   #endif
>
> +#ifdef CONFIG_CPU_V7
> +EXPORT_SYMBOL(v7_flush_dcache_all);
> +#endif
> +
You have already mentioned, this export is wrong and indeed it
is wrong. You can use "flush_cache_all()" instead here which will
pick the right asm function. The downside is it will invalidate
I cache as well but that's ok because it's get invalidated anyways
in wakeup path.

Regards
Santosh

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

* Re: [PATCH 12/13] OMAP2+: PM: export functions and variables to PM modules
  2011-05-18 17:32 ` [PATCH 12/13] OMAP2+: PM: export functions and variables to PM modules jean.pihet
@ 2011-05-19  8:32   ` Santosh Shilimkar
  0 siblings, 0 replies; 27+ messages in thread
From: Santosh Shilimkar @ 2011-05-19  8:32 UTC (permalink / raw)
  To: jean.pihet; +Cc: linux-omap

On 5/18/2011 11:02 PM, jean.pihet@newoldbits.com wrote:
> From: Jean Pihet<j-pihet@ti.com>
>
> Addition of EXPORT_SYMBOL for functions and variables used by
> the code in PM modules.
>
> Signed-off-by: Jean Pihet<j-pihet@ti.com>
> ---
>   arch/arm/kernel/setup.c            |    1 +
>   arch/arm/kernel/smp_tlb.c          |    2 ++
>   arch/arm/mach-omap2/clockdomain.c  |    7 +++++++
>   arch/arm/mach-omap2/cm2xxx_3xxx.c  |    7 +++++++
>   arch/arm/mach-omap2/control.c      |   13 +++++++++++++
>   arch/arm/mach-omap2/gpmc.c         |    2 ++
>   arch/arm/mach-omap2/id.c           |    1 +
>   arch/arm/mach-omap2/irq.c          |    7 +++++++
>   arch/arm/mach-omap2/pm-debug.c     |    1 +
>   arch/arm/mach-omap2/pm.c           |    9 +++++++++
>   arch/arm/mach-omap2/pm34xx.c       |    3 +++
>   arch/arm/mach-omap2/powerdomain.c  |   16 ++++++++++++++++
>   arch/arm/mach-omap2/prm2xxx_3xxx.c |    6 ++++++
>   arch/arm/mach-omap2/sdrc.c         |    2 ++
>   arch/arm/mach-omap2/serial.c       |    5 +++++
>   arch/arm/mach-omap2/timer-gp.c     |    1 +
>   arch/arm/plat-omap/common.c        |    1 +
>   arch/arm/plat-omap/dma.c           |    3 +++
>   arch/arm/plat-omap/gpio.c          |    4 ++++
>   arch/arm/plat-omap/omap-pm-noop.c  |    2 ++
>   arch/arm/plat-omap/omap_device.c   |    1 +
>   arch/arm/plat-omap/sram.c          |    2 ++
>   22 files changed, 96 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
> index 006c1e8..73ad7ae 100644
> --- a/arch/arm/kernel/setup.c
> +++ b/arch/arm/kernel/setup.c
> @@ -438,6 +438,7 @@ void cpu_init(void)
>   	      PLC (PSR_F_BIT | PSR_I_BIT | SVC_MODE)
>   	    : "r14");
>   }
> +EXPORT_SYMBOL(cpu_init);
>
LAK needs to be CC'd to approve this change.


>   static struct machine_desc * __init setup_machine(unsigned int nr)
>   {
> diff --git a/arch/arm/kernel/smp_tlb.c b/arch/arm/kernel/smp_tlb.c
> index 7dcb352..2cfdefa 100644
> --- a/arch/arm/kernel/smp_tlb.c
> +++ b/arch/arm/kernel/smp_tlb.c
> @@ -9,6 +9,7 @@
>    */
>   #include<linux/preempt.h>
>   #include<linux/smp.h>
> +#include<linux/module.h>
>
>   #include<asm/smp_plat.h>
>   #include<asm/tlbflush.h>
> @@ -83,6 +84,7 @@ void flush_tlb_all(void)
>   	else
>   		local_flush_tlb_all();
>   }
> +EXPORT_SYMBOL(flush_tlb_all);
>
This one too.

[....]

>
>   /* Clockdomain-to-clock framework interface code */
> diff --git a/arch/arm/mach-omap2/cm2xxx_3xxx.c b/arch/arm/mach-omap2/cm2xxx_3xxx.c
> index 38830d8..6516e30 100644
> --- a/arch/arm/mach-omap2/cm2xxx_3xxx.c
> +++ b/arch/arm/mach-omap2/cm2xxx_3xxx.c
> @@ -41,11 +41,13 @@ u32 omap2_cm_read_mod_reg(s16 module, u16 idx)
>   {
>   	return __raw_readl(cm_base + module + idx);
>   }
> +EXPORT_SYMBOL(omap2_cm_read_mod_reg);
>
>   void omap2_cm_write_mod_reg(u32 val, s16 module, u16 idx)
>   {
>   	__raw_writel(val, cm_base + module + idx);
>   }
> +EXPORT_SYMBOL(omap2_cm_write_mod_reg);

Above are too low level API's to be exported

>
>   /* Read-modify-write a register in a CM module. Caller must lock */
>   u32 omap2_cm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx)
> @@ -59,16 +61,19 @@ u32 omap2_cm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx)
>
>   	return v;
>   }
> +EXPORT_SYMBOL(omap2_cm_rmw_mod_reg_bits);
>
>   u32 omap2_cm_set_mod_reg_bits(u32 bits, s16 module, s16 idx)
>   {
>   	return omap2_cm_rmw_mod_reg_bits(bits, bits, module, idx);
>   }
> +EXPORT_SYMBOL(omap2_cm_set_mod_reg_bits);
>
>   u32 omap2_cm_clear_mod_reg_bits(u32 bits, s16 module, s16 idx)
>   {
>   	return omap2_cm_rmw_mod_reg_bits(bits, 0x0, module, idx);
>   }
> +EXPORT_SYMBOL(omap2_cm_clear_mod_reg_bits);
>
These too ..

>   /*
>    *
> @@ -431,6 +436,7 @@ void omap3_cm_save_context(void)
>   		omap2_cm_read_mod_reg(OMAP3430_CCR_MOD,
>   				      OMAP3_CM_CLKOUT_CTRL_OFFSET);
>   }
> +EXPORT_SYMBOL(omap3_cm_save_context);
>
>   void omap3_cm_restore_context(void)
>   {
> @@ -554,4 +560,5 @@ void omap3_cm_restore_context(void)
>   	omap2_cm_write_mod_reg(cm_context.cm_clkout_ctrl, OMAP3430_CCR_MOD,
>   			       OMAP3_CM_CLKOUT_CTRL_OFFSET);
>   }
> +EXPORT_SYMBOL(omap3_cm_restore_context);
>   #endif
> diff --git a/arch/arm/mach-omap2/control.c b/arch/arm/mach-omap2/control.c
> index 23b83bd..b91aded 100644
> --- a/arch/arm/mach-omap2/control.c
> +++ b/arch/arm/mach-omap2/control.c
> @@ -93,6 +93,7 @@ struct omap3_scratchpad_sdrc_block {
>   };
>
>   void *omap3_secure_ram_storage;
> +EXPORT_SYMBOL(omap3_secure_ram_storage);
>
Instead of exporting variable, a get_*_addr() accessory
fn is better.

>   /*
>    * This is used to store ARM registers in SDRAM before attempting
> @@ -101,6 +102,7 @@ void *omap3_secure_ram_storage;
>    * during the restore path.
>    */
>   u32 omap3_arm_context[128];
> +EXPORT_SYMBOL(omap3_arm_context);
>
ditto...

>   #endif /* CONFIG_ARCH_OMAP3&&  CONFIG_PM */
[...]

>   #endif /* CONFIG_ARCH_OMAP3 */
> diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c
> index 4e81e8d..fd93bc3 100644
> --- a/arch/arm/mach-omap2/pm-debug.c
> +++ b/arch/arm/mach-omap2/pm-debug.c
> @@ -157,6 +157,7 @@ void omap2_pm_dump(int mode, int resume, unsigned int us)
>   	for (i = 0; i<  reg_count; i++)
>   		printk(KERN_INFO "%-20s: 0x%08x\n", regs[i].name, regs[i].val);
>   }
> +EXPORT_SYMBOL(omap2_pm_dump);
>
>   #ifdef CONFIG_DEBUG_FS
>   #include<linux/debugfs.h>
> diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
> index ab69c5a..323870f 100644
> --- a/arch/arm/mach-omap2/pm.c
> +++ b/arch/arm/mach-omap2/pm.c
> @@ -31,6 +31,7 @@
>   static struct omap_device_pm_latency *pm_lats;
>   #if defined(CONFIG_PM)&&  defined(CONFIG_CPU_IDLE)
>   struct cpuidle_params *cpuidle_params_override_table;
> +EXPORT_SYMBOL(cpuidle_params_override_table);
>   #endif
>
>   #ifdef CONFIG_PM_DEBUG
> @@ -38,9 +39,16 @@ u32 enable_off_mode;
>   EXPORT_SYMBOL(enable_off_mode);
>
>   int omap2_pm_debug;
> +EXPORT_SYMBOL(omap2_pm_debug);
> +
>   u32 sleep_while_idle;
> +EXPORT_SYMBOL(sleep_while_idle);
> +
>   u32 wakeup_timer_seconds;
> +EXPORT_SYMBOL(wakeup_timer_seconds);
> +
>   u32 wakeup_timer_milliseconds;
> +EXPORT_SYMBOL(wakeup_timer_milliseconds);
>   #endif
>

All above can be clubbed in a structure and then
only that struct needs to be exported.

[...]

>    * pwrdm_get_context_loss_count - get powerdomain's context loss count
> diff --git a/arch/arm/mach-omap2/prm2xxx_3xxx.c b/arch/arm/mach-omap2/prm2xxx_3xxx.c
> index 051213f..009f393 100644
> --- a/arch/arm/mach-omap2/prm2xxx_3xxx.c
> +++ b/arch/arm/mach-omap2/prm2xxx_3xxx.c
> @@ -29,11 +29,13 @@ u32 omap2_prm_read_mod_reg(s16 module, u16 idx)
>   {
>   	return __raw_readl(prm_base + module + idx);
>   }
> +EXPORT_SYMBOL(omap2_prm_read_mod_reg);
>
>   void omap2_prm_write_mod_reg(u32 val, s16 module, u16 idx)
>   {
>   	__raw_writel(val, prm_base + module + idx);
>   }
> +EXPORT_SYMBOL(omap2_prm_write_mod_reg);
>
>   /* Read-modify-write a register in a PRM module. Caller must lock */
>   u32 omap2_prm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx)
> @@ -47,6 +49,7 @@ u32 omap2_prm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx)
>
>   	return v;
>   }
> +EXPORT_SYMBOL(omap2_prm_rmw_mod_reg_bits);
>
>   /* Read a PRM register, AND it, and shift the result down to bit 0 */
>   u32 omap2_prm_read_mod_bits_shift(s16 domain, s16 idx, u32 mask)
> @@ -59,16 +62,19 @@ u32 omap2_prm_read_mod_bits_shift(s16 domain, s16 idx, u32 mask)
>
>   	return v;
>   }
> +EXPORT_SYMBOL(omap2_prm_read_mod_bits_shift);
>
>   u32 omap2_prm_set_mod_reg_bits(u32 bits, s16 module, s16 idx)
>   {
>   	return omap2_prm_rmw_mod_reg_bits(bits, bits, module, idx);
>   }
> +EXPORT_SYMBOL(omap2_prm_set_mod_reg_bits);
>
>   u32 omap2_prm_clear_mod_reg_bits(u32 bits, s16 module, s16 idx)
>   {
>   	return omap2_prm_rmw_mod_reg_bits(bits, 0x0, module, idx);
>   }
> +EXPORT_SYMBOL(omap2_prm_clear_mod_reg_bits);
>
>
Too low level fn to be exported.

>   /**
> diff --git a/arch/arm/mach-omap2/sdrc.c b/arch/arm/mach-omap2/sdrc.c
> index da6f3a6..6096749 100644
> --- a/arch/arm/mach-omap2/sdrc.c
> +++ b/arch/arm/mach-omap2/sdrc.c
> @@ -33,6 +33,7 @@
>   static struct omap_sdrc_params *sdrc_init_params_cs0, *sdrc_init_params_cs1;
>
>   void __iomem *omap2_sdrc_base;
> +EXPORT_SYMBOL(omap2_sdrc_base);
>   void __iomem *omap2_sms_base;
>
get_*_addr() instead of variable export.

Overall this patch doesn't seems to be right.
We need a better way to do this instead of
exporting every small fn used by PM code.

Regards
Santosh

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

* Re: [PATCH 08/13] OMAP2+: PM: provide the next timer event API to PM modules
  2011-05-19  7:59   ` Santosh Shilimkar
@ 2011-05-19 12:02     ` Jean Pihet
  0 siblings, 0 replies; 27+ messages in thread
From: Jean Pihet @ 2011-05-19 12:02 UTC (permalink / raw)
  To: Santosh Shilimkar; +Cc: linux-omap

Hi Santosh,

On Thu, May 19, 2011 at 9:59 AM, Santosh Shilimkar
<santosh.shilimkar@ti.com> wrote:
> Jean,
>
> On 5/18/2011 11:02 PM, jean.pihet@newoldbits.com wrote:
>>
>> From: Jean Pihet<j-pihet@ti.com>
>>
>> Provide omap_pm_tick_nohz_get_sleep_length_us so that the code
>> from the OMAP PM modules can use it.
>>
>> Signed-off-by: Jean Pihet<j-pihet@ti.com>
>> ---
>>  arch/arm/mach-omap2/pm-debug.c |    7 ++++---
>>  arch/arm/mach-omap2/pm.c       |   15 +++++++++++++++
>>  arch/arm/mach-omap2/pm.h       |   12 ++++++++----
>>  3 files changed, 27 insertions(+), 7 deletions(-)
>>
>> diff --git a/arch/arm/mach-omap2/pm-debug.c
>> b/arch/arm/mach-omap2/pm-debug.c
>> index 0b896d4..24e5c31 100644
>> --- a/arch/arm/mach-omap2/pm-debug.c
>> +++ b/arch/arm/mach-omap2/pm-debug.c
>> @@ -141,9 +141,10 @@ void omap2_pm_dump(int mode, int resume, unsigned int
>> us)
>>        if (!resume)
>>  #ifdef CONFIG_NO_HZ
>>                printk(KERN_INFO
>> -                      "--- Going to %s %s (next timer after %u ms)\n",
>> s1, s2,
>> -                      jiffies_to_msecs(get_next_timer_interrupt(jiffies)
>> -
>> -                                       jiffies));
>> +                      "--- Going to %s %s (next timer after %lu ms)\n",
>> s1, s2,
>> +
>>  DIV_ROUND_UP(omap_pm_tick_nohz_get_sleep_length_us(),
>> +                                   1000)
>> +                     );
>>  #else
>>                printk(KERN_INFO "--- Going to %s %s\n", s1, s2);
>>  #endif
>> diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
>> index 37a4801..0c451e3 100644
>> --- a/arch/arm/mach-omap2/pm.c
>> +++ b/arch/arm/mach-omap2/pm.c
>> @@ -14,6 +14,8 @@
>>  #include<linux/io.h>
>>  #include<linux/err.h>
>>  #include<linux/opp.h>
>> +#include<linux/hrtimer.h>
>> +#include<linux/tick.h>
>>
>>  #include<plat/omap-pm.h>
>>  #include<plat/omap_device.h>
>> @@ -30,6 +32,7 @@ static struct omap_device_pm_latency *pm_lats;
>>  struct cpuidle_params *cpuidle_params_override_table;
>>  #endif
>>
>> +#ifdef CONFIG_PM_DEBUG
>>  u32 enable_off_mode;
>>  EXPORT_SYMBOL(enable_off_mode);
>>
>> @@ -37,6 +40,7 @@ int omap2_pm_debug;
>>  u32 sleep_while_idle;
>>  u32 wakeup_timer_seconds;
>>  u32 wakeup_timer_milliseconds;
>> +#endif
>>
>>  static struct device *mpu_dev;
>>  static struct device *iva_dev;
>> @@ -292,6 +296,7 @@ void omap3_pm_init_cpuidle(struct cpuidle_params
>> *cpuidle_board_params)
>>  }
>>  #endif
>>
>> +#ifdef CONFIG_PM_DEBUG
>>  void omap2_pm_wakeup_on_timer(u32 seconds, u32 milliseconds)
>>  {
>>        u32 tick_rate, cycles;
>> @@ -308,4 +313,14 @@ void omap2_pm_wakeup_on_timer(u32 seconds, u32
>> milliseconds)
>>                " (%d ticks at %d ticks/sec.)\n",
>>                seconds, milliseconds, cycles, tick_rate);
>>  }
>> +EXPORT_SYMBOL(omap2_pm_wakeup_on_timer);
>> +#endif
>> +
>> +#ifdef CONFIG_NO_HZ
>> +unsigned long omap_pm_tick_nohz_get_sleep_length_us(void)
>> +{
>> +       return ktime_to_us(tick_nohz_get_sleep_length());
>> +}
>> +EXPORT_SYMBOL(omap_pm_tick_nohz_get_sleep_length_us);
>
> This wrapper seems to be un-necesssary. You can directly use
> "ktime_to_us(tick_nohz_get_sleep_length())" instead.
No because tick_nohz_get_sleep_length is not exported to modules.

>
> Regards
> Santosh
>

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

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

* Re: [PATCH 10/13] OMAP3: PM: export the v7_flush_dcache_all API to modules
  2011-05-19  8:04   ` Santosh Shilimkar
@ 2011-05-25 12:21     ` Jean Pihet
  0 siblings, 0 replies; 27+ messages in thread
From: Jean Pihet @ 2011-05-25 12:21 UTC (permalink / raw)
  To: Santosh Shilimkar; +Cc: linux-omap

Hi Santosh,

On Thu, May 19, 2011 at 10:04 AM, Santosh Shilimkar
<santosh.shilimkar@ti.com> wrote:
> On 5/18/2011 11:02 PM, jean.pihet@newoldbits.com wrote:
>>
>> From: Jean Pihet<j-pihet@ti.com>
>>
>> Provide the the assembly function v7_flush_dcache_all to the
>> OMAP3 PM module, under CONFIG_CPU_V7.
>> v7_flush_dcache_all is used by the low level sleep code.
>>
>> Signed-off-by: Jean Pihet<j-pihet@ti.com>
>> ---
>>  arch/arm/mach-omap2/pm.c |    4 ++++
>>  arch/arm/mach-omap2/pm.h |    4 ++++
>>  2 files changed, 8 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
>> index 2e43fd6..ab69c5a 100644
>> --- a/arch/arm/mach-omap2/pm.c
>> +++ b/arch/arm/mach-omap2/pm.c
>> @@ -325,6 +325,10 @@ unsigned long
>> omap_pm_tick_nohz_get_sleep_length_us(void)
>>  EXPORT_SYMBOL(omap_pm_tick_nohz_get_sleep_length_us);
>>  #endif
>>
>> +#ifdef CONFIG_CPU_V7
>> +EXPORT_SYMBOL(v7_flush_dcache_all);
>> +#endif
>> +
>
> You have already mentioned, this export is wrong and indeed it
> is wrong. You can use "flush_cache_all()" instead here which will
> pick the right asm function.
I could not find a usable flush cache function that is exported for
use by the modules. I will re-submit the next version of the patches
and specifically ask about it on l-a-k ML as well.

>The downside is it will invalidate
> I cache as well but that's ok because it's get invalidated anyways
> in wakeup path.
That should be ok.

>
> Regards
> Santosh
>

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

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

* Re: [PATCH 03/13] OMAP2+: PM: clean up usage of SRAM functions
  2011-05-18 17:32 ` [PATCH 03/13] OMAP2+: PM: clean up usage of SRAM functions jean.pihet
@ 2011-05-26 20:34   ` Kevin Hilman
  0 siblings, 0 replies; 27+ messages in thread
From: Kevin Hilman @ 2011-05-26 20:34 UTC (permalink / raw)
  To: jean.pihet; +Cc: linux-omap

jean.pihet@newoldbits.com writes:

> From: Jean Pihet <j-pihet@ti.com>
>
> Clean-up SRAM functions usage to better isolate PM code, in order
> to allow it to be used as a module.

Could use some more description as to why this is needed. e.g. SRAM code
is built-in, but PM code pushed to SRAM is module, etc...

> Signed-off-by: Jean Pihet <j-pihet@ti.com>
> ---
>  arch/arm/mach-omap2/pm34xx.c |    1 +
>  arch/arm/plat-omap/sram.c    |    2 --
>  2 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
> index 0c5e3a4..74169a2 100644
> --- a/arch/arm/mach-omap2/pm34xx.c
> +++ b/arch/arm/mach-omap2/pm34xx.c
> @@ -456,6 +456,7 @@ void omap_sram_idle(void)
>  			omap3_core_restore_context();
>  			omap3_cm_restore_context();
>  			omap3_sram_restore_context();
> +			omap_push_sram_idle();
>  			omap2_sms_restore_context();
>  		}
>  		omap_uart_resume_idle(0);
> diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
> index a3f50b3..f1a54bb 100644
> --- a/arch/arm/plat-omap/sram.c
> +++ b/arch/arm/plat-omap/sram.c
> @@ -390,7 +390,6 @@ void omap3_sram_restore_context(void)
>  	_omap3_sram_configure_core_dpll =
>  		omap_sram_push(omap3_sram_configure_core_dpll,
>  			       omap3_sram_configure_core_dpll_sz);
> -	omap_push_sram_idle();

OK, this removal is replaced by the one above..

>  }
>  #endif /* CONFIG_PM */
>  
> @@ -399,7 +398,6 @@ static int __init omap34xx_sram_init(void)
>  	_omap3_sram_configure_core_dpll =
>  		omap_sram_push(omap3_sram_configure_core_dpll,
>  			       omap3_sram_configure_core_dpll_sz);
> -	omap_push_sram_idle();

what replaces this one, which happens at init time?

Looking closer at pm34xx, there's alrady a call in omap3_pm_init(), you
should make that clear in the changelog too, otherwise it's a red flag
to see two removals and only one addition.

Kevin

>  	return 0;
>  }
>  #else

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

* Re: [PATCH 07/13] OMAP2+: PM: move the powerdomains time stats to powerdomain code
  2011-05-18 17:32 ` [PATCH 07/13] OMAP2+: PM: move the powerdomains time stats to powerdomain code jean.pihet
@ 2011-05-26 20:45   ` Kevin Hilman
  0 siblings, 0 replies; 27+ messages in thread
From: Kevin Hilman @ 2011-05-26 20:45 UTC (permalink / raw)
  To: jean.pihet; +Cc: linux-omap, Paul Walmsley

jean.pihet@newoldbits.com writes:

> From: Jean Pihet <j-pihet@ti.com>
>
> Move the powerdomains time accounting code from in pm-debug to the
> powerdomain code. The pm-debug code only displays the information on
> request.
>
> This also cleans up the core PM code, in order to allow it to be used
> as a module.
>
> Signed-off-by: Jean Pihet <j-pihet@ti.com>

Acked-by: Kevin Hilman <khilman@ti.com>

This make sense to me, and probably can be merged separately from this
series, if Paul is OK with it.

Kevin

> ---
>  arch/arm/mach-omap2/pm-debug.c    |   26 +-------------------------
>  arch/arm/mach-omap2/pm.h          |    2 --
>  arch/arm/mach-omap2/powerdomain.c |   25 ++++++++++++++++++++++++-
>  arch/arm/mach-omap2/powerdomain.h |    3 +++
>  4 files changed, 28 insertions(+), 28 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c
> index 98cc9ee..0b896d4 100644
> --- a/arch/arm/mach-omap2/pm-debug.c
> +++ b/arch/arm/mach-omap2/pm-debug.c
> @@ -333,21 +333,6 @@ static const char pwrdm_state_names[][PWRDM_MAX_PWRSTS] = {
>  	"ON"
>  };
>  
> -void pm_dbg_update_time(struct powerdomain *pwrdm, int prev)
> -{
> -	s64 t;
> -
> -	if (!pm_dbg_init_done)
> -		return ;
> -
> -	/* Update timer for previous state */
> -	t = sched_clock();
> -
> -	pwrdm->state_timer[prev] += t - pwrdm->timer;
> -
> -	pwrdm->timer = t;
> -}
> -
>  static int clkdm_dbg_show_counter(struct clockdomain *clkdm, void *user)
>  {
>  	struct seq_file *s = (struct seq_file *)user;
> @@ -410,7 +395,7 @@ static int pwrdm_dbg_show_timer(struct powerdomain *pwrdm, void *user)
>  	seq_printf(s, "%s (%s)", pwrdm->name,
>  		pwrdm_state_names[pwrdm->state]);
>  
> -	for (i = 0; i < 4; i++)
> +	for (i = 0; i < PWRDM_MAX_PWRSTS; i++)
>  		seq_printf(s, ",%s:%lld", pwrdm_state_names[i],
>  			pwrdm->state_timer[i]);
>  
> @@ -517,17 +502,8 @@ DEFINE_SIMPLE_ATTRIBUTE(pwrdm_suspend_fops, pwrdm_suspend_get,
>  
>  static int __init pwrdms_setup(struct powerdomain *pwrdm, void *dir)
>  {
> -	int i;
> -	s64 t;
>  	struct dentry *d;
>  
> -	t = sched_clock();
> -
> -	for (i = 0; i < 4; i++)
> -		pwrdm->state_timer[i] = 0;
> -
> -	pwrdm->timer = t;
> -
>  	if (strncmp(pwrdm->name, "dpll", 4) == 0)
>  		return 0;
>  
> diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
> index f36f79c..03da7f8 100644
> --- a/arch/arm/mach-omap2/pm.h
> +++ b/arch/arm/mach-omap2/pm.h
> @@ -76,11 +76,9 @@ extern u32 sleep_while_idle;
>  #endif
>  
>  #if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)
> -extern void pm_dbg_update_time(struct powerdomain *pwrdm, int prev);
>  extern int pm_dbg_regset_save(int reg_set);
>  extern int pm_dbg_regset_init(int reg_set);
>  #else
> -#define pm_dbg_update_time(pwrdm, prev) do {} while (0);
>  #define pm_dbg_regset_save(reg_set) do {} while (0);
>  #define pm_dbg_regset_init(reg_set) do {} while (0);
>  #endif /* CONFIG_PM_DEBUG */
> diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
> index 9af0847..93a17c8 100644
> --- a/arch/arm/mach-omap2/powerdomain.c
> +++ b/arch/arm/mach-omap2/powerdomain.c
> @@ -19,6 +19,7 @@
>  #include <linux/list.h>
>  #include <linux/errno.h>
>  #include <linux/string.h>
> +#include <linux/sched.h>
>  #include <trace/events/power.h>
>  
>  #include "cm2xxx_3xxx.h"
> @@ -77,6 +78,7 @@ static struct powerdomain *_pwrdm_lookup(const char *name)
>  static int _pwrdm_register(struct powerdomain *pwrdm)
>  {
>  	int i;
> +	s64 t;
>  
>  	if (!pwrdm || !pwrdm->name)
>  		return -EINVAL;
> @@ -100,6 +102,12 @@ static int _pwrdm_register(struct powerdomain *pwrdm)
>  	for (i = 0; i < PWRDM_MAX_PWRSTS; i++)
>  		pwrdm->state_counter[i] = 0;
>  
> +	/* Initialize the powerdomain's state timing stats */
> +	t = sched_clock();
> +	for (i = 0; i < PWRDM_MAX_PWRSTS; i++)
> +		pwrdm->state_timer[i] = 0;
> +	pwrdm->timer = t;
> +
>  	pwrdm->ret_logic_off_counter = 0;
>  	for (i = 0; i < pwrdm->banks; i++)
>  		pwrdm->ret_mem_off_counter[i] = 0;
> @@ -171,7 +179,9 @@ static int _pwrdm_state_switch(struct powerdomain *pwrdm, int flag)
>  	if (state != prev)
>  		pwrdm->state_counter[state]++;
>  
> -	pm_dbg_update_time(pwrdm, prev);
> +#ifdef CONFIG_PM_DEBUG
> +	pwrdm_update_state_timer(pwrdm, prev);
> +#endif
>  
>  	pwrdm->state = state;
>  
> @@ -999,3 +1009,16 @@ bool pwrdm_can_ever_lose_context(struct powerdomain *pwrdm)
>  
>  	return 0;
>  }
> +
> +#ifdef CONFIG_PM_DEBUG
> +void pwrdm_update_state_timer(struct powerdomain *pwrdm, int prev)
> +{
> +	s64 t;
> +
> +	/* Update timer for previous state */
> +	t = sched_clock();
> +	pwrdm->state_timer[prev] += t - pwrdm->timer;
> +	pwrdm->timer = t;
> +}
> +#endif
> +
> diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h
> index d23d979..abda68d 100644
> --- a/arch/arm/mach-omap2/powerdomain.h
> +++ b/arch/arm/mach-omap2/powerdomain.h
> @@ -209,6 +209,9 @@ int pwrdm_post_transition(void);
>  int pwrdm_set_lowpwrstchange(struct powerdomain *pwrdm);
>  u32 pwrdm_get_context_loss_count(struct powerdomain *pwrdm);
>  bool pwrdm_can_ever_lose_context(struct powerdomain *pwrdm);
> +#ifdef CONFIG_PM_DEBUG
> +void pwrdm_update_state_timer(struct powerdomain *pwrdm, int prev);
> +#endif
>  
>  extern void omap2xxx_powerdomains_init(void);
>  extern void omap3xxx_powerdomains_init(void);

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

* Re: [PATCH 08/13] OMAP2+: PM: provide the next timer event API to PM modules
  2011-05-18 17:32 ` [PATCH 08/13] OMAP2+: PM: provide the next timer event API to PM modules jean.pihet
  2011-05-19  7:59   ` Santosh Shilimkar
@ 2011-05-26 23:00   ` Kevin Hilman
  2011-05-27  7:44     ` Jean Pihet
  1 sibling, 1 reply; 27+ messages in thread
From: Kevin Hilman @ 2011-05-26 23:00 UTC (permalink / raw)
  To: jean.pihet; +Cc: linux-omap

jean.pihet@newoldbits.com writes:

> From: Jean Pihet <j-pihet@ti.com>
>
> Provide omap_pm_tick_nohz_get_sleep_length_us so that the code
> from the OMAP PM modules can use it.
>
> Signed-off-by: Jean Pihet <j-pihet@ti.com>

This patch is doing more than mentioned in the changelog.

> ---
>  arch/arm/mach-omap2/pm-debug.c |    7 ++++---
>  arch/arm/mach-omap2/pm.c       |   15 +++++++++++++++
>  arch/arm/mach-omap2/pm.h       |   12 ++++++++----
>  3 files changed, 27 insertions(+), 7 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c
> index 0b896d4..24e5c31 100644
> --- a/arch/arm/mach-omap2/pm-debug.c
> +++ b/arch/arm/mach-omap2/pm-debug.c
> @@ -141,9 +141,10 @@ void omap2_pm_dump(int mode, int resume, unsigned int us)
>  	if (!resume)
>  #ifdef CONFIG_NO_HZ
>  		printk(KERN_INFO
> -		       "--- Going to %s %s (next timer after %u ms)\n", s1, s2,
> -		       jiffies_to_msecs(get_next_timer_interrupt(jiffies) -
> -					jiffies));
> +		       "--- Going to %s %s (next timer after %lu ms)\n", s1, s2,
> +		       DIV_ROUND_UP(omap_pm_tick_nohz_get_sleep_length_us(),
> +				    1000)
> +		      );
>  #else
>  		printk(KERN_INFO "--- Going to %s %s\n", s1, s2);
>  #endif
> diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
> index 37a4801..0c451e3 100644
> --- a/arch/arm/mach-omap2/pm.c
> +++ b/arch/arm/mach-omap2/pm.c
> @@ -14,6 +14,8 @@
>  #include <linux/io.h>
>  #include <linux/err.h>
>  #include <linux/opp.h>
> +#include <linux/hrtimer.h>
> +#include <linux/tick.h>
>  
>  #include <plat/omap-pm.h>
>  #include <plat/omap_device.h>
> @@ -30,6 +32,7 @@ static struct omap_device_pm_latency *pm_lats;
>  struct cpuidle_params *cpuidle_params_override_table;
>  #endif
>  
> +#ifdef CONFIG_PM_DEBUG
>  u32 enable_off_mode;
>  EXPORT_SYMBOL(enable_off_mode);
>  
> @@ -37,6 +40,7 @@ int omap2_pm_debug;
>  u32 sleep_while_idle;
>  u32 wakeup_timer_seconds;
>  u32 wakeup_timer_milliseconds;
> +#endif
>  
>  static struct device *mpu_dev;
>  static struct device *iva_dev;
> @@ -292,6 +296,7 @@ void omap3_pm_init_cpuidle(struct cpuidle_params *cpuidle_board_params)
>  }
>  #endif
>  
> +#ifdef CONFIG_PM_DEBUG
>  void omap2_pm_wakeup_on_timer(u32 seconds, u32 milliseconds)
>  {
>  	u32 tick_rate, cycles;
> @@ -308,4 +313,14 @@ void omap2_pm_wakeup_on_timer(u32 seconds, u32 milliseconds)
>  		" (%d ticks at %d ticks/sec.)\n",
>  		seconds, milliseconds, cycles, tick_rate);
>  }
> +EXPORT_SYMBOL(omap2_pm_wakeup_on_timer);

This doesn't seem related to $SUBJECT

> +#endif
> +
> +#ifdef CONFIG_NO_HZ
> +unsigned long omap_pm_tick_nohz_get_sleep_length_us(void)
> +{
> +	return ktime_to_us(tick_nohz_get_sleep_length());
> +}
> +EXPORT_SYMBOL(omap_pm_tick_nohz_get_sleep_length_us);
> +#endif

Usage of this is OMAP2-specific and needed for this very old, debug-only
interface.  I was inspired by some of what you did in this series, and
will attempt to make your life easier by just removing this code all
together.  I just posted a series for that.

>  
> diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
> index 03da7f8..70eb80e 100644
> --- a/arch/arm/mach-omap2/pm.h
> +++ b/arch/arm/mach-omap2/pm.h
> @@ -68,11 +68,15 @@ extern int omap2_pm_debug;
>  extern u32 enable_off_mode;
>  extern u32 sleep_while_idle;
>  #else
> -#define omap2_pm_dump(mode, resume, us)		do {} while (0);
> +#define omap2_pm_dump(mode, resume, us)			do {} while (0);
>  #define omap2_pm_wakeup_on_timer(seconds, milliseconds)	do {} while (0);
> -#define omap2_pm_debug				0
> -#define enable_off_mode 0
> -#define sleep_while_idle 0
> +#define omap2_pm_debug					0
> +#define enable_off_mode					0
> +#define sleep_while_idle				0
> +#endif

Unrelated whitespace changes.

> +#ifdef CONFIG_NO_HZ
> +extern unsigned long omap_pm_tick_nohz_get_sleep_length_us(void);
>  #endif
>  
>  #if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)

Kevin

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

* Re: [PATCH 09/13] OMAP2+: PM: export suspend_set_ops to PM modules
  2011-05-18 17:32 ` [PATCH 09/13] OMAP2+: PM: export suspend_set_ops " jean.pihet
@ 2011-05-26 23:09   ` Kevin Hilman
  2011-05-27  7:48     ` Jean Pihet
  0 siblings, 1 reply; 27+ messages in thread
From: Kevin Hilman @ 2011-05-26 23:09 UTC (permalink / raw)
  To: jean.pihet; +Cc: linux-omap

jean.pihet@newoldbits.com writes:

> From: Jean Pihet <j-pihet@ti.com>
>
> Export the suspend_set_ops API as omap_pm_suspend_set_ops in the pm
> generic code, under CONFIG_SUSPEND.
>
> Note -hack warning-: since the 'suspend_valid_only_mem' function is
> not exported to modules, fill the 'valid' field value of
> 'struct platform_suspend_ops' in the common code.
>
> Signed-off-by: Jean Pihet <j-pihet@ti.com>

Can you try the patch below instead?    If that works, I'll submit to
Rafael/linux-pm.

Kevin

>From d3aca6317f5f92a5fd4fbaf1d039232c83cac4f4 Mon Sep 17 00:00:00 2001
From: Kevin Hilman <khilman@ti.com>
Date: Thu, 26 May 2011 16:10:13 -0700
Subject: [PATCH] PM: export suspend_set_ops, suspend_valid_only_mem

Some platforms wish to implement their PM core code as modules.  To
do so, these functions need to be exported for modules.

Reported-by: Jean Pihet <j-pihet@ti.com>
Signed-off-by: Kevin Hilman <khilman@ti.com>
---
 kernel/power/suspend.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 6275970..eca495d 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -44,6 +44,7 @@ void suspend_set_ops(const struct platform_suspend_ops *ops)
 	suspend_ops = ops;
 	mutex_unlock(&pm_mutex);
 }
+EXPORT_SYMBOL(suspend_set_ops);
 
 bool valid_state(suspend_state_t state)
 {
@@ -65,6 +66,7 @@ int suspend_valid_only_mem(suspend_state_t state)
 {
 	return state == PM_SUSPEND_MEM;
 }
+EXPORT_SYMBOL(suspend_valid_only_mem);
 
 static int suspend_test(int level)
 {
-- 
1.7.4


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

* Re: [PATCH 08/13] OMAP2+: PM: provide the next timer event API to PM modules
  2011-05-26 23:00   ` Kevin Hilman
@ 2011-05-27  7:44     ` Jean Pihet
  0 siblings, 0 replies; 27+ messages in thread
From: Jean Pihet @ 2011-05-27  7:44 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: linux-omap

On Fri, May 27, 2011 at 1:00 AM, Kevin Hilman <khilman@ti.com> wrote:
> jean.pihet@newoldbits.com writes:
>
>> From: Jean Pihet <j-pihet@ti.com>
>>
>> Provide omap_pm_tick_nohz_get_sleep_length_us so that the code
>> from the OMAP PM modules can use it.
>>
>> Signed-off-by: Jean Pihet <j-pihet@ti.com>
>
> This patch is doing more than mentioned in the changelog.
Agree, there is a bit of clean-up/rework as well. Will re-organize.

...

>
>> +#endif
>> +
>> +#ifdef CONFIG_NO_HZ
>> +unsigned long omap_pm_tick_nohz_get_sleep_length_us(void)
>> +{
>> +     return ktime_to_us(tick_nohz_get_sleep_length());
>> +}
>> +EXPORT_SYMBOL(omap_pm_tick_nohz_get_sleep_length_us);
>> +#endif
>
> Usage of this is OMAP2-specific and needed for this very old, debug-only
> interface.
>  I was inspired by some of what you did in this series, and
> will attempt to make your life easier by just removing this code all
> together.  I just posted a series for that.
Only OMAP2 uses it currently but I think it is useful to have the time
to next tick available for debug purpose.
BTW this change implements it in a more generic way:
tick_nohz_get_sleep_length is generic and also used by e.g. cpuidle to
determine the next state to enter.

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

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

* Re: [PATCH 09/13] OMAP2+: PM: export suspend_set_ops to PM modules
  2011-05-26 23:09   ` Kevin Hilman
@ 2011-05-27  7:48     ` Jean Pihet
  2011-05-28  0:28       ` Kevin Hilman
  0 siblings, 1 reply; 27+ messages in thread
From: Jean Pihet @ 2011-05-27  7:48 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: linux-omap

On Fri, May 27, 2011 at 1:09 AM, Kevin Hilman <khilman@ti.com> wrote:
> jean.pihet@newoldbits.com writes:
>
>> From: Jean Pihet <j-pihet@ti.com>
>>
>> Export the suspend_set_ops API as omap_pm_suspend_set_ops in the pm
>> generic code, under CONFIG_SUSPEND.
>>
>> Note -hack warning-: since the 'suspend_valid_only_mem' function is
>> not exported to modules, fill the 'valid' field value of
>> 'struct platform_suspend_ops' in the common code.
>>
>> Signed-off-by: Jean Pihet <j-pihet@ti.com>
>
> Can you try the patch below instead?    If that works, I'll submit to
> Rafael/linux-pm.
This is much cleaner! We need this pushed upstream.

Acked-by: Jean Pihet <j-pihet@ti.com>

Thanks,
Jean

>
> Kevin
>
> From d3aca6317f5f92a5fd4fbaf1d039232c83cac4f4 Mon Sep 17 00:00:00 2001
> From: Kevin Hilman <khilman@ti.com>
> Date: Thu, 26 May 2011 16:10:13 -0700
> Subject: [PATCH] PM: export suspend_set_ops, suspend_valid_only_mem
>
> Some platforms wish to implement their PM core code as modules.  To
> do so, these functions need to be exported for modules.
>
> Reported-by: Jean Pihet <j-pihet@ti.com>
> Signed-off-by: Kevin Hilman <khilman@ti.com>
> ---
>  kernel/power/suspend.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
> index 6275970..eca495d 100644
> --- a/kernel/power/suspend.c
> +++ b/kernel/power/suspend.c
> @@ -44,6 +44,7 @@ void suspend_set_ops(const struct platform_suspend_ops *ops)
>        suspend_ops = ops;
>        mutex_unlock(&pm_mutex);
>  }
> +EXPORT_SYMBOL(suspend_set_ops);
>
>  bool valid_state(suspend_state_t state)
>  {
> @@ -65,6 +66,7 @@ int suspend_valid_only_mem(suspend_state_t state)
>  {
>        return state == PM_SUSPEND_MEM;
>  }
> +EXPORT_SYMBOL(suspend_valid_only_mem);
>
>  static int suspend_test(int level)
>  {
> --
> 1.7.4
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 09/13] OMAP2+: PM: export suspend_set_ops to PM modules
  2011-05-27  7:48     ` Jean Pihet
@ 2011-05-28  0:28       ` Kevin Hilman
  0 siblings, 0 replies; 27+ messages in thread
From: Kevin Hilman @ 2011-05-28  0:28 UTC (permalink / raw)
  To: Jean Pihet; +Cc: linux-omap

Jean Pihet <jean.pihet@newoldbits.com> writes:

> On Fri, May 27, 2011 at 1:09 AM, Kevin Hilman <khilman@ti.com> wrote:
>> jean.pihet@newoldbits.com writes:
>>
>>> From: Jean Pihet <j-pihet@ti.com>
>>>
>>> Export the suspend_set_ops API as omap_pm_suspend_set_ops in the pm
>>> generic code, under CONFIG_SUSPEND.
>>>
>>> Note -hack warning-: since the 'suspend_valid_only_mem' function is
>>> not exported to modules, fill the 'valid' field value of
>>> 'struct platform_suspend_ops' in the common code.
>>>
>>> Signed-off-by: Jean Pihet <j-pihet@ti.com>
>>
>> Can you try the patch below instead?    If that works, I'll submit to
>> Rafael/linux-pm.
> This is much cleaner! We need this pushed upstream.

OK, thanks.  I just sent it to linux-pm.

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

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

* Re: [RFC/PATCH 00/13] OMAP2+: PM: isolate PM code in modules
  2011-05-18 17:32 [RFC/PATCH 00/13] OMAP2+: PM: isolate PM code in modules jean.pihet
                   ` (12 preceding siblings ...)
  2011-05-18 17:32 ` [PATCH 13/13] OMAP2+: PM: build PM functionality as modules jean.pihet
@ 2011-05-31  8:02 ` Tony Lindgren
  13 siblings, 0 replies; 27+ messages in thread
From: Tony Lindgren @ 2011-05-31  8:02 UTC (permalink / raw)
  To: jean.pihet; +Cc: linux-omap

* jean.pihet@newoldbits.com <jean.pihet@newoldbits.com> [110518 10:28]:
> From: Jean Pihet <j-pihet@ti.com>
> 
> First attempt at isolation of the OMAP2+ PM code
> 
> RFC quality code but successfully tested on board as a proof
> of concept
> 
> 1) provide PM functionality as modules
> 
> To allow for the PM functionality to be built and used as modules a
> clean-up and isolation task first has been performed ('spaghetti
> unwinding') because there are a lot of cross calls between various parts
> of the PM code (core, platform specific, cpuidle ...).

Glad to see this happening! :)
 
> 2) Addition of EXPORT_SYMBOL for functions and variables used by
> the code in PM modules. Lots of (too many?) symbols need to exported
> to the PM modules.

Ideally these would all be Linux generic of course..

Anyways, please also consider what all modules could be moved to
live under drivers/pm or similar. I'd assume a lot of this can
be done in a generic way.

Regards,

Tony

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

end of thread, other threads:[~2011-05-31  8:02 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-18 17:32 [RFC/PATCH 00/13] OMAP2+: PM: isolate PM code in modules jean.pihet
2011-05-18 17:32 ` [PATCH 01/13] perf: export power_start and power_end tracepoints jean.pihet
2011-05-18 17:32 ` [PATCH 02/13] OMAP2+: PM: isolate PM code jean.pihet
2011-05-18 17:32 ` [PATCH 03/13] OMAP2+: PM: clean up usage of SRAM functions jean.pihet
2011-05-26 20:34   ` Kevin Hilman
2011-05-18 17:32 ` [PATCH 04/13] OMAP2+: cpuidle: register the board specific C-states table jean.pihet
2011-05-18 17:32 ` [PATCH 05/13] OMAP2+: PM: move common code from pm-debug.c to pm.c jean.pihet
2011-05-18 17:32 ` [PATCH 06/13] OMAP2+: PM: isolate the scratchpad save function from the PM code jean.pihet
2011-05-18 17:32 ` [PATCH 07/13] OMAP2+: PM: move the powerdomains time stats to powerdomain code jean.pihet
2011-05-26 20:45   ` Kevin Hilman
2011-05-18 17:32 ` [PATCH 08/13] OMAP2+: PM: provide the next timer event API to PM modules jean.pihet
2011-05-19  7:59   ` Santosh Shilimkar
2011-05-19 12:02     ` Jean Pihet
2011-05-26 23:00   ` Kevin Hilman
2011-05-27  7:44     ` Jean Pihet
2011-05-18 17:32 ` [PATCH 09/13] OMAP2+: PM: export suspend_set_ops " jean.pihet
2011-05-26 23:09   ` Kevin Hilman
2011-05-27  7:48     ` Jean Pihet
2011-05-28  0:28       ` Kevin Hilman
2011-05-18 17:32 ` [PATCH 10/13] OMAP3: PM: export the v7_flush_dcache_all API to modules jean.pihet
2011-05-19  8:04   ` Santosh Shilimkar
2011-05-25 12:21     ` Jean Pihet
2011-05-18 17:32 ` [PATCH 11/13] OMAP2+: PM: implement modules insertion and removal code jean.pihet
2011-05-18 17:32 ` [PATCH 12/13] OMAP2+: PM: export functions and variables to PM modules jean.pihet
2011-05-19  8:32   ` Santosh Shilimkar
2011-05-18 17:32 ` [PATCH 13/13] OMAP2+: PM: build PM functionality as modules jean.pihet
2011-05-31  8:02 ` [RFC/PATCH 00/13] OMAP2+: PM: isolate PM code in modules Tony Lindgren

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