sun4c_irq.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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/slab.h>
  19. #include <linux/init.h>
  20. #include <linux/of.h>
  21. #include <linux/of_device.h>
  22. #include "irq.h"
  23. #include <asm/ptrace.h>
  24. #include <asm/processor.h>
  25. #include <asm/system.h>
  26. #include <asm/psr.h>
  27. #include <asm/vaddrs.h>
  28. #include <asm/timer.h>
  29. #include <asm/openprom.h>
  30. #include <asm/oplib.h>
  31. #include <asm/traps.h>
  32. #include <asm/irq.h>
  33. #include <asm/io.h>
  34. #include <asm/idprom.h>
  35. #include <asm/machines.h>
  36. /*
  37. * Bit field defines for the interrupt registers on various
  38. * Sparc machines.
  39. */
  40. /* The sun4c interrupt register. */
  41. #define SUN4C_INT_ENABLE 0x01 /* Allow interrupts. */
  42. #define SUN4C_INT_E14 0x80 /* Enable level 14 IRQ. */
  43. #define SUN4C_INT_E10 0x20 /* Enable level 10 IRQ. */
  44. #define SUN4C_INT_E8 0x10 /* Enable level 8 IRQ. */
  45. #define SUN4C_INT_E6 0x08 /* Enable level 6 IRQ. */
  46. #define SUN4C_INT_E4 0x04 /* Enable level 4 IRQ. */
  47. #define SUN4C_INT_E1 0x02 /* Enable level 1 IRQ. */
  48. /* Pointer to the interrupt enable byte
  49. *
  50. * Dave Redman (djhr@tadpole.co.uk)
  51. * What you may not be aware of is that entry.S requires this variable.
  52. *
  53. * --- linux_trap_nmi_sun4c --
  54. *
  55. * so don't go making it static, like I tried. sigh.
  56. */
  57. unsigned char __iomem *interrupt_enable = NULL;
  58. static void sun4c_disable_irq(unsigned int irq_nr)
  59. {
  60. unsigned long flags;
  61. unsigned char current_mask, new_mask;
  62. local_irq_save(flags);
  63. irq_nr &= (NR_IRQS - 1);
  64. current_mask = sbus_readb(interrupt_enable);
  65. switch(irq_nr) {
  66. case 1:
  67. new_mask = ((current_mask) & (~(SUN4C_INT_E1)));
  68. break;
  69. case 8:
  70. new_mask = ((current_mask) & (~(SUN4C_INT_E8)));
  71. break;
  72. case 10:
  73. new_mask = ((current_mask) & (~(SUN4C_INT_E10)));
  74. break;
  75. case 14:
  76. new_mask = ((current_mask) & (~(SUN4C_INT_E14)));
  77. break;
  78. default:
  79. local_irq_restore(flags);
  80. return;
  81. }
  82. sbus_writeb(new_mask, interrupt_enable);
  83. local_irq_restore(flags);
  84. }
  85. static void sun4c_enable_irq(unsigned int irq_nr)
  86. {
  87. unsigned long flags;
  88. unsigned char current_mask, new_mask;
  89. local_irq_save(flags);
  90. irq_nr &= (NR_IRQS - 1);
  91. current_mask = sbus_readb(interrupt_enable);
  92. switch(irq_nr) {
  93. case 1:
  94. new_mask = ((current_mask) | SUN4C_INT_E1);
  95. break;
  96. case 8:
  97. new_mask = ((current_mask) | SUN4C_INT_E8);
  98. break;
  99. case 10:
  100. new_mask = ((current_mask) | SUN4C_INT_E10);
  101. break;
  102. case 14:
  103. new_mask = ((current_mask) | SUN4C_INT_E14);
  104. break;
  105. default:
  106. local_irq_restore(flags);
  107. return;
  108. }
  109. sbus_writeb(new_mask, interrupt_enable);
  110. local_irq_restore(flags);
  111. }
  112. #define TIMER_IRQ 10 /* Also at level 14, but we ignore that one. */
  113. #define PROFILE_IRQ 14 /* Level14 ticker.. used by OBP for polling */
  114. volatile struct sun4c_timer_info *sun4c_timers;
  115. static void sun4c_clear_clock_irq(void)
  116. {
  117. volatile unsigned int clear_intr;
  118. clear_intr = sun4c_timers->timer_limit10;
  119. }
  120. static void sun4c_load_profile_irq(int cpu, unsigned int limit)
  121. {
  122. /* Errm.. not sure how to do this.. */
  123. }
  124. static void __init sun4c_init_timers(irq_handler_t counter_fn)
  125. {
  126. int irq;
  127. /* Map the Timer chip, this is implemented in hardware inside
  128. * the cache chip on the sun4c.
  129. */
  130. sun4c_timers = ioremap(SUN_TIMER_PHYSADDR,
  131. sizeof(struct sun4c_timer_info));
  132. /* Have the level 10 timer tick at 100HZ. We don't touch the
  133. * level 14 timer limit since we are letting the prom handle
  134. * them until we have a real console driver so L1-A works.
  135. */
  136. sun4c_timers->timer_limit10 = (((1000000/HZ) + 1) << 10);
  137. master_l10_counter = &sun4c_timers->cur_count10;
  138. master_l10_limit = &sun4c_timers->timer_limit10;
  139. irq = request_irq(TIMER_IRQ,
  140. counter_fn,
  141. (IRQF_DISABLED | SA_STATIC_ALLOC),
  142. "timer", NULL);
  143. if (irq) {
  144. prom_printf("time_init: unable to attach IRQ%d\n",TIMER_IRQ);
  145. prom_halt();
  146. }
  147. sun4c_disable_irq(PROFILE_IRQ);
  148. }
  149. #ifdef CONFIG_SMP
  150. static void sun4c_nop(void) {}
  151. #endif
  152. void __init sun4c_init_IRQ(void)
  153. {
  154. struct device_node *dp;
  155. const u32 *addr;
  156. dp = of_find_node_by_name(NULL, "interrupt-enable");
  157. if (!dp) {
  158. prom_printf("sun4c_init_IRQ: Unable to find interrupt-enable\n");
  159. prom_halt();
  160. }
  161. addr = of_get_property(dp, "address", NULL);
  162. if (!addr) {
  163. prom_printf("sun4c_init_IRQ: No address property\n");
  164. prom_halt();
  165. }
  166. interrupt_enable = (void __iomem *) (unsigned long) addr[0];
  167. BTFIXUPSET_CALL(enable_irq, sun4c_enable_irq, BTFIXUPCALL_NORM);
  168. BTFIXUPSET_CALL(disable_irq, sun4c_disable_irq, BTFIXUPCALL_NORM);
  169. BTFIXUPSET_CALL(enable_pil_irq, sun4c_enable_irq, BTFIXUPCALL_NORM);
  170. BTFIXUPSET_CALL(disable_pil_irq, sun4c_disable_irq, BTFIXUPCALL_NORM);
  171. BTFIXUPSET_CALL(clear_clock_irq, sun4c_clear_clock_irq, BTFIXUPCALL_NORM);
  172. BTFIXUPSET_CALL(load_profile_irq, sun4c_load_profile_irq, BTFIXUPCALL_NOP);
  173. sparc_init_timers = sun4c_init_timers;
  174. #ifdef CONFIG_SMP
  175. BTFIXUPSET_CALL(set_cpu_int, sun4c_nop, BTFIXUPCALL_NOP);
  176. BTFIXUPSET_CALL(clear_cpu_int, sun4c_nop, BTFIXUPCALL_NOP);
  177. BTFIXUPSET_CALL(set_irq_udt, sun4c_nop, BTFIXUPCALL_NOP);
  178. #endif
  179. sbus_writeb(SUN4C_INT_ENABLE, interrupt_enable);
  180. /* Cannot enable interrupts until OBP ticker is disabled. */
  181. }