sun4c_irq.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /*
  2. * sun4c irq support
  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/init.h>
  12. #include <asm/oplib.h>
  13. #include <asm/timer.h>
  14. #include <asm/irq.h>
  15. #include <asm/io.h>
  16. #include "irq.h"
  17. /* Sun4c interrupts are typically laid out as follows:
  18. *
  19. * 1 - Software interrupt, SBUS level 1
  20. * 2 - SBUS level 2
  21. * 3 - ESP SCSI, SBUS level 3
  22. * 4 - Software interrupt
  23. * 5 - Lance ethernet, SBUS level 4
  24. * 6 - Software interrupt
  25. * 7 - Graphics card, SBUS level 5
  26. * 8 - SBUS level 6
  27. * 9 - SBUS level 7
  28. * 10 - Counter timer
  29. * 11 - Floppy
  30. * 12 - Zilog uart
  31. * 13 - CS4231 audio
  32. * 14 - Profiling timer
  33. * 15 - NMI
  34. *
  35. * The interrupt enable bits in the interrupt mask register are
  36. * really only used to enable/disable the timer interrupts, and
  37. * for signalling software interrupts. There is also a master
  38. * interrupt enable bit in this register.
  39. *
  40. * Interrupts are enabled by setting the SUN4C_INT_* bits, they
  41. * are disabled by clearing those bits.
  42. */
  43. /*
  44. * Bit field defines for the interrupt registers on various
  45. * Sparc machines.
  46. */
  47. /* The sun4c interrupt register. */
  48. #define SUN4C_INT_ENABLE 0x01 /* Allow interrupts. */
  49. #define SUN4C_INT_E14 0x80 /* Enable level 14 IRQ. */
  50. #define SUN4C_INT_E10 0x20 /* Enable level 10 IRQ. */
  51. #define SUN4C_INT_E8 0x10 /* Enable level 8 IRQ. */
  52. #define SUN4C_INT_E6 0x08 /* Enable level 6 IRQ. */
  53. #define SUN4C_INT_E4 0x04 /* Enable level 4 IRQ. */
  54. #define SUN4C_INT_E1 0x02 /* Enable level 1 IRQ. */
  55. /*
  56. * Pointer to the interrupt enable byte
  57. * Used by entry.S
  58. */
  59. unsigned char __iomem *interrupt_enable;
  60. static void sun4c_disable_irq(unsigned int irq_nr)
  61. {
  62. unsigned long flags;
  63. unsigned char current_mask, new_mask;
  64. local_irq_save(flags);
  65. irq_nr &= (NR_IRQS - 1);
  66. current_mask = sbus_readb(interrupt_enable);
  67. switch (irq_nr) {
  68. case 1:
  69. new_mask = ((current_mask) & (~(SUN4C_INT_E1)));
  70. break;
  71. case 8:
  72. new_mask = ((current_mask) & (~(SUN4C_INT_E8)));
  73. break;
  74. case 10:
  75. new_mask = ((current_mask) & (~(SUN4C_INT_E10)));
  76. break;
  77. case 14:
  78. new_mask = ((current_mask) & (~(SUN4C_INT_E14)));
  79. break;
  80. default:
  81. local_irq_restore(flags);
  82. return;
  83. }
  84. sbus_writeb(new_mask, interrupt_enable);
  85. local_irq_restore(flags);
  86. }
  87. static void sun4c_enable_irq(unsigned int irq_nr)
  88. {
  89. unsigned long flags;
  90. unsigned char current_mask, new_mask;
  91. local_irq_save(flags);
  92. irq_nr &= (NR_IRQS - 1);
  93. current_mask = sbus_readb(interrupt_enable);
  94. switch (irq_nr) {
  95. case 1:
  96. new_mask = ((current_mask) | SUN4C_INT_E1);
  97. break;
  98. case 8:
  99. new_mask = ((current_mask) | SUN4C_INT_E8);
  100. break;
  101. case 10:
  102. new_mask = ((current_mask) | SUN4C_INT_E10);
  103. break;
  104. case 14:
  105. new_mask = ((current_mask) | SUN4C_INT_E14);
  106. break;
  107. default:
  108. local_irq_restore(flags);
  109. return;
  110. }
  111. sbus_writeb(new_mask, interrupt_enable);
  112. local_irq_restore(flags);
  113. }
  114. struct sun4c_timer_info {
  115. u32 l10_count;
  116. u32 l10_limit;
  117. u32 l14_count;
  118. u32 l14_limit;
  119. };
  120. static struct sun4c_timer_info __iomem *sun4c_timers;
  121. static void sun4c_clear_clock_irq(void)
  122. {
  123. sbus_readl(&sun4c_timers->l10_limit);
  124. }
  125. static void sun4c_load_profile_irq(int cpu, unsigned int limit)
  126. {
  127. /* Errm.. not sure how to do this.. */
  128. }
  129. static void __init sun4c_init_timers(irq_handler_t counter_fn)
  130. {
  131. const struct linux_prom_irqs *irq;
  132. struct device_node *dp;
  133. const u32 *addr;
  134. int err;
  135. dp = of_find_node_by_name(NULL, "counter-timer");
  136. if (!dp) {
  137. prom_printf("sun4c_init_timers: Unable to find counter-timer\n");
  138. prom_halt();
  139. }
  140. addr = of_get_property(dp, "address", NULL);
  141. if (!addr) {
  142. prom_printf("sun4c_init_timers: No address property\n");
  143. prom_halt();
  144. }
  145. sun4c_timers = (void __iomem *) (unsigned long) addr[0];
  146. irq = of_get_property(dp, "intr", NULL);
  147. of_node_put(dp);
  148. if (!irq) {
  149. prom_printf("sun4c_init_timers: No intr property\n");
  150. prom_halt();
  151. }
  152. /* Have the level 10 timer tick at 100HZ. We don't touch the
  153. * level 14 timer limit since we are letting the prom handle
  154. * them until we have a real console driver so L1-A works.
  155. */
  156. sbus_writel((((1000000/HZ) + 1) << 10), &sun4c_timers->l10_limit);
  157. master_l10_counter = &sun4c_timers->l10_count;
  158. err = request_irq(irq[0].pri, counter_fn,
  159. (IRQF_DISABLED | SA_STATIC_ALLOC),
  160. "timer", NULL);
  161. if (err) {
  162. prom_printf("sun4c_init_timers: request_irq() fails with %d\n", err);
  163. prom_halt();
  164. }
  165. sun4c_disable_irq(irq[1].pri);
  166. }
  167. #ifdef CONFIG_SMP
  168. static void sun4c_nop(void)
  169. {
  170. }
  171. #endif
  172. void __init sun4c_init_IRQ(void)
  173. {
  174. struct device_node *dp;
  175. const u32 *addr;
  176. dp = of_find_node_by_name(NULL, "interrupt-enable");
  177. if (!dp) {
  178. prom_printf("sun4c_init_IRQ: Unable to find interrupt-enable\n");
  179. prom_halt();
  180. }
  181. addr = of_get_property(dp, "address", NULL);
  182. of_node_put(dp);
  183. if (!addr) {
  184. prom_printf("sun4c_init_IRQ: No address property\n");
  185. prom_halt();
  186. }
  187. interrupt_enable = (void __iomem *) (unsigned long) addr[0];
  188. BTFIXUPSET_CALL(enable_irq, sun4c_enable_irq, BTFIXUPCALL_NORM);
  189. BTFIXUPSET_CALL(disable_irq, sun4c_disable_irq, BTFIXUPCALL_NORM);
  190. BTFIXUPSET_CALL(enable_pil_irq, sun4c_enable_irq, BTFIXUPCALL_NORM);
  191. BTFIXUPSET_CALL(disable_pil_irq, sun4c_disable_irq, BTFIXUPCALL_NORM);
  192. BTFIXUPSET_CALL(clear_clock_irq, sun4c_clear_clock_irq, BTFIXUPCALL_NORM);
  193. BTFIXUPSET_CALL(load_profile_irq, sun4c_load_profile_irq, BTFIXUPCALL_NOP);
  194. sparc_irq_config.init_timers = sun4c_init_timers;
  195. #ifdef CONFIG_SMP
  196. BTFIXUPSET_CALL(set_cpu_int, sun4c_nop, BTFIXUPCALL_NOP);
  197. BTFIXUPSET_CALL(clear_cpu_int, sun4c_nop, BTFIXUPCALL_NOP);
  198. BTFIXUPSET_CALL(set_irq_udt, sun4c_nop, BTFIXUPCALL_NOP);
  199. #endif
  200. sbus_writeb(SUN4C_INT_ENABLE, interrupt_enable);
  201. /* Cannot enable interrupts until OBP ticker is disabled. */
  202. }