From: Florent Kermarrec Date: Fri, 20 Mar 2020 08:57:37 +0000 (+0100) Subject: integration/soc: add add_spi_sdcard method to add SPI mode SDCard support to the... X-Git-Tag: 24jan2021_ls180~547 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d276036f24f82fe4e455fe2972ec1bc1a8c0b5ba;p=litex.git integration/soc: add add_spi_sdcard method to add SPI mode SDCard support to the SoC. --- diff --git a/litex/soc/integration/soc.py b/litex/soc/integration/soc.py index aade79db..cf056ae4 100644 --- a/litex/soc/integration/soc.py +++ b/litex/soc/integration/soc.py @@ -13,6 +13,7 @@ from migen import * from litex.soc.cores import cpu from litex.soc.cores.identifier import Identifier from litex.soc.cores.timer import Timer +from litex.soc.cores.spi import SPIMaster from litex.soc.interconnect.csr import * from litex.soc.interconnect import csr_bus @@ -1056,3 +1057,12 @@ class LiteXSoC(SoC): self.crg.cd_sys.clk, phy.crg.cd_eth_rx.clk, phy.crg.cd_eth_tx.clk) + + # Add SPI SDCard ------------------------------------------------------------------------------- + def add_spi_sdcard(self, name="spisdcard", clk_freq=400e3): + pads = self.platform.request(name) + if hasattr(pads, "rst"): + self.comb += pads.rst.eq(0) + spisdcard = SPIMaster(pads, 8, self.sys_clk_freq, 400e3) + setattr(self.submodules, name, spisdcard) + self.add_csr(name)