sys_jensen.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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. return 0;
  64. }
  65. static void
  66. jensen_local_shutdown(unsigned int irq)
  67. {
  68. /* the parport is really hw IRQ 1, silly Jensen. */
  69. if (irq == 7)
  70. i8259a_disable_irq(1);
  71. }
  72. static void
  73. jensen_local_enable(unsigned int irq)
  74. {
  75. /* the parport is really hw IRQ 1, silly Jensen. */
  76. if (irq == 7)
  77. i8259a_enable_irq(1);
  78. }
  79. static void
  80. jensen_local_disable(unsigned int irq)
  81. {
  82. /* the parport is really hw IRQ 1, silly Jensen. */
  83. if (irq == 7)
  84. i8259a_disable_irq(1);
  85. }
  86. static void
  87. jensen_local_ack(unsigned int irq)
  88. {
  89. /* the parport is really hw IRQ 1, silly Jensen. */
  90. if (irq == 7)
  91. i8259a_mask_and_ack_irq(1);
  92. }
  93. static void
  94. jensen_local_end(unsigned int irq)
  95. {
  96. /* the parport is really hw IRQ 1, silly Jensen. */
  97. if (irq == 7)
  98. i8259a_end_irq(1);
  99. }
  100. static struct irq_chip jensen_local_irq_type = {
  101. .name = "LOCAL",
  102. .startup = jensen_local_startup,
  103. .shutdown = jensen_local_shutdown,
  104. .enable = jensen_local_enable,
  105. .disable = jensen_local_disable,
  106. .ack = jensen_local_ack,
  107. .end = jensen_local_end,
  108. };
  109. static void
  110. jensen_device_interrupt(unsigned long vector)
  111. {
  112. int irq;
  113. switch (vector) {
  114. case 0x660:
  115. printk("Whee.. NMI received. Probable hardware error\n");
  116. printk("61=%02x, 461=%02x\n", inb(0x61), inb(0x461));
  117. return;
  118. /* local device interrupts: */
  119. case 0x900: irq = 4; break; /* com1 -> irq 4 */
  120. case 0x920: irq = 3; break; /* com2 -> irq 3 */
  121. case 0x980: irq = 1; break; /* kbd -> irq 1 */
  122. case 0x990: irq = 9; break; /* mouse -> irq 9 */
  123. default:
  124. if (vector > 0x900) {
  125. printk("Unknown local interrupt %lx\n", vector);
  126. return;
  127. }
  128. irq = (vector - 0x800) >> 4;
  129. if (irq == 1)
  130. irq = 7;
  131. break;
  132. }
  133. /* If there is no handler yet... */
  134. if (!irq_has_action(irq)) {
  135. /* If it is a local interrupt that cannot be masked... */
  136. if (vector >= 0x900)
  137. {
  138. /* Clear keyboard/mouse state */
  139. inb(0x64);
  140. inb(0x60);
  141. /* Reset serial ports */
  142. inb(0x3fa);
  143. inb(0x2fa);
  144. outb(0x0c, 0x3fc);
  145. outb(0x0c, 0x2fc);
  146. /* Clear NMI */
  147. outb(0,0x61);
  148. outb(0,0x461);
  149. }
  150. }
  151. #if 0
  152. /* A useful bit of code to find out if an interrupt is going wild. */
  153. {
  154. static unsigned int last_msg = 0, last_cc = 0;
  155. static int last_irq = -1, count = 0;
  156. unsigned int cc;
  157. __asm __volatile("rpcc %0" : "=r"(cc));
  158. ++count;
  159. #define JENSEN_CYCLES_PER_SEC (150000000)
  160. if (cc - last_msg > ((JENSEN_CYCLES_PER_SEC) * 3) ||
  161. irq != last_irq) {
  162. printk(KERN_CRIT " irq %d count %d cc %u @ %lx\n",
  163. irq, count, cc-last_cc, get_irq_regs()->pc);
  164. count = 0;
  165. last_msg = cc;
  166. last_irq = irq;
  167. }
  168. last_cc = cc;
  169. }
  170. #endif
  171. handle_irq(irq);
  172. }
  173. static void __init
  174. jensen_init_irq(void)
  175. {
  176. init_i8259a_irqs();
  177. set_irq_chip_and_handler(1, &jensen_local_irq_type, alpha_do_IRQ);
  178. set_irq_chip_and_handler(4, &jensen_local_irq_type, alpha_do_IRQ);
  179. set_irq_chip_and_handler(3, &jensen_local_irq_type, alpha_do_IRQ);
  180. set_irq_chip_and_handler(7, &jensen_local_irq_type, alpha_do_IRQ);
  181. set_irq_chip_and_handler(9, &jensen_local_irq_type, alpha_do_IRQ);
  182. common_init_isa_dma();
  183. }
  184. static void __init
  185. jensen_init_arch(void)
  186. {
  187. struct pci_controller *hose;
  188. #ifdef CONFIG_PCI
  189. static struct pci_dev fake_isa_bridge = { .dma_mask = 0xffffffffUL, };
  190. isa_bridge = &fake_isa_bridge;
  191. #endif
  192. /* Create a hose so that we can report i/o base addresses to
  193. userland. */
  194. pci_isa_hose = hose = alloc_pci_controller();
  195. hose->io_space = &ioport_resource;
  196. hose->mem_space = &iomem_resource;
  197. hose->index = 0;
  198. hose->sparse_mem_base = EISA_MEM - IDENT_ADDR;
  199. hose->dense_mem_base = 0;
  200. hose->sparse_io_base = EISA_IO - IDENT_ADDR;
  201. hose->dense_io_base = 0;
  202. hose->sg_isa = hose->sg_pci = NULL;
  203. __direct_map_base = 0;
  204. __direct_map_size = 0xffffffff;
  205. }
  206. static void
  207. jensen_machine_check(unsigned long vector, unsigned long la)
  208. {
  209. printk(KERN_CRIT "Machine check\n");
  210. }
  211. /*
  212. * The System Vector
  213. */
  214. struct alpha_machine_vector jensen_mv __initmv = {
  215. .vector_name = "Jensen",
  216. DO_EV4_MMU,
  217. IO_LITE(JENSEN,jensen),
  218. .machine_check = jensen_machine_check,
  219. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  220. .rtc_port = 0x170,
  221. .rtc_get_time = common_get_rtc_time,
  222. .rtc_set_time = common_set_rtc_time,
  223. .nr_irqs = 16,
  224. .device_interrupt = jensen_device_interrupt,
  225. .init_arch = jensen_init_arch,
  226. .init_irq = jensen_init_irq,
  227. .init_rtc = common_init_rtc,
  228. .init_pci = NULL,
  229. .kill_arch = NULL,
  230. };
  231. ALIAS_MV(jensen)