sun4c_irq.c 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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 <asm/ptrace.h>
  21. #include <asm/processor.h>
  22. #include <asm/system.h>
  23. #include <asm/psr.h>
  24. #include <asm/vaddrs.h>
  25. #include <asm/timer.h>
  26. #include <asm/openprom.h>
  27. #include <asm/oplib.h>
  28. #include <asm/traps.h>
  29. #include <asm/irq.h>
  30. #include <asm/io.h>
  31. #include <asm/sun4paddr.h>
  32. #include <asm/idprom.h>
  33. #include <asm/machines.h>
  34. #include <asm/sbus.h>
  35. #if 0
  36. static struct resource sun4c_timer_eb = { "sun4c_timer" };
  37. static struct resource sun4c_intr_eb = { "sun4c_intr" };
  38. #endif
  39. /* Pointer to the interrupt enable byte
  40. *
  41. * Dave Redman (djhr@tadpole.co.uk)
  42. * What you may not be aware of is that entry.S requires this variable.
  43. *
  44. * --- linux_trap_nmi_sun4c --
  45. *
  46. * so don't go making it static, like I tried. sigh.
  47. */
  48. unsigned char *interrupt_enable = NULL;
  49. static int sun4c_pil_map[] = { 0, 1, 2, 3, 5, 7, 8, 9 };
  50. unsigned int sun4c_sbint_to_irq(struct sbus_dev *sdev, unsigned int sbint)
  51. {
  52. if (sbint >= sizeof(sun4c_pil_map)) {
  53. printk(KERN_ERR "%s: bogus SBINT %d\n", sdev->prom_name, sbint);
  54. BUG();
  55. }
  56. return sun4c_pil_map[sbint];
  57. }
  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 = *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. *interrupt_enable = new_mask;
  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 = *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. *interrupt_enable = new_mask;
  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. #ifdef CONFIG_SUN4
  116. /* This is an ugly hack to work around the
  117. current timer code, and make it work with
  118. the sun4/260 intersil
  119. */
  120. volatile struct sun4c_timer_info sun4_timer;
  121. #endif
  122. static void sun4c_clear_clock_irq(void)
  123. {
  124. volatile unsigned int clear_intr;
  125. #ifdef CONFIG_SUN4
  126. if (idprom->id_machtype == (SM_SUN4 | SM_4_260))
  127. clear_intr = sun4_timer.timer_limit10;
  128. else
  129. #endif
  130. clear_intr = sun4c_timers->timer_limit10;
  131. }
  132. static void sun4c_clear_profile_irq(int cpu)
  133. {
  134. /* Errm.. not sure how to do this.. */
  135. }
  136. static void sun4c_load_profile_irq(int cpu, unsigned int limit)
  137. {
  138. /* Errm.. not sure how to do this.. */
  139. }
  140. static void __init sun4c_init_timers(irq_handler_t counter_fn)
  141. {
  142. int irq;
  143. /* Map the Timer chip, this is implemented in hardware inside
  144. * the cache chip on the sun4c.
  145. */
  146. #ifdef CONFIG_SUN4
  147. if (idprom->id_machtype == (SM_SUN4 | SM_4_260))
  148. sun4c_timers = &sun4_timer;
  149. else
  150. #endif
  151. sun4c_timers = ioremap(SUN_TIMER_PHYSADDR,
  152. sizeof(struct sun4c_timer_info));
  153. /* Have the level 10 timer tick at 100HZ. We don't touch the
  154. * level 14 timer limit since we are letting the prom handle
  155. * them until we have a real console driver so L1-A works.
  156. */
  157. sun4c_timers->timer_limit10 = (((1000000/HZ) + 1) << 10);
  158. master_l10_counter = &sun4c_timers->cur_count10;
  159. master_l10_limit = &sun4c_timers->timer_limit10;
  160. irq = request_irq(TIMER_IRQ,
  161. counter_fn,
  162. (IRQF_DISABLED | SA_STATIC_ALLOC),
  163. "timer", NULL);
  164. if (irq) {
  165. prom_printf("time_init: unable to attach IRQ%d\n",TIMER_IRQ);
  166. prom_halt();
  167. }
  168. #if 0
  169. /* This does not work on 4/330 */
  170. sun4c_enable_irq(10);
  171. #endif
  172. claim_ticker14(NULL, PROFILE_IRQ, 0);
  173. }
  174. #ifdef CONFIG_SMP
  175. static void sun4c_nop(void) {}
  176. #endif
  177. void __init sun4c_init_IRQ(void)
  178. {
  179. struct linux_prom_registers int_regs[2];
  180. int ie_node;
  181. if (ARCH_SUN4) {
  182. interrupt_enable = (char *)
  183. ioremap(sun4_ie_physaddr, PAGE_SIZE);
  184. } else {
  185. struct resource phyres;
  186. ie_node = prom_searchsiblings (prom_getchild(prom_root_node),
  187. "interrupt-enable");
  188. if(ie_node == 0)
  189. panic("Cannot find /interrupt-enable node");
  190. /* Depending on the "address" property is bad news... */
  191. interrupt_enable = NULL;
  192. if (prom_getproperty(ie_node, "reg", (char *) int_regs,
  193. sizeof(int_regs)) != -1) {
  194. memset(&phyres, 0, sizeof(struct resource));
  195. phyres.flags = int_regs[0].which_io;
  196. phyres.start = int_regs[0].phys_addr;
  197. interrupt_enable = (char *) sbus_ioremap(&phyres, 0,
  198. int_regs[0].reg_size, "sun4c_intr");
  199. }
  200. }
  201. if (!interrupt_enable)
  202. panic("Cannot map interrupt_enable");
  203. BTFIXUPSET_CALL(sbint_to_irq, sun4c_sbint_to_irq, BTFIXUPCALL_NORM);
  204. BTFIXUPSET_CALL(enable_irq, sun4c_enable_irq, BTFIXUPCALL_NORM);
  205. BTFIXUPSET_CALL(disable_irq, sun4c_disable_irq, BTFIXUPCALL_NORM);
  206. BTFIXUPSET_CALL(enable_pil_irq, sun4c_enable_irq, BTFIXUPCALL_NORM);
  207. BTFIXUPSET_CALL(disable_pil_irq, sun4c_disable_irq, BTFIXUPCALL_NORM);
  208. BTFIXUPSET_CALL(clear_clock_irq, sun4c_clear_clock_irq, BTFIXUPCALL_NORM);
  209. BTFIXUPSET_CALL(clear_profile_irq, sun4c_clear_profile_irq, BTFIXUPCALL_NOP);
  210. BTFIXUPSET_CALL(load_profile_irq, sun4c_load_profile_irq, BTFIXUPCALL_NOP);
  211. sparc_init_timers = sun4c_init_timers;
  212. #ifdef CONFIG_SMP
  213. BTFIXUPSET_CALL(set_cpu_int, sun4c_nop, BTFIXUPCALL_NOP);
  214. BTFIXUPSET_CALL(clear_cpu_int, sun4c_nop, BTFIXUPCALL_NOP);
  215. BTFIXUPSET_CALL(set_irq_udt, sun4c_nop, BTFIXUPCALL_NOP);
  216. #endif
  217. *interrupt_enable = (SUN4C_INT_ENABLE);
  218. /* Cannot enable interrupts until OBP ticker is disabled. */
  219. }