sys_eiger.c 5.4 KB

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