]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/arm/mach-omap1/pm.c
Merge with /home/tmlind/src/kernel/linux-2.6
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap1 / pm.c
index d483ac4f846ef4219845bf52868de6272dcbc13f..8ff232034871161d7073db531a04fae63a81081b 100644 (file)
@@ -1,5 +1,6 @@
+//kernel/linux-omap-fsample/arch/arm/mach-omap1/pm.c#3 - integrate change 4545 (text)
 /*
- * linux/arch/arm/plat-omap/pm.c
+ * linux/arch/arm/mach-omap1/pm.c
  *
  * OMAP Power Management Routines
  *
@@ -50,6 +51,7 @@
 #include <asm/mach/irq.h>
 #include <asm/mach-types.h>
 
+#include <asm/arch/cpu.h>
 #include <asm/arch/irqs.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/sram.h>
@@ -62,6 +64,7 @@
 #include <asm/arch/dmtimer.h>
 
 static unsigned int arm_sleep_save[ARM_SLEEP_SAVE_SIZE];
+static unsigned short dsp_sleep_save[DSP_SLEEP_SAVE_SIZE];
 static unsigned short ulpd_sleep_save[ULPD_SLEEP_SAVE_SIZE];
 static unsigned int mpui730_sleep_save[MPUI730_SLEEP_SAVE_SIZE];
 static unsigned int mpui1510_sleep_save[MPUI1510_SLEEP_SAVE_SIZE];
@@ -164,7 +167,7 @@ void omap_pm_idle(void)
        if ((use_idlect1 != ~0) || !do_sleep) {
 
                __u32 saved_idlect1 = omap_readl(ARM_IDLECT1);
-               if (cpu_is_omap1510())
+               if (cpu_is_omap15xx())
                        use_idlect1 &= OMAP1510_BIG_SLEEP_REQUEST;
                else
                        use_idlect1 &= OMAP1610_IDLECT1_SLEEP_VAL;
@@ -203,7 +206,7 @@ static void omap_pm_wakeup_setup(void)
        if (cpu_is_omap730())
                level1_wake = OMAP_IRQ_BIT(INT_730_GPIO_BANK1) |
                        OMAP_IRQ_BIT(INT_730_IH2_IRQ);
-       else if (cpu_is_omap1510())
+       else if (cpu_is_omap15xx())
                level1_wake = OMAP_IRQ_BIT(INT_GPIO_BANK1) |
                        OMAP_IRQ_BIT(INT_1510_IH2_IRQ);
        else if (cpu_is_omap16xx())
@@ -217,7 +220,7 @@ static void omap_pm_wakeup_setup(void)
                omap_writel(~(OMAP_IRQ_BIT(INT_730_WAKE_UP_REQ) |
                                OMAP_IRQ_BIT(INT_730_MPUIO_KEYPAD)),
                                OMAP_IH2_1_MIR);
-       } else if (cpu_is_omap1510()) {
+       } else if (cpu_is_omap15xx()) {
                level2_wake |= OMAP_IRQ_BIT(INT_KEYBOARD);
                omap_writel(~level2_wake,  OMAP_IH2_MIR);
        } else if (cpu_is_omap16xx()) {
@@ -233,9 +236,13 @@ static void omap_pm_wakeup_setup(void)
 
        /*  New IRQ agreement, recalculate in cascade order */
        omap_writel(1, OMAP_IH2_CONTROL);
-       omap_writel(1, OMAP_IH1_CONTROL);
+       omap_writel(1, OMAP_IH1_CONTROL);
 }
 
+#define EN_DSPCK       13      /* ARM_CKCTL */
+#define EN_APICK       6       /* ARM_IDLECT2 */
+#define DSP_EN         1       /* ARM_RSTCT1 */
+
 void omap_pm_suspend(void)
 {
        unsigned long arg0 = 0, arg1 = 0;
@@ -249,7 +256,8 @@ void omap_pm_suspend(void)
                tps65010_set_led(LED1, OFF);
        }
 
