sys_mikasa.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * linux/arch/alpha/kernel/sys_mikasa.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 MIKASA (AlphaServer 1000).
  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/mce.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/core_cia.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. /* Note mask bit is true for ENABLED irqs. */
  31. static int cached_irq_mask;
  32. static inline void
  33. mikasa_update_irq_hw(int mask)
  34. {
  35. outw(mask, 0x536);
  36. }
  37. static inline void
  38. mikasa_enable_irq(struct irq_data *d)
  39. {
  40. mikasa_update_irq_hw(cached_irq_mask |= 1 << (d->irq - 16));
  41. }
  42. static void
  43. mikasa_disable_irq(struct irq_data *d)
  44. {
  45. mikasa_update_irq_hw(cached_irq_mask &= ~(1 << (d->irq - 16)));
  46. }
  47. static struct irq_chip mikasa_irq_type = {
  48. .name = "MIKASA",
  49. .irq_unmask = mikasa_enable_irq,
  50. .irq_mask = mikasa_disable_irq,
  51. .irq_mask_ack = mikasa_disable_irq,
  52. };
  53. static void
  54. mikasa_device_interrupt(unsigned long vector)
  55. {
  56. unsigned long pld;
  57. unsigned int i;
  58. /* Read the interrupt summary registers */
  59. pld = (((~inw(0x534) & 0x0000ffffUL) << 16)
  60. | (((unsigned long) inb(0xa0)) << 8)
  61. | inb(0x20));
  62. /*
  63. * Now for every possible bit set, work through them and call
  64. * the appropriate interrupt handler.
  65. */
  66. while (pld) {
  67. i = ffz(~pld);
  68. pld &= pld - 1; /* clear least bit set */
  69. if (i < 16) {
  70. isa_device_interrupt(vector);
  71. } else {
  72. handle_irq(i);
  73. }
  74. }
  75. }
  76. static void __init
  77. mikasa_init_irq(void)
  78. {
  79. long i;
  80. if (alpha_using_srm)
  81. alpha_mv.device_interrupt = srm_device_interrupt;
  82. mikasa_update_irq_hw(0);
  83. for (i = 16; i < 32; ++i) {
  84. irq_set_chip_and_handler(i, &mikasa_irq_type,
  85. handle_level_irq);
  86. irq_set_status_flags(i, IRQ_LEVEL);
  87. }
  88. init_i8259a_irqs();
  89. common_init_isa_dma();
  90. }
  91. /*
  92. * PCI Fixup configuration.
  93. *
  94. * Summary @ 0x536:
  95. * Bit Meaning
  96. * 0 Interrupt Line A from slot 0
  97. * 1 Interrupt Line B from slot 0
  98. * 2 Interrupt Line C from slot 0
  99. * 3 Interrupt Line D from slot 0
  100. * 4 Interrupt Line A from slot 1
  101. * 5 Interrupt line B from slot 1
  102. * 6 Interrupt Line C from slot 1
  103. * 7 Interrupt Line D from slot 1
  104. * 8 Interrupt Line A from slot 2
  105. * 9 Interrupt Line B from slot 2
  106. *10 Interrupt Line C from slot 2
  107. *11 Interrupt Line D from slot 2
  108. *12 NCR 810 SCSI
  109. *13 Power Supply Fail
  110. *14 Temperature Warn
  111. *15 Reserved
  112. *
  113. * The device to slot mapping looks like:
  114. *
  115. * Slot Device
  116. * 6 NCR SCSI controller
  117. * 7 Intel PCI-EISA bridge chip
  118. * 11 PCI on board slot 0
  119. * 12 PCI on board slot 1
  120. * 13 PCI on board slot 2
  121. *
  122. *
  123. * This two layered interrupt approach means that we allocate IRQ 16 and
  124. * above for PCI interrupts. The IRQ relates to which bit the interrupt
  125. * comes in on. This makes interrupt processing much easier.
  126. */
  127. static int
  128. mikasa_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  129. {
  130. static char irq_tab[8][5] = {
  131. /*INT INTA INTB INTC INTD */
  132. {16+12, 16+12, 16+12, 16+12, 16+12}, /* IdSel 17, SCSI */
  133. { -1, -1, -1, -1, -1}, /* IdSel 18, PCEB */
  134. { -1, -1, -1, -1, -1}, /* IdSel 19, ???? */
  135. { -1, -1, -1, -1, -1}, /* IdSel 20, ???? */
  136. { -1, -1, -1, -1, -1}, /* IdSel 21, ???? */
  137. { 16+0, 16+0, 16+1, 16+2, 16+3}, /* IdSel 22, slot 0 */
  138. { 16+4, 16+4, 16+5, 16+6, 16+7}, /* IdSel 23, slot 1 */
  139. { 16+8, 16+8, 16+9, 16+10, 16+11}, /* IdSel 24, slot 2 */
  140. };
  141. const long min_idsel = 6, max_idsel = 13, irqs_per_slot = 5;
  142. return COMMON_TABLE_LOOKUP;
  143. }
  144. /*
  145. * The System Vector
  146. */
  147. struct alpha_machine_vector mikasa_primo_mv __initmv = {
  148. .vector_name = "Mikasa-Primo",
  149. DO_EV5_MMU,
  150. DO_DEFAULT_RTC,
  151. DO_CIA_IO,
  152. .machine_check = cia_machine_check,
  153. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  154. .min_io_address = DEFAULT_IO_BASE,
  155. .min_mem_address = CIA_DEFAULT_MEM_BASE,
  156. .nr_irqs = 32,
  157. .device_interrupt = mikasa_device_interrupt,
  158. .init_arch = cia_init_arch,
  159. .init_irq = mikasa_init_irq,
  160. .init_rtc = common_init_rtc,
  161. .init_pci = cia_init_pci,
  162. .kill_arch = cia_kill_arch,
  163. .pci_map_irq = mikasa_map_irq,
  164. .pci_swizzle = common_swizzle,
  165. };
  166. ALIAS_MV(mikasa_primo)