]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/macintosh/via-pmu.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6
[linux-2.6-omap-h63xx.git] / drivers / macintosh / via-pmu.c
index 8f98257e6a152f9560345609771c23ca2287b5f7..ebec663d5d3708d74a8197ddfe16e7e761e71c87 100644 (file)
@@ -197,12 +197,6 @@ static int proc_read_options(char *page, char **start, off_t off,
 static int proc_write_options(struct file *file, const char __user *buffer,
                        unsigned long count, void *data);
 
-#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_PPC32)
-static void powerbook_sleep_init_3400(void);
-#else
-#define powerbook_sleep_init_3400()    do { } while (0)
-#endif
-
 #ifdef CONFIG_ADB
 struct adb_driver via_pmu_driver = {
        "PMU",
@@ -450,10 +444,6 @@ static int __init via_pmu_start(void)
                pmu_poll();
        } while (pmu_state != idle);
 
-       /* Do allocations and ioremaps that will be needed for sleep */
-       if (pmu_kind == PMU_OHARE_BASED)
-               powerbook_sleep_init_3400();
-
        return 0;
 }
 
@@ -1758,8 +1748,6 @@ restore_via_state(void)
        out_8(&via[IER], IER_SET | SR_INT | CB1_INT);
 }
 
-extern void pmu_backlight_set_sleep(int sleep);
-
 #define        GRACKLE_PM      (1<<7)
 #define GRACKLE_DOZE   (1<<5)
 #define        GRACKLE_NAP     (1<<4)
@@ -2168,34 +2156,11 @@ pmu_release(struct inode *inode, struct file *file)
 }
 
 #if defined(CONFIG_SUSPEND) && defined(CONFIG_PPC32)
-/*
- * overrides the weak arch_suspend_disable_irqs in kernel/power/main.c
- *
- * XXX: Once Scott Wood's patch is merged, this needs to use the ppc_md
- *     hooks that patch adds!
- */
-void arch_suspend_disable_irqs(void)
+static void pmac_suspend_disable_irqs(void)
 {
-#ifdef CONFIG_PMAC_BACKLIGHT
-       /* Tell backlight code not to muck around with the chip anymore */
-       pmu_backlight_set_sleep(1);
-#endif
-
        /* Call platform functions marked "on sleep" */
        pmac_pfunc_i2c_suspend();
        pmac_pfunc_base_suspend();
-
-       /* Stop preemption */
-       preempt_disable();
-
-       /* Make sure the decrementer won't interrupt us */
-       asm volatile("mtdec %0" : : "r" (0x7fffffff));
-       /* Make sure any pending DEC interrupt occurring while we did
-        * the above didn't re-enable the DEC */
-       mb();
-       asm volatile("mtdec %0" : : "r" (0x7fffffff));
-
-       local_irq_disable();
 }
 
 static int powerbook_sleep(suspend_state_t state)
@@ -2236,33 +2201,16 @@ static int powerbook_sleep(suspend_state_t state)
 
        mdelay(100);
 
-#ifdef CONFIG_PMAC_BACKLIGHT
-       /* Tell backlight code it can use the chip again */
-       pmu_backlight_set_sleep(0);
-#endif
-
        return 0;
 }
 
-/*
- * overrides the weak arch_suspend_enable_irqs in kernel/power/main.c
- *
- * XXX: Once Scott Wood's patch is merged, this needs to use the ppc_md
- *     hooks that patch adds!
- */
-void arch_suspend_enable_irqs(void)
+static void pmac_suspend_enable_irqs(void)
 {
        /* Force a poll of ADB interrupts */
        adb_int_pending = 1;
        via_pmu_interrupt(0, NULL);
 
-       /* Restart jiffies & scheduling */
-       wakeup_decrementer();
-
-       /* Re-enable local CPU interrupts */
-       local_irq_enable();
        mdelay(10);
-       preempt_enable();
 
        /* Call platform functions marked "on wake" */
        pmac_pfunc_base_resume();
@@ -2282,6 +2230,10 @@ static struct platform_suspend_ops pmu_pm_ops = {
 
 static int register_pmu_pm_ops(void)
 {
+       if (pmu_kind == PMU_OHARE_BASED)
+               powerbook_sleep_init_3400();
+       ppc_md.suspend_disable_irqs = pmac_suspend_disable_irqs;
+       ppc_md.suspend_enable_irqs = pmac_suspend_enable_irqs;
        suspend_set_ops(&pmu_pm_ops);
 
        return 0;
@@ -2493,10 +2445,15 @@ static int pmu_sys_suspend(struct sys_device *sysdev, pm_message_t state)
        if (state.event != PM_EVENT_SUSPEND || pmu_sys_suspended)
                return 0;
 
-       /* Suspend PMU event interrupts */
+       /* Suspend PMU event interrupts */\
        pmu_suspend();
-
        pmu_sys_suspended = 1;
+
+#ifdef CONFIG_PMAC_BACKLIGHT
+       /* Tell backlight code not to muck around with the chip anymore */
+       pmu_backlight_set_sleep(1);
+#endif
+
        return 0;
 }
 
@@ -2511,9 +2468,12 @@ static int pmu_sys_resume(struct sys_device *sysdev)
        pmu_request(&req, NULL, 2, PMU_SYSTEM_READY, 2);
        pmu_wait_complete(&req);
 
+#ifdef CONFIG_PMAC_BACKLIGHT
+       /* Tell backlight code it can use the chip again */
+       pmu_backlight_set_sleep(0);
+#endif
        /* Resume PMU event interrupts */
        pmu_resume();
-
        pmu_sys_suspended = 0;
 
        return 0;
@@ -2522,7 +2482,7 @@ static int pmu_sys_resume(struct sys_device *sysdev)
 #endif /* CONFIG_SUSPEND && CONFIG_PPC32 */
 
 static struct sysdev_class pmu_sysclass = {
-       set_kset_name("pmu"),
+       .name = "pmu",
 };
 
 static struct sys_device device_pmu = {