-       omap_writew(0xffff, ULPD_SOFT_DISABLE_REQ_REG);
+       if (!cpu_is_omap15xx())
+               omap_writew(0xffff, ULPD_SOFT_DISABLE_REQ_REG);
 
        /*
         * Step 1: turn off interrupts (FIXME: NOTE: already disabled)
@@ -266,7 +274,7 @@ void omap_pm_suspend(void)
         * We have to save and restore very little register state to
         * idle the omap.
          *
-        * Save interrupt, MPUI, ARM and UPLD control registers.
+        * Save interrupt, MPUI, ARM and UPLD control registers.
         */
 
        if (cpu_is_omap730()) {
@@ -279,7 +287,7 @@ void omap_pm_suspend(void)
                MPUI730_SAVE(EMIFS_CONFIG);
                MPUI730_SAVE(EMIFF_SDRAM_CONFIG);
 
-       } else if (cpu_is_omap1510()) {
+       } else if (cpu_is_omap15xx()) {
                MPUI1510_SAVE(OMAP_IH1_MIR);
                MPUI1510_SAVE(OMAP_IH2_MIR);
                MPUI1510_SAVE(MPUI_CTRL);
@@ -303,7 +311,7 @@ void omap_pm_suspend(void)
        ARM_SAVE(ARM_CKCTL);
        ARM_SAVE(ARM_IDLECT1);
        ARM_SAVE(ARM_IDLECT2);
-       if (!(cpu_is_omap1510()))
+       if (!(cpu_is_omap15xx()))
                ARM_SAVE(ARM_IDLECT3);
        ARM_SAVE(ARM_EWUPCT);
        ARM_SAVE(ARM_RSTCT1);
@@ -318,7 +326,21 @@ void omap_pm_suspend(void)
         * Step 4: OMAP DSP Shutdown
         */
 
-       omap_dsp_pm_suspend();
+       /* stop DSP */
+       omap_writew(omap_readw(ARM_RSTCT1) & ~(1 << DSP_EN), ARM_RSTCT1);
+
+               /* shut down dsp_ck */
+       if (!cpu_is_omap730())
+               omap_writew(omap_readw(ARM_CKCTL) & ~(1 << EN_DSPCK), ARM_CKCTL);
+
+       /* temporarily enabling api_ck to access DSP registers */
+       omap_writew(omap_readw(ARM_IDLECT2) | 1 << EN_APICK, ARM_IDLECT2);
+
+       /* save DSP registers */
+       DSP_SAVE(DSP_IDLECT2);
+
+       /* Stop all DSP domain clocks */
+       __raw_writew(0, DSP_IDLECT2);
 
        /*
         * Step 5: Wakeup Event Setup
@@ -353,7 +375,7 @@ void omap_pm_suspend(void)
         * Step 6c: ARM and Traffic controller shutdown
         *
         * Jump to assembly code. The processor will stay there
-        * until wake up.
+        * until wake up.
         */
         omap_sram_suspend(arg0, arg1);
 
@@ -361,14 +383,21 @@ void omap_pm_suspend(void)
         * If we are here, processor is woken up!
         */
 
-       /* Restore DSP clocks */
-       omap_dsp_pm_resume();
+       /*
+        * Restore DSP clocks
+        */
+
+       /* again temporarily enabling api_ck to access DSP registers */
+       omap_writew(omap_readw(ARM_IDLECT2) | 1 << EN_APICK, ARM_IDLECT2);
+
+       /* Restore DSP domain clocks */
+       DSP_RESTORE(DSP_IDLECT2);
 
        /*
         * Restore ARM state, except ARM_IDLECT1/2 which omap_cpu_suspend did
         */
 
-       if (!(cpu_is_omap1510()))
+       if (!(cpu_is_omap15xx()))
                ARM_RESTORE(ARM_IDLECT3);
        ARM_RESTORE(ARM_CKCTL);
        ARM_RESTORE(ARM_EWUPCT);
@@ -384,7 +413,7 @@ void omap_pm_suspend(void)
                MPUI730_RESTORE(OMAP_IH1_MIR);
                MPUI730_RESTORE(OMAP_IH2_0_MIR);
                MPUI730_RESTORE(OMAP_IH2_1_MIR);
-       } else if (cpu_is_omap1510()) {
+       } else if (cpu_is_omap15xx()) {
                MPUI1510_RESTORE(MPUI_CTRL);
                MPUI1510_RESTORE(MPUI_DSP_BOOT_CONFIG);
                MPUI1510_RESTORE(MPUI_DSP_API_CONFIG);
@@ -406,7 +435,8 @@ void omap_pm_suspend(void)
                MPUI1610_RESTORE(OMAP_IH2_3_MIR);
        }
 
-       omap_writew(0, ULPD_SOFT_DISABLE_REQ_REG);
+       if (!cpu_is_omap15xx())
+               omap_writew(0, ULPD_SOFT_DISABLE_REQ_REG);
 
        /*
         * Reenable interrupts
@@ -445,7 +475,7 @@ static int omap_pm_read_proc(
        ARM_SAVE(ARM_CKCTL);
        ARM_SAVE(ARM_IDLECT1);
        ARM_SAVE(ARM_IDLECT2);
-       if (!(cpu_is_omap1510()))
+       if (!(cpu_is_omap15xx()))
                ARM_SAVE(ARM_IDLECT3);
        ARM_SAVE(ARM_EWUPCT);
        ARM_SAVE(ARM_RSTCT1);
@@ -466,7 +496,7 @@ static int omap_pm_read_proc(
                MPUI730_SAVE(MPUI_DSP_API_CONFIG);
                MPUI730_SAVE(EMIFF_SDRAM_CONFIG);
                MPUI730_SAVE(EMIFS_CONFIG);
-       } else if (cpu_is_omap1510()) {
+       } else if (cpu_is_omap15xx()) {
                MPUI1510_SAVE(MPUI_CTRL);
                MPUI1510_SAVE(MPUI_DSP_STATUS);
                MPUI1510_SAVE(MPUI_DSP_BOOT_CONFIG);
@@ -529,34 +559,34 @@ static int omap_pm_read_proc(
                           MPUI730_SHOW(MPUI_DSP_API_CONFIG),
                           MPUI730_SHOW(EMIFF_SDRAM_CONFIG),
                           MPUI730_SHOW(EMIFS_CONFIG));
-               } else if (cpu_is_omap1510()) {
+               } else if (cpu_is_omap15xx()) {
                        my_buffer_offset += sprintf(my_base + my_buffer_offset,
                           "MPUI1510_CTRL_REG             0x%-8x \n"
                           "MPUI1510_DSP_STATUS_REG:      0x%-8x \n"
                           "MPUI1510_DSP_BOOT_CONFIG_REG: 0x%-8x \n"
-                          "MPUI1510_DSP_API_CONFIG_REG:  0x%-8x \n"
-                          "MPUI1510_SDRAM_CONFIG_REG:    0x%-8x \n"
-                          "MPUI1510_EMIFS_CONFIG_REG:    0x%-8x \n",
-                          MPUI1510_SHOW(MPUI_CTRL),
-                          MPUI1510_SHOW(MPUI_DSP_STATUS),
-                          MPUI1510_SHOW(MPUI_DSP_BOOT_CONFIG),
-                          MPUI1510_SHOW(MPUI_DSP_API_CONFIG),
-                          MPUI1510_SHOW(EMIFF_SDRAM_CONFIG),
-                          MPUI1510_SHOW(EMIFS_CONFIG));
+                          "MPUI1510_DSP_API_CONFIG_REG:  0x%-8x \n"
+                          "MPUI1510_SDRAM_CONFIG_REG:    0x%-8x \n"
+                          "MPUI1510_EMIFS_CONFIG_REG:    0x%-8x \n",
+                          MPUI1510_SHOW(MPUI_CTRL),
+                          MPUI1510_SHOW(MPUI_DSP_STATUS),
+                          MPUI1510_SHOW(MPUI_DSP_BOOT_CONFIG),
+                          MPUI1510_SHOW(MPUI_DSP_API_CONFIG),
+                          MPUI1510_SHOW(EMIFF_SDRAM_CONFIG),
+                          MPUI1510_SHOW(EMIFS_CONFIG));
                } else if (cpu_is_omap16xx()) {
                        my_buffer_offset += sprintf(my_base + my_buffer_offset,
                           "MPUI1610_CTRL_REG             0x%-8x \n"
                           "MPUI1610_DSP_STATUS_REG:      0x%-8x \n"
                           "MPUI1610_DSP_BOOT_CONFIG_REG: 0x%-8x \n"
-                          "MPUI1610_DSP_API_CONFIG_REG:  0x%-8x \n"
-                          "MPUI1610_SDRAM_CONFIG_REG:    0x%-8x \n"
-                          "MPUI1610_EMIFS_CONFIG_REG:    0x%-8x \n",
-                          MPUI1610_SHOW(MPUI_CTRL),
-                          MPUI1610_SHOW(MPUI_DSP_STATUS),
-                          MPUI1610_SHOW(MPUI_DSP_BOOT_CONFIG),
-                          MPUI1610_SHOW(MPUI_DSP_API_CONFIG),
-                          MPUI1610_SHOW(EMIFF_SDRAM_CONFIG),
-                          MPUI1610_SHOW(EMIFS_CONFIG));
+                          "MPUI1610_DSP_API_CONFIG_REG:  0x%-8x \n"
+                          "MPUI1610_SDRAM_CONFIG_REG:    0x%-8x \n"
+                          "MPUI1610_EMIFS_CONFIG_REG:    0x%-8x \n",
+                          MPUI1610_SHOW(MPUI_CTRL),
+                          MPUI1610_SHOW(MPUI_DSP_STATUS),
+                          MPUI1610_SHOW(MPUI_DSP_BOOT_CONFIG),
+                          MPUI1610_SHOW(MPUI_DSP_API_CONFIG),
+                          MPUI1610_SHOW(EMIFF_SDRAM_CONFIG),
+                          MPUI1610_SHOW(EMIFS_CONFIG));
                }
 
                g_read_completed++;
@@ -654,25 +684,24 @@ static int omap_pm_finish(suspend_state_t state)
 }
 
 
-static irqreturn_t  omap_wakeup_interrupt(int  irq, void *  dev,
-                                    struct pt_regs *  regs)
+static irqreturn_t  omap_wakeup_interrupt(int irq, void *dev)
 {
        return IRQ_HANDLED;
 }
 
 static struct irqaction omap_wakeup_irq = {
        .name           = "peripheral wakeup",
-       .flags          = SA_INTERRUPT,
+       .flags          = IRQF_DISABLED,
        .handler        = omap_wakeup_interrupt
 };
 
 
 
 static struct pm_ops omap_pm_ops ={
-       .pm_disk_mode = 0,
-        .prepare        = omap_pm_prepare,
-        .enter          = omap_pm_enter,
-        .finish         = omap_pm_finish,
+       .pm_disk_mode   = 0,
+       .prepare        = omap_pm_prepare,
+       .enter          = omap_pm_enter,
+       .finish         = omap_pm_finish,
 };
 
 static int __init omap_pm_init(void)
@@ -689,7 +718,7 @@ static int __init omap_pm_init(void)
                                                omap730_idle_loop_suspend_sz);
                omap_sram_suspend = omap_sram_push(omap730_cpu_suspend,
                                                   omap730_cpu_suspend_sz);
-       } else if (cpu_is_omap1510()) {
+       } 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,
@@ -713,15 +742,6 @@ static int __init omap_pm_init(void)
        else if (cpu_is_omap16xx())
                setup_irq(INT_1610_WAKE_UP_REQ, &omap_wakeup_irq);
 
-#if 0
-       /* --- BEGIN BOARD-DEPENDENT CODE --- */
-       /* Sleepx mask direction */
-       omap_writew((omap_readw(0xfffb5008) & ~2), 0xfffb5008);
-       /* Unmask sleepx signal */
-       omap_writew((omap_readw(0xfffb5004) & ~2), 0xfffb5004);
-       /* --- END BOARD-DEPENDENT CODE --- */
-#endif
-
        /* Program new power ramp-up time
         * (0 for most boards since we don't lower voltage when in deep sleep)
         */