armint.c
上传用户:qiulin1960
上传日期:2013-10-16
资源大小:2844k
文件大小:19k
源码类别:

Windows CE

开发平台:

Windows_Unix

  1. /*++
  2. THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  3. ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  4. THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  5. PARTICULAR PURPOSE.
  6. Copyright (c) 2001. Samsung Electronics, co. ltd  All rights reserved.
  7. Module Name:  
  8. Abstract:
  9. ARM920(S3C2440) interrupt service routine
  10. rev:
  11. 2002.4.3 : first S3C2410 version (SOC)
  12. 2002.2.5 : system tick modification (kwangyoon LEE, kwangyoon@samsung.com)
  13. - one shot timer
  14. 2002.1.29 : bug fixups (kwangyoon LEE, kwangyoon@samsung.com)
  15. - system tick interrupt
  16. 2002.1.28 : CE.NET port (kwangyoon LEE, kwangyoon@samsung.com)
  17. 2002.1.22 : Add USBD interrupt (kwangyoon LEE, kwangyoon@samsung.com)
  18. Notes: 
  19. --*/
  20. #include <windows.h>
  21. #include <nkintr.h>
  22. #include <oalintr.h>
  23. #include "p2.h"
  24. #include "p2debug.h"
  25. #include "drv_glob.h"
  26. #include <S2440.h>
  27. #define SDIO_FOR_100BD 0
  28. extern DWORD CurMSec;
  29. extern DWORD DiffMSec;
  30. #if (CE_MAJOR_VER == 0x0003)
  31. extern DWORD ticksleft, dwSleepMin, dwPreempt;
  32. extern DWORD DiffMSec;
  33. #else
  34. extern DWORD dwReschedTime;
  35. #endif
  36. extern DWORD AlarmTime;
  37. extern volatile LARGE_INTEGER CurTicks;
  38. extern DWORD dwReschedIncrement;
  39. extern int (*PProfileInterrupt)(void);
  40. extern DWORD dwIsrTime1, dwIsrTime2;
  41. extern BOOL fIntrTime, fIntrTimeToggle;
  42. extern WORD wNumInterrupts;    // Reset by a read of the ISR times from the IST
  43. extern DWORD dwIntrTimeCountdown;
  44. extern DWORD dwIntrTimeCountdownRef;
  45. extern DWORD dwSPC;
  46. extern DWORD PerfCountSinceTick();
  47. extern BOOL fInterruptFlag;
  48. extern VOID CPUPowerReset();
  49. extern VOID OEMEmergencyPowerOff();
  50. static USBD_GLOBALS *usbdShMem=&((DRIVER_GLOBALS *)DRIVER_GLOBALS_PHYSICAL_MEMORY_START)->usbd; //:-)
  51. void UsbdClearEir(void);  //:-)
  52. DWORD OEMTranslateIrq(DWORD dwIrq)
  53. {
  54.     return dwIrq;
  55. }
  56. DWORD OEMTranslateSysIntr(DWORD SysIntr)
  57. {
  58.     return (SysIntr<SYSINTR_FIRMWARE?(DWORD)-1:SysIntr);
  59. }
  60. void OEMInterruptHandlerFIQ() 
  61. {
  62. // This FIQ interrupt is from BAT_FLT.
  63. volatile IOPreg *s2440IOP = (IOPreg *)IOP_BASE;
  64. volatile INTreg *s2440INT = (INTreg *)INT_BASE;
  65. s2440IOP->rGPFDAT = ~(0xa << 4);   /* LED Off */
  66. OEMEmergencyPowerOff();
  67. while(1);
  68. // RETAILMSG(1, (TEXT(">>> OEMInterruptHandlerFIQ rn")));
  69. }
  70. int flag = 1;
  71. unsigned int tCnt = 0;
  72. unsigned int ttt = 0;
  73. int OEMInterruptHandler(unsigned int ra) 
  74. {
  75. static BYTE nLED = 0x1;
  76. volatile INTreg *s2440INT = (INTreg *)INT_BASE;
  77. volatile IOPreg *s2440IOP = (IOPreg *)IOP_BASE;
  78. volatile PWMreg *s2440PWM = (PWMreg *)PWM_BASE;
  79. volatile MMCreg *s2440SDIO = (MMCreg *)MMC_BACE;
  80. unsigned int IntPendVal;
  81. unsigned int SubIntPendVal; // for serial
  82. DWORD submask;
  83. // jylee
  84. volatile ADCreg *s2440ADC = (ADCreg *)ADC_BASE;
  85. static DWORD HeartBeatCnt, HeartBeatStat;
  86. static volatile struct udcreg *s2440USBD = (volatile struct udcreg *)(0xB1200140); // 0xB1200140
  87. volatile BYTE usbd_eir = 0, usbd_uir = 0;
  88.     TOUCH_GLOBALS *odo_tsb;  //Sample buffer stuff
  89.     // for this, You MUST modify bsp/inc/drv_glob.h.. check drv_glob.h_jylee
  90.     odo_tsb = &((DRIVER_GLOBALS *)DRIVER_GLOBALS_PHYSICAL_MEMORY_START)->tch;
  91. // Update LEDs.
  92. //
  93. // if (nLED++ > 0xf) nLED = 0;
  94. // OEMWriteDebugLED(0, ~nLED);
  95.     
  96. IntPendVal = s2440INT->rINTOFFSET; // Get pending IRQ mode interrupt in INTPND.
  97.     
  98. // Fake CPUEnterIdle needs to know about interrupt firing.
  99. fInterruptFlag = TRUE;
  100.     if (fIntrTime) {
  101.         //
  102.         // We're doing interrupt timing. Get Time to ISR. We subtract TIMER_COUNTDOWN
  103.         // here because the compare register has not been updated.
  104.         //
  105.         dwIsrTime1 = PerfCountSinceTick() - dwReschedIncrement;
  106.         dwSPC = ra;
  107.         wNumInterrupts++;
  108.     }
  109. //
  110. // Check the timer interrupt.
  111. //
  112. if (IntPendVal == INTSRC_TIMER4) 
  113. {
  114. DWORD ttmp;
  115.         if (++HeartBeatCnt > 10)
  116.         {
  117.             HeartBeatCnt   = 0;
  118.             HeartBeatStat ^= 1;
  119.             if (HeartBeatStat)                        
  120.                 s2440IOP->rGPFDAT &= ~(1 << 4); /* LED 0 On                 */
  121.             else
  122.                 s2440IOP->rGPFDAT |=  (1 << 4); /* LED 0 Off                */
  123.         }
  124.                              
  125. s2440PWM->rTCNTB4 = dwReschedIncrement;
  126.                              
  127. ttmp = s2440PWM->rTCON & (~(0xf << 20));
  128.                              
  129. s2440PWM->rTCON = ttmp | (2 << 20); /* update TCVNTB4, stop */
  130. s2440PWM->rTCON = ttmp | (1 << 20); /* one-shot mode,  start */
  131.                              
  132. // Update the tick counter.
  133. //
  134. CurTicks.QuadPart += dwReschedIncrement;
  135.                                      
  136. // Call the profile ISR if it's enabled.
  137. //
  138.         if (PProfileInterrupt)
  139.         {
  140. DWORD dwRetVal = SYSINTR_NOP;
  141. dwRetVal = PProfileInterrupt();
  142.             if (dwRetVal == SYSINTR_RESCHED)
  143. {
  144. // Update the millisecond counter.
  145. //
  146. CurMSec  += RESCHED_PERIOD;
  147. #if (CE_MAJOR_VER == 0x0003)
  148.                 DiffMSec += RESCHED_PERIOD;
  149. #endif
  150.             }
  151. // Clear the interrupt
  152. //
  153. s2440INT->rSRCPND = BIT_TIMER4;        
  154. if (s2440INT->rINTPND & BIT_TIMER4) s2440INT->rINTPND = BIT_TIMER4;
  155.             // Return whatever we got back from the profiling ISR.
  156. //
  157.             return(dwRetVal);
  158.         }
  159. // Update the millisecond counter.
  160. //
  161. #if (CE_MAJOR_VER == 0x0003)
  162. DiffMSec += RESCHED_PERIOD;
  163. #endif
  164. CurMSec  += RESCHED_PERIOD;
  165. //
  166. // Clear the interrupt
  167. //
  168. s2440INT->rSRCPND = BIT_TIMER4;        
  169. if (s2440INT->rINTPND & BIT_TIMER4) s2440INT->rINTPND = BIT_TIMER4;
  170.                              
  171. if (fIntrTime) 
  172. {
  173. //
  174. // We're doing interrupt timing. Every other tick is a RESCHED.
  175. //
  176. dwIntrTimeCountdown--;
  177.                                                                           
  178. if (dwIntrTimeCountdown == 0) 
  179. {
  180. dwIntrTimeCountdown = dwIntrTimeCountdownRef;
  181. wNumInterrupts = 0;
  182.                                                                               
  183. dwIsrTime2 = PerfCountSinceTick();
  184. return (SYSINTR_TIMING);
  185. } else {
  186. #if (CE_MAJOR_VER == 0x0003)
  187. if (ticksleft || (dwSleepMin && (dwSleepMin <= DiffMSec)) || (dwPreempt && (dwPreempt <= DiffMSec)))
  188. #else
  189. if ((int) (CurMSec - dwReschedTime) >= 0)
  190. #endif
  191. return(SYSINTR_RESCHED);
  192. }    
  193. } else {
  194. #if (CE_MAJOR_VER == 0x0003)
  195. if (ticksleft || (dwSleepMin && (DiffMSec >= dwSleepMin)) || (dwPreempt && (DiffMSec >= dwPreempt)))
  196. #else
  197. if ((int) (CurMSec - dwReschedTime) >= 0)
  198. #endif
  199.                              
  200. {
  201. return(SYSINTR_RESCHED);
  202. }
  203. return(SYSINTR_NOP);
  204. }
  205. else if(IntPendVal == INTSRC_MMC) // SD, MMC
  206. {
  207. s2440INT->rINTMSK |= BIT_MMC;
  208.         s2440INT->rSRCPND = BIT_MMC;        
  209.         if (s2440INT->rINTPND & BIT_MMC) s2440INT->rINTPND = BIT_MMC;
  210. // RETAILMSG(1, (TEXT("ARMINT.C-INT:INTSRC_MMC INTrn")));
  211. if( s2440SDIO->rSDIDATSTA & (0x1<<9) ){
  212. // RETAILMSG(1, (TEXT("INT:SYSINTR_SDMMC_SDIO_INTERRUPT INTrn")));
  213. return SYSINTR_SDMMC_SDIO_INTERRUPT;
  214. }
  215. else {
  216. // RETAILMSG(1, (TEXT("INT:SYSINTR_SDMMC INTrn")));
  217. return SYSINTR_SDMMC;
  218. }
  219. }
  220. else if(IntPendVal == INTSRC_DMA0) // SD DMA interrupt
  221. {
  222. s2440INT->rINTMSK |= BIT_DMA0;
  223. s2440INT->rSRCPND = BIT_DMA0;
  224. if (s2440INT->rINTPND & BIT_DMA0) s2440INT->rINTPND = BIT_DMA0;
  225. return SYSINTR_DMA0;
  226. }
  227. else if (IntPendVal == INTSRC_EINT1) // Keyboard interrupt is connected to EINT1.
  228. s2440INT->rINTMSK |= BIT_EINT1;
  229. s2440INT->rSRCPND  = BIT_EINT1;        
  230. if (s2440INT->rINTPND & BIT_EINT1) s2440INT->rINTPND  = BIT_EINT1;
  231. return(SYSINTR_KEYBOARD);
  232. else if (IntPendVal == INTSRC_EINT2) // EINT2
  233. s2440IOP->rGPBCON &= ~(3<<18);
  234. s2440IOP->rGPBCON |=  (1<<18);
  235. s2440IOP->rGPBUP  |=  (1<<9);
  236. s2440IOP->rGPBDAT &= ~(1<<9);
  237. s2440INT->rINTMSK |= BIT_EINT2;
  238. s2440INT->rSRCPND  = BIT_EINT2; /* Interrupt Clear */
  239. if (s2440INT->rINTPND & BIT_EINT2) s2440INT->rINTPND  = BIT_EINT2;
  240. // RETAILMSG(1, (TEXT(">>> CPUPowerReset rn")));
  241. //RETAILMSG(1,(TEXT(">>> >>> Reset Button Pressed <<< <<< rn")));
  242. CPUPowerReset();
  243. return(SYSINTR_POWER);
  244. }
  245. else if (IntPendVal == INTSRC_EINT3) // PCMCIA interrupt is connected to EINT3. (nINT_P_DEV)
  246.     s2440INT->rINTMSK |= BIT_EINT3;
  247.     s2440INT->rSRCPND  =  BIT_EINT3;        
  248.     if (s2440INT->rINTPND & BIT_EINT3) s2440INT->rINTPND = BIT_EINT3;
  249.                            
  250.     return(SYSINTR_PCMCIA_STATE);
  251. }  
  252. else if (IntPendVal == INTSRC_EINT8_23) // EINT8 ~ 23
  253. ///s2440INT->rINTMSK |= BIT_EINT8_23;
  254. ///submask = s2440IOP->rEINTPEND;
  255. DWORD dwSubMask = s2440IOP->rEINTPEND & (~s2440IOP->rEINTMASK);
  256. ///if ( submask & (1 << 9)) // 0x200 EINT9 : CS8900
  257. if ( dwSubMask & (1 << 9)) // 0x200 EINT9 : CS8900
  258. {
  259. s2440IOP->rEINTMASK |= 0x200;
  260. s2440IOP->rEINTPEND = 0x200;
  261. s2440INT->rSRCPND = BIT_EINT8_23;        
  262. if (s2440INT->rINTPND & BIT_EINT8_23) s2440INT->rINTPND = BIT_EINT8_23;
  263. // RETAILMSG(1, (TEXT("INT:SYSINTR_ETHER INT s2440IOP->rEINTMASK = 0x%8x, s2440IOP->rEINTMASKrn")));
  264. // RETAILMSG(1, (TEXT("INT:SYSINTR_ETHER INT s2440IOP->rEINTPEND = 0x%8x, s2440IOP->rEINTPENDrn")));
  265. return SYSINTR_ETHER;
  266. }
  267. #if SDIO_FOR_100BD // for b'd revision 1.00
  268. ///if ( submask & (1 << 18)) // EINT28 : SDMMC_CARD_DETECT
  269. if ( dwSubMask & (1 << 18)) // EINT28 : SDMMC_CARD_DETECT
  270. {
  271. s2440IOP->rEINTMASK |= (1 << 18);
  272. s2440IOP->rEINTPEND  = (1 << 18);
  273. s2440INT->rSRCPND  = BIT_EINT8_23;
  274. if (s2440INT->rINTPND & BIT_EINT8_23) 
  275. s2440INT->rINTPND = BIT_EINT8_23;
  276. // RETAILMSG(1, (TEXT("ARMINT.C - SYSINTR_SDMMC_CARD_DETECT rEINTMASK = 0x%8x, s2440IOP->rEINTMASKrn")));
  277.  RETAILMSG(1, (TEXT("ARMINT.C - SYSINTR_SDMMC_CARD_DETECT rEINTPEND = 0x%8x, s2440IOP->rEINTPENDrn")));
  278. return SYSINTR_SDMMC_CARD_DETECT;
  279. }
  280. #else // for b'd revision 0.17
  281. if ( s2440IOP->rEINTPEND & (1 << 16)) // SD Card Detect
  282. {
  283. s2440IOP->rEINTMASK |= (1 << 16);
  284. s2440IOP->rEINTPEND  = (1 << 16);
  285. s2440INT->rSRCPND  = BIT_EINT8_23;
  286. if (s2440INT->rINTPND & BIT_EINT8_23) 
  287. s2440INT->rINTPND  = BIT_EINT8_23;
  288. return SYSINTR_SDMMC_CARD_DETECT;
  289. }
  290. #endif
  291. //else if (submask & (1 << 8)) // 0x100 EINT8 : PCMCIA_LEVEL
  292. else if (dwSubMask & (1 << 8)) // 0x100 EINT8 : PCMCIA_LEVEL
  293. {
  294. s2440IOP->rEINTMASK |= 0x100;
  295. s2440IOP->rEINTPEND = 0x100;
  296. s2440INT->rSRCPND = BIT_EINT8_23;        
  297. if (s2440INT->rINTPND & BIT_EINT8_23) s2440INT->rINTPND = BIT_EINT8_23;
  298. //RETAILMSG(1, (TEXT("INT:SYSINTR_PCMCIA_LEVEL INTrn")));
  299. return SYSINTR_PCMCIA_LEVEL;
  300. }
  301. else
  302. {
  303. s2440INT->rSRCPND = BIT_EINT8_23;        
  304. if (s2440INT->rINTPND & BIT_EINT8_23) s2440INT->rINTPND = BIT_EINT8_23;
  305. //RETAILMSG(0, (TEXT("INT:???rn")));
  306. //return SYSINTR_NOP;
  307. }
  308. }
  309. else if (IntPendVal == INTSRC_ADC) // INTSRC_ADC
  310. {
  311.         // Touch Panel Int
  312.         SubIntPendVal = s2440INT->rSUBSRCPND;
  313.        
  314.         if(SubIntPendVal & INTSUB_TC) 
  315. {
  316.         s2440INT->rINTSUBMSK |= INTSUB_TC;
  317.         s2440INT->rSUBSRCPND  = INTSUB_TC;
  318.        
  319.             s2440INT->rINTMSK |= BIT_ADC;
  320.             s2440INT->rSRCPND  = BIT_ADC;        
  321.             if (s2440INT->rINTPND & BIT_ADC) s2440INT->rINTPND = BIT_ADC;
  322.            
  323. if( (s2440ADC->rADCDAT0 & 0x8000) || (s2440ADC->rADCDAT1 & 0x8000) )
  324. {
  325. s2440INT->rINTMSK |= BIT_TIMER1;     // Mask timer1 interrupt.
  326.     s2440INT->rSRCPND = BIT_TIMER1;     // Clear pending bit
  327.     if (s2440INT->rINTPND & BIT_TIMER1) s2440INT->rINTPND = BIT_TIMER1;
  328. //RETAILMSG(0,(TEXT("INT Touch pen up rn")));
  329.                odo_tsb->status = TOUCH_PEN_UP;
  330.        }
  331. else
  332. {
  333. //RETAILMSG(0,(TEXT("INT Touch pen down rn")));
  334.                 odo_tsb->status = TOUCH_PEN_DOWN;
  335. }
  336.        
  337.         return SYSINTR_TOUCH_CHANGED;
  338. }
  339.         else if(SubIntPendVal & INTSUB_ADC)
  340. {
  341.         s2440INT->rINTSUBMSK |= INTSUB_ADC;
  342.         s2440INT->rSUBSRCPND = INTSUB_ADC;
  343.         s2440INT->rINTMSK |= BIT_ADC;
  344.         s2440INT->rSRCPND = BIT_ADC;        
  345.         if (s2440INT->rINTPND & BIT_ADC) s2440INT->rINTPND = BIT_ADC;
  346.             
  347.          s2440INT->rINTMSK &= ~BIT_ADC;
  348.             return SYSINTR_NOP;
  349.         }
  350.         else
  351.         return SYSINTR_NOP;
  352. }
  353. else if (IntPendVal == INTSRC_TIMER1) // INTSRC_TIMER1
  354. {
  355.        // Timer 1 interrupt to get touch point
  356.        s2440INT->rINTMSK |= BIT_TIMER1;
  357.         s2440INT->rSRCPND = BIT_TIMER1;
  358.        if (s2440INT->rINTPND & BIT_TIMER1) s2440INT->rINTPND = BIT_TIMER1;
  359. // charlie, 020620
  360. if( (s2440ADC->rADCDAT0 & 0x8000) || (s2440ADC->rADCDAT1 & 0x8000) )
  361. {
  362. //RETAILMSG(0,(TEXT("INT Touch SYSINTR_TOUCH_CHANGED 1rn")));
  363. odo_tsb->status = TOUCH_PEN_UP;
  364. return SYSINTR_TOUCH_CHANGED;
  365. }
  366.         if(odo_tsb->status == TOUCH_PEN_UP) 
  367. {
  368. //RETAILMSG(0,(TEXT("INT Touch SYSINTR_TOUCH_CHANGED 2 rn")));
  369. odo_tsb->status = TOUCH_PEN_UP;
  370. return SYSINTR_TOUCH_CHANGED;
  371. }
  372.         else 
  373. {
  374. unsigned int TmpTCON;
  375.          odo_tsb->status = TOUCH_PEN_SAMPLE;
  376. TmpTCON = s2440PWM->rTCON; // get TCON value to temp TCON register
  377. TmpTCON &= ~0xf00;      // clear fields of Timer 1 
  378. TmpTCON |= 0x200;      // interval mode(auto reload), update TCVNTB4, stop 
  379. s2440PWM->rTCON = TmpTCON; // put the value to TCON register
  380. TmpTCON = s2440PWM->rTCON; // get TCON value to temp TCON register
  381. TmpTCON &= ~0xf00;      // clear fields of Timer 1 
  382. TmpTCON |= 0x100;      // interval mode, no operation, start for Timer 4 
  383. s2440PWM->rTCON = TmpTCON; // put the value to TCON register
  384. //RETAILMSG(0,(TEXT("INT Touch SYSINTR_TOUCHrn")));
  385.          return SYSINTR_TOUCH;
  386. }
  387. }
  388. else if (IntPendVal == INTSRC_EINT0) // POWER BUTTON
  389. s2440INT->rINTMSK |= BIT_EINT0;
  390. s2440INT->rSRCPND  = BIT_EINT0; // Interrupt Clear
  391. if (s2440INT->rINTPND & BIT_EINT0) s2440INT->rINTPND  = BIT_EINT0;
  392. return(SYSINTR_POWER);
  393. }
  394. else if(IntPendVal == INTSRC_DMA1) // AUDIO DMA input.
  395. {  
  396. s2440INT->rINTMSK |= BIT_DMA1;
  397. s2440INT->rSRCPND  = BIT_DMA1;
  398. if (s2440INT->rINTPND & BIT_DMA1) s2440INT->rINTPND  = BIT_DMA1;
  399. return(SYSINTR_AUDIO);
  400. }
  401. else if(IntPendVal == INTSRC_DMA2) // AUDIO DMA output.
  402. {  
  403. s2440INT->rINTMSK |= BIT_DMA2;
  404. s2440INT->rSRCPND  = BIT_DMA2;
  405. if (s2440INT->rINTPND & BIT_DMA2) s2440INT->rINTPND  = BIT_DMA2;
  406. return(SYSINTR_AUDIO);
  407. }
  408. else if(IntPendVal == INTSRC_USBH)  // USB.
  409. {
  410. s2440INT->rINTMSK |= BIT_USBH;
  411. s2440INT->rSRCPND  = BIT_USBH;        
  412. if (s2440INT->rINTPND & BIT_USBH) s2440INT->rINTPND  = BIT_USBH;
  413. //RETAILMSG(1, (TEXT("INT:SYSINTR_USB INTrn")));
  414. return(SYSINTR_USB);     
  415. else if (IntPendVal == INTSRC_DMA3)
  416. {
  417. s2440INT->rINTMSK |= BIT_USBD; // USBD interrupt should be masked
  418. //s2440INT->rINTMSK |= BIT_DMA3;
  419. s2440INT->rSRCPND = BIT_DMA3;
  420. if (s2440INT->rINTPND & BIT_DMA3) s2440INT->rINTPND = BIT_DMA3;
  421. usbdShMem->usbdDma3Int=1;
  422. return SYSINTR_USBD;  
  423. //Correct. DMA3 interrupt will be connected to USBD interrupt.
  424. //break;
  425. }
  426. else if(IntPendVal == INTSRC_USBD) 
  427. {
  428. s2440INT->rINTMSK |= BIT_USBD;
  429. UsbdClearEir();  //:-)
  430. s2440INT->rSRCPND = BIT_USBD;
  431. if (s2440INT->rINTPND & BIT_USBD) s2440INT->rINTPND = BIT_USBD;
  432. RETAILMSG(0,(TEXT("INT_USBDrn")));
  433. return SYSINTR_USBD;
  434.     }
  435. else if(IntPendVal == INTSRC_UART0) // SERIAL (UART0) (physical COM1: P1 connector).
  436. {  
  437. SubIntPendVal = s2440INT->rSUBSRCPND;
  438. // Note that we only mask the sub source interrupt - the serial driver will clear the
  439. // sub source pending register.
  440. //
  441. if(SubIntPendVal & INTSUB_ERR0) 
  442. {
  443. s2440INT->rINTSUBMSK |= INTSUB_ERR0;
  444. }
  445. else if(SubIntPendVal & INTSUB_RXD0) 
  446. {
  447. s2440INT->rINTSUBMSK |= INTSUB_RXD0;
  448. #if USE_AFC
  449. // by 0212.
  450. s2440IOP->rGPHDAT |= (0x2);  // Deassert nRTS
  451. #endif
  452. }
  453. else if(SubIntPendVal & INTSUB_TXD0) 
  454. {
  455. s2440INT->rINTSUBMSK |= INTSUB_TXD0;
  456. }
  457. else
  458. {
  459. return(SYSINTR_NOP);
  460. }
  461. // NOTE: Don't clear INTSRC:UART0 here - serial driver does that.
  462. //
  463. s2440INT->rINTMSK |= BIT_UART0;
  464. if (s2440INT->rINTPND & BIT_UART0) s2440INT->rINTPND  = BIT_UART0;
  465. return(SYSINTR_SERIAL);
  466. }
  467. else if(IntPendVal == INTSRC_UART2) // IrDA (UART2)
  468. {
  469. SubIntPendVal = s2440INT->rSUBSRCPND;
  470. if(SubIntPendVal & INTSUB_ERR2) 
  471. {
  472. s2440INT->rINTSUBMSK |= INTSUB_ERR2;
  473. }       
  474. else if(SubIntPendVal & INTSUB_RXD2) 
  475. {
  476. s2440INT->rINTSUBMSK |= INTSUB_RXD2;
  477. }       
  478. else if(SubIntPendVal & INTSUB_TXD2) 
  479. {
  480. s2440INT->rINTSUBMSK |= INTSUB_TXD2;
  481. }       
  482. else
  483. {
  484. return(SYSINTR_NOP);
  485. }
  486. // NOTE: Don't clear INTSRC:UART2 here - serial driver does that.
  487. //
  488. s2440INT->rINTMSK |= BIT_UART2;
  489. if (s2440INT->rINTPND & BIT_UART2) s2440INT->rINTPND  = BIT_UART2;
  490. return(SYSINTR_IR);
  491. }
  492. else if (IntPendVal == INTSRC_RTC) // for alarm. 030818
  493. s2440INT->rSRCPND  = BIT_RTC;   // Interrupt Clear
  494. s2440INT->rINTPND  = BIT_RTC;
  495. s2440INT->rINTMSK |= BIT_RTC;   // Alarm Interrupt Disable
  496. return SYSINTR_RTC_ALARM;
  497. }
  498. else if(IntPendVal == INTSRC_CAM) 
  499. {
  500. // RETAILMSG(1,(TEXT("INT:SYSINTR_CAM INT:0x%x,0x%xrn"),s2440INT->rSRCPND,s2440INT->rSUBSRCPND));
  501. if( s2440INT->rSUBSRCPND & (0x1<<11) )
  502. {
  503. s2440INT->rINTSUBMSK |= (0x1<<11);
  504. s2440INT->rINTMSK |= BIT_CAM;
  505. s2440INT->rSUBSRCPND = (0x1<<11);
  506. s2440INT->rSRCPND = BIT_CAM;
  507. if (s2440INT->rINTPND & BIT_CAM) s2440INT->rINTPND = BIT_CAM;
  508. return SYSINTR_CAM;
  509. }
  510. else if (s2440INT->rSUBSRCPND & BIT_SUB_CAM_P)
  511. {
  512. s2440INT->rINTSUBMSK |= (0x2<<11);
  513. s2440INT->rINTMSK |= BIT_CAM;
  514. s2440INT->rSUBSRCPND = (0x2<<11);
  515. s2440INT->rSRCPND = BIT_CAM;
  516. if (s2440INT->rINTPND & BIT_CAM) s2440INT->rINTPND = BIT_CAM;
  517. return SYSINTR_CAM;
  518. }
  519. s2440INT->rINTSUBMSK |= (BIT_SUB_CAM_C | BIT_SUB_CAM_P);
  520. s2440INT->rINTMSK |= BIT_CAM;
  521. s2440INT->rSUBSRCPND = (BIT_SUB_CAM_C | BIT_SUB_CAM_P);
  522. s2440INT->rSRCPND = BIT_CAM;
  523. if (s2440INT->rINTPND & BIT_CAM)
  524. {
  525. s2440INT->rINTPND = BIT_CAM;
  526. }
  527. return SYSINTR_NOP;
  528. }
  529. else if(IntPendVal == INTSRC_IIC) 
  530. {
  531. s2440INT->rINTMSK |= BIT_IIC;
  532. s2440INT->rSRCPND = BIT_IIC;
  533. if (s2440INT->rINTPND & BIT_IIC) s2440INT->rINTPND = BIT_IIC;
  534. // RETAILMSG(1,(TEXT("IIC Interruptrn")));
  535. return SYSINTR_IIC;
  536. }
  537. return(SYSINTR_NOP);
  538. }
  539. void UsbdClearEir(void)
  540. {
  541. static volatile struct udcreg *s2440USBD = (volatile struct udcreg *)(0xB1200140);
  542. usbdShMem->usbdEir|=*(volatile BYTE *)&s2440USBD->EIR;
  543. usbdShMem->usbdUir|=*(volatile BYTE *)&s2440USBD->UIR;
  544. *(volatile BYTE *)&s2440USBD->EIR=usbdShMem->usbdEir;
  545. *(volatile BYTE *)&s2440USBD->UIR=usbdShMem->usbdUir;
  546. }