Skip to content

Commit 7cb7bee

Browse files
committed
colognechip_gatemate_evb: add SD card support
1 parent a17e439 commit 7cb7bee

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

litex_boards/platforms/colognechip_gatemate_evb.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,23 @@ def usb_pmod_io(pmod):
124124
),
125125
]
126126

127+
def pmods_sdcard_io(pmod):
128+
return [
129+
# SDCard PMOD:
130+
# - https://store.digilentinc.com/pmod-microsd-microsd-card-slot/
131+
("spisdcard", 0,
132+
Subsignal("clk", Pins(f"{pmod}:3")),
133+
Subsignal("mosi", Pins(f"{pmod}:1"), Misc("PULLUP=true")),
134+
Subsignal("cs_n", Pins(f"{pmod}:0"), Misc("PULLUP=true")),
135+
Subsignal("miso", Pins(f"{pmod}:2"), Misc("PULLUP=true")),
136+
),
137+
("sdcard", 0,
138+
Subsignal("data", Pins(f"{pmod}:2 {pmod}:4 {pmod}:5 {pmod}:0"), Misc("PULLUP=true")),
139+
Subsignal("cmd", Pins(f"{pmod}:1"), Misc("PULLUP=true")),
140+
Subsignal("clk", Pins(f"{pmod}:3")),
141+
Subsignal("cd", Pins(f"{pmod}:6")),
142+
),
143+
]
127144
# Platform -----------------------------------------------------------------------------------------
128145

129146
class Platform(CologneChipPlatform):

litex_boards/targets/colognechip_gatemate_evb.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,23 @@ def main():
124124
parser.add_target_argument("--sys-clk-freq", default=24e6, type=float, help="System clock frequency.")
125125
parser.add_target_argument("--flash", action="store_true", help="Flash bitstream.")
126126
parser.add_target_argument("--with-spi-flash", action="store_true", help="Enable SPI Flash (MMAPed).")
127+
sdopts = parser.target_group.add_mutually_exclusive_group()
128+
sdopts.add_argument("--with-spi-sdcard", action="store_true", help="Enable SPI-mode SDCard support.")
129+
sdopts.add_argument("--with-sdcard", action="store_true", help="Enable SDCard support.")
127130
args = parser.parse_args()
128131

129132
soc = BaseSoC(
130133
sys_clk_freq = args.sys_clk_freq,
131134
toolchain = args.toolchain,
132135
with_spi_flash = args.with_spi_flash,
133136
**parser.soc_argdict)
137+
138+
soc.platform.add_extension(colognechip_gatemate_evb.pmods_sdcard_io("PMODA"))
139+
if args.with_spi_sdcard:
140+
soc.add_spi_sdcard()
141+
if args.with_sdcard:
142+
soc.add_sdcard()
143+
134144
builder = Builder(soc, **parser.builder_argdict)
135145
if args.build:
136146
builder.build(**parser.toolchain_argdict)

0 commit comments

Comments
 (0)