sun4c_irq.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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 "irq.h"
  21. #include <asm/ptrace.h>
  22. #include <asm/processor.h>
  23. #include <asm/system.h>
  24. #include <asm/psr.h>
  25. #include <asm/vaddrs.h>
  26. #include <asm/timer.h>
  27. #include <asm/openprom.h>
  28. #include <asm/oplib.h>
  29. #include <asm/traps.h>
  30. #include <asm/irq.h>
  31. #include <asm/io.h>
  32. #include <asm/sun4paddr.h>
  33. #include <asm/idprom.h>
  34. #include <asm/machines.h>
  35. #include <asm/sbus.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 int sun4c_pil_map[] = { 0, 1, 2, 3, 5, 7, 8, 9 };
  63. unsigned int sun4c_sbint_to_irq(struct sbus_dev *sdev, unsigned int sbint)
  64. {
  65. if (sbint >= sizeof(sun4c_pil_map)) {
  66. printk(KERN_ERR "%s: bogus SBINT %d\n", sdev->prom_name, sbint);
  67. BUG();
  68. }
  69. return sun4c_pil_map[sbint];
  70. }
  71. static void sun4c_disable_irq(unsigned int irq_nr)
  72. {
  73. unsigned long flags;
  74. unsigned char current_mask, new_mask;
  75. local_irq_save(flags);
  76. irq_nr &= (NR_IRQS - 1);
  77. current_mask = *interrupt_enable;
  78. switch(irq_nr) {
  79. case 1:
  80. new_mask = ((current_mask) & (~(SUN4C_INT_E1)));
  81. break;
  82. case 8:
  83. new_mask = ((current_mask) & (~(SUN4C_INT_E8)));
  84. break;
  85. case 10:
  86. new_mask = ((current_mask) & (~(SUN4C_INT_E10)));
  87. break;
  88. case 14:
  89. new_mask = ((current_mask) & (~(SUN4C_INT_E14)));
  90. break;
  91. default:
  92. local_irq_restore(flags);
  93. return;
  94. }
  95. *interrupt_enable = new_mask;
  96. local_irq_restore(flags);
  97. }
  98. static void sun4c_enable_irq(unsigned int irq_nr)
  99. {
  100. unsigned long flags;
  101. unsigned char current_mask, new_mask;
  102. local_irq_save(flags);
  103. irq_nr &= (NR_IRQS - 1);
  104. current_mask = *interrupt_enable;
  105. switch(irq_nr) {
  106. case 1:
  107. new_mask = ((current_mask) | SUN4C_INT_E1);
  108. break;
  109. case 8:
  110. new_mask = ((current_mask) | SUN4C_INT_E8);
  111. break;
  112. case 10:
  113. new_mask = ((current_mask) | SUN4C_INT_E10);
  114. break;
  115. case 14:
  116. new_mask = ((current_mask) | SUN4C_INT_E14);
  117. break;
  118. default:
  119. local_irq_restore(flags);
  120. return;
  121. }
  122. *interrupt_enable = new_mask;
  123. local_irq_restore(flags);
  124. }
  125. #define TIMER_IRQ 10 /* Also at level 14, but we ignore that one. */
  126. #define PROFILE_IRQ 14 /* Level14 ticker.. used by OBP for polling */
  127. volatile struct sun4c_timer_info *sun4c_timers;
  128. #ifdef CONFIG_SUN4
  129. /* This is an ugly hack to work around the
  130. current timer code, and make it work with
  131. the sun4/260 intersil
  132. */
  133. volatile struct sun4c_timer_info sun4_timer;
  134. #endif
  135. static void sun4c_clear_clock_irq(void)
  136. {
  137. volatile unsigned int clear_intr;
  138. #ifdef CONFIG_SUN4
  139. if (idprom->id_machtype == (SM_SUN4 | SM_4_260))
  140. clear_intr = sun4_timer.timer_limit10;
  141. else
  142. #endif
  143. clear_intr = sun4c_timers->timer_limit10;
  144. }
  145. static void sun4c_clear_profile_irq(int cpu)
  146. {
  147. /* Errm.. not sure how to do this.. */
  148. }
  149. static void sun4c_load_profile_irq(int cpu, unsigned int limit)
  150. {
  151. /* Errm.. not sure how to do this.. */
  152. }
  153. static void __init sun4c_init_timers(irq_handler_t counter_fn)
  154. {
  155. int irq;
  156. /* Map the Timer chip, this is implemented in hardware inside
  157. * the cache chip on the sun4c.
  158. */
  159. #ifdef CONFIG_SUN4
  160. if (idprom->id_machtype == (SM_SUN4 | SM_4_260))
  161. sun4c_timers = &sun4_timer;
  162. else
  163. #endif
  164. sun4c_timers = ioremap(SUN_TIMER_PHYSADDR,
  165. sizeof(struct sun4c_timer_info));
  166. /* Have the level 10 timer tick at 100HZ. We don't touch the
  167. * level 14 timer limit since we are letting the prom handle
  168. * them until we have a real console driver so L1-A works.
  169. */
  170. sun4c_timers->timer_limit10 = (((1000000/HZ) + 1) << 10);
  171. master_l10_counter = &sun4c_timers->cur_count10;
  172. master_l10_limit = &sun4c_timers->timer_limit10;
  173. irq = request_irq(TIMER_IRQ,
  174. counter_fn,
  175. (IRQF_DISABLED | SA_STATIC_ALLOC),
  176. "timer", NULL);
  177. if (irq) {
  178. prom_printf("time_init: unable to attach IRQ%d\n",TIMER_IRQ);
  179. prom_halt();
  180. }
  181. #if 0
  182. /* This does not work on 4/330 */
  183. sun4c_enable_irq(10);
  184. #endif
  185. claim_ticker14(NULL, PROFILE_IRQ, 0);
  186. }
  187. #ifdef CONFIG_SMP
  188. static void sun4c_nop(void) {}
  189. #endif
  190. void __init sun4c_init_IRQ(void)
  191. {
  192. struct linux_prom_registers int_regs[2];
  193. int ie_node;
  194. if (ARCH_SUN4) {
  195. interrupt_enable = (char *)
  196. ioremap(sun4_ie_physaddr, PAGE_SIZE);
  197. } else {
  198. struct resource phyres;
  199. ie_node = prom_searchsiblings (prom_getchild(prom_root_node),
  200. "interrupt-enable");
  201. if(ie_node == 0)
  202. panic("Cannot find /interrupt-enable node");
  203. /* Depending on the "address" property is bad news... */
  204. interrupt_enable = NULL;
  205. if (prom_getproperty(ie_node, "reg", (char *) int_regs,
  206. sizeof(int_regs)) != -1) {
  207. memset(&phyres, 0, sizeof(struct resource));
  208. phyres.flags = int_regs[0].which_io;
  209. phyres.start = int_regs[0].phys_addr;
  210. interrupt_enable = (char *) sbus_ioremap(&phyres, 0,
  211. int_regs[0].reg_size, "sun4c_intr");
  212. }
  213. }
  214. if (!interrupt_enable)
  215. panic("Cannot map interrupt_enable");
  216. BTFIXUPSET_CALL(sbint_to_irq, sun4c_sbint_to_irq, BTFIXUPCALL_NORM);
  217. BTFIXUPSET_CALL(enable_irq, sun4c_enable_irq, BTFIXUPCALL_NORM);
  218. BTFIXUPSET_CALL(disable_irq, sun4c_disable_irq, BTFIXUPCALL_NORM);
  219. BTFIXUPSET_CALL(enable_pil_irq, sun4c_enable_irq, BTFIXUPCALL_NORM);
  220. BTFIXUPSET_CALL(disable_pil_irq, sun4c_disable_irq, BTFIXUPCALL_NORM);
  221. BTFIXUPSET_CALL(clear_clock_irq, sun4c_clear_clock_irq, BTFIXUPCALL_NORM);
  222. BTFIXUPSET_CALL(clear_profile_irq, sun4c_clear_profile_irq, BTFIXUPCALL_NOP);
  223. BTFIXUPSET_CALL(load_profile_irq, sun4c_load_profile_irq, BTFIXUPCALL_NOP);
  224. sparc_init_timers = sun4c_init_timers;
  225. #ifdef CONFIG_SMP
  226. BTFIXUPSET_CALL(set_cpu_int, sun4c_nop, BTFIXUPCALL_NOP);
  227. BTFIXUPSET_CALL(clear_cpu_int, sun4c_nop, BTFIXUPCALL_NOP);
  228. BTFIXUPSET_CALL(set_irq_udt, sun4c_nop, BTFIXUPCALL_NOP);
  229. #endif
  230. *interrupt_enable = (SUN4C_INT_ENABLE);
  231. /* Cannot enable interrupts until OBP ticker is disabled. */
  232. }