sys_nautilus.c 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. /*
  2. * linux/arch/alpha/kernel/sys_nautilus.c
  3. *
  4. * Copyright (C) 1995 David A Rusling
  5. * Copyright (C) 1998 Richard Henderson
  6. * Copyright (C) 1999 Alpha Processor, Inc.,
  7. * (David Daniel, Stig Telfer, Soohoon Lee)
  8. *
  9. * Code supporting NAUTILUS systems.
  10. *
  11. *
  12. * NAUTILUS has the following I/O features:
  13. *
  14. * a) Driven by AMD 751 aka IRONGATE (northbridge):
  15. * 4 PCI slots
  16. * 1 AGP slot
  17. *
  18. * b) Driven by ALI M1543C (southbridge)
  19. * 2 ISA slots
  20. * 2 IDE connectors
  21. * 1 dual drive capable FDD controller
  22. * 2 serial ports
  23. * 1 ECP/EPP/SP parallel port
  24. * 2 USB ports
  25. */
  26. #include <linux/kernel.h>
  27. #include <linux/types.h>
  28. #include <linux/mm.h>
  29. #include <linux/sched.h>
  30. #include <linux/pci.h>
  31. #include <linux/init.h>
  32. #include <linux/reboot.h>
  33. #include <linux/bootmem.h>
  34. #include <linux/bitops.h>
  35. #include <asm/ptrace.h>
  36. #include <asm/dma.h>
  37. #include <asm/irq.h>
  38. #include <asm/mmu_context.h>
  39. #include <asm/io.h>
  40. #include <asm/pgtable.h>
  41. #include <asm/core_irongate.h>
  42. #include <asm/hwrpb.h>
  43. #include <asm/tlbflush.h>
  44. #include "proto.h"
  45. #include "err_impl.h"
  46. #include "irq_impl.h"
  47. #include "pci_impl.h"
  48. #include "machvec_impl.h"
  49. static void __init
  50. nautilus_init_irq(void)
  51. {
  52. if (alpha_using_srm) {
  53. alpha_mv.device_interrupt = srm_device_interrupt;
  54. }
  55. init_i8259a_irqs();
  56. common_init_isa_dma();
  57. }
  58. static int __init
  59. nautilus_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  60. {
  61. /* Preserve the IRQ set up by the console. */
  62. u8 irq;
  63. /* UP1500: AGP INTA is actually routed to IRQ 5, not IRQ 10 as
  64. console reports. Check the device id of AGP bridge to distinguish
  65. UP1500 from UP1000/1100. Note: 'pin' is 2 due to bridge swizzle. */
  66. if (slot == 1 && pin == 2 &&
  67. dev->bus->self && dev->bus->self->device == 0x700f)
  68. return 5;
  69. pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq);
  70. return irq;
  71. }
  72. void
  73. nautilus_kill_arch(int mode)
  74. {
  75. struct pci_bus *bus = pci_isa_hose->bus;
  76. u32 pmuport;
  77. int off;
  78. switch (mode) {
  79. case LINUX_REBOOT_CMD_RESTART:
  80. if (! alpha_using_srm) {
  81. u8 t8;
  82. pci_bus_read_config_byte(bus, 0x38, 0x43, &t8);
  83. pci_bus_write_config_byte(bus, 0x38, 0x43, t8 | 0x80);
  84. outb(1, 0x92);
  85. outb(0, 0x92);
  86. /* NOTREACHED */
  87. }
  88. break;
  89. case LINUX_REBOOT_CMD_POWER_OFF:
  90. /* Assume M1543C */
  91. off = 0x2000; /* SLP_TYPE = 0, SLP_EN = 1 */
  92. pci_bus_read_config_dword(bus, 0x88, 0x10, &pmuport);
  93. if (!pmuport) {
  94. /* M1535D/D+ */
  95. off = 0x3400; /* SLP_TYPE = 5, SLP_EN = 1 */
  96. pci_bus_read_config_dword(bus, 0x88, 0xe0, &pmuport);
  97. }
  98. pmuport &= 0xfffe;
  99. outw(0xffff, pmuport); /* Clear pending events. */
  100. outw(off, pmuport + 4);
  101. /* NOTREACHED */
  102. break;
  103. }
  104. }
  105. /* Perform analysis of a machine check that arrived from the system (NMI) */
  106. static void
  107. naut_sys_machine_check(unsigned long vector, unsigned long la_ptr,
  108. struct pt_regs *regs)
  109. {
  110. printk("PC %lx RA %lx\n", regs->pc, regs->r26);
  111. irongate_pci_clr_err();
  112. }
  113. /* Machine checks can come from two sources - those on the CPU and those
  114. in the system. They are analysed separately but all starts here. */
  115. void
  116. nautilus_machine_check(unsigned long vector, unsigned long la_ptr)
  117. {
  118. char *mchk_class;
  119. /* Now for some analysis. Machine checks fall into two classes --
  120. those picked up by the system, and those picked up by the CPU.
  121. Add to that the two levels of severity - correctable or not. */
  122. if (vector == SCB_Q_SYSMCHK
  123. && ((IRONGATE0->dramms & 0x300) == 0x300)) {
  124. unsigned long nmi_ctl;
  125. /* Clear ALI NMI */
  126. nmi_ctl = inb(0x61);
  127. nmi_ctl |= 0x0c;
  128. outb(nmi_ctl, 0x61);
  129. nmi_ctl &= ~0x0c;
  130. outb(nmi_ctl, 0x61);
  131. /* Write again clears error bits. */
  132. IRONGATE0->stat_cmd = IRONGATE0->stat_cmd & ~0x100;
  133. mb();
  134. IRONGATE0->stat_cmd;
  135. /* Write again clears error bits. */
  136. IRONGATE0->dramms = IRONGATE0->dramms;
  137. mb();
  138. IRONGATE0->dramms;
  139. draina();
  140. wrmces(0x7);
  141. mb();
  142. return;
  143. }
  144. if (vector == SCB_Q_SYSERR)
  145. mchk_class = "Correctable";
  146. else if (vector == SCB_Q_SYSMCHK)
  147. mchk_class = "Fatal";
  148. else {
  149. ev6_machine_check(vector, la_ptr);
  150. return;
  151. }
  152. printk(KERN_CRIT "NAUTILUS Machine check 0x%lx "
  153. "[%s System Machine Check (NMI)]\n",
  154. vector, mchk_class);
  155. naut_sys_machine_check(vector, la_ptr, get_irq_regs());
  156. /* Tell the PALcode to clear the machine check */
  157. draina();
  158. wrmces(0x7);
  159. mb();
  160. }
  161. extern void pcibios_claim_one_bus(struct pci_bus *);
  162. static struct resource irongate_io = {
  163. .name = "Irongate PCI IO",
  164. .flags = IORESOURCE_IO,
  165. };
  166. static struct resource irongate_mem = {
  167. .name = "Irongate PCI MEM",
  168. .flags = IORESOURCE_MEM,
  169. };
  170. void __init
  171. nautilus_init_pci(void)
  172. {
  173. struct pci_controller *hose = hose_head;
  174. struct pci_bus *bus;
  175. struct pci_dev *irongate;
  176. unsigned long bus_align, bus_size, pci_mem;
  177. unsigned long memtop = max_low_pfn << PAGE_SHIFT;
  178. /* Scan our single hose. */
  179. bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
  180. if (!bus)
  181. return;
  182. hose->bus = bus;
  183. pcibios_claim_one_bus(bus);
  184. irongate = pci_get_bus_and_slot(0, 0);
  185. bus->self = irongate;
  186. bus->resource[0] = &irongate_io;
  187. bus->resource[1] = &irongate_mem;
  188. pci_bus_size_bridges(bus);
  189. /* IO port range. */
  190. bus->resource[0]->start = 0;
  191. bus->resource[0]->end = 0xffff;
  192. /* Set up PCI memory range - limit is hardwired to 0xffffffff,
  193. base must be at aligned to 16Mb. */
  194. bus_align = bus->resource[1]->start;
  195. bus_size = bus->resource[1]->end + 1 - bus_align;
  196. if (bus_align < 0x1000000UL)
  197. bus_align = 0x1000000UL;
  198. pci_mem = (0x100000000UL - bus_size) & -bus_align;
  199. bus->resource[1]->start = pci_mem;
  200. bus->resource[1]->end = 0xffffffffUL;
  201. if (request_resource(&iomem_resource, bus->resource[1]) < 0)
  202. printk(KERN_ERR "Failed to request MEM on hose 0\n");
  203. if (pci_mem < memtop)
  204. memtop = pci_mem;
  205. if (memtop > alpha_mv.min_mem_address) {
  206. free_reserved_area(__va(alpha_mv.min_mem_address),
  207. __va(memtop), -1, NULL);
  208. printk("nautilus_init_pci: %ldk freed\n",
  209. (memtop - alpha_mv.min_mem_address) >> 10);
  210. }
  211. if ((IRONGATE0->dev_vendor >> 16) > 0x7006) /* Albacore? */
  212. IRONGATE0->pci_mem = pci_mem;
  213. pci_bus_assign_resources(bus);
  214. /* pci_common_swizzle() relies on bus->self being NULL
  215. for the root bus, so just clear it. */
  216. bus->self = NULL;
  217. pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq);
  218. pci_bus_add_devices(bus);
  219. }
  220. /*
  221. * The System Vectors
  222. */
  223. struct alpha_machine_vector nautilus_mv __initmv = {
  224. .vector_name = "Nautilus",
  225. DO_EV6_MMU,
  226. DO_DEFAULT_RTC,
  227. DO_IRONGATE_IO,
  228. .machine_check = nautilus_machine_check,
  229. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  230. .min_io_address = DEFAULT_IO_BASE,
  231. .min_mem_address = IRONGATE_DEFAULT_MEM_BASE,
  232. .nr_irqs = 16,
  233. .device_interrupt = isa_device_interrupt,
  234. .init_arch = irongate_init_arch,
  235. .init_irq = nautilus_init_irq,
  236. .init_rtc = common_init_rtc,
  237. .init_pci = nautilus_init_pci,
  238. .kill_arch = nautilus_kill_arch,
  239. .pci_map_irq = nautilus_map_irq,
  240. .pci_swizzle = common_swizzle,
  241. };
  242. ALIAS_MV(nautilus)