sys_jensen.c 5.5 KB

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