sun4c_irq.c 6.7 KB

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