From dc1a4c5380be351387b1cd48dd15ee1bffaf5857 Mon Sep 17 00:00:00 2001 From: Stafford Horne Date: Thu, 29 Apr 2021 17:18:40 +0900 Subject: [PATCH 1/2] integration/soc: Wire up the sdirq to the CPU I am working on testing out the patches from: https://github.com/litex-hub/linux/pull/8 These linux patches take advantage of the sdcard interrupt to track when transfers finish. However, it seems the interrupt is not being connected to the CPU. This patch does that by allowing us to directly register and EventManager module with the irq handler. --- litex/soc/integration/soc.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/litex/soc/integration/soc.py b/litex/soc/integration/soc.py index 276bb91d8..dc26c06d0 100644 --- a/litex/soc/integration/soc.py +++ b/litex/soc/integration/soc.py @@ -1070,12 +1070,17 @@ class SoC(Module): continue if hasattr(self, name): module = getattr(self, name) - if not hasattr(module, "ev"): + ev = None + if hasattr(module, "ev"): + ev = module.ev + elif isinstance(module, EventManager): + ev = module + else: self.logger.error("EventManager {} in {} SubModule.".format( colorer("not found", color="red"), colorer(name))) raise - self.comb += self.cpu.interrupt[loc].eq(module.ev.irq) + self.comb += self.cpu.interrupt[loc].eq(ev.irq) self.add_constant(name + "_INTERRUPT", loc) # SoC Infos -------------------------------------------------------------------------------- @@ -1558,6 +1563,8 @@ class LiteXSoC(SoC): 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: + self.irq.add("sdirq", use_loc_if_exists=True) # Debug. if software_debug: From a9e935e61a15586300ff1a5deca4242378c87794 Mon Sep 17 00:00:00 2001 From: Stafford Horne Date: Thu, 29 Apr 2021 17:52:17 +0900 Subject: [PATCH 2/2] tools/litex_json2dts: Add interrupt settings for sdcard --- litex/tools/litex_json2dts.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/litex/tools/litex_json2dts.py b/litex/tools/litex_json2dts.py index 716d227ac..1573ebd3a 100755 --- a/litex/tools/litex_json2dts.py +++ b/litex/tools/litex_json2dts.py @@ -283,8 +283,10 @@ def generate_dts(d, initrd_start=None, initrd_size=None, polling=False): reg = <0x{sdphy_csr_base:x} 0x100>, <0x{sdcore_csr_base:x} 0x100>, <0x{sdblock2mem:x} 0x100>, - <0x{sdmem2block:x} 0x100>; + <0x{sdmem2block:x} 0x100>, + <0x{sdirq:x} 0x100>; bus-width = <0x04>; + {sdirq_interrupt} status = "okay"; }}; """.format( @@ -292,7 +294,9 @@ def generate_dts(d, initrd_start=None, initrd_size=None, polling=False): sdphy_csr_base = d["csr_bases"]["sdphy"], sdcore_csr_base = d["csr_bases"]["sdcore"], sdblock2mem = d["csr_bases"]["sdblock2mem"], - sdmem2block = d["csr_bases"]["sdmem2block"] + sdmem2block = d["csr_bases"]["sdmem2block"], + sdirq = d["csr_bases"]["sdirq"], + sdirq_interrupt = "" if polling else "interrupts = <{}>;".format(d["constants"]["sdirq_interrupt"]) ) # Leds -----------------------------------------------------------------------------------------