From: Florent Kermarrec Date: Tue, 7 Jul 2020 13:05:07 +0000 (+0200) Subject: integration/soc/sdcard: cleanup emulator integration, fix sim. X-Git-Tag: 24jan2021_ls180~97 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=52f36b125795d361f1485fc080c0784016ca0a1d;p=litex.git integration/soc/sdcard: cleanup emulator integration, fix sim. --- 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 --------------------------------------------------------------------------------------------