sys_nautilus.c 6.2 KB

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