sys_rawhide.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. /*
  2. * linux/arch/alpha/kernel/sys_rawhide.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 RAWHIDE.
  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 <asm/ptrace.h>
  17. #include <asm/system.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_mcpcia.h>
  24. #include <asm/tlbflush.h>
  25. #include "proto.h"
  26. #include "irq_impl.h"
  27. #include "pci_impl.h"
  28. #include "machvec_impl.h"
  29. /*
  30. * HACK ALERT! only the boot cpu is used for interrupts.
  31. */
  32. /* Note mask bit is true for ENABLED irqs. */
  33. static unsigned int hose_irq_masks[4] = {
  34. 0xff0000, 0xfe0000, 0xff0000, 0xff0000
  35. };
  36. static unsigned int cached_irq_masks[4];
  37. DEFINE_SPINLOCK(rawhide_irq_lock);
  38. static inline void
  39. rawhide_update_irq_hw(int hose, int mask)
  40. {
  41. *(vuip)MCPCIA_INT_MASK0(MCPCIA_HOSE2MID(hose)) = mask;
  42. mb();
  43. *(vuip)MCPCIA_INT_MASK0(MCPCIA_HOSE2MID(hose));
  44. }
  45. static inline void
  46. rawhide_enable_irq(unsigned int irq)
  47. {
  48. unsigned int mask, hose;
  49. irq -= 16;
  50. hose = irq / 24;
  51. irq -= hose * 24;
  52. mask = 1 << irq;
  53. spin_lock(&rawhide_irq_lock);
  54. mask |= cached_irq_masks[hose];
  55. cached_irq_masks[hose] = mask;
  56. rawhide_update_irq_hw(hose, mask);
  57. spin_unlock(&rawhide_irq_lock);
  58. }
  59. static void
  60. rawhide_disable_irq(unsigned int irq)
  61. {
  62. unsigned int mask, hose;
  63. irq -= 16;
  64. hose = irq / 24;
  65. irq -= hose * 24;
  66. mask = ~(1 << irq) | hose_irq_masks[hose];
  67. spin_lock(&rawhide_irq_lock);
  68. mask &= cached_irq_masks[hose];
  69. cached_irq_masks[hose] = mask;
  70. rawhide_update_irq_hw(hose, mask);
  71. spin_unlock(&rawhide_irq_lock);
  72. }
  73. static void
  74. rawhide_mask_and_ack_irq(unsigned int irq)
  75. {
  76. unsigned int mask, mask1, hose;
  77. irq -= 16;
  78. hose = irq / 24;
  79. irq -= hose * 24;
  80. mask1 = 1 << irq;
  81. mask = ~mask1 | hose_irq_masks[hose];
  82. spin_lock(&rawhide_irq_lock);
  83. mask &= cached_irq_masks[hose];
  84. cached_irq_masks[hose] = mask;
  85. rawhide_update_irq_hw(hose, mask);
  86. /* Clear the interrupt. */
  87. *(vuip)MCPCIA_INT_REQ(MCPCIA_HOSE2MID(hose)) = mask1;
  88. spin_unlock(&rawhide_irq_lock);
  89. }
  90. static unsigned int
  91. rawhide_startup_irq(unsigned int irq)
  92. {
  93. rawhide_enable_irq(irq);
  94. return 0;
  95. }
  96. static void
  97. rawhide_end_irq(unsigned int irq)
  98. {
  99. if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
  100. rawhide_enable_irq(irq);
  101. }
  102. static struct hw_interrupt_type rawhide_irq_type = {
  103. .typename = "RAWHIDE",
  104. .startup = rawhide_startup_irq,
  105. .shutdown = rawhide_disable_irq,
  106. .enable = rawhide_enable_irq,
  107. .disable = rawhide_disable_irq,
  108. .ack = rawhide_mask_and_ack_irq,
  109. .end = rawhide_end_irq,
  110. };
  111. static void
  112. rawhide_srm_device_interrupt(unsigned long vector, struct pt_regs * regs)
  113. {
  114. int irq;
  115. irq = (vector - 0x800) >> 4;
  116. /*
  117. * The RAWHIDE SRM console reports PCI interrupts with a vector
  118. * 0x80 *higher* than one might expect, as PCI IRQ 0 (ie bit 0)
  119. * shows up as IRQ 24, etc, etc. We adjust it down by 8 to have
  120. * it line up with the actual bit numbers from the REQ registers,
  121. * which is how we manage the interrupts/mask. Sigh...
  122. *
  123. * Also, PCI #1 interrupts are offset some more... :-(
  124. */
  125. if (irq == 52) {
  126. /* SCSI on PCI1 is special. */
  127. irq = 72;
  128. }
  129. /* Adjust by which hose it is from. */
  130. irq -= ((irq + 16) >> 2) & 0x38;
  131. handle_irq(irq, regs);
  132. }
  133. static void __init
  134. rawhide_init_irq(void)
  135. {
  136. struct pci_controller *hose;
  137. long i;
  138. mcpcia_init_hoses();
  139. for (hose = hose_head; hose; hose = hose->next) {
  140. unsigned int h = hose->index;
  141. unsigned int mask = hose_irq_masks[h];
  142. cached_irq_masks[h] = mask;
  143. *(vuip)MCPCIA_INT_MASK0(MCPCIA_HOSE2MID(h)) = mask;
  144. *(vuip)MCPCIA_INT_MASK1(MCPCIA_HOSE2MID(h)) = 0;
  145. }
  146. for (i = 16; i < 128; ++i) {
  147. irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
  148. irq_desc[i].handler = &rawhide_irq_type;
  149. }
  150. init_i8259a_irqs();
  151. common_init_isa_dma();
  152. }
  153. /*
  154. * PCI Fixup configuration.
  155. *
  156. * Summary @ MCPCIA_PCI0_INT_REQ:
  157. * Bit Meaning
  158. * 0 Interrupt Line A from slot 2 PCI0
  159. * 1 Interrupt Line B from slot 2 PCI0
  160. * 2 Interrupt Line C from slot 2 PCI0
  161. * 3 Interrupt Line D from slot 2 PCI0
  162. * 4 Interrupt Line A from slot 3 PCI0
  163. * 5 Interrupt Line B from slot 3 PCI0
  164. * 6 Interrupt Line C from slot 3 PCI0
  165. * 7 Interrupt Line D from slot 3 PCI0
  166. * 8 Interrupt Line A from slot 4 PCI0
  167. * 9 Interrupt Line B from slot 4 PCI0
  168. * 10 Interrupt Line C from slot 4 PCI0
  169. * 11 Interrupt Line D from slot 4 PCI0
  170. * 12 Interrupt Line A from slot 5 PCI0
  171. * 13 Interrupt Line B from slot 5 PCI0
  172. * 14 Interrupt Line C from slot 5 PCI0
  173. * 15 Interrupt Line D from slot 5 PCI0
  174. * 16 EISA interrupt (PCI 0) or SCSI interrupt (PCI 1)
  175. * 17-23 NA
  176. *
  177. * IdSel
  178. * 1 EISA bridge (PCI bus 0 only)
  179. * 2 PCI option slot 2
  180. * 3 PCI option slot 3
  181. * 4 PCI option slot 4
  182. * 5 PCI option slot 5
  183. *
  184. */
  185. static int __init
  186. rawhide_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  187. {
  188. static char irq_tab[5][5] __initdata = {
  189. /*INT INTA INTB INTC INTD */
  190. { 16+16, 16+16, 16+16, 16+16, 16+16}, /* IdSel 1 SCSI PCI 1 */
  191. { 16+ 0, 16+ 0, 16+ 1, 16+ 2, 16+ 3}, /* IdSel 2 slot 2 */
  192. { 16+ 4, 16+ 4, 16+ 5, 16+ 6, 16+ 7}, /* IdSel 3 slot 3 */
  193. { 16+ 8, 16+ 8, 16+ 9, 16+10, 16+11}, /* IdSel 4 slot 4 */
  194. { 16+12, 16+12, 16+13, 16+14, 16+15} /* IdSel 5 slot 5 */
  195. };
  196. const long min_idsel = 1, max_idsel = 5, irqs_per_slot = 5;
  197. struct pci_controller *hose = dev->sysdata;
  198. int irq = COMMON_TABLE_LOOKUP;
  199. if (irq >= 0)
  200. irq += 24 * hose->index;
  201. return irq;
  202. }
  203. /*
  204. * The System Vector
  205. */
  206. struct alpha_machine_vector rawhide_mv __initmv = {
  207. .vector_name = "Rawhide",
  208. DO_EV5_MMU,
  209. DO_DEFAULT_RTC,
  210. DO_MCPCIA_IO,
  211. .machine_check = mcpcia_machine_check,
  212. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  213. .min_io_address = DEFAULT_IO_BASE,
  214. .min_mem_address = MCPCIA_DEFAULT_MEM_BASE,
  215. .pci_dac_offset = MCPCIA_DAC_OFFSET,
  216. .nr_irqs = 128,
  217. .device_interrupt = rawhide_srm_device_interrupt,
  218. .init_arch = mcpcia_init_arch,
  219. .init_irq = rawhide_init_irq,
  220. .init_rtc = common_init_rtc,
  221. .init_pci = common_init_pci,
  222. .kill_arch = NULL,
  223. .pci_map_irq = rawhide_map_irq,
  224. .pci_swizzle = common_swizzle,
  225. };
  226. ALIAS_MV(rawhide)