sys_jensen.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. /*
  2. * linux/arch/alpha/kernel/sys_jensen.c
  3. *
  4. * Copyright (C) 1995 Linus Torvalds
  5. * Copyright (C) 1998, 1999 Richard Henderson
  6. *
  7. * Code supporting the Jensen.
  8. */
  9. #include <linux/kernel.h>
  10. #include <linux/types.h>
  11. #include <linux/mm.h>
  12. #include <linux/sched.h>
  13. #include <linux/pci.h>
  14. #include <linux/init.h>
  15. #include <asm/ptrace.h>
  16. #include <asm/system.h>
  17. #define __EXTERN_INLINE inline
  18. #include <asm/io.h>
  19. #include <asm/jensen.h>
  20. #undef __EXTERN_INLINE
  21. #include <asm/dma.h>
  22. #include <asm/irq.h>
  23. #include <asm/mmu_context.h>
  24. #include <asm/pgtable.h>
  25. #include <asm/tlbflush.h>
  26. #include "proto.h"
  27. #include "irq_impl.h"
  28. #include "pci_impl.h"
  29. #include "machvec_impl.h"
  30. /*
  31. * Jensen is special: the vector is 0x8X0 for EISA interrupt X, and
  32. * 0x9X0 for the local motherboard interrupts.
  33. *
  34. * Note especially that those local interrupts CANNOT be masked,
  35. * which causes much of the pain below...
  36. *
  37. * 0x660 - NMI
  38. *
  39. * 0x800 - IRQ0 interval timer (not used, as we use the RTC timer)
  40. * 0x810 - IRQ1 line printer (duh..)
  41. * 0x860 - IRQ6 floppy disk
  42. *
  43. * 0x900 - COM1
  44. * 0x920 - COM2
  45. * 0x980 - keyboard
  46. * 0x990 - mouse
  47. *
  48. * PCI-based systems are more sane: they don't have the local
  49. * interrupts at all, and have only normal PCI interrupts from
  50. * devices. Happily it's easy enough to do a sane mapping from the
  51. * Jensen.
  52. *
  53. * Note that this means that we may have to do a hardware
  54. * "local_op" to a different interrupt than we report to the rest of the
  55. * world.
  56. */
  57. static unsigned int
  58. jensen_local_startup(unsigned int irq)
  59. {
  60. /* the parport is really hw IRQ 1, silly Jensen. */
  61. if (irq == 7)
  62. i8259a_startup_irq(1);
  63. else
  64. /*
  65. * For all true local interrupts, set the flag that prevents
  66. * the IPL from being dropped during handler processing.
  67. */
  68. if (irq_desc[irq].action)
  69. irq_desc[irq].action->flags |= IRQF_DISABLED;
  70. return 0;
  71. }
  72. static void
  73. jensen_local_shutdown(unsigned int irq)
  74. {
  75. /* the parport is really hw IRQ 1, silly Jensen. */
  76. if (irq == 7)
  77. i8259a_disable_irq(1);
  78. }
  79. static void
  80. jensen_local_enable(unsigned int irq)
  81. {
  82. /* the parport is really hw IRQ 1, silly Jensen. */
  83. if (irq == 7)
  84. i8259a_enable_irq(1);
  85. }
  86. static void
  87. jensen_local_disable(unsigned int irq)
  88. {
  89. /* the parport is really hw IRQ 1, silly Jensen. */
  90. if (irq == 7)
  91. i8259a_disable_irq(1);
  92. }
  93. static void
  94. jensen_local_ack(unsigned int irq)
  95. {
  96. /* the parport is really hw IRQ 1, silly Jensen. */
  97. if (irq == 7)
  98. i8259a_mask_and_ack_irq(1);
  99. }
  100. static void
  101. jensen_local_end(unsigned int irq)
  102. {
  103. /* the parport is really hw IRQ 1, silly Jensen. */
  104. if (irq == 7)
  105. i8259a_end_irq(1);
  106. }
  107. static struct hw_interrupt_type jensen_local_irq_type = {
  108. .typename = "LOCAL",
  109. .startup = jensen_local_startup,
  110. .shutdown = jensen_local_shutdown,
  111. .enable = jensen_local_enable,
  112. .disable = jensen_local_disable,
  113. .ack = jensen_local_ack,
  114. .end = jensen_local_end,
  115. };
  116. static void
  117. jensen_device_interrupt(unsigned long vector)
  118. {
  119. int irq;
  120. switch (vector) {
  121. case 0x660:
  122. printk("Whee.. NMI received. Probable hardware error\n");
  123. printk("61=%02x, 461=%02x\n", inb(0x61), inb(0x461));
  124. return;
  125. /* local device interrupts: */
  126. case 0x900: irq = 4; break; /* com1 -> irq 4 */
  127. case 0x920: irq = 3; break; /* com2 -> irq 3 */
  128. case 0x980: irq = 1; break; /* kbd -> irq 1 */
  129. case 0x990: irq = 9; break; /* mouse -> irq 9 */
  130. default:
  131. if (vector > 0x900) {
  132. printk("Unknown local interrupt %lx\n", vector);
  133. return;
  134. }
  135. irq = (vector - 0x800) >> 4;
  136. if (irq == 1)
  137. irq = 7;
  138. break;
  139. }
  140. /* If there is no handler yet... */
  141. if (irq_desc[irq].action == NULL) {
  142. /* If it is a local interrupt that cannot be masked... */
  143. if (vector >= 0x900)
  144. {
  145. /* Clear keyboard/mouse state */
  146. inb(0x64);
  147. inb(0x60);
  148. /* Reset serial ports */
  149. inb(0x3fa);
  150. inb(0x2fa);
  151. outb(0x0c, 0x3fc);
  152. outb(0x0c, 0x2fc);
  153. /* Clear NMI */
  154. outb(0,0x61);
  155. outb(0,0x461);
  156. }
  157. }
  158. #if 0
  159. /* A useful bit of code to find out if an interrupt is going wild. */
  160. {
  161. static unsigned int last_msg = 0, last_cc = 0;
  162. static int last_irq = -1, count = 0;
  163. unsigned int cc;
  164. __asm __volatile("rpcc %0" : "=r"(cc));
  165. ++count;
  166. #define JENSEN_CYCLES_PER_SEC (150000000)
  167. if (cc - last_msg > ((JENSEN_CYCLES_PER_SEC) * 3) ||
  168. irq != last_irq) {
  169. printk(KERN_CRIT " irq %d count %d cc %u @ %lx\n",
  170. irq, count, cc-last_cc, get_irq_regs()->pc);
  171. count = 0;
  172. last_msg = cc;
  173. last_irq = irq;
  174. }
  175. last_cc = cc;
  176. }
  177. #endif
  178. handle_irq(irq);
  179. }
  180. static void __init
  181. jensen_init_irq(void)
  182. {
  183. init_i8259a_irqs();
  184. irq_desc[1].chip = &jensen_local_irq_type;
  185. irq_desc[4].chip = &jensen_local_irq_type;
  186. irq_desc[3].chip = &jensen_local_irq_type;
  187. irq_desc[7].chip = &jensen_local_irq_type;
  188. irq_desc[9].chip = &jensen_local_irq_type;
  189. common_init_isa_dma();
  190. }
  191. static void __init
  192. jensen_init_arch(void)
  193. {
  194. struct pci_controller *hose;
  195. #ifdef CONFIG_PCI
  196. static struct pci_dev fake_isa_bridge = { .dma_mask = 0xffffffffUL, };
  197. isa_bridge = &fake_isa_bridge;
  198. #endif
  199. /* Create a hose so that we can report i/o base addresses to
  200. userland. */
  201. pci_isa_hose = hose = alloc_pci_controller();
  202. hose->io_space = &ioport_resource;
  203. hose->mem_space = &iomem_resource;
  204. hose->index = 0;
  205. hose->sparse_mem_base = EISA_MEM - IDENT_ADDR;
  206. hose->dense_mem_base = 0;
  207. hose->sparse_io_base = EISA_IO - IDENT_ADDR;
  208. hose->dense_io_base = 0;
  209. hose->sg_isa = hose->sg_pci = NULL;
  210. __direct_map_base = 0;
  211. __direct_map_size = 0xffffffff;
  212. }
  213. static void
  214. jensen_machine_check(unsigned long vector, unsigned long la)
  215. {
  216. printk(KERN_CRIT "Machine check\n");
  217. }
  218. /*
  219. * The System Vector
  220. */
  221. struct alpha_machine_vector jensen_mv __initmv = {
  222. .vector_name = "Jensen",
  223. DO_EV4_MMU,
  224. IO_LITE(JENSEN,jensen),
  225. .machine_check = jensen_machine_check,
  226. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  227. .rtc_port = 0x170,
  228. .rtc_get_time = common_get_rtc_time,
  229. .rtc_set_time = common_set_rtc_time,
  230. .nr_irqs = 16,
  231. .device_interrupt = jensen_device_interrupt,
  232. .init_arch = jensen_init_arch,
  233. .init_irq = jensen_init_irq,
  234. .init_rtc = common_init_rtc,
  235. .init_pci = NULL,
  236. .kill_arch = NULL,
  237. };
  238. ALIAS_MV(jensen)