From 2d7cd7802c10a29b26e4ba1e873ee649830d39bc Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Tue, 10 Jan 2023 10:17:10 +0100 Subject: [PATCH] software/liblitedram Fix compilation when no SDRAM. --- litex/soc/software/liblitedram/sdram_spd.c | 6 +++--- litex/soc/software/liblitedram/sdram_spd.h | 7 +++++++ litex/soc/software/liblitedram/utils.c | 8 ++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/litex/soc/software/liblitedram/sdram_spd.c b/litex/soc/software/liblitedram/sdram_spd.c index 82b39b86c..4f07b4616 100644 --- a/litex/soc/software/liblitedram/sdram_spd.c +++ b/litex/soc/software/liblitedram/sdram_spd.c @@ -3,7 +3,7 @@ #include -#ifdef CONFIG_HAS_I2C +#if defined(CSR_SDRAM_BASE) && defined(CONFIG_HAS_I2C) #if defined(SDRAM_PHY_DDR4) /* @@ -55,8 +55,8 @@ bool sdram_read_spd(uint8_t spd, uint16_t addr, uint8_t *buf, uint16_t len, bool return ok; } -#else /* no CONFIG_HAS_I2C */ +#else /* no CSR_SDRAM_BASE && CONFIG_HAS_I2C */ bool sdram_read_spd(uint8_t spd, uint16_t addr, uint8_t *buf, uint16_t len, bool send_stop) { return false; } -#endif /* CONFIG_HAS_I2C */ +#endif /* CSR_SDRAM_BASE && CONFIG_HAS_I2C */ diff --git a/litex/soc/software/liblitedram/sdram_spd.h b/litex/soc/software/liblitedram/sdram_spd.h index c95fd64bc..28a680135 100644 --- a/litex/soc/software/liblitedram/sdram_spd.h +++ b/litex/soc/software/liblitedram/sdram_spd.h @@ -7,6 +7,11 @@ #include #include #include + +#include + +#if defined(CSR_SDRAM_BASE) && defined(CONFIG_HAS_I2C) + #include #define SPD_RW_PREAMBLE 0b1010 @@ -25,6 +30,8 @@ #define SDRAM_SPD_SIZE (SDRAM_SPD_PAGES * SDRAM_SPD_PAGE_SIZE) +#endif /* CSR_SDRAM_BASE && CONFIG_HAS_I2C */ + bool sdram_read_spd(uint8_t spd, uint16_t addr, uint8_t *buf, uint16_t len, bool send_stop); #endif /* __SDRAM_SPD_H */ diff --git a/litex/soc/software/liblitedram/utils.c b/litex/soc/software/liblitedram/utils.c index 480565163..9dd18f918 100644 --- a/litex/soc/software/liblitedram/utils.c +++ b/litex/soc/software/liblitedram/utils.c @@ -8,8 +8,6 @@ #include -#include - #define KIB 1024 #define MIB (KIB*1024) #define GIB (MIB*1024) @@ -32,6 +30,10 @@ void print_progress(const char * header, uint64_t origin, uint64_t size) printf(" \r"); } +#ifdef CSR_SDRAM_BASE + +#include + uint64_t sdram_get_supported_memory(void) { #ifdef CONFIG_HAS_I2C @@ -59,3 +61,5 @@ uint64_t sdram_get_supported_memory(void) { return SDRAM_PHY_SUPPORTED_MEMORY; #endif /* CONFIG_HAS_I2C */ } + +#endif \ No newline at end of file