irq.c 19 KB

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