blob: 6152eb21a909d38ecca9f0c01f2d89c83cbb80a6 [file] [log] [blame]
Igor Lisitsina11e0692007-03-28 19:06:19 +04001/*
2 * (C) Copyright 2007
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
Sergei Poselenovb4489622007-07-05 08:17:37 +02005 * Author: Igor Lisitsin <igor@emcraft.com>
6 *
Igor Lisitsina11e0692007-03-28 19:06:19 +04007 * See file CREDITS for list of people who contributed to this
8 * project.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 * MA 02111-1307 USA
24 */
25
26#include <common.h>
27
28/*
29 * SPR test
30 *
31 * The test checks the contents of Special Purpose Registers (SPR) listed
32 * in the spr_test_list array below.
33 * Each SPR value is read using mfspr instruction, some bits are masked
34 * according to the table and the resulting value is compared to the
35 * corresponding table value.
36 */
37
Igor Lisitsina11e0692007-03-28 19:06:19 +040038#include <post.h>
39
40#if CONFIG_POST & CFG_POST_SPR
41
Sergei Poselenovb4489622007-07-05 08:17:37 +020042#include <asm/processor.h>
43
Anatolij Gustschin60ec6542008-02-25 20:04:20 +010044#ifdef CONFIG_4xx_DCACHE
45#include <asm/mmu.h>
46
47DECLARE_GLOBAL_DATA_PTR;
48#endif
49
Wolfgang Denk4ef218f2007-07-10 00:01:28 +020050static struct {
51 int number;
52 char * name;
53 unsigned long mask;
54 unsigned long value;
Igor Lisitsina11e0692007-03-28 19:06:19 +040055} spr_test_list [] = {
56 /* Standard Special-Purpose Registers */
57
58 {0x001, "XER", 0x00000000, 0x00000000},
59 {0x008, "LR", 0x00000000, 0x00000000},
60 {0x009, "CTR", 0x00000000, 0x00000000},
61 {0x016, "DEC", 0x00000000, 0x00000000},
62 {0x01a, "SRR0", 0x00000000, 0x00000000},
63 {0x01b, "SRR1", 0x00000000, 0x00000000},
64 {0x110, "SPRG0", 0x00000000, 0x00000000},
65 {0x111, "SPRG1", 0x00000000, 0x00000000},
66 {0x112, "SPRG2", 0x00000000, 0x00000000},
67 {0x113, "SPRG3", 0x00000000, 0x00000000},
68 {0x11f, "PVR", 0x00000000, 0x00000000},
69
Sergei Poselenovb4489622007-07-05 08:17:37 +020070 /* Additional Special-Purpose Registers.
Wolfgang Denk4ef218f2007-07-10 00:01:28 +020071 * The values must match the initialization
Sergei Poselenovb4489622007-07-05 08:17:37 +020072 * values from cpu/ppc4xx/start.S
73 */
Igor Lisitsina11e0692007-03-28 19:06:19 +040074 {0x30, "PID", 0x00000000, 0x00000000},
75 {0x3a, "CSRR0", 0x00000000, 0x00000000},
76 {0x3b, "CSRR1", 0x00000000, 0x00000000},
77 {0x3d, "DEAR", 0x00000000, 0x00000000},
78 {0x3e, "ESR", 0x00000000, 0x00000000},
79 {0x3f, "IVPR", 0xffff0000, 0x00000000},
80 {0x100, "USPRG0", 0x00000000, 0x00000000},
81 {0x104, "SPRG4", 0x00000000, 0x00000000},
82 {0x105, "SPRG5", 0x00000000, 0x00000000},
83 {0x106, "SPRG6", 0x00000000, 0x00000000},
84 {0x107, "SPRG7", 0x00000000, 0x00000000},
85 {0x10c, "TBL", 0x00000000, 0x00000000},
86 {0x10d, "TBU", 0x00000000, 0x00000000},
Niklaus Giger17bef682008-01-14 14:04:42 +010087#ifdef CONFIG_440
Igor Lisitsina11e0692007-03-28 19:06:19 +040088 {0x11e, "PIR", 0x0000000f, 0x00000000},
Niklaus Giger17bef682008-01-14 14:04:42 +010089#endif
Igor Lisitsina11e0692007-03-28 19:06:19 +040090 {0x130, "DBSR", 0x00000000, 0x00000000},
91 {0x134, "DBCR0", 0x00000000, 0x00000000},
92 {0x135, "DBCR1", 0x00000000, 0x00000000},
93 {0x136, "DBCR2", 0x00000000, 0x00000000},
94 {0x138, "IAC1", 0x00000000, 0x00000000},
95 {0x139, "IAC2", 0x00000000, 0x00000000},
96 {0x13a, "IAC3", 0x00000000, 0x00000000},
97 {0x13b, "IAC4", 0x00000000, 0x00000000},
98 {0x13c, "DAC1", 0x00000000, 0x00000000},
99 {0x13d, "DAC2", 0x00000000, 0x00000000},
100 {0x13e, "DVC1", 0x00000000, 0x00000000},
101 {0x13f, "DVC2", 0x00000000, 0x00000000},
102 {0x150, "TSR", 0x00000000, 0x00000000},
103 {0x154, "TCR", 0x00000000, 0x00000000},
Niklaus Giger17bef682008-01-14 14:04:42 +0100104#ifdef CONFIG_440
Sergei Poselenovb4489622007-07-05 08:17:37 +0200105 {0x190, "IVOR0", 0x0000fff0, 0x00000100},
106 {0x191, "IVOR1", 0x0000fff0, 0x00000200},
107 {0x192, "IVOR2", 0x0000fff0, 0x00000300},
108 {0x193, "IVOR3", 0x0000fff0, 0x00000400},
109 {0x194, "IVOR4", 0x0000fff0, 0x00000500},
110 {0x195, "IVOR5", 0x0000fff0, 0x00000600},
111 {0x196, "IVOR6", 0x0000fff0, 0x00000700},
112 {0x197, "IVOR7", 0x0000fff0, 0x00000800},
113 {0x198, "IVOR8", 0x0000fff0, 0x00000c00},
Igor Lisitsina11e0692007-03-28 19:06:19 +0400114 {0x199, "IVOR9", 0x00000000, 0x00000000},
Sergei Poselenovb4489622007-07-05 08:17:37 +0200115 {0x19a, "IVOR10", 0x0000fff0, 0x00000900},
Igor Lisitsina11e0692007-03-28 19:06:19 +0400116 {0x19b, "IVOR11", 0x00000000, 0x00000000},
117 {0x19c, "IVOR12", 0x00000000, 0x00000000},
Sergei Poselenovb4489622007-07-05 08:17:37 +0200118 {0x19d, "IVOR13", 0x0000fff0, 0x00001300},
119 {0x19e, "IVOR14", 0x0000fff0, 0x00001400},
120 {0x19f, "IVOR15", 0x0000fff0, 0x00002000},
Niklaus Giger17bef682008-01-14 14:04:42 +0100121#endif
Igor Lisitsina11e0692007-03-28 19:06:19 +0400122 {0x23a, "MCSRR0", 0x00000000, 0x00000000},
123 {0x23b, "MCSRR1", 0x00000000, 0x00000000},
124 {0x23c, "MCSR", 0x00000000, 0x00000000},
125 {0x370, "INV0", 0x00000000, 0x00000000},
126 {0x371, "INV1", 0x00000000, 0x00000000},
127 {0x372, "INV2", 0x00000000, 0x00000000},
128 {0x373, "INV3", 0x00000000, 0x00000000},
129 {0x374, "ITV0", 0x00000000, 0x00000000},
130 {0x375, "ITV1", 0x00000000, 0x00000000},
131 {0x376, "ITV2", 0x00000000, 0x00000000},
132 {0x377, "ITV3", 0x00000000, 0x00000000},
133 {0x378, "CCR1", 0x00000000, 0x00000000},
134 {0x390, "DNV0", 0x00000000, 0x00000000},
135 {0x391, "DNV1", 0x00000000, 0x00000000},
136 {0x392, "DNV2", 0x00000000, 0x00000000},
137 {0x393, "DNV3", 0x00000000, 0x00000000},
138 {0x394, "DTV0", 0x00000000, 0x00000000},
139 {0x395, "DTV1", 0x00000000, 0x00000000},
140 {0x396, "DTV2", 0x00000000, 0x00000000},
141 {0x397, "DTV3", 0x00000000, 0x00000000},
Niklaus Giger17bef682008-01-14 14:04:42 +0100142#ifdef CONFIG_440
Sergei Poselenovb4489622007-07-05 08:17:37 +0200143 {0x398, "DVLIM", 0x0fc1f83f, 0x0001f800},
144 {0x399, "IVLIM", 0x0fc1f83f, 0x0001f800},
Niklaus Giger17bef682008-01-14 14:04:42 +0100145#endif
Igor Lisitsina11e0692007-03-28 19:06:19 +0400146 {0x39b, "RSTCFG", 0x00000000, 0x00000000},
147 {0x39c, "DCDBTRL", 0x00000000, 0x00000000},
148 {0x39d, "DCDBTRH", 0x00000000, 0x00000000},
149 {0x39e, "ICDBTRL", 0x00000000, 0x00000000},
150 {0x39f, "ICDBTRH", 0x00000000, 0x00000000},
151 {0x3b2, "MMUCR", 0x00000000, 0x00000000},
152 {0x3b3, "CCR0", 0x00000000, 0x00000000},
153 {0x3d3, "ICDBDR", 0x00000000, 0x00000000},
154 {0x3f3, "DBDR", 0x00000000, 0x00000000},
155};
156
157static int spr_test_list_size =
158 sizeof (spr_test_list) / sizeof (spr_test_list[0]);
159
160int spr_post_test (int flags)
161{
162 int ret = 0;
163 int i;
164
165 unsigned long code[] = {
166 0x7c6002a6, /* mfspr r3,SPR */
167 0x4e800020 /* blr */
168 };
169 unsigned long (*get_spr) (void) = (void *) code;
170
Anatolij Gustschin60ec6542008-02-25 20:04:20 +0100171#ifdef CONFIG_4xx_DCACHE
172 /* disable cache */
173 change_tlb(gd->bd->bi_memstart, gd->bd->bi_memsize, TLB_WORD2_I_ENABLE);
174#endif
Igor Lisitsina11e0692007-03-28 19:06:19 +0400175 for (i = 0; i < spr_test_list_size; i++) {
176 int num = spr_test_list[i].number;
177
178 /* mfspr r3,num */
179 code[0] = 0x7c6002a6 | ((num & 0x1F) << 16) | ((num & 0x3E0) << 6);
180
181 asm volatile ("isync");
182
183 if ((get_spr () & spr_test_list[i].mask) !=
184 (spr_test_list[i].value & spr_test_list[i].mask)) {
185 post_log ("The value of %s special register "
186 "is incorrect: 0x%08X\n",
187 spr_test_list[i].name, get_spr ());
188 ret = -1;
189 }
190 }
Anatolij Gustschin60ec6542008-02-25 20:04:20 +0100191#ifdef CONFIG_4xx_DCACHE
192 /* enable cache */
193 change_tlb(gd->bd->bi_memstart, gd->bd->bi_memsize, 0);
194#endif
Igor Lisitsina11e0692007-03-28 19:06:19 +0400195
196 return ret;
197}
Sergei Poselenovb4489622007-07-05 08:17:37 +0200198
Igor Lisitsina11e0692007-03-28 19:06:19 +0400199#endif /* CONFIG_POST & CFG_POST_SPR */