irq.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790
  1. /* linux/arch/arm/plat-s3c24xx/irq.c
  2. *
  3. * Copyright (c) 2003,2004 Simtec Electronics
  4. * Ben Dooks <ben@simtec.co.uk>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. * Changelog:
  21. *
  22. * 22-Jul-2004 Ben Dooks <ben@simtec.co.uk>
  23. * Fixed compile warnings
  24. *
  25. * 22-Jul-2004 Roc Wu <cooloney@yahoo.com.cn>
  26. * Fixed s3c_extirq_type
  27. *
  28. * 21-Jul-2004 Arnaud Patard (Rtp) <arnaud.patard@rtp-net.org>
  29. * Addition of ADC/TC demux
  30. *
  31. * 04-Oct-2004 Klaus Fetscher <k.fetscher@fetron.de>
  32. * Fix for set_irq_type() on low EINT numbers
  33. *
  34. * 05-Oct-2004 Ben Dooks <ben@simtec.co.uk>
  35. * Tidy up KF's patch and sort out new release
  36. *
  37. * 05-Oct-2004 Ben Dooks <ben@simtec.co.uk>
  38. * Add support for power management controls
  39. *
  40. * 04-Nov-2004 Ben Dooks
  41. * Fix standard IRQ wake for EINT0..4 and RTC
  42. *
  43. * 22-Feb-2005 Ben Dooks
  44. * Fixed edge-triggering on ADC IRQ
  45. *
  46. * 28-Jun-2005 Ben Dooks
  47. * Mark IRQ_LCD valid
  48. *
  49. * 25-Jul-2005 Ben Dooks
  50. * Split the S3C2440 IRQ code to separate file
  51. */
  52. #include <linux/init.h>
  53. #include <linux/module.h>
  54. #include <linux/interrupt.h>
  55. #include <linux/ioport.h>
  56. #include <linux/sysdev.h>
  57. #include <linux/io.h>
  58. #include <mach/hardware.h>
  59. #include <asm/irq.h>
  60. #include <asm/mach/irq.h>
  61. #include <mach/regs-irq.h>
  62. #include <mach/regs-gpio.h>
  63. #include <plat/cpu.h>
  64. #include <plat/pm.h>
  65. #include <plat/irq.h>
  66. /* wakeup irq control */
  67. #ifdef CONFIG_PM
  68. /* state for IRQs over sleep */
  69. /* default is to allow for EINT0..EINT15, and IRQ_RTC as wakeup sources
  70. *
  71. * set bit to 1 in allow bitfield to enable the wakeup settings on it
  72. */
  73. unsigned long s3c_irqwake_intallow = 1L << (IRQ_RTC - IRQ_EINT0) | 0xfL;
  74. unsigned long s3c_irqwake_intmask = 0xffffffffL;
  75. unsigned long s3c_irqwake_eintallow = 0x0000fff0L;
  76. unsigned long s3c_irqwake_eintmask = 0xffffffffL;
  77. int
  78. s3c_irq_wake(unsigned int irqno, unsigned int state)
  79. {
  80. unsigned long irqbit = 1 << (irqno - IRQ_EINT0);
  81. if (!(s3c_irqwake_intallow & irqbit))
  82. return -ENOENT;
  83. printk(KERN_INFO "wake %s for irq %d\n",
  84. state ? "enabled" : "disabled", irqno);
  85. if (!state)
  86. s3c_irqwake_intmask |= irqbit;
  87. else
  88. s3c_irqwake_intmask &= ~irqbit;
  89. return 0;
  90. }
  91. static int
  92. s3c_irqext_wake(unsigned int irqno, unsigned int state)
  93. {
  94. unsigned long bit = 1L << (irqno - EXTINT_OFF);
  95. if (!(s3c_irqwake_eintallow & bit))
  96. return -ENOENT;
  97. printk(KERN_INFO "wake %s for irq %d\n",
  98. state ? "enabled" : "disabled", irqno);
  99. if (!state)
  100. s3c_irqwake_eintmask |= bit;
  101. else
  102. s3c_irqwake_eintmask &= ~bit;
  103. return 0;
  104. }
  105. #else
  106. #define s3c_irqext_wake NULL
  107. #define s3c_irq_wake NULL
  108. #endif
  109. static void
  110. s3c_irq_mask(unsigned int irqno)
  111. {
  112. unsigned long mask;
  113. irqno -= IRQ_EINT0;
  114. mask = __raw_readl(S3C2410_INTMSK);
  115. mask |= 1UL << irqno;
  116. __raw_writel(mask, S3C2410_INTMSK);
  117. }
  118. static inline void
  119. s3c_irq_ack(unsigned int irqno)
  120. {
  121. unsigned long bitval = 1UL << (irqno - IRQ_EINT0);
  122. __raw_writel(bitval, S3C2410_SRCPND);
  123. __raw_writel(bitval, S3C2410_INTPND);
  124. }
  125. static inline void
  126. s3c_irq_maskack(unsigned int irqno)
  127. {
  128. unsigned long bitval = 1UL << (irqno - IRQ_EINT0);
  129. unsigned long mask;
  130. mask = __raw_readl(S3C2410_INTMSK);
  131. __raw_writel(mask|bitval, S3C2410_INTMSK);
  132. __raw_writel(bitval, S3C2410_SRCPND);
  133. __raw_writel(bitval, S3C2410_INTPND);
  134. }
  135. static void
  136. s3c_irq_unmask(unsigned int irqno)
  137. {
  138. unsigned long mask;
  139. if (irqno != IRQ_TIMER4 && irqno != IRQ_EINT8t23)
  140. irqdbf2("s3c_irq_unmask %d\n", irqno);
  141. irqno -= IRQ_EINT0;
  142. mask = __raw_readl(S3C2410_INTMSK);
  143. mask &= ~(1UL << irqno);
  144. __raw_writel(mask, S3C2410_INTMSK);
  145. }
  146. struct irq_chip s3c_irq_level_chip = {
  147. .name = "s3c-level",
  148. .ack = s3c_irq_maskack,
  149. .mask = s3c_irq_mask,
  150. .unmask = s3c_irq_unmask,
  151. .set_wake = s3c_irq_wake
  152. };
  153. struct irq_chip s3c_irq_chip = {
  154. .name = "s3c",
  155. .ack = s3c_irq_ack,
  156. .mask = s3c_irq_mask,
  157. .unmask = s3c_irq_unmask,
  158. .set_wake = s3c_irq_wake
  159. };
  160. static void
  161. s3c_irqext_mask(unsigned int irqno)
  162. {
  163. unsigned long mask;
  164. irqno -= EXTINT_OFF;
  165. mask = __raw_readl(S3C24XX_EINTMASK);
  166. mask |= ( 1UL << irqno);
  167. __raw_writel(mask, S3C24XX_EINTMASK);
  168. }
  169. static void
  170. s3c_irqext_ack(unsigned int irqno)
  171. {
  172. unsigned long req;
  173. unsigned long bit;
  174. unsigned long mask;
  175. bit = 1UL << (irqno - EXTINT_OFF);
  176. mask = __raw_readl(S3C24XX_EINTMASK);
  177. __raw_writel(bit, S3C24XX_EINTPEND);
  178. req = __raw_readl(S3C24XX_EINTPEND);
  179. req &= ~mask;
  180. /* not sure if we should be acking the parent irq... */
  181. if (irqno <= IRQ_EINT7 ) {
  182. if ((req & 0xf0) == 0)
  183. s3c_irq_ack(IRQ_EINT4t7);
  184. } else {
  185. if ((req >> 8) == 0)
  186. s3c_irq_ack(IRQ_EINT8t23);
  187. }
  188. }
  189. static void
  190. s3c_irqext_unmask(unsigned int irqno)
  191. {
  192. unsigned long mask;
  193. irqno -= EXTINT_OFF;
  194. mask = __raw_readl(S3C24XX_EINTMASK);
  195. mask &= ~( 1UL << irqno);
  196. __raw_writel(mask, S3C24XX_EINTMASK);
  197. }
  198. int
  199. s3c_irqext_type(unsigned int irq, unsigned int type)
  200. {
  201. void __iomem *extint_reg;
  202. void __iomem *gpcon_reg;
  203. unsigned long gpcon_offset, extint_offset;
  204. unsigned long newvalue = 0, value;
  205. if ((irq >= IRQ_EINT0) && (irq <= IRQ_EINT3))
  206. {
  207. gpcon_reg = S3C2410_GPFCON;
  208. extint_reg = S3C24XX_EXTINT0;
  209. gpcon_offset = (irq - IRQ_EINT0) * 2;
  210. extint_offset = (irq - IRQ_EINT0) * 4;
  211. }
  212. else if ((irq >= IRQ_EINT4) && (irq <= IRQ_EINT7))
  213. {
  214. gpcon_reg = S3C2410_GPFCON;
  215. extint_reg = S3C24XX_EXTINT0;
  216. gpcon_offset = (irq - (EXTINT_OFF)) * 2;
  217. extint_offset = (irq - (EXTINT_OFF)) * 4;
  218. }
  219. else if ((irq >= IRQ_EINT8) && (irq <= IRQ_EINT15))
  220. {
  221. gpcon_reg = S3C2410_GPGCON;
  222. extint_reg = S3C24XX_EXTINT1;
  223. gpcon_offset = (irq - IRQ_EINT8) * 2;
  224. extint_offset = (irq - IRQ_EINT8) * 4;
  225. }
  226. else if ((irq >= IRQ_EINT16) && (irq <= IRQ_EINT23))
  227. {
  228. gpcon_reg = S3C2410_GPGCON;
  229. extint_reg = S3C24XX_EXTINT2;
  230. gpcon_offset = (irq - IRQ_EINT8) * 2;
  231. extint_offset = (irq - IRQ_EINT16) * 4;
  232. } else
  233. return -1;
  234. /* Set the GPIO to external interrupt mode */
  235. value = __raw_readl(gpcon_reg);
  236. value = (value & ~(3 << gpcon_offset)) | (0x02 << gpcon_offset);
  237. __raw_writel(value, gpcon_reg);
  238. /* Set the external interrupt to pointed trigger type */
  239. switch (type)
  240. {
  241. case IRQ_TYPE_NONE:
  242. printk(KERN_WARNING "No edge setting!\n");
  243. break;
  244. case IRQ_TYPE_EDGE_RISING:
  245. newvalue = S3C2410_EXTINT_RISEEDGE;
  246. break;
  247. case IRQ_TYPE_EDGE_FALLING:
  248. newvalue = S3C2410_EXTINT_FALLEDGE;
  249. break;
  250. case IRQ_TYPE_EDGE_BOTH:
  251. newvalue = S3C2410_EXTINT_BOTHEDGE;
  252. break;
  253. case IRQ_TYPE_LEVEL_LOW:
  254. newvalue = S3C2410_EXTINT_LOWLEV;
  255. break;
  256. case IRQ_TYPE_LEVEL_HIGH:
  257. newvalue = S3C2410_EXTINT_HILEV;
  258. break;
  259. default:
  260. printk(KERN_ERR "No such irq type %d", type);
  261. return -1;
  262. }
  263. value = __raw_readl(extint_reg);
  264. value = (value & ~(7 << extint_offset)) | (newvalue << extint_offset);
  265. __raw_writel(value, extint_reg);
  266. return 0;
  267. }
  268. static struct irq_chip s3c_irqext_chip = {
  269. .name = "s3c-ext",
  270. .mask = s3c_irqext_mask,
  271. .unmask = s3c_irqext_unmask,
  272. .ack = s3c_irqext_ack,
  273. .set_type = s3c_irqext_type,
  274. .set_wake = s3c_irqext_wake
  275. };
  276. static struct irq_chip s3c_irq_eint0t4 = {
  277. .name = "s3c-ext0",
  278. .ack = s3c_irq_ack,
  279. .mask = s3c_irq_mask,
  280. .unmask = s3c_irq_unmask,
  281. .set_wake = s3c_irq_wake,
  282. .set_type = s3c_irqext_type,
  283. };
  284. /* mask values for the parent registers for each of the interrupt types */
  285. #define INTMSK_UART0 (1UL << (IRQ_UART0 - IRQ_EINT0))
  286. #define INTMSK_UART1 (1UL << (IRQ_UART1 - IRQ_EINT0))
  287. #define INTMSK_UART2 (1UL << (IRQ_UART2 - IRQ_EINT0))
  288. #define INTMSK_ADCPARENT (1UL << (IRQ_ADCPARENT - IRQ_EINT0))
  289. /* UART0 */
  290. static void
  291. s3c_irq_uart0_mask(unsigned int irqno)
  292. {
  293. s3c_irqsub_mask(irqno, INTMSK_UART0, 7);
  294. }
  295. static void
  296. s3c_irq_uart0_unmask(unsigned int irqno)
  297. {
  298. s3c_irqsub_unmask(irqno, INTMSK_UART0);
  299. }
  300. static void
  301. s3c_irq_uart0_ack(unsigned int irqno)
  302. {
  303. s3c_irqsub_maskack(irqno, INTMSK_UART0, 7);
  304. }
  305. static struct irq_chip s3c_irq_uart0 = {
  306. .name = "s3c-uart0",
  307. .mask = s3c_irq_uart0_mask,
  308. .unmask = s3c_irq_uart0_unmask,
  309. .ack = s3c_irq_uart0_ack,
  310. };
  311. /* UART1 */
  312. static void
  313. s3c_irq_uart1_mask(unsigned int irqno)
  314. {
  315. s3c_irqsub_mask(irqno, INTMSK_UART1, 7 << 3);
  316. }
  317. static void
  318. s3c_irq_uart1_unmask(unsigned int irqno)
  319. {
  320. s3c_irqsub_unmask(irqno, INTMSK_UART1);
  321. }
  322. static void
  323. s3c_irq_uart1_ack(unsigned int irqno)
  324. {
  325. s3c_irqsub_maskack(irqno, INTMSK_UART1, 7 << 3);
  326. }
  327. static struct irq_chip s3c_irq_uart1 = {
  328. .name = "s3c-uart1",
  329. .mask = s3c_irq_uart1_mask,
  330. .unmask = s3c_irq_uart1_unmask,
  331. .ack = s3c_irq_uart1_ack,
  332. };
  333. /* UART2 */
  334. static void
  335. s3c_irq_uart2_mask(unsigned int irqno)
  336. {
  337. s3c_irqsub_mask(irqno, INTMSK_UART2, 7 << 6);
  338. }
  339. static void
  340. s3c_irq_uart2_unmask(unsigned int irqno)
  341. {
  342. s3c_irqsub_unmask(irqno, INTMSK_UART2);
  343. }
  344. static void
  345. s3c_irq_uart2_ack(unsigned int irqno)
  346. {
  347. s3c_irqsub_maskack(irqno, INTMSK_UART2, 7 << 6);
  348. }
  349. static struct irq_chip s3c_irq_uart2 = {
  350. .name = "s3c-uart2",
  351. .mask = s3c_irq_uart2_mask,
  352. .unmask = s3c_irq_uart2_unmask,
  353. .ack = s3c_irq_uart2_ack,
  354. };
  355. /* ADC and Touchscreen */
  356. static void
  357. s3c_irq_adc_mask(unsigned int irqno)
  358. {
  359. s3c_irqsub_mask(irqno, INTMSK_ADCPARENT, 3 << 9);
  360. }
  361. static void
  362. s3c_irq_adc_unmask(unsigned int irqno)
  363. {
  364. s3c_irqsub_unmask(irqno, INTMSK_ADCPARENT);
  365. }
  366. static void
  367. s3c_irq_adc_ack(unsigned int irqno)
  368. {
  369. s3c_irqsub_ack(irqno, INTMSK_ADCPARENT, 3 << 9);
  370. }
  371. static struct irq_chip s3c_irq_adc = {
  372. .name = "s3c-adc",
  373. .mask = s3c_irq_adc_mask,
  374. .unmask = s3c_irq_adc_unmask,
  375. .ack = s3c_irq_adc_ack,
  376. };
  377. /* irq demux for adc */
  378. static void s3c_irq_demux_adc(unsigned int irq,
  379. struct irq_desc *desc)
  380. {
  381. unsigned int subsrc, submsk;
  382. unsigned int offset = 9;
  383. /* read the current pending interrupts, and the mask
  384. * for what it is available */
  385. subsrc = __raw_readl(S3C2410_SUBSRCPND);
  386. submsk = __raw_readl(S3C2410_INTSUBMSK);
  387. subsrc &= ~submsk;
  388. subsrc >>= offset;
  389. subsrc &= 3;
  390. if (subsrc != 0) {
  391. if (subsrc & 1) {
  392. generic_handle_irq(IRQ_TC);
  393. }
  394. if (subsrc & 2) {
  395. generic_handle_irq(IRQ_ADC);
  396. }
  397. }
  398. }
  399. static void s3c_irq_demux_uart(unsigned int start)
  400. {
  401. unsigned int subsrc, submsk;
  402. unsigned int offset = start - IRQ_S3CUART_RX0;
  403. /* read the current pending interrupts, and the mask
  404. * for what it is available */
  405. subsrc = __raw_readl(S3C2410_SUBSRCPND);
  406. submsk = __raw_readl(S3C2410_INTSUBMSK);
  407. irqdbf2("s3c_irq_demux_uart: start=%d (%d), subsrc=0x%08x,0x%08x\n",
  408. start, offset, subsrc, submsk);
  409. subsrc &= ~submsk;
  410. subsrc >>= offset;
  411. subsrc &= 7;
  412. if (subsrc != 0) {
  413. if (subsrc & 1)
  414. generic_handle_irq(start);
  415. if (subsrc & 2)
  416. generic_handle_irq(start+1);
  417. if (subsrc & 4)
  418. generic_handle_irq(start+2);
  419. }
  420. }
  421. /* uart demux entry points */
  422. static void
  423. s3c_irq_demux_uart0(unsigned int irq,
  424. struct irq_desc *desc)
  425. {
  426. irq = irq;
  427. s3c_irq_demux_uart(IRQ_S3CUART_RX0);
  428. }
  429. static void
  430. s3c_irq_demux_uart1(unsigned int irq,
  431. struct irq_desc *desc)
  432. {
  433. irq = irq;
  434. s3c_irq_demux_uart(IRQ_S3CUART_RX1);
  435. }
  436. static void
  437. s3c_irq_demux_uart2(unsigned int irq,
  438. struct irq_desc *desc)
  439. {
  440. irq = irq;
  441. s3c_irq_demux_uart(IRQ_S3CUART_RX2);
  442. }
  443. static void
  444. s3c_irq_demux_extint8(unsigned int irq,
  445. struct irq_desc *desc)
  446. {
  447. unsigned long eintpnd = __raw_readl(S3C24XX_EINTPEND);
  448. unsigned long eintmsk = __raw_readl(S3C24XX_EINTMASK);
  449. eintpnd &= ~eintmsk;
  450. eintpnd &= ~0xff; /* ignore lower irqs */
  451. /* we may as well handle all the pending IRQs here */
  452. while (eintpnd) {
  453. irq = __ffs(eintpnd);
  454. eintpnd &= ~(1<<irq);
  455. irq += (IRQ_EINT4 - 4);
  456. generic_handle_irq(irq);
  457. }
  458. }
  459. static void
  460. s3c_irq_demux_extint4t7(unsigned int irq,
  461. struct irq_desc *desc)
  462. {
  463. unsigned long eintpnd = __raw_readl(S3C24XX_EINTPEND);
  464. unsigned long eintmsk = __raw_readl(S3C24XX_EINTMASK);
  465. eintpnd &= ~eintmsk;
  466. eintpnd &= 0xff; /* only lower irqs */
  467. /* we may as well handle all the pending IRQs here */
  468. while (eintpnd) {
  469. irq = __ffs(eintpnd);
  470. eintpnd &= ~(1<<irq);
  471. irq += (IRQ_EINT4 - 4);
  472. generic_handle_irq(irq);
  473. }
  474. }
  475. #ifdef CONFIG_PM
  476. static struct sleep_save irq_save[] = {
  477. SAVE_ITEM(S3C2410_INTMSK),
  478. SAVE_ITEM(S3C2410_INTSUBMSK),
  479. };
  480. /* the extint values move between the s3c2410/s3c2440 and the s3c2412
  481. * so we use an array to hold them, and to calculate the address of
  482. * the register at run-time
  483. */
  484. static unsigned long save_extint[3];
  485. static unsigned long save_eintflt[4];
  486. static unsigned long save_eintmask;
  487. int s3c24xx_irq_suspend(struct sys_device *dev, pm_message_t state)
  488. {
  489. unsigned int i;
  490. for (i = 0; i < ARRAY_SIZE(save_extint); i++)
  491. save_extint[i] = __raw_readl(S3C24XX_EXTINT0 + (i*4));
  492. for (i = 0; i < ARRAY_SIZE(save_eintflt); i++)
  493. save_eintflt[i] = __raw_readl(S3C24XX_EINFLT0 + (i*4));
  494. s3c2410_pm_do_save(irq_save, ARRAY_SIZE(irq_save));
  495. save_eintmask = __raw_readl(S3C24XX_EINTMASK);
  496. return 0;
  497. }
  498. int s3c24xx_irq_resume(struct sys_device *dev)
  499. {
  500. unsigned int i;
  501. for (i = 0; i < ARRAY_SIZE(save_extint); i++)
  502. __raw_writel(save_extint[i], S3C24XX_EXTINT0 + (i*4));
  503. for (i = 0; i < ARRAY_SIZE(save_eintflt); i++)
  504. __raw_writel(save_eintflt[i], S3C24XX_EINFLT0 + (i*4));
  505. s3c2410_pm_do_restore(irq_save, ARRAY_SIZE(irq_save));
  506. __raw_writel(save_eintmask, S3C24XX_EINTMASK);
  507. return 0;
  508. }
  509. #else
  510. #define s3c24xx_irq_suspend NULL
  511. #define s3c24xx_irq_resume NULL
  512. #endif
  513. /* s3c24xx_init_irq
  514. *
  515. * Initialise S3C2410 IRQ system
  516. */
  517. void __init s3c24xx_init_irq(void)
  518. {
  519. unsigned long pend;
  520. unsigned long last;
  521. int irqno;
  522. int i;
  523. irqdbf("s3c2410_init_irq: clearing interrupt status flags\n");
  524. /* first, clear all interrupts pending... */
  525. last = 0;
  526. for (i = 0; i < 4; i++) {
  527. pend = __raw_readl(S3C24XX_EINTPEND);
  528. if (pend == 0 || pend == last)
  529. break;
  530. __raw_writel(pend, S3C24XX_EINTPEND);
  531. printk("irq: clearing pending ext status %08x\n", (int)pend);
  532. last = pend;
  533. }
  534. last = 0;
  535. for (i = 0; i < 4; i++) {
  536. pend = __raw_readl(S3C2410_INTPND);
  537. if (pend == 0 || pend == last)
  538. break;
  539. __raw_writel(pend, S3C2410_SRCPND);
  540. __raw_writel(pend, S3C2410_INTPND);
  541. printk("irq: clearing pending status %08x\n", (int)pend);
  542. last = pend;
  543. }
  544. last = 0;
  545. for (i = 0; i < 4; i++) {
  546. pend = __raw_readl(S3C2410_SUBSRCPND);
  547. if (pend == 0 || pend == last)
  548. break;
  549. printk("irq: clearing subpending status %08x\n", (int)pend);
  550. __raw_writel(pend, S3C2410_SUBSRCPND);
  551. last = pend;
  552. }
  553. /* register the main interrupts */
  554. irqdbf("s3c2410_init_irq: registering s3c2410 interrupt handlers\n");
  555. for (irqno = IRQ_EINT4t7; irqno <= IRQ_ADCPARENT; irqno++) {
  556. /* set all the s3c2410 internal irqs */
  557. switch (irqno) {
  558. /* deal with the special IRQs (cascaded) */
  559. case IRQ_EINT4t7:
  560. case IRQ_EINT8t23:
  561. case IRQ_UART0:
  562. case IRQ_UART1:
  563. case IRQ_UART2:
  564. case IRQ_ADCPARENT:
  565. set_irq_chip(irqno, &s3c_irq_level_chip);
  566. set_irq_handler(irqno, handle_level_irq);
  567. break;
  568. case IRQ_RESERVED6:
  569. case IRQ_RESERVED24:
  570. /* no IRQ here */
  571. break;
  572. default:
  573. //irqdbf("registering irq %d (s3c irq)\n", irqno);
  574. set_irq_chip(irqno, &s3c_irq_chip);
  575. set_irq_handler(irqno, handle_edge_irq);
  576. set_irq_flags(irqno, IRQF_VALID);
  577. }
  578. }
  579. /* setup the cascade irq handlers */
  580. set_irq_chained_handler(IRQ_EINT4t7, s3c_irq_demux_extint4t7);
  581. set_irq_chained_handler(IRQ_EINT8t23, s3c_irq_demux_extint8);
  582. set_irq_chained_handler(IRQ_UART0, s3c_irq_demux_uart0);
  583. set_irq_chained_handler(IRQ_UART1, s3c_irq_demux_uart1);
  584. set_irq_chained_handler(IRQ_UART2, s3c_irq_demux_uart2);
  585. set_irq_chained_handler(IRQ_ADCPARENT, s3c_irq_demux_adc);
  586. /* external interrupts */
  587. for (irqno = IRQ_EINT0; irqno <= IRQ_EINT3; irqno++) {
  588. irqdbf("registering irq %d (ext int)\n", irqno);
  589. set_irq_chip(irqno, &s3c_irq_eint0t4);
  590. set_irq_handler(irqno, handle_edge_irq);
  591. set_irq_flags(irqno, IRQF_VALID);
  592. }
  593. for (irqno = IRQ_EINT4; irqno <= IRQ_EINT23; irqno++) {
  594. irqdbf("registering irq %d (extended s3c irq)\n", irqno);
  595. set_irq_chip(irqno, &s3c_irqext_chip);
  596. set_irq_handler(irqno, handle_edge_irq);
  597. set_irq_flags(irqno, IRQF_VALID);
  598. }
  599. /* register the uart interrupts */
  600. irqdbf("s3c2410: registering external interrupts\n");
  601. for (irqno = IRQ_S3CUART_RX0; irqno <= IRQ_S3CUART_ERR0; irqno++) {
  602. irqdbf("registering irq %d (s3c uart0 irq)\n", irqno);
  603. set_irq_chip(irqno, &s3c_irq_uart0);
  604. set_irq_handler(irqno, handle_level_irq);
  605. set_irq_flags(irqno, IRQF_VALID);
  606. }
  607. for (irqno = IRQ_S3CUART_RX1; irqno <= IRQ_S3CUART_ERR1; irqno++) {
  608. irqdbf("registering irq %d (s3c uart1 irq)\n", irqno);
  609. set_irq_chip(irqno, &s3c_irq_uart1);
  610. set_irq_handler(irqno, handle_level_irq);
  611. set_irq_flags(irqno, IRQF_VALID);
  612. }
  613. for (irqno = IRQ_S3CUART_RX2; irqno <= IRQ_S3CUART_ERR2; irqno++) {
  614. irqdbf("registering irq %d (s3c uart2 irq)\n", irqno);
  615. set_irq_chip(irqno, &s3c_irq_uart2);
  616. set_irq_handler(irqno, handle_level_irq);
  617. set_irq_flags(irqno, IRQF_VALID);
  618. }
  619. for (irqno = IRQ_TC; irqno <= IRQ_ADC; irqno++) {
  620. irqdbf("registering irq %d (s3c adc irq)\n", irqno);
  621. set_irq_chip(irqno, &s3c_irq_adc);
  622. set_irq_handler(irqno, handle_edge_irq);
  623. set_irq_flags(irqno, IRQF_VALID);
  624. }
  625. irqdbf("s3c2410: registered interrupt handlers\n");
  626. }