sun4c_irq.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:6k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  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/config.h>
  12. #include <linux/ptrace.h>
  13. #include <linux/errno.h>
  14. #include <linux/linkage.h>
  15. #include <linux/kernel_stat.h>
  16. #include <linux/signal.h>
  17. #include <linux/sched.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/slab.h>
  20. #include <linux/init.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. #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 = 0;
  49. static void sun4c_disable_irq(unsigned int irq_nr)
  50. {
  51. unsigned long flags;
  52. unsigned char current_mask, new_mask;
  53.     
  54. save_and_cli(flags);
  55. irq_nr &= NR_IRQS;
  56. current_mask = *interrupt_enable;
  57. switch(irq_nr) {
  58. case 1:
  59. new_mask = ((current_mask) & (~(SUN4C_INT_E1)));
  60. break;
  61. case 8:
  62. new_mask = ((current_mask) & (~(SUN4C_INT_E8)));
  63. break;
  64. case 10:
  65. new_mask = ((current_mask) & (~(SUN4C_INT_E10)));
  66. break;
  67. case 14:
  68. new_mask = ((current_mask) & (~(SUN4C_INT_E14)));
  69. break;
  70. default:
  71. restore_flags(flags);
  72. return;
  73. }
  74. *interrupt_enable = new_mask;
  75. restore_flags(flags);
  76. }
  77. static void sun4c_enable_irq(unsigned int irq_nr)
  78. {
  79. unsigned long flags;
  80. unsigned char current_mask, new_mask;
  81.     
  82. save_and_cli(flags);
  83. irq_nr &= NR_IRQS;
  84. current_mask = *interrupt_enable;
  85. switch(irq_nr) {
  86. case 1:
  87. new_mask = ((current_mask) | SUN4C_INT_E1);
  88. break;
  89. case 8:
  90. new_mask = ((current_mask) | SUN4C_INT_E8);
  91. break;
  92. case 10:
  93. new_mask = ((current_mask) | SUN4C_INT_E10);
  94. break;
  95. case 14:
  96. new_mask = ((current_mask) | SUN4C_INT_E14);
  97. break;
  98. default:
  99. restore_flags(flags);
  100. return;
  101. }
  102. *interrupt_enable = new_mask;
  103. restore_flags(flags);
  104. }
  105. #define TIMER_IRQ   10    /* Also at level 14, but we ignore that one. */
  106. #define PROFILE_IRQ 14    /* Level14 ticker.. used by OBP for polling */
  107. volatile struct sun4c_timer_info *sun4c_timers;
  108. #ifdef CONFIG_SUN4
  109. /* This is an ugly hack to work around the
  110.    current timer code, and make it work with 
  111.    the sun4/260 intersil 
  112.    */
  113. volatile struct sun4c_timer_info sun4_timer;
  114. #endif
  115. static void sun4c_clear_clock_irq(void)
  116. {
  117. volatile unsigned int clear_intr;
  118. #ifdef CONFIG_SUN4
  119. if (idprom->id_machtype == (SM_SUN4 | SM_4_260)) 
  120.   clear_intr = sun4_timer.timer_limit10;
  121. else
  122. #endif
  123. clear_intr = sun4c_timers->timer_limit10;
  124. }
  125. static void sun4c_clear_profile_irq(int cpu)
  126. {
  127. /* Errm.. not sure how to do this.. */
  128. }
  129. static void sun4c_load_profile_irq(int cpu, unsigned int limit)
  130. {
  131. /* Errm.. not sure how to do this.. */
  132. }
  133. static void __init sun4c_init_timers(void (*counter_fn)(int, void *, struct pt_regs *))
  134. {
  135. int irq;
  136. /* Map the Timer chip, this is implemented in hardware inside
  137.  * the cache chip on the sun4c.
  138.  */
  139. #ifdef CONFIG_SUN4
  140. if (idprom->id_machtype == (SM_SUN4 | SM_4_260))
  141. sun4c_timers = &sun4_timer;
  142. else
  143. #endif
  144. sun4c_timers = ioremap(SUN_TIMER_PHYSADDR,
  145.     sizeof(struct sun4c_timer_info));
  146. /* Have the level 10 timer tick at 100HZ.  We don't touch the
  147.  * level 14 timer limit since we are letting the prom handle
  148.  * them until we have a real console driver so L1-A works.
  149.  */
  150. sun4c_timers->timer_limit10 = (((1000000/HZ) + 1) << 10);
  151. master_l10_counter = &sun4c_timers->cur_count10;
  152. master_l10_limit = &sun4c_timers->timer_limit10;
  153. irq = request_irq(TIMER_IRQ,
  154.   counter_fn,
  155.   (SA_INTERRUPT | SA_STATIC_ALLOC),
  156.   "timer", NULL);
  157. if (irq) {
  158. prom_printf("time_init: unable to attach IRQ%dn",TIMER_IRQ);
  159. prom_halt();
  160. }
  161.     
  162. #if 0
  163. /* This does not work on 4/330 */
  164. sun4c_enable_irq(10);
  165. #endif
  166. claim_ticker14(NULL, PROFILE_IRQ, 0);
  167. }
  168. #ifdef CONFIG_SMP
  169. static void sun4c_nop(void) {}
  170. #endif
  171. extern char *sun4m_irq_itoa(unsigned int irq);
  172. void __init sun4c_init_IRQ(void)
  173. {
  174. struct linux_prom_registers int_regs[2];
  175. int ie_node;
  176. if (ARCH_SUN4) {
  177. interrupt_enable = (char *)
  178.     ioremap(sun4_ie_physaddr, PAGE_SIZE);
  179. } else {
  180. struct resource phyres;
  181. ie_node = prom_searchsiblings (prom_getchild(prom_root_node),
  182.         "interrupt-enable");
  183. if(ie_node == 0)
  184. panic("Cannot find /interrupt-enable node");
  185. /* Depending on the "address" property is bad news... */
  186. prom_getproperty(ie_node, "reg", (char *) int_regs, sizeof(int_regs));
  187. memset(&phyres, 0, sizeof(struct resource));
  188. phyres.flags = int_regs[0].which_io;
  189. phyres.start = int_regs[0].phys_addr;
  190. interrupt_enable = (char *) sbus_ioremap(&phyres, 0,
  191.     int_regs[0].reg_size, "sun4c_intr");
  192. }
  193. BTFIXUPSET_CALL(enable_irq, sun4c_enable_irq, BTFIXUPCALL_NORM);
  194. BTFIXUPSET_CALL(disable_irq, sun4c_disable_irq, BTFIXUPCALL_NORM);
  195. BTFIXUPSET_CALL(enable_pil_irq, sun4c_enable_irq, BTFIXUPCALL_NORM);
  196. BTFIXUPSET_CALL(disable_pil_irq, sun4c_disable_irq, BTFIXUPCALL_NORM);
  197. BTFIXUPSET_CALL(clear_clock_irq, sun4c_clear_clock_irq, BTFIXUPCALL_NORM);
  198. BTFIXUPSET_CALL(clear_profile_irq, sun4c_clear_profile_irq, BTFIXUPCALL_NOP);
  199. BTFIXUPSET_CALL(load_profile_irq, sun4c_load_profile_irq, BTFIXUPCALL_NOP);
  200. BTFIXUPSET_CALL(__irq_itoa, sun4m_irq_itoa, BTFIXUPCALL_NORM);
  201. init_timers = sun4c_init_timers;
  202. #ifdef CONFIG_SMP
  203. BTFIXUPSET_CALL(set_cpu_int, sun4c_nop, BTFIXUPCALL_NOP);
  204. BTFIXUPSET_CALL(clear_cpu_int, sun4c_nop, BTFIXUPCALL_NOP);
  205. BTFIXUPSET_CALL(set_irq_udt, sun4c_nop, BTFIXUPCALL_NOP);
  206. #endif
  207. *interrupt_enable = (SUN4C_INT_ENABLE);
  208. /* Cannot enable interrupts until OBP ticker is disabled. */
  209. }