irq.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. /*
  2. * Copyright 2001, 2007-2008 MontaVista Software Inc.
  3. * Author: MontaVista Software, Inc. <source@mvista.com>
  4. *
  5. * Copyright (C) 2007 Ralf Baechle (ralf@linux-mips.org)
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. *
  12. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  13. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  15. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  16. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  17. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  18. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  19. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  20. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  21. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. *
  23. * You should have received a copy of the GNU General Public License along
  24. * with this program; if not, write to the Free Software Foundation, Inc.,
  25. * 675 Mass Ave, Cambridge, MA 02139, USA.
  26. */
  27. #include <linux/bitops.h>
  28. #include <linux/init.h>
  29. #include <linux/interrupt.h>
  30. #include <linux/irq.h>
  31. #include <asm/irq_cpu.h>
  32. #include <asm/mipsregs.h>
  33. #include <asm/mach-au1x00/au1000.h>
  34. #ifdef CONFIG_MIPS_PB1000
  35. #include <asm/mach-pb1x00/pb1000.h>
  36. #endif
  37. #define EXT_INTC0_REQ0 2 /* IP 2 */
  38. #define EXT_INTC0_REQ1 3 /* IP 3 */
  39. #define EXT_INTC1_REQ0 4 /* IP 4 */
  40. #define EXT_INTC1_REQ1 5 /* IP 5 */
  41. #define MIPS_TIMER_IP 7 /* IP 7 */
  42. void (*board_init_irq)(void) __initdata = NULL;
  43. static DEFINE_SPINLOCK(irq_lock);
  44. #ifdef CONFIG_PM
  45. /*
  46. * Save/restore the interrupt controller state.
  47. * Called from the save/restore core registers as part of the
  48. * au_sleep function in power.c.....maybe I should just pm_register()
  49. * them instead?
  50. */
  51. static unsigned int sleep_intctl_config0[2];
  52. static unsigned int sleep_intctl_config1[2];
  53. static unsigned int sleep_intctl_config2[2];
  54. static unsigned int sleep_intctl_src[2];
  55. static unsigned int sleep_intctl_assign[2];
  56. static unsigned int sleep_intctl_wake[2];
  57. static unsigned int sleep_intctl_mask[2];
  58. void save_au1xxx_intctl(void)
  59. {
  60. sleep_intctl_config0[0] = au_readl(IC0_CFG0RD);
  61. sleep_intctl_config1[0] = au_readl(IC0_CFG1RD);
  62. sleep_intctl_config2[0] = au_readl(IC0_CFG2RD);
  63. sleep_intctl_src[0] = au_readl(IC0_SRCRD);
  64. sleep_intctl_assign[0] = au_readl(IC0_ASSIGNRD);
  65. sleep_intctl_wake[0] = au_readl(IC0_WAKERD);
  66. sleep_intctl_mask[0] = au_readl(IC0_MASKRD);
  67. sleep_intctl_config0[1] = au_readl(IC1_CFG0RD);
  68. sleep_intctl_config1[1] = au_readl(IC1_CFG1RD);
  69. sleep_intctl_config2[1] = au_readl(IC1_CFG2RD);
  70. sleep_intctl_src[1] = au_readl(IC1_SRCRD);
  71. sleep_intctl_assign[1] = au_readl(IC1_ASSIGNRD);
  72. sleep_intctl_wake[1] = au_readl(IC1_WAKERD);
  73. sleep_intctl_mask[1] = au_readl(IC1_MASKRD);
  74. }
  75. /*
  76. * For most restore operations, we clear the entire register and
  77. * then set the bits we found during the save.
  78. */
  79. void restore_au1xxx_intctl(void)
  80. {
  81. au_writel(0xffffffff, IC0_MASKCLR); au_sync();
  82. au_writel(0xffffffff, IC0_CFG0CLR); au_sync();
  83. au_writel(sleep_intctl_config0[0], IC0_CFG0SET); au_sync();
  84. au_writel(0xffffffff, IC0_CFG1CLR); au_sync();
  85. au_writel(sleep_intctl_config1[0], IC0_CFG1SET); au_sync();
  86. au_writel(0xffffffff, IC0_CFG2CLR); au_sync();
  87. au_writel(sleep_intctl_config2[0], IC0_CFG2SET); au_sync();
  88. au_writel(0xffffffff, IC0_SRCCLR); au_sync();
  89. au_writel(sleep_intctl_src[0], IC0_SRCSET); au_sync();
  90. au_writel(0xffffffff, IC0_ASSIGNCLR); au_sync();
  91. au_writel(sleep_intctl_assign[0], IC0_ASSIGNSET); au_sync();
  92. au_writel(0xffffffff, IC0_WAKECLR); au_sync();
  93. au_writel(sleep_intctl_wake[0], IC0_WAKESET); au_sync();
  94. au_writel(0xffffffff, IC0_RISINGCLR); au_sync();
  95. au_writel(0xffffffff, IC0_FALLINGCLR); au_sync();
  96. au_writel(0x00000000, IC0_TESTBIT); au_sync();
  97. au_writel(0xffffffff, IC1_MASKCLR); au_sync();
  98. au_writel(0xffffffff, IC1_CFG0CLR); au_sync();
  99. au_writel(sleep_intctl_config0[1], IC1_CFG0SET); au_sync();
  100. au_writel(0xffffffff, IC1_CFG1CLR); au_sync();
  101. au_writel(sleep_intctl_config1[1], IC1_CFG1SET); au_sync();
  102. au_writel(0xffffffff, IC1_CFG2CLR); au_sync();
  103. au_writel(sleep_intctl_config2[1], IC1_CFG2SET); au_sync();
  104. au_writel(0xffffffff, IC1_SRCCLR); au_sync();
  105. au_writel(sleep_intctl_src[1], IC1_SRCSET); au_sync();
  106. au_writel(0xffffffff, IC1_ASSIGNCLR); au_sync();
  107. au_writel(sleep_intctl_assign[1], IC1_ASSIGNSET); au_sync();
  108. au_writel(0xffffffff, IC1_WAKECLR); au_sync();
  109. au_writel(sleep_intctl_wake[1], IC1_WAKESET); au_sync();
  110. au_writel(0xffffffff, IC1_RISINGCLR); au_sync();
  111. au_writel(0xffffffff, IC1_FALLINGCLR); au_sync();
  112. au_writel(0x00000000, IC1_TESTBIT); au_sync();
  113. au_writel(sleep_intctl_mask[1], IC1_MASKSET); au_sync();
  114. au_writel(sleep_intctl_mask[0], IC0_MASKSET); au_sync();
  115. }
  116. #endif /* CONFIG_PM */
  117. inline void local_enable_irq(unsigned int irq_nr)
  118. {
  119. unsigned int bit = irq_nr - AU1000_INTC0_INT_BASE;
  120. if (bit >= 32) {
  121. au_writel(1 << (bit - 32), IC1_MASKSET);
  122. au_writel(1 << (bit - 32), IC1_WAKESET);
  123. } else {
  124. au_writel(1 << bit, IC0_MASKSET);
  125. au_writel(1 << bit, IC0_WAKESET);
  126. }
  127. au_sync();
  128. }
  129. inline void local_disable_irq(unsigned int irq_nr)
  130. {
  131. unsigned int bit = irq_nr - AU1000_INTC0_INT_BASE;
  132. if (bit >= 32) {
  133. au_writel(1 << (bit - 32), IC1_MASKCLR);
  134. au_writel(1 << (bit - 32), IC1_WAKECLR);
  135. } else {
  136. au_writel(1 << bit, IC0_MASKCLR);
  137. au_writel(1 << bit, IC0_WAKECLR);
  138. }
  139. au_sync();
  140. }
  141. static inline void mask_and_ack_rise_edge_irq(unsigned int irq_nr)
  142. {
  143. unsigned int bit = irq_nr - AU1000_INTC0_INT_BASE;
  144. if (bit >= 32) {
  145. au_writel(1 << (bit - 32), IC1_RISINGCLR);
  146. au_writel(1 << (bit - 32), IC1_MASKCLR);
  147. } else {
  148. au_writel(1 << bit, IC0_RISINGCLR);
  149. au_writel(1 << bit, IC0_MASKCLR);
  150. }
  151. au_sync();
  152. }
  153. static inline void mask_and_ack_fall_edge_irq(unsigned int irq_nr)
  154. {
  155. unsigned int bit = irq_nr - AU1000_INTC0_INT_BASE;
  156. if (bit >= 32) {
  157. au_writel(1 << (bit - 32), IC1_FALLINGCLR);
  158. au_writel(1 << (bit - 32), IC1_MASKCLR);
  159. } else {
  160. au_writel(1 << bit, IC0_FALLINGCLR);
  161. au_writel(1 << bit, IC0_MASKCLR);
  162. }
  163. au_sync();
  164. }
  165. static inline void mask_and_ack_either_edge_irq(unsigned int irq_nr)
  166. {
  167. unsigned int bit = irq_nr - AU1000_INTC0_INT_BASE;
  168. /*
  169. * This may assume that we don't get interrupts from
  170. * both edges at once, or if we do, that we don't care.
  171. */
  172. if (bit >= 32) {
  173. au_writel(1 << (bit - 32), IC1_FALLINGCLR);
  174. au_writel(1 << (bit - 32), IC1_RISINGCLR);
  175. au_writel(1 << (bit - 32), IC1_MASKCLR);
  176. } else {
  177. au_writel(1 << bit, IC0_FALLINGCLR);
  178. au_writel(1 << bit, IC0_RISINGCLR);
  179. au_writel(1 << bit, IC0_MASKCLR);
  180. }
  181. au_sync();
  182. }
  183. static inline void mask_and_ack_level_irq(unsigned int irq_nr)
  184. {
  185. local_disable_irq(irq_nr);
  186. au_sync();
  187. #if defined(CONFIG_MIPS_PB1000)
  188. if (irq_nr == AU1000_GPIO_15) {
  189. au_writel(0x8000, PB1000_MDR); /* ack int */
  190. au_sync();
  191. }
  192. #endif
  193. }
  194. static void end_irq(unsigned int irq_nr)
  195. {
  196. if (!(irq_desc[irq_nr].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
  197. local_enable_irq(irq_nr);
  198. #if defined(CONFIG_MIPS_PB1000)
  199. if (irq_nr == AU1000_GPIO_15) {
  200. au_writel(0x4000, PB1000_MDR); /* enable int */
  201. au_sync();
  202. }
  203. #endif
  204. }
  205. unsigned long save_local_and_disable(int controller)
  206. {
  207. int i;
  208. unsigned long flags, mask;
  209. spin_lock_irqsave(&irq_lock, flags);
  210. if (controller) {
  211. mask = au_readl(IC1_MASKSET);
  212. for (i = 32; i < 64; i++)
  213. local_disable_irq(i);
  214. } else {
  215. mask = au_readl(IC0_MASKSET);
  216. for (i = 0; i < 32; i++)
  217. local_disable_irq(i);
  218. }
  219. spin_unlock_irqrestore(&irq_lock, flags);
  220. return mask;
  221. }
  222. void restore_local_and_enable(int controller, unsigned long mask)
  223. {
  224. int i;
  225. unsigned long flags, new_mask;
  226. spin_lock_irqsave(&irq_lock, flags);
  227. for (i = 0; i < 32; i++)
  228. if (mask & (1 << i)) {
  229. if (controller)
  230. local_enable_irq(i + 32);
  231. else
  232. local_enable_irq(i);
  233. }
  234. if (controller)
  235. new_mask = au_readl(IC1_MASKSET);
  236. else
  237. new_mask = au_readl(IC0_MASKSET);
  238. spin_unlock_irqrestore(&irq_lock, flags);
  239. }
  240. static struct irq_chip rise_edge_irq_type = {
  241. .name = "Au1000 Rise Edge",
  242. .ack = mask_and_ack_rise_edge_irq,
  243. .mask = local_disable_irq,
  244. .mask_ack = mask_and_ack_rise_edge_irq,
  245. .unmask = local_enable_irq,
  246. .end = end_irq,
  247. };
  248. static struct irq_chip fall_edge_irq_type = {
  249. .name = "Au1000 Fall Edge",
  250. .ack = mask_and_ack_fall_edge_irq,
  251. .mask = local_disable_irq,
  252. .mask_ack = mask_and_ack_fall_edge_irq,
  253. .unmask = local_enable_irq,
  254. .end = end_irq,
  255. };
  256. static struct irq_chip either_edge_irq_type = {
  257. .name = "Au1000 Rise or Fall Edge",
  258. .ack = mask_and_ack_either_edge_irq,
  259. .mask = local_disable_irq,
  260. .mask_ack = mask_and_ack_either_edge_irq,
  261. .unmask = local_enable_irq,
  262. .end = end_irq,
  263. };
  264. static struct irq_chip level_irq_type = {
  265. .name = "Au1000 Level",
  266. .ack = mask_and_ack_level_irq,
  267. .mask = local_disable_irq,
  268. .mask_ack = mask_and_ack_level_irq,
  269. .unmask = local_enable_irq,
  270. .end = end_irq,
  271. };
  272. static void __init setup_local_irq(unsigned int irq_nr, int type, int int_req)
  273. {
  274. unsigned int bit = irq_nr - AU1000_INTC0_INT_BASE;
  275. if (irq_nr > AU1000_MAX_INTR)
  276. return;
  277. /* Config2[n], Config1[n], Config0[n] */
  278. if (bit >= 32) {
  279. switch (type) {
  280. case INTC_INT_RISE_EDGE: /* 0:0:1 */
  281. au_writel(1 << (bit - 32), IC1_CFG2CLR);
  282. au_writel(1 << (bit - 32), IC1_CFG1CLR);
  283. au_writel(1 << (bit - 32), IC1_CFG0SET);
  284. set_irq_chip(irq_nr, &rise_edge_irq_type);
  285. break;
  286. case INTC_INT_FALL_EDGE: /* 0:1:0 */
  287. au_writel(1 << (bit - 32), IC1_CFG2CLR);
  288. au_writel(1 << (bit - 32), IC1_CFG1SET);
  289. au_writel(1 << (bit - 32), IC1_CFG0CLR);
  290. set_irq_chip(irq_nr, &fall_edge_irq_type);
  291. break;
  292. case INTC_INT_RISE_AND_FALL_EDGE: /* 0:1:1 */
  293. au_writel(1 << (bit - 32), IC1_CFG2CLR);
  294. au_writel(1 << (bit - 32), IC1_CFG1SET);
  295. au_writel(1 << (bit - 32), IC1_CFG0SET);
  296. set_irq_chip(irq_nr, &either_edge_irq_type);
  297. break;
  298. case INTC_INT_HIGH_LEVEL: /* 1:0:1 */
  299. au_writel(1 << (bit - 32), IC1_CFG2SET);
  300. au_writel(1 << (bit - 32), IC1_CFG1CLR);
  301. au_writel(1 << (bit - 32), IC1_CFG0SET);
  302. set_irq_chip(irq_nr, &level_irq_type);
  303. break;
  304. case INTC_INT_LOW_LEVEL: /* 1:1:0 */
  305. au_writel(1 << (bit - 32), IC1_CFG2SET);
  306. au_writel(1 << (bit - 32), IC1_CFG1SET);
  307. au_writel(1 << (bit - 32), IC1_CFG0CLR);
  308. set_irq_chip(irq_nr, &level_irq_type);
  309. break;
  310. case INTC_INT_DISABLED: /* 0:0:0 */
  311. au_writel(1 << (bit - 32), IC1_CFG0CLR);
  312. au_writel(1 << (bit - 32), IC1_CFG1CLR);
  313. au_writel(1 << (bit - 32), IC1_CFG2CLR);
  314. break;
  315. default: /* disable the interrupt */
  316. printk(KERN_WARNING "unexpected int type %d (irq %d)\n",
  317. type, irq_nr);
  318. au_writel(1 << (bit - 32), IC1_CFG0CLR);
  319. au_writel(1 << (bit - 32), IC1_CFG1CLR);
  320. au_writel(1 << (bit - 32), IC1_CFG2CLR);
  321. return;
  322. }
  323. if (int_req) /* assign to interrupt request 1 */
  324. au_writel(1 << (bit - 32), IC1_ASSIGNCLR);
  325. else /* assign to interrupt request 0 */
  326. au_writel(1 << (bit - 32), IC1_ASSIGNSET);
  327. au_writel(1 << (bit - 32), IC1_SRCSET);
  328. au_writel(1 << (bit - 32), IC1_MASKCLR);
  329. au_writel(1 << (bit - 32), IC1_WAKECLR);
  330. } else {
  331. switch (type) {
  332. case INTC_INT_RISE_EDGE: /* 0:0:1 */
  333. au_writel(1 << bit, IC0_CFG2CLR);
  334. au_writel(1 << bit, IC0_CFG1CLR);
  335. au_writel(1 << bit, IC0_CFG0SET);
  336. set_irq_chip(irq_nr, &rise_edge_irq_type);
  337. break;
  338. case INTC_INT_FALL_EDGE: /* 0:1:0 */
  339. au_writel(1 << bit, IC0_CFG2CLR);
  340. au_writel(1 << bit, IC0_CFG1SET);
  341. au_writel(1 << bit, IC0_CFG0CLR);
  342. set_irq_chip(irq_nr, &fall_edge_irq_type);
  343. break;
  344. case INTC_INT_RISE_AND_FALL_EDGE: /* 0:1:1 */
  345. au_writel(1 << bit, IC0_CFG2CLR);
  346. au_writel(1 << bit, IC0_CFG1SET);
  347. au_writel(1 << bit, IC0_CFG0SET);
  348. set_irq_chip(irq_nr, &either_edge_irq_type);
  349. break;
  350. case INTC_INT_HIGH_LEVEL: /* 1:0:1 */
  351. au_writel(1 << bit, IC0_CFG2SET);
  352. au_writel(1 << bit, IC0_CFG1CLR);
  353. au_writel(1 << bit, IC0_CFG0SET);
  354. set_irq_chip(irq_nr, &level_irq_type);
  355. break;
  356. case INTC_INT_LOW_LEVEL: /* 1:1:0 */
  357. au_writel(1 << bit, IC0_CFG2SET);
  358. au_writel(1 << bit, IC0_CFG1SET);
  359. au_writel(1 << bit, IC0_CFG0CLR);
  360. set_irq_chip(irq_nr, &level_irq_type);
  361. break;
  362. case INTC_INT_DISABLED: /* 0:0:0 */
  363. au_writel(1 << bit, IC0_CFG0CLR);
  364. au_writel(1 << bit, IC0_CFG1CLR);
  365. au_writel(1 << bit, IC0_CFG2CLR);
  366. break;
  367. default: /* disable the interrupt */
  368. printk(KERN_WARNING "unexpected int type %d (irq %d)\n",
  369. type, irq_nr);
  370. au_writel(1 << bit, IC0_CFG0CLR);
  371. au_writel(1 << bit, IC0_CFG1CLR);
  372. au_writel(1 << bit, IC0_CFG2CLR);
  373. return;
  374. }
  375. if (int_req) /* assign to interrupt request 1 */
  376. au_writel(1 << bit, IC0_ASSIGNCLR);
  377. else /* assign to interrupt request 0 */
  378. au_writel(1 << bit, IC0_ASSIGNSET);
  379. au_writel(1 << bit, IC0_SRCSET);
  380. au_writel(1 << bit, IC0_MASKCLR);
  381. au_writel(1 << bit, IC0_WAKECLR);
  382. }
  383. au_sync();
  384. }
  385. /*
  386. * Interrupts are nested. Even if an interrupt handler is registered
  387. * as "fast", we might get another interrupt before we return from
  388. * intcX_reqX_irqdispatch().
  389. */
  390. static void intc0_req0_irqdispatch(void)
  391. {
  392. static unsigned long intc0_req0;
  393. unsigned int bit;
  394. intc0_req0 |= au_readl(IC0_REQ0INT);
  395. if (!intc0_req0)
  396. return;
  397. #ifdef AU1000_USB_DEV_REQ_INT
  398. /*
  399. * Because of the tight timing of SETUP token to reply
  400. * transactions, the USB devices-side packet complete
  401. * interrupt needs the highest priority.
  402. */
  403. if ((intc0_req0 & (1 << AU1000_USB_DEV_REQ_INT))) {
  404. intc0_req0 &= ~(1 << AU1000_USB_DEV_REQ_INT);
  405. do_IRQ(AU1000_USB_DEV_REQ_INT);
  406. return;
  407. }
  408. #endif
  409. bit = __ffs(intc0_req0);
  410. intc0_req0 &= ~(1 << bit);
  411. do_IRQ(AU1000_INTC0_INT_BASE + bit);
  412. }
  413. static void intc0_req1_irqdispatch(void)
  414. {
  415. static unsigned long intc0_req1;
  416. unsigned int bit;
  417. intc0_req1 |= au_readl(IC0_REQ1INT);
  418. if (!intc0_req1)
  419. return;
  420. bit = __ffs(intc0_req1);
  421. intc0_req1 &= ~(1 << bit);
  422. do_IRQ(AU1000_INTC0_INT_BASE + bit);
  423. }
  424. /*
  425. * Interrupt Controller 1:
  426. * interrupts 32 - 63
  427. */
  428. static void intc1_req0_irqdispatch(void)
  429. {
  430. static unsigned long intc1_req0;
  431. unsigned int bit;
  432. intc1_req0 |= au_readl(IC1_REQ0INT);
  433. if (!intc1_req0)
  434. return;
  435. bit = __ffs(intc1_req0);
  436. intc1_req0 &= ~(1 << bit);
  437. do_IRQ(AU1000_INTC1_INT_BASE + bit);
  438. }
  439. static void intc1_req1_irqdispatch(void)
  440. {
  441. static unsigned long intc1_req1;
  442. unsigned int bit;
  443. intc1_req1 |= au_readl(IC1_REQ1INT);
  444. if (!intc1_req1)
  445. return;
  446. bit = __ffs(intc1_req1);
  447. intc1_req1 &= ~(1 << bit);
  448. do_IRQ(AU1000_INTC1_INT_BASE + bit);
  449. }
  450. asmlinkage void plat_irq_dispatch(void)
  451. {
  452. unsigned int pending = read_c0_status() & read_c0_cause();
  453. if (pending & CAUSEF_IP7)
  454. do_IRQ(MIPS_CPU_IRQ_BASE + 7);
  455. else if (pending & CAUSEF_IP2)
  456. intc0_req0_irqdispatch();
  457. else if (pending & CAUSEF_IP3)
  458. intc0_req1_irqdispatch();
  459. else if (pending & CAUSEF_IP4)
  460. intc1_req0_irqdispatch();
  461. else if (pending & CAUSEF_IP5)
  462. intc1_req1_irqdispatch();
  463. else
  464. spurious_interrupt();
  465. }
  466. void __init arch_init_irq(void)
  467. {
  468. int i;
  469. struct au1xxx_irqmap *imp;
  470. extern struct au1xxx_irqmap au1xxx_irq_map[];
  471. extern struct au1xxx_irqmap au1xxx_ic0_map[];
  472. extern int au1xxx_nr_irqs;
  473. extern int au1xxx_ic0_nr_irqs;
  474. /*
  475. * Initialize interrupt controllers to a safe state.
  476. */
  477. au_writel(0xffffffff, IC0_CFG0CLR);
  478. au_writel(0xffffffff, IC0_CFG1CLR);
  479. au_writel(0xffffffff, IC0_CFG2CLR);
  480. au_writel(0xffffffff, IC0_MASKCLR);
  481. au_writel(0xffffffff, IC0_ASSIGNSET);
  482. au_writel(0xffffffff, IC0_WAKECLR);
  483. au_writel(0xffffffff, IC0_SRCSET);
  484. au_writel(0xffffffff, IC0_FALLINGCLR);
  485. au_writel(0xffffffff, IC0_RISINGCLR);
  486. au_writel(0x00000000, IC0_TESTBIT);
  487. au_writel(0xffffffff, IC1_CFG0CLR);
  488. au_writel(0xffffffff, IC1_CFG1CLR);
  489. au_writel(0xffffffff, IC1_CFG2CLR);
  490. au_writel(0xffffffff, IC1_MASKCLR);
  491. au_writel(0xffffffff, IC1_ASSIGNSET);
  492. au_writel(0xffffffff, IC1_WAKECLR);
  493. au_writel(0xffffffff, IC1_SRCSET);
  494. au_writel(0xffffffff, IC1_FALLINGCLR);
  495. au_writel(0xffffffff, IC1_RISINGCLR);
  496. au_writel(0x00000000, IC1_TESTBIT);
  497. mips_cpu_irq_init();
  498. /*
  499. * Initialize IC0, which is fixed per processor.
  500. */
  501. imp = au1xxx_ic0_map;
  502. for (i = 0; i < au1xxx_ic0_nr_irqs; i++) {
  503. setup_local_irq(imp->im_irq, imp->im_type, imp->im_request);
  504. imp++;
  505. }
  506. /*
  507. * Now set up the irq mapping for the board.
  508. */
  509. imp = au1xxx_irq_map;
  510. for (i = 0; i < au1xxx_nr_irqs; i++) {
  511. setup_local_irq(imp->im_irq, imp->im_type, imp->im_request);
  512. imp++;
  513. }
  514. set_c0_status(IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4);
  515. /* Board specific IRQ initialization.
  516. */
  517. if (board_init_irq)
  518. board_init_irq();
  519. }