1 // SPDX-License-Identifier: GPL-2.0
3 * linux/arch/alpha/kernel/sys_nautilus.c
5 * Copyright (C) 1995 David A Rusling
6 * Copyright (C) 1998 Richard Henderson
7 * Copyright (C) 1999 Alpha Processor, Inc.,
8 * (David Daniel, Stig Telfer, Soohoon Lee)
10 * Code supporting NAUTILUS systems.
13 * NAUTILUS has the following I/O features:
15 * a) Driven by AMD 751 aka IRONGATE (northbridge):
19 * b) Driven by ALI M1543C (southbridge)
22 * 1 dual drive capable FDD controller
24 * 1 ECP/EPP/SP parallel port
28 #include <linux/kernel.h>
29 #include <linux/types.h>
31 #include <linux/sched.h>
32 #include <linux/pci.h>
33 #include <linux/init.h>
34 #include <linux/reboot.h>
35 #include <linux/memblock.h>
36 #include <linux/bitops.h>
38 #include <asm/ptrace.h>
41 #include <asm/mmu_context.h>
43 #include <asm/core_irongate.h>
44 #include <asm/hwrpb.h>
45 #include <asm/tlbflush.h>
51 #include "machvec_impl.h"
55 nautilus_init_irq(void)
57 if (alpha_using_srm
) {
58 alpha_mv
.device_interrupt
= srm_device_interrupt
;
62 common_init_isa_dma();
66 nautilus_map_irq(const struct pci_dev
*dev
, u8 slot
, u8 pin
)
68 /* Preserve the IRQ set up by the console. */
71 /* UP1500: AGP INTA is actually routed to IRQ 5, not IRQ 10 as
72 console reports. Check the device id of AGP bridge to distinguish
73 UP1500 from UP1000/1100. Note: 'pin' is 2 due to bridge swizzle. */
74 if (slot
== 1 && pin
== 2 &&
75 dev
->bus
->self
&& dev
->bus
->self
->device
== 0x700f)
77 pci_read_config_byte(dev
, PCI_INTERRUPT_LINE
, &irq
);
82 nautilus_kill_arch(int mode
)
84 struct pci_bus
*bus
= pci_isa_hose
->bus
;
89 case LINUX_REBOOT_CMD_RESTART
:
90 if (! alpha_using_srm
) {
92 pci_bus_read_config_byte(bus
, 0x38, 0x43, &t8
);
93 pci_bus_write_config_byte(bus
, 0x38, 0x43, t8
| 0x80);
100 case LINUX_REBOOT_CMD_POWER_OFF
:
102 off
= 0x2000; /* SLP_TYPE = 0, SLP_EN = 1 */
103 pci_bus_read_config_dword(bus
, 0x88, 0x10, &pmuport
);
106 off
= 0x3400; /* SLP_TYPE = 5, SLP_EN = 1 */
107 pci_bus_read_config_dword(bus
, 0x88, 0xe0, &pmuport
);
110 outw(0xffff, pmuport
); /* Clear pending events. */
111 outw(off
, pmuport
+ 4);
117 /* Perform analysis of a machine check that arrived from the system (NMI) */
120 naut_sys_machine_check(unsigned long vector
, unsigned long la_ptr
,
121 struct pt_regs
*regs
)
123 printk("PC %lx RA %lx\n", regs
->pc
, regs
->r26
);
124 irongate_pci_clr_err();
127 /* Machine checks can come from two sources - those on the CPU and those
128 in the system. They are analysed separately but all starts here. */
131 nautilus_machine_check(unsigned long vector
, unsigned long la_ptr
)
135 /* Now for some analysis. Machine checks fall into two classes --
136 those picked up by the system, and those picked up by the CPU.
137 Add to that the two levels of severity - correctable or not. */
139 if (vector
== SCB_Q_SYSMCHK
140 && ((IRONGATE0
->dramms
& 0x300) == 0x300)) {
141 unsigned long nmi_ctl
;
150 /* Write again clears error bits. */
151 IRONGATE0
->stat_cmd
= IRONGATE0
->stat_cmd
& ~0x100;
155 /* Write again clears error bits. */
156 IRONGATE0
->dramms
= IRONGATE0
->dramms
;
166 if (vector
== SCB_Q_SYSERR
)
167 mchk_class
= "Correctable";
168 else if (vector
== SCB_Q_SYSMCHK
)
169 mchk_class
= "Fatal";
171 ev6_machine_check(vector
, la_ptr
);
175 printk(KERN_CRIT
"NAUTILUS Machine check 0x%lx "
176 "[%s System Machine Check (NMI)]\n",
179 naut_sys_machine_check(vector
, la_ptr
, get_irq_regs());
181 /* Tell the PALcode to clear the machine check */
187 extern void pcibios_claim_one_bus(struct pci_bus
*);
189 static struct resource irongate_mem
= {
190 .name
= "Irongate PCI MEM",
191 .flags
= IORESOURCE_MEM
,
193 static struct resource busn_resource
= {
197 .flags
= IORESOURCE_BUS
,
201 nautilus_init_pci(void)
203 struct pci_controller
*hose
= hose_head
;
204 struct pci_host_bridge
*bridge
;
206 unsigned long bus_align
, bus_size
, pci_mem
;
207 unsigned long memtop
= max_low_pfn
<< PAGE_SHIFT
;
209 bridge
= pci_alloc_host_bridge(0);
213 /* Use default IO. */
214 pci_add_resource(&bridge
->windows
, &ioport_resource
);
215 /* Irongate PCI memory aperture, calculate requred size before
217 pci_add_resource(&bridge
->windows
, &irongate_mem
);
219 pci_add_resource(&bridge
->windows
, &busn_resource
);
220 bridge
->dev
.parent
= NULL
;
221 bridge
->sysdata
= hose
;
223 bridge
->ops
= alpha_mv
.pci_ops
;
224 bridge
->swizzle_irq
= alpha_mv
.pci_swizzle
;
225 bridge
->map_irq
= alpha_mv
.pci_map_irq
;
226 bridge
->size_windows
= 1;
228 /* Scan our single hose. */
229 if (pci_scan_root_bus_bridge(bridge
)) {
230 pci_free_host_bridge(bridge
);
233 bus
= hose
->bus
= bridge
->bus
;
234 pcibios_claim_one_bus(bus
);
236 pci_bus_size_bridges(bus
);
238 /* Now we've got the size and alignment of PCI memory resources
239 stored in irongate_mem. Set up the PCI memory range: limit is
240 hardwired to 0xffffffff, base must be aligned to 16Mb. */
241 bus_align
= irongate_mem
.start
;
242 bus_size
= irongate_mem
.end
+ 1 - bus_align
;
243 if (bus_align
< 0x1000000UL
)
244 bus_align
= 0x1000000UL
;
246 pci_mem
= (0x100000000UL
- bus_size
) & -bus_align
;
247 irongate_mem
.start
= pci_mem
;
248 irongate_mem
.end
= 0xffffffffUL
;
250 /* Register our newly calculated PCI memory window in the resource
252 if (request_resource(&iomem_resource
, &irongate_mem
) < 0)
253 printk(KERN_ERR
"Failed to request MEM on hose 0\n");
255 printk(KERN_INFO
"Irongate pci_mem %pR\n", &irongate_mem
);
257 if (pci_mem
< memtop
)
259 if (memtop
> alpha_mv
.min_mem_address
) {
260 free_reserved_area(__va(alpha_mv
.min_mem_address
),
261 __va(memtop
), -1, NULL
);
262 printk(KERN_INFO
"nautilus_init_pci: %ldk freed\n",
263 (memtop
- alpha_mv
.min_mem_address
) >> 10);
265 if ((IRONGATE0
->dev_vendor
>> 16) > 0x7006) /* Albacore? */
266 IRONGATE0
->pci_mem
= pci_mem
;
268 pci_bus_assign_resources(bus
);
269 pci_bus_add_devices(bus
);
276 struct alpha_machine_vector nautilus_mv __initmv
= {
277 .vector_name
= "Nautilus",
281 .machine_check
= nautilus_machine_check
,
282 .max_isa_dma_address
= ALPHA_MAX_ISA_DMA_ADDRESS
,
283 .min_io_address
= DEFAULT_IO_BASE
,
284 .min_mem_address
= IRONGATE_DEFAULT_MEM_BASE
,
287 .device_interrupt
= isa_device_interrupt
,
289 .init_arch
= irongate_init_arch
,
290 .init_irq
= nautilus_init_irq
,
291 .init_rtc
= common_init_rtc
,
292 .init_pci
= nautilus_init_pci
,
293 .kill_arch
= nautilus_kill_arch
,
294 .pci_map_irq
= nautilus_map_irq
,
295 .pci_swizzle
= common_swizzle
,