sys_rawhide.c 6.4 KB

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