sys_eb64p.c 6.0 KB

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