sys_eiger.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /*
  2. * linux/arch/alpha/kernel/sys_eiger.c
  3. *
  4. * Copyright (C) 1995 David A Rusling
  5. * Copyright (C) 1996, 1999 Jay A Estabrook
  6. * Copyright (C) 1998, 1999 Richard Henderson
  7. * Copyright (C) 1999 Iain Grant
  8. *
  9. * Code supporting the EIGER (EV6+TSUNAMI).
  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/pgtable.h>
  24. #include <asm/core_tsunami.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 that this interrupt code is identical to TAKARA. */
  32. /* Note mask bit is true for DISABLED irqs. */
  33. static unsigned long cached_irq_mask[2] = { -1, -1 };
  34. static inline void
  35. eiger_update_irq_hw(unsigned long irq, unsigned long mask)
  36. {
  37. int regaddr;
  38. mask = (irq >= 64 ? mask << 16 : mask >> ((irq - 16) & 0x30));
  39. regaddr = 0x510 + (((irq - 16) >> 2) & 0x0c);
  40. outl(mask & 0xffff0000UL, regaddr);
  41. }
  42. static inline void
  43. eiger_enable_irq(struct irq_data *d)
  44. {
  45. unsigned int irq = d->irq;
  46. unsigned long mask;
  47. mask = (cached_irq_mask[irq >= 64] &= ~(1UL << (irq & 63)));
  48. eiger_update_irq_hw(irq, mask);
  49. }
  50. static void
  51. eiger_disable_irq(struct irq_data *d)
  52. {
  53. unsigned int irq = d->irq;
  54. unsigned long mask;
  55. mask = (cached_irq_mask[irq >= 64] |= 1UL << (irq & 63));
  56. eiger_update_irq_hw(irq, mask);
  57. }
  58. static struct irq_chip eiger_irq_type = {
  59. .name = "EIGER",
  60. .irq_unmask = eiger_enable_irq,
  61. .irq_mask = eiger_disable_irq,
  62. .irq_mask_ack = eiger_disable_irq,
  63. };
  64. static void
  65. eiger_device_interrupt(unsigned long vector)
  66. {
  67. unsigned intstatus;
  68. /*
  69. * The PALcode will have passed us vectors 0x800 or 0x810,
  70. * which are fairly arbitrary values and serve only to tell
  71. * us whether an interrupt has come in on IRQ0 or IRQ1. If
  72. * it's IRQ1 it's a PCI interrupt; if it's IRQ0, it's
  73. * probably ISA, but PCI interrupts can come through IRQ0
  74. * as well if the interrupt controller isn't in accelerated
  75. * mode.
  76. *
  77. * OTOH, the accelerator thing doesn't seem to be working
  78. * overly well, so what we'll do instead is try directly
  79. * examining the Master Interrupt Register to see if it's a
  80. * PCI interrupt, and if _not_ then we'll pass it on to the
  81. * ISA handler.
  82. */
  83. intstatus = inw(0x500) & 15;
  84. if (intstatus) {
  85. /*
  86. * This is a PCI interrupt. Check each bit and
  87. * despatch an interrupt if it's set.
  88. */
  89. if (intstatus & 8) handle_irq(16+3);
  90. if (intstatus & 4) handle_irq(16+2);
  91. if (intstatus & 2) handle_irq(16+1);
  92. if (intstatus & 1) handle_irq(16+0);
  93. } else {
  94. isa_device_interrupt(vector);
  95. }
  96. }
  97. static void
  98. eiger_srm_device_interrupt(unsigned long vector)
  99. {
  100. int irq = (vector - 0x800) >> 4;
  101. handle_irq(irq);
  102. }
  103. static void __init
  104. eiger_init_irq(void)
  105. {
  106. long i;
  107. outb(0, DMA1_RESET_REG);
  108. outb(0, DMA2_RESET_REG);
  109. outb(DMA_MODE_CASCADE, DMA2_MODE_REG);
  110. outb(0, DMA2_MASK_REG);
  111. if (alpha_using_srm)
  112. alpha_mv.device_interrupt = eiger_srm_device_interrupt;
  113. for (i = 16; i < 128; i += 16)
  114. eiger_update_irq_hw(i, -1);
  115. init_i8259a_irqs();
  116. for (i = 16; i < 128; ++i) {
  117. irq_set_chip_and_handler(i, &eiger_irq_type, handle_level_irq);
  118. irq_set_status_flags(i, IRQ_LEVEL);
  119. }
  120. }
  121. static int __init
  122. eiger_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  123. {
  124. u8 irq_orig;
  125. /* The SRM console has already calculated out the IRQ value's for
  126. option cards. As this works lets just read in the value already
  127. set and change it to a useable value by Linux.
  128. All the IRQ values generated by the console are greater than 90,
  129. so we subtract 80 because it is (90 - allocated ISA IRQ's). */
  130. pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq_orig);
  131. return irq_orig - 0x80;
  132. }
  133. static u8 __init
  134. eiger_swizzle(struct pci_dev *dev, u8 *pinp)
  135. {
  136. struct pci_controller *hose = dev->sysdata;
  137. int slot, pin = *pinp;
  138. int bridge_count = 0;
  139. /* Find the number of backplane bridges. */
  140. int backplane = inw(0x502) & 0x0f;
  141. switch (backplane)
  142. {
  143. case 0x00: bridge_count = 0; break; /* No bridges */
  144. case 0x01: bridge_count = 1; break; /* 1 */
  145. case 0x03: bridge_count = 2; break; /* 2 */
  146. case 0x07: bridge_count = 3; break; /* 3 */
  147. case 0x0f: bridge_count = 4; break; /* 4 */
  148. };
  149. slot = PCI_SLOT(dev->devfn);
  150. while (dev->bus->self) {
  151. /* Check for built-in bridges on hose 0. */
  152. if (hose->index == 0
  153. && (PCI_SLOT(dev->bus->self->devfn)
  154. > 20 - bridge_count)) {
  155. slot = PCI_SLOT(dev->devfn);
  156. break;
  157. }
  158. /* Must be a card-based bridge. */
  159. pin = pci_swizzle_interrupt_pin(dev, pin);
  160. /* Move up the chain of bridges. */
  161. dev = dev->bus->self;
  162. }
  163. *pinp = pin;
  164. return slot;
  165. }
  166. /*
  167. * The System Vectors
  168. */
  169. struct alpha_machine_vector eiger_mv __initmv = {
  170. .vector_name = "Eiger",
  171. DO_EV6_MMU,
  172. DO_DEFAULT_RTC,
  173. DO_TSUNAMI_IO,
  174. .machine_check = tsunami_machine_check,
  175. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  176. .min_io_address = DEFAULT_IO_BASE,
  177. .min_mem_address = DEFAULT_MEM_BASE,
  178. .pci_dac_offset = TSUNAMI_DAC_OFFSET,
  179. .nr_irqs = 128,
  180. .device_interrupt = eiger_device_interrupt,
  181. .init_arch = tsunami_init_arch,
  182. .init_irq = eiger_init_irq,
  183. .init_rtc = common_init_rtc,
  184. .init_pci = common_init_pci,
  185. .kill_arch = tsunami_kill_arch,
  186. .pci_map_irq = eiger_map_irq,
  187. .pci_swizzle = eiger_swizzle,
  188. };
  189. ALIAS_MV(eiger)