atspeed_sram.c
4.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#include <regdef.h>
#include <asm.h>
#include <R4300.h>
#include <PR/bcp.h>
#include <PR/bbdebug.h>
#include "test_vector.h"
static inline int do_virage_sram_test();
static inline int do_sram_test(unsigned int start, unsigned int end);
static inline int do_nec_iram_test_march(unsigned int start, unsigned int end);
static inline int do_nec_iram_test_check(unsigned int start, unsigned int end);
/* Test all mi sram here */
int main()
{
int err=0;
#ifdef NEC_IRAM_TEST
#ifdef NEC_IRAM_MARCH
err += do_nec_iram_test_march(INTERNAL_RAM_START, INTERNAL_RAM_END);
#else
err += do_nec_iram_test_check(INTERNAL_RAM_START, INTERNAL_RAM_END);
#endif
#else
err += do_virage_sram_test();
err += do_sram_test(BOOT_RAM_LO_START, BOOT_RAM_LO_END);
err += do_sram_test(INTERNAL_RAM_START, INTERNAL_RAM_END);
#endif
if (err) { TEST_ERROR;}
else {TEST_PASS;}
for (;;);
return 0;
}
static inline int do_sram_test(unsigned int start, unsigned int end)
{
int err=0, data, addr, k;
/* change to cache space */
start |= K1BASE;
end |= K1BASE;
/* walk through address line */
*((unsigned int *) start) = 0x12345678;
for (addr=start, k=4; (addr+k)<end; k<<=1) {
data = (k & 0xff) | ((~k & 0xff) << 8);
data |= (~data << 16);
*((unsigned int *) (addr + k)) = data;
}
*((unsigned int *) (end -4)) = 0xbabecafe;
if ( *((unsigned int *) start) != 0x12345678 ) err++;
for (addr=start, k=4; (addr+k)<end; k<<=1) {
data = (k & 0xff) | ((~k & 0xff) << 8);
data |= (~data << 16);
if (*((unsigned int *) (addr + k)) != data) err++;
}
if ( *((unsigned int *) (end-4)) != 0xbabecafe ) err++;
/* 1 Walk through data line */
for (k=0; k<32; k++) {
data = 1 << k;
*((unsigned int *) start) = data;
if ( *((unsigned int *) start) != data) err++;
}
return err;
}
static inline int do_virage_sram_test()
{
int err = 0;
err += do_sram_test(VIRAGE0_RAM_START, VIRAGE0_RAM_END );
err += do_sram_test(VIRAGE1_RAM_START, VIRAGE1_RAM_END );
IO_WRITE(VIRAGE2_CTRL_REG, 0);
err += do_sram_test(VIRAGE2_RAM_START, VIRAGE2_RAM_END );
return err;
}
#define IRAM_DATA_OUTPUT K1BASE
#define RSP_RET_ADDR 0x7FFFC0
static inline int do_nec_iram_test_march(unsigned int start, unsigned int end)
{
unsigned int *p_iram, *p_ddr, *p_iram_end, *p_iram_start;
unsigned int v, data, v1, dummy;
#ifdef PATTERN_0
v = 0;
#else
v = 0xffffffff;
#endif
v1 = (~v) & 0xffffffff;
p_iram = p_iram_start = (unsigned int *) (start | K1BASE);
p_iram_end = (unsigned int *) (end | K1BASE);
p_ddr = (unsigned int *) IRAM_DATA_OUTPUT;
/* 1st write */
while (p_iram < p_iram_end)
*p_iram++ = v;
/* 2nd write */
p_iram = (unsigned int *) (start | K1BASE);
while (p_iram < p_iram_end) {
data = *p_iram;
*p_iram = v1;
dummy = IO_READ((u32) p_iram);
p_iram++;
*p_ddr++ = data;
}
/* 3rd write */
p_iram = p_iram_end - 1;
while (p_iram >= p_iram_start) {
data = *p_iram;
*p_iram = v;
dummy = IO_READ((u32) p_iram);
p_iram--;
*p_ddr++ = data;
}
/* 4th write */
p_iram = p_iram_end - 1;
while (p_iram >= p_iram_start) {
data = *p_iram;
*p_iram = v1;
dummy = IO_READ((u32) p_iram);
p_iram--;
*p_ddr++ = data;
}
IO_WRITE(RSP_RET_ADDR, 1);
return 0;
}
static inline int do_nec_iram_test_check(unsigned int start, unsigned int end)
{
unsigned int v, data, dummy, ddr;
int i, addr;
unsigned int *p_iram, *p_ddr, *p_iram_end, *p_iram_start;
#ifdef PATTERN_0
v = 0;
#else
v = 0xffffffff;
#endif
/* 1st write */
ddr = IRAM_DATA_OUTPUT;
for (addr=start, i=0 ; addr<end; addr+=sizeof(int), i++) {
IO_WRITE(addr, v);
v = (~v) & 0xffffffff;
if ((i & 0xf) == 0xf)
v = (~v) & 0xffffffff;
}
p_iram = p_iram_start = (unsigned int *) (start | K1BASE);
p_iram_end = (unsigned int *) (end | K1BASE);
p_ddr = (unsigned int *) IRAM_DATA_OUTPUT;
/* 2nd write */
while (p_iram < p_iram_end) {
data = *p_iram;
*p_iram = (~data) & 0xffffffff;
dummy = IO_READ((u32) p_iram);
p_iram++;
*p_ddr++ = data;
}
/* 3rd write */
p_iram = p_iram_end - 1;
while (p_iram >= p_iram_start) {
data = *p_iram;
*p_iram = (~data) & 0xffffffff;
dummy = IO_READ((u32) p_iram);
p_iram--;
*p_ddr++ = data;
}
/* 4th write */
p_iram = p_iram_end - 1;
while (p_iram >= p_iram_start) {
data = *p_iram;
*p_iram = (~data) & 0xffffffff;
dummy = IO_READ((u32) p_iram);
p_iram--;
*p_ddr++ = data;
}
IO_WRITE(RSP_RET_ADDR, 1);
return 0;
}