From a7a520695ec23b4ce4cb298f2d24148904f9cf98 Mon Sep 17 00:00:00 2001 From: Icenowy Zheng Date: Wed, 9 Nov 2022 17:47:58 +0800 Subject: [PATCH] software/liblitedram: seek for consecutive delay range when centering On some boards, the working delay range found may be not so consecutive. Considering this to be some inference, we should only count the biggest consecutive delay range instead of just skip ahead for a fixed offset. Signed-off-by: Icenowy Zheng --- litex/soc/software/liblitedram/sdram.c | 31 ++++++++++++-------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/litex/soc/software/liblitedram/sdram.c b/litex/soc/software/liblitedram/sdram.c index 48bb2bf48..47f20944d 100644 --- a/litex/soc/software/liblitedram/sdram.c +++ b/litex/soc/software/liblitedram/sdram.c @@ -378,7 +378,7 @@ static void sdram_leveling_center_module( int working; unsigned int errors; int delay, delay_mid, delay_range; - int delay_min = -1, delay_max = -1; + int delay_min = -1, delay_max = -1, cur_delay_min = -1; if (show_long) printf("m%d: |", module); @@ -406,20 +406,9 @@ static void sdram_leveling_center_module( inc_delay(module); } - /* Get a bit further into the working zone */ -#if SDRAM_PHY_DELAYS > 32 - #define SDRAM_PHY_DELAY_JUMP 16 -#elif SDRAM_PHY_DELAYS > 8 - #define SDRAM_PHY_DELAY_JUMP 4 -#else - #define SDRAM_PHY_DELAY_JUMP 1 -#endif - for(i=0;i best_delay_length) { + delay_min = cur_delay_min; + delay_max = delay; + } + } else { + cur_delay_min = delay + 1; } delay++; if(delay >= SDRAM_PHY_DELAYS)