From 6a980781d3eedd0ee60d80ce4ad39f1a66fa98d6 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 25 Feb 2019 14:36:47 +0100 Subject: [PATCH] soc/software/bios/sdram: add helpers for rst/inc of delays --- litex/soc/software/bios/sdram.c | 140 ++++++++++++++++++++++---------- 1 file changed, 98 insertions(+), 42 deletions(-) diff --git a/litex/soc/software/bios/sdram.c b/litex/soc/software/bios/sdram.c index ef3280de..ad63bf84 100644 --- a/litex/soc/software/bios/sdram.c +++ b/litex/soc/software/bios/sdram.c @@ -235,6 +235,36 @@ void sdrwloff(void) ddrphy_wlevel_en_write(0); } +static void write_delay_rst(int module) { + int i; + + /* sel module */ + ddrphy_dly_sel_write(1 << module); + + /* rst delay */ + ddrphy_wdly_dq_rst_write(1); + ddrphy_wdly_dqs_rst_write(1); +#ifdef USDDRPHY /* need to init manually on Ultrascale */ + for(i=0; i= ERR_DDRPHY_DELAY) break; - ddrphy_rdly_dq_inc_write(1); + read_delay_inc(module); } delay_min = delay; @@ -481,11 +535,11 @@ static void read_level(int module) #ifdef USDDRPHY for(j=0;j<16;j++) { delay += 1; - ddrphy_rdly_dq_inc_write(1); + read_delay_inc(module) } #else delay++; - ddrphy_rdly_dq_inc_write(1); + read_delay_inc(module); #endif /* Find largest working delay */ @@ -504,7 +558,7 @@ static void read_level(int module) delay++; if(delay >= ERR_DDRPHY_DELAY) break; - ddrphy_rdly_dq_inc_write(1); + read_delay_inc(module); } delay_max = delay; @@ -514,9 +568,9 @@ static void read_level(int module) printf("%02d+-%02d", (delay_min+delay_max)/2, (delay_max-delay_min)/2); /* Set delay to the middle */ - ddrphy_rdly_dq_rst_write(1); + read_delay_rst(module); for(j=0;j<(delay_min+delay_max)/2;j++) - ddrphy_rdly_dq_inc_write(1); + read_delay_inc(module); /* Precharge */ sdram_dfii_pi0_address_write(0); @@ -716,10 +770,12 @@ int sdrlevel(void) sdrsw(); - for(i=0; i