tools/litex_json2dts: cleanup and reorganize peripherals.
This commit is contained in:
parent
df92e2aea7
commit
5ec5554713
|
@ -21,8 +21,7 @@ def generate_dts(d):
|
|||
|
||||
aliases = {}
|
||||
|
||||
# Header -------------------------------------------------------------------------------------------
|
||||
|
||||
# Header ---------------------------------------------------------------------------------------
|
||||
dts = """
|
||||
/dts-v1/;
|
||||
|
||||
|
@ -32,8 +31,7 @@ def generate_dts(d):
|
|||
|
||||
"""
|
||||
|
||||
# Boot Arguments -----------------------------------------------------------------------------------
|
||||
|
||||
# Boot Arguments -------------------------------------------------------------------------------
|
||||
linux_initrd_start_offset = {
|
||||
"mor1kx": 8*mB,
|
||||
"vexriscv smp-linux" : 16*mB,
|
||||
|
@ -49,14 +47,16 @@ def generate_dts(d):
|
|||
linux,initrd-start = <0x{linux_initrd_start:x}>;
|
||||
linux,initrd-end = <0x{linux_initrd_end:x}>;
|
||||
}};
|
||||
""".format(main_ram_base=d["memories"]["main_ram"]["base"],
|
||||
main_ram_size=d["memories"]["main_ram"]["size"],
|
||||
main_ram_size_mb=d["memories"]["main_ram"]["size"] // mB,
|
||||
linux_initrd_start=d["memories"]["main_ram"]["base"] + linux_initrd_start_offset[cpu_name],
|
||||
linux_initrd_end=d["memories"]["main_ram"]["base"] + linux_initrd_end_offset[cpu_name])
|
||||
""".format(
|
||||
main_ram_base = d["memories"]["main_ram"]["base"],
|
||||
main_ram_size = d["memories"]["main_ram"]["size"],
|
||||
main_ram_size_mb = d["memories"]["main_ram"]["size"] // mB,
|
||||
linux_initrd_start = d["memories"]["main_ram"]["base"] + linux_initrd_start_offset[cpu_name],
|
||||
linux_initrd_end = d["memories"]["main_ram"]["base"] + linux_initrd_end_offset[cpu_name])
|
||||
|
||||
# CPU ----------------------------------------------------------------------------------------------
|
||||
# CPU ------------------------------------------------------------------------------------------
|
||||
|
||||
# VexRiscv-SMP
|
||||
if cpu_name == "vexriscv smp-linux":
|
||||
dts += """
|
||||
cpus {{
|
||||
|
@ -64,7 +64,6 @@ def generate_dts(d):
|
|||
#size-cells = <0>;
|
||||
timebase-frequency = <{sys_clk_freq}>;
|
||||
""".format(sys_clk_freq=int(50e6) if "sim" in d["constants"] else d["constants"]["config_clock_frequency"])
|
||||
|
||||
cpus = range(int(d["constants"]["config_cpu_count"]))
|
||||
for cpu in cpus:
|
||||
dts += """
|
||||
|
@ -82,13 +81,12 @@ def generate_dts(d):
|
|||
}};
|
||||
}};
|
||||
""".format(cpu=cpu, irq=cpu)
|
||||
|
||||
dts += """
|
||||
};
|
||||
"""
|
||||
|
||||
# mor1kx
|
||||
elif cpu_name == "mor1kx":
|
||||
|
||||
dts += """
|
||||
cpus {{
|
||||
#address-cells = <1>;
|
||||
|
@ -101,19 +99,19 @@ def generate_dts(d):
|
|||
}};
|
||||
""".format(sys_clk_freq=d["constants"]["config_clock_frequency"])
|
||||
|
||||
# Memory -------------------------------------------------------------------------------------------
|
||||
# Memory ---------------------------------------------------------------------------------------
|
||||
|
||||
dts += """
|
||||
memory@{main_ram_base:x} {{
|
||||
device_type = "memory";
|
||||
reg = <0x{main_ram_base:x} 0x{main_ram_size:x}>;
|
||||
}};
|
||||
""".format(main_ram_base=d["memories"]["main_ram"]["base"],
|
||||
main_ram_size=d["memories"]["main_ram"]["size"])
|
||||
""".format(
|
||||
main_ram_base = d["memories"]["main_ram"]["base"],
|
||||
main_ram_size = d["memories"]["main_ram"]["size"])
|
||||
|
||||
if "opensbi" in d["memories"]:
|
||||
dts += """
|
||||
|
||||
reserved-memory {{
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
@ -122,10 +120,11 @@ def generate_dts(d):
|
|||
reg = <0x{opensbi_base:x} 0x{opensbi_size:x}>;
|
||||
}};
|
||||
}};
|
||||
""".format(opensbi_base=d["memories"]["opensbi"]["base"],
|
||||
opensbi_size=d["memories"]["opensbi"]["size"])
|
||||
""".format(
|
||||
opensbi_base = d["memories"]["opensbi"]["base"],
|
||||
opensbi_size = d["memories"]["opensbi"]["size"])
|
||||
|
||||
# SoC ----------------------------------------------------------------------------------------------
|
||||
# SoC ------------------------------------------------------------------------------------------
|
||||
|
||||
dts += """
|
||||
soc {{
|
||||
|
@ -136,11 +135,21 @@ def generate_dts(d):
|
|||
ranges;
|
||||
""".format(sys_clk_freq=d["constants"]["config_clock_frequency"])
|
||||
|
||||
# Interrupt controller -----------------------------------------------------------------------------
|
||||
# SoC Controller -------------------------------------------------------------------------------
|
||||
|
||||
dts += """
|
||||
soc_ctrl0: soc_controller@{soc_ctrl_csr_base:x} {{
|
||||
compatible = "litex,soc_controller";
|
||||
reg = <0x{soc_ctrl_csr_base:x} 0xc>;
|
||||
status = "okay";
|
||||
}};
|
||||
""".format(soc_ctrl_csr_base=d["csr_bases"]["ctrl"])
|
||||
|
||||
# Interrupt Controller -------------------------------------------------------------------------
|
||||
|
||||
if cpu_name == "vexriscv smp-linux":
|
||||
dts += """
|
||||
plic: interrupt-controller@{plic_base:x} {{
|
||||
intc0: interrupt-controller@{plic_base:x} {{
|
||||
compatible = "sifive,plic-1.0.0", "sifive,fu540-c000-plic";
|
||||
reg = <0x{plic_base:x} 0x400000>;
|
||||
#interrupt-cells = <1>;
|
||||
|
@ -149,8 +158,9 @@ def generate_dts(d):
|
|||
{cpu_mapping}>;
|
||||
riscv,ndev = <32>;
|
||||
}};
|
||||
""".format( plic_base=d["memories"]["plic"]["base"],
|
||||
cpu_mapping="\n\t\t\t\t".join(["&L{} 11 &L{} 9".format(cpu, cpu) for cpu in cpus]))
|
||||
""".format(
|
||||
plic_base =d["memories"]["plic"]["base"],
|
||||
cpu_mapping =("\n" + " "*20).join(["&L{} 11 &L{} 9".format(cpu, cpu) for cpu in cpus]))
|
||||
|
||||
elif cpu_name == "mor1kx":
|
||||
dts += """
|
||||
|
@ -161,27 +171,10 @@ def generate_dts(d):
|
|||
status = "okay";
|
||||
};
|
||||
"""
|
||||
else:
|
||||
raise Exception("Unsupported CPU type: {}".format(cpu_name))
|
||||
|
||||
|
||||
|
||||
# SoC Controller -----------------------------------------------------------------------------------
|
||||
|
||||
dts += """
|
||||
soc_ctrl0: soc_controller@{soc_ctrl_csr_base:x} {{
|
||||
compatible = "litex,soc_controller";
|
||||
reg = <0x{soc_ctrl_csr_base:x} 0xc>;
|
||||
status = "okay";
|
||||
}};
|
||||
""".format(soc_ctrl_csr_base=d["csr_bases"]["ctrl"])
|
||||
|
||||
# UART ---------------------------------------------------------------------------------------------
|
||||
# UART -----------------------------------------------------------------------------------------
|
||||
|
||||
if "uart" in d["csr_bases"]:
|
||||
|
||||
aliases["serial0"] = "liteuart0"
|
||||
|
||||
dts += """
|
||||
liteuart0: serial@{uart_csr_base:x} {{
|
||||
device_type = "serial";
|
||||
|
@ -191,10 +184,9 @@ def generate_dts(d):
|
|||
}};
|
||||
""".format(uart_csr_base=d["csr_bases"]["uart"])
|
||||
|
||||
# Ethernet MAC -------------------------------------------------------------------------------------
|
||||
# Ethernet -------------------------------------------------------------------------------------
|
||||
|
||||
if "ethphy" in d["csr_bases"] and "ethmac" in d["csr_bases"]:
|
||||
|
||||
dts += """
|
||||
mac0: mac@{ethmac_csr_base:x} {{
|
||||
compatible = "litex,liteeth";
|
||||
|
@ -204,88 +196,17 @@ def generate_dts(d):
|
|||
tx-fifo-depth = <{ethmac_tx_slots}>;
|
||||
rx-fifo-depth = <{ethmac_rx_slots}>;
|
||||
}};
|
||||
""".format(ethphy_csr_base=d["csr_bases"]["ethphy"],
|
||||
ethmac_csr_base=d["csr_bases"]["ethmac"],
|
||||
ethmac_mem_base=d["memories"]["ethmac"]["base"],
|
||||
ethmac_tx_slots=d["constants"]["ethmac_tx_slots"],
|
||||
ethmac_rx_slots=d["constants"]["ethmac_rx_slots"])
|
||||
""".format(
|
||||
ethphy_csr_base = d["csr_bases"]["ethphy"],
|
||||
ethmac_csr_base = d["csr_bases"]["ethmac"],
|
||||
ethmac_mem_base = d["memories"]["ethmac"]["base"],
|
||||
ethmac_tx_slots = d["constants"]["ethmac_tx_slots"],
|
||||
ethmac_rx_slots = d["constants"]["ethmac_rx_slots"])
|
||||
|
||||
# Leds ---------------------------------------------------------------------------------------------
|
||||
|
||||
if "leds" in d["csr_bases"]:
|
||||
|
||||
dts += """
|
||||
leds: gpio@{leds_csr_base:x} {{
|
||||
compatible = "litex,gpio";
|
||||
reg = <0x{leds_csr_base:x} 0x4>;
|
||||
litex,direction = "out";
|
||||
status = "disabled";
|
||||
}};
|
||||
""".format(leds_csr_base=d["csr_bases"]["leds"])
|
||||
|
||||
# RGB Led ------------------------------------------------------------------------------------------
|
||||
|
||||
for name in ["rgb_led_r0", "rgb_led_g0", "rgb_led_b0"]:
|
||||
if name in d["csr_bases"]:
|
||||
|
||||
dts += """
|
||||
{pwm_name}: pwm@{pwm_csr_base:x} {{
|
||||
compatible = "litex,pwm";
|
||||
reg = <0x{pwm_csr_base:x} 0x24>;
|
||||
clock = <100000000>;
|
||||
#pwm-cells = <3>;
|
||||
status = "okay";
|
||||
}};
|
||||
""".format(pwm_name=name,
|
||||
pwm_csr_base=d["csr_bases"][name])
|
||||
|
||||
# Switches -----------------------------------------------------------------------------------------
|
||||
|
||||
if "switches" in d["csr_bases"]:
|
||||
|
||||
dts += """
|
||||
switches: gpio@{switches_csr_base:x} {{
|
||||
compatible = "litex,gpio";
|
||||
reg = <0x{switches_csr_base:x} 0x4>;
|
||||
litex,direction = "in";
|
||||
status = "disabled";
|
||||
}};
|
||||
""".format(switches_csr_base=d["csr_bases"]["switches"])
|
||||
|
||||
# SPI ----------------------------------------------------------------------------------------------
|
||||
|
||||
if "spi" in d["csr_bases"]:
|
||||
|
||||
aliases["spi0"] = "litespi0"
|
||||
|
||||
dts += """
|
||||
litespi0: spi@{spi_csr_base:x} {{
|
||||
compatible = "litex,litespi";
|
||||
reg = <0x{spi_csr_base:x} 0x100>;
|
||||
status = "okay";
|
||||
|
||||
litespi,max-bpw = <8>;
|
||||
litespi,sck-frequency = <1000000>;
|
||||
litespi,num-cs = <1>;
|
||||
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
spidev0: spidev@0 {{
|
||||
compatible = "linux,spidev";
|
||||
reg = <0>;
|
||||
spi-max-frequency = <1000000>;
|
||||
status = "okay";
|
||||
}};
|
||||
}};
|
||||
""".format(spi_csr_base=d["csr_bases"]["spi"])
|
||||
|
||||
# SPIFLASH -------------------------------------------------------------------------------------------
|
||||
# SPI Flash -------------------------------------------------------------------------------------
|
||||
|
||||
if "spiflash" in d["csr_bases"]:
|
||||
|
||||
aliases["spiflash"] = "litespiflash"
|
||||
|
||||
dts += """
|
||||
litespiflash: spiflash@{spiflash_csr_base:x} {{
|
||||
#address-cells = <1>;
|
||||
|
@ -297,15 +218,12 @@ def generate_dts(d):
|
|||
reg = <0x0 0x{spiflash_size:x}>;
|
||||
}};
|
||||
}};
|
||||
""".format(spiflash_csr_base=d["csr_bases"]["spiflash"],
|
||||
spiflash_size=d["memories"]["spiflash"]["size"])
|
||||
""".format(spiflash_csr_base=d["csr_bases"]["spiflash"], spiflash_size=d["memories"]["spiflash"]["size"])
|
||||
|
||||
# SPISDCARD ----------------------------------------------------------------------------------------
|
||||
# SPI-SDCard -----------------------------------------------------------------------------------
|
||||
|
||||
if "spisdcard" in d["csr_bases"]:
|
||||
|
||||
aliases["sdcard0"] = "litespisdcard0"
|
||||
|
||||
dts += """
|
||||
litespisdcard0: spi@{spisdcard_csr_base:x} {{
|
||||
compatible = "litex,litespi";
|
||||
|
@ -329,10 +247,95 @@ def generate_dts(d):
|
|||
}};
|
||||
""".format(spisdcard_csr_base=d["csr_bases"]["spisdcard"])
|
||||
|
||||
# I2C ----------------------------------------------------------------------------------------------
|
||||
|
||||
# SDCard ---------------------------------------------------------------------------------------
|
||||
|
||||
if "sdcore" in d["csr_bases"]:
|
||||
dts += """
|
||||
mmc0: mmc@{mmc_csr_base:x} {{
|
||||
compatible = "litex,mmc";
|
||||
reg = <
|
||||
0x{sdphy_csr_base:x} 0x100
|
||||
0x{sdcore_csr_base:x} 0x100
|
||||
0x{sdblock2mem:x} 0x100
|
||||
0x{sdmem2block:x} 0x100>;
|
||||
bus-width = <0x04>;
|
||||
status = "okay";
|
||||
}};
|
||||
""".format(
|
||||
mmc_csr_base = d["csr_bases"]["sdcore"],
|
||||
sdphy_csr_base = d["csr_bases"]["sdphy"],
|
||||
sdcore_csr_base = d["csr_bases"]["sdcore"],
|
||||
sdblock2mem = d["csr_bases"]["sdblock2mem"],
|
||||
sdmem2block = d["csr_bases"]["sdmem2block"]
|
||||
)
|
||||
# Leds -----------------------------------------------------------------------------------------
|
||||
|
||||
if "leds" in d["csr_bases"]:
|
||||
dts += """
|
||||
leds: gpio@{leds_csr_base:x} {{
|
||||
compatible = "litex,gpio";
|
||||
reg = <0x{leds_csr_base:x} 0x4>;
|
||||
litex,direction = "out";
|
||||
status = "disabled";
|
||||
}};
|
||||
""".format(leds_csr_base=d["csr_bases"]["leds"])
|
||||
|
||||
# RGB Leds -------------------------------------------------------------------------------------
|
||||
|
||||
for name in ["rgb_led_r0", "rgb_led_g0", "rgb_led_b0"]:
|
||||
if name in d["csr_bases"]:
|
||||
dts += """
|
||||
{pwm_name}: pwm@{pwm_csr_base:x} {{
|
||||
compatible = "litex,pwm";
|
||||
reg = <0x{pwm_csr_base:x} 0x24>;
|
||||
clock = <100000000>;
|
||||
#pwm-cells = <3>;
|
||||
status = "okay";
|
||||
}};
|
||||
""".format(pwm_name=name, pwm_csr_base=d["csr_bases"][name])
|
||||
|
||||
# Switches -------------------------------------------------------------------------------------
|
||||
|
||||
if "switches" in d["csr_bases"]:
|
||||
dts += """
|
||||
switches: gpio@{switches_csr_base:x} {{
|
||||
compatible = "litex,gpio";
|
||||
reg = <0x{switches_csr_base:x} 0x4>;
|
||||
litex,direction = "in";
|
||||
status = "disabled";
|
||||
}};
|
||||
""".format(switches_csr_base=d["csr_bases"]["switches"])
|
||||
|
||||
# SPI ------------------------------------------------------------------------------------------
|
||||
|
||||
if "spi" in d["csr_bases"]:
|
||||
aliases["spi0"] = "litespi0"
|
||||
dts += """
|
||||
litespi0: spi@{spi_csr_base:x} {{
|
||||
compatible = "litex,litespi";
|
||||
reg = <0x{spi_csr_base:x} 0x100>;
|
||||
status = "okay";
|
||||
|
||||
litespi,max-bpw = <8>;
|
||||
litespi,sck-frequency = <1000000>;
|
||||
litespi,num-cs = <1>;
|
||||
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
spidev0: spidev@0 {{
|
||||
compatible = "linux,spidev";
|
||||
reg = <0>;
|
||||
spi-max-frequency = <1000000>;
|
||||
status = "okay";
|
||||
}};
|
||||
}};
|
||||
""".format(spi_csr_base=d["csr_bases"]["spi"])
|
||||
|
||||
# I2C ------------------------------------------------------------------------------------------
|
||||
|
||||
if "i2c0" in d["csr_bases"]:
|
||||
|
||||
dts += """
|
||||
i2c0: i2c@{i2c0_csr_base:x} {{
|
||||
compatible = "litex,i2c";
|
||||
|
@ -341,10 +344,9 @@ def generate_dts(d):
|
|||
}};
|
||||
""".format(i2c0_csr_base=d["csr_bases"]["i2c0"])
|
||||
|
||||
# XADC ---------------------------------------------------------------------------------------------
|
||||
# XADC -----------------------------------------------------------------------------------------
|
||||
|
||||
if "xadc" in d["csr_bases"]:
|
||||
|
||||
dts += """
|
||||
hwmon0: xadc@{xadc_csr_base:x} {{
|
||||
compatible = "litex,hwmon-xadc";
|
||||
|
@ -353,11 +355,10 @@ def generate_dts(d):
|
|||
}};
|
||||
""".format(xadc_csr_base=d["csr_bases"]["xadc"])
|
||||
|
||||
# Framebuffer --------------------------------------------------------------------------------------
|
||||
# Framebuffer ----------------------------------------------------------------------------------
|
||||
|
||||
if "framebuffer" in d["csr_bases"]:
|
||||
|
||||
# FIXME: dynamic framebuffer base and size
|
||||
# FIXME: Use dynamic framebuffer base and size
|
||||
framebuffer_base = 0xc8000000
|
||||
framebuffer_width = d["constants"]["litevideo_h_active"]
|
||||
framebuffer_height = d["constants"]["litevideo_v_active"]
|
||||
|
@ -370,11 +371,12 @@ def generate_dts(d):
|
|||
stride = <{framebuffer_stride}>;
|
||||
format = "a8b8g8r8";
|
||||
}};
|
||||
""".format(framebuffer_base=framebuffer_base,
|
||||
framebuffer_width=framebuffer_width,
|
||||
framebuffer_height=framebuffer_height,
|
||||
framebuffer_size=framebuffer_width * framebuffer_height * 4,
|
||||
framebuffer_stride=framebuffer_width * 4)
|
||||
""".format(
|
||||
framebuffer_base = framebuffer_base,
|
||||
framebuffer_width = framebuffer_width,
|
||||
framebuffer_height = framebuffer_height,
|
||||
framebuffer_size = framebuffer_width * framebuffer_height * 4,
|
||||
framebuffer_stride = framebuffer_width * 4)
|
||||
|
||||
dts += """
|
||||
litevideo0: gpu@{litevideo_base:x} {{
|
||||
|
@ -392,23 +394,23 @@ def generate_dts(d):
|
|||
litevideo,dma-offset = <0x{litevideo_dma_offset:x}>;
|
||||
litevideo,dma-length = <0x{litevideo_dma_length:x}>;
|
||||
}};
|
||||
""".format(litevideo_base=d["csr_bases"]["framebuffer"],
|
||||
litevideo_pixel_clock=int(d["constants"]["litevideo_pix_clk"] / 1e3),
|
||||
litevideo_h_active=d["constants"]["litevideo_h_active"],
|
||||
litevideo_h_blanking=d["constants"]["litevideo_h_blanking"],
|
||||
litevideo_h_sync=d["constants"]["litevideo_h_sync"],
|
||||
litevideo_h_front_porch=d["constants"]["litevideo_h_front_porch"],
|
||||
litevideo_v_active=d["constants"]["litevideo_v_active"],
|
||||
litevideo_v_blanking=d["constants"]["litevideo_v_blanking"],
|
||||
litevideo_v_sync=d["constants"]["litevideo_v_sync"],
|
||||
litevideo_v_front_porch=d["constants"]["litevideo_v_front_porch"],
|
||||
litevideo_dma_offset=framebuffer_base - d["memories"]["main_ram"]["base"],
|
||||
litevideo_dma_length=framebuffer_width * framebuffer_height * 4)
|
||||
""".format(
|
||||
litevideo_base = d["csr_bases"]["framebuffer"],
|
||||
litevideo_pixel_clock = int(d["constants"]["litevideo_pix_clk"] / 1e3),
|
||||
litevideo_h_active = d["constants"]["litevideo_h_active"],
|
||||
litevideo_h_blanking = d["constants"]["litevideo_h_blanking"],
|
||||
litevideo_h_sync = d["constants"]["litevideo_h_sync"],
|
||||
litevideo_h_front_porch = d["constants"]["litevideo_h_front_porch"],
|
||||
litevideo_v_active = d["constants"]["litevideo_v_active"],
|
||||
litevideo_v_blanking = d["constants"]["litevideo_v_blanking"],
|
||||
litevideo_v_sync = d["constants"]["litevideo_v_sync"],
|
||||
litevideo_v_front_porch = d["constants"]["litevideo_v_front_porch"],
|
||||
litevideo_dma_offset = framebuffer_base - d["memories"]["main_ram"]["base"],
|
||||
litevideo_dma_length = framebuffer_width * framebuffer_height * 4)
|
||||
|
||||
# ICAPBitstream ------------------------------------------------------------------------------------
|
||||
# ICAP Bitstream -------------------------------------------------------------------------------
|
||||
|
||||
if "icap_bit" in d["csr_bases"]:
|
||||
|
||||
dts += """
|
||||
fpga0: icap@{icap_csr_base:x} {{
|
||||
compatible = "litex,fpga-icap";
|
||||
|
@ -417,7 +419,7 @@ def generate_dts(d):
|
|||
}};
|
||||
""".format(icap_csr_base=d["csr_bases"]["icap_bit"])
|
||||
|
||||
# CLK ----------------------------------------------------------------------------------------------
|
||||
# Clocking ------------------------------------------------------------------------------------
|
||||
|
||||
def add_clkout(clkout_nr, clk_f, clk_p, clk_dn, clk_dd, clk_margin, clk_margin_exp):
|
||||
return """
|
||||
|
@ -433,17 +435,17 @@ def generate_dts(d):
|
|||
litex,clock-margin = <{clk_margin}>;
|
||||
litex,clock-margin-exp = <{clk_margin_exp}>;
|
||||
}};
|
||||
""".format(clkout_nr=clkout_nr,
|
||||
clk_f=clk_f,
|
||||
clk_p=clk_p,
|
||||
clk_dn=clk_dn,
|
||||
clk_dd=clk_dd,
|
||||
clk_margin=clk_margin,
|
||||
clk_margin_exp=clk_margin_exp)
|
||||
""".format(
|
||||
clkout_nr = clkout_nr,
|
||||
clk_f = clk_f,
|
||||
clk_p = clk_p,
|
||||
clk_dn = clk_dn,
|
||||
clk_dd = clk_dd,
|
||||
clk_margin = clk_margin,
|
||||
clk_margin_exp = clk_margin_exp)
|
||||
|
||||
if "mmcm" in d["csr_bases"]:
|
||||
nclkout = d["constants"]["nclkout"]
|
||||
|
||||
dts += """
|
||||
clk0: clk@{mmcm_csr_base:x} {{
|
||||
compatible = "litex,clk";
|
||||
|
@ -453,17 +455,13 @@ def generate_dts(d):
|
|||
#size-cells = <0>;
|
||||
clock-output-names =
|
||||
""".format(mmcm_csr_base=d["csr_bases"]["mmcm"])
|
||||
|
||||
for clkout_nr in range(nclkout - 1):
|
||||
|
||||
dts += """
|
||||
"CLKOUT{clkout_nr}",
|
||||
""".format(clkout_nr=clkout_nr)
|
||||
|
||||
dts += """
|
||||
"CLKOUT{nclkout}";
|
||||
""".format(nclkout=(nclkout - 1))
|
||||
|
||||
dts += """
|
||||
litex,lock-timeout = <{mmcm_lock_timeout}>;
|
||||
litex,drdy-timeout = <{mmcm_drdy_timeout}>;
|
||||
|
@ -477,15 +475,15 @@ def generate_dts(d):
|
|||
litex,clkout-divide-min = <{clkout_divide_range[0]}>;
|
||||
litex,clkout-divide-max = <{clkout_divide_range[1]}>;
|
||||
litex,vco-margin = <{vco_margin}>;
|
||||
""".format(mmcm_lock_timeout=d["constants"]["mmcm_lock_timeout"],
|
||||
mmcm_drdy_timeout=d["constants"]["mmcm_drdy_timeout"],
|
||||
sys_clk=d["constants"]["config_clock_frequency"],
|
||||
divclk_divide_range=(d["constants"]["divclk_divide_range_min"], d["constants"]["divclk_divide_range_max"]),
|
||||
clkfbout_mult_frange=(d["constants"]["clkfbout_mult_frange_min"], d["constants"]["clkfbout_mult_frange_max"]),
|
||||
vco_freq_range=(d["constants"]["vco_freq_range_min"], d["constants"]["vco_freq_range_max"]),
|
||||
clkout_divide_range=(d["constants"]["clkout_divide_range_min"], d["constants"]["clkout_divide_range_max"]),
|
||||
vco_margin=d["constants"]["vco_margin"])
|
||||
|
||||
""".format(
|
||||
mmcm_lock_timeout = d["constants"]["mmcm_lock_timeout"],
|
||||
mmcm_drdy_timeout = d["constants"]["mmcm_drdy_timeout"],
|
||||
sys_clk = d["constants"]["config_clock_frequency"],
|
||||
divclk_divide_range = (d["constants"]["divclk_divide_range_min"], d["constants"]["divclk_divide_range_max"]),
|
||||
clkfbout_mult_frange = (d["constants"]["clkfbout_mult_frange_min"], d["constants"]["clkfbout_mult_frange_max"]),
|
||||
vco_freq_range = (d["constants"]["vco_freq_range_min"], d["constants"]["vco_freq_range_max"]),
|
||||
clkout_divide_range = (d["constants"]["clkout_divide_range_min"], d["constants"]["clkout_divide_range_max"]),
|
||||
vco_margin = d["constants"]["vco_margin"])
|
||||
for clkout_nr in range(nclkout):
|
||||
dts += add_clkout(clkout_nr,
|
||||
d["constants"]["clkout_def_freq"],
|
||||
|
@ -494,35 +492,14 @@ def generate_dts(d):
|
|||
d["constants"]["clkout_def_duty_den"],
|
||||
d["constants"]["clkout_margin"],
|
||||
d["constants"]["clkout_margin_exp"])
|
||||
|
||||
dts += """
|
||||
};"""
|
||||
|
||||
# SDCARD -------------------------------------------------------------------------------------------
|
||||
|
||||
if "sdcore" in d["csr_bases"]:
|
||||
dts += """
|
||||
mmc0: mmc@{mmc_csr_base:x} {{
|
||||
compatible = "litex,mmc";
|
||||
reg = <
|
||||
0x{sdphy_csr_base:x} 0x100
|
||||
0x{sdcore_csr_base:x} 0x100
|
||||
0x{sdblock2mem:x} 0x100
|
||||
0x{sdmem2block:x} 0x100>;
|
||||
bus-width = <0x04>;
|
||||
status = "okay";
|
||||
}};
|
||||
""".format(mmc_csr_base=d["csr_bases"]["sdcore"],
|
||||
sdphy_csr_base=d["csr_bases"]["sdphy"],
|
||||
sdcore_csr_base=d["csr_bases"]["sdcore"],
|
||||
sdblock2mem=d["csr_bases"]["sdblock2mem"],
|
||||
sdmem2block=d["csr_bases"]["sdmem2block"]
|
||||
)
|
||||
dts += """
|
||||
};
|
||||
"""
|
||||
|
||||
# Aliases ------------------------------------------------------------------------------------------
|
||||
# Aliases --------------------------------------------------------------------------------------
|
||||
|
||||
if aliases:
|
||||
dts += """
|
||||
|
@ -542,7 +519,7 @@ def generate_dts(d):
|
|||
};
|
||||
"""
|
||||
|
||||
# Leds & switches ----------------------------------------------------------------------------------
|
||||
# Leds & switches ------------------------------------------------------------------------------
|
||||
|
||||
if "leds" in d["csr_bases"]:
|
||||
dts += """
|
||||
|
@ -562,7 +539,6 @@ def generate_dts(d):
|
|||
|
||||
return dts
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="LiteX's CSR JSON to Linux DTS generator")
|
||||
parser.add_argument("csr_json", help="CSR JSON file")
|
||||
|
|
Loading…
Reference in New Issue