irq.c 17 KB

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