software/liblitedram/sdram.c: move activate/precharge to sdram_write_read_check_test_pattern, change second seed.

This commit is contained in:
Florent Kermarrec 2020-10-12 13:00:44 +02:00
parent d1f04e67c5
commit d4d4ca53b0
1 changed files with 10 additions and 16 deletions

View File

@ -668,6 +668,9 @@ static int sdram_write_read_check_test_pattern(int module, unsigned int seed) {
} }
} }
/* Activate */
sdram_activate_test_row();
/* Write pseudo-random sequence */ /* Write pseudo-random sequence */
for(p=0;p<SDRAM_PHY_PHASES;p++) for(p=0;p<SDRAM_PHY_PHASES;p++)
csr_wr_buf_uint8(sdram_dfii_pix_wrdata_addr[p], prs[p], DFII_PIX_DATA_BYTES); csr_wr_buf_uint8(sdram_dfii_pix_wrdata_addr[p], prs[p], DFII_PIX_DATA_BYTES);
@ -686,6 +689,9 @@ static int sdram_write_read_check_test_pattern(int module, unsigned int seed) {
command_prd(DFII_COMMAND_CAS|DFII_COMMAND_CS|DFII_COMMAND_RDDATA); command_prd(DFII_COMMAND_CAS|DFII_COMMAND_CS|DFII_COMMAND_RDDATA);
cdelay(15); cdelay(15);
/* Precharge */
sdram_precharge_test_row();
for(p=0;p<SDRAM_PHY_PHASES;p++) { for(p=0;p<SDRAM_PHY_PHASES;p++) {
/* Read back test pattern */ /* Read back test pattern */
csr_rd_buf_uint8(sdram_dfii_pix_rddata_addr[p], tst, DFII_PIX_DATA_BYTES); csr_rd_buf_uint8(sdram_dfii_pix_rddata_addr[p], tst, DFII_PIX_DATA_BYTES);
@ -708,9 +714,6 @@ static int sdram_read_leveling_scan_module(int module, int bitslip, int show)
int i; int i;
int score; int score;
/* Activate */
sdram_activate_test_row();
/* Check test pattern for each delay value */ /* Check test pattern for each delay value */
score = 0; score = 0;
if (show) if (show)
@ -723,7 +726,7 @@ static int sdram_read_leveling_scan_module(int module, int bitslip, int show)
_show = (i%16 == 0) & show; _show = (i%16 == 0) & show;
#endif #endif
working = sdram_write_read_check_test_pattern(module, 42); working = sdram_write_read_check_test_pattern(module, 42);
working &= sdram_write_read_check_test_pattern(module, 43); working &= sdram_write_read_check_test_pattern(module, 84);
if (_show) if (_show)
printf("%d", working); printf("%d", working);
score += working; score += working;
@ -732,9 +735,6 @@ static int sdram_read_leveling_scan_module(int module, int bitslip, int show)
if (show) if (show)
printf("| "); printf("| ");
/* Precharge */
sdram_precharge_test_row();
return score; return score;
} }
@ -746,15 +746,12 @@ static void sdram_read_leveling_module(int module)
printf("delays: "); printf("delays: ");
/* Activate */
sdram_activate_test_row();
/* Find smallest working delay */ /* Find smallest working delay */
delay = 0; delay = 0;
sdram_read_leveling_rst_delay(module); sdram_read_leveling_rst_delay(module);
while(1) { while(1) {
working = sdram_write_read_check_test_pattern(module, 42); working = sdram_write_read_check_test_pattern(module, 42);
working &= sdram_write_read_check_test_pattern(module, 43); working &= sdram_write_read_check_test_pattern(module, 84);
if(working) if(working)
break; break;
delay++; delay++;
@ -778,7 +775,7 @@ static void sdram_read_leveling_module(int module)
/* Find largest working delay */ /* Find largest working delay */
while(1) { while(1) {
working = sdram_write_read_check_test_pattern(module, 42); working = sdram_write_read_check_test_pattern(module, 42);
working &= sdram_write_read_check_test_pattern(module, 43); working &= sdram_write_read_check_test_pattern(module, 84);
if(!working) if(!working)
break; break;
delay++; delay++;
@ -797,9 +794,6 @@ static void sdram_read_leveling_module(int module)
sdram_read_leveling_rst_delay(module); sdram_read_leveling_rst_delay(module);
for(i=0;i<(delay_min+delay_max)/2;i++) for(i=0;i<(delay_min+delay_max)/2;i++)
sdram_read_leveling_inc_delay(module); sdram_read_leveling_inc_delay(module);
/* Precharge */
sdram_precharge_test_row();
} }
#endif /* CSR_DDRPHY_BASE */ #endif /* CSR_DDRPHY_BASE */