Merge branches 'release', 'button-sysfs', 'misc', 'mismatch', 'randconfig' and 'toshi...
[sfrench/cifs-2.6.git] / arch / arm / mach-omap1 / pm.c
index 2e68be607295ef3cf7174bea05c03cb5f1e90466..e6c64e10b7ec283b46d58177e2a7e5d7b9984b0a 100644 (file)
  * 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#include <linux/pm.h>
+#include <linux/suspend.h>
 #include <linux/sched.h>
 #include <linux/proc_fs.h>
-#include <linux/pm.h>
 #include <linux/interrupt.h>
 #include <linux/sysfs.h>
 #include <linux/module.h>
@@ -58,7 +57,6 @@
 #include <asm/arch/pm.h>
 #include <asm/arch/mux.h>
 #include <asm/arch/dma.h>
-#include <asm/arch/dsp_common.h>
 #include <asm/arch/dmtimer.h>
 
 static unsigned int arm_sleep_save[ARM_SLEEP_SAVE_SIZE];
@@ -68,16 +66,18 @@ static unsigned int mpui730_sleep_save[MPUI730_SLEEP_SAVE_SIZE];
 static unsigned int mpui1510_sleep_save[MPUI1510_SLEEP_SAVE_SIZE];
 static unsigned int mpui1610_sleep_save[MPUI1610_SLEEP_SAVE_SIZE];
 
+#ifdef CONFIG_OMAP_32K_TIMER
+
 static unsigned short enable_dyn_sleep = 1;
 
-static ssize_t omap_pm_sleep_while_idle_show(struct kset *kset, char *buf)
+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 omap_pm_sleep_while_idle_store(struct kset *kset,
-                                             const char * buf,
-                                             size_t n)
+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 ||
@@ -89,17 +89,11 @@ static ssize_t omap_pm_sleep_while_idle_store(struct kset *kset,
        return n;
 }
 
-static struct subsys_attribute sleep_while_idle_attr = {
-       .attr   = {
-               .name = __stringify(sleep_while_idle),
-               .mode = 0644,
-       },
-       .show   = omap_pm_sleep_while_idle_show,
-       .store  = omap_pm_sleep_while_idle_store,
-};
+static struct kobj_attribute sleep_while_idle_attr =
+       __ATTR(sleep_while_idle, 0644, idle_show, idle_store);
+
+#endif
 
-extern struct kset power_subsys;
-static void (*omap_sram_idle)(void) = NULL;
 static void (*omap_sram_suspend)(unsigned long r0, unsigned long r1) = NULL;
 
 /*
@@ -112,9 +106,7 @@ void omap_pm_idle(void)
 {
        extern __u32 arm_idlect1_mask;
        __u32 use_idlect1 = arm_idlect1_mask;
-#ifndef CONFIG_OMAP_MPU_TIMER
-       int do_sleep;
-#endif
+       int do_sleep = 0;
 
        local_irq_disable();
        local_fiq_disable();
@@ -136,7 +128,6 @@ void omap_pm_idle(void)
        use_idlect1 = use_idlect1 & ~(1 << 9);
 #else
 
-       do_sleep = 0;
        while (enable_dyn_sleep) {
 
 #ifdef CONFIG_CBUS_TAHVO_USB
@@ -149,15 +140,14 @@ void omap_pm_idle(void)
                break;
        }
 
+#endif
+
 #ifdef CONFIG_OMAP_DM_TIMER
        use_idlect1 = omap_dm_timer_modify_idlect_mask(use_idlect1);
 #endif
 
-       if (omap_dma_running()) {
+       if (omap_dma_running())
                use_idlect1 &= ~(1 << 6);
-               if (omap_lcd_dma_ext_running())
-                       use_idlect1 &= ~(1 << 12);
-       }
 
        /* We should be able to remove the do_sleep variable and multiple
         * tests above as soon as drivers, timer and DMA code have been fixed.
@@ -179,7 +169,6 @@ void omap_pm_idle(void)
        }
        omap_sram_suspend(omap_readl(ARM_IDLECT1),
                          omap_readl(ARM_IDLECT2));
-#endif
 
        local_fiq_enable();
        local_irq_enable();
@@ -603,27 +592,15 @@ static void (*saved_idle)(void) = NULL;
 
 /*
  *     omap_pm_prepare - Do preliminary suspend work.
- *     @state:         suspend state we're entering.
  *
  */
