//------------------------------------------------------------------------------ // // Function: OEMSetAlarmTime // // Set the RTC alarm time. // BOOL OEMSetAlarmTime(SYSTEMTIME *pTime) { BOOL rc = FALSE; S3C2410X_RTC_REG *pRTCReg; UINT32 irq; OALMSG(OAL_RTC&&OAL_FUNC, ( L"+OEMSetAlarmTime(%d/%d/%d %d:%d:%d.%03d)\r\n", pTime->wMonth, pTime->wDay, pTime->wYear, pTime->wHour, pTime->wMinute, pTime->wSecond, pTime->wMilliseconds )); if (pTime == NULL) goto cleanUp; // Get uncached virtual address pRTCReg = OALPAtoVA(S3C2410X_BASE_REG_PA_RTC, FALSE); // Enable RTC control SETREG32(&pRTCReg->RTCCON, 1); OUTPORT32(&pRTCReg->ALMSEC, TO_BCD(pTime->wSecond)); OUTPORT32(&pRTCReg->ALMMIN, TO_BCD(pTime->wMinute)); OUTPORT32(&pRTCReg->ALMHOUR, TO_BCD(pTime->wHour)); OUTPORT32(&pRTCReg->ALMDATE, TO_BCD(pTime->wDay)); OUTPORT32(&pRTCReg->ALMMON, TO_BCD(pTime->wMonth)); OUTPORT32(&pRTCReg->ALMYEAR, TO_BCD(pTime->wYear - RTC_YEAR_DATUM)); // Enable the RTC alarm interrupt OUTPORT32(&pRTCReg->RTCALM, 0x7F); // Disable RTC control. CLRREG32(&pRTCReg->RTCCON, 1); // Enable/clear RTC interrupt irq = IRQ_RTC; OALIntrDoneIrqs(1, &irq); // Done rc = TRUE; cleanUp: OALMSG(OAL_RTC&&OAL_FUNC, (L"-OEMSetAlarmTime(rc = %d)\r\n", rc)); return rc; }
void OEMPowerOff() { #if (BSP_TYPE == BSP_SMDK2443) static UINT32 saveArea[85]; #elif (BSP_TYPE == BSP_SMDK2450) static UINT32 saveArea[90]; #endif volatile S3C2450_INTR_REG *pIntr = (S3C2450_INTR_REG*)OALPAtoVA(S3C2450_BASE_REG_PA_INTR, FALSE); volatile S3C2450_IOPORT_REG *pIOPort = (S3C2450_IOPORT_REG*)OALPAtoVA(S3C2450_BASE_REG_PA_IOPORT, FALSE); volatile S3C2450_LCD_REG *pLCD = (S3C2450_LCD_REG*)OALPAtoVA(S3C2450_BASE_REG_PA_LCD, FALSE); volatile S3C2450_CLKPWR_REG *pCLKPWR = (S3C2450_CLKPWR_REG*)OALPAtoVA(S3C2450_BASE_REG_PA_CLOCK_POWER, FALSE); // First do platform specific actions //BSPPowerOff(); RETAILMSG(1,(TEXT("\r\n --OEMPowerOff--\r\n"))); g_pLCDReg = (volatile S3C2450_LCD_REG*)OALPAtoVA(S3C2450_BASE_REG_PA_LCD, FALSE); // g_pMEMCTRLReg = (volatile S3C2450_MEMCTRL_REG *)OALPAtoVA(S3C2450_BASE_REG_PA_MEMCTRL, FALSE); g_pPWMRegs = (volatile S3C2450_PWM_REG *)OALPAtoVA(S3C2450_BASE_REG_PA_PWM, FALSE); g_pCLKPWRRegs = (volatile S3C2450_CLKPWR_REG *)OALPAtoVA(S3C2450_BASE_REG_PA_CLOCK_POWER, FALSE); g_pNandRegs = (volatile S3C2450_NAND_REG*)OALPAtoVA(S3C2450_BASE_REG_PA_NAND, FALSE); g_pRTCRegs = (volatile S3C2450_RTC_REG*)OALPAtoVA(S3C2450_BASE_REG_PA_RTC, FALSE); g_pIOPort = (volatile S3C2450_IOPORT_REG*)OALPAtoVA(S3C2450_BASE_REG_PA_IOPORT, FALSE); g_pIntrRegs = (volatile S3C2450_INTR_REG*)OALPAtoVA(S3C2450_BASE_REG_PA_INTR, FALSE); g_pBspArgs = (volatile BSP_ARGS *)OALPAtoVA(IMAGE_SHARE_ARGS_PA_START, FALSE); g_pADCReg = (S3C2450_ADC_REG*)OALPAtoVA(S3C2450_BASE_REG_PA_ADC, FALSE); #ifdef DVS_EN RETAILMSG(1,(TEXT("DVS OFF\r\n"))); { int voltage_set[2] = HIGH_V_SET; ChangeVoltage(ARM_INT_VDD, voltage_set); } HCLK_RECOVERYUP(); DVS_OFF(); g_oalIoCtlClockSpeed = S3C2450_FCLK; CurrentState = Active; #endif //DVS_EN // Then save system registers #if (BSP_TYPE == BSP_SMDK2443) #ifdef EVT1 pIOPort->GPACDL = 0xFFFF; pIOPort->GPACDH = 0x1FFFF; #else saveArea[0] = INPORT32(&pIOPort->GPACON); saveArea[1] = INPORT32(&pIOPort->GPADAT); #endif #elif (BSP_TYPE == BSP_SMDK2450) #if 0 //[david.modify] 2008-06-04 18:26 // s805g ÓÐÓõ½GPA //========================= pIOPort->GPACON = 0xFFFFFFFF; pIOPort->GPADAT= 0x1FFFF; //ÔÚ´Ë´¦¹Ø±ÕGPA13 //GPA14 pIOPort->GPACON&=~( (1<<13)|(1<<14)); pIOPort->GPADAT&=~( (1<<13)|(1<<14)); //========================= #endif #endif saveArea[2] = INPORT32(&pIOPort->GPBCON); saveArea[3] = INPORT32(&pIOPort->GPBDAT); saveArea[4] = INPORT32(&pIOPort->GPBUDP); saveArea[5] = INPORT32(&pIOPort->GPCCON); saveArea[6] = INPORT32(&pIOPort->GPCDAT); saveArea[7] = INPORT32(&pIOPort->GPCUDP); saveArea[8] = INPORT32(&pIOPort->GPDCON); saveArea[9] = INPORT32(&pIOPort->GPDDAT); saveArea[10] = INPORT32(&pIOPort->GPDUDP); saveArea[11] = INPORT32(&pIOPort->GPECON); saveArea[12] = INPORT32(&pIOPort->GPEDAT); saveArea[13] = INPORT32(&pIOPort->GPEUDP); saveArea[14] = INPORT32(&pIOPort->GPFCON); saveArea[15] = INPORT32(&pIOPort->GPFDAT); saveArea[16] = INPORT32(&pIOPort->GPFUDP); saveArea[17] = INPORT32(&pIOPort->GPGCON); saveArea[18] = INPORT32(&pIOPort->GPGDAT); saveArea[19] = INPORT32(&pIOPort->GPGUDP); saveArea[20] = INPORT32(&pIOPort->GPHCON); saveArea[21] = INPORT32(&pIOPort->GPHDAT); saveArea[22] = INPORT32(&pIOPort->GPHUDP); saveArea[23] = INPORT32(&pIOPort->GPJCON); saveArea[24] = INPORT32(&pIOPort->GPJDAT); saveArea[25] = INPORT32(&pIOPort->GPJUDP); #if (BSP_TYPE == BSP_SMDK2443) #ifdef EVT1 saveArea[26] = INPORT32(&pIOPort->GPKCON); saveArea[27] = INPORT32(&pIOPort->GPKDAT); saveArea[28] = INPORT32(&pIOPort->DATAPDEN); #else saveArea[26] = INPORT32(&pIOPort->GPKCON); saveArea[27] = INPORT32(&pIOPort->GPKDAT); saveArea[28] = INPORT32(&pIOPort->GPKUDP); #endif #elif (BSP_TYPE == BSP_SMDK2450) saveArea[26] = INPORT32(&pIOPort->GPKCON); saveArea[27] = INPORT32(&pIOPort->GPKDAT); saveArea[28] = INPORT32(&pIOPort->GPKUDP); #endif saveArea[29] = INPORT32(&pIOPort->GPLCON); saveArea[30] = INPORT32(&pIOPort->GPLDAT); saveArea[31] = INPORT32(&pIOPort->GPLUDP); saveArea[32] = INPORT32(&pIOPort->GPMCON); saveArea[33] = INPORT32(&pIOPort->GPMDAT); saveArea[34] = INPORT32(&pIOPort->GPMUDP); saveArea[35] = INPORT32(&pIOPort->MISCCR); saveArea[36] = INPORT32(&pIOPort->DCLKCON); #if (BSP_TYPE == BSP_SMDK2443) #ifdef EVT1 saveArea[37] = READEXTINT0(pIOPort->EXTINT0); saveArea[38] = READEXTINT1(pIOPort->EXTINT1); saveArea[39] = READEXTINT2(pIOPort->EXTINT2); #else saveArea[37] = INPORT32(&pIOPort->EXTINT0); saveArea[38] = INPORT32(&pIOPort->EXTINT1); saveArea[39] = INPORT32(&pIOPort->EXTINT2); #endif #elif (BSP_TYPE == BSP_SMDK2450) saveArea[37] = INPORT32(&pIOPort->EXTINT0); saveArea[38] = INPORT32(&pIOPort->EXTINT1); saveArea[39] = INPORT32(&pIOPort->EXTINT2); #endif saveArea[40] = INPORT32(&pIOPort->EINTFLT0); saveArea[41] = INPORT32(&pIOPort->EINTFLT1); saveArea[42] = INPORT32(&pIOPort->EINTFLT2); saveArea[43] = INPORT32(&pIOPort->EINTFLT3); saveArea[44] = INPORT32(&pIOPort->EINTMASK); #if (BSP_TYPE == BSP_SMDK2443) saveArea[45] = INPORT32(&pIntr->INTMOD); saveArea[46] = INPORT32(&pIntr->INTMSK); #elif (BSP_TYPE == BSP_SMDK2450) saveArea[45] = INPORT32(&pIntr->INTMOD1); saveArea[46] = INPORT32(&pIntr->INTMSK1); #endif saveArea[47] = INPORT32(&pIntr->INTSUBMSK); saveArea[48] = INPORT32(&pLCD->VIDCON0); saveArea[49] = INPORT32(&pLCD->VIDCON1); saveArea[50] = INPORT32(&pLCD->VIDTCON0); saveArea[51] = INPORT32(&pLCD->VIDTCON1); saveArea[52] = INPORT32(&pLCD->VIDTCON2); saveArea[53] = INPORT32(&pLCD->WINCON0); saveArea[54] = INPORT32(&pLCD->WINCON1); saveArea[55] = INPORT32(&pLCD->VIDOSD0A); saveArea[56] = INPORT32(&pLCD->VIDOSD0B); saveArea[57] = INPORT32(&pLCD->VIDOSD0C); saveArea[58] = INPORT32(&pLCD->VIDOSD1A); saveArea[59] = INPORT32(&pLCD->VIDOSD1B); saveArea[60] = INPORT32(&pLCD->VIDOSD1C); saveArea[61] = INPORT32(&pLCD->VIDW00ADD0B0); saveArea[62] = INPORT32(&pLCD->VIDW00ADD0B1); saveArea[63] = INPORT32(&pLCD->VIDW01ADD0); saveArea[64] = INPORT32(&pLCD->VIDW00ADD1B0); saveArea[65] = INPORT32(&pLCD->VIDW00ADD1B1); saveArea[66] = INPORT32(&pLCD->VIDW01ADD1); saveArea[67] = INPORT32(&pLCD->VIDW00ADD2B0); saveArea[68] = INPORT32(&pLCD->VIDW00ADD2B1); saveArea[69] = INPORT32(&pLCD->VIDW01ADD2); saveArea[70] = INPORT32(&pLCD->VIDINTCON); saveArea[71] = INPORT32(&pLCD->W1KEYCON0); saveArea[72] = INPORT32(&pLCD->W1KEYCON1); saveArea[73] = INPORT32(&pLCD->W2KEYCON0); saveArea[74] = INPORT32(&pLCD->W2KEYCON1); saveArea[75] = INPORT32(&pLCD->W3KEYCON0); saveArea[76] = INPORT32(&pLCD->W3KEYCON1); saveArea[77] = INPORT32(&pLCD->W4KEYCON0); saveArea[78] = INPORT32(&pLCD->W4KEYCON1); saveArea[79] = INPORT32(&pLCD->WIN0MAP); saveArea[80] = INPORT32(&pLCD->WIN1MAP); saveArea[81] = INPORT32(&pLCD->WPALCON); saveArea[82] = INPORT32(&pLCD->SYSIFCON0); saveArea[83] = INPORT32(&pLCD->SYSIFCON1); saveArea[84] = INPORT32(&pLCD->DITHMODE); #if (BSP_TYPE == BSP_SMDK2443) #elif (BSP_TYPE == BSP_SMDK2450) saveArea[85] = INPORT32(&pIntr->INTMOD2); saveArea[86] = INPORT32(&pIntr->INTMSK2); #endif pLCD->VIDCON0 = 0; pLCD->VIDCON1 = 0; pLCD->VIDTCON0 = 0; pLCD->VIDTCON1 = 0; pLCD->VIDTCON2 = 0; pLCD->WINCON0 = 0; pLCD->WINCON1 = 0; pLCD->VIDOSD0A = 0; pLCD->VIDOSD0B = 0; pLCD->VIDOSD0C = 0; pLCD->VIDW00ADD0B0 = 0; pLCD->VIDW00ADD1B0 = 0; pLCD->VIDW00ADD2B0 = 0; // ConfigStopGPIO(); #define NEW_BSP_MODIFY 1 #if NEW_BSP_MODIFY //EVT3 For IROM Boot, GPC is retention in sleep mode pIOPort->GPCCON &= ~(0x3f<<10); pIOPort->GPCUDP &= ~(0x3f<<10); #endif // Switch off power for KITL device //OALKitlPowerOff(); // woo 1021 //[david.modify] 2008-07-04 11:19 //==================================== DPNOK(g_pBspArgs->u32WakeupHoldTime); ConfigSleepGPIO_david(); //[david.modify] 2008-07-23 18:49 // ½«´ËÐÐÄõô£¬²âÊÔ´ËÐÐÊÇ·ñÓ°Ï쵽˯ÃߺóTOUCH²»ºÃʹµÄÎÊÌâ ConfigMiscReg_david(); // clear interrupt pending register g_pIOPort->EINTPEND = g_pIOPort->EINTPEND; g_pIntrRegs->SUBSRCPND = g_pIntrRegs->SUBSRCPND; g_pIntrRegs->SRCPND1 = g_pIntrRegs->SRCPND1; g_pIntrRegs->INTPND1 = g_pIntrRegs->INTPND1; //==================================== //[david.modify] 2008-07-08 15:07 // ¸Ä³ÉÖ§³Ö³¤°´»½ÐѺͶ̰´»½ÐÑ if(WAKEUP_MODE1_SHORTPRESS==g_pBspArgs->u32WakeUpMode){ // Go to power off mode OALCPUPowerOff(); } else/* if(WAKEUP_MODE2_LONGPRESS==g_pBspArgs->u32WakeUpMode)*/ { do { g_stGPIOInfo[4].u32Stat = 1; SetGPIOInfo(&g_stGPIOInfo[4], g_pIOPort); //[david.modify] 2008-08-04 12:33 // ÓÃÓÚ¼ì²â˯ÂÇÇ°CHARGERÊDz»ÊÇÒѾ²åÈëµÄ //================================= if (IsChargerIn()) { //[david.modify] 2008-08-19 00:31 g_bAcAdapterInBeforeSleep = TRUE; //[david.modify] 2008-08-19 00:31 // g_bAcAdapterInBeforeSleep = FALSE; } else { g_bAcAdapterInBeforeSleep = FALSE; } //====================================== // Go to power off mode OALCPUPowerOff(); }while(!OALBspWakeupCheck()); } // Switch on power for KITL device // OALKitlPowerOn(); /* Recover Process, Load CPU Regs */ #if (BSP_TYPE == BSP_SMDK2443) #ifdef EVT1 #else OUTPORT32(&pIOPort->GPACON, saveArea[0]); OUTPORT32(&pIOPort->GPADAT, saveArea[1]); #endif #elif (BSP_TYPE == BSP_SMDK2450) #endif //OUTPORT32(&pIOPort->GPACON, saveArea[0]); //OUTPORT32(&pIOPort->GPADAT, saveArea[1]); OUTPORT32(&pIOPort->GPBCON, saveArea[2]); OUTPORT32(&pIOPort->GPBDAT, saveArea[3]); OUTPORT32(&pIOPort->GPBUDP, saveArea[4]); OUTPORT32(&pIOPort->GPCCON, saveArea[5]); OUTPORT32(&pIOPort->GPCDAT, saveArea[6]); OUTPORT32(&pIOPort->GPCUDP, saveArea[7]); OUTPORT32(&pIOPort->GPDCON, saveArea[8]); OUTPORT32(&pIOPort->GPDDAT, saveArea[9]); OUTPORT32(&pIOPort->GPDUDP, saveArea[10]); OUTPORT32(&pIOPort->GPECON, saveArea[11]); OUTPORT32(&pIOPort->GPEDAT, saveArea[12]); OUTPORT32(&pIOPort->GPEUDP, saveArea[13]); OUTPORT32(&pIOPort->GPFCON, saveArea[14]); OUTPORT32(&pIOPort->GPFDAT, saveArea[15]); OUTPORT32(&pIOPort->GPFUDP, saveArea[16]); OUTPORT32(&pIOPort->GPGCON, saveArea[17]); OUTPORT32(&pIOPort->GPGDAT, saveArea[18]); OUTPORT32(&pIOPort->GPGUDP, saveArea[19]); OUTPORT32(&pIOPort->GPHCON, saveArea[20]); OUTPORT32(&pIOPort->GPHDAT, saveArea[21]); OUTPORT32(&pIOPort->GPHUDP, saveArea[22]); OUTPORT32(&pIOPort->GPJCON, saveArea[23]); OUTPORT32(&pIOPort->GPJDAT, saveArea[24]); OUTPORT32(&pIOPort->GPJUDP, saveArea[25]); #if (BSP_TYPE == BSP_SMDK2443) #ifdef EVT1 OUTPORT32(&pIOPort->GPKCON, saveArea[26]); OUTPORT32(&pIOPort->GPKDAT, saveArea[27]); OUTPORT32(&pIOPort->DATAPDEN, saveArea[28]); #else OUTPORT32(&pIOPort->GPKCON, saveArea[26]); OUTPORT32(&pIOPort->GPKDAT, saveArea[27]); OUTPORT32(&pIOPort->GPKUDP, saveArea[28]); #endif #elif (BSP_TYPE == BSP_SMDK2450) OUTPORT32(&pIOPort->GPKCON, saveArea[26]); OUTPORT32(&pIOPort->GPKDAT, saveArea[27]); OUTPORT32(&pIOPort->GPKUDP, saveArea[28]); #endif OUTPORT32(&pIOPort->GPLCON, saveArea[29]); OUTPORT32(&pIOPort->GPLDAT, saveArea[30]); OUTPORT32(&pIOPort->GPLUDP, saveArea[31]); OUTPORT32(&pIOPort->GPMCON, saveArea[32]); OUTPORT32(&pIOPort->GPMDAT, saveArea[33]); OUTPORT32(&pIOPort->GPMUDP, saveArea[34]); OUTPORT32(&pIOPort->MISCCR, saveArea[35]); OUTPORT32(&pIOPort->DCLKCON, saveArea[36]); OUTPORT32(&pIOPort->EXTINT0, saveArea[37]); OUTPORT32(&pIOPort->EXTINT1, saveArea[38]); OUTPORT32(&pIOPort->EXTINT2, saveArea[39]); OUTPORT32(&pIOPort->EINTFLT0, saveArea[40]); OUTPORT32(&pIOPort->EINTFLT1, saveArea[41]); OUTPORT32(&pIOPort->EINTFLT2, saveArea[42]); OUTPORT32(&pIOPort->EINTFLT3, saveArea[43]); OUTPORT32(&pIOPort->EINTMASK, saveArea[44]); #if NEW_BSP_MODIFY // retention release pCLKPWR->RSTCON |= (1<<16); #endif #if (BSP_TYPE == BSP_SMDK2443) OUTPORT32(&pIntr->INTMOD, saveArea[45]); OUTPORT32(&pIntr->INTMSK, saveArea[46]); #elif (BSP_TYPE == BSP_SMDK2450) OUTPORT32(&pIntr->INTMOD1, saveArea[45]); OUTPORT32(&pIntr->INTMSK1, saveArea[46]); #endif OUTPORT32(&pIntr->INTSUBMSK, saveArea[47]); // InitDisplay2(); pLCD->VIDCON0 = saveArea[48]; pLCD->VIDCON1 = saveArea[49]; pLCD->VIDTCON0 = saveArea[50]; pLCD->VIDTCON1 = saveArea[51]; pLCD->VIDTCON2 = saveArea[52]; pLCD->WINCON0 = saveArea[53]; pLCD->WINCON1 = saveArea[54]; pLCD->VIDOSD0A = saveArea[55]; pLCD->VIDOSD0B = saveArea[56]; pLCD->VIDOSD0C = saveArea[57]; pLCD->VIDOSD1A = saveArea[58]; pLCD->VIDOSD1B = saveArea[59]; pLCD->VIDOSD1C = saveArea[60]; pLCD->VIDW00ADD0B0 = saveArea[61]; pLCD->VIDW00ADD0B1 = saveArea[62]; pLCD->VIDW01ADD0 = saveArea[63]; pLCD->VIDW00ADD1B0 = saveArea[64]; pLCD->VIDW00ADD1B1 = saveArea[65]; pLCD->VIDW01ADD1 = saveArea[66]; pLCD->VIDW00ADD2B0 = saveArea[67]; pLCD->VIDW00ADD2B1 = saveArea[68]; pLCD->VIDW01ADD2 = saveArea[69]; pLCD->VIDINTCON = saveArea[70]; pLCD->W1KEYCON0 = saveArea[71]; pLCD->W1KEYCON1 = saveArea[72]; pLCD->W2KEYCON0 = saveArea[73]; pLCD->W2KEYCON1 = saveArea[74]; pLCD->W3KEYCON0 = saveArea[75]; pLCD->W3KEYCON1 = saveArea[76]; pLCD->W4KEYCON0 = saveArea[77]; pLCD->W4KEYCON1 = saveArea[78]; pLCD->WIN0MAP = saveArea[79]; pLCD->WIN1MAP = saveArea[80]; pLCD->WPALCON = saveArea[81]; pLCD->SYSIFCON0 = saveArea[82]; pLCD->SYSIFCON1 = saveArea[83]; pLCD->DITHMODE = saveArea[84]; //[david.modify] 2008-06-19 15:21 //=========================== #if 0 delayLoop(100*LCD_DELAY_1MS); #endif //=========================== #if (BSP_TYPE == BSP_SMDK2443) #elif (BSP_TYPE == BSP_SMDK2450) OUTPORT32(&pIntr->INTMOD2, saveArea[85]); OUTPORT32(&pIntr->INTMSK2, saveArea[86]); #endif pCLKPWR->RSTCON |= pCLKPWR->RSTCON; // This is for control GPIO pads. #if (BSP_TYPE == BSP_SMDK2443) /* Interrupt Clear */ //OUTPORT32(&pIOPort->EINTPEND, INPORT32(&pIOPort->EINTPEND)); //OUTPORT32(&pIntr->SUBSRCPND, INPORT32(&pIntr->SUBSRCPND)); #elif (BSP_TYPE == BSP_SMDK2450) /* Interrupt Clear */ OUTPORT32(&pIOPort->EINTPEND, INPORT32(&pIOPort->EINTPEND)); OUTPORT32(&pIntr->SUBSRCPND, INPORT32(&pIntr->SUBSRCPND)); /* Interrupt Clear */ //OUTPORT32(&pIntr->SRCPND, INPORT32(&pIntr->SRCPND)); //OUTPORT32(&pIntr->INTPND, INPORT32(&pIntr->INTPND)); #endif // pLCD->LCDSRCPND = pLCD->LCDSRCPND; // pLCD->LCDINTPND = pLCD->LCDINTPND; // Do platform dependent power on actions BSPPowerOn(); }