sys_jensen.c 5.6 KB

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