From 52f36b125795d361f1485fc080c0784016ca0a1d Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Tue, 7 Jul 2020 15:05:07 +0200 Subject: [PATCH] integration/soc/sdcard: cleanup emulator integration, fix sim. --- litex/soc/integration/soc.py | 15 ++++++++------- litex/soc/software/liblitesdcard/sdcard.c | 2 ++ litex/tools/litex_sim.py | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/litex/soc/integration/soc.py b/litex/soc/integration/soc.py index a92faa6a..a8c40e09 100644 --- a/litex/soc/integration/soc.py +++ b/litex/soc/integration/soc.py @@ -1244,23 +1244,24 @@ class LiteXSoC(SoC): self.add_csr(name) # Add SDCard ----------------------------------------------------------------------------------- - def add_sdcard(self, name="sdcard", with_emulator=False): + def add_sdcard(self, name="sdcard", use_emulator=False): # Imports + from litesdcard.emulator import SDEmulator from litesdcard.phy import SDPHY from litesdcard.core import SDCore from litesdcard.frontend.dma import SDBlock2MemDMA, SDMem2BlockDMA # Emulator / Pads - if with_emulator: - from litesdcard.emulator import SDEmulator - self.submodules.sdemulator = SDEmulator(self.platform) - sdcard_pads = self.sdemulator.pads + if use_emulator: + sdemulator = SDEmulator(self.platform) + self.submodules += sdemulator + sdcard_pads = sdemulator.pads else: sdcard_pads = self.platform.request(name) # Core - self.submodules.sdphy = SDPHY(sdcard_pads, self.platform.device, self.clk_freq) - self.submodules.sdcore = SDCore(self.sdphy) + self.submodules.sdphy = SDPHY(sdcard_pads, self.platform.device, self.clk_freq) + self.submodules.sdcore = SDCore(self.sdphy) self.add_csr("sdphy") self.add_csr("sdcore") diff --git a/litex/soc/software/liblitesdcard/sdcard.c b/litex/soc/software/liblitesdcard/sdcard.c index b0f875c0..4361fe49 100644 --- a/litex/soc/software/liblitesdcard/sdcard.c +++ b/litex/soc/software/liblitesdcard/sdcard.c @@ -562,7 +562,9 @@ sdcard_set_block_count(count); /* Flush CPU caches */ flush_cpu_dcache(); +#ifdef CONFIG_L2_SIZE flush_l2_cache(); +#endif } void sdcard_write(uint32_t sector, uint32_t count, uint8_t* buf) diff --git a/litex/tools/litex_sim.py b/litex/tools/litex_sim.py index 680fb4a3..4c33dbb7 100755 --- a/litex/tools/litex_sim.py +++ b/litex/tools/litex_sim.py @@ -309,7 +309,7 @@ class SimSoC(SoCCore): # SDCard ----------------------------------------------------------------------------------- if with_sdcard: - self.add_sdcard("sdcard", with_emulator=True) + self.add_sdcard("sdcard", use_emulator=True) # Build -------------------------------------------------------------------------------------------- -- 2.30.2