2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* linux/arch/alpha/kernel/sys_nautilus.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 1995 David A Rusling
|
|
|
|
* Copyright (C) 1998 Richard Henderson
|
|
|
|
* Copyright (C) 1999 Alpha Processor, Inc.,
|
|
|
|
* (David Daniel, Stig Telfer, Soohoon Lee)
|
|
|
|
*
|
|
|
|
* Code supporting NAUTILUS systems.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* NAUTILUS has the following I/O features:
|
|
|
|
*
|
|
|
|
* a) Driven by AMD 751 aka IRONGATE (northbridge):
|
|
|
|
* 4 PCI slots
|
|
|
|
* 1 AGP slot
|
|
|
|
*
|
|
|
|
* b) Driven by ALI M1543C (southbridge)
|
|
|
|
* 2 ISA slots
|
|
|
|
* 2 IDE connectors
|
|
|
|
* 1 dual drive capable FDD controller
|
|
|
|
* 2 serial ports
|
|
|
|
* 1 ECP/EPP/SP parallel port
|
|
|
|
* 2 USB ports
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/reboot.h>
|
|
|
|
#include <linux/bootmem.h>
|
|
|
|
#include <linux/bitops.h>
|
|
|
|
|
|
|
|
#include <asm/ptrace.h>
|
|
|
|
#include <asm/dma.h>
|
|
|
|
#include <asm/irq.h>
|
|
|
|
#include <asm/mmu_context.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/pgtable.h>
|
|
|
|
#include <asm/core_irongate.h>
|
|
|
|
#include <asm/hwrpb.h>
|
|
|
|
#include <asm/tlbflush.h>
|
|
|
|
|
|
|
|
#include "proto.h"
|
|
|
|
#include "err_impl.h"
|
|
|
|
#include "irq_impl.h"
|
|
|
|
#include "pci_impl.h"
|
|
|
|
#include "machvec_impl.h"
|
|
|
|
|
|
|
|
|
|
|
|
static void __init
|
|
|
|
nautilus_init_irq(void)
|
|
|
|
{
|
|
|
|
if (alpha_using_srm) {
|
|
|
|
alpha_mv.device_interrupt = srm_device_interrupt;
|
|
|
|
}
|
|
|
|
|
|
|
|
init_i8259a_irqs();
|
|
|
|
common_init_isa_dma();
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init
|
2011-06-10 22:30:21 +08:00
|
|
|
nautilus_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
/* Preserve the IRQ set up by the console. */
|
|
|
|
|
|
|
|
u8 irq;
|
2007-04-17 13:53:21 +08:00
|
|
|
/* UP1500: AGP INTA is actually routed to IRQ 5, not IRQ 10 as
|
|
|
|
console reports. Check the device id of AGP bridge to distinguish
|
|
|
|
UP1500 from UP1000/1100. Note: 'pin' is 2 due to bridge swizzle. */
|
|
|
|
if (slot == 1 && pin == 2 &&
|
|
|
|
dev->bus->self && dev->bus->self->device == 0x700f)
|
|
|
|
return 5;
|
2005-04-17 06:20:36 +08:00
|
|
|
pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq);
|
|
|
|
return irq;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nautilus_kill_arch(int mode)
|
|
|
|
{
|
|
|
|
struct pci_bus *bus = pci_isa_hose->bus;
|
|
|
|
u32 pmuport;
|
|
|
|
int off;
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case LINUX_REBOOT_CMD_RESTART:
|
|
|
|
if (! alpha_using_srm) {
|
|
|
|
u8 t8;
|
|
|
|
pci_bus_read_config_byte(bus, 0x38, 0x43, &t8);
|
|
|
|
pci_bus_write_config_byte(bus, 0x38, 0x43, t8 | 0x80);
|
|
|
|
outb(1, 0x92);
|
|
|
|
outb(0, 0x92);
|
|
|
|
/* NOTREACHED */
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LINUX_REBOOT_CMD_POWER_OFF:
|
|
|
|
/* Assume M1543C */
|
|
|
|
off = 0x2000; /* SLP_TYPE = 0, SLP_EN = 1 */
|
|
|
|
pci_bus_read_config_dword(bus, 0x88, 0x10, &pmuport);
|
|
|
|
if (!pmuport) {
|
|
|
|
/* M1535D/D+ */
|
|
|
|
off = 0x3400; /* SLP_TYPE = 5, SLP_EN = 1 */
|
|
|
|
pci_bus_read_config_dword(bus, 0x88, 0xe0, &pmuport);
|
|
|
|
}
|
|
|
|
pmuport &= 0xfffe;
|
|
|
|
outw(0xffff, pmuport); /* Clear pending events. */
|
|
|
|
outw(off, pmuport + 4);
|
|
|
|
/* NOTREACHED */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Perform analysis of a machine check that arrived from the system (NMI) */
|
|
|
|
|
|
|
|
static void
|
|
|
|
naut_sys_machine_check(unsigned long vector, unsigned long la_ptr,
|
|
|
|
struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
printk("PC %lx RA %lx\n", regs->pc, regs->r26);
|
|
|
|
irongate_pci_clr_err();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Machine checks can come from two sources - those on the CPU and those
|
|
|
|
in the system. They are analysed separately but all starts here. */
|
|
|
|
|
|
|
|
void
|
2006-10-08 21:44:38 +08:00
|
|
|
nautilus_machine_check(unsigned long vector, unsigned long la_ptr)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
char *mchk_class;
|
|
|
|
|
|
|
|
/* Now for some analysis. Machine checks fall into two classes --
|
|
|
|
those picked up by the system, and those picked up by the CPU.
|
|
|
|
Add to that the two levels of severity - correctable or not. */
|
|
|
|
|
|
|
|
if (vector == SCB_Q_SYSMCHK
|
|
|
|
&& ((IRONGATE0->dramms & 0x300) == 0x300)) {
|
|
|
|
unsigned long nmi_ctl;
|
|
|
|
|
|
|
|
/* Clear ALI NMI */
|
|
|
|
nmi_ctl = inb(0x61);
|
|
|
|
nmi_ctl |= 0x0c;
|
|
|
|
outb(nmi_ctl, 0x61);
|
|
|
|
nmi_ctl &= ~0x0c;
|
|
|
|
outb(nmi_ctl, 0x61);
|
|
|
|
|
|
|
|
/* Write again clears error bits. */
|
|
|
|
IRONGATE0->stat_cmd = IRONGATE0->stat_cmd & ~0x100;
|
|
|
|
mb();
|
|
|
|
IRONGATE0->stat_cmd;
|
|
|
|
|
|
|
|
/* Write again clears error bits. */
|
|
|
|
IRONGATE0->dramms = IRONGATE0->dramms;
|
|
|
|
mb();
|
|
|
|
IRONGATE0->dramms;
|
|
|
|
|
|
|
|
draina();
|
|
|
|
wrmces(0x7);
|
|
|
|
mb();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vector == SCB_Q_SYSERR)
|
|
|
|
mchk_class = "Correctable";
|
|
|
|
else if (vector == SCB_Q_SYSMCHK)
|
|
|
|
mchk_class = "Fatal";
|
|
|
|
else {
|
2006-10-08 21:44:38 +08:00
|
|
|
ev6_machine_check(vector, la_ptr);
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
printk(KERN_CRIT "NAUTILUS Machine check 0x%lx "
|
|
|
|
"[%s System Machine Check (NMI)]\n",
|
|
|
|
vector, mchk_class);
|
|
|
|
|
2006-10-08 21:44:38 +08:00
|
|
|
naut_sys_machine_check(vector, la_ptr, get_irq_regs());
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Tell the PALcode to clear the machine check */
|
|
|
|
draina();
|
|
|
|
wrmces(0x7);
|
|
|
|
mb();
|
|
|
|
}
|
|
|
|
|
2008-04-24 20:51:55 +08:00
|
|
|
extern void pcibios_claim_one_bus(struct pci_bus *);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-04-07 17:36:09 +08:00
|
|
|
static struct resource irongate_io = {
|
|
|
|
.name = "Irongate PCI IO",
|
|
|
|
.flags = IORESOURCE_IO,
|
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
static struct resource irongate_mem = {
|
|
|
|
.name = "Irongate PCI MEM",
|
|
|
|
.flags = IORESOURCE_MEM,
|
|
|
|
};
|
2017-08-01 00:37:51 +08:00
|
|
|
static struct resource busn_resource = {
|
|
|
|
.name = "PCI busn",
|
|
|
|
.start = 0,
|
|
|
|
.end = 255,
|
|
|
|
.flags = IORESOURCE_BUS,
|
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
void __init
|
|
|
|
nautilus_init_pci(void)
|
|
|
|
{
|
|
|
|
struct pci_controller *hose = hose_head;
|
2017-08-01 00:37:51 +08:00
|
|
|
struct pci_host_bridge *bridge;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct pci_bus *bus;
|
|
|
|
struct pci_dev *irongate;
|
|
|
|
unsigned long bus_align, bus_size, pci_mem;
|
|
|
|
unsigned long memtop = max_low_pfn << PAGE_SHIFT;
|
2017-08-01 00:37:51 +08:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
bridge = pci_alloc_host_bridge(0);
|
|
|
|
if (!bridge)
|
|
|
|
return;
|
|
|
|
|
|
|
|
pci_add_resource(&bridge->windows, &ioport_resource);
|
|
|
|
pci_add_resource(&bridge->windows, &iomem_resource);
|
|
|
|
pci_add_resource(&bridge->windows, &busn_resource);
|
|
|
|
bridge->dev.parent = NULL;
|
|
|
|
bridge->sysdata = hose;
|
|
|
|
bridge->busnr = 0;
|
|
|
|
bridge->ops = alpha_mv.pci_ops;
|
|
|
|
bridge->swizzle_irq = alpha_mv.pci_swizzle;
|
|
|
|
bridge->map_irq = alpha_mv.pci_map_irq;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Scan our single hose. */
|
2017-08-01 00:37:51 +08:00
|
|
|
ret = pci_scan_root_bus_bridge(bridge);
|
|
|
|
if (ret) {
|
|
|
|
pci_free_host_bridge(bridge);
|
2015-03-09 10:33:58 +08:00
|
|
|
return;
|
2017-08-01 00:37:51 +08:00
|
|
|
}
|
2015-03-09 10:33:58 +08:00
|
|
|
|
2017-08-01 00:37:51 +08:00
|
|
|
bus = hose->bus = bridge->bus;
|
2008-04-24 20:51:55 +08:00
|
|
|
pcibios_claim_one_bus(bus);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-12-07 12:33:59 +08:00
|
|
|
irongate = pci_get_bus_and_slot(0, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
bus->self = irongate;
|
2013-04-07 17:36:09 +08:00
|
|
|
bus->resource[0] = &irongate_io;
|
2005-04-17 06:20:36 +08:00
|
|
|
bus->resource[1] = &irongate_mem;
|
|
|
|
|
|
|
|
pci_bus_size_bridges(bus);
|
|
|
|
|
|
|
|
/* IO port range. */
|
|
|
|
bus->resource[0]->start = 0;
|
|
|
|
bus->resource[0]->end = 0xffff;
|
|
|
|
|
|
|
|
/* Set up PCI memory range - limit is hardwired to 0xffffffff,
|
|
|
|
base must be at aligned to 16Mb. */
|
|
|
|
bus_align = bus->resource[1]->start;
|
|
|
|
bus_size = bus->resource[1]->end + 1 - bus_align;
|
|
|
|
if (bus_align < 0x1000000UL)
|
|
|
|
bus_align = 0x1000000UL;
|
|
|
|
|
|
|
|
pci_mem = (0x100000000UL - bus_size) & -bus_align;
|
|
|
|
|
|
|
|
bus->resource[1]->start = pci_mem;
|
|
|
|
bus->resource[1]->end = 0xffffffffUL;
|
|
|
|
if (request_resource(&iomem_resource, bus->resource[1]) < 0)
|
|
|
|
printk(KERN_ERR "Failed to request MEM on hose 0\n");
|
|
|
|
|
|
|
|
if (pci_mem < memtop)
|
|
|
|
memtop = pci_mem;
|
|
|
|
if (memtop > alpha_mv.min_mem_address) {
|
mm: change signature of free_reserved_area() to fix building warnings
Change signature of free_reserved_area() according to Russell King's
suggestion to fix following build warnings:
arch/arm/mm/init.c: In function 'mem_init':
arch/arm/mm/init.c:603:2: warning: passing argument 1 of 'free_reserved_area' makes integer from pointer without a cast [enabled by default]
free_reserved_area(__va(PHYS_PFN_OFFSET), swapper_pg_dir, 0, NULL);
^
In file included from include/linux/mman.h:4:0,
from arch/arm/mm/init.c:15:
include/linux/mm.h:1301:22: note: expected 'long unsigned int' but argument is of type 'void *'
extern unsigned long free_reserved_area(unsigned long start, unsigned long end,
mm/page_alloc.c: In function 'free_reserved_area':
>> mm/page_alloc.c:5134:3: warning: passing argument 1 of 'virt_to_phys' makes pointer from integer without a cast [enabled by default]
In file included from arch/mips/include/asm/page.h:49:0,
from include/linux/mmzone.h:20,
from include/linux/gfp.h:4,
from include/linux/mm.h:8,
from mm/page_alloc.c:18:
arch/mips/include/asm/io.h:119:29: note: expected 'const volatile void *' but argument is of type 'long unsigned int'
mm/page_alloc.c: In function 'free_area_init_nodes':
mm/page_alloc.c:5030:34: warning: array subscript is below array bounds [-Warray-bounds]
Also address some minor code review comments.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Reported-by: Arnd Bergmann <arnd@arndb.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: <sworddragon2@aol.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Jianguo Wu <wujianguo@huawei.com>
Cc: Joonsoo Kim <js1304@gmail.com>
Cc: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Michel Lespinasse <walken@google.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Tang Chen <tangchen@cn.fujitsu.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Wen Congyang <wency@cn.fujitsu.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-07-04 06:02:48 +08:00
|
|
|
free_reserved_area(__va(alpha_mv.min_mem_address),
|
2013-07-04 06:02:51 +08:00
|
|
|
__va(memtop), -1, NULL);
|
2005-04-17 06:20:36 +08:00
|
|
|
printk("nautilus_init_pci: %ldk freed\n",
|
|
|
|
(memtop - alpha_mv.min_mem_address) >> 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((IRONGATE0->dev_vendor >> 16) > 0x7006) /* Albacore? */
|
|
|
|
IRONGATE0->pci_mem = pci_mem;
|
|
|
|
|
|
|
|
pci_bus_assign_resources(bus);
|
2009-01-16 05:51:18 +08:00
|
|
|
|
|
|
|
/* pci_common_swizzle() relies on bus->self being NULL
|
|
|
|
for the root bus, so just clear it. */
|
|
|
|
bus->self = NULL;
|
2015-03-09 10:33:58 +08:00
|
|
|
pci_bus_add_devices(bus);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The System Vectors
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct alpha_machine_vector nautilus_mv __initmv = {
|
|
|
|
.vector_name = "Nautilus",
|
|
|
|
DO_EV6_MMU,
|
|
|
|
DO_DEFAULT_RTC,
|
|
|
|
DO_IRONGATE_IO,
|
|
|
|
.machine_check = nautilus_machine_check,
|
|
|
|
.max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
|
|
|
|
.min_io_address = DEFAULT_IO_BASE,
|
|
|
|
.min_mem_address = IRONGATE_DEFAULT_MEM_BASE,
|
|
|
|
|
|
|
|
.nr_irqs = 16,
|
|
|
|
.device_interrupt = isa_device_interrupt,
|
|
|
|
|
|
|
|
.init_arch = irongate_init_arch,
|
|
|
|
.init_irq = nautilus_init_irq,
|
|
|
|
.init_rtc = common_init_rtc,
|
|
|
|
.init_pci = nautilus_init_pci,
|
|
|
|
.kill_arch = nautilus_kill_arch,
|
|
|
|
.pci_map_irq = nautilus_map_irq,
|
|
|
|
.pci_swizzle = common_swizzle,
|
|
|
|
};
|
|
|
|
ALIAS_MV(nautilus)
|