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