litex_json2dts_linux: Add support for multiple Ethernet interfaces

This commit is contained in:
inc 2024-03-12 14:42:48 +01:00
parent c2fd1e9a49
commit 9d0fc2c7c2
1 changed files with 16 additions and 11 deletions

View File

@ -393,10 +393,14 @@ def generate_dts(d, initrd_start=None, initrd_size=None, initrd=None, root_devic
uart_interrupt = "" if polling else "interrupts = <{}>;".format(d["constants"]["uart_interrupt"])) uart_interrupt = "" if polling else "interrupts = <{}>;".format(d["constants"]["uart_interrupt"]))
# Ethernet ------------------------------------------------------------------------------------- # Ethernet -------------------------------------------------------------------------------------
for i in [''] + list(range(0, 10)):
idx = (0 if i == '' else i)
ethphy_name = "ethphy" + str(i)
ethmac_name = "ethmac" + str(i)
if ethphy_name in d["csr_bases"] and ethmac_name in d["csr_bases"]:
if "ethphy" in d["csr_bases"] and "ethmac" in d["csr_bases"]:
dts += """ dts += """
mac0: mac@{ethmac_csr_base:x} {{ mac{idx}: mac@{ethmac_csr_base:x} {{
compatible = "litex,liteeth"; compatible = "litex,liteeth";
reg = <0x{ethmac_csr_base:x} 0x7c>, reg = <0x{ethmac_csr_base:x} 0x7c>,
<0x{ethphy_csr_base:x} 0x0a>, <0x{ethphy_csr_base:x} 0x0a>,
@ -409,14 +413,15 @@ def generate_dts(d, initrd_start=None, initrd_size=None, initrd=None, root_devic
status = "okay"; status = "okay";
}}; }};
""".format( """.format(
ethphy_csr_base = d["csr_bases"]["ethphy"], idx = idx,
ethmac_csr_base = d["csr_bases"]["ethmac"], ethphy_csr_base = d["csr_bases"][ethphy_name],
ethmac_mem_base = d["memories"]["ethmac"]["base"], ethmac_csr_base = d["csr_bases"][ethmac_name],
ethmac_mem_size = d["memories"]["ethmac"]["size"], ethmac_mem_base = d["memories"][ethmac_name]["base"],
ethmac_rx_slots = d["constants"]["ethmac_rx_slots"], ethmac_mem_size = d["memories"][ethmac_name]["size"],
ethmac_tx_slots = d["constants"]["ethmac_tx_slots"], ethmac_rx_slots = d["constants"][ethmac_name + "_rx_slots"],
ethmac_slot_size = d["constants"]["ethmac_slot_size"], ethmac_tx_slots = d["constants"][ethmac_name + "_tx_slots"],
ethmac_interrupt = "" if polling else "interrupts = <{}>;".format(d["constants"]["ethmac_interrupt"])) ethmac_slot_size = d["constants"][ethmac_name + "_slot_size"],
ethmac_interrupt = "" if polling else "interrupts = <{}>;".format(d["constants"][ethmac_name + "_interrupt"]))
# USB OHCI ------------------------------------------------------------------------------------- # USB OHCI -------------------------------------------------------------------------------------