tools/litex_json2dts: add --polling args to allow forcing polling mode on peripherals.

Can be useful for debug purpose or bring up of new hardware not yet supporting IRQs.
This commit is contained in:
Florent Kermarrec 2020-12-29 09:02:56 +01:00
parent d9a44ce10f
commit bf32d23d9a

View file

@ -12,7 +12,7 @@ import json
import argparse import argparse
def generate_dts(d, initrd_start=None, initrd_size=None): def generate_dts(d, initrd_start=None, initrd_size=None, polling=False):
kB = 1024 kB = 1024
mB = kB*1024 mB = kB*1024
@ -184,12 +184,12 @@ def generate_dts(d, initrd_start=None, initrd_size=None):
device_type = "serial"; device_type = "serial";
compatible = "litex,liteuart"; compatible = "litex,liteuart";
reg = <0x{uart_csr_base:x} 0x100>; reg = <0x{uart_csr_base:x} 0x100>;
interrupts = <{uart_interrupt}>; {uart_interrupt}
status = "okay"; status = "okay";
}}; }};
""".format( """.format(
uart_csr_base = d["csr_bases"]["uart"], uart_csr_base = d["csr_bases"]["uart"],
uart_interrupt = d["constants"]["uart_interrupt"]) uart_interrupt = "" if polling else "interrupts = <{}>;".format(d["constants"]["uart_interrupt"]))
# Ethernet ------------------------------------------------------------------------------------- # Ethernet -------------------------------------------------------------------------------------
@ -202,15 +202,15 @@ def generate_dts(d, initrd_start=None, initrd_size=None):
<0x{ethmac_mem_base:x} 0x2000>; <0x{ethmac_mem_base:x} 0x2000>;
tx-fifo-depth = <{ethmac_tx_slots}>; tx-fifo-depth = <{ethmac_tx_slots}>;
rx-fifo-depth = <{ethmac_rx_slots}>; rx-fifo-depth = <{ethmac_rx_slots}>;
interrupts = <{ethmac_interrupt}>; {ethmac_interrupt}
}}; }};
""".format( """.format(
ethphy_csr_base = d["csr_bases"]["ethphy"], ethphy_csr_base = d["csr_bases"]["ethphy"],
ethmac_csr_base = d["csr_bases"]["ethmac"], ethmac_csr_base = d["csr_bases"]["ethmac"],
ethmac_mem_base = d["memories"]["ethmac"]["base"], ethmac_mem_base = d["memories"]["ethmac"]["base"],
ethmac_tx_slots = d["constants"]["ethmac_tx_slots"], ethmac_tx_slots = d["constants"]["ethmac_tx_slots"],
ethmac_rx_slots = d["constants"]["ethmac_rx_slots"], ethmac_rx_slots = d["constants"]["ethmac_rx_slots"],
ethmac_interrupt = d["constants"]["ethmac_interrupt"]) ethmac_interrupt = "" if polling else "interrupts = <{}>;".format(d["constants"]["ethmac_interrupt"]))
# SPI Flash ------------------------------------------------------------------------------------- # SPI Flash -------------------------------------------------------------------------------------
@ -551,14 +551,16 @@ def generate_dts(d, initrd_start=None, initrd_size=None):
def main(): def main():
parser = argparse.ArgumentParser(description="LiteX's CSR JSON to Linux DTS generator") parser = argparse.ArgumentParser(description="LiteX's CSR JSON to Linux DTS generator")
parser.add_argument("csr_json", help="CSR JSON file") parser.add_argument("csr_json", help="CSR JSON file")
parser.add_argument("--initrd-start", type=int, help="Location of initrd in RAM (relative, default depends on CPU)") parser.add_argument("--initrd-start", type=int, help="Location of initrd in RAM (relative, default depends on CPU)")
parser.add_argument("--initrd-size", type=int, help="Size of initrd (default=8MB)") parser.add_argument("--initrd-size", type=int, help="Size of initrd (default=8MB)")
parser.add_argument("--polling", action="store_true", help="Force polling mode on peripherals")
args = parser.parse_args() args = parser.parse_args()
d = json.load(open(args.csr_json)) d = json.load(open(args.csr_json))
r = generate_dts(d, r = generate_dts(d,
initrd_start = args.initrd_start, initrd_start = args.initrd_start,
initrd_size = args.initrd_size initrd_size = args.initrd_size,
polling = args.polling,
) )
print(r) print(r)