sys_rawhide.c 6.3 KB

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