]> rtime.felk.cvut.cz Git - arc.git/commitdiff
Mcu, sleep fixes for mpc5668.
authorhebe <devnull@localhost>
Thu, 13 Sep 2012 08:16:02 +0000 (10:16 +0200)
committerhebe <devnull@localhost>
Thu, 13 Sep 2012 08:16:02 +0000 (10:16 +0200)
arch/ppc/mpc55xx/drivers/Mcu.c
arch/ppc/mpc55xx/drivers/Mcu_Sleep.sx

index 5b14c60c178e29cd12bad7db8948643d19271f2e..178edfbfba7fa349da7dea51e8c35c738986b5dd 100644 (file)
@@ -689,6 +689,48 @@ void Mcu_PerformReset(void)
  */\r
 static void enterLowPower (Mcu_ModeType mcuMode )\r
 {\r
+#if defined(CFG_MPC5668)\r
+       uint32 timeout;\r
+       /* Set the sleep bit; following a WAIT instruction, the device will go to sleep */\r
+       CRP.PSCR.B.SLEEP = 1;\r
+\r
+       /* 0x1 32k, 0x2 64k, 0x3 128k -- RAMs maintain power */\r
+       CRP.PSCR.B.RAMSEL = 0x3;                // Keep all 128K\r
+\r
+       CRP.Z6VEC.R = (uint32)&McuE_LowPowerRecoverFlash;\r
+#if defined(CFG_VLE)\r
+       CRP.Z6VEC.VLE = 1;\r
+#endif\r
+\r
+       /* If we "Mcu_Wakeup()" is located in RAM, set FASTREC */\r
+       CRP.RECPTR.B.FASTREC = 0;\r
+\r
+       /* Halt everything */\r
+    SIU.HLT0.R = 0x037FFF3D;\r
+    SIU.HLT1.R = 0x18000F3C;\r
+    while((SIU.HLTACK0.R != 0x037FFF3D) && (SIU.HLTACK1.R != 0x18000F3C) && (timeout<3000)){}\r
+\r
+       /* put Z0 in reset if not used for wakeup */\r
+       CRP.Z0VEC.B.Z0RST = 1;\r
+\r
+       // TODO: Enable_all_internal_pull_devices (PULL_DOWN);\r
+\r
+       /* Save context and execute wait instruction.\r
+        *\r
+        * Things that matter here are\r
+        * - Z1VEC, determines where TLB0 will point. TLB0 is written with a\r
+        *   value at startup that 4K aligned to this address.\r
+        * - LowPower_Sleep() will save a interrupt context so we will return\r
+        *   intact.\r
+        * - For devices with little RAM we don't want to impose the alignment\r
+        *   requirements there. Almost as we have to occupy a 4K block for this..\r
+        *   although the code does not take that much space.\r
+        * */\r
+       McuE_EnterLowPower(mcuMode);\r
+\r
+    /* Clear sleep flags to allow pads to operate */\r
+       CRP.PSCR.B.SLEEPF = 0x1;\r
+#else\r
        uint32 timeout;\r
        /* Set the sleep bit; following a WAIT instruction, the device will go to sleep */\r
        CRP.PSCR.B.SLEEP = 1;\r
@@ -730,7 +772,7 @@ static void enterLowPower (Mcu_ModeType mcuMode )
     /* Clear sleep flags to allow pads to operate */\r
     CRP.PSCR.B.SLEEPF = 0x1;\r
 \r
-\r
+#endif\r
 }\r
 \r
 \r
@@ -740,7 +782,7 @@ void Mcu_SetMode( Mcu_ModeType mcuMode)
        // VALIDATE( ( McuMode <= Mcu_Global.config->McuNumberOfMcuModes ), MCU_SETMODE_SERVICE_ID, MCU_E_PARAM_MODE );\r
 \r
 \r
-#if defined(CFG_MPC5516)\r
+#if defined(CFG_MPC5516) || defined(CFG_MPC5668)\r
        if( MCU_MODE_RUN == mcuMode ) {\r
 \r
        } else if( MCU_MODE_SLEEP == mcuMode ) {\r
index 485fa9029e0ec64584d466713e89c8d7970c4c89..4b2532d5707b020851b589a52189dd1b74e00434 100644 (file)
 .section .text\r
 #endif\r
 \r
-\r
+#if defined(CFG_MPC5516) || defined(CFG_MPC5668)\r
 #define CRP_RECPTR             0xfffec058\r
+#else\r
+#error\r
+#endif\r
 \r
        .global McuE_EnterLowPower\r
        \r
@@ -122,7 +125,7 @@ McuE_LowPowerRecoverFlash:
  #define VLE_VAL               0\r
  #endif\r
 \r
-#if defined(CFG_MPC5516)\r
+#if defined(CFG_MPC5516) || defined(CFG_MPC5668)\r
 #define SRAM_START                     0x40000000\r
 #define FLASH_START                    0x00000000\r
 #define PERIPHERAL_START       0xfff00000\r