From: Florent Kermarrec Date: Mon, 16 Jul 2018 07:42:09 +0000 (+0200) Subject: bios/sdram: improve bitslip selection when window can't be optimal (not enough taps... X-Git-Tag: 24jan2021_ls180~1676 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4f1274e6a6a9abda73f7f4d17d63b9c6c20e9908;p=litex.git bios/sdram: improve bitslip selection when window can't be optimal (not enough taps for a full window) --- diff --git a/litex/soc/software/bios/sdram.c b/litex/soc/software/bios/sdram.c index 45751569..cd06491a 100644 --- a/litex/soc/software/bios/sdram.c +++ b/litex/soc/software/bios/sdram.c @@ -377,6 +377,7 @@ static int read_level_scan(int silent) unsigned char prs[DFII_NPHASES*DFII_PIX_DATA_SIZE]; int p, i, j; int working; + int working_delays; int optimal; if (!silent) @@ -407,6 +408,7 @@ static int read_level_scan(int silent) sdram_dfii_pird_address_write(0); sdram_dfii_pird_baddress_write(0); working = 0; + working_delays = 0; optimal = 1; for(i=DFII_PIX_DATA_SIZE/2-1;i>=0;i--) { if (!silent) @@ -425,6 +427,7 @@ static int read_level_scan(int silent) working_delay = 0; } working |= working_delay; + working_delays += working_delay; if ((j == 0) || (j == (ERR_DDRPHY_DELAY-1))) /* to have an optimal scan, first tap and last tap should not be working */ optimal &= (working_delay == 0); @@ -442,7 +445,8 @@ static int read_level_scan(int silent) command_p0(DFII_COMMAND_RAS|DFII_COMMAND_WE|DFII_COMMAND_CS); cdelay(15); - return working & optimal; + /* Successful if working and optimal or if number of working delays > 3/4 of the taps */ + return (working & optimal) | (working_delays > 3*ERR_DDRPHY_DELAY/4); } static void read_level(void)