-static int omap_pm_prepare(suspend_state_t state)
+static int omap_pm_prepare(void)
 {
-       int error = 0;
-
        /* We cannot sleep in idle until we have resumed */
        saved_idle = pm_idle;
        pm_idle = NULL;
 
-       switch (state)
-       {
-       case PM_SUSPEND_STANDBY:
-       case PM_SUSPEND_MEM:
-               break;
-       default:
-               return -EINVAL;
-       }
-
-       return error;
+       return 0;
 }
 
 
@@ -651,20 +628,18 @@ static int omap_pm_enter(suspend_state_t state)
 
 /**
  *     omap_pm_finish - Finish up suspend sequence.
- *     @state:         State we're coming out of.
  *
  *     This is called after we wake back up (or if entering the sleep state
  *     failed).
  */
 
-static int omap_pm_finish(suspend_state_t state)
+static void omap_pm_finish(void)
 {
        pm_idle = saved_idle;
-       return 0;
 }
 
 
-static irqreturn_t  omap_wakeup_interrupt(int irq, void *dev)
+static irqreturn_t omap_wakeup_interrupt(int irq, void *dev)
 {
        return IRQ_HANDLED;
 }
@@ -677,16 +652,19 @@ static struct irqaction omap_wakeup_irq = {
 
 
 
-static struct pm_ops omap_pm_ops ={
+static struct platform_suspend_ops omap_pm_ops ={
        .prepare        = omap_pm_prepare,
        .enter          = omap_pm_enter,
        .finish         = omap_pm_finish,
-       .valid          = pm_valid_only_mem,
+       .valid          = suspend_valid_only_mem,
 };
 
 static int __init omap_pm_init(void)
 {
+
+#ifdef CONFIG_OMAP_32K_TIMER
        int error;
+#endif
 
        printk("Power Management for TI OMAP.\n");
 
@@ -696,23 +674,17 @@ static int __init omap_pm_init(void)
         * memory the MPU can see when it wakes up.
         */
        if (cpu_is_omap730()) {
-               omap_sram_idle = omap_sram_push(omap730_idle_loop_suspend,
-                                               omap730_idle_loop_suspend_sz);
                omap_sram_suspend = omap_sram_push(omap730_cpu_suspend,
                                                   omap730_cpu_suspend_sz);
        } else if (cpu_is_omap15xx()) {
-               omap_sram_idle = omap_sram_push(omap1510_idle_loop_suspend,
-                                               omap1510_idle_loop_suspend_sz);
                omap_sram_suspend = omap_sram_push(omap1510_cpu_suspend,
                                                   omap1510_cpu_suspend_sz);
        } else if (cpu_is_omap16xx()) {
-               omap_sram_idle = omap_sram_push(omap1610_idle_loop_suspend,
-                                               omap1610_idle_loop_suspend_sz);
                omap_sram_suspend = omap_sram_push(omap1610_cpu_suspend,
                                                   omap1610_cpu_suspend_sz);
        }
 
-       if (omap_sram_idle == NULL || omap_sram_suspend == NULL) {
+       if (omap_sram_suspend == NULL) {
                printk(KERN_ERR "PM not initialized: Missing SRAM support\n");
                return -ENODEV;
        }
@@ -738,15 +710,17 @@ static int __init omap_pm_init(void)
        else if (cpu_is_omap16xx())
                omap_writel(OMAP1610_IDLECT3_VAL, OMAP1610_IDLECT3);
 
-       pm_set_ops(&omap_pm_ops);
+       suspend_set_ops(&omap_pm_ops);
 
 #if defined(DEBUG) && defined(CONFIG_PROC_FS)
        omap_pm_init_proc();
 #endif
 
-       error = subsys_create_file(&power_subsys, &sleep_while_idle_attr);
+#ifdef CONFIG_OMAP_32K_TIMER
+       error = sysfs_create_file(power_kobj, &sleep_while_idle_attr.attr);
        if (error)
-               printk(KERN_ERR "subsys_create_file failed: %d\n", error);
+               printk(KERN_ERR "sysfs_create_file failed: %d\n", error);
+#endif
 
        if (cpu_is_omap16xx()) {
                /* configure LOW_PWR pin */