| #include <common.h> |
| #include <malloc.h> |
| #include <asm/io.h> |
| |
| #include "tim.h" |
| #include "asr_common.h" |
| #include "obm2osl.h" |
| #include "asr_flag.h" |
| #include "asr_flash.h" |
| |
| |
| #ifndef CONFIG_BOOT_LOG_ADDR |
| #define CONFIG_BOOT_LOG_ADDR (0x1f00000) |
| #endif |
| |
| #define CONFIG_DDR_ADDR_END (0xFEDCBA98) |
| #define CONFIG_SEC_DDR_ADDR_BEGIN (0xFEDCBA99) |
| #define CONFIG_SEC_DDR_ADDR_END (0xFEDCBA9A) |
| |
| #define DDR_TEST_PASS (0) |
| #define DDR_TEST_FAIL (1) |
| |
| #define MALLOC_BUFF_RESERVE_SZ (0x400000) |
| |
| #define NR_TEST_PATTERN 16 |
| |
| #ifndef data_write32 |
| #define data_write32(ptrReg, value) \ |
| (*((u32 *)(ptrReg)) = value) |
| #endif |
| |
| #ifndef data_read32 |
| #define data_read32(ptrReg) \ |
| (*((u32 *)(ptrReg))) |
| #endif |
| |
| struct mtest_buf_desc { |
| u32 ddr_mtest_begin; |
| u32 ddr_mtest_end; |
| }; |
| |
| static struct asr_firmware_flag *p_asr_flag; |
| |
| #ifdef CONFIG_TEE_OS |
| static struct mtest_buf_desc ddr_test_ranges[] = { |
| [0] = { |
| .ddr_mtest_begin = 0x0, |
| .ddr_mtest_end = CONFIG_SYS_TEXT_BASE - 0x8000, |
| }, |
| [1] = { |
| .ddr_mtest_begin = CONFIG_SYS_LONG_RELOC_END + 0x8000, |
| .ddr_mtest_end = CONFIG_BOOT_LOG_ADDR, |
| }, |
| [2] = { |
| .ddr_mtest_begin = CONFIG_BOOT_LOG_ADDR + 0x10000, /* reserve 64KB */ |
| .ddr_mtest_end = CONFIG_SEC_DDR_ADDR_BEGIN, |
| }, |
| [3] = { |
| .ddr_mtest_begin = CONFIG_SEC_DDR_ADDR_END, |
| .ddr_mtest_end = CONFIG_DDR_ADDR_END, |
| }, |
| }; |
| #else |
| static struct mtest_buf_desc ddr_test_ranges[] = { |
| [0] = { |
| .ddr_mtest_begin = 0x0, |
| .ddr_mtest_end = CONFIG_SYS_TEXT_BASE - 0x8000, |
| }, |
| [1] = { |
| .ddr_mtest_begin = CONFIG_SYS_LONG_RELOC_END + 0x8000, |
| .ddr_mtest_end = CONFIG_BOOT_LOG_ADDR, |
| }, |
| [2] = { |
| .ddr_mtest_begin = CONFIG_BOOT_LOG_ADDR + 0x10000, /* reserve 64KB */ |
| .ddr_mtest_end = CONFIG_DDR_ADDR_END, |
| }, |
| }; |
| #endif |
| |
| |
| #ifdef CONFIG_USE_DDR_ALL_PATTERN |
| static int giBitFails[32], giByteLaneFails[4], giPatternFails[22], giPatternRuns[22],giPatternNumOfFails[22]; |
| #define ANALOG 1 |
| #define CONSTANT 2 |
| #define COMPLEMENT 3 |
| #define DECREMENT 4 |
| #define INCREMENT 5 |
| #define INCREMENTB 6 |
| #define MILLER_EFFECT 7 |
| #define ZERO_ROR_INVERT 8 |
| #define ONE_ROL_INVERT 9 |
| #define ZERO_ROR 10 |
| #define ONE_ROL 11 |
| #define WALKING_ONES 12 |
| #define WALKING_ZEROS 13 |
| #define SSTAILGATE_0101XXXX 14 |
| #define SSTAILGATE_01010000 15 |
| #define SSTAILGATE_01011111 16 |
| #define SSTAILGATE_01011010 17 |
| #define MSTAILGATE 18 |
| #define FREQ_SWEEP 19 |
| #define VERT_INCREMENT 20 |
| #define HORZ_INCREMENT 21 |
| |
| #define read_data_u32(reg) (*((volatile u32 *)(reg))) |
| |
| #define WORD_SIZE (4) |
| |
| static u32 rol32_mcu(u32 val) |
| { |
| u32 msb = val >> 31; |
| |
| val = val << 1; |
| |
| msb &= 0x00000001; |
| val |= msb; |
| |
| return val; |
| } |
| |
| static u32 ror32_mcu(u32 val) |
| { |
| u32 lsb = val << 31; |
| |
| val = val >> 1; |
| |
| val &= 0x7FFFFFFF; |
| val |= lsb; |
| |
| return val; |
| } |
| |
| static int test_write_ANALOG(u32* start, int count) |
| { |
| u32* p = (u32*)start; |
| while (p < (start + count)) |
| { |
| #define DOIT1(i) p[i]=0xffffffff; |
| #define DOIT2(i) p[i]=0x0; |
| |
| DOIT1(0) DOIT2(1) DOIT1(2) DOIT2(3) DOIT1(4) DOIT2(5) DOIT1(6) DOIT2(7) |
| DOIT1(8) DOIT2(9) DOIT1(10) DOIT2(11) DOIT1(12) DOIT2(13) DOIT1(14) DOIT2(15) |
| DOIT1(16) DOIT2(17) DOIT1(18) DOIT2(19) DOIT1(20) DOIT2(21) DOIT1(22) DOIT2(23) |
| DOIT1(24) DOIT2(25) DOIT1(26) DOIT2(27) DOIT1(28) DOIT2(29) DOIT1(30) DOIT2(31) |
| p += 32; |
| |
| DOIT1(0) DOIT2(1) DOIT1(2) DOIT2(3) DOIT1(4) DOIT2(5) DOIT1(6) DOIT2(7) |
| DOIT1(8) DOIT2(9) DOIT1(10) DOIT2(11) DOIT1(12) DOIT2(13) DOIT1(14) DOIT2(15) |
| DOIT1(16) DOIT2(17) DOIT1(18) DOIT2(19) DOIT1(20) DOIT2(21) DOIT1(22) DOIT2(23) |
| DOIT1(24) DOIT2(25) DOIT1(26) DOIT2(27) DOIT1(28) DOIT2(29) DOIT1(30) DOIT2(31) |
| p += 32; |
| } |
| return 0; |
| } |
| #undef DOIT1 |
| #undef DOIT2 |
| |
| static int test_write_CONSTANT(u32* start, int count) |
| { |
| u32* p = (u32*)start; |
| while (p < (start + count)) |
| { |
| #define DOIT1(i) p[i]=0xffffffff; |
| |
| DOIT1(0) DOIT1(1) DOIT1(2) DOIT1(3) DOIT1(4) DOIT1(5) DOIT1(6) DOIT1(7) |
| DOIT1(8) DOIT1(9) DOIT1(10) DOIT1(11) DOIT1(12) DOIT1(13) DOIT1(14) DOIT1(15) |
| DOIT1(16) DOIT1(17) DOIT1(18) DOIT1(19) DOIT1(20) DOIT1(21) DOIT1(22) DOIT1(23) |
| DOIT1(24) DOIT1(25) DOIT1(26) DOIT1(27) DOIT1(28) DOIT1(29) DOIT1(30) DOIT1(31) |
| p += 32; |
| DOIT1(0) DOIT1(1) DOIT1(2) DOIT1(3) DOIT1(4) DOIT1(5) DOIT1(6) DOIT1(7) |
| DOIT1(8) DOIT1(9) DOIT1(10) DOIT1(11) DOIT1(12) DOIT1(13) DOIT1(14) DOIT1(15) |
| DOIT1(16) DOIT1(17) DOIT1(18) DOIT1(19) DOIT1(20) DOIT1(21) DOIT1(22) DOIT1(23) |
| DOIT1(24) DOIT1(25) DOIT1(26) DOIT1(27) DOIT1(28) DOIT1(29) DOIT1(30) DOIT1(31) |
| p += 32; |
| } |
| return 0; |
| } |
| #undef DOIT1 |
| |
| static int test_write_COMPLETEMENT(u32* start, int count, u32 uiStartVal) |
| { |
| u32* p = (u32*)start; |
| while (p < (start + count)) |
| { |
| #define DOIT1(i) p[i]=uiStartVal; |
| #define DOIT2(i) p[i]=(~uiStartVal); |
| |
| DOIT1(0) DOIT2(1) DOIT1(2) DOIT2(3) DOIT1(4) DOIT2(5) DOIT1(6) DOIT2(7) |
| DOIT1(8) DOIT2(9) DOIT1(10) DOIT2(11) DOIT1(12) DOIT2(13) DOIT1(14) DOIT2(15) |
| DOIT1(16) DOIT2(17) DOIT1(18) DOIT2(19) DOIT1(20) DOIT2(21) DOIT1(22) DOIT2(23) |
| DOIT1(24) DOIT2(25) DOIT1(26) DOIT2(27) DOIT1(28) DOIT2(29) DOIT1(30) DOIT2(31) |
| p += 32; |
| |
| DOIT1(0) DOIT2(1) DOIT1(2) DOIT2(3) DOIT1(4) DOIT2(5) DOIT1(6) DOIT2(7) |
| DOIT1(8) DOIT2(9) DOIT1(10) DOIT2(11) DOIT1(12) DOIT2(13) DOIT1(14) DOIT2(15) |
| DOIT1(16) DOIT2(17) DOIT1(18) DOIT2(19) DOIT1(20) DOIT2(21) DOIT1(22) DOIT2(23) |
| DOIT1(24) DOIT2(25) DOIT1(26) DOIT2(27) DOIT1(28) DOIT2(29) DOIT1(30) DOIT2(31) |
| p += 32; |
| } |
| return 0; |
| } |
| #undef DOIT1 |
| #undef DOIT2 |
| |
| static u32 allp_mcuGenerateWordPattern(unsigned long uiSourceAddress, u32 uiPattern, u32 size_in_word, u32 uiStartVal, u32 bCheck) |
| { |
| const u32 c_zero = 0x00000000; |
| u32 test_signal = 0x00000001; |
| u32 c_pattern; |
| u32 c_pattern_or_signal; |
| u32 i = 0, j = 0, k = 0, uiTemp = 0, uiFails = 0, expected; |
| u32 value = 0; |
| |
| u32* Tmp_Address32 = (u32*)(long)uiSourceAddress; |
| |
| giPatternRuns[uiPattern]++; |
| |
| switch (uiPattern) |
| { |
| |
| case ANALOG: |
| //printf("Generating ANALOG Pattern\n"); |
| if (bCheck) |
| { |
| for (i = 0; i < size_in_word;) { |
| if (Tmp_Address32[i++] != 0xffffffff) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, 0xffffffff, (uiTemp ^ 0xffffffff)); |
| } |
| //else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], 0xffffffff); |
| |
| if (Tmp_Address32[i++] != 0) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, 0, (uiTemp ^ 0)); |
| } |
| //else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], ~(0xffffffff)); |
| } |
| } |
| else |
| { |
| test_write_ANALOG((u32*)(long)uiSourceAddress, size_in_word); |
| } |
| break; |
| |
| case CONSTANT: |
| uiStartVal = 0xffffffff; |
| //printf("Generating CONSTANT Pattern 0x%X\n", uiStartVal); |
| if (bCheck) |
| { |
| for (i = 0; i < size_in_word;) { |
| |
| if (Tmp_Address32[i++] != uiStartVal) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X - DB=0x%08X - DA=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, (uiStartVal), (uiTemp ^ uiStartVal), read_data_u32(uiSourceAddress + ((i - 1) * 4)), read_data_u32(uiSourceAddress + ((i + 1) * 4))); |
| } |
| //else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], (uiStartVal)); |
| } |
| } |
| else |
| { |
| test_write_CONSTANT((u32*)(long)uiSourceAddress, size_in_word); |
| } |
| break; |
| |
| case COMPLEMENT: |
| //printf("Generating COMPLEMENT Pattern - uiStartVal=%08X\n", uiStartVal); |
| if (bCheck) |
| { |
| for (i = 0; i < size_in_word;) |
| { |
| if (Tmp_Address32[i++] != (uiStartVal)) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, (uiStartVal), (uiTemp ^ (uiStartVal))); |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], (uiStartVal)); |
| |
| if (Tmp_Address32[i++] != (~uiStartVal)) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, (~uiStartVal), (uiTemp ^ (~uiStartVal))); |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], (~uiStartVal)); |
| } |
| } |
| else |
| { |
| test_write_COMPLETEMENT((u32*)(long)uiSourceAddress, size_in_word, uiStartVal); |
| } |
| break; |
| |
| case DECREMENT: |
| //printf("Generating DECREMENT Pattern - uiStartVal=%08X\n", uiStartVal); |
| if (uiStartVal == 0) uiStartVal = 0xF0F0F0F0; |
| c_pattern = uiStartVal; |
| if (bCheck) |
| { |
| for (i = 0; i < size_in_word;) { |
| if (Tmp_Address32[i++] != c_pattern) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_pattern, (uiTemp ^ c_pattern)); |
| } |
| //else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], c_pattern); |
| |
| |
| if (Tmp_Address32[i++] != 0xFFFFFFFF) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, 0xFFFFFFFF, (uiTemp ^ 0xFFFFFFFF)); |
| } |
| //else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], 0xFFFFFFFF); |
| |
| if (c_pattern == 0) |
| c_pattern = uiStartVal; |
| else |
| c_pattern--; |
| |
| } |
| } |
| else |
| { |
| for (i = 0; i < size_in_word;) { |
| Tmp_Address32[i++] = c_pattern; |
| Tmp_Address32[i++] = 0xFFFFFFFF; |
| if (c_pattern == 0) |
| c_pattern = uiStartVal; |
| else |
| c_pattern--; |
| } |
| } |
| break; |
| |
| case INCREMENT: |
| //printf("Generating INCREMENT Pattern - uiStartVal=%08X\n", uiStartVal); |
| if (uiStartVal == 0xFFFFFFFF) uiStartVal = 0; |
| c_pattern = uiStartVal; |
| if (bCheck) |
| { |
| for (i = 0; i < size_in_word;) { |
| if (Tmp_Address32[i++] != c_pattern) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_pattern, (uiTemp ^ c_pattern)); |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], c_pattern); |
| |
| if (Tmp_Address32[i++] != 0) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, 0, (uiTemp ^ 0)); |
| } |
| //else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], 0); |
| |
| if (c_pattern == 0xFFFFFFFF) |
| c_pattern = 0; |
| else |
| c_pattern++; |
| |
| } |
| } |
| else |
| { |
| for (i = 0; i < size_in_word;) { |
| Tmp_Address32[i++] = c_pattern; |
| Tmp_Address32[i++] = 0; |
| |
| |
| if (c_pattern == 0xFFFFFFFF) |
| c_pattern = 0; |
| else |
| c_pattern++; |
| } |
| } |
| |
| break; |
| |
| case INCREMENTB: |
| //printf("Generating INCREMENTB Pattern - uiStartVal=%08X\n", c_zero); |
| c_pattern = uiStartVal; |
| if (bCheck) |
| { |
| for (i = 0; i < size_in_word;) { |
| if (Tmp_Address32[i++] != c_pattern) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X - DB=0x%08X - DA=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_pattern, (uiTemp ^ c_pattern), read_data_u32(uiSourceAddress + ((i - 1) * 4)), read_data_u32(uiSourceAddress + ((i + 1) * 4))); |
| expected = c_pattern; |
| #if 0 |
| process_fail(expected, uiTemp); |
| #endif |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], c_pattern); |
| |
| c_pattern += 0x04040404; |
| if ((c_pattern & 0xFF) == 0) c_pattern = uiStartVal; |
| |
| } |
| } |
| else |
| { |
| for (i = 0; i < size_in_word;) { |
| Tmp_Address32[i++] = c_pattern; |
| c_pattern += 0x04040404; |
| if ((c_pattern & 0xFF) == 0) c_pattern = uiStartVal; |
| |
| } |
| } |
| break; |
| |
| case MILLER_EFFECT: |
| //printf("Generating MILLER_EFFECT "); |
| c_pattern = 0x55555555; |
| //printf("Generating MILLER_EFFECT Pattern - uiStartVal=%08X\n", c_pattern); |
| if (bCheck) |
| { |
| for (i = 0; i < size_in_word;) |
| { |
| if (Tmp_Address32[i++] != (c_pattern)) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, (c_pattern), (uiTemp ^ (c_pattern))); |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], (c_pattern)); |
| |
| if (Tmp_Address32[i++] != (~c_pattern)) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, (~c_pattern), (uiTemp ^ (~c_pattern))); |
| |
| |
| } |
| //else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], (~c_pattern)); |
| } |
| } |
| else |
| { |
| for (i = 0; i < size_in_word;) { |
| Tmp_Address32[i++] = (c_pattern); |
| Tmp_Address32[i++] = (~c_pattern); |
| } |
| } |
| break; |
| |
| case ZERO_ROR_INVERT: |
| //printf("Generating ZERO_ROR_INVERT Pattern\n"); |
| if (bCheck) |
| { |
| for (i = 0; i < size_in_word;) |
| { |
| if (Tmp_Address32[i++] != (uiStartVal)) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, (uiStartVal), (uiTemp ^ (uiStartVal))); |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], (uiStartVal)); |
| |
| if (Tmp_Address32[i++] != (~uiStartVal)) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, (~uiStartVal), (uiTemp ^ (~uiStartVal))); |
| |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], (~uiStartVal)); |
| |
| uiStartVal = ror32_mcu(uiStartVal); |
| } |
| } |
| else |
| { |
| for (i = 0; i < size_in_word;) { |
| Tmp_Address32[i++] = (uiStartVal); |
| Tmp_Address32[i++] = (~uiStartVal); |
| uiStartVal = ror32_mcu(uiStartVal); |
| } |
| } |
| break; |
| |
| case ONE_ROL_INVERT: |
| //printf("Generating ONE_ROL_INVERT Pattern\n"); |
| if (bCheck) |
| { |
| for (i = 0; i < size_in_word;) |
| { |
| if (Tmp_Address32[i++] != (uiStartVal)) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, (uiStartVal), (uiTemp ^ (uiStartVal))); |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], (uiStartVal)); |
| |
| if (Tmp_Address32[i++] != (~uiStartVal)) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, (~uiStartVal), (uiTemp ^ (~uiStartVal))); |
| |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], (~uiStartVal)); |
| |
| uiStartVal = rol32_mcu(uiStartVal); |
| } |
| } |
| else |
| { |
| for (i = 0; i < size_in_word;) { |
| Tmp_Address32[i++] = (uiStartVal); |
| Tmp_Address32[i++] = (~uiStartVal); |
| uiStartVal = rol32_mcu(uiStartVal); |
| } |
| } |
| |
| break; |
| |
| case ZERO_ROR: |
| //printf("Generating ZERO_ROR Pattern\n"); |
| if (bCheck) |
| { |
| for (i = 0; i < size_in_word;) { |
| if (Tmp_Address32[i++] != (uiStartVal)) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X - DB=0x%08X - DA=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, (uiStartVal), (uiTemp ^ (uiStartVal)), read_data_u32(uiSourceAddress + ((i - 1) * 4)), read_data_u32(uiSourceAddress + ((i + 1) * 4))); |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + (i * 4)), Tmp_Address32[i - 1], (uiStartVal)); |
| |
| uiStartVal = ror32_mcu(uiStartVal); |
| } |
| } |
| else |
| { |
| for (i = 0; i < size_in_word;) { |
| Tmp_Address32[i++] = (uiStartVal); |
| uiStartVal = ror32_mcu(uiStartVal); |
| } |
| } |
| break; |
| |
| case ONE_ROL: |
| //printf("Generating ONE_ROL Pattern\n"); |
| if (bCheck) |
| { |
| for (i = 0; i < size_in_word;) { |
| if (Tmp_Address32[i++] != (uiStartVal)) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X - DB=0x%08X - DA=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, (uiStartVal), (uiTemp ^ (uiStartVal)), read_data_u32(uiSourceAddress + ((i - 1) * 4)), read_data_u32(uiSourceAddress + ((i + 1) * 4))); |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], (uiStartVal)); |
| |
| uiStartVal = rol32_mcu(uiStartVal); |
| } |
| } |
| else |
| { |
| for (i = 0; i < size_in_word;) { |
| Tmp_Address32[i++] = (uiStartVal); |
| uiStartVal = rol32_mcu(uiStartVal); |
| } |
| } |
| break; |
| |
| case WALKING_ONES: |
| //printf("Generating WALKING_ONES Pattern\n"); |
| i = 0; |
| if (bCheck) |
| { |
| for (j = 0; j < size_in_word;) |
| { |
| if (Tmp_Address32[j++] != (1 << i)) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[j - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((j - 1) * 4)), uiTemp, (1 << i), (uiTemp ^ (1 << i))); |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((j - 1) * 4)), Tmp_Address32[j - 1], ~(1 << i)); |
| |
| if (Tmp_Address32[j++] != 0xFFFFFFFF) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[j - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((j - 1) * 4)), uiTemp, 0xFFFFFFFF, (uiTemp ^ 0xFFFFFFFF)); |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((j - 1) * 4)), Tmp_Address32[j - 1], 0xFFFFFFFF); |
| |
| |
| i++; |
| if (i >= 32) i = 0; |
| } |
| } |
| else |
| { |
| for (j = 0; j < size_in_word; ) |
| { |
| Tmp_Address32[j++] = (u32)(1 << i); |
| Tmp_Address32[j++] = 0xFFFFFFFF; |
| |
| i++; |
| if (i >= 32) i = 0; |
| } |
| } |
| break; |
| |
| case WALKING_ZEROS: |
| //printf("Generating WALKING_ZEROS Pattern\n"); |
| i = 0; |
| if (bCheck) |
| { |
| for (j = 0; j < size_in_word;) |
| { |
| if (Tmp_Address32[j++] != ~(1 << i)) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[j - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((j - 1) * 4)), uiTemp, ~(1 << i), (uiTemp ^ ~(1 << i))); |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((j - 1) * 4)), Tmp_Address32[j - 1], ~(1 << i)); |
| |
| if (Tmp_Address32[j++] != 0) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[j - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((j - 1) * 4)), uiTemp, 0, (uiTemp ^ 0)); |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((j - 1) * 4)), Tmp_Address32[j - 1], 0); |
| |
| |
| i++; |
| if (i >= 32) i = 0; |
| } |
| } |
| else |
| { |
| for (j = 0; j < size_in_word; ) |
| { |
| Tmp_Address32[j++] = (u32)~(1 << i); |
| Tmp_Address32[j++] = 0; |
| |
| i++; |
| if (i >= 32) i = 0; |
| } |
| } |
| break; |
| |
| case SSTAILGATE_0101XXXX: //SSTAILGATE 0101XXXX |
| value = 0xFFFEFFFE; |
| //printf("Generating WALKING_ZEROS Pattern\n"); |
| i = 0; |
| if (bCheck) |
| { |
| for (j = 0; j < size_in_word;) |
| { |
| if (Tmp_Address32[j++] != value) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[j - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((j - 1) * 4)), uiTemp, value, (uiTemp ^ value)); |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((j - 1) * 4)), Tmp_Address32[j - 1], value); |
| |
| if (Tmp_Address32[j++] != 0) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[j - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((j - 1) * 4)), uiTemp, 0, (uiTemp ^ 0)); |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((j - 1) * 4)), Tmp_Address32[j - 1], 0); |
| |
| value = ror32_mcu(value); |
| } |
| } |
| else |
| { |
| for (j = 0; j < size_in_word; ) |
| { |
| Tmp_Address32[j++] = value; |
| Tmp_Address32[j++] = 0; |
| value = ror32_mcu(value); |
| } |
| } |
| break; |
| |
| case SSTAILGATE_01010000: //SSTAILGATE 0101XXXX |
| value = 0xFEFEFEFE; |
| //printf("Generating WALKING_ZEROS Pattern\n"); |
| i = 0; |
| if (bCheck) |
| { |
| for (j = 0; j < size_in_word;) |
| { |
| if (Tmp_Address32[j++] != value) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[j - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((j - 1) * 4)), uiTemp, value, (uiTemp ^ value)); |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((j - 1) * 4)), Tmp_Address32[j - 1], value); |
| |
| if (Tmp_Address32[j++] != 0) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[j - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((j - 1) * 4)), uiTemp, 0, (uiTemp ^ 0)); |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((j - 1) * 4)), Tmp_Address32[j - 1], 0); |
| |
| value = ror32_mcu(value); |
| } |
| } |
| else |
| { |
| for (j = 0; j < size_in_word; ) |
| { |
| Tmp_Address32[j++] = value; |
| Tmp_Address32[j++] = 0; |
| value = ror32_mcu(value); |
| } |
| } |
| break; |
| |
| case SSTAILGATE_01011111: //SSTAILGATE 0101XXXX |
| case MSTAILGATE: |
| //printf("Generating SSTAILGATE_0101 Pattern\n"); |
| if (uiPattern == SSTAILGATE_01011111) |
| uiStartVal = 0x00000001; |
| else if (uiPattern == MSTAILGATE) |
| uiStartVal = 0xFFFFFFFF; |
| |
| c_pattern = (uiStartVal); |
| c_pattern_or_signal = (uiStartVal | test_signal); |
| |
| if (bCheck) |
| { |
| for (i = 0; i < size_in_word;) |
| { |
| if (Tmp_Address32[i++] != c_zero) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_zero, (uiTemp ^ c_zero)); |
| |
| |
| } |
| else if (Tmp_Address32[i++] != c_pattern_or_signal) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_pattern_or_signal, (uiTemp ^ c_pattern_or_signal)); |
| |
| } |
| else if (Tmp_Address32[i++] != c_zero) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_zero, (uiTemp ^ c_zero)); |
| |
| } |
| else if (Tmp_Address32[i++] != c_pattern_or_signal) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_pattern_or_signal, (uiTemp ^ c_pattern_or_signal)); |
| |
| } |
| else if (Tmp_Address32[i++] != c_pattern) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_pattern, (uiTemp ^ c_pattern)); |
| |
| } |
| else if (Tmp_Address32[i++] != c_pattern) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_pattern, (uiTemp ^ c_pattern)); |
| |
| } |
| else if (Tmp_Address32[i++] != c_pattern) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_pattern, (uiTemp ^ c_pattern)); |
| |
| } |
| else if (Tmp_Address32[i++] != c_pattern) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_pattern, (uiTemp ^ c_pattern)); |
| |
| } |
| // else |
| // printf("PASS - pa%d all data\n", uiPattern); |
| |
| } |
| } |
| else |
| { |
| for (i = 0; i < size_in_word;) |
| { |
| Tmp_Address32[i++] = c_zero; |
| Tmp_Address32[i++] = c_pattern_or_signal; |
| Tmp_Address32[i++] = c_zero; |
| Tmp_Address32[i++] = c_pattern_or_signal; |
| Tmp_Address32[i++] = c_pattern; |
| Tmp_Address32[i++] = c_pattern; |
| Tmp_Address32[i++] = c_pattern; |
| Tmp_Address32[i++] = c_pattern; |
| } |
| } |
| break; |
| |
| case SSTAILGATE_01011010: //SSTAILGATE 01011010 |
| //printf("Generating SSTAILGATE_1100 Pattern\n"); |
| uiStartVal = 0x00000001; |
| c_pattern = (uiStartVal); |
| c_pattern_or_signal = (uiStartVal | test_signal); |
| |
| if (bCheck) |
| { |
| for (i = 0; i < size_in_word;) |
| { |
| if (Tmp_Address32[i++] != c_zero) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_zero, (uiTemp ^ c_zero)); |
| |
| |
| } |
| else if (Tmp_Address32[i++] != c_pattern_or_signal) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_pattern_or_signal, (uiTemp ^ c_pattern_or_signal)); |
| |
| } |
| else if (Tmp_Address32[i++] != c_zero) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_zero, (uiTemp ^ c_zero)); |
| |
| } |
| else if (Tmp_Address32[i++] != c_pattern_or_signal) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_pattern_or_signal, (uiTemp ^ c_pattern_or_signal)); |
| |
| } |
| else if (Tmp_Address32[i++] != c_pattern) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_pattern, (uiTemp ^ c_pattern)); |
| |
| } |
| else if (Tmp_Address32[i++] != c_zero) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_zero, (uiTemp ^ c_zero)); |
| |
| } |
| else if (Tmp_Address32[i++] != c_pattern) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_pattern, (uiTemp ^ c_pattern)); |
| |
| } |
| else if (Tmp_Address32[i++] != c_zero) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_zero, (uiTemp ^ c_zero)); |
| |
| } |
| // else |
| // printf("PASS - pa%d all data\n", uiPattern); |
| |
| uiStartVal = rol32_mcu(uiStartVal); |
| test_signal = rol32_mcu(test_signal); |
| |
| c_pattern = (uiStartVal); |
| c_pattern_or_signal = (uiStartVal | test_signal); |
| |
| |
| } |
| } |
| else |
| { |
| for (i = 0; i < size_in_word;) |
| { |
| Tmp_Address32[i++] = c_zero; |
| Tmp_Address32[i++] = c_pattern_or_signal; |
| Tmp_Address32[i++] = c_zero; |
| Tmp_Address32[i++] = c_pattern_or_signal; |
| Tmp_Address32[i++] = c_pattern; |
| Tmp_Address32[i++] = c_zero; |
| Tmp_Address32[i++] = c_pattern; |
| Tmp_Address32[i++] = c_zero; |
| |
| uiStartVal = rol32_mcu(uiStartVal); |
| test_signal = rol32_mcu(test_signal); |
| |
| c_pattern = (uiStartVal); |
| c_pattern_or_signal = (uiStartVal | test_signal); |
| } |
| } |
| break; |
| |
| case FREQ_SWEEP: |
| //printf("Generating FREQ_SWEEP Pattern\n"); |
| i = 0; |
| c_pattern = (c_zero); |
| c_pattern_or_signal = (~c_zero); |
| for (j = 1; j < size_in_word / 2; j++) |
| { |
| k = 0; |
| while (k < j) |
| { |
| if (bCheck) |
| { |
| if (Tmp_Address32[i++] != c_pattern) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X - DB=0x%08X - DA=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_pattern, (uiTemp ^ c_pattern), read_data_u32(uiSourceAddress + ((i - 1) * 4)), read_data_u32(uiSourceAddress + ((i + 1) * 4))); |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], c_pattern); |
| } |
| else |
| { |
| Tmp_Address32[i++] = c_pattern; |
| } |
| k++; |
| if (i >= size_in_word) |
| break; |
| } |
| if (i >= size_in_word) |
| break; |
| |
| k = 0; |
| while (k < j) |
| { |
| if (bCheck) |
| { |
| if (Tmp_Address32[i++] != c_pattern_or_signal) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X - DB=0x%08X - DA=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_pattern_or_signal, (uiTemp ^ c_pattern_or_signal), read_data_u32(uiSourceAddress + ((i - 1) * 4)), read_data_u32(uiSourceAddress + ((i + 1) * 4))); |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], c_pattern_or_signal); |
| } |
| else |
| { |
| Tmp_Address32[i++] = c_pattern_or_signal; |
| } |
| k++; |
| if (i >= size_in_word) |
| break; |
| } |
| if (i >= size_in_word) |
| break; |
| } |
| break; |
| |
| case VERT_INCREMENT: |
| //printf("Generating VERT_INCREMENT Pattern\n"); |
| c_pattern = (uiStartVal); |
| if (bCheck) |
| { |
| for (i = 0; i < size_in_word;) { |
| if (Tmp_Address32[i++] != c_pattern) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X - DB=0x%08X - DA=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_pattern, (uiTemp ^ c_pattern), read_data_u32(uiSourceAddress + ((i - 1) * 4)), read_data_u32(uiSourceAddress + ((i + 1) * 4))); |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], c_pattern); |
| |
| c_pattern++; |
| } |
| } |
| else |
| { |
| for (i = 0; i < size_in_word;) { |
| Tmp_Address32[i++] = c_pattern; |
| c_pattern++; |
| } |
| } |
| break; |
| |
| case HORZ_INCREMENT: |
| //printf("Generating HORZ_INCREMENT Pattern\n"); |
| c_pattern = 0x00000001; |
| i = 0; |
| for (k = 0; k < (size_in_word / 16); k++) |
| { |
| for (j = 0; j < 16; j++) |
| { |
| if ((j % 2) == 1) { // ODD |
| if (bCheck) |
| { |
| if (Tmp_Address32[i++] != c_pattern) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X - DB=0x%08X - DA=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_pattern, (uiTemp ^ c_pattern), read_data_u32(uiSourceAddress + ((i - 1) * 4)), read_data_u32(uiSourceAddress + ((i + 1) * 4))); |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], c_pattern); |
| } |
| else |
| { |
| Tmp_Address32[i++] = c_pattern; |
| } |
| } |
| else { // EVEN |
| if (bCheck) |
| { |
| if (Tmp_Address32[i++] != c_zero) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X - DB=0x%08X - DA=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_zero, (uiTemp ^ c_zero), read_data_u32(uiSourceAddress + ((i - 1) * 4)), read_data_u32(uiSourceAddress + ((i + 1) * 4))); |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], c_zero); |
| } |
| else |
| { |
| Tmp_Address32[i++] = c_zero; |
| } |
| } |
| if (i >= size_in_word) |
| break; |
| if (((j % 4) / 2) == 1) { // {2,3,6,7,10,11,14,15} |
| if (bCheck) |
| { |
| if (Tmp_Address32[i++] != c_pattern) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X - DB=0x%08X - DA=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_pattern, (uiTemp ^ c_pattern), read_data_u32(uiSourceAddress + ((i - 1) * 4)), read_data_u32(uiSourceAddress + ((i + 1) * 4))); |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], c_pattern); |
| } |
| else |
| { |
| Tmp_Address32[i++] = c_pattern; |
| } |
| } |
| else { // {0,1,4,5,8,9,12,13} |
| if (bCheck) |
| { |
| if (Tmp_Address32[i++] != c_zero) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X - DB=0x%08X - DA=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_zero, (uiTemp ^ c_zero), read_data_u32(uiSourceAddress + ((i - 1) * 4)), read_data_u32(uiSourceAddress + ((i + 1) * 4))); |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], c_zero); |
| } |
| else |
| { |
| Tmp_Address32[i++] = c_zero; |
| } |
| } |
| if (i >= size_in_word) |
| break; |
| if (((j % 8) / 4) == 1) { // {4,5,6,7,12,13,14,15} |
| if (bCheck) |
| { |
| if (Tmp_Address32[i++] != c_pattern) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X - DB=0x%08X - DA=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_pattern, (uiTemp ^ c_pattern), read_data_u32(uiSourceAddress + ((i - 1) * 4)), read_data_u32(uiSourceAddress + ((i + 1) * 4))); |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], c_pattern); |
| } |
| else |
| { |
| Tmp_Address32[i++] = c_pattern; |
| //printf("i(%d) - j(%d) = %08X\n",i,j,c_pattern); |
| } |
| } |
| else { // {0,1,2,3,8,9,10,11} |
| if (bCheck) |
| { |
| |
| if (Tmp_Address32[i++] != c_zero) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X - DB=0x%08X - DA=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_zero, (uiTemp ^ c_zero), read_data_u32(uiSourceAddress + ((i - 1) * 4)), read_data_u32(uiSourceAddress + ((i + 1) * 4))); |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], c_zero); |
| } |
| else |
| { |
| Tmp_Address32[i++] = c_zero; |
| //printf("i(%d) - j(%d) = %08X\n",i,j,c_zero); |
| } |
| } |
| if (i >= size_in_word) |
| break; |
| if ((j / 8) == 1) { // {8 - 15} |
| if (bCheck) |
| { |
| if (Tmp_Address32[i++] != c_pattern) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X - DB=0x%08X - DA=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_pattern, (uiTemp ^ c_pattern), read_data_u32(uiSourceAddress + ((i - 1) * 4)), read_data_u32(uiSourceAddress + ((i + 1) * 4))); |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], c_pattern); |
| } |
| else |
| { |
| Tmp_Address32[i++] = c_pattern; |
| //printf("i(%d) - j(%d) = %08X\n",i,j,c_pattern); |
| } |
| } |
| else { // {0 - 7} |
| if (bCheck) |
| { |
| if (Tmp_Address32[i++] != c_zero) |
| { |
| uiFails++; |
| uiTemp = Tmp_Address32[i - 1]; |
| printf( "FAIL! pa%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X - DB=0x%08X - DA=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), uiTemp, c_zero, (uiTemp ^ c_zero), read_data_u32(uiSourceAddress + ((i - 1) * 4)), read_data_u32(uiSourceAddress + ((i + 1) * 4))); |
| |
| } |
| // else |
| // printf("PASS - pa%d:[@0x%08lx]=0x%08X Exp=0x%08X\n", uiPattern, (uiSourceAddress + ((i - 1) * 4)), Tmp_Address32[i - 1], c_zero); |
| } |
| else |
| { |
| Tmp_Address32[i++] = c_zero; |
| } |
| } |
| if (i >= size_in_word) |
| break; |
| } |
| if (i >= size_in_word) |
| break; |
| |
| c_pattern = rol32_mcu(c_pattern); |
| } |
| break; |
| |
| default: |
| printf("No option with uipat[%d ]\n", uiPattern); |
| break; |
| |
| } |
| |
| if (uiFails) |
| { |
| giPatternNumOfFails[uiPattern] += uiFails; |
| giPatternFails[uiPattern]++; |
| } |
| return uiFails; |
| } |
| |
| static u32 mem_all_pattern_test(u32 uiStartBase, u32 uiSize) |
| { |
| u32 fail_cnt = 0, total_fail = 0, pattern = 0; |
| u32 bResult = DDR_TEST_FAIL; |
| u32 uiStartVal[10] = { 0xa5a5a5a5, 0xA5A50000, 0x2d2d2d2d, 0x5a5a5a5a, 0x89abcdef, |
| 0xD2D2D2D2, 0x01010101, 0xECA86420, 0x00000000, 0xFFFFFFFF }; |
| unsigned long uiSource = 0; |
| int trace_print_level = 0; |
| // only test width with 32b and 64b as the limited size of SQU |
| for (pattern = ANALOG; pattern <= HORZ_INCREMENT; pattern++) |
| // for(pattern = 8; pattern <= HORZ_INCREMENT; pattern++) |
| { |
| //temp = (pattern - ANALOG); |
| //uiSource = uiStartBase + temp*uiSize; |
| uiSource = uiStartBase; |
| |
| printf( "[0x%08lx: 0x%X %d] D[0x%08X]", uiSource, uiSize, pattern, uiStartVal[pattern % 10]); |
| allp_mcuGenerateWordPattern(uiSource, pattern, (uiSize / WORD_SIZE), uiStartVal[pattern % 10], 0); |
| fail_cnt += allp_mcuGenerateWordPattern(uiSource, pattern, (uiSize / WORD_SIZE), uiStartVal[pattern % 10], 1); |
| |
| if (fail_cnt) |
| printf( "\n***FAIL*** pattern test failed=%d times - Address[0x%08lx] - Pattern[%d] - Start Value[0x%08X], Size=[0x%x]B\n", fail_cnt, uiSource, pattern, uiStartVal[pattern % 10], uiSize); |
| else |
| printf("-P\n"); |
| |
| total_fail += fail_cnt; |
| |
| if (total_fail) //break on any fail |
| break; |
| } |
| |
| if (total_fail == 0) |
| { |
| bResult = DDR_TEST_PASS; |
| printf( "===OK=== all pattern tests ok - Address[0x%08lx], Size=[0x%x]B\n\n", uiSource, uiSize); |
| } |
| else |
| { |
| bResult = DDR_TEST_FAIL; |
| printf( "===FAIL=== all pattern tests failed - total_fail=%d, Address[0x%08lx], Size=[0x%x]B\n\n", total_fail, uiSource, uiSize); |
| } |
| |
| return bResult; |
| } |
| |
| #else //CONFIG_USE_DDR_ALL_PATTERN |
| |
| static u32 mem_data16_pattern_test(u32 uiStartBase, u32 uiSize) |
| { |
| u32 i=0,j=0,k=0; |
| u32 data=0; |
| u32 err=0; |
| u32 start_addr=0x7e000000; |
| u32 len=0x400000; |
| u32 bResult = DDR_TEST_FAIL; |
| static u32 test_pattern[NR_TEST_PATTERN] = { |
| 0x01010101,0x02020202,0x04040404,0x08080808, |
| 0x10101010,0x20202020,0x40404040,0x80808080, |
| 0xFEFEFEFE,0xFDFDFDFD,0xFBFBFBFB,0xF7F7F7F7, |
| 0xEFEFEFEF,0xDFDFDFDF,0xBFBFBFBF,0x7F7F7F7F, |
| }; |
| //u32 local_test_pattern[NR_TEST_PATTERN]; |
| |
| printf("mem_data16_pattern_test [0x%08x-->0x%08x]!!!\n", |
| uiStartBase, uiStartBase + uiSize); |
| |
| start_addr = uiStartBase; |
| len = uiSize; |
| len &= (~(sizeof(test_pattern) - 1)); |
| printf("len: %x\n", len); |
| |
| #if 1 |
| for(j = 0; j <= 15; j++) |
| { |
| for(i = 0; i< len/4; i++) |
| { |
| data_write32(start_addr + i*4, test_pattern[j]); |
| } |
| flush_dcache_all(); |
| |
| for(i = 0; i < len/4; i++) |
| { |
| data = data_read32(start_addr + i*4); |
| if(data != test_pattern[j]) |
| { |
| printf("FAIL! data%d:[@0x%08lx]=0x%08X Exp=0x%08X - Dif=0x%08X\n",j,start_addr+i*4,data,test_pattern[j],(data^test_pattern[j])); |
| err++; |
| } |
| } |
| } |
| #else |
| for (i = 0; i < NR_TEST_PATTERN; i++) { |
| /* prepare pattern data */ |
| for (j = 0; j < NR_TEST_PATTERN; j++) { |
| local_test_pattern[j] = test_pattern[i]; |
| } |
| |
| for (j = 0; j < len; j += sizeof(local_test_pattern)) { |
| memcpy((void *)(start_addr + j), (void *)local_test_pattern, sizeof(local_test_pattern)); |
| } |
| flush_dcache_all(); |
| |
| for (j = 0; j < len; j += sizeof(local_test_pattern)) { |
| memcpy(local_test_pattern, (void *)(start_addr + j), sizeof(local_test_pattern)); |
| for (k = 0; k < NR_TEST_PATTERN; k++) { |
| if (local_test_pattern[k] != test_pattern[i]) { |
| err++; |
| printf("mem err: wr 0x%08x rd 0x%08x @0x%08x\n", |
| test_pattern[i], local_test_pattern[k], |
| (start_addr + j + k)); |
| } |
| } |
| } |
| } |
| #endif |
| if (err == 0) |
| { |
| bResult = DDR_TEST_PASS; |
| printf("===PASS=== all data tests passed - StartAddress[0x%08lx], Size=[0x%x]B\n\n",start_addr,len); |
| } |
| else |
| { |
| bResult = DDR_TEST_FAIL; |
| printf("===FAIL=== all data tests passed - total_fail=%d, StartAddress[0x%08lx], Size=[0x%x]B\n\n",err, start_addr, len); |
| } |
| |
| return bResult; |
| } |
| #endif |
| |
| u32 asr_ddr_pattern_test(u32 uiStartBase, u32 uiSize) |
| { |
| u32 ret; |
| |
| #ifdef CONFIG_USE_DDR_ALL_PATTERN |
| ret = mem_all_pattern_test(uiStartBase, uiSize); |
| #else |
| ret = mem_data16_pattern_test(uiStartBase, uiSize); |
| #endif |
| return ret; |
| } |
| |
| #define SINGLE_MALLOC_LEN (1024 * 1024) |
| #define LOW_PP_TEST_SIZE (10 * 1024 *1024) |
| |
| __weak int switch_low_pp_and_dvc(bool set_low, bool restore, u32 target_dop) {return 0;} |
| extern int hold_cpdsp_in_reset(void); |
| /* |
| * NOTE: should be very careful about the ddr test ranges |
| */ |
| int do_uboot_mem_test(u32 ddr_end_addr, u32 sec_ddr_start, u32 sec_ddr_end) |
| { |
| int i, ret = DDR_TEST_PASS; |
| u32 malloc_bufs[CONFIG_SYS_LONG_MALLOC_LEN / SINGLE_MALLOC_LEN]; |
| u32 reg_sp = 0x100000; |
| u32 nr_test_array = ARRAY_SIZE(ddr_test_ranges); |
| u32 obm_test_res; |
| |
| p_asr_flag = get_asr_flag(); |
| |
| printf("mem test: asr flag header: %x\n", p_asr_flag->header); |
| if(p_asr_flag->header != ASRFLAG_HEADER) { |
| printf("!!!! asr flag error\n"); |
| return 1; |
| } |
| |
| printf("asr flag ddrt_state: %x\n", p_asr_flag->ddrt_state.value); |
| |
| if (p_asr_flag->ddrt_state.bits.test_proc != 1) |
| return 1; |
| |
| if (ddr_test_is_done_obm(&obm_test_res)) { |
| if (obm_test_res == DDR_TEST_FAIL) { |
| printf("DDR test in OBM failed\n"); |
| p_asr_flag->ddrt_state.bits.total_times++; |
| p_asr_flag->ddrt_state.bits.fail_times++; |
| ret = DDR_TEST_FAIL; |
| goto finalize_result; |
| } else { |
| printf("DDR test in OBM PASS\n"); |
| } |
| } else { |
| printf("No ddr test in OBM\n"); |
| } |
| |
| /* hold cp/dsp in reset to stop running in ddr */ |
| hold_cpdsp_in_reset(); |
| |
| /* initially set fail res to avoid sw panic during test */ |
| p_asr_flag->ddrt_state.bits.total_times++; |
| p_asr_flag->ddrt_state.bits.fail_times++; |
| p_asr_flag->ddrt_state.bits.test_proc = 0; /* to avoid endless reboot */ |
| p_asr_flag->ddrt_state.bits.last_res = 1; /* fail */ |
| asr_flag_update(); |
| |
| #ifdef CONFIG_TEE_OS |
| for (i = 0; i < ARRAY_SIZE(ddr_test_ranges); i++) { |
| if (ddr_test_ranges[i].ddr_mtest_end == CONFIG_SEC_DDR_ADDR_BEGIN) |
| ddr_test_ranges[i].ddr_mtest_end = sec_ddr_start; |
| |
| if (ddr_test_ranges[i].ddr_mtest_end == CONFIG_DDR_ADDR_END) |
| ddr_test_ranges[i].ddr_mtest_end = ddr_end_addr; |
| |
| if (ddr_test_ranges[i].ddr_mtest_begin == CONFIG_SEC_DDR_ADDR_END) |
| ddr_test_ranges[i].ddr_mtest_begin = sec_ddr_end; |
| } |
| #else |
| for (i = 0; i < ARRAY_SIZE(ddr_test_ranges); i++) { |
| if (ddr_test_ranges[i].ddr_mtest_end == CONFIG_DDR_ADDR_END) |
| ddr_test_ranges[i].ddr_mtest_end = ddr_end_addr; |
| } |
| #endif |
| |
| for (i = 0; i < ARRAY_SIZE(ddr_test_ranges); i++) { |
| ret = asr_ddr_pattern_test(ddr_test_ranges[i].ddr_mtest_begin, |
| ddr_test_ranges[i].ddr_mtest_end - ddr_test_ranges[i].ddr_mtest_begin); |
| if (DDR_TEST_FAIL == ret) { |
| break; |
| } |
| } |
| |
| if (i == ARRAY_SIZE(ddr_test_ranges) && (ret == DDR_TEST_PASS)) { |
| |
| for (i = 0; i < (CONFIG_SYS_LONG_MALLOC_LEN / SINGLE_MALLOC_LEN); i++) |
| malloc_bufs[i] = 0; |
| |
| for (i = 0; i < (CONFIG_SYS_LONG_MALLOC_LEN / SINGLE_MALLOC_LEN); i++) { |
| malloc_bufs[i] = memalign(4, SINGLE_MALLOC_LEN); |
| printf("malloc_buf[%d]: 0x%08x, size: 0x%08x\n", i, malloc_bufs[i], SINGLE_MALLOC_LEN); |
| if (malloc_bufs[i]) { |
| ret = asr_ddr_pattern_test(malloc_bufs[i], SINGLE_MALLOC_LEN); |
| if (DDR_TEST_FAIL == ret) { |
| printf("!!!%s: ddr test failed in mallc buffer\n", __func__); |
| break; |
| } |
| } else { |
| ret = DDR_TEST_PASS; |
| printf("%s: no malloc buffer available now\n", __func__); |
| break; |
| } |
| } |
| |
| for (i = 0; i < (CONFIG_SYS_LONG_MALLOC_LEN / SINGLE_MALLOC_LEN); i++) { |
| if (malloc_bufs[i]) { |
| printf("free buf[%d]: 0x%08x\n", i, malloc_bufs[i]); |
| free(malloc_bufs[i]); |
| } |
| } |
| |
| } else { |
| ret = DDR_TEST_FAIL; |
| } |
| |
| /* cpu low + ddr 266 */ |
| if (DDR_TEST_PASS == ret) { |
| switch_low_pp_and_dvc(1, 0, 0); |
| ret = asr_ddr_pattern_test(ddr_test_ranges[nr_test_array - 1].ddr_mtest_end - LOW_PP_TEST_SIZE, LOW_PP_TEST_SIZE); |
| if (DDR_TEST_FAIL == ret) { |
| printf("!!!%s: low ddr-266 test failed\n", __func__); |
| } else { |
| ret = DDR_TEST_PASS; |
| } |
| switch_low_pp_and_dvc(0, 1, 0); |
| } |
| |
| /* cpu low + ddr 533 */ |
| if (DDR_TEST_PASS == ret) { |
| switch_low_pp_and_dvc(1, 0, 1); |
| ret = asr_ddr_pattern_test(ddr_test_ranges[nr_test_array - 1].ddr_mtest_end - LOW_PP_TEST_SIZE, LOW_PP_TEST_SIZE); |
| if (DDR_TEST_FAIL == ret) { |
| printf("!!!%s: low ddr-533 test failed\n", __func__); |
| } else { |
| ret = DDR_TEST_PASS; |
| } |
| switch_low_pp_and_dvc(0, 1, 1); |
| } |
| |
| if (DDR_TEST_PASS == ret) { |
| __asm__ __volatile__("mov %0, sp":"=r"(reg_sp)::"memory"); |
| printf("cpu sp: 0x%x\n", reg_sp); |
| reg_sp -= 0x8000; /* leave 32KB gap */ |
| reg_sp &= ~(0x8000 - 1); |
| printf("cpu sp: 0x%x\n", reg_sp); |
| if (((CONFIG_SYS_TEXT_BASE - 0x8000) < reg_sp) && (reg_sp < CONFIG_SYS_LONG_RELOC_END)) { |
| ret = asr_ddr_pattern_test((CONFIG_SYS_TEXT_BASE - 0x8000), reg_sp - (CONFIG_SYS_TEXT_BASE - 0x8000)); |
| if (DDR_TEST_FAIL == ret) { |
| printf("!!!%s: ddr test failed in stack area\n", __func__); |
| } else { |
| ret = DDR_TEST_PASS; |
| } |
| } |
| } |
| |
| finalize_result: |
| if (DDR_TEST_FAIL == ret) { |
| printf("!!!%s: total test FAIL\n", __func__); |
| p_asr_flag->ddrt_state.bits.last_res = 1; /* fail */ |
| p_asr_flag->ddrt_state.bits.test_proc = 0; /* clear */ |
| } else { |
| printf("$$$%s: total test PASS\n", __func__); |
| p_asr_flag->ddrt_state.bits.last_res = 0; /* pass */ |
| p_asr_flag->ddrt_state.bits.test_proc = 0; /* clear */ |
| p_asr_flag->ddrt_state.bits.fail_times--; |
| } |
| printf("asr flag ddrt_state: %x\n", p_asr_flag->ddrt_state.value); |
| asr_flag_update(); |
| printf("reset cpu\n"); |
| run_command("reset", 0); |
| udelay(1000 * 1000); |
| printf("error: sys reset failed\n"); |
| } |
| |
| static int do_devtest(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| { |
| ulong addr, ddr_len, count, i, ret; |
| |
| if ((argc < 3) || (argc > 5)) |
| return CMD_RET_USAGE; |
| |
| addr = simple_strtoul(argv[1], NULL, 16); |
| |
| /* Get the length to test. |
| */ |
| ddr_len = simple_strtoul(argv[2], NULL, 16); |
| |
| /* loop Count */ |
| if (argc == 4) { |
| count = simple_strtoul(argv[3], NULL, 16); |
| } else { |
| count = 1; |
| } |
| |
| for (i = 0; i < count; i++) { |
| ret = asr_ddr_pattern_test(addr, ddr_len); |
| if (DDR_TEST_FAIL == ret) { |
| printf("ddr test FAIL\n"); |
| break; |
| } |
| } |
| return 0; |
| } |
| |
| U_BOOT_CMD( |
| devtest, 4, 0, do_devtest, |
| "ddr device test cmd\n", |
| "devtest addr len loops" |
| ); |
| |