From bcbf558b6b74ca74ca861324da5b3da579a8676a Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Tue, 10 Mar 2020 13:08:49 +0100 Subject: [PATCH] bios: add more Ultrascale SDRAM debug with sdram_cdly command to set clk/cmd delay. --- litex/soc/software/bios/main.c | 3 +++ litex/soc/software/bios/sdram.c | 6 +++--- litex/soc/software/bios/sdram.h | 4 ++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/litex/soc/software/bios/main.c b/litex/soc/software/bios/main.c index 4c3824c7..83bff1e1 100644 --- a/litex/soc/software/bios/main.c +++ b/litex/soc/software/bios/main.c @@ -390,6 +390,7 @@ static void help(void) #endif #ifdef USDDRPHY_DEBUG puts(""); + puts("sdram_cdly value - Set SDRAM clk/cmd delay"); puts("sdram_cal - run SDRAM calibration"); puts("sdram_mpr - read SDRAM MPR"); puts("sdram_mrwr reg value - write SDRAM mode registers"); @@ -486,6 +487,8 @@ static void do_command(char *c) else if(strcmp(token, "sdtest") == 0) sdcard_test(atoi(get_token(&c))); #endif #ifdef USDDRPHY_DEBUG + else if(strcmp(token, "sdram_cdly") == 0) + ddrphy_cdly(atoi(get_token(&c))); else if(strcmp(token, "sdram_cal") == 0) sdrcal(); else if(strcmp(token, "sdram_mpr") == 0) diff --git a/litex/soc/software/bios/sdram.c b/litex/soc/software/bios/sdram.c index 7654caaf..c0fec254 100644 --- a/litex/soc/software/bios/sdram.c +++ b/litex/soc/software/bios/sdram.c @@ -257,8 +257,9 @@ void sdrwr(char *startaddr) #define NBMODULES DFII_PIX_DATA_BYTES/2 #endif -#ifdef DDRPHY_CMD_DELAY -static void ddrphy_cdly(unsigned int delay) { +#if defined(DDRPHY_CMD_DELAY) || defined(USDDRPHY_DEBUG) +void ddrphy_cdly(unsigned int delay) { + printf("Setting clk/cmd delay to %d taps\n", delay); #if CSR_DDRPHY_EN_VTC_ADDR ddrphy_en_vtc_write(0); #endif @@ -994,7 +995,6 @@ int sdrinit(void) ddrphy_en_vtc_write(0); #endif #ifdef DDRPHY_CMD_DELAY - printf("Setting clk/cmd delay to %d taps\n", DDRPHY_CMD_DELAY); ddrphy_cdly(DDRPHY_CMD_DELAY); #endif sdrlevel(); diff --git a/litex/soc/software/bios/sdram.h b/litex/soc/software/bios/sdram.h index 7844c1e8..58509bb0 100644 --- a/litex/soc/software/bios/sdram.h +++ b/litex/soc/software/bios/sdram.h @@ -27,6 +27,10 @@ int memtest_silent(void); int memtest(void); int sdrinit(void); +#if defined(DDRPHY_CMD_DELAY) || defined(USDDRPHY_DEBUG) +void ddrphy_cdly(unsigned int delay); +#endif + #ifdef USDDRPHY_DEBUG void sdrcal(void); void sdrmrwr(char reg, int value); -- 2.30.2