irq.c 16 KB

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