irq.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. /*
  2. * BRIEF MODULE DESCRIPTION
  3. * Au1000 interrupt routines.
  4. *
  5. * Copyright 2001 MontaVista Software Inc.
  6. * Author: MontaVista Software, Inc.
  7. * ppopov@mvista.com or source@mvista.com
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation; either version 2 of the License, or (at your
  12. * option) any later version.
  13. *
  14. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  15. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  16. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  17. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  18. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  19. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  20. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  21. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  23. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. *
  25. * You should have received a copy of the GNU General Public License along
  26. * with this program; if not, write to the Free Software Foundation, Inc.,
  27. * 675 Mass Ave, Cambridge, MA 02139, USA.
  28. */
  29. #include <linux/bitops.h>
  30. #include <linux/init.h>
  31. #include <linux/io.h>
  32. #include <linux/interrupt.h>
  33. #include <linux/irq.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);
  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. if (irq_nr > AU1000_LAST_INTC0_INT) {
  122. au_writel(1 << (irq_nr - 32), IC1_MASKSET);
  123. au_writel(1 << (irq_nr - 32), IC1_WAKESET);
  124. } else {
  125. au_writel(1 << irq_nr, IC0_MASKSET);
  126. au_writel(1 << irq_nr, IC0_WAKESET);
  127. }
  128. au_sync();
  129. }
  130. inline void local_disable_irq(unsigned int irq_nr)
  131. {
  132. if (irq_nr > AU1000_LAST_INTC0_INT) {
  133. au_writel(1 << (irq_nr - 32), IC1_MASKCLR);
  134. au_writel(1 << (irq_nr - 32), IC1_WAKECLR);
  135. } else {
  136. au_writel(1 << irq_nr, IC0_MASKCLR);
  137. au_writel(1 << irq_nr, IC0_WAKECLR);
  138. }
  139. au_sync();
  140. }
  141. static inline void mask_and_ack_rise_edge_irq(unsigned int irq_nr)
  142. {
  143. if (irq_nr > AU1000_LAST_INTC0_INT) {
  144. au_writel(1 << (irq_nr - 32), IC1_RISINGCLR);
  145. au_writel(1 << (irq_nr - 32), IC1_MASKCLR);
  146. } else {
  147. au_writel(1 << irq_nr, IC0_RISINGCLR);
  148. au_writel(1 << irq_nr, IC0_MASKCLR);
  149. }
  150. au_sync();
  151. }
  152. static inline void mask_and_ack_fall_edge_irq(unsigned int irq_nr)
  153. {
  154. if (irq_nr > AU1000_LAST_INTC0_INT) {
  155. au_writel(1 << (irq_nr - 32), IC1_FALLINGCLR);
  156. au_writel(1 << (irq_nr - 32), IC1_MASKCLR);
  157. } else {
  158. au_writel(1 << irq_nr, IC0_FALLINGCLR);
  159. au_writel(1 << irq_nr, IC0_MASKCLR);
  160. }
  161. au_sync();
  162. }
  163. static inline void mask_and_ack_either_edge_irq(unsigned int irq_nr)
  164. {
  165. /* This may assume that we don't get interrupts from
  166. * both edges at once, or if we do, that we don't care.
  167. */
  168. if (irq_nr > AU1000_LAST_INTC0_INT) {
  169. au_writel(1 << (irq_nr - 32), IC1_FALLINGCLR);
  170. au_writel(1 << (irq_nr - 32), IC1_RISINGCLR);
  171. au_writel(1 << (irq_nr - 32), IC1_MASKCLR);
  172. } else {
  173. au_writel(1 << irq_nr, IC0_FALLINGCLR);
  174. au_writel(1 << irq_nr, IC0_RISINGCLR);
  175. au_writel(1 << irq_nr, IC0_MASKCLR);
  176. }
  177. au_sync();
  178. }
  179. static inline void mask_and_ack_level_irq(unsigned int irq_nr)
  180. {
  181. local_disable_irq(irq_nr);
  182. au_sync();
  183. #if defined(CONFIG_MIPS_PB1000)
  184. if (irq_nr == AU1000_GPIO_15) {
  185. au_writel(0x8000, PB1000_MDR); /* ack int */
  186. au_sync();
  187. }
  188. #endif
  189. return;
  190. }
  191. static void end_irq(unsigned int irq_nr)
  192. {
  193. if (!(irq_desc[irq_nr].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
  194. local_enable_irq(irq_nr);
  195. #if defined(CONFIG_MIPS_PB1000)
  196. if (irq_nr == AU1000_GPIO_15) {
  197. au_writel(0x4000, PB1000_MDR); /* enable int */
  198. au_sync();
  199. }
  200. #endif
  201. }
  202. unsigned long save_local_and_disable(int controller)
  203. {
  204. int i;
  205. unsigned long flags, mask;
  206. spin_lock_irqsave(&irq_lock, flags);
  207. if (controller) {
  208. mask = au_readl(IC1_MASKSET);
  209. for (i = 32; i < 64; i++)
  210. local_disable_irq(i);
  211. } else {
  212. mask = au_readl(IC0_MASKSET);
  213. for (i = 0; i < 32; i++)
  214. local_disable_irq(i);
  215. }
  216. spin_unlock_irqrestore(&irq_lock, flags);
  217. return mask;
  218. }
  219. void restore_local_and_enable(int controller, unsigned long mask)
  220. {
  221. int i;
  222. unsigned long flags, new_mask;
  223. spin_lock_irqsave(&irq_lock, flags);
  224. for (i = 0; i < 32; i++) {
  225. if (mask & (1 << i)) {
  226. if (controller)
  227. local_enable_irq(i + 32);
  228. else
  229. local_enable_irq(i);
  230. }
  231. }
  232. if (controller)
  233. new_mask = au_readl(IC1_MASKSET);
  234. else
  235. new_mask = au_readl(IC0_MASKSET);
  236. spin_unlock_irqrestore(&irq_lock, flags);
  237. }
  238. static struct irq_chip rise_edge_irq_type = {
  239. .name = "Au1000 Rise Edge",
  240. .ack = mask_and_ack_rise_edge_irq,
  241. .mask = local_disable_irq,
  242. .mask_ack = mask_and_ack_rise_edge_irq,
  243. .unmask = local_enable_irq,
  244. .end = end_irq,
  245. };
  246. static struct irq_chip fall_edge_irq_type = {
  247. .name = "Au1000 Fall Edge",
  248. .ack = mask_and_ack_fall_edge_irq,
  249. .mask = local_disable_irq,
  250. .mask_ack = mask_and_ack_fall_edge_irq,
  251. .unmask = local_enable_irq,
  252. .end = end_irq,
  253. };
  254. static struct irq_chip either_edge_irq_type = {
  255. .name = "Au1000 Rise or Fall Edge",
  256. .ack = mask_and_ack_either_edge_irq,
  257. .mask = local_disable_irq,
  258. .mask_ack = mask_and_ack_either_edge_irq,
  259. .unmask = local_enable_irq,
  260. .end = end_irq,
  261. };
  262. static struct irq_chip level_irq_type = {
  263. .name = "Au1000 Level",
  264. .ack = mask_and_ack_level_irq,
  265. .mask = local_disable_irq,
  266. .mask_ack = mask_and_ack_level_irq,
  267. .unmask = local_enable_irq,
  268. .end = end_irq,
  269. };
  270. #ifdef CONFIG_PM
  271. void startup_match20_interrupt(irq_handler_t handler)
  272. {
  273. struct irq_desc *desc = &irq_desc[AU1000_TOY_MATCH2_INT];
  274. static struct irqaction action;
  275. memset(&action, 0, sizeof(struct irqaction));
  276. /*
  277. * This is a big problem.... since we didn't use request_irq
  278. * when kernel/irq.c calls probe_irq_xxx this interrupt will
  279. * be probed for usage. This will end up disabling the device :(
  280. * Give it a bogus "action" pointer -- this will keep it from
  281. * getting auto-probed!
  282. *
  283. * By setting the status to match that of request_irq() we
  284. * can avoid it. --cgray
  285. */
  286. action.dev_id = handler;
  287. action.flags = IRQF_DISABLED;
  288. cpus_clear(action.mask);
  289. action.name = "Au1xxx TOY";
  290. action.handler = handler;
  291. action.next = NULL;
  292. desc->action = &action;
  293. desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT | IRQ_WAITING | IRQ_INPROGRESS);
  294. local_enable_irq(AU1000_TOY_MATCH2_INT);
  295. }
  296. #endif
  297. static void setup_local_irq(unsigned int irq_nr, int type, int int_req)
  298. {
  299. if (irq_nr > AU1000_MAX_INTR) return;
  300. /* Config2[n], Config1[n], Config0[n] */
  301. if (irq_nr > AU1000_LAST_INTC0_INT) {
  302. switch (type) {
  303. case INTC_INT_RISE_EDGE: /* 0:0:1 */
  304. au_writel(1 << (irq_nr - 32), IC1_CFG2CLR);
  305. au_writel(1 << (irq_nr - 32), IC1_CFG1CLR);
  306. au_writel(1 << (irq_nr - 32), IC1_CFG0SET);
  307. set_irq_chip(irq_nr, &rise_edge_irq_type);
  308. break;
  309. case INTC_INT_FALL_EDGE: /* 0:1:0 */
  310. au_writel(1 << (irq_nr - 32), IC1_CFG2CLR);
  311. au_writel(1 << (irq_nr - 32), IC1_CFG1SET);
  312. au_writel(1 << (irq_nr - 32), IC1_CFG0CLR);
  313. set_irq_chip(irq_nr, &fall_edge_irq_type);
  314. break;
  315. case INTC_INT_RISE_AND_FALL_EDGE: /* 0:1:1 */
  316. au_writel(1 << (irq_nr - 32), IC1_CFG2CLR);
  317. au_writel(1 << (irq_nr - 32), IC1_CFG1SET);
  318. au_writel(1 << (irq_nr - 32), IC1_CFG0SET);
  319. set_irq_chip(irq_nr, &either_edge_irq_type);
  320. break;
  321. case INTC_INT_HIGH_LEVEL: /* 1:0:1 */
  322. au_writel(1 << (irq_nr - 32), IC1_CFG2SET);
  323. au_writel(1 << (irq_nr - 32), IC1_CFG1CLR);
  324. au_writel(1 << (irq_nr - 32), IC1_CFG0SET);
  325. set_irq_chip(irq_nr, &level_irq_type);
  326. break;
  327. case INTC_INT_LOW_LEVEL: /* 1:1:0 */
  328. au_writel(1 << (irq_nr - 32), IC1_CFG2SET);
  329. au_writel(1 << (irq_nr - 32), IC1_CFG1SET);
  330. au_writel(1 << (irq_nr - 32), IC1_CFG0CLR);
  331. set_irq_chip(irq_nr, &level_irq_type);
  332. break;
  333. case INTC_INT_DISABLED: /* 0:0:0 */
  334. au_writel(1 << (irq_nr - 32), IC1_CFG0CLR);
  335. au_writel(1 << (irq_nr - 32), IC1_CFG1CLR);
  336. au_writel(1 << (irq_nr - 32), IC1_CFG2CLR);
  337. break;
  338. default: /* disable the interrupt */
  339. printk(KERN_WARNING "unexpected int type %d (irq %d)\n",
  340. type, irq_nr);
  341. au_writel(1 << (irq_nr - 32), IC1_CFG0CLR);
  342. au_writel(1 << (irq_nr - 32), IC1_CFG1CLR);
  343. au_writel(1 << (irq_nr - 32), IC1_CFG2CLR);
  344. return;
  345. }
  346. if (int_req) /* assign to interrupt request 1 */
  347. au_writel(1 << (irq_nr - 32), IC1_ASSIGNCLR);
  348. else /* assign to interrupt request 0 */
  349. au_writel(1 << (irq_nr - 32), IC1_ASSIGNSET);
  350. au_writel(1 << (irq_nr - 32), IC1_SRCSET);
  351. au_writel(1 << (irq_nr - 32), IC1_MASKCLR);
  352. au_writel(1 << (irq_nr - 32), IC1_WAKECLR);
  353. } else {
  354. switch (type) {
  355. case INTC_INT_RISE_EDGE: /* 0:0:1 */
  356. au_writel(1 << irq_nr, IC0_CFG2CLR);
  357. au_writel(1 << irq_nr, IC0_CFG1CLR);
  358. au_writel(1 << irq_nr, IC0_CFG0SET);
  359. set_irq_chip(irq_nr, &rise_edge_irq_type);
  360. break;
  361. case INTC_INT_FALL_EDGE: /* 0:1:0 */
  362. au_writel(1 << irq_nr, IC0_CFG2CLR);
  363. au_writel(1 << irq_nr, IC0_CFG1SET);
  364. au_writel(1 << irq_nr, IC0_CFG0CLR);
  365. set_irq_chip(irq_nr, &fall_edge_irq_type);
  366. break;
  367. case INTC_INT_RISE_AND_FALL_EDGE: /* 0:1:1 */
  368. au_writel(1 << irq_nr, IC0_CFG2CLR);
  369. au_writel(1 << irq_nr, IC0_CFG1SET);
  370. au_writel(1 << irq_nr, IC0_CFG0SET);
  371. set_irq_chip(irq_nr, &either_edge_irq_type);
  372. break;
  373. case INTC_INT_HIGH_LEVEL: /* 1:0:1 */
  374. au_writel(1 << irq_nr, IC0_CFG2SET);
  375. au_writel(1 << irq_nr, IC0_CFG1CLR);
  376. au_writel(1 << irq_nr, IC0_CFG0SET);
  377. set_irq_chip(irq_nr, &level_irq_type);
  378. break;
  379. case INTC_INT_LOW_LEVEL: /* 1:1:0 */
  380. au_writel(1 << irq_nr, IC0_CFG2SET);
  381. au_writel(1 << irq_nr, IC0_CFG1SET);
  382. au_writel(1 << irq_nr, IC0_CFG0CLR);
  383. set_irq_chip(irq_nr, &level_irq_type);
  384. break;
  385. case INTC_INT_DISABLED: /* 0:0:0 */
  386. au_writel(1 << irq_nr, IC0_CFG0CLR);
  387. au_writel(1 << irq_nr, IC0_CFG1CLR);
  388. au_writel(1 << irq_nr, IC0_CFG2CLR);
  389. break;
  390. default: /* disable the interrupt */
  391. printk(KERN_WARNING "unexpected int type %d (irq %d)\n",
  392. type, irq_nr);
  393. au_writel(1 << irq_nr, IC0_CFG0CLR);
  394. au_writel(1 << irq_nr, IC0_CFG1CLR);
  395. au_writel(1 << irq_nr, IC0_CFG2CLR);
  396. return;
  397. }
  398. if (int_req) /* assign to interrupt request 1 */
  399. au_writel(1 << irq_nr, IC0_ASSIGNCLR);
  400. else /* assign to interrupt request 0 */
  401. au_writel(1 << irq_nr, IC0_ASSIGNSET);
  402. au_writel(1 << irq_nr, IC0_SRCSET);
  403. au_writel(1 << irq_nr, IC0_MASKCLR);
  404. au_writel(1 << irq_nr, IC0_WAKECLR);
  405. }
  406. au_sync();
  407. }
  408. /*
  409. * Interrupts are nested. Even if an interrupt handler is registered
  410. * as "fast", we might get another interrupt before we return from
  411. * intcX_reqX_irqdispatch().
  412. */
  413. static void intc0_req0_irqdispatch(void)
  414. {
  415. int irq = 0;
  416. static unsigned long intc0_req0;
  417. intc0_req0 |= au_readl(IC0_REQ0INT);
  418. if (!intc0_req0)
  419. return;
  420. #ifdef AU1000_USB_DEV_REQ_INT
  421. /*
  422. * Because of the tight timing of SETUP token to reply
  423. * transactions, the USB devices-side packet complete
  424. * interrupt needs the highest priority.
  425. */
  426. if ((intc0_req0 & (1 << AU1000_USB_DEV_REQ_INT))) {
  427. intc0_req0 &= ~(1 << AU1000_USB_DEV_REQ_INT);
  428. do_IRQ(AU1000_USB_DEV_REQ_INT);
  429. return;
  430. }
  431. #endif
  432. irq = au_ffs(intc0_req0) - 1;
  433. intc0_req0 &= ~(1 << irq);
  434. do_IRQ(irq);
  435. }
  436. static void intc0_req1_irqdispatch(void)
  437. {
  438. int irq = 0;
  439. static unsigned long intc0_req1;
  440. intc0_req1 |= au_readl(IC0_REQ1INT);
  441. if (!intc0_req1)
  442. return;
  443. irq = au_ffs(intc0_req1) - 1;
  444. intc0_req1 &= ~(1 << irq);
  445. do_IRQ(irq);
  446. }
  447. /*
  448. * Interrupt Controller 1:
  449. * interrupts 32 - 63
  450. */
  451. static void intc1_req0_irqdispatch(void)
  452. {
  453. int irq = 0;
  454. static unsigned long intc1_req0;
  455. intc1_req0 |= au_readl(IC1_REQ0INT);
  456. if (!intc1_req0)
  457. return;
  458. irq = au_ffs(intc1_req0) - 1;
  459. intc1_req0 &= ~(1 << irq);
  460. irq += 32;
  461. do_IRQ(irq);
  462. }
  463. static void intc1_req1_irqdispatch(void)
  464. {
  465. int irq = 0;
  466. static unsigned long intc1_req1;
  467. intc1_req1 |= au_readl(IC1_REQ1INT);
  468. if (!intc1_req1)
  469. return;
  470. irq = au_ffs(intc1_req1) - 1;
  471. intc1_req1 &= ~(1 << irq);
  472. irq += 32;
  473. do_IRQ(irq);
  474. }
  475. asmlinkage void plat_irq_dispatch(void)
  476. {
  477. unsigned int pending = read_c0_status() & read_c0_cause() & ST0_IM;
  478. if (pending & CAUSEF_IP7)
  479. do_IRQ(63);
  480. else if (pending & CAUSEF_IP2)
  481. intc0_req0_irqdispatch();
  482. else if (pending & CAUSEF_IP3)
  483. intc0_req1_irqdispatch();
  484. else if (pending & CAUSEF_IP4)
  485. intc1_req0_irqdispatch();
  486. else if (pending & CAUSEF_IP5)
  487. intc1_req1_irqdispatch();
  488. else
  489. spurious_interrupt();
  490. }
  491. void __init arch_init_irq(void)
  492. {
  493. int i;
  494. unsigned long cp0_status;
  495. au1xxx_irq_map_t *imp;
  496. extern au1xxx_irq_map_t au1xxx_irq_map[];
  497. extern au1xxx_irq_map_t au1xxx_ic0_map[];
  498. extern int au1xxx_nr_irqs;
  499. extern int au1xxx_ic0_nr_irqs;
  500. cp0_status = read_c0_status();
  501. /* Initialize interrupt controllers to a safe state.
  502. */
  503. au_writel(0xffffffff, IC0_CFG0CLR);
  504. au_writel(0xffffffff, IC0_CFG1CLR);
  505. au_writel(0xffffffff, IC0_CFG2CLR);
  506. au_writel(0xffffffff, IC0_MASKCLR);
  507. au_writel(0xffffffff, IC0_ASSIGNSET);
  508. au_writel(0xffffffff, IC0_WAKECLR);
  509. au_writel(0xffffffff, IC0_SRCSET);
  510. au_writel(0xffffffff, IC0_FALLINGCLR);
  511. au_writel(0xffffffff, IC0_RISINGCLR);
  512. au_writel(0x00000000, IC0_TESTBIT);
  513. au_writel(0xffffffff, IC1_CFG0CLR);
  514. au_writel(0xffffffff, IC1_CFG1CLR);
  515. au_writel(0xffffffff, IC1_CFG2CLR);
  516. au_writel(0xffffffff, IC1_MASKCLR);
  517. au_writel(0xffffffff, IC1_ASSIGNSET);
  518. au_writel(0xffffffff, IC1_WAKECLR);
  519. au_writel(0xffffffff, IC1_SRCSET);
  520. au_writel(0xffffffff, IC1_FALLINGCLR);
  521. au_writel(0xffffffff, IC1_RISINGCLR);
  522. au_writel(0x00000000, IC1_TESTBIT);
  523. /* Initialize IC0, which is fixed per processor.
  524. */
  525. imp = au1xxx_ic0_map;
  526. for (i = 0; i < au1xxx_ic0_nr_irqs; i++) {
  527. setup_local_irq(imp->im_irq, imp->im_type, imp->im_request);
  528. imp++;
  529. }
  530. /* Now set up the irq mapping for the board.
  531. */
  532. imp = au1xxx_irq_map;
  533. for (i = 0; i < au1xxx_nr_irqs; i++) {
  534. setup_local_irq(imp->im_irq, imp->im_type, imp->im_request);
  535. imp++;
  536. }
  537. set_c0_status(ALLINTS);
  538. /* Board specific IRQ initialization.
  539. */
  540. if (board_init_irq)
  541. (*board_init_irq)();
  542. }