sys_nautilus.c 6.7 KB

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