soc/add_sdcard: Fix IRQ code, only add IRQs depending on mode

This commit is contained in:
Christian Klarhorst 2021-07-20 21:40:18 +02:00
parent c64c6e4056
commit e17a010866
1 changed files with 8 additions and 4 deletions

View File

@ -1563,14 +1563,18 @@ class LiteXSoC(SoC):
# Interrupts.
self.submodules.sdirq = EventManager()
self.sdirq.card_detect = EventSourcePulse(description="SDCard has been ejected/inserted.")
if "read" in mode:
self.sdirq.block2mem_dma = EventSourcePulse(description="Block2Mem DMA terminated.")
if "write" in mode:
self.sdirq.mem2block_dma = EventSourcePulse(description="Mem2Block DMA terminated.")
self.sdirq.cmd_done = EventSourceLevel(description="Command completed.")
self.sdirq.finalize()
if "read" in mode:
self.comb += self.sdirq.block2mem_dma.trigger.eq(self.sdblock2mem.irq)
if "write" in mode:
self.comb += self.sdirq.mem2block_dma.trigger.eq(self.sdmem2block.irq)
self.comb += [
self.sdirq.card_detect.trigger.eq(self.sdphy.card_detect_irq),
self.sdirq.block2mem_dma.trigger.eq(self.sdblock2mem.irq),
self.sdirq.mem2block_dma.trigger.eq(self.sdmem2block.irq),
self.sdirq.cmd_done.trigger.eq(self.sdcore.cmd_event.fields.done)
]
if self.irq.enabled: