sys_rx164.c 5.0 KB

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