irq.c 16 KB

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