sys_ruffian.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. /*
  2. * linux/arch/alpha/kernel/sys_ruffian.c
  3. *
  4. * Copyright (C) 1995 David A Rusling
  5. * Copyright (C) 1996 Jay A Estabrook
  6. * Copyright (C) 1998, 1999, 2000 Richard Henderson
  7. *
  8. * Code supporting the RUFFIAN.
  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/ioport.h>
  16. #include <linux/timex.h>
  17. #include <linux/init.h>
  18. #include <asm/ptrace.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_cia.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. static void __init
  31. ruffian_init_irq(void)
  32. {
  33. /* Invert 6&7 for i82371 */
  34. *(vulp)PYXIS_INT_HILO = 0x000000c0UL; mb();
  35. *(vulp)PYXIS_INT_CNFG = 0x00002064UL; mb(); /* all clear */
  36. outb(0x11,0xA0);
  37. outb(0x08,0xA1);
  38. outb(0x02,0xA1);
  39. outb(0x01,0xA1);
  40. outb(0xFF,0xA1);
  41. outb(0x11,0x20);
  42. outb(0x00,0x21);
  43. outb(0x04,0x21);
  44. outb(0x01,0x21);
  45. outb(0xFF,0x21);
  46. /* Finish writing the 82C59A PIC Operation Control Words */
  47. outb(0x20,0xA0);
  48. outb(0x20,0x20);
  49. init_i8259a_irqs();
  50. /* Not interested in the bogus interrupts (0,3,6),
  51. NMI (1), HALT (2), flash (5), or 21142 (8). */
  52. init_pyxis_irqs(0x16f0000);
  53. common_init_isa_dma();
  54. }
  55. #define RUFFIAN_LATCH DIV_ROUND_CLOSEST(PIT_TICK_RATE, HZ)
  56. static void __init
  57. ruffian_init_rtc(void)
  58. {
  59. /* Ruffian does not have the RTC connected to the CPU timer
  60. interrupt. Instead, it uses the PIT connected to IRQ 0. */
  61. /* Setup interval timer. */
  62. outb(0x34, 0x43); /* binary, mode 2, LSB/MSB, ch 0 */
  63. outb(RUFFIAN_LATCH & 0xff, 0x40); /* LSB */
  64. outb(RUFFIAN_LATCH >> 8, 0x40); /* MSB */
  65. outb(0xb6, 0x43); /* pit counter 2: speaker */
  66. outb(0x31, 0x42);
  67. outb(0x13, 0x42);
  68. setup_irq(0, &timer_irqaction);
  69. }
  70. static void
  71. ruffian_kill_arch (int mode)
  72. {
  73. cia_kill_arch(mode);
  74. #if 0
  75. /* This only causes re-entry to ARCSBIOS */
  76. /* Perhaps this works for other PYXIS as well? */
  77. *(vuip) PYXIS_RESET = 0x0000dead;
  78. mb();
  79. #endif
  80. }
  81. /*
  82. * Interrupt routing:
  83. *
  84. * Primary bus
  85. * IdSel INTA INTB INTC INTD
  86. * 21052 13 - - - -
  87. * SIO 14 23 - - -
  88. * 21143 15 44 - - -
  89. * Slot 0 17 43 42 41 40
  90. *
  91. * Secondary bus
  92. * IdSel INTA INTB INTC INTD
  93. * Slot 0 8 (18) 19 18 17 16
  94. * Slot 1 9 (19) 31 30 29 28
  95. * Slot 2 10 (20) 27 26 25 24
  96. * Slot 3 11 (21) 39 38 37 36
  97. * Slot 4 12 (22) 35 34 33 32
  98. * 53c875 13 (23) 20 - - -
  99. *
  100. */
  101. static int __init
  102. ruffian_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  103. {
  104. static char irq_tab[11][5] __initdata = {
  105. /*INT INTA INTB INTC INTD */
  106. {-1, -1, -1, -1, -1}, /* IdSel 13, 21052 */
  107. {-1, -1, -1, -1, -1}, /* IdSel 14, SIO */
  108. {44, 44, 44, 44, 44}, /* IdSel 15, 21143 */
  109. {-1, -1, -1, -1, -1}, /* IdSel 16, none */
  110. {43, 43, 42, 41, 40}, /* IdSel 17, 64-bit slot */
  111. /* the next 6 are actually on PCI bus 1, across the bridge */
  112. {19, 19, 18, 17, 16}, /* IdSel 8, slot 0 */
  113. {31, 31, 30, 29, 28}, /* IdSel 9, slot 1 */
  114. {27, 27, 26, 25, 24}, /* IdSel 10, slot 2 */
  115. {39, 39, 38, 37, 36}, /* IdSel 11, slot 3 */
  116. {35, 35, 34, 33, 32}, /* IdSel 12, slot 4 */
  117. {20, 20, 20, 20, 20}, /* IdSel 13, 53c875 */
  118. };
  119. const long min_idsel = 13, max_idsel = 23, irqs_per_slot = 5;
  120. return COMMON_TABLE_LOOKUP;
  121. }
  122. static u8 __init
  123. ruffian_swizzle(struct pci_dev *dev, u8 *pinp)
  124. {
  125. int slot, pin = *pinp;
  126. if (dev->bus->number == 0) {
  127. slot = PCI_SLOT(dev->devfn);
  128. }
  129. /* Check for the built-in bridge. */
  130. else if (PCI_SLOT(dev->bus->self->devfn) == 13) {
  131. slot = PCI_SLOT(dev->devfn) + 10;
  132. }
  133. else
  134. {
  135. /* Must be a card-based bridge. */
  136. do {
  137. if (PCI_SLOT(dev->bus->self->devfn) == 13) {
  138. slot = PCI_SLOT(dev->devfn) + 10;
  139. break;
  140. }
  141. pin = pci_swizzle_interrupt_pin(dev, pin);
  142. /* Move up the chain of bridges. */
  143. dev = dev->bus->self;
  144. /* Slot of the next bridge. */
  145. slot = PCI_SLOT(dev->devfn);
  146. } while (dev->bus->self);
  147. }
  148. *pinp = pin;
  149. return slot;
  150. }
  151. #ifdef BUILDING_FOR_MILO
  152. /*
  153. * The DeskStation Ruffian motherboard firmware does not place
  154. * the memory size in the PALimpure area. Therefore, we use
  155. * the Bank Configuration Registers in PYXIS to obtain the size.
  156. */
  157. static unsigned long __init
  158. ruffian_get_bank_size(unsigned long offset)
  159. {
  160. unsigned long bank_addr, bank, ret = 0;
  161. /* Valid offsets are: 0x800, 0x840 and 0x880
  162. since Ruffian only uses three banks. */
  163. bank_addr = (unsigned long)PYXIS_MCR + offset;
  164. bank = *(vulp)bank_addr;
  165. /* Check BANK_ENABLE */
  166. if (bank & 0x01) {
  167. static unsigned long size[] __initdata = {
  168. 0x40000000UL, /* 0x00, 1G */
  169. 0x20000000UL, /* 0x02, 512M */
  170. 0x10000000UL, /* 0x04, 256M */
  171. 0x08000000UL, /* 0x06, 128M */
  172. 0x04000000UL, /* 0x08, 64M */
  173. 0x02000000UL, /* 0x0a, 32M */
  174. 0x01000000UL, /* 0x0c, 16M */
  175. 0x00800000UL, /* 0x0e, 8M */
  176. 0x80000000UL, /* 0x10, 2G */
  177. };
  178. bank = (bank & 0x1e) >> 1;
  179. if (bank < ARRAY_SIZE(size))
  180. ret = size[bank];
  181. }
  182. return ret;
  183. }
  184. #endif /* BUILDING_FOR_MILO */
  185. /*
  186. * The System Vector
  187. */
  188. struct alpha_machine_vector ruffian_mv __initmv = {
  189. .vector_name = "Ruffian",
  190. DO_EV5_MMU,
  191. DO_DEFAULT_RTC,
  192. DO_PYXIS_IO,
  193. .machine_check = cia_machine_check,
  194. .max_isa_dma_address = ALPHA_RUFFIAN_MAX_ISA_DMA_ADDRESS,
  195. .min_io_address = DEFAULT_IO_BASE,
  196. .min_mem_address = DEFAULT_MEM_BASE,
  197. .pci_dac_offset = PYXIS_DAC_OFFSET,
  198. .nr_irqs = 48,
  199. .device_interrupt = pyxis_device_interrupt,
  200. .init_arch = pyxis_init_arch,
  201. .init_irq = ruffian_init_irq,
  202. .init_rtc = ruffian_init_rtc,
  203. .init_pci = cia_init_pci,
  204. .kill_arch = ruffian_kill_arch,
  205. .pci_map_irq = ruffian_map_irq,
  206. .pci_swizzle = ruffian_swizzle,
  207. };
  208. ALIAS_MV(ruffian)