irq.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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 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 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 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 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 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 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 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 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 void write_intstr_0(u32 val)
  81. {
  82. asm volatile("mcr p6, 0, %0, c0, c5, 0"::"r" (val));
  83. }
  84. /* INTSTR1 CP6 R1 Page 5
  85. */
  86. static void write_intstr_1(u32 val)
  87. {
  88. asm volatile("mcr p6, 0, %0, c1, c5, 0"::"r" (val));
  89. }
  90. /* INTSTR2 CP6 R2 Page 5
  91. */
  92. static void write_intstr_2(u32 val)
  93. {
  94. asm volatile("mcr p6, 0, %0, c2, c5, 0"::"r" (val));
  95. }
  96. /* INTSTR3 CP6 R3 Page 5
  97. */
  98. static void write_intstr_3(u32 val)
  99. {
  100. asm volatile("mcr p6, 0, %0, c3, c5, 0"::"r" (val));
  101. }
  102. /* INTBASE CP6 R0 Page 2
  103. */
  104. static void write_intbase(u32 val)
  105. {
  106. asm volatile("mcr p6, 0, %0, c0, c2, 0"::"r" (val));
  107. }
  108. /* INTSIZE CP6 R2 Page 2
  109. */
  110. static void write_intsize(u32 val)
  111. {
  112. asm volatile("mcr p6, 0, %0, c2, c2, 0"::"r" (val));
  113. }
  114. /* 0 = Interrupt Masked and 1 = Interrupt not masked */
  115. static void
  116. iop13xx_irq_mask0 (unsigned int irq)
  117. {
  118. write_intctl_0(read_intctl_0() & ~(1 << (irq - 0)));
  119. }
  120. static void
  121. iop13xx_irq_mask1 (unsigned int irq)
  122. {
  123. write_intctl_1(read_intctl_1() & ~(1 << (irq - 32)));
  124. }
  125. static void
  126. iop13xx_irq_mask2 (unsigned int irq)
  127. {
  128. write_intctl_2(read_intctl_2() & ~(1 << (irq - 64)));
  129. }
  130. static void
  131. iop13xx_irq_mask3 (unsigned int irq)
  132. {
  133. write_intctl_3(read_intctl_3() & ~(1 << (irq - 96)));
  134. }
  135. static void
  136. iop13xx_irq_unmask0(unsigned int irq)
  137. {
  138. write_intctl_0(read_intctl_0() | (1 << (irq - 0)));
  139. }
  140. static void
  141. iop13xx_irq_unmask1(unsigned int irq)
  142. {
  143. write_intctl_1(read_intctl_1() | (1 << (irq - 32)));
  144. }
  145. static void
  146. iop13xx_irq_unmask2(unsigned int irq)
  147. {
  148. write_intctl_2(read_intctl_2() | (1 << (irq - 64)));
  149. }
  150. static void
  151. iop13xx_irq_unmask3(unsigned int irq)
  152. {
  153. write_intctl_3(read_intctl_3() | (1 << (irq - 96)));
  154. }
  155. static struct irq_chip iop13xx_irqchip1 = {
  156. .name = "IOP13xx-1",
  157. .ack = iop13xx_irq_mask0,
  158. .mask = iop13xx_irq_mask0,
  159. .unmask = iop13xx_irq_unmask0,
  160. };
  161. static struct irq_chip iop13xx_irqchip2 = {
  162. .name = "IOP13xx-2",
  163. .ack = iop13xx_irq_mask1,
  164. .mask = iop13xx_irq_mask1,
  165. .unmask = iop13xx_irq_unmask1,
  166. };
  167. static struct irq_chip iop13xx_irqchip3 = {
  168. .name = "IOP13xx-3",
  169. .ack = iop13xx_irq_mask2,
  170. .mask = iop13xx_irq_mask2,
  171. .unmask = iop13xx_irq_unmask2,
  172. };
  173. static struct irq_chip iop13xx_irqchip4 = {
  174. .name = "IOP13xx-4",
  175. .ack = iop13xx_irq_mask3,
  176. .mask = iop13xx_irq_mask3,
  177. .unmask = iop13xx_irq_unmask3,
  178. };
  179. extern void iop_init_cp6_handler(void);
  180. void __init iop13xx_init_irq(void)
  181. {
  182. unsigned int i;
  183. iop_init_cp6_handler();
  184. /* disable all interrupts */
  185. write_intctl_0(0);
  186. write_intctl_1(0);
  187. write_intctl_2(0);
  188. write_intctl_3(0);
  189. /* treat all as IRQ */
  190. write_intstr_0(0);
  191. write_intstr_1(0);
  192. write_intstr_2(0);
  193. write_intstr_3(0);
  194. /* initialize the interrupt vector generator */
  195. write_intbase(INTBASE);
  196. write_intsize(INTSIZE_4);
  197. for(i = 0; i <= IRQ_IOP13XX_HPI; i++) {
  198. if (i < 32)
  199. set_irq_chip(i, &iop13xx_irqchip1);
  200. else if (i < 64)
  201. set_irq_chip(i, &iop13xx_irqchip2);
  202. else if (i < 96)
  203. set_irq_chip(i, &iop13xx_irqchip3);
  204. else
  205. set_irq_chip(i, &iop13xx_irqchip4);
  206. set_irq_handler(i, handle_level_irq);
  207. set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
  208. }
  209. iop13xx_msi_init();
  210. }