From: Florent Kermarrec Date: Wed, 22 Aug 2018 21:15:32 +0000 (+0200) Subject: bios/sdram: improve/simplify read window selection X-Git-Tag: 24jan2021_ls180~1635 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=759e7d4dc3ba499b66da0820c1a7fa34fc220a48;p=litex.git bios/sdram: improve/simplify read window selection Compute a score for each window and select the best --- diff --git a/litex/soc/software/bios/sdram.c b/litex/soc/software/bios/sdram.c index fbe3a27e..76c5f13e 100644 --- a/litex/soc/software/bios/sdram.c +++ b/litex/soc/software/bios/sdram.c @@ -377,9 +377,7 @@ static int read_level_scan(int silent) unsigned int prv; unsigned char prs[DFII_NPHASES*DFII_PIX_DATA_SIZE]; int p, i, j; - int working; - int working_delays; - int optimal; + int score; if (!silent) printf("Read delays scan:\n"); @@ -408,32 +406,26 @@ static int read_level_scan(int silent) /* Calibrate each DQ in turn */ sdram_dfii_pird_address_write(0); sdram_dfii_pird_baddress_write(0); - working = 0; - working_delays = 0; - optimal = 1; + score = 0; for(i=DFII_PIX_DATA_SIZE/2-1;i>=0;i--) { if (!silent) printf("m%d: ", (DFII_PIX_DATA_SIZE/2-i-1)); ddrphy_dly_sel_write(1 << (DFII_PIX_DATA_SIZE/2-i-1)); ddrphy_rdly_dq_rst_write(1); for(j=0; j 3/4 of the taps */ - return working & (optimal | working_delays > 3*(DFII_PIX_DATA_SIZE/2)*ERR_DDRPHY_DELAY/4); + return score; } static void read_level(void) @@ -732,6 +723,9 @@ int sdrlevel(void) int high_skew[DFII_PIX_DATA_SIZE/2]; int i, j; int bitslip; + int score; + int best_score; + int best_bitslip; for(i=0; i best_score) { + best_bitslip = bitslip; + best_score = score; + } + /* exit */ if (bitslip == ERR_DDRPHY_BITSLIP-1) - return 0; + break; /* increment bitslip */ for(i=0; i