sys_eb64p.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. /*
  2. * linux/arch/alpha/kernel/sys_eb64p.c
  3. *
  4. * Copyright (C) 1995 David A Rusling
  5. * Copyright (C) 1996 Jay A Estabrook
  6. * Copyright (C) 1998, 1999 Richard Henderson
  7. *
  8. * Code supporting the EB64+ and EB66.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/types.h>
  12. #include <linux/mm.h>
  13. #include <linux/sched.h>
  14. #include <linux/pci.h>
  15. #include <linux/init.h>
  16. #include <linux/bitops.h>
  17. #include <asm/ptrace.h>
  18. #include <asm/system.h>
  19. #include <asm/dma.h>
  20. #include <asm/irq.h>
  21. #include <asm/mmu_context.h>
  22. #include <asm/io.h>
  23. #include <asm/pgtable.h>
  24. #include <asm/core_apecs.h>
  25. #include <asm/core_lca.h>
  26. #include <asm/hwrpb.h>
  27. #include <asm/tlbflush.h>
  28. #include "proto.h"
  29. #include "irq_impl.h"
  30. #include "pci_impl.h"
  31. #include "machvec_impl.h"
  32. /* Note mask bit is true for DISABLED irqs. */
  33. static unsigned int cached_irq_mask = -1;
  34. static inline void
  35. eb64p_update_irq_hw(unsigned int irq, unsigned long mask)
  36. {
  37. outb(mask >> (irq >= 24 ? 24 : 16), (irq >= 24 ? 0x27 : 0x26));
  38. }
  39. static inline void
  40. eb64p_enable_irq(unsigned int irq)
  41. {
  42. eb64p_update_irq_hw(irq, cached_irq_mask &= ~(1 << irq));
  43. }
  44. static void
  45. eb64p_disable_irq(unsigned int irq)
  46. {
  47. eb64p_update_irq_hw(irq, cached_irq_mask |= 1 << irq);
  48. }
  49. static unsigned int
  50. eb64p_startup_irq(unsigned int irq)
  51. {
  52. eb64p_enable_irq(irq);
  53. return 0; /* never anything pending */
  54. }
  55. static void
  56. eb64p_end_irq(unsigned int irq)
  57. {
  58. if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
  59. eb64p_enable_irq(irq);
  60. }
  61. static struct hw_interrupt_type eb64p_irq_type = {
  62. .typename = "EB64P",
  63. .startup = eb64p_startup_irq,
  64. .shutdown = eb64p_disable_irq,
  65. .enable = eb64p_enable_irq,
  66. .disable = eb64p_disable_irq,
  67. .ack = eb64p_disable_irq,
  68. .end = eb64p_end_irq,
  69. };
  70. static void
  71. eb64p_device_interrupt(unsigned long vector)
  72. {
  73. unsigned long pld;
  74. unsigned int i;
  75. /* Read the interrupt summary registers */
  76. pld = inb(0x26) | (inb(0x27) << 8);
  77. /*
  78. * Now, for every possible bit set, work through
  79. * them and call the appropriate interrupt handler.
  80. */
  81. while (pld) {
  82. i = ffz(~pld);
  83. pld &= pld - 1; /* clear least bit set */
  84. if (i == 5) {
  85. isa_device_interrupt(vector);
  86. } else {
  87. handle_irq(16 + i);
  88. }
  89. }
  90. }
  91. static void __init
  92. eb64p_init_irq(void)
  93. {
  94. long i;
  95. #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_CABRIOLET)
  96. /*
  97. * CABRIO SRM may not set variation correctly, so here we test
  98. * the high word of the interrupt summary register for the RAZ
  99. * bits, and hope that a true EB64+ would read all ones...
  100. */
  101. if (inw(0x806) != 0xffff) {
  102. extern struct alpha_machine_vector cabriolet_mv;
  103. printk("Detected Cabriolet: correcting HWRPB.\n");
  104. hwrpb->sys_variation |= 2L << 10;
  105. hwrpb_update_checksum(hwrpb);
  106. alpha_mv = cabriolet_mv;
  107. alpha_mv.init_irq();
  108. return;
  109. }
  110. #endif /* GENERIC */
  111. outb(0xff, 0x26);
  112. outb(0xff, 0x27);
  113. init_i8259a_irqs();
  114. for (i = 16; i < 32; ++i) {
  115. irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
  116. irq_desc[i].chip = &eb64p_irq_type;
  117. }
  118. common_init_isa_dma();
  119. setup_irq(16+5, &isa_cascade_irqaction);
  120. }
  121. /*
  122. * PCI Fixup configuration.
  123. *
  124. * There are two 8 bit external summary registers as follows:
  125. *
  126. * Summary @ 0x26:
  127. * Bit Meaning
  128. * 0 Interrupt Line A from slot 0
  129. * 1 Interrupt Line A from slot 1
  130. * 2 Interrupt Line B from slot 0
  131. * 3 Interrupt Line B from slot 1
  132. * 4 Interrupt Line C from slot 0
  133. * 5 Interrupt line from the two ISA PICs
  134. * 6 Tulip
  135. * 7 NCR SCSI
  136. *
  137. * Summary @ 0x27
  138. * Bit Meaning
  139. * 0 Interrupt Line C from slot 1
  140. * 1 Interrupt Line D from slot 0
  141. * 2 Interrupt Line D from slot 1
  142. * 3 RAZ
  143. * 4 RAZ
  144. * 5 RAZ
  145. * 6 RAZ
  146. * 7 RAZ
  147. *
  148. * The device to slot mapping looks like:
  149. *
  150. * Slot Device
  151. * 5 NCR SCSI controller
  152. * 6 PCI on board slot 0
  153. * 7 PCI on board slot 1
  154. * 8 Intel SIO PCI-ISA bridge chip
  155. * 9 Tulip - DECchip 21040 Ethernet controller
  156. *
  157. *
  158. * This two layered interrupt approach means that we allocate IRQ 16 and
  159. * above for PCI interrupts. The IRQ relates to which bit the interrupt
  160. * comes in on. This makes interrupt processing much easier.
  161. */
  162. static int __init
  163. eb64p_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  164. {
  165. static char irq_tab[5][5] __initdata = {
  166. /*INT INTA INTB INTC INTD */
  167. {16+7, 16+7, 16+7, 16+7, 16+7}, /* IdSel 5, slot ?, ?? */
  168. {16+0, 16+0, 16+2, 16+4, 16+9}, /* IdSel 6, slot ?, ?? */
  169. {16+1, 16+1, 16+3, 16+8, 16+10}, /* IdSel 7, slot ?, ?? */
  170. { -1, -1, -1, -1, -1}, /* IdSel 8, SIO */
  171. {16+6, 16+6, 16+6, 16+6, 16+6}, /* IdSel 9, TULIP */
  172. };
  173. const long min_idsel = 5, max_idsel = 9, irqs_per_slot = 5;
  174. return COMMON_TABLE_LOOKUP;
  175. }
  176. /*
  177. * The System Vector
  178. */
  179. #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EB64P)
  180. struct alpha_machine_vector eb64p_mv __initmv = {
  181. .vector_name = "EB64+",
  182. DO_EV4_MMU,
  183. DO_DEFAULT_RTC,
  184. DO_APECS_IO,
  185. .machine_check = apecs_machine_check,
  186. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  187. .min_io_address = DEFAULT_IO_BASE,
  188. .min_mem_address = APECS_AND_LCA_DEFAULT_MEM_BASE,
  189. .nr_irqs = 32,
  190. .device_interrupt = eb64p_device_interrupt,
  191. .init_arch = apecs_init_arch,
  192. .init_irq = eb64p_init_irq,
  193. .init_rtc = common_init_rtc,
  194. .init_pci = common_init_pci,
  195. .kill_arch = NULL,
  196. .pci_map_irq = eb64p_map_irq,
  197. .pci_swizzle = common_swizzle,
  198. };
  199. ALIAS_MV(eb64p)
  200. #endif
  201. #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EB66)
  202. struct alpha_machine_vector eb66_mv __initmv = {
  203. .vector_name = "EB66",
  204. DO_EV4_MMU,
  205. DO_DEFAULT_RTC,
  206. DO_LCA_IO,
  207. .machine_check = lca_machine_check,
  208. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  209. .min_io_address = DEFAULT_IO_BASE,
  210. .min_mem_address = APECS_AND_LCA_DEFAULT_MEM_BASE,
  211. .nr_irqs = 32,
  212. .device_interrupt = eb64p_device_interrupt,
  213. .init_arch = lca_init_arch,
  214. .init_irq = eb64p_init_irq,
  215. .init_rtc = common_init_rtc,
  216. .init_pci = common_init_pci,
  217. .pci_map_irq = eb64p_map_irq,
  218. .pci_swizzle = common_swizzle,
  219. };
  220. ALIAS_MV(eb66)
  221. #endif