Skip to content

Commit

Permalink
software/liblitedram: allow forced write leveling delays, improve del…
Browse files Browse the repository at this point in the history
…ay printf when failing.
  • Loading branch information
enjoy-digital committed Sep 15, 2020
1 parent 1d63d66 commit e28e808
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
20 changes: 17 additions & 3 deletions litex/soc/software/liblitedram/sdram.c
Expand Up @@ -337,16 +337,27 @@ static int write_level_scan(int *delays, int loops, int show)
/* rst delay */
write_delay_rst(i);

/* use forced delay if configured */
if (sdrwl_delays[i] >= 0) {
delays[i] = sdrwl_delays[i];

/* configure write delay */
for(j=0; j<delays[i]; j++)
write_delay_inc(i);
/* succeed only if the start of a 1s window has been found */
if (one_window_best_count > 0 && one_window_best_start > 0) {
} else if (one_window_best_count > 0 && one_window_best_start > 0) {
delays[i] = one_window_best_start;

/* configure write delay */
for(j=0; j<delays[i]; j++)
write_delay_inc(i);
}
if (show)
printf(" delay: %02d\n", delays[i]);
if (show) {
if (delays[i] == -1)
printf(" delay: -\n");
else
printf(" delay: %02d\n", delays[i]);
}
}

sdrwloff();
Expand Down Expand Up @@ -847,6 +858,9 @@ void sdrcal(void)

int sdrinit(void)
{
int i;
for (i=0; i<16; i++) sdrwl_delays[i] = -1; /* disabled forced delays */

printf("Initializing DRAM @0x%08x...\n", MAIN_RAM_BASE);

#if CSR_DDRPHY_RST_ADDR
Expand Down
2 changes: 2 additions & 0 deletions litex/soc/software/liblitedram/sdram.h
Expand Up @@ -31,6 +31,8 @@ void sdrwr(unsigned int addr);
/* Write Leveling */
/*-----------------------------------------------------------------------*/

int sdrwl_delays[16];

void sdrwlon(void);
void sdrwloff(void);
int write_level(void);
Expand Down

0 comments on commit e28e808

Please sign in to comment.