sun4c_irq.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. #if 0
  37. static struct resource sun4c_timer_eb = { "sun4c_timer" };
  38. static struct resource sun4c_intr_eb = { "sun4c_intr" };
  39. #endif
  40. /*
  41. * Bit field defines for the interrupt registers on various
  42. * Sparc machines.
  43. */
  44. /* The sun4c interrupt register. */
  45. #define SUN4C_INT_ENABLE 0x01 /* Allow interrupts. */
  46. #define SUN4C_INT_E14 0x80 /* Enable level 14 IRQ. */
  47. #define SUN4C_INT_E10 0x20 /* Enable level 10 IRQ. */
  48. #define SUN4C_INT_E8 0x10 /* Enable level 8 IRQ. */
  49. #define SUN4C_INT_E6 0x08 /* Enable level 6 IRQ. */
  50. #define SUN4C_INT_E4 0x04 /* Enable level 4 IRQ. */
  51. #define SUN4C_INT_E1 0x02 /* Enable level 1 IRQ. */
  52. /* Pointer to the interrupt enable byte
  53. *
  54. * Dave Redman (djhr@tadpole.co.uk)
  55. * What you may not be aware of is that entry.S requires this variable.
  56. *
  57. * --- linux_trap_nmi_sun4c --
  58. *
  59. * so don't go making it static, like I tried. sigh.
  60. */
  61. unsigned char *interrupt_enable = NULL;
  62. static void sun4c_disable_irq(unsigned int irq_nr)
  63. {
  64. unsigned long flags;
  65. unsigned char current_mask, new_mask;
  66. local_irq_save(flags);
  67. irq_nr &= (NR_IRQS - 1);
  68. current_mask = *interrupt_enable;
  69. switch(irq_nr) {
  70. case 1:
  71. new_mask = ((current_mask) & (~(SUN4C_INT_E1)));
  72. break;
  73. case 8:
  74. new_mask = ((current_mask) & (~(SUN4C_INT_E8)));
  75. break;
  76. case 10:
  77. new_mask = ((current_mask) & (~(SUN4C_INT_E10)));
  78. break;
  79. case 14:
  80. new_mask = ((current_mask) & (~(SUN4C_INT_E14)));
  81. break;
  82. default:
  83. local_irq_restore(flags);
  84. return;
  85. }
  86. *interrupt_enable = new_mask;
  87. local_irq_restore(flags);
  88. }
  89. static void sun4c_enable_irq(unsigned int irq_nr)
  90. {
  91. unsigned long flags;
  92. unsigned char current_mask, new_mask;
  93. local_irq_save(flags);
  94. irq_nr &= (NR_IRQS - 1);
  95. current_mask = *interrupt_enable;
  96. switch(irq_nr) {
  97. case 1:
  98. new_mask = ((current_mask) | SUN4C_INT_E1);
  99. break;
  100. case 8:
  101. new_mask = ((current_mask) | SUN4C_INT_E8);
  102. break;
  103. case 10:
  104. new_mask = ((current_mask) | SUN4C_INT_E10);
  105. break;
  106. case 14:
  107. new_mask = ((current_mask) | SUN4C_INT_E14);
  108. break;
  109. default:
  110. local_irq_restore(flags);
  111. return;
  112. }
  113. *interrupt_enable = new_mask;
  114. local_irq_restore(flags);
  115. }
  116. #define TIMER_IRQ 10 /* Also at level 14, but we ignore that one. */
  117. #define PROFILE_IRQ 14 /* Level14 ticker.. used by OBP for polling */
  118. volatile struct sun4c_timer_info *sun4c_timers;
  119. static void sun4c_clear_clock_irq(void)
  120. {
  121. volatile unsigned int clear_intr;
  122. clear_intr = sun4c_timers->timer_limit10;
  123. }
  124. static void sun4c_clear_profile_irq(int cpu)
  125. {
  126. /* Errm.. not sure how to do this.. */
  127. }
  128. static void sun4c_load_profile_irq(int cpu, unsigned int limit)
  129. {
  130. /* Errm.. not sure how to do this.. */
  131. }
  132. static void __init sun4c_init_timers(irq_handler_t counter_fn)
  133. {
  134. int irq;
  135. /* Map the Timer chip, this is implemented in hardware inside
  136. * the cache chip on the sun4c.
  137. */
  138. sun4c_timers = ioremap(SUN_TIMER_PHYSADDR,
  139. sizeof(struct sun4c_timer_info));
  140. /* Have the level 10 timer tick at 100HZ. We don't touch the
  141. * level 14 timer limit since we are letting the prom handle
  142. * them until we have a real console driver so L1-A works.
  143. */
  144. sun4c_timers->timer_limit10 = (((1000000/HZ) + 1) << 10);
  145. master_l10_counter = &sun4c_timers->cur_count10;
  146. master_l10_limit = &sun4c_timers->timer_limit10;
  147. irq = request_irq(TIMER_IRQ,
  148. counter_fn,
  149. (IRQF_DISABLED | SA_STATIC_ALLOC),
  150. "timer", NULL);
  151. if (irq) {
  152. prom_printf("time_init: unable to attach IRQ%d\n",TIMER_IRQ);
  153. prom_halt();
  154. }
  155. #if 0
  156. /* This does not work on 4/330 */
  157. sun4c_enable_irq(10);
  158. #endif
  159. claim_ticker14(NULL, PROFILE_IRQ, 0);
  160. }
  161. #ifdef CONFIG_SMP
  162. static void sun4c_nop(void) {}
  163. #endif
  164. void __init sun4c_init_IRQ(void)
  165. {
  166. struct linux_prom_registers int_regs[2];
  167. int ie_node;
  168. struct resource phyres;
  169. ie_node = prom_searchsiblings (prom_getchild(prom_root_node),
  170. "interrupt-enable");
  171. if(ie_node == 0)
  172. panic("Cannot find /interrupt-enable node");
  173. /* Depending on the "address" property is bad news... */
  174. interrupt_enable = NULL;
  175. if (prom_getproperty(ie_node, "reg", (char *) int_regs,
  176. sizeof(int_regs)) != -1) {
  177. memset(&phyres, 0, sizeof(struct resource));
  178. phyres.flags = int_regs[0].which_io;
  179. phyres.start = int_regs[0].phys_addr;
  180. interrupt_enable = (char *) of_ioremap(&phyres, 0,
  181. int_regs[0].reg_size, "sun4c_intr");
  182. }
  183. if (!interrupt_enable)
  184. panic("Cannot map interrupt_enable");
  185. BTFIXUPSET_CALL(enable_irq, sun4c_enable_irq, BTFIXUPCALL_NORM);
  186. BTFIXUPSET_CALL(disable_irq, sun4c_disable_irq, BTFIXUPCALL_NORM);
  187. BTFIXUPSET_CALL(enable_pil_irq, sun4c_enable_irq, BTFIXUPCALL_NORM);
  188. BTFIXUPSET_CALL(disable_pil_irq, sun4c_disable_irq, BTFIXUPCALL_NORM);
  189. BTFIXUPSET_CALL(clear_clock_irq, sun4c_clear_clock_irq, BTFIXUPCALL_NORM);
  190. BTFIXUPSET_CALL(clear_profile_irq, sun4c_clear_profile_irq, BTFIXUPCALL_NOP);
  191. BTFIXUPSET_CALL(load_profile_irq, sun4c_load_profile_irq, BTFIXUPCALL_NOP);
  192. sparc_init_timers = sun4c_init_timers;
  193. #ifdef CONFIG_SMP
  194. BTFIXUPSET_CALL(set_cpu_int, sun4c_nop, BTFIXUPCALL_NOP);
  195. BTFIXUPSET_CALL(clear_cpu_int, sun4c_nop, BTFIXUPCALL_NOP);
  196. BTFIXUPSET_CALL(set_irq_udt, sun4c_nop, BTFIXUPCALL_NOP);
  197. #endif
  198. *interrupt_enable = (SUN4C_INT_ENABLE);
  199. /* Cannot enable interrupts until OBP ticker is disabled. */
  200. }