1*a0640b2bSmatt /* $NetBSD: memc_3max.c,v 1.17 2011/07/09 17:32:31 matt Exp $ */
2a5b668beSnisimura
3a5b668beSnisimura /*
4a5b668beSnisimura * Copyright (c) 1998 Jonathan Stone. All rights reserved.
5a5b668beSnisimura *
6a5b668beSnisimura * Redistribution and use in source and binary forms, with or without
7a5b668beSnisimura * modification, are permitted provided that the following conditions
8a5b668beSnisimura * are met:
9a5b668beSnisimura * 1. Redistributions of source code must retain the above copyright
10a5b668beSnisimura * notice, this list of conditions and the following disclaimer.
11a5b668beSnisimura * 2. Redistributions in binary form must reproduce the above copyright
12a5b668beSnisimura * notice, this list of conditions and the following disclaimer in the
13a5b668beSnisimura * documentation and/or other materials provided with the distribution.
14a5b668beSnisimura * 3. All advertising materials mentioning features or use of this software
15a5b668beSnisimura * must display the following acknowledgement:
16a5b668beSnisimura * This product includes software developed by Jonathan Stone for
17a5b668beSnisimura * the NetBSD Project.
18a5b668beSnisimura * 4. The name of the author may not be used to endorse or promote products
19a5b668beSnisimura * derived from this software without specific prior written permission.
20a5b668beSnisimura *
21a5b668beSnisimura * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22a5b668beSnisimura * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23a5b668beSnisimura * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24a5b668beSnisimura * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25a5b668beSnisimura * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26a5b668beSnisimura * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27a5b668beSnisimura * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28a5b668beSnisimura * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29a5b668beSnisimura * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30a5b668beSnisimura * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31a5b668beSnisimura */
32a5b668beSnisimura
33a5b668beSnisimura #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
34a5b668beSnisimura
35*a0640b2bSmatt __KERNEL_RCSID(0, "$NetBSD: memc_3max.c,v 1.17 2011/07/09 17:32:31 matt Exp $");
36a5b668beSnisimura
3717f87d38Ssimonb #include <sys/param.h>
38ede7778aSsimonb #include <sys/systm.h>
39a5b668beSnisimura
40*a0640b2bSmatt #include <mips/locore.h> /* wbflush() */
41a5b668beSnisimura
42a5b668beSnisimura #include <pmax/pmax/kn02.h> /* error-register defs copied into kn03.h */
43d7a56fd7Snisimura #include <pmax/pmax/memc.h>
44a5b668beSnisimura
45a5b668beSnisimura /*
46a5b668beSnisimura * the 3max and 3maxplus have compatible memory subsystems;
47a5b668beSnisimura * we handle them both here.
48a5b668beSnisimura */
49a5b668beSnisimura
50a5b668beSnisimura
51a5b668beSnisimura void
dec_mtasic_err(uint32_t erradr,vaddr_t errsyn,uint32_t bnk32m)52290a34a0Smatt dec_mtasic_err(uint32_t erradr, vaddr_t errsyn, uint32_t bnk32m)
53a5b668beSnisimura {
548a66a954Stsutsui uint32_t physadr;
5517f87d38Ssimonb int module;
56a5b668beSnisimura
57a5b668beSnisimura if (!(erradr & KN02_ERR_VALID))
58a5b668beSnisimura return;
59a5b668beSnisimura /* extract the physical word address and compensate for pipelining */
60a5b668beSnisimura physadr = erradr & KN02_ERR_ADDRESS;
61a5b668beSnisimura if (!(erradr & KN02_ERR_WRITE))
62a5b668beSnisimura physadr = (physadr & ~0xfff) | ((physadr & 0xfff) - 5);
63a5b668beSnisimura physadr <<= 2;
6417f87d38Ssimonb printf("%s memory %s %s error at 0x%08x",
65a5b668beSnisimura (erradr & KN02_ERR_CPU) ? "CPU" : "DMA",
66a5b668beSnisimura (erradr & KN02_ERR_WRITE) ? "write" : "read",
67a5b668beSnisimura (erradr & KN02_ERR_ECCERR) ? "ECC" : "timeout",
68a5b668beSnisimura physadr);
6917f87d38Ssimonb if (physadr <= ctob(physmem)) {
7017f87d38Ssimonb if (bnk32m != 0) /* 32MB modules? */
7117f87d38Ssimonb module = physadr / ( 32 * 1024 * 1024);
7217f87d38Ssimonb else
7317f87d38Ssimonb module = physadr / ( 8 * 1024 * 1024);
7417f87d38Ssimonb printf(" module %d", module);
7517f87d38Ssimonb }
7617f87d38Ssimonb else {
7717f87d38Ssimonb /* ECC error didn't occur in RAM */
7817f87d38Ssimonb printf(" (no RAM)");
7917f87d38Ssimonb }
8017f87d38Ssimonb printf("\n");
81a5b668beSnisimura if (erradr & KN02_ERR_ECCERR) {
828a66a954Stsutsui uint32_t errsyn_value = *(uint32_t *)errsyn;
838a66a954Stsutsui *(uint32_t *)errsyn = 0;
84a5b668beSnisimura wbflush();
85a5b668beSnisimura printf(" ECC 0x%08x\n", errsyn_value);
86a5b668beSnisimura
87a5b668beSnisimura /* check for a corrected, single bit, read error */
88a5b668beSnisimura if (!(erradr & KN02_ERR_WRITE)) {
89a5b668beSnisimura if (physadr & 0x4) {
90a5b668beSnisimura /* check high word */
91a5b668beSnisimura if (errsyn_value & KN02_ECC_SNGHI)
92a5b668beSnisimura return;
93a5b668beSnisimura } else {
94a5b668beSnisimura /* check low word */
95a5b668beSnisimura if (errsyn_value & KN02_ECC_SNGLO)
96a5b668beSnisimura return;
97a5b668beSnisimura }
98a5b668beSnisimura }
99a5b668beSnisimura printf("\n");
100a5b668beSnisimura }
101a5b668beSnisimura else
102a5b668beSnisimura printf("\n");
103683554e2Swiz panic("Mem error interrupt");
104a5b668beSnisimura }
105a5b668beSnisimura
106a5b668beSnisimura /*
107a5b668beSnisimura * Xxx noncontig memory probing with mixed-sized memory boards
108a5b668beSnisimura * XXX on 3max (kn02) or 3maxplus (kn03) belongs here.
109a5b668beSnisimura */
110a5b668beSnisimura
111a5b668beSnisimura /*
112a5b668beSnisimura * Xxx any support for NVRAM (PrestoServe) modules in
113a5b668beSnisimura * XXX on 3max (kn02) or 3maxplus (kn03) memory slots probably belongs here,
114a5b668beSnisimura * since we need to not probe it as normal RAM.
115a5b668beSnisimura */
116