sun4c_irq.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /* sun4c_irq.c
  2. * arch/sparc/kernel/sun4c_irq.c:
  3. *
  4. * djhr: Hacked out of irq.c into a CPU dependent version.
  5. *
  6. * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  7. * Copyright (C) 1995 Miguel de Icaza (miguel@nuclecu.unam.mx)
  8. * Copyright (C) 1995 Pete A. Zaitcev (zaitcev@yahoo.com)
  9. * Copyright (C) 1996 Dave Redman (djhr@tadpole.co.uk)
  10. */
  11. #include <linux/errno.h>
  12. #include <linux/linkage.h>
  13. #include <linux/kernel_stat.h>
  14. #include <linux/signal.h>
  15. #include <linux/sched.h>
  16. #include <linux/ptrace.h>
  17. #include <linux/interrupt.h>
  18. #include <linux/init.h>
  19. #include <linux/of.h>
  20. #include <linux/of_device.h>
  21. #include "irq.h"
  22. #include <asm/ptrace.h>
  23. #include <asm/processor.h>
  24. #include <asm/system.h>
  25. #include <asm/psr.h>
  26. #include <asm/vaddrs.h>
  27. #include <asm/timer.h>
  28. #include <asm/openprom.h>
  29. #include <asm/oplib.h>
  30. #include <asm/traps.h>
  31. #include <asm/irq.h>
  32. #include <asm/io.h>
  33. #include <asm/idprom.h>
  34. #include <asm/machines.h>
  35. /*
  36. * Bit field defines for the interrupt registers on various
  37. * Sparc machines.
  38. */
  39. /* The sun4c interrupt register. */
  40. #define SUN4C_INT_ENABLE 0x01 /* Allow interrupts. */
  41. #define SUN4C_INT_E14 0x80 /* Enable level 14 IRQ. */
  42. #define SUN4C_INT_E10 0x20 /* Enable level 10 IRQ. */
  43. #define SUN4C_INT_E8 0x10 /* Enable level 8 IRQ. */
  44. #define SUN4C_INT_E6 0x08 /* Enable level 6 IRQ. */
  45. #define SUN4C_INT_E4 0x04 /* Enable level 4 IRQ. */
  46. #define SUN4C_INT_E1 0x02 /* Enable level 1 IRQ. */
  47. /* Pointer to the interrupt enable byte
  48. *
  49. * Dave Redman (djhr@tadpole.co.uk)
  50. * What you may not be aware of is that entry.S requires this variable.
  51. *
  52. * --- linux_trap_nmi_sun4c --
  53. *
  54. * so don't go making it static, like I tried. sigh.
  55. */
  56. unsigned char __iomem *interrupt_enable = NULL;
  57. static void sun4c_disable_irq(unsigned int irq_nr)
  58. {
  59. unsigned long flags;
  60. unsigned char current_mask, new_mask;
  61. local_irq_save(flags);
  62. irq_nr &= (NR_IRQS - 1);
  63. current_mask = sbus_readb(interrupt_enable);
  64. switch(irq_nr) {
  65. case 1:
  66. new_mask = ((current_mask) & (~(SUN4C_INT_E1)));
  67. break;
  68. case 8:
  69. new_mask = ((current_mask) & (~(SUN4C_INT_E8)));
  70. break;
  71. case 10:
  72. new_mask = ((current_mask) & (~(SUN4C_INT_E10)));
  73. break;
  74. case 14:
  75. new_mask = ((current_mask) & (~(SUN4C_INT_E14)));
  76. break;
  77. default:
  78. local_irq_restore(flags);
  79. return;
  80. }
  81. sbus_writeb(new_mask, interrupt_enable);
  82. local_irq_restore(flags);
  83. }
  84. static void sun4c_enable_irq(unsigned int irq_nr)
  85. {
  86. unsigned long flags;
  87. unsigned char current_mask, new_mask;
  88. local_irq_save(flags);
  89. irq_nr &= (NR_IRQS - 1);
  90. current_mask = sbus_readb(interrupt_enable);
  91. switch(irq_nr) {
  92. case 1:
  93. new_mask = ((current_mask) | SUN4C_INT_E1);
  94. break;
  95. case 8:
  96. new_mask = ((current_mask) | SUN4C_INT_E8);
  97. break;
  98. case 10:
  99. new_mask = ((current_mask) | SUN4C_INT_E10);
  100. break;
  101. case 14:
  102. new_mask = ((current_mask) | SUN4C_INT_E14);
  103. break;
  104. default:
  105. local_irq_restore(flags);
  106. return;
  107. }
  108. sbus_writeb(new_mask, interrupt_enable);
  109. local_irq_restore(flags);
  110. }
  111. struct sun4c_timer_info {
  112. u32 l10_count;
  113. u32 l10_limit;
  114. u32 l14_count;
  115. u32 l14_limit;
  116. };
  117. static struct sun4c_timer_info __iomem *sun4c_timers;
  118. static void sun4c_clear_clock_irq(void)
  119. {
  120. sbus_readl(&sun4c_timers->l10_limit);
  121. }
  122. static void sun4c_load_profile_irq(int cpu, unsigned int limit)
  123. {
  124. /* Errm.. not sure how to do this.. */
  125. }
  126. static void __init sun4c_init_timers(irq_handler_t counter_fn)
  127. {
  128. const struct linux_prom_irqs *irq;
  129. struct device_node *dp;
  130. const u32 *addr;
  131. int err;
  132. dp = of_find_node_by_name(NULL, "counter-timer");
  133. if (!dp) {
  134. prom_printf("sun4c_init_timers: Unable to find counter-timer\n");
  135. prom_halt();
  136. }
  137. addr = of_get_property(dp, "address", NULL);
  138. if (!addr) {
  139. prom_printf("sun4c_init_timers: No address property\n");
  140. prom_halt();
  141. }
  142. sun4c_timers = (void __iomem *) (unsigned long) addr[0];
  143. irq = of_get_property(dp, "intr", NULL);
  144. of_node_put(dp);
  145. if (!irq) {
  146. prom_printf("sun4c_init_timers: No intr property\n");
  147. prom_halt();
  148. }
  149. /* Have the level 10 timer tick at 100HZ. We don't touch the
  150. * level 14 timer limit since we are letting the prom handle
  151. * them until we have a real console driver so L1-A works.
  152. */
  153. sbus_writel((((1000000/HZ) + 1) << 10), &sun4c_timers->l10_limit);
  154. master_l10_counter = &sun4c_timers->l10_count;
  155. err = request_irq(irq[0].pri, counter_fn,
  156. (IRQF_DISABLED | SA_STATIC_ALLOC),
  157. "timer", NULL);
  158. if (err) {
  159. prom_printf("sun4c_init_timers: request_irq() fails with %d\n", err);
  160. prom_halt();
  161. }
  162. sun4c_disable_irq(irq[1].pri);
  163. }
  164. #ifdef CONFIG_SMP
  165. static void sun4c_nop(void) {}
  166. #endif
  167. void __init sun4c_init_IRQ(void)
  168. {
  169. struct device_node *dp;
  170. const u32 *addr;
  171. dp = of_find_node_by_name(NULL, "interrupt-enable");
  172. if (!dp) {
  173. prom_printf("sun4c_init_IRQ: Unable to find interrupt-enable\n");
  174. prom_halt();
  175. }
  176. addr = of_get_property(dp, "address", NULL);
  177. of_node_put(dp);
  178. if (!addr) {
  179. prom_printf("sun4c_init_IRQ: No address property\n");
  180. prom_halt();
  181. }
  182. interrupt_enable = (void __iomem *) (unsigned long) addr[0];
  183. BTFIXUPSET_CALL(enable_irq, sun4c_enable_irq, BTFIXUPCALL_NORM);
  184. BTFIXUPSET_CALL(disable_irq, sun4c_disable_irq, BTFIXUPCALL_NORM);
  185. BTFIXUPSET_CALL(enable_pil_irq, sun4c_enable_irq, BTFIXUPCALL_NORM);
  186. BTFIXUPSET_CALL(disable_pil_irq, sun4c_disable_irq, BTFIXUPCALL_NORM);
  187. BTFIXUPSET_CALL(clear_clock_irq, sun4c_clear_clock_irq, BTFIXUPCALL_NORM);
  188. BTFIXUPSET_CALL(load_profile_irq, sun4c_load_profile_irq, BTFIXUPCALL_NOP);
  189. sparc_init_timers = sun4c_init_timers;
  190. #ifdef CONFIG_SMP
  191. BTFIXUPSET_CALL(set_cpu_int, sun4c_nop, BTFIXUPCALL_NOP);
  192. BTFIXUPSET_CALL(clear_cpu_int, sun4c_nop, BTFIXUPCALL_NOP);
  193. BTFIXUPSET_CALL(set_irq_udt, sun4c_nop, BTFIXUPCALL_NOP);
  194. #endif
  195. sbus_writeb(SUN4C_INT_ENABLE, interrupt_enable);
  196. /* Cannot enable interrupts until OBP ticker is disabled. */
  197. }