1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27#include <linux/kernel.h>
28#include <linux/types.h>
29#include <linux/mm.h>
30#include <linux/sched.h>
31#include <linux/pci.h>
32#include <linux/init.h>
33#include <linux/reboot.h>
34#include <linux/bootmem.h>
35#include <linux/bitops.h>
36
37#include <asm/ptrace.h>
38#include <asm/dma.h>
39#include <asm/irq.h>
40#include <asm/mmu_context.h>
41#include <asm/io.h>
42#include <asm/pci.h>
43#include <asm/pgtable.h>
44#include <asm/core_irongate.h>
45#include <asm/hwrpb.h>
46#include <asm/tlbflush.h>
47
48#include "proto.h"
49#include "err_impl.h"
50#include "irq_impl.h"
51#include "pci_impl.h"
52#include "machvec_impl.h"
53
54
55static void __init
56nautilus_init_irq(void)
57{
58 if (alpha_using_srm) {
59 alpha_mv.device_interrupt = srm_device_interrupt;
60 }
61
62 init_i8259a_irqs();
63 common_init_isa_dma();
64}
65
66static int __init
67nautilus_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
68{
69
70
71 u8 irq;
72
73
74
75 if (slot == 1 && pin == 2 &&
76 dev->bus->self && dev->bus->self->device == 0x700f)
77 return 5;
78 pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq);
79 return irq;
80}
81
82void
83nautilus_kill_arch(int mode)
84{
85 struct pci_bus *bus = pci_isa_hose->bus;
86 u32 pmuport;
87 int off;
88
89 switch (mode) {
90 case LINUX_REBOOT_CMD_RESTART:
91 if (! alpha_using_srm) {
92 u8 t8;
93 pci_bus_read_config_byte(bus, 0x38, 0x43, &t8);
94 pci_bus_write_config_byte(bus, 0x38, 0x43, t8 | 0x80);
95 outb(1, 0x92);
96 outb(0, 0x92);
97
98 }
99 break;
100
101 case LINUX_REBOOT_CMD_POWER_OFF:
102
103 off = 0x2000;
104 pci_bus_read_config_dword(bus, 0x88, 0x10, &pmuport);
105 if (!pmuport) {
106
107 off = 0x3400;
108 pci_bus_read_config_dword(bus, 0x88, 0xe0, &pmuport);
109 }
110 pmuport &= 0xfffe;
111 outw(0xffff, pmuport);
112 outw(off, pmuport + 4);
113
114 break;
115 }
116}
117
118
119
120static void
121naut_sys_machine_check(unsigned long vector, unsigned long la_ptr,
122 struct pt_regs *regs)
123{
124 printk("PC %lx RA %lx\n", regs->pc, regs->r26);
125 irongate_pci_clr_err();
126}
127
128
129
130
131void
132nautilus_machine_check(unsigned long vector, unsigned long la_ptr)
133{
134 char *mchk_class;
135
136
137
138
139
140 if (vector == SCB_Q_SYSMCHK
141 && ((IRONGATE0->dramms & 0x300) == 0x300)) {
142 unsigned long nmi_ctl;
143
144
145 nmi_ctl = inb(0x61);
146 nmi_ctl |= 0x0c;
147 outb(nmi_ctl, 0x61);
148 nmi_ctl &= ~0x0c;
149 outb(nmi_ctl, 0x61);
150
151
152 IRONGATE0->stat_cmd = IRONGATE0->stat_cmd & ~0x100;
153 mb();
154 IRONGATE0->stat_cmd;
155
156
157 IRONGATE0->dramms = IRONGATE0->dramms;
158 mb();
159 IRONGATE0->dramms;
160
161 draina();
162 wrmces(0x7);
163 mb();
164 return;
165 }
166
167 if (vector == SCB_Q_SYSERR)
168 mchk_class = "Correctable";
169 else if (vector == SCB_Q_SYSMCHK)
170 mchk_class = "Fatal";
171 else {
172 ev6_machine_check(vector, la_ptr);
173 return;
174 }
175
176 printk(KERN_CRIT "NAUTILUS Machine check 0x%lx "
177 "[%s System Machine Check (NMI)]\n",
178 vector, mchk_class);
179
180 naut_sys_machine_check(vector, la_ptr, get_irq_regs());
181
182
183 draina();
184 wrmces(0x7);
185 mb();
186}
187
188extern void pcibios_claim_one_bus(struct pci_bus *);
189
190static struct resource irongate_io = {
191 .name = "Irongate PCI IO",
192 .flags = IORESOURCE_IO,
193};
194static struct resource irongate_mem = {
195 .name = "Irongate PCI MEM",
196 .flags = IORESOURCE_MEM,
197};
198
199void __init
200nautilus_init_pci(void)
201{
202 struct pci_controller *hose = hose_head;
203 struct pci_bus *bus;
204 struct pci_dev *irongate;
205 unsigned long bus_align, bus_size, pci_mem;
206 unsigned long memtop = max_low_pfn << PAGE_SHIFT;
207
208
209 bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
210 hose->bus = bus;
211 pcibios_claim_one_bus(bus);
212
213 irongate = pci_get_bus_and_slot(0, 0);
214 bus->self = irongate;
215 bus->resource[0] = &irongate_io;
216 bus->resource[1] = &irongate_mem;
217
218 pci_bus_size_bridges(bus);
219
220
221 bus->resource[0]->start = 0;
222 bus->resource[0]->end = 0xffff;
223
224
225
226 bus_align = bus->resource[1]->start;
227 bus_size = bus->resource[1]->end + 1 - bus_align;
228 if (bus_align < 0x1000000UL)
229 bus_align = 0x1000000UL;
230
231 pci_mem = (0x100000000UL - bus_size) & -bus_align;
232
233 bus->resource[1]->start = pci_mem;
234 bus->resource[1]->end = 0xffffffffUL;
235 if (request_resource(&iomem_resource, bus->resource[1]) < 0)
236 printk(KERN_ERR "Failed to request MEM on hose 0\n");
237
238 if (pci_mem < memtop)
239 memtop = pci_mem;
240 if (memtop > alpha_mv.min_mem_address) {
241 free_reserved_area((unsigned long)__va(alpha_mv.min_mem_address),
242 (unsigned long)__va(memtop), 0, NULL);
243 printk("nautilus_init_pci: %ldk freed\n",
244 (memtop - alpha_mv.min_mem_address) >> 10);
245 }
246
247 if ((IRONGATE0->dev_vendor >> 16) > 0x7006)
248 IRONGATE0->pci_mem = pci_mem;
249
250 pci_bus_assign_resources(bus);
251
252
253
254 bus->self = NULL;
255 pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq);
256}
257
258
259
260
261
262struct alpha_machine_vector nautilus_mv __initmv = {
263 .vector_name = "Nautilus",
264 DO_EV6_MMU,
265 DO_DEFAULT_RTC,
266 DO_IRONGATE_IO,
267 .machine_check = nautilus_machine_check,
268 .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
269 .min_io_address = DEFAULT_IO_BASE,
270 .min_mem_address = IRONGATE_DEFAULT_MEM_BASE,
271
272 .nr_irqs = 16,
273 .device_interrupt = isa_device_interrupt,
274
275 .init_arch = irongate_init_arch,
276 .init_irq = nautilus_init_irq,
277 .init_rtc = common_init_rtc,
278 .init_pci = nautilus_init_pci,
279 .kill_arch = nautilus_kill_arch,
280 .pci_map_irq = nautilus_map_irq,
281 .pci_swizzle = common_swizzle,
282};
283ALIAS_MV(nautilus)
284