//------------------------------------------------------------------------------ // // Function: OEMPowerOff // // Description: Called when the system is to transition to it's lowest power mode (off) // // void OEMPowerOff() { volatile S3C6410_SYSCON_REG *pSysConReg; volatile S3C6410_GPIO_REG *pGPIOReg; volatile S3C6410_VIC_REG *pVIC0Reg; volatile S3C6410_VIC_REG *pVIC1Reg; volatile S3C6410_DMAC_REG *pDMAC0Reg; volatile S3C6410_DMAC_REG *pDMAC1Reg; volatile OTG_PHY_REG *pOtgPhyReg; OAL_KITL_ARGS *pArgs; BOOL PowerStateOn; int nIndex = 0; OALMSG(TRUE, (L"[OEM] ++OEMPowerOff()")); // Make sure that KITL is powered off pArgs = (OAL_KITL_ARGS*)OALArgsQuery(OAL_ARGS_QUERY_KITL); if (pArgs && ((pArgs->flags & OAL_KITL_FLAGS_ENABLED) != 0)) { PowerStateOn = FALSE; KITLIoctl (IOCTL_KITL_POWER_CALL, &PowerStateOn, sizeof(PowerStateOn), NULL, 0, NULL); OALMSG(OAL_VERBOSE, (L"OEMPowerOff: KITL Disabled\r\n")); } //----------------------------- // Prepare Specific Actions for Sleep //----------------------------- BSPPowerOff(); //------------------------------ // Prepare CPU Entering Sleep Mode //------------------------------ //---------------- // Map SFR Address //---------------- pSysConReg = (S3C6410_SYSCON_REG *)OALPAtoVA(S3C6410_BASE_REG_PA_SYSCON, FALSE); pGPIOReg = (S3C6410_GPIO_REG *)OALPAtoVA(S3C6410_BASE_REG_PA_GPIO, FALSE); pVIC0Reg = (S3C6410_VIC_REG *)OALPAtoVA(S3C6410_BASE_REG_PA_VIC0, FALSE); pVIC1Reg = (S3C6410_VIC_REG *)OALPAtoVA(S3C6410_BASE_REG_PA_VIC1, FALSE); pDMAC0Reg = (S3C6410_DMAC_REG *)OALPAtoVA(S3C6410_BASE_REG_PA_DMA0, FALSE); pDMAC1Reg = (S3C6410_DMAC_REG *)OALPAtoVA(S3C6410_BASE_REG_PA_DMA1, FALSE); pOtgPhyReg = (OTG_PHY_REG *)OALPAtoVA(S3C6410_BASE_REG_PA_USBOTG_PHY, FALSE); //------------------ // Save VIC Registers //------------------ S3C6410_SaveState_VIC((void *)pVIC0Reg, (void *)pVIC1Reg, g_aSleepSave_VIC); // Disable All Interrupt pVIC0Reg->VICINTENCLEAR = 0xFFFFFFFF; pVIC1Reg->VICINTENCLEAR = 0xFFFFFFFF; pVIC0Reg->VICSOFTINTCLEAR = 0xFFFFFFFF; pVIC1Reg->VICSOFTINTCLEAR = 0xFFFFFFFF; //-------------------- // Save DMAC Registers //-------------------- S3C6410_SaveState_DMACon((void *)pDMAC0Reg, g_aSleepSave_DMACon0); S3C6410_SaveState_DMACon((void *)pDMAC1Reg, g_aSleepSave_DMACon1); //------------------ // Save GPIO Register //------------------ S3C6410_SaveState_GPIO((void *)pGPIOReg, g_aSleepSave_GPIO); //-------------------- // Save SysCon Register //-------------------- S3C6410_SaveState_SysCon((void *)pSysConReg, g_aSleepSave_SysCon); //--------------------------------------------------------------------------- // Unmask Clock Gating for All IPsand Block Power turn On for the IPs not going to sleep //--------------------------------------------------------------------------- // HCLK_IROM, HCLK_MEM1, HCLK_MEM0, HCLK_MFC Should be Always On for power Mode (Something coupled with BUS operation) //pSysConReg->HCLK_GATE |= ((1<<25)|(1<<22)|(1<<21)|(1<<0)); pSysConReg->HCLK_GATE = 0xFFFFFFFF; pSysConReg->PCLK_GATE = 0xFFFFFFFF; pSysConReg->SCLK_GATE = 0xFFFFFFFF; // Turn On All Block Block Power pSysConReg->NORMAL_CFG = 0xFFFFFF00; // Wait for Block Power Stable while((pSysConReg->BLK_PWR_STAT & 0x7E) != 0x7E); //---------------------------- // Wake Up Source Configuration //---------------------------- // S3C6410_WakeUpSource_Configure(); //------------------------------- // Extra work for Entering Sleep Mode //------------------------------- // USB Power Control pSysConReg->OTHERS &= ~(1<<16); // USB Signal Mask Clear pGPIOReg->SPCON |= (1<<3); // USB Tranceiver PAD to Suspend #ifdef _IROM_SDMMC_ // Sleep Mode Pad Configuration. HSJANG 070926. SLPEN must be 0 to change cpcon value for reading OM. #else // Sleep Mode Pad Configuration pGPIOReg->SLPEN = 0x2; // Controlled by SLPEN Bit (You Should Clear SLPEN Bit in Wake Up Process...) #endif //----------------------- // CPU Entering Sleep Mode //----------------------- OALCPUPowerOff(); // Now in Sleep //---------------------------- // CPU Wake Up from Sleep Mode //---------------------------- // Restore SysCon Register S3C6410_RestoreState_SysCon((void *)pSysConReg, g_aSleepSave_SysCon); // Restore GPIO Register S3C6410_RestoreState_GPIO((void *)pGPIOReg, g_aSleepSave_GPIO); #ifdef _IROM_SDMMC_ // Sleep Mode Pad Configuration. HSJANG 070926. SLPEN must be 0 to change cpcon value for reading OM. #else // Sleep Mode Pad Configuration pGPIOReg->SLPEN = 0x2; // Clear SLPEN Bit for Pad back to Normal Mode #endif //----------------------- // Restore DMAC Registers //----------------------- S3C6410_RestoreState_DMACon((void *)pDMAC0Reg, g_aSleepSave_DMACon0); S3C6410_RestoreState_DMACon((void *)pDMAC1Reg, g_aSleepSave_DMACon1); // Restore VIC Registers S3C6410_RestoreState_VIC((void *)pVIC0Reg, (void *)pVIC1Reg, g_aSleepSave_VIC); // UART Debug Port Initialize OEMInitDebugSerial(); // Disable Vectored Interrupt Mode on CP15 System_DisableVIC(); // Enable Branch Prediction on CP15 System_EnableBP(); // Enable IRQ Interrupt on CP15 System_EnableIRQ(); // Enable FIQ Interrupt on CP15 System_EnableFIQ(); // Initialize System Timer OEMInitializeSystemTimer(RESCHED_PERIOD, OEM_COUNT_1MS, 0); // USB Power Control InitializeOTGCLK(); // pll_powerdown, suspend mode pGPIOReg->SPCON &= ~(1<<3); // USB Tranceiver PAD to Normal //-------------------------------------- // Post Processing Specific Actions for Wake Up //-------------------------------------- BSPPowerOn(); // Reinitialize KITL if (pArgs && ((pArgs->flags & OAL_KITL_FLAGS_ENABLED) != 0)) { PowerStateOn = TRUE; KITLIoctl (IOCTL_KITL_POWER_CALL, &PowerStateOn, sizeof(PowerStateOn), NULL, 0, NULL); } OALMSG(TRUE, (L"[OEM] --OEMPowerOff()")); }
//------------------------------------------------------------------------------ // // Function: OEMInit // // This is Windows CE OAL initialization function. It is called from kernel // after basic initialization is made. // void OEMInit() { BOOL *bCleanBootFlag; OALMSG(OAL_FUNC, (L"[OAL] ++OEMInit()\r\n")); OALMSG(OAL_FUNC, (TEXT("[OAL] S3C6410_APLL_CLK : %d\n\r"), System_GetAPLLCLK())); OALMSG(OAL_FUNC, (TEXT("[OAL] ARMCLK : %d\n\r"), System_GetARMCLK())); OALMSG(OAL_FUNC, (TEXT("[OAL] HCLK : %d\n\r"), System_GetHCLK())); OALMSG(OAL_FUNC, (TEXT("[OAL] PCLK : %d\n\r"), System_GetPCLK())); OALMSG(1, (TEXT("[OAL] S3C6410_APLL_CLK : %d\n\r"), System_GetAPLLCLK())); OALMSG(1, (TEXT("[OAL] ARMCLK : %d\n\r"), System_GetARMCLK())); OALMSG(1, (TEXT("[OAL] HCLK : %d\n\r"), System_GetHCLK())); OALMSG(1, (TEXT("[OAL] PCLK : %d\n\r"), System_GetPCLK())); g_oalIoCtlClockSpeed = System_GetARMCLK(); //CEProcessorType = PROCESSOR_STRONGARM; // Set memory size for DrWatson kernel support // dwNKDrWatsonSize = 128 * 1024; // Intialize optional kernel functions. (Processor Extended Feature) // g_pOemGlobal->pfnIsProcessorFeaturePresent = (PFN_IsProcessorFeaturePresent)OALIsProcessorFeaturePresent; // Set OEMSetMemoryAttributes function g_pOemGlobal->pfnSetMemoryAttributes = (PFN_SetMemoryAttributes)OEMSetMemoryAttributes; // Turn Off all Debug LED // // Initialize Clock Source // InitializeCLKSource(); // Initialize Clock Gating // InitializeCLKGating(); // Initialize Block Power // InitializeBlockPower(); // Initialize ExtPowerCTL // InitPowerCTL(); // Initialize OTG PHY Clock // InitializeOTGCLK(); // Initialize BCD registers in RTC to known values // Initilize cache globals // OALCacheGlobalsInit(); OALLogSerial(L"DCache: %d sets, %d ways, %d line size, %d size\r\n", g_oalCacheInfo.L1DSetsPerWay, g_oalCacheInfo.L1DNumWays, g_oalCacheInfo.L1DLineSize, g_oalCacheInfo.L1DSize); OALLogSerial(L"ICache: %d sets, %d ways, %d line size, %d size\r\n", g_oalCacheInfo.L1ISetsPerWay, g_oalCacheInfo.L1INumWays, g_oalCacheInfo.L1ILineSize, g_oalCacheInfo.L1ISize); // Check and Initialize the BSP Args area // OALArgsInit((BSP_ARGS *)IMAGE_SHARE_ARGS_UA_START); // Check clean boot flag in BSP Args area // OALMSG(OAL_FUNC, (TEXT("[OAL] OEMInit() : BSP Args forces Clean Boot\r\n"))); bCleanBootFlag = (BOOL *)OALArgsQuery(BSP_ARGS_QUERY_CLEANBOOT); if (*bCleanBootFlag) { // Notify to filesys.exe that we want a clean boot. NKForceCleanBoot(); } // Initialize Interrupts // if (!OALIntrInit()) { OALMSG(OAL_ERROR, (L"[OAL:ERR] OEMInit() : failed to initialize interrupts\r\n")); } // Initialize System Clock // OALTimerInit(RESCHED_PERIOD, (OEM_COUNT_1MS ), 0); // Make high-res Monte Carlo profiling available to the kernel // g_pOemGlobal->pfnProfileTimerEnable = OEMProfileTimerEnable; g_pOemGlobal->pfnProfileTimerDisable = OEMProfileTimerDisable; // Initialize the KITL connection if required // KITLIoctl(IOCTL_KITL_STARTUP, NULL, 0, NULL, 0, NULL); InitializeBank(); OALMSG(OAL_FUNC, (L"[OAL] --OEMInit()\r\n")); }
//------------------------------------------------------------------------------ // // Function: OEMInit // // This is Windows CE OAL initialization function. It is called from kernel // after basic initialization is made. // void OEMInit() { UINT32 logMask_Backup; extern DWORD CEProcessorType; // From nkarm.h in the private tree. //volatile S3C6410_VIC_REG *pIntr = (S3C6410_VIC_REG*)OALPAtoVA(S3C6410_BASE_REG_PA_VIC0, FALSE); //NKForceCleanBoot(); OALMSG(OAL_FUNC, (L"[OAL] ++OEMInit()\r\n")); OALMSG(TRUE, (L"[OAL] ++OEMInit()\r\n")); OALMSG(OAL_FUNC, ((L"[OAL] APLLCLK : %d\n\r"), System_GetAPLLCLK())); OALMSG(OAL_FUNC, ((L"[OAL] ARMCLK : %d\n\r"), System_GetARMCLK())); OALMSG(OAL_FUNC, ((L"[OAL] HCLK : %d\n\r"), System_GetHCLK())); OALMSG(OAL_FUNC, ((L"[OAL] PCLK : %d\n\r"), System_GetPCLK())); g_oalIoCtlClockSpeed = System_GetARMCLK(); // Lie about the Processor Type (we do this so that the visual C tools work) CEProcessorType = PROCESSOR_STRONGARM; logMask_Backup = g_oalLogMask; OALLogSetZones( (1<<OAL_LOG_ERROR) | (1<<OAL_LOG_WARN) | (1<<OAL_LOG_FUNC) ); RETAILMSG(TRUE, (TEXT("CEProcessorType = 0x%x\r\n"),CEProcessorType)); RETAILMSG(TRUE, (TEXT("APLLCLK: %d, FCLK: %d, HCLK: %d, PCLK: %d\r\n"), System_GetAPLLCLK(), System_GetARMCLK(), System_GetHCLK(), System_GetPCLK())); // Set memory size for DrWatson kernel support if (dwOEMDrWatsonSize != NOT_FIXEDUP) { dwNKDrWatsonSize = dwOEMDrWatsonSize; // set size of reserved memory for Watson dump } // Intialize optional kernel functions. (Processor Extended Feature) // pOEMIsProcessorFeaturePresent = OALIsProcessorFeaturePresent; // Set OEMSetMemoryAttributes function pfnOEMSetMemoryAttributes = OEMSetMemoryAttributes; // Turn Off all Debug LED // OEMWriteDebugLED(0, 0x0); // Initialize INFORM SFR // This function should be called for CPU Identification. InitializeINFORMSFR(); // Initialize Clock Source // InitializeCLKSource(); // Initialize Clock Gating // InitializeCLKGating(); // Initialize Block Power // InitializeBlockPower(); // Initialize OTG PHY Clock // InitializeOTGCLK(); // Initilize cache globals OALCacheGlobalsInit(); OALLogSerial( L"DCache: %d sets, %d ways, %d line size, %d size\r\n", g_oalCacheInfo.L1DSetsPerWay, g_oalCacheInfo.L1DNumWays, g_oalCacheInfo.L1DLineSize, g_oalCacheInfo.L1DSize ); OALLogSerial( L"ICache: %d sets, %d ways, %d line size, %d size\r\n", g_oalCacheInfo.L1ISetsPerWay, g_oalCacheInfo.L1INumWays, g_oalCacheInfo.L1ILineSize, g_oalCacheInfo.L1ISize ); // Initialize Interrupts // if (!OALIntrInit()) { OALMSG(OAL_ERROR, (L"[OAL:ERR] OEMInit() : failed to initialize interrupts\r\n")); } // Initialize system clock OALTimerInit(RESCHED_PERIOD, OEM_COUNT_1MS, 0); // Initialize GPIO // InitializeGPIO(); // Initialize the KITL connection if required RETAILMSG(1, (TEXT("OALKitlStart() \n\r"))); OALKitlStart(); Init_BspArgs(); OALMSG(OAL_FUNC, (L"-OEMInit\r\n")); OALLogSetZones(logMask_Backup); }