6 /*******************************************************************************
8 * Name : mem_data_bus_test
9 * Description : The function tests data bus of the DRAM. It writes walking one
10 * pattern to a fixed memory location.
13 * Return : Returns 1 on failure, else 0
14 *******************************************************************************/
16 int mem_data_bus_test(void)
18 unsigned int pattern
= 1;
19 unsigned int *address
= mem_test_start_offset
;
21 printf("\tDDR2 data bus test ");
23 for(; pattern
!= 0; pattern
<<= 1)
27 if(pattern
!= *address
)
30 printf("\t\tTest failed at offset = 0x%X\n"
31 "\t\tData written = 0x%X\n"
32 "\t\tData read = 0x%X\n", address
,
41 /*******************************************************************************
43 * Name : mem_address_bus_test
44 * Description : The function tests address bus of the DRAM. It writes walking
45 * one pattern while changes the addresses in the same way. i.e.
46 * write 1 to offset 1, 8 to offset 8, etc. Verify the data after
47 * writting to the buffer with length MEM_ADD_TEST_SIZE.
50 * Return : Returns 1 on failure, else 0
51 *******************************************************************************/
53 int mem_address_bus_test(void)
55 unsigned int offset
= 1, size
;
56 unsigned int *base_address
= mem_test_start_offset
;
58 size
= mem_test_end_offset
- mem_test_start_offset
;
60 printf("\tDDR2 address bus test ");
62 /* We should start with pattern = 1. As we want to use offset and
63 * pattern the same variable, we will decrement base address by 1.
64 * So, even if we start with offset = pattern = 1, we have actually
65 * started from the given base address. */
68 for(; offset
< size
; offset
<<= 1)
70 base_address
[offset
] = offset
;
73 for(offset
= 1; offset
< size
; offset
<<= 1)
75 if(base_address
[offset
] != offset
)
78 printf("\t\tTest failed at offset = 0x%X\n"
79 "\t\tData written = 0x%X\n"
80 "\t\tData read = 0x%X\n", base_address
81 + offset
, offset
, base_address
[offset
]);
89 /*******************************************************************************
91 * Name : mem_device_test
92 * Description : The function tests address bus of the DRAM. It writes walking
93 * one pattern while changes the addresses in the same way. i.e.
94 * write 1 to offset 1, 8 to offset 8, etc. Verify the data after
95 * writting to the buffer with length MEM_ADD_TEST_SIZE.
98 * Return : Returns 1 on failure, else 0
99 *******************************************************************************/
101 int mem_device_test(void)
103 unsigned int offset
= 1, size
;
104 unsigned int *base_address
= mem_test_start_offset
;
106 size
= mem_test_end_offset
- mem_test_start_offset
;
108 printf("\tDDR2 device test ");
112 printf("Start address = %#X\n", base_address
);
113 printf("size = %#X\n", size
);
116 /* We should start with pattern = 1. As we want to use offset and
117 * pattern the same variable, we will decrement base address by 1.
118 * So, even if we start with offset = pattern = 1, we have actually
119 * started from the given base address. */
122 for(; offset
< size
; offset
++)
124 base_address
[offset
] = offset
;
127 /* Check previously written pattern and write anti-pattern */
128 for(offset
= 1; offset
< size
; offset
++)
130 if(base_address
[offset
] != offset
)
133 printf("\t\tTest failed at offset = 0x%X\n"
134 "\t\tData written = 0x%X\n"
135 "\t\tData read = 0x%X\n", base_address
136 + offset
, offset
, base_address
[offset
]);
140 /* Write anti-pattern */
141 base_address
[offset
] = ~offset
;
146 printf("Checking anti-pattern\n");
149 /* Check anti-pattern */
150 for(offset
= 1; offset
< size
; offset
++)
152 if(base_address
[offset
] != ~offset
)
155 printf("\t\tTest failed at offset = 0x%X\n"
156 "\t\tData written = 0x%X\n"
157 "\t\tData read = 0x%X\n", base_address
158 + offset
, ~offset
, base_address
[offset
]);