sys_rawhide.c 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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 unsigned int
  99. rawhide_startup_irq(unsigned int irq)
  100. {
  101. rawhide_enable_irq(irq);
  102. return 0;
  103. }
  104. static void
  105. rawhide_end_irq(unsigned int irq)
  106. {
  107. if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
  108. rawhide_enable_irq(irq);
  109. }
  110. static struct hw_interrupt_type rawhide_irq_type = {
  111. .typename = "RAWHIDE",
  112. .startup = rawhide_startup_irq,
  113. .shutdown = rawhide_disable_irq,
  114. .enable = rawhide_enable_irq,
  115. .disable = rawhide_disable_irq,
  116. .ack = rawhide_mask_and_ack_irq,
  117. .end = rawhide_end_irq,
  118. };
  119. static void
  120. rawhide_srm_device_interrupt(unsigned long vector)
  121. {
  122. int irq;
  123. irq = (vector - 0x800) >> 4;
  124. /*
  125. * The RAWHIDE SRM console reports PCI interrupts with a vector
  126. * 0x80 *higher* than one might expect, as PCI IRQ 0 (ie bit 0)
  127. * shows up as IRQ 24, etc, etc. We adjust it down by 8 to have
  128. * it line up with the actual bit numbers from the REQ registers,
  129. * which is how we manage the interrupts/mask. Sigh...
  130. *
  131. * Also, PCI #1 interrupts are offset some more... :-(
  132. */
  133. if (irq == 52) {
  134. /* SCSI on PCI1 is special. */
  135. irq = 72;
  136. }
  137. /* Adjust by which hose it is from. */
  138. irq -= ((irq + 16) >> 2) & 0x38;
  139. handle_irq(irq);
  140. }
  141. static void __init
  142. rawhide_init_irq(void)
  143. {
  144. struct pci_controller *hose;
  145. long i;
  146. mcpcia_init_hoses();
  147. /* Clear them all; only hoses that exist will be non-zero. */
  148. for (i = 0; i < MCPCIA_MAX_HOSES; i++) cached_irq_masks[i] = 0;
  149. for (hose = hose_head; hose; hose = hose->next) {
  150. unsigned int h = hose->index;
  151. unsigned int mask = hose_irq_masks[h];
  152. cached_irq_masks[h] = mask;
  153. *(vuip)MCPCIA_INT_MASK0(MCPCIA_HOSE2MID(h)) = mask;
  154. *(vuip)MCPCIA_INT_MASK1(MCPCIA_HOSE2MID(h)) = 0;
  155. }
  156. for (i = 16; i < 128; ++i) {
  157. irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
  158. irq_desc[i].chip = &rawhide_irq_type;
  159. }
  160. init_i8259a_irqs();
  161. common_init_isa_dma();
  162. }
  163. /*
  164. * PCI Fixup configuration.
  165. *
  166. * Summary @ MCPCIA_PCI0_INT_REQ:
  167. * Bit Meaning
  168. * 0 Interrupt Line A from slot 2 PCI0
  169. * 1 Interrupt Line B from slot 2 PCI0
  170. * 2 Interrupt Line C from slot 2 PCI0
  171. * 3 Interrupt Line D from slot 2 PCI0
  172. * 4 Interrupt Line A from slot 3 PCI0
  173. * 5 Interrupt Line B from slot 3 PCI0
  174. * 6 Interrupt Line C from slot 3 PCI0
  175. * 7 Interrupt Line D from slot 3 PCI0
  176. * 8 Interrupt Line A from slot 4 PCI0
  177. * 9 Interrupt Line B from slot 4 PCI0
  178. * 10 Interrupt Line C from slot 4 PCI0
  179. * 11 Interrupt Line D from slot 4 PCI0
  180. * 12 Interrupt Line A from slot 5 PCI0
  181. * 13 Interrupt Line B from slot 5 PCI0
  182. * 14 Interrupt Line C from slot 5 PCI0
  183. * 15 Interrupt Line D from slot 5 PCI0
  184. * 16 EISA interrupt (PCI 0) or SCSI interrupt (PCI 1)
  185. * 17-23 NA
  186. *
  187. * IdSel
  188. * 1 EISA bridge (PCI bus 0 only)
  189. * 2 PCI option slot 2
  190. * 3 PCI option slot 3
  191. * 4 PCI option slot 4
  192. * 5 PCI option slot 5
  193. *
  194. */
  195. static int __init
  196. rawhide_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  197. {
  198. static char irq_tab[5][5] __initdata = {
  199. /*INT INTA INTB INTC INTD */
  200. { 16+16, 16+16, 16+16, 16+16, 16+16}, /* IdSel 1 SCSI PCI 1 */
  201. { 16+ 0, 16+ 0, 16+ 1, 16+ 2, 16+ 3}, /* IdSel 2 slot 2 */
  202. { 16+ 4, 16+ 4, 16+ 5, 16+ 6, 16+ 7}, /* IdSel 3 slot 3 */
  203. { 16+ 8, 16+ 8, 16+ 9, 16+10, 16+11}, /* IdSel 4 slot 4 */
  204. { 16+12, 16+12, 16+13, 16+14, 16+15} /* IdSel 5 slot 5 */
  205. };
  206. const long min_idsel = 1, max_idsel = 5, irqs_per_slot = 5;
  207. struct pci_controller *hose = dev->sysdata;
  208. int irq = COMMON_TABLE_LOOKUP;
  209. if (irq >= 0)
  210. irq += 24 * hose->index;
  211. return irq;
  212. }
  213. /*
  214. * The System Vector
  215. */
  216. struct alpha_machine_vector rawhide_mv __initmv = {
  217. .vector_name = "Rawhide",
  218. DO_EV5_MMU,
  219. DO_DEFAULT_RTC,
  220. DO_MCPCIA_IO,
  221. .machine_check = mcpcia_machine_check,
  222. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  223. .min_io_address = DEFAULT_IO_BASE,
  224. .min_mem_address = MCPCIA_DEFAULT_MEM_BASE,
  225. .pci_dac_offset = MCPCIA_DAC_OFFSET,
  226. .nr_irqs = 128,
  227. .device_interrupt = rawhide_srm_device_interrupt,
  228. .init_arch = mcpcia_init_arch,
  229. .init_irq = rawhide_init_irq,
  230. .init_rtc = common_init_rtc,
  231. .init_pci = common_init_pci,
  232. .kill_arch = NULL,
  233. .pci_map_irq = rawhide_map_irq,
  234. .pci_swizzle = common_swizzle,
  235. };
  236. ALIAS_MV(rawhide)