sys_rawhide.c 6.4 KB

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