xref: /linux/arch/mips/sgi-ip32/crime.c (revision 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2)
1*1da177e4SLinus Torvalds /*
2*1da177e4SLinus Torvalds  * This file is subject to the terms and conditions of the GNU General Public
3*1da177e4SLinus Torvalds  * License.  See the file "COPYING" in the main directory of this archive
4*1da177e4SLinus Torvalds  * for more details.
5*1da177e4SLinus Torvalds  *
6*1da177e4SLinus Torvalds  * Copyright (C) 2001, 2003 Keith M Wesolowski
7*1da177e4SLinus Torvalds  * Copyright (C) 2005 Ilya A. Volynets <ilya@total-knowledge.com>
8*1da177e4SLinus Torvalds  */
9*1da177e4SLinus Torvalds #include <linux/types.h>
10*1da177e4SLinus Torvalds #include <linux/init.h>
11*1da177e4SLinus Torvalds #include <linux/kernel.h>
12*1da177e4SLinus Torvalds #include <linux/interrupt.h>
13*1da177e4SLinus Torvalds #include <asm/bootinfo.h>
14*1da177e4SLinus Torvalds #include <asm/io.h>
15*1da177e4SLinus Torvalds #include <asm/mipsregs.h>
16*1da177e4SLinus Torvalds #include <asm/ptrace.h>
17*1da177e4SLinus Torvalds #include <asm/page.h>
18*1da177e4SLinus Torvalds #include <asm/ip32/crime.h>
19*1da177e4SLinus Torvalds #include <asm/ip32/mace.h>
20*1da177e4SLinus Torvalds 
21*1da177e4SLinus Torvalds struct sgi_crime *crime;
22*1da177e4SLinus Torvalds struct sgi_mace *mace;
23*1da177e4SLinus Torvalds 
24*1da177e4SLinus Torvalds void __init crime_init(void)
25*1da177e4SLinus Torvalds {
26*1da177e4SLinus Torvalds 	unsigned int id, rev;
27*1da177e4SLinus Torvalds 	const int field = 2 * sizeof(unsigned long);
28*1da177e4SLinus Torvalds 
29*1da177e4SLinus Torvalds 	set_io_port_base((unsigned long) ioremap(MACEPCI_LOW_IO, 0x2000000));
30*1da177e4SLinus Torvalds 	crime = ioremap(CRIME_BASE, sizeof(struct sgi_crime));
31*1da177e4SLinus Torvalds 	mace = ioremap(MACE_BASE, sizeof(struct sgi_mace));
32*1da177e4SLinus Torvalds 
33*1da177e4SLinus Torvalds 	id = crime->id;
34*1da177e4SLinus Torvalds 	rev = id & CRIME_ID_REV;
35*1da177e4SLinus Torvalds 	id = (id & CRIME_ID_IDBITS) >> 4;
36*1da177e4SLinus Torvalds 	printk (KERN_INFO "CRIME id %1x rev %d at 0x%0*lx\n",
37*1da177e4SLinus Torvalds 		id, rev, field, (unsigned long) CRIME_BASE);
38*1da177e4SLinus Torvalds }
39*1da177e4SLinus Torvalds 
40*1da177e4SLinus Torvalds irqreturn_t
41*1da177e4SLinus Torvalds crime_memerr_intr (unsigned int irq, void *dev_id, struct pt_regs *regs)
42*1da177e4SLinus Torvalds {
43*1da177e4SLinus Torvalds 	unsigned long stat, addr;
44*1da177e4SLinus Torvalds 	int fatal = 0;
45*1da177e4SLinus Torvalds 
46*1da177e4SLinus Torvalds 	stat = crime->mem_error_stat & CRIME_MEM_ERROR_STAT_MASK;
47*1da177e4SLinus Torvalds 	addr = crime->mem_error_addr & CRIME_MEM_ERROR_ADDR_MASK;
48*1da177e4SLinus Torvalds 
49*1da177e4SLinus Torvalds 	printk("CRIME memory error at 0x%08lx ST 0x%08lx<", addr, stat);
50*1da177e4SLinus Torvalds 
51*1da177e4SLinus Torvalds 	if (stat & CRIME_MEM_ERROR_INV)
52*1da177e4SLinus Torvalds 		printk("INV,");
53*1da177e4SLinus Torvalds 	if (stat & CRIME_MEM_ERROR_ECC) {
54*1da177e4SLinus Torvalds 		unsigned long ecc_syn =
55*1da177e4SLinus Torvalds 			crime->mem_ecc_syn & CRIME_MEM_ERROR_ECC_SYN_MASK;
56*1da177e4SLinus Torvalds 		unsigned long ecc_gen =
57*1da177e4SLinus Torvalds 			crime->mem_ecc_chk & CRIME_MEM_ERROR_ECC_CHK_MASK;
58*1da177e4SLinus Torvalds 		printk("ECC,SYN=0x%08lx,GEN=0x%08lx,", ecc_syn, ecc_gen);
59*1da177e4SLinus Torvalds 	}
60*1da177e4SLinus Torvalds 	if (stat & CRIME_MEM_ERROR_MULTIPLE) {
61*1da177e4SLinus Torvalds 		fatal = 1;
62*1da177e4SLinus Torvalds 		printk("MULTIPLE,");
63*1da177e4SLinus Torvalds 	}
64*1da177e4SLinus Torvalds 	if (stat & CRIME_MEM_ERROR_HARD_ERR) {
65*1da177e4SLinus Torvalds 		fatal = 1;
66*1da177e4SLinus Torvalds 		printk("HARD,");
67*1da177e4SLinus Torvalds 	}
68*1da177e4SLinus Torvalds 	if (stat & CRIME_MEM_ERROR_SOFT_ERR)
69*1da177e4SLinus Torvalds 		printk("SOFT,");
70*1da177e4SLinus Torvalds 	if (stat & CRIME_MEM_ERROR_CPU_ACCESS)
71*1da177e4SLinus Torvalds 		printk("CPU,");
72*1da177e4SLinus Torvalds 	if (stat & CRIME_MEM_ERROR_VICE_ACCESS)
73*1da177e4SLinus Torvalds 		printk("VICE,");
74*1da177e4SLinus Torvalds 	if (stat & CRIME_MEM_ERROR_GBE_ACCESS)
75*1da177e4SLinus Torvalds 		printk("GBE,");
76*1da177e4SLinus Torvalds 	if (stat & CRIME_MEM_ERROR_RE_ACCESS)
77*1da177e4SLinus Torvalds 		printk("RE,REID=0x%02lx,", (stat & CRIME_MEM_ERROR_RE_ID)>>8);
78*1da177e4SLinus Torvalds 	if (stat & CRIME_MEM_ERROR_MACE_ACCESS)
79*1da177e4SLinus Torvalds 		printk("MACE,MACEID=0x%02lx,", stat & CRIME_MEM_ERROR_MACE_ID);
80*1da177e4SLinus Torvalds 
81*1da177e4SLinus Torvalds 	crime->mem_error_stat = 0;
82*1da177e4SLinus Torvalds 
83*1da177e4SLinus Torvalds 	if (fatal) {
84*1da177e4SLinus Torvalds 		printk("FATAL>\n");
85*1da177e4SLinus Torvalds 		panic("Fatal memory error.");
86*1da177e4SLinus Torvalds 	} else
87*1da177e4SLinus Torvalds 		printk("NONFATAL>\n");
88*1da177e4SLinus Torvalds 
89*1da177e4SLinus Torvalds 	return IRQ_HANDLED;
90*1da177e4SLinus Torvalds }
91*1da177e4SLinus Torvalds 
92*1da177e4SLinus Torvalds irqreturn_t
93*1da177e4SLinus Torvalds crime_cpuerr_intr (unsigned int irq, void *dev_id, struct pt_regs *regs)
94*1da177e4SLinus Torvalds {
95*1da177e4SLinus Torvalds 	unsigned long stat = crime->cpu_error_stat & CRIME_CPU_ERROR_MASK;
96*1da177e4SLinus Torvalds 	unsigned long addr = crime->cpu_error_addr & CRIME_CPU_ERROR_ADDR_MASK;
97*1da177e4SLinus Torvalds 
98*1da177e4SLinus Torvalds 	addr <<= 2;
99*1da177e4SLinus Torvalds 	printk ("CRIME CPU error at 0x%09lx status 0x%08lx\n", addr, stat);
100*1da177e4SLinus Torvalds 	crime->cpu_error_stat = 0;
101*1da177e4SLinus Torvalds 
102*1da177e4SLinus Torvalds 	return IRQ_HANDLED;
103*1da177e4SLinus Torvalds }
104