From: jean.pihet@newoldbits.com
To: linux-omap@vger.kernel.org
Subject: [PATCH 11/13] OMAP2+: PM: implement modules insertion and removal code
Date: Wed, 18 May 2011 19:32:28 +0200 [thread overview]
Message-ID: <1305739950-11695-12-git-send-email-j-pihet@ti.com> (raw)
In-Reply-To: <1305739950-11695-1-git-send-email-j-pihet@ti.com>
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
next prev parent reply other threads:[~2011-05-18 17:33 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` jean.pihet [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1305739950-11695-12-git-send-email-j-pihet@ti.com \
--to=jean.pihet@newoldbits.com \
--cc=linux-omap@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).