irq.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. /*
  2. * iop13xx IRQ handling / support functions
  3. * Copyright (c) 2005-2006, Intel Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  16. * Place - Suite 330, Boston, MA 02111-1307 USA.
  17. *
  18. */
  19. #include <linux/init.h>
  20. #include <linux/interrupt.h>
  21. #include <linux/list.h>
  22. #include <linux/sysctl.h>
  23. #include <asm/uaccess.h>
  24. #include <asm/mach/irq.h>
  25. #include <asm/irq.h>
  26. #include <asm/hardware.h>
  27. #include <asm/mach-types.h>
  28. #include <asm/arch/irqs.h>
  29. /* INTCTL0 CP6 R0 Page 4
  30. */
  31. static inline u32 read_intctl_0(void)
  32. {
  33. u32 val;
  34. asm volatile("mrc p6, 0, %0, c0, c4, 0":"=r" (val));
  35. return val;
  36. }
  37. static inline void write_intctl_0(u32 val)
  38. {
  39. asm volatile("mcr p6, 0, %0, c0, c4, 0"::"r" (val));
  40. }
  41. /* INTCTL1 CP6 R1 Page 4
  42. */
  43. static inline u32 read_intctl_1(void)
  44. {
  45. u32 val;
  46. asm volatile("mrc p6, 0, %0, c1, c4, 0":"=r" (val));
  47. return val;
  48. }
  49. static inline void write_intctl_1(u32 val)
  50. {
  51. asm volatile("mcr p6, 0, %0, c1, c4, 0"::"r" (val));
  52. }
  53. /* INTCTL2 CP6 R2 Page 4
  54. */
  55. static inline u32 read_intctl_2(void)
  56. {
  57. u32 val;
  58. asm volatile("mrc p6, 0, %0, c2, c4, 0":"=r" (val));
  59. return val;
  60. }
  61. static inline void write_intctl_2(u32 val)
  62. {
  63. asm volatile("mcr p6, 0, %0, c2, c4, 0"::"r" (val));
  64. }
  65. /* INTCTL3 CP6 R3 Page 4
  66. */
  67. static inline u32 read_intctl_3(void)
  68. {
  69. u32 val;
  70. asm volatile("mrc p6, 0, %0, c3, c4, 0":"=r" (val));
  71. return val;
  72. }
  73. static inline void write_intctl_3(u32 val)
  74. {
  75. asm volatile("mcr p6, 0, %0, c3, c4, 0"::"r" (val));
  76. }
  77. /* INTSTR0 CP6 R0 Page 5
  78. */
  79. static inline u32 read_intstr_0(void)
  80. {
  81. u32 val;
  82. asm volatile("mrc p6, 0, %0, c0, c5, 0":"=r" (val));
  83. return val;
  84. }
  85. static inline void write_intstr_0(u32 val)
  86. {
  87. asm volatile("mcr p6, 0, %0, c0, c5, 0"::"r" (val));
  88. }
  89. /* INTSTR1 CP6 R1 Page 5
  90. */
  91. static inline u32 read_intstr_1(void)
  92. {
  93. u32 val;
  94. asm volatile("mrc p6, 0, %0, c1, c5, 0":"=r" (val));
  95. return val;
  96. }
  97. static void write_intstr_1(u32 val)
  98. {
  99. asm volatile("mcr p6, 0, %0, c1, c5, 0"::"r" (val));
  100. }
  101. /* INTSTR2 CP6 R2 Page 5
  102. */
  103. static inline u32 read_intstr_2(void)
  104. {
  105. u32 val;
  106. asm volatile("mrc p6, 0, %0, c2, c5, 0":"=r" (val));
  107. return val;
  108. }
  109. static void write_intstr_2(u32 val)
  110. {
  111. asm volatile("mcr p6, 0, %0, c2, c5, 0"::"r" (val));
  112. }
  113. /* INTSTR3 CP6 R3 Page 5
  114. */
  115. static inline u32 read_intstr_3(void)
  116. {
  117. u32 val;
  118. asm volatile("mrc p6, 0, %0, c3, c5, 0":"=r" (val));
  119. return val;
  120. }
  121. static void write_intstr_3(u32 val)
  122. {
  123. asm volatile("mcr p6, 0, %0, c3, c5, 0"::"r" (val));
  124. }
  125. /* INTBASE CP6 R0 Page 2
  126. */
  127. static inline u32 read_intbase(void)
  128. {
  129. u32 val;
  130. asm volatile("mrc p6, 0, %0, c0, c2, 0":"=r" (val));
  131. return val;
  132. }
  133. static void write_intbase(u32 val)
  134. {
  135. asm volatile("mcr p6, 0, %0, c0, c2, 0"::"r" (val));
  136. }
  137. /* INTSIZE CP6 R2 Page 2
  138. */
  139. static inline u32 read_intsize(void)
  140. {
  141. u32 val;
  142. asm volatile("mrc p6, 0, %0, c2, c2, 0":"=r" (val));
  143. return val;
  144. }
  145. static void write_intsize(u32 val)
  146. {
  147. asm volatile("mcr p6, 0, %0, c2, c2, 0"::"r" (val));
  148. }
  149. /* 0 = Interrupt Masked and 1 = Interrupt not masked */
  150. static void
  151. iop13xx_irq_mask0 (unsigned int irq)
  152. {
  153. u32 cp_flags = iop13xx_cp6_save();
  154. write_intctl_0(read_intctl_0() & ~(1 << (irq - 0)));
  155. iop13xx_cp6_restore(cp_flags);
  156. }
  157. static void
  158. iop13xx_irq_mask1 (unsigned int irq)
  159. {
  160. u32 cp_flags = iop13xx_cp6_save();
  161. write_intctl_1(read_intctl_1() & ~(1 << (irq - 32)));
  162. iop13xx_cp6_restore(cp_flags);
  163. }
  164. static void
  165. iop13xx_irq_mask2 (unsigned int irq)
  166. {
  167. u32 cp_flags = iop13xx_cp6_save();
  168. write_intctl_2(read_intctl_2() & ~(1 << (irq - 64)));
  169. iop13xx_cp6_restore(cp_flags);
  170. }
  171. static void
  172. iop13xx_irq_mask3 (unsigned int irq)
  173. {
  174. u32 cp_flags = iop13xx_cp6_save();
  175. write_intctl_3(read_intctl_3() & ~(1 << (irq - 96)));
  176. iop13xx_cp6_restore(cp_flags);
  177. }
  178. static void
  179. iop13xx_irq_unmask0(unsigned int irq)
  180. {
  181. u32 cp_flags = iop13xx_cp6_save();
  182. write_intctl_0(read_intctl_0() | (1 << (irq - 0)));
  183. iop13xx_cp6_restore(cp_flags);
  184. }
  185. static void
  186. iop13xx_irq_unmask1(unsigned int irq)
  187. {
  188. u32 cp_flags = iop13xx_cp6_save();
  189. write_intctl_1(read_intctl_1() | (1 << (irq - 32)));
  190. iop13xx_cp6_restore(cp_flags);
  191. }
  192. static void
  193. iop13xx_irq_unmask2(unsigned int irq)
  194. {
  195. u32 cp_flags = iop13xx_cp6_save();
  196. write_intctl_2(read_intctl_2() | (1 << (irq - 64)));
  197. iop13xx_cp6_restore(cp_flags);
  198. }
  199. static void
  200. iop13xx_irq_unmask3(unsigned int irq)
  201. {
  202. u32 cp_flags = iop13xx_cp6_save();
  203. write_intctl_3(read_intctl_3() | (1 << (irq - 96)));
  204. iop13xx_cp6_restore(cp_flags);
  205. }
  206. static struct irq_chip iop13xx_irqchip1 = {
  207. .name = "IOP13xx-1",
  208. .ack = iop13xx_irq_mask0,
  209. .mask = iop13xx_irq_mask0,
  210. .unmask = iop13xx_irq_unmask0,
  211. };
  212. static struct irq_chip iop13xx_irqchip2 = {
  213. .name = "IOP13xx-2",
  214. .ack = iop13xx_irq_mask1,
  215. .mask = iop13xx_irq_mask1,
  216. .unmask = iop13xx_irq_unmask1,
  217. };
  218. static struct irq_chip iop13xx_irqchip3 = {
  219. .name = "IOP13xx-3",
  220. .ack = iop13xx_irq_mask2,
  221. .mask = iop13xx_irq_mask2,
  222. .unmask = iop13xx_irq_unmask2,
  223. };
  224. static struct irq_chip iop13xx_irqchip4 = {
  225. .name = "IOP13xx-4",
  226. .ack = iop13xx_irq_mask3,
  227. .mask = iop13xx_irq_mask3,
  228. .unmask = iop13xx_irq_unmask3,
  229. };
  230. void __init iop13xx_init_irq(void)
  231. {
  232. unsigned int i;
  233. u32 cp_flags = iop13xx_cp6_save();
  234. /* disable all interrupts */
  235. write_intctl_0(0);
  236. write_intctl_1(0);
  237. write_intctl_2(0);
  238. write_intctl_3(0);
  239. /* treat all as IRQ */
  240. write_intstr_0(0);
  241. write_intstr_1(0);
  242. write_intstr_2(0);
  243. write_intstr_3(0);
  244. /* initialize the interrupt vector generator */
  245. write_intbase(INTBASE);
  246. write_intsize(INTSIZE_4);
  247. for(i = 0; i < NR_IOP13XX_IRQS; i++) {
  248. if (i < 32)
  249. set_irq_chip(i, &iop13xx_irqchip1);
  250. else if (i < 64)
  251. set_irq_chip(i, &iop13xx_irqchip2);
  252. else if (i < 96)
  253. set_irq_chip(i, &iop13xx_irqchip3);
  254. else
  255. set_irq_chip(i, &iop13xx_irqchip4);
  256. set_irq_handler(i, handle_level_irq);
  257. set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
  258. }
  259. iop13xx_cp6_restore(cp_flags);
  260. }