]> rtime.felk.cvut.cz Git - arc.git/blobdiff - arch/ppc/mpc55xx/drivers/Mcu_Sleep.sx
EcuM: Adding more sleep functionility
[arc.git] / arch / ppc / mpc55xx / drivers / Mcu_Sleep.sx
index aa6cb3f4e3294f80a77ee612f014f43dadc40eb7..485fa9029e0ec64584d466713e89c8d7970c4c89 100644 (file)
@@ -26,10 +26,13 @@ McuE_EnterLowPower:
        mfCR    r29\r
        mfXER   r30\r
        mfCTR   r31\r
-       stmw    r25, 0x78(r1)   #-- Store SPR data to stack\r
+       stmw    r25, 0x78(r1)   // Store SPR data to stack\r
                \r
        LOAD_ADDR_32(r4,CRP_RECPTR)\r
        stw             r1,0x0(r4)      //  Save stack pointer to CRP to be preserved during LPM\r
+       \r
+/* Note! You cannot step over the wait instruction with the debugger */        \r
+       \r
        .long   0x7C00007C      //  Wait instruction\r
        \r
        \r
@@ -69,46 +72,46 @@ McuE_LowPowerVector:
 #elif defined(__DCC__)\r
        .section .text_vle,x\r
 #endif\r
+\r
+       .extern EcuM_CheckWakeup\r
        .global McuE_LowPowerRecoverFlash\r
 \r
 /*\r
- * When we come back here only TLB0 is setup for flash and then only 4K\r
+ * When we come back here only TLB0 is setup for flash and then only 4K.\r
+ *\r
+ * Debuggers:\r
+ * - WinIDEA : Hardware->Emulation Options->CPU Setup->MPC55xx->Low Power Debug\r
+ *             This will make the debugger stop on the function below.\r
+ * - UDE:      No support for this yet. It just runs through the "wait" instruction.       \r
  */    \r
 McuE_LowPowerRecoverFlash:\r
     \r
     bl cfg_MMU\r
\r
\r
-#if 0 \r
-       // Setup the SIU again.\r
-       li       r4,0x0202\r
-    LOAD_ADDR_32(r3,0xfffe8040+(52*2))         // PD4, SIU_PCR \r
-       sth  r4,0(r3)\r
-       \r
-       LOAD_ADDR_32(r3,0xfffe8600+52)          // PD4, SIU_GPDO\r
-       stb             1,0(r3) \r
-\r
-    // Release PAD keepers\r
-    LOAD_ADDR_32(r3,0xfffec060)   // CRP_PSCR\r
-    LOAD_ADDR_32(r4,0x1000)\r
-    stw         r4,0(r3)\r
-#endif    \r
-    \r
+     \r
 /* Recover the stack */\r
        LOAD_ADDR_32(r4,CRP_RECPTR)\r
-       lwz     r1,0x0(r4)      #-- Restore stack pointer from CRP\r
-       lmw     r25,0x78(r1)    #-- Load SPR values back into GPRs\r
+       lwz     r1,0x0(r4)          // Restore stack pointer from CRP\r
+       lmw     r25,0x78(r1)    // Load SPR values back into GPRs\r
        mtSRR1  r25\r
        mtSRR0  r26\r
        mtLR    r27\r
        mtmsr   r28\r
        mtCR    r29\r
        mtXER   r30\r
-       mtCTR   r31             #-- Load SPRs with GPR values\r
-       lmw     r2, 0(r1)       #-- Restore GPRs from stack\r
-       addi    r1,r1,0x94      #-- Deallocate space on stack\r
-       blr                     #-- Branch back to calling function\r
-    \r
+       mtCTR   r31                 // Load SPRs with GPR values\r
+       lmw     r2, 0(r1)           // Restore GPRs from stack\r
+       addi    r1,r1,0x94      // Deallocate space on stack\r
+\r
+#if defined(USE_ECUM)\r
+\r
+       /* We have no idea what made us wakeup, pass all */\r
+       LOAD_ADDR_32(r3,0x3fffffff);            // EcuM_WakeupSourceType\r
+       bl EcuM_CheckWakeup\r
+\r
+#endif\r
+\r
+\r
+\r
     /* branch back to Mcu_SetMode().. */\r
     blr\r
  \r
@@ -119,9 +122,13 @@ McuE_LowPowerRecoverFlash:
  #define VLE_VAL               0\r
  #endif\r
 \r
+#if defined(CFG_MPC5516)\r
 #define SRAM_START                     0x40000000\r
 #define FLASH_START                    0x00000000\r
 #define PERIPHERAL_START       0xfff00000\r
+#else\r
+#error No support for this MCU\r
+#endif\r
 \r
  \r
  cfg_MMU:\r