sys_rx164.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. /*
  2. * linux/arch/alpha/kernel/sys_rx164.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 RX164 (PCA56+POLARIS).
  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 <linux/bitops.h>
  17. #include <asm/ptrace.h>
  18. #include <asm/system.h>
  19. #include <asm/dma.h>
  20. #include <asm/irq.h>
  21. #include <asm/mmu_context.h>
  22. #include <asm/io.h>
  23. #include <asm/pgtable.h>
  24. #include <asm/core_polaris.h>
  25. #include <asm/tlbflush.h>
  26. #include "proto.h"
  27. #include "irq_impl.h"
  28. #include "pci_impl.h"
  29. #include "machvec_impl.h"
  30. /* Note mask bit is true for ENABLED irqs. */
  31. static unsigned long cached_irq_mask;
  32. static inline void
  33. rx164_update_irq_hw(unsigned long mask)
  34. {
  35. volatile unsigned int *irq_mask;
  36. irq_mask = (void *)(POLARIS_DENSE_CONFIG_BASE + 0x74);
  37. *irq_mask = mask;
  38. mb();
  39. *irq_mask;
  40. }
  41. static inline void
  42. rx164_enable_irq(unsigned int irq)
  43. {
  44. rx164_update_irq_hw(cached_irq_mask |= 1UL << (irq - 16));
  45. }
  46. static void
  47. rx164_disable_irq(unsigned int irq)
  48. {
  49. rx164_update_irq_hw(cached_irq_mask &= ~(1UL << (irq - 16)));
  50. }
  51. static unsigned int
  52. rx164_startup_irq(unsigned int irq)
  53. {
  54. rx164_enable_irq(irq);
  55. return 0;
  56. }
  57. static void
  58. rx164_end_irq(unsigned int irq)
  59. {
  60. if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
  61. rx164_enable_irq(irq);
  62. }
  63. static struct hw_interrupt_type rx164_irq_type = {
  64. .typename = "RX164",
  65. .startup = rx164_startup_irq,
  66. .shutdown = rx164_disable_irq,
  67. .enable = rx164_enable_irq,
  68. .disable = rx164_disable_irq,
  69. .ack = rx164_disable_irq,
  70. .end = rx164_end_irq,
  71. };
  72. static void
  73. rx164_device_interrupt(unsigned long vector)
  74. {
  75. unsigned long pld;
  76. volatile unsigned int *dirr;
  77. long i;
  78. /* Read the interrupt summary register. On Polaris, this is
  79. the DIRR register in PCI config space (offset 0x84). */
  80. dirr = (void *)(POLARIS_DENSE_CONFIG_BASE + 0x84);
  81. pld = *dirr;
  82. /*
  83. * Now for every possible bit set, work through them and call
  84. * the appropriate interrupt handler.
  85. */
  86. while (pld) {
  87. i = ffz(~pld);
  88. pld &= pld - 1; /* clear least bit set */
  89. if (i == 20) {
  90. isa_no_iack_sc_device_interrupt(vector);
  91. } else {
  92. handle_irq(16+i);
  93. }
  94. }
  95. }
  96. static void __init
  97. rx164_init_irq(void)
  98. {
  99. long i;
  100. rx164_update_irq_hw(0);
  101. for (i = 16; i < 40; ++i) {
  102. irq_desc[i].status = IRQ_DISABLED | IRQ_LEVEL;
  103. irq_desc[i].chip = &rx164_irq_type;
  104. }
  105. init_i8259a_irqs();
  106. common_init_isa_dma();
  107. setup_irq(16+20, &isa_cascade_irqaction);
  108. }
  109. /*
  110. * The RX164 changed its interrupt routing between pass1 and pass2...
  111. *
  112. * PASS1:
  113. *
  114. * Slot IDSEL INTA INTB INTC INTD
  115. * 0 6 5 10 15 20
  116. * 1 7 4 9 14 19
  117. * 2 5 3 8 13 18
  118. * 3 9 2 7 12 17
  119. * 4 10 1 6 11 16
  120. *
  121. * PASS2:
  122. * Slot IDSEL INTA INTB INTC INTD
  123. * 0 5 1 7 12 17
  124. * 1 6 2 8 13 18
  125. * 2 8 3 9 14 19
  126. * 3 9 4 10 15 20
  127. * 4 10 5 11 16 6
  128. *
  129. */
  130. /*
  131. * IdSel
  132. * 5 32 bit PCI option slot 0
  133. * 6 64 bit PCI option slot 1
  134. * 7 PCI-ISA bridge
  135. * 7 64 bit PCI option slot 2
  136. * 9 32 bit PCI option slot 3
  137. * 10 PCI-PCI bridge
  138. *
  139. */
  140. static int __init
  141. rx164_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  142. {
  143. #if 0
  144. static char irq_tab_pass1[6][5] __initdata = {
  145. /*INT INTA INTB INTC INTD */
  146. { 16+3, 16+3, 16+8, 16+13, 16+18}, /* IdSel 5, slot 2 */
  147. { 16+5, 16+5, 16+10, 16+15, 16+20}, /* IdSel 6, slot 0 */
  148. { 16+4, 16+4, 16+9, 16+14, 16+19}, /* IdSel 7, slot 1 */
  149. { -1, -1, -1, -1, -1}, /* IdSel 8, PCI/ISA bridge */
  150. { 16+2, 16+2, 16+7, 16+12, 16+17}, /* IdSel 9, slot 3 */
  151. { 16+1, 16+1, 16+6, 16+11, 16+16}, /* IdSel 10, slot 4 */
  152. };
  153. #else
  154. static char irq_tab[6][5] __initdata = {
  155. /*INT INTA INTB INTC INTD */
  156. { 16+0, 16+0, 16+6, 16+11, 16+16}, /* IdSel 5, slot 0 */
  157. { 16+1, 16+1, 16+7, 16+12, 16+17}, /* IdSel 6, slot 1 */
  158. { -1, -1, -1, -1, -1}, /* IdSel 7, PCI/ISA bridge */
  159. { 16+2, 16+2, 16+8, 16+13, 16+18}, /* IdSel 8, slot 2 */
  160. { 16+3, 16+3, 16+9, 16+14, 16+19}, /* IdSel 9, slot 3 */
  161. { 16+4, 16+4, 16+10, 16+15, 16+5}, /* IdSel 10, PCI-PCI */
  162. };
  163. #endif
  164. const long min_idsel = 5, max_idsel = 10, irqs_per_slot = 5;
  165. /* JRP - Need to figure out how to distinguish pass1 from pass2,
  166. and use the correct table. */
  167. return COMMON_TABLE_LOOKUP;
  168. }
  169. /*
  170. * The System Vector
  171. */
  172. struct alpha_machine_vector rx164_mv __initmv = {
  173. .vector_name = "RX164",
  174. DO_EV5_MMU,
  175. DO_DEFAULT_RTC,
  176. DO_POLARIS_IO,
  177. .machine_check = polaris_machine_check,
  178. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  179. .min_io_address = DEFAULT_IO_BASE,
  180. .min_mem_address = DEFAULT_MEM_BASE,
  181. .nr_irqs = 40,
  182. .device_interrupt = rx164_device_interrupt,
  183. .init_arch = polaris_init_arch,
  184. .init_irq = rx164_init_irq,
  185. .init_rtc = common_init_rtc,
  186. .init_pci = common_init_pci,
  187. .kill_arch = NULL,
  188. .pci_map_irq = rx164_map_irq,
  189. .pci_swizzle = common_swizzle,
  190. };
  191. ALIAS_MV(rx164)