sys_eb64p.c 5.6 KB

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