iotestcmd.c
15.7 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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
/*************************************************************************
*
* File: iotestcmd.c
*
* This file contains the main test command table.
*
* $Header: /root/leakn64/depot/rf/sw/bbplayer/iosim/src/iotestcmd.c,v 1.41 2003/01/31 03:03:13 whs Exp $
*
*/
#include <stdio.h>
#include "trace.h"
#include "bcp.h"
#include "iomap.h"
#include "iotest.h"
#include "bcptest.h"
#include "bcp_util.h"
#include "simipc.h"
#include "bcp_usb.h"
#include "bcptestsi.h"
#include "bcp_rand_tests.h"
/***********************************************************************
* Global definitions
*/
int errorTotal = 0;
int errorCount = 0;
/***********************************************************************
* Global variables
*/
/*
* Test Command Table
* - This is the main command table where each test/task from the
* input file gets executed.
*/
int test_bcp_time(int a1, int a2, int a3, int a4)
{
unsigned long long tt;
unsigned int d1, d2;
SIM_TIME(&tt);
d1 = (unsigned int)((tt >> 32) & 0xffffffff);
d2 = (unsigned int)(tt & 0xffffffff);
printf("Sim time= %u %u %x %x \n", d1, d2, d1, d2);
return 1;
}
TstCmd TstCmdTbl[] = {
/*
* Test Description Routine RoutineName
* ID
* ===================================================================
*/
{ 0, "Config RDRAM", rdramConfig, "rdramConfig" },
{ 1, "Config PI Domain 1", piConfigDom1, "piConfigDom1" },
{ 2, "Config PI Domain 2", piConfigDom2, "piConfigDom2" },
{ 3, "Config AI", AiTestInit, "AiTestInit" },
{ 5, "W/R RDRAM (1B)", rdramTestSglRw, "rdramTestSglRw" },
{ 6, "W/R RDRAM (2B)", rdramTestSglRw, "rdramTestSglRw" },
{ 7, "W/R RDRAM (3B)", rdramTestSglRw, "rdramTestSglRw" },
{ 8, "W/R RDRAM (4B)", rdramTestSglRw, "rdramTestSglRw" },
{ 9, "W/R RDRAM (2-word)", rdramTestBlkRw, "rdramTestBlkRw" },
{ 10, "W/R RDRAM (4-word)", rdramTestBlkRw, "rdramTestBlkRw" },
{ 11, "W/R RDRAM (8-word)", rdramTestBlkRw, "rdramTestBlkRw" },
{ 12, "W/R RDRAM (4B) to pages", rdramTestPgRw, "rdramTestPgRw" },
{ 13, "Init RDRAM", rdramInit, "rdramInit" },
{ 14, "Cpu Wait", CpuWait, "CpuWait" },
{ 15, "Ebus R/W to pages", EbusTestPgRw, "EbusTestPgRw" },
{ 20, "W/R PI Reg", PiTestReg, "PiTestReg" },
{ 21, "PI IO Read", PiTestIoRead, "PiTestIoRead" },
{ 22, "PI IO Write", PiTestIoWrite, "PiTestIoWrite" },
{ 23, "PI DMA", PiTestDma, "PiTestDma" },
{ 24, "PI IO Dump", MemDump, "MemDump" },
{ 25, "PI Compare", MemCompare, "MemCompare" },
{ 26, "PI Status", PiTestStatus, "PiTestStatus" },
{ 27, "PI DMA Pages", PiTestDmaPg, "PiTestDmaPg" },
/* N64 Legacy SI tests */
{ 30, "W/R SI Reg", SiTestReg, "SiTestReg" },
{ 31, "SI IO Read", SiTestIoRead, "SiTestIoRead" },
{ 32, "SI IO Write", SiTestIoWrite, "SiTestIoWrite" },
{ 33, "SI DMA", SiTestDma, "SiTestDma" },
{ 34, "SI Dump", MemDump, "MemDump" },
{ 35, "SI Compare", MemCompare, "MemCompare" },
{ 36, "SI Status", SiTestStatus, "SiTestStatus" },
{ 37, "SI DMA Pages", SiTestDmaPg, "SiTestDmaPg" },
{ 40, "W/R AI Reg", AiTestReg, "AiTestReg" },
{ 43, "AI DMA", AiTestDma, "AiTestDma" },
{ 45, "AI Compare", AiCompareData, "AiCompareData" },
{ 46, "AI Status", AiTestStatus, "AiTestStatus" },
{ 47, "AI DMA Pages", AiTestDmaPg, "AiTestDmaPg" },
{ 48, "AI Start DMA", AiStartDma,"AiStartDma" },
{ 49, "AI Length Decrement", AiCompareLength,"AiCompareLength" },
/* 50 is reserved for VI */
{ 60, "W/R SP Reg", SpTestReg, "SpTestReg" },
{ 61, "SP IO Read", SpTestIoRead, "SpTestIoRead" },
{ 62, "SP IO Write", SpTestIoWrite, "SpTestIoWrite" },
{ 63, "SP DMA", SpTestDma, "SpTestDma" },
{ 64, "SP IO Dump", MemDump, "MemDump" },
{ 65, "SP Compare", MemCompare, "MemCompare" },
{ 66, "SP Status", SpTestStatus, "SpTestStatus" },
{ 67, "SP DMA Pages", SpTestDmaPg, "SpTestDmaPg" },
/* 70 is reserved for DP CMD */
{ 70, "RDP List", RDPList, "RDPList" },
{ 71, "RDP List Loop", RDPListLoop, "RDPListLoop" },
{ 72, "RDP List Counter", RDPListCounter, "RDPListCounter"},
/* 80 is reserved for DP SPAN */
{ 100, "Mem Read", MemRead, "MemRead" },
{ 101, "Mem Read-Compare", MemReadCompare, "MemReadCompare" },
{ 102, "Mem Write", MemWrite, "MemWrite" },
{ 103, "Mem Write-Read", MemWriteRead, "MemWriteRead" },
{ 104, "Mem Poll Status", MemPollStatus, "MemPollStatus" },
{ 105, "Mem Compare", MemCompare, "MemCompare" },
{ 106, "Mem Dump", MemDump, "MemDump" },
{ 107, "Mem Read-Until", MemReadUntil, "MemReadUntil" },
{ 108, "Mem Read-Compare-Masked",MemReadCompMask,"MemReadCompMask" },
{ 109, "Mem Read-Write", MemReadWrite, "MemReadWrite" },
{ 110, "Mem Read-Write Mask", MemReadWriteMask,"MemReadWriteMask" },
/* 200~299 Special BCP setup function */
{ 200, "Init BCP DDR", InitDDR, "InitDDR"},
{ 201, "BCP simulator time", test_bcp_time, "bcp_time"},
{ 202, "BCP register test", register_test, "register_test"},
{ 203, "BCP sram test", sram_test, "sram_test"},
{ 210, "Extented Read and compare", ExtMemReadComp, "ExtMemReadComp"},
{ 211, "Extented Write", ExtMemWrite, "ExtMemWrite"},
{ 212, "Extented Read and mask compare", ExtMemReadMaskComp, "ExtMemReadMaskComp"},
{ 216, "Extented Read/write(per bit)test", rwExtReadComp, "rwExtReadComp"},
{ 230, "BCP single walk", regMemSglWalk, "regMemSglWalk"},
{ 231, "xz BCP single walk", ExtMemSglWalk, "ExtMemSglWalk"},
{ 232, "BCP block walk", regMemBlkWalk, "regMemBlkWalk"},
{ 233, "xz BCP block walk", ExtMemBlkWalk, "ExtMemBlkWalk"},
/* 300~399 BCP RI test */
{ 300, "Backdoor DDR Read", BDMemReadComp, "BDMemReadComp"},
{ 301, "Backdoor DDR Write", BDMemWrite, "BDMemWrite"},
{ 302, "Bdoor rd and mask compare", BDMemReadMaskComp,"BDMemReadMaskComp"},
{ 312, "BD DDR Read test", BDMemReadTest, "BDMemReadTest"},
{ 313, "BD DDR Write test", BDMemWriteTest, "BDMemWriteTest"},
/* memory walk but checked by memory backdoor */
{ 330, "BD BCP single walk", BDregMemSglWalk, "BDregMemSglWalk"},
{ 331, "BD xz BCP single walk", BDExtMemSglWalk, "BDExtMemSglWalk"},
{ 332, "BD BCP block walk", BDregMemBlkWalk, "BDregMemBlkWalk"},
{ 333, "BD xz BCP block walk", BDExtMemBlkWalk, "BDExtMemBlkWalk"},
{ 350, "BCP_RI_RAND", bcp_ri_rand, "bcp_ri_rand"},
/* 400~410 BCP RSP CTRACE test */
{400, "BCP RSP CTRACE ONE PASS", RspCtraceRun, "RspCtraceRun" },
{401, "BCP RSP CTRACE SINGLE STEP", RspCtraceSingle, "RspCtraceSingle"},
/* 420 SI backdoor */
{420, "BCP SI BDoor", bd_si_ctrl_setup, "bd_si_ctrl_setup"},
/* 500 -- 520 USB test */
{500, "USB reg read", usb_read_reg_test, "usb_read_reg_test"},
{501, "USB reg write", usb_reg_write_test, "usb_reg_write_test"},
{502, "USB BDT test", usb_bdt_sram, "usb_bdt_sram"},
{510, "USB reset reg value", usb_reset_test , "USB reset reg value"},
{511, "USB register read/write", usb_reg_rw, "USB reg r/w"},
{512, "USB device test", usb_device_test, "USB device test"},
{513, "USB line test", usb_line_state_test, "USB Linestate"},
{514, "USB otg test", usb_otg_test, "USB OTG"},
{515, "USB host echo", usb_simple_host_echo, "USB HOST ECHO"},
{516, "USB hosts test", hosts_test, "USB HOSTS TEST"},
{517, "USB hosts single test", hosts_one_test, "USB HOSTS TEST"},
/* 600 -- 649 BCP SI test */
{600, "SI run set of tests", SiRunTests, "SiRunTests" },
{601, "SI valid Ctrlr Cmds", SiTestValidCtrlCmds, "SiTestValidCtrlCmds" },
{602, "SI invalid Ctrlr Cmds", SiTestInvalidCtrlrCmds, "SiTestInvalidCtrlrCmds" },
{603, "SI force Ctrlr error via BD", SiTestCtrlrErrViaBD, "SiTestCtrlrErrViaBD" },
{604, "SI DMA busy error", SiTestDmaBusyError, "SiTestDmaBusyError" },
{605, "SI LC single command dectect", SiTestSingleCmdDetection,"SiTestSingleCmdDetection" },
{606, "SI JChannel reset(JCRST)", SiTestJChannelReset, "SiTestJChannelReset" },
{607, "SI DMA from/to specific addr", SiTestDmaSpecificAddrs, "SiTestDmaSpecificAddrs" },
{608, "SI DMA from/to walk bits", SiTestDmaWalkBits, "SiTestDmaWalkBits" },
{609, "SI DMA with random params", SiTestRandom, "SiTestRandom" },
{610, "SI LC joystick reset ref", SiTestLCtrlJSRST, "SiTestLCtrlJSRST" },
{611, "SI LC button sample rate", SiTestLCtrlButRate, "SiTestLCtrlButRate" },
{612, "SI LC joystick x,y", SiTestLCtrlJsxy, "SiTestLCtrlJsxy" },
{700, "Write a single line luma ramp", write_luma_ramp, "write_luma_ramp"},
{701, "Write a single line of color bars",write_color_bar, "write_color_bar"},
/* 800 -- 900 for BCP random test */
{800, "BCP RI SINGLE r/w", bcp_ri_single_rw, "bcp_ri_single_rw"},
{810, "BCP AI DMA", bcp_ai_dma, "bcp_ai_dma"},
{820, "BCP SI tests in random env", SiTestRandEnv, "SiTestRandEnv" },
{840, "BCP SP PIO", bcp_sp_rand_pio, "bcp_sp_rand_pio"},
{841, "BCP SP DMA", bcp_sp_rand_dma, "bcp_sp_rand_dma"},
{830, "BCP UI SETUP", hosts_setup, "hosts_setup"},
{831, "BCP UI PIO", bcp_ui_rand_pio, "bcp_ui_rand_pio"},
{832, "BCP UI TRANSACTION", bcp_ui_rand_trans, "bcp_ui_rand_trans"},
{900, "BCP CLEAR STAT", bcp_unit_clear_stat, "bcp_unit_clear_stat"},
{901, "BCP DISPLAY STAT", bcp_unit_disp_stat, "bcp_unit_disp_stat"},
{902, "BCP CHECK Bits 9", bcp_check_9th, "bcp_check_9th"},
};
/***********************************************************************
* Routines
*/
int
rdramConfig(int rdram1, int size, int a3, int a4)
{
if (size == 0) {
size = (rdram1) ? 4 : 2;
}
RdramInit(size);
return(1);
}
int
InitDDR(int a1, int a2, int a3, int a4)
{
unsigned int sysclk_period, memclk;
int refcnt = 0x1e0;
int trdel, twdel, tras, trp, trcdr, trfc, tcl, tcl_b;
int mem_info;
bcp_sysclk_period(&sysclk_period);
mem_info = BCP_MEM_INFO;
if (sysclk_period > 16000 || sysclk_period < 10000) {
_TRACE(DERROR, fprintf(LogFp, "System clk wrong"));
sysclk_period=16000;
}
memclk = 2000000 / sysclk_period;
trdel = 3;
twdel = 1;
tras = (memclk >= 150)?1:0;
trp = (memclk > 150)?1:0;
trcdr = (memclk > 150)?1:0;
trfc = (memclk > 150)?0xE:0xC;
if ((mem_info & BCP_MEM_DDR_MASK) == 0x1000) { /* 16 bits */
trfc = 0xf;
trcdr = (memclk >= 160)?1:0;
trp = (memclk >= 160)?1:0;
tcl = (memclk >= 160) ? 6 : 2;
tcl_b = tcl;
} else {
tcl = 3;
tcl_b = 4;
}
#if 0
IO_WRITE(0x04700020, 0x80000000);
IO_READ(0x04700020);
IO_WRITE(0x04700020, 0x00002002);
IO_READ(0x04700020);
IO_WRITE(0x04700020, 0x0000013a);
IO_READ(0x04700020);
IO_WRITE(0x04700020, 0x80000000);
IO_READ(0x04700020);
IO_WRITE(0x04700020, 0x40000000);
IO_READ(0x04700020);
IO_WRITE(0x04700030, 0x00001000 | refcnt);
//IO_WRITE(0x04700030, 0x00000000);
IO_READ(0x04700030);
//IO_WRITE(0x04700040, 0x0006000fa);
IO_WRITE(0x04700040, 0x001111e3);
IO_READ(0x04700030);
IO_READ(0x04700030);
#else
IO_WRITE(RI_NMODE_REG, RI_NMODE_CMD_PRECHARGE_ALL);
IO_READ(RI_NMODE_REG);
IO_WRITE(RI_NMODE_REG, RI_NMODE_EX|RI_NMODE_EX_DRIVE_STR_HALF);
IO_READ(RI_NMODE_REG);
IO_WRITE(RI_NMODE_REG, RI_NMODE_MX_BURST_ILV|
RI_NMODE_MX_BURST_LEN_4|
RI_NMODE_MX_CL(tcl)|
RI_NMODE_MX_RESET_DLL);
IO_READ(RI_NMODE_REG);
IO_WRITE(RI_NMODE_REG, RI_NMODE_CMD_PRECHARGE_ALL);
IO_READ(RI_NMODE_REG);
IO_WRITE(RI_NMODE_REG, RI_NMODE_CMD_AUTO_REFRESH);
IO_READ(RI_NMODE_REG);
IO_WRITE(RI_NREFRESH_REG, RI_NREFRESH_ENABLE | refcnt);
IO_READ(RI_NREFRESH_REG);
IO_WRITE(RI_DDR_CONFIG_REG, (trdel<<RI_DDR_CONFIG_TRDEL_SHIFT)|
(twdel<<RI_DDR_CONFIG_TWDEL_SHIFT)|
(tras<<RI_DDR_CONFIG_TRAS_SHIFT)|
(trp<<RI_DDR_CONFIG_TRP_SHIFT)|
(trcdr<<RI_DDR_CONFIG_TRCD_SHIFT)|
(trfc<<RI_DDR_CONFIG_TRFC_SHIFT)|
(tcl_b<<RI_DDR_CONFIG_TCL_SHIFT));
IO_READ(RI_NREFRESH_REG);
IO_READ(RI_NREFRESH_REG);
if ((mem_info & BCP_MEM_DDR_MASK) == 0x1000) /* 16 bits */
IO_WRITE(RI_XMEM_REG, 1);
else {
IO_WRITE(RI_STROBE_REV_REG, 1);
IO_WRITE(RI_AUTO_PRE_CHG_REG, 1);
}
#endif
cpuWait(100);
}
int
InitDDRBypass(int tcl0, int tcl1, int a3, int a4)
{
unsigned int sysclk_period, memclk;
int refcnt = 0x1e0;
int trdel, twdel, tras, trp, trcdr, trfc, tcl;
int mem_info;
bcp_sysclk_period(&sysclk_period);
mem_info = BCP_MEM_INFO;
if (sysclk_period > 16000 || sysclk_period < 10000) {
_TRACE(DERROR, fprintf(LogFp, "System clk wrong"));
sysclk_period=16000;
}
memclk = 2000000 / sysclk_period;
trdel = 3;
twdel = 1;
tras = (memclk >= 150)?1:0;
trp = (memclk > 150)?1:0;
trcdr = (memclk > 150)?1:0;
trfc = (memclk > 150)?0xE:0xC;
if ((mem_info & BCP_MEM_DDR_MASK) == 0x1000) { /* 16 bits */
trfc = 0xf;
trcdr = (memclk >= 160)?1:0;
trp = (memclk >= 160)?1:0;
tcl = (memclk >= 160) ? 6 : 2;
} else tcl = 3;
#if 0
IO_WRITE(0x04700020, 0x80000000);
IO_READ(0x04700020);
IO_WRITE(0x04700020, 0x00002002);
IO_READ(0x04700020);
IO_WRITE(0x04700020, 0x0000013a);
IO_READ(0x04700020);
IO_WRITE(0x04700020, 0x80000000);
IO_READ(0x04700020);
IO_WRITE(0x04700020, 0x40000000);
IO_READ(0x04700020);
IO_WRITE(0x04700030, 0x00001000 | refcnt);
//IO_WRITE(0x04700030, 0x00000000);
IO_READ(0x04700030);
//IO_WRITE(0x04700040, 0x0006000fa);
IO_WRITE(0x04700040, 0x001111e3);
IO_READ(0x04700030);
IO_READ(0x04700030);
#else
IO_WRITE(RI_NMODE_REG, RI_NMODE_CMD_PRECHARGE_ALL);
IO_READ(RI_NMODE_REG);
IO_WRITE(RI_NMODE_REG, RI_NMODE_EX|RI_NMODE_EX_DRIVE_STR_HALF);
IO_READ(RI_NMODE_REG);
IO_WRITE(RI_NMODE_REG, RI_NMODE_MX_BURST_ILV|
RI_NMODE_MX_BURST_LEN_4|
RI_NMODE_MX_CL(tcl0)|
RI_NMODE_MX_RESET_DLL);
IO_READ(RI_NMODE_REG);
IO_WRITE(RI_NMODE_REG, RI_NMODE_CMD_PRECHARGE_ALL);
IO_READ(RI_NMODE_REG);
IO_WRITE(RI_NMODE_REG, RI_NMODE_CMD_AUTO_REFRESH);
IO_READ(RI_NMODE_REG);
IO_WRITE(RI_NREFRESH_REG, RI_NREFRESH_ENABLE | refcnt);
IO_READ(RI_NREFRESH_REG);
IO_WRITE(RI_DDR_CONFIG_REG, (trdel<<RI_DDR_CONFIG_TRDEL_SHIFT)|
(twdel<<RI_DDR_CONFIG_TWDEL_SHIFT)|
(tras<<RI_DDR_CONFIG_TRAS_SHIFT)|
(trp<<RI_DDR_CONFIG_TRP_SHIFT)|
(trcdr<<RI_DDR_CONFIG_TRCD_SHIFT)|
(trfc<<RI_DDR_CONFIG_TRFC_SHIFT)|
(tcl1<<RI_DDR_CONFIG_TCL_SHIFT));
IO_READ(RI_NREFRESH_REG);
IO_READ(RI_NREFRESH_REG);
if ((mem_info & BCP_MEM_DDR_MASK) == 0x1000) /* 16 bits */
IO_WRITE(RI_XMEM_REG, 1);
else {
IO_WRITE(RI_STROBE_REV_REG, 0);
//IO_WRITE(RI_AUTO_PRE_CHG_REG, 1);
}
#endif
cpuWait(120);
}
int
piConfigDom1(int lat, int pwd, int pgs, int rls)
{
_TRACE(DLOG, printf(
"\tPI Config Dom1: lat=%x, pwd=%x, pgs=%x, rls=%x\n",
lat, pwd, pgs, rls));
PiConfigDomain(PI_DOMAIN1_REG, lat, pwd, pgs, rls);
return(1);
}
int
piConfigDom2(int lat, int pwd, int pgs, int rls)
{
_TRACE(DLOG, printf(
"\tPI Config Dom2: lat=%x, pwd=%x, pgs=%x, rls=%x\n",
lat, pwd, pgs, rls));
PiConfigDomain(PI_DOMAIN2_REG, lat, pwd, pgs, rls);
return(1);
}
/*
* Stub routine to delay CPU clock cycles
*/
int
CpuWait(int count, int a2, int a3, int a4)
{
int i;
/* This generates a 4 clock delay in verilog model */
/* for (i = 0; i < count; i++)
IO_WRITE(MI_NOOP_REG, 0); */
BCP_STALL(count*4);
return(1);
}