static int ddr_addrtrain(void) { ddrtr_t entry; struct ddrtr_result_t *result; struct ddrtr_param_t param; param.cmd = DDRTR_PARAM_ADDRTRAIN; entry = (ddrtr_t)get_ddrtr_entry(); if (!entry) return -1; printf("## DDR address training entry: 0x%08X, ", (unsigned int)entry); asm("mcr p15, 0, r0, c7, c5, 0"); asm("mcr p15, 0, r0, c7, c10, 4"); result = entry(¶m); if (!result) { printf("## DDR address training fail, reset system.\n"); reset_cpu(0); return 0; } memcpy((void *)&ddrtr_result, result, sizeof(ddrtr_result)); printf("## DDR address training terminated.\n"); ddr_training_result((unsigned int)(&(ddrtr_result.data))); printf("\nDDR address training Registers and Value:\n"); printf(dump_ddrtr_result(result, '\n')); return 0; }
int ddr_training(void) { ddrtr_t entry; unsigned int start, length; struct ddrtr_result_t *result; struct ddrtr_param_t param; start = get_ddr_free(&length, 0x100000); param.cmd = DDRTR_PARAM_TRAINING; param.train.start = start; param.train.length = length; entry = (ddrtr_t)get_ddrtr_entry(); if (!entry) return -1; printf("## DDR training entry: 0x%08X area: 0x%08X - 0x%08X\n", (unsigned int)entry, start, start + length); asm("mcr p15, 0, r0, c7, c5, 0"); asm("mcr p15, 0, r0, c7, c10, 4"); result = entry(¶m); if (!result) { printf("## DDR training fail, reset system.\n"); reset_cpu(0); return 0; } memcpy((void *)&ddrtr_result, result, sizeof(ddrtr_result)); printf("## DDR training terminated.\n"); ddr_training_result((unsigned int)(&(ddrtr_result.data))); printf("\nDDR Training Registers and Value:\n"); printf(dump_ddrtr_result(result, '\n')); return 0; }
int ddr_training(void) { ddrtr_t entry; unsigned int start, end; struct ddrtr_result_t *result; start = get_ddr_free(&end, 0x100000); end += start; entry = (ddrtr_t)get_ddrtr_entry(); if (!entry) return -1; printf ("## DDR training entry: 0x%08X, " "training area: 0x%08X - 0x%08X\n", (unsigned int)entry, start, end); asm("mcr p15, 0, r0, c7, c5, 0"); asm("mcr p15, 0, r0, c7, c10, 4"); result = entry(start, (end - start)); if (!result) { printf("## DDR training fail, reset system.\n"); reset_cpu(0); return 0; } memcpy((void*)&ddrtr_result, result, sizeof(ddrtr_result)); printf ("## DDR training terminated.\n"); ddr_training_result((unsigned int)(&(ddrtr_result.data))); printf("\nDDR Training Registers and Value:\n"); printf(dump_ddrtr_result(result, '\n')); return 0; }
static int ddrt_pressure(int argc, char *argv[]) { ddrtr_t entry; struct ddrtr_result_t *result; unsigned int mode = 0; unsigned int codetype = 0; unsigned long cnt = 1; unsigned int burstnum = 0; unsigned int change_bit = 0; struct ddrtr_param_t param; char *endp; if (argc > 6) goto usage; if (argc > 1) { mode = simple_strtoul(argv[1], &endp, 0); if (mode > 10) goto usage; } if (argc > 2) { codetype = simple_strtoul(argv[2], &endp, 0); if (codetype > 3) goto usage; } if (argc > 3) cnt = simple_strtoull(argv[3], &endp, 0); if (argc > 4) burstnum = simple_strtoull(argv[4], &endp, 0); if (argc > 5) change_bit = simple_strtoull(argv[5], &endp, 0); entry = (ddrtr_t)get_ddrtr_entry(); asm("mcr p15, 0, r0, c7, c5, 0"); asm("mcr p15, 0, r0, c7, c10, 4"); param.cmd = DDRTR_PARAM_PRESSURE; param.pressure.mode = mode; param.pressure.codetype = codetype; param.pressure.count = cnt; param.pressure.burstnum = burstnum; param.pressure.changebit = change_bit; result = entry(¶m); if (!result) { printf("## DDR pressure fail, reset system.\n"); reset_cpu(0); return 0; } return 0; usage: puts("ddr pressure [mode] [codetype] [count] [burstnum] [changebit]\n" " do DDR training stress tests\n" " mode\n" " - 0 write & read\n" " - 1 write\n" " - 2 read\n" " - 3 randrom write & read\n" " codetype\n" " - 0 PRBS9\n" " - 1 PRBS7\n" " - 2 PRBS11\n" " - 3 K28.5\n" " count send len\n" " burstnum burst num\n" " changebit change bit\n"); return -1; }