sys_ruffian.c 5.8 KB

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