diff --git a/litex/tools/litex_json2dts.py b/litex/tools/litex_json2dts.py index b5d658f43..fe698ce5d 100755 --- a/litex/tools/litex_json2dts.py +++ b/litex/tools/litex_json2dts.py @@ -259,6 +259,7 @@ def generate_dts(d, initrd_start=None, initrd_size=None, polling=False): liteuart0: serial@{uart_csr_base:x} {{ compatible = "litex,liteuart"; reg = <0x{uart_csr_base:x} 0x100>; + interrupt-parent = <&intc0>; {uart_interrupt} status = "okay"; }}; @@ -277,6 +278,7 @@ def generate_dts(d, initrd_start=None, initrd_size=None, polling=False): <0x{ethmac_mem_base:x} 0x{ethmac_mem_size:x}>; tx-fifo-depth = <{ethmac_tx_slots}>; rx-fifo-depth = <{ethmac_rx_slots}>; + interrupt-parent = <&intc0>; {ethmac_interrupt} status = "okay"; }}; @@ -403,6 +405,15 @@ def generate_dts(d, initrd_start=None, initrd_size=None, polling=False): # Switches ------------------------------------------------------------------------------------- if "switches" in d["csr_bases"]: + interrupt_specification = "" + if "switches_interrupt" in d["constants"]: + switches_interrupt = d["constants"]["switches_interrupt"] + interrupt_specification = """ + interrupt-controller; + #interrupt-cells = <2>; + interrupt-parent = <&intc0>; + interrupts = <{switches_interrupt}>;""".format(switches_interrupt=switches_interrupt) + dts += """ switches: gpio@{switches_csr_base:x} {{ compatible = "litex,gpio"; @@ -410,9 +421,11 @@ def generate_dts(d, initrd_start=None, initrd_size=None, polling=False): gpio-controller; #gpio-cells = <2>; litex,direction = "in"; + gpio-controller; + #gpio-cells = <2>;{interrupt_specification} status = "disabled"; }}; -""".format(switches_csr_base=d["csr_bases"]["switches"]) +""".format(switches_csr_base=d["csr_bases"]["switches"], interrupt_specification=interrupt_specification) # SPI ------------------------------------------------------------------------------------------ @@ -601,19 +614,19 @@ def generate_dts(d, initrd_start=None, initrd_size=None, polling=False): if "leds" in d["csr_bases"]: dts += """ -&leds { - litex,ngpio = <4>; +&leds {{ + litex,ngpio = <{ngpio}>; status = "okay"; -}; -""" +}}; +""".format(ngpio=d["constants"].get('leds_ngpio', 4)) if "switches" in d["csr_bases"]: dts += """ -&switches { - litex,ngpio = <4>; +&switches {{ + litex,ngpio = <{ngpio}>; status = "okay"; -}; -""" +}}; +""".format(ngpio=d["constants"].get('switches_ngpio', 4)) return dts