sys_eb64p.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * linux/arch/alpha/kernel/sys_eb64p.c
  4. *
  5. * Copyright (C) 1995 David A Rusling
  6. * Copyright (C) 1996 Jay A Estabrook
  7. * Copyright (C) 1998, 1999 Richard Henderson
  8. *
  9. * Code supporting the EB64+ and EB66.
  10. */
  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/dma.h>
  20. #include <asm/irq.h>
  21. #include <asm/mmu_context.h>
  22. #include <asm/io.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. if (request_irq(16 + 5, no_action, 0, "isa-cascade", NULL))
  104. pr_err("Failed to register isa-cascade interrupt\n");
  105. }
  106. /*
  107. * PCI Fixup configuration.
  108. *
  109. * There are two 8 bit external summary registers as follows:
  110. *
  111. * Summary @ 0x26:
  112. * Bit Meaning
  113. * 0 Interrupt Line A from slot 0
  114. * 1 Interrupt Line A from slot 1
  115. * 2 Interrupt Line B from slot 0
  116. * 3 Interrupt Line B from slot 1
  117. * 4 Interrupt Line C from slot 0
  118. * 5 Interrupt line from the two ISA PICs
  119. * 6 Tulip
  120. * 7 NCR SCSI
  121. *
  122. * Summary @ 0x27
  123. * Bit Meaning
  124. * 0 Interrupt Line C from slot 1
  125. * 1 Interrupt Line D from slot 0
  126. * 2 Interrupt Line D from slot 1
  127. * 3 RAZ
  128. * 4 RAZ
  129. * 5 RAZ
  130. * 6 RAZ
  131. * 7 RAZ
  132. *
  133. * The device to slot mapping looks like:
  134. *
  135. * Slot Device
  136. * 5 NCR SCSI controller
  137. * 6 PCI on board slot 0
  138. * 7 PCI on board slot 1
  139. * 8 Intel SIO PCI-ISA bridge chip
  140. * 9 Tulip - DECchip 21040 Ethernet controller
  141. *
  142. *
  143. * This two layered interrupt approach means that we allocate IRQ 16 and
  144. * above for PCI interrupts. The IRQ relates to which bit the interrupt
  145. * comes in on. This makes interrupt processing much easier.
  146. */
  147. static int
  148. eb64p_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  149. {
  150. static char irq_tab[5][5] = {
  151. /*INT INTA INTB INTC INTD */
  152. {16+7, 16+7, 16+7, 16+7, 16+7}, /* IdSel 5, slot ?, ?? */
  153. {16+0, 16+0, 16+2, 16+4, 16+9}, /* IdSel 6, slot ?, ?? */
  154. {16+1, 16+1, 16+3, 16+8, 16+10}, /* IdSel 7, slot ?, ?? */
  155. { -1, -1, -1, -1, -1}, /* IdSel 8, SIO */
  156. {16+6, 16+6, 16+6, 16+6, 16+6}, /* IdSel 9, TULIP */
  157. };
  158. const long min_idsel = 5, max_idsel = 9, irqs_per_slot = 5;
  159. return COMMON_TABLE_LOOKUP;
  160. }
  161. /*
  162. * The System Vector
  163. */
  164. #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EB64P)
  165. struct alpha_machine_vector eb64p_mv __initmv = {
  166. .vector_name = "EB64+",
  167. DO_EV4_MMU,
  168. DO_DEFAULT_RTC,
  169. DO_APECS_IO,
  170. .machine_check = apecs_machine_check,
  171. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  172. .min_io_address = DEFAULT_IO_BASE,
  173. .min_mem_address = APECS_AND_LCA_DEFAULT_MEM_BASE,
  174. .nr_irqs = 32,
  175. .device_interrupt = eb64p_device_interrupt,
  176. .init_arch = apecs_init_arch,
  177. .init_irq = eb64p_init_irq,
  178. .init_rtc = common_init_rtc,
  179. .init_pci = common_init_pci,
  180. .kill_arch = NULL,
  181. .pci_map_irq = eb64p_map_irq,
  182. .pci_swizzle = common_swizzle,
  183. };
  184. ALIAS_MV(eb64p)
  185. #endif
  186. #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EB66)
  187. struct alpha_machine_vector eb66_mv __initmv = {
  188. .vector_name = "EB66",
  189. DO_EV4_MMU,
  190. DO_DEFAULT_RTC,
  191. DO_LCA_IO,
  192. .machine_check = lca_machine_check,
  193. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  194. .min_io_address = DEFAULT_IO_BASE,
  195. .min_mem_address = APECS_AND_LCA_DEFAULT_MEM_BASE,
  196. .nr_irqs = 32,
  197. .device_interrupt = eb64p_device_interrupt,
  198. .init_arch = lca_init_arch,
  199. .init_irq = eb64p_init_irq,
  200. .init_rtc = common_init_rtc,
  201. .init_pci = common_init_pci,
  202. .pci_map_irq = eb64p_map_irq,
  203. .pci_swizzle = common_swizzle,
  204. };
  205. ALIAS_MV(eb66)
  206. #endif