]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
PM: Add pm.c file for omap2 and omap3 common code
authorJouni Hogander <jouni.hogander@nokia.com>
Fri, 16 May 2008 10:57:12 +0000 (13:57 +0300)
committerTony Lindgren <tony@atomide.com>
Tue, 20 May 2008 17:30:05 +0000 (10:30 -0700)
Add pm.c file for common code and move handling of sleep_while_idle
attribute and sleep_block to it.

Signed-off-by: Jouni Hogander <jouni.hogander@nokia.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/mach-omap2/Makefile
arch/arm/mach-omap2/pm.c [new file with mode: 0644]
arch/arm/mach-omap2/pm.h
arch/arm/mach-omap2/pm24xx.c

index 87815ced3cab6af931587364a0730e453a97d316..9ff50478d01e4d183d1cd37281b2293f2891dc1f 100644 (file)
@@ -12,6 +12,8 @@ obj-$(CONFIG_ARCH_OMAP2)              += sram24xx.o
 obj-$(CONFIG_ARCH_OMAP3)               += sram34xx.o
 
 # Power Management
+obj-$(CONFIG_PM) += pm.o
+
 ifeq ($(CONFIG_ARCH_OMAP2),y)
 obj-$(CONFIG_PM) += pm24xx.o sleep24xx.o
 endif
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
new file mode 100644 (file)
index 0000000..55ed75b
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * linux/arch/arm/mach-omap2/pm.c
+ *
+ * OMAP Power Management Common Routines
+ *
+ * Copyright (C) 2005 Texas Instruments, Inc.
+ * Copyright (C) 2006-2008 Nokia Corporation
+ *
+ * Written by:
+ * Richard Woodruff <r-woodruff2@ti.com>
+ * Tony Lindgren
+ * Juha Yrjola
+ * Amit Kucheria <amit.kucheria@nokia.com>
+ * Igor Stoppa <igor.stoppa@nokia.com>
+ * Jouni Hogander
+ *
+ * Based on pm.c for omap1
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/suspend.h>
+#include <linux/time.h>
+
+#include <asm/arch/cpu.h>
+#include <asm/mach/time.h>
+#include <asm/atomic.h>
+
+#include "pm.h"
+
+unsigned short enable_dyn_sleep;
+atomic_t sleep_block = ATOMIC_INIT(0);
+
+static ssize_t idle_show(struct kobject *kobj, struct kobj_attribute *attr,
+                        char *buf)
+{
+       return sprintf(buf, "%hu\n", enable_dyn_sleep);
+}
+
+static ssize_t idle_store(struct kobject *kobj, struct kobj_attribute *attr,
+                         const char *buf, size_t n)
+{
+       unsigned short value;
+       if (sscanf(buf, "%hu", &value) != 1 ||
+           (value != 0 && value != 1)) {
+               printk(KERN_ERR "idle_sleep_store: Invalid value\n");
+               return -EINVAL;
+       }
+       enable_dyn_sleep = value;
+       return n;
+}
+
+static struct kobj_attribute sleep_while_idle_attr =
+       __ATTR(sleep_while_idle, 0644, idle_show, idle_store);
+
+void omap2_block_sleep(void)
+{
+       atomic_inc(&sleep_block);
+}
+
+void omap2_allow_sleep(void)
+{
+       int i;
+
+       i = atomic_dec_return(&sleep_block);
+       BUG_ON(i < 0);
+}
+
+int __init omap_pm_init(void)
+{
+       int error = -1;
+
+       if (cpu_is_omap24xx())
+               error = omap2_pm_init();
+       if (error) {
+               printk(KERN_ERR "omap2_pm_init failed: %d\n", error);
+               return error;
+       }
+
+       /* disabled till drivers are fixed */
+       enable_dyn_sleep = 0;
+       error = sysfs_create_file(power_kobj, &sleep_while_idle_attr.attr);
+       if (error)
+               printk(KERN_ERR "sysfs_create_file failed: %d\n", error);
+
+       return error;
+}
+
+late_initcall(omap_pm_init);
index 541bf902398271a15320a9ce46d575a494c8bad0..15482ba7f49361e59688a71095d57af00632c326 100644 (file)
  * published by the Free Software Foundation.
  */
 
+extern int omap2_pm_init(void);
+extern unsigned short enable_dyn_sleep;
+extern atomic_t sleep_block;
+
 #ifdef CONFIG_PM_DEBUG
 extern u32 omap2_read_32k_sync_counter(void);
 extern void omap2_pm_dump(int mode, int resume, unsigned int us);
index 593f62947f64d32d75bf438e1afa4ff291b08f69..7bb654f14e7da2f8a0503e77ec6fb6ad1589f0fc 100644 (file)
@@ -31,7 +31,6 @@
 #include <linux/io.h>
 #include <linux/irq.h>
 
-#include <asm/atomic.h>
 #include <asm/mach/time.h>
 #include <asm/mach/irq.h>
 #include <asm/mach-types.h>
@@ -61,30 +60,6 @@ static void (*omap2_sram_idle)(void);
 static void (*omap2_sram_suspend)(void __iomem *dllctrl);
 static void (*saved_idle)(void);
 
-static unsigned short enable_dyn_sleep = 0; /* disabled till drivers are fixed */
-
-static ssize_t idle_show(struct kobject *kobj, struct kobj_attribute *attr,
-                        char *buf)
-{
-       return sprintf(buf, "%hu\n", enable_dyn_sleep);
-}
-
-static ssize_t idle_store(struct kobject *kobj, struct kobj_attribute *attr,
-                         const char *buf, size_t n)
-{
-       unsigned short value;
-       if (sscanf(buf, "%hu", &value) != 1 ||
-           (value != 0 && value != 1)) {
-               printk(KERN_ERR "idle_sleep_store: Invalid value\n");
-               return -EINVAL;
-       }
-       enable_dyn_sleep = value;
-       return n;
-}
-
-static struct kobj_attribute sleep_while_idle_attr =
-       __ATTR(sleep_while_idle, 0644, idle_show, idle_store);
-
 static struct clk *osc_ck, *emul_ck;
 
 static int omap2_fclks_active(void)
@@ -112,21 +87,6 @@ static int omap2_irq_pending(void)
        return 0;
 }
 
-static atomic_t sleep_block = ATOMIC_INIT(0);
-
-void omap2_block_sleep(void)
-{
-       atomic_inc(&sleep_block);
-}
-
-void omap2_allow_sleep(void)
-{
-       int i;
-
-       i = atomic_dec_return(&sleep_block);
-       BUG_ON(i < 0);
-}
-
 static void omap2_enter_full_retention(void)
 {
        u32 l, sleep_time = 0;
@@ -519,10 +479,9 @@ static void __init prcm_setup_regs(void)
                          WKUP_MOD, PM_WKEN);
 }
 
-static int __init omap2_pm_init(void)
+int __init omap2_pm_init(void)
 {
        u32 l;
-       int error;
 
        printk(KERN_INFO "Power Management for OMAP2 initializing\n");
        l = __raw_readl(OMAP24XX_PRCM_REVISION);
@@ -579,11 +538,5 @@ static int __init omap2_pm_init(void)
        suspend_set_ops(&omap_pm_ops);
        pm_idle = omap2_pm_idle;
 
-       error = sysfs_create_file(power_kobj, &sleep_while_idle_attr.attr);
-       if (error)
-               printk(KERN_ERR "sysfs_create_file failed: %d\n", error);
-
        return 0;
 }
-
-late_initcall(omap2_pm_init);