sys_rx164.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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(struct irq_data *d)
  43. {
  44. rx164_update_irq_hw(cached_irq_mask |= 1UL << (d->irq - 16));
  45. }
  46. static void
  47. rx164_disable_irq(struct irq_data *d)
  48. {
  49. rx164_update_irq_hw(cached_irq_mask &= ~(1UL << (d->irq - 16)));
  50. }
  51. static struct irq_chip rx164_irq_type = {
  52. .name = "RX164",
  53. .irq_unmask = rx164_enable_irq,
  54. .irq_mask = rx164_disable_irq,
  55. .irq_mask_ack = rx164_disable_irq,
  56. };
  57. static void
  58. rx164_device_interrupt(unsigned long vector)
  59. {
  60. unsigned long pld;
  61. volatile unsigned int *dirr;
  62. long i;
  63. /* Read the interrupt summary register. On Polaris, this is
  64. the DIRR register in PCI config space (offset 0x84). */
  65. dirr = (void *)(POLARIS_DENSE_CONFIG_BASE + 0x84);
  66. pld = *dirr;
  67. /*
  68. * Now for every possible bit set, work through them and call
  69. * the appropriate interrupt handler.
  70. */
  71. while (pld) {
  72. i = ffz(~pld);
  73. pld &= pld - 1; /* clear least bit set */
  74. if (i == 20) {
  75. isa_no_iack_sc_device_interrupt(vector);
  76. } else {
  77. handle_irq(16+i);
  78. }
  79. }
  80. }
  81. static void __init
  82. rx164_init_irq(void)
  83. {
  84. long i;
  85. rx164_update_irq_hw(0);
  86. for (i = 16; i < 40; ++i) {
  87. irq_set_chip_and_handler(i, &rx164_irq_type, handle_level_irq);
  88. irq_set_status_flags(i, IRQ_LEVEL);
  89. }
  90. init_i8259a_irqs();
  91. common_init_isa_dma();
  92. setup_irq(16+20, &isa_cascade_irqaction);
  93. }
  94. /*
  95. * The RX164 changed its interrupt routing between pass1 and pass2...
  96. *
  97. * PASS1:
  98. *
  99. * Slot IDSEL INTA INTB INTC INTD
  100. * 0 6 5 10 15 20
  101. * 1 7 4 9 14 19
  102. * 2 5 3 8 13 18
  103. * 3 9 2 7 12 17
  104. * 4 10 1 6 11 16
  105. *
  106. * PASS2:
  107. * Slot IDSEL INTA INTB INTC INTD
  108. * 0 5 1 7 12 17
  109. * 1 6 2 8 13 18
  110. * 2 8 3 9 14 19
  111. * 3 9 4 10 15 20
  112. * 4 10 5 11 16 6
  113. *
  114. */
  115. /*
  116. * IdSel
  117. * 5 32 bit PCI option slot 0
  118. * 6 64 bit PCI option slot 1
  119. * 7 PCI-ISA bridge
  120. * 7 64 bit PCI option slot 2
  121. * 9 32 bit PCI option slot 3
  122. * 10 PCI-PCI bridge
  123. *
  124. */
  125. static int __init
  126. rx164_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  127. {
  128. #if 0
  129. static char irq_tab_pass1[6][5] __initdata = {
  130. /*INT INTA INTB INTC INTD */
  131. { 16+3, 16+3, 16+8, 16+13, 16+18}, /* IdSel 5, slot 2 */
  132. { 16+5, 16+5, 16+10, 16+15, 16+20}, /* IdSel 6, slot 0 */
  133. { 16+4, 16+4, 16+9, 16+14, 16+19}, /* IdSel 7, slot 1 */
  134. { -1, -1, -1, -1, -1}, /* IdSel 8, PCI/ISA bridge */
  135. { 16+2, 16+2, 16+7, 16+12, 16+17}, /* IdSel 9, slot 3 */
  136. { 16+1, 16+1, 16+6, 16+11, 16+16}, /* IdSel 10, slot 4 */
  137. };
  138. #else
  139. static char irq_tab[6][5] __initdata = {
  140. /*INT INTA INTB INTC INTD */
  141. { 16+0, 16+0, 16+6, 16+11, 16+16}, /* IdSel 5, slot 0 */
  142. { 16+1, 16+1, 16+7, 16+12, 16+17}, /* IdSel 6, slot 1 */
  143. { -1, -1, -1, -1, -1}, /* IdSel 7, PCI/ISA bridge */
  144. { 16+2, 16+2, 16+8, 16+13, 16+18}, /* IdSel 8, slot 2 */
  145. { 16+3, 16+3, 16+9, 16+14, 16+19}, /* IdSel 9, slot 3 */
  146. { 16+4, 16+4, 16+10, 16+15, 16+5}, /* IdSel 10, PCI-PCI */
  147. };
  148. #endif
  149. const long min_idsel = 5, max_idsel = 10, irqs_per_slot = 5;
  150. /* JRP - Need to figure out how to distinguish pass1 from pass2,
  151. and use the correct table. */
  152. return COMMON_TABLE_LOOKUP;
  153. }
  154. /*
  155. * The System Vector
  156. */
  157. struct alpha_machine_vector rx164_mv __initmv = {
  158. .vector_name = "RX164",
  159. DO_EV5_MMU,
  160. DO_DEFAULT_RTC,
  161. DO_POLARIS_IO,
  162. .machine_check = polaris_machine_check,
  163. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  164. .min_io_address = DEFAULT_IO_BASE,
  165. .min_mem_address = DEFAULT_MEM_BASE,
  166. .nr_irqs = 40,
  167. .device_interrupt = rx164_device_interrupt,
  168. .init_arch = polaris_init_arch,
  169. .init_irq = rx164_init_irq,
  170. .init_rtc = common_init_rtc,
  171. .init_pci = common_init_pci,
  172. .kill_arch = NULL,
  173. .pci_map_irq = rx164_map_irq,
  174. .pci_swizzle = common_swizzle,
  175. };
  176. ALIAS_MV(rx164)