irq.c 18 KB

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