irq.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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. #include <asm/arch/msi.h>
  30. /* INTCTL0 CP6 R0 Page 4
  31. */
  32. static inline u32 read_intctl_0(void)
  33. {
  34. u32 val;
  35. asm volatile("mrc p6, 0, %0, c0, c4, 0":"=r" (val));
  36. return val;
  37. }
  38. static inline void write_intctl_0(u32 val)
  39. {
  40. asm volatile("mcr p6, 0, %0, c0, c4, 0"::"r" (val));
  41. }
  42. /* INTCTL1 CP6 R1 Page 4
  43. */
  44. static inline u32 read_intctl_1(void)
  45. {
  46. u32 val;
  47. asm volatile("mrc p6, 0, %0, c1, c4, 0":"=r" (val));
  48. return val;
  49. }
  50. static inline void write_intctl_1(u32 val)
  51. {
  52. asm volatile("mcr p6, 0, %0, c1, c4, 0"::"r" (val));
  53. }
  54. /* INTCTL2 CP6 R2 Page 4
  55. */
  56. static inline u32 read_intctl_2(void)
  57. {
  58. u32 val;
  59. asm volatile("mrc p6, 0, %0, c2, c4, 0":"=r" (val));
  60. return val;
  61. }
  62. static inline void write_intctl_2(u32 val)
  63. {
  64. asm volatile("mcr p6, 0, %0, c2, c4, 0"::"r" (val));
  65. }
  66. /* INTCTL3 CP6 R3 Page 4
  67. */
  68. static inline u32 read_intctl_3(void)
  69. {
  70. u32 val;
  71. asm volatile("mrc p6, 0, %0, c3, c4, 0":"=r" (val));
  72. return val;
  73. }
  74. static inline void write_intctl_3(u32 val)
  75. {
  76. asm volatile("mcr p6, 0, %0, c3, c4, 0"::"r" (val));
  77. }
  78. /* INTSTR0 CP6 R0 Page 5
  79. */
  80. static inline u32 read_intstr_0(void)
  81. {
  82. u32 val;
  83. asm volatile("mrc p6, 0, %0, c0, c5, 0":"=r" (val));
  84. return val;
  85. }
  86. static inline void write_intstr_0(u32 val)
  87. {
  88. asm volatile("mcr p6, 0, %0, c0, c5, 0"::"r" (val));
  89. }
  90. /* INTSTR1 CP6 R1 Page 5
  91. */
  92. static inline u32 read_intstr_1(void)
  93. {
  94. u32 val;
  95. asm volatile("mrc p6, 0, %0, c1, c5, 0":"=r" (val));
  96. return val;
  97. }
  98. static void write_intstr_1(u32 val)
  99. {
  100. asm volatile("mcr p6, 0, %0, c1, c5, 0"::"r" (val));
  101. }
  102. /* INTSTR2 CP6 R2 Page 5
  103. */
  104. static inline u32 read_intstr_2(void)
  105. {
  106. u32 val;
  107. asm volatile("mrc p6, 0, %0, c2, c5, 0":"=r" (val));
  108. return val;
  109. }
  110. static void write_intstr_2(u32 val)
  111. {
  112. asm volatile("mcr p6, 0, %0, c2, c5, 0"::"r" (val));
  113. }
  114. /* INTSTR3 CP6 R3 Page 5
  115. */
  116. static inline u32 read_intstr_3(void)
  117. {
  118. u32 val;
  119. asm volatile("mrc p6, 0, %0, c3, c5, 0":"=r" (val));
  120. return val;
  121. }
  122. static void write_intstr_3(u32 val)
  123. {
  124. asm volatile("mcr p6, 0, %0, c3, c5, 0"::"r" (val));
  125. }
  126. /* INTBASE CP6 R0 Page 2
  127. */
  128. static inline u32 read_intbase(void)
  129. {
  130. u32 val;
  131. asm volatile("mrc p6, 0, %0, c0, c2, 0":"=r" (val));
  132. return val;
  133. }
  134. static void write_intbase(u32 val)
  135. {
  136. asm volatile("mcr p6, 0, %0, c0, c2, 0"::"r" (val));
  137. }
  138. /* INTSIZE CP6 R2 Page 2
  139. */
  140. static inline u32 read_intsize(void)
  141. {
  142. u32 val;
  143. asm volatile("mrc p6, 0, %0, c2, c2, 0":"=r" (val));
  144. return val;
  145. }
  146. static void write_intsize(u32 val)
  147. {
  148. asm volatile("mcr p6, 0, %0, c2, c2, 0"::"r" (val));
  149. }
  150. /* 0 = Interrupt Masked and 1 = Interrupt not masked */
  151. static void
  152. iop13xx_irq_mask0 (unsigned int irq)
  153. {
  154. write_intctl_0(read_intctl_0() & ~(1 << (irq - 0)));
  155. }
  156. static void
  157. iop13xx_irq_mask1 (unsigned int irq)
  158. {
  159. write_intctl_1(read_intctl_1() & ~(1 << (irq - 32)));
  160. }
  161. static void
  162. iop13xx_irq_mask2 (unsigned int irq)
  163. {
  164. write_intctl_2(read_intctl_2() & ~(1 << (irq - 64)));
  165. }
  166. static void
  167. iop13xx_irq_mask3 (unsigned int irq)
  168. {
  169. write_intctl_3(read_intctl_3() & ~(1 << (irq - 96)));
  170. }
  171. static void
  172. iop13xx_irq_unmask0(unsigned int irq)
  173. {
  174. write_intctl_0(read_intctl_0() | (1 << (irq - 0)));
  175. }
  176. static void
  177. iop13xx_irq_unmask1(unsigned int irq)
  178. {
  179. write_intctl_1(read_intctl_1() | (1 << (irq - 32)));
  180. }
  181. static void
  182. iop13xx_irq_unmask2(unsigned int irq)
  183. {
  184. write_intctl_2(read_intctl_2() | (1 << (irq - 64)));
  185. }
  186. static void
  187. iop13xx_irq_unmask3(unsigned int irq)
  188. {
  189. write_intctl_3(read_intctl_3() | (1 << (irq - 96)));
  190. }
  191. static struct irq_chip iop13xx_irqchip1 = {
  192. .name = "IOP13xx-1",
  193. .ack = iop13xx_irq_mask0,
  194. .mask = iop13xx_irq_mask0,
  195. .unmask = iop13xx_irq_unmask0,
  196. };
  197. static struct irq_chip iop13xx_irqchip2 = {
  198. .name = "IOP13xx-2",
  199. .ack = iop13xx_irq_mask1,
  200. .mask = iop13xx_irq_mask1,
  201. .unmask = iop13xx_irq_unmask1,
  202. };
  203. static struct irq_chip iop13xx_irqchip3 = {
  204. .name = "IOP13xx-3",
  205. .ack = iop13xx_irq_mask2,
  206. .mask = iop13xx_irq_mask2,
  207. .unmask = iop13xx_irq_unmask2,
  208. };
  209. static struct irq_chip iop13xx_irqchip4 = {
  210. .name = "IOP13xx-4",
  211. .ack = iop13xx_irq_mask3,
  212. .mask = iop13xx_irq_mask3,
  213. .unmask = iop13xx_irq_unmask3,
  214. };
  215. extern void iop_init_cp6_handler(void);
  216. void __init iop13xx_init_irq(void)
  217. {
  218. unsigned int i;
  219. iop_init_cp6_handler();
  220. /* disable all interrupts */
  221. write_intctl_0(0);
  222. write_intctl_1(0);
  223. write_intctl_2(0);
  224. write_intctl_3(0);
  225. /* treat all as IRQ */
  226. write_intstr_0(0);
  227. write_intstr_1(0);
  228. write_intstr_2(0);
  229. write_intstr_3(0);
  230. /* initialize the interrupt vector generator */
  231. write_intbase(INTBASE);
  232. write_intsize(INTSIZE_4);
  233. for(i = 0; i <= IRQ_IOP13XX_HPI; i++) {
  234. if (i < 32)
  235. set_irq_chip(i, &iop13xx_irqchip1);
  236. else if (i < 64)
  237. set_irq_chip(i, &iop13xx_irqchip2);
  238. else if (i < 96)
  239. set_irq_chip(i, &iop13xx_irqchip3);
  240. else
  241. set_irq_chip(i, &iop13xx_irqchip4);
  242. set_irq_handler(i, handle_level_irq);
  243. set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
  244. }
  245. iop13xx_msi_init();
  246. }