sys_nautilus.c 6.7 KB

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