Lines Matching +full:zynqmp +full:- +full:mailbox

13 #include "qemu/error-report.h"
20 #include "hw/qdev-properties.h"
21 #include "hw/arm/xlnx-versal.h"
26 #define TYPE_XLNX_VERSAL_VIRT_MACHINE MACHINE_TYPE_NAME("xlnx-versal-virt")
61 s->fdt = create_device_tree(&s->fdt_size); in fdt_create()
62 if (!s->fdt) { in fdt_create()
68 s->phandle.gic = qemu_fdt_alloc_phandle(s->fdt); in fdt_create()
69 for (i = 0; i < ARRAY_SIZE(s->phandle.ethernet_phy); i++) { in fdt_create()
70 s->phandle.ethernet_phy[i] = qemu_fdt_alloc_phandle(s->fdt); in fdt_create()
72 s->phandle.clk_25Mhz = qemu_fdt_alloc_phandle(s->fdt); in fdt_create()
73 s->phandle.clk_125Mhz = qemu_fdt_alloc_phandle(s->fdt); in fdt_create()
75 s->phandle.usb = qemu_fdt_alloc_phandle(s->fdt); in fdt_create()
76 s->phandle.dwc = qemu_fdt_alloc_phandle(s->fdt); in fdt_create()
78 qemu_fdt_add_subnode(s->fdt, "/chosen"); in fdt_create()
81 qemu_fdt_setprop_cell(s->fdt, "/", "interrupt-parent", s->phandle.gic); in fdt_create()
82 qemu_fdt_setprop_cell(s->fdt, "/", "#size-cells", 0x2); in fdt_create()
83 qemu_fdt_setprop_cell(s->fdt, "/", "#address-cells", 0x2); in fdt_create()
84 qemu_fdt_setprop_string(s->fdt, "/", "model", mc->desc); in fdt_create()
85 qemu_fdt_setprop_string(s->fdt, "/", "compatible", "xlnx-versal-virt"); in fdt_create()
91 qemu_fdt_add_subnode(s->fdt, name); in fdt_add_clk_node()
92 qemu_fdt_setprop_cell(s->fdt, name, "phandle", phandle); in fdt_add_clk_node()
93 qemu_fdt_setprop_cell(s->fdt, name, "clock-frequency", freq_hz); in fdt_add_clk_node()
94 qemu_fdt_setprop_cell(s->fdt, name, "#clock-cells", 0x0); in fdt_add_clk_node()
95 qemu_fdt_setprop_string(s->fdt, name, "compatible", "fixed-clock"); in fdt_add_clk_node()
96 qemu_fdt_setprop(s->fdt, name, "u-boot,dm-pre-reloc", NULL, 0); in fdt_add_clk_node()
103 qemu_fdt_add_subnode(s->fdt, "/cpus"); in fdt_add_cpu_nodes()
104 qemu_fdt_setprop_cell(s->fdt, "/cpus", "#size-cells", 0x0); in fdt_add_cpu_nodes()
105 qemu_fdt_setprop_cell(s->fdt, "/cpus", "#address-cells", 1); in fdt_add_cpu_nodes()
107 for (i = XLNX_VERSAL_NR_ACPUS - 1; i >= 0; i--) { in fdt_add_cpu_nodes()
111 qemu_fdt_add_subnode(s->fdt, name); in fdt_add_cpu_nodes()
112 qemu_fdt_setprop_cell(s->fdt, name, "reg", in fdt_add_cpu_nodes()
115 qemu_fdt_setprop_string(s->fdt, name, "enable-method", "psci"); in fdt_add_cpu_nodes()
117 qemu_fdt_setprop_string(s->fdt, name, "device_type", "cpu"); in fdt_add_cpu_nodes()
118 qemu_fdt_setprop_string(s->fdt, name, "compatible", in fdt_add_cpu_nodes()
119 armcpu->dtb_compatible); in fdt_add_cpu_nodes()
129 qemu_fdt_add_subnode(s->fdt, nodename); in fdt_add_gic_nodes()
130 qemu_fdt_setprop_cell(s->fdt, nodename, "phandle", s->phandle.gic); in fdt_add_gic_nodes()
131 qemu_fdt_setprop_cells(s->fdt, nodename, "interrupts", in fdt_add_gic_nodes()
134 qemu_fdt_setprop(s->fdt, nodename, "interrupt-controller", NULL, 0); in fdt_add_gic_nodes()
135 qemu_fdt_setprop_sized_cells(s->fdt, nodename, "reg", in fdt_add_gic_nodes()
140 qemu_fdt_setprop_cell(s->fdt, nodename, "#interrupt-cells", 3); in fdt_add_gic_nodes()
141 qemu_fdt_setprop_string(s->fdt, nodename, "compatible", "arm,gic-v3"); in fdt_add_gic_nodes()
147 const char compat[] = "arm,armv8-timer"; in fdt_add_timer_nodes()
150 qemu_fdt_add_subnode(s->fdt, "/timer"); in fdt_add_timer_nodes()
151 qemu_fdt_setprop_cells(s->fdt, "/timer", "interrupts", in fdt_add_timer_nodes()
156 qemu_fdt_setprop(s->fdt, "/timer", "compatible", in fdt_add_timer_nodes()
164 const char compatVersalDWC3[] = "xlnx,versal-dwc3"; in fdt_add_usb_xhci_nodes()
168 qemu_fdt_add_subnode(s->fdt, name); in fdt_add_usb_xhci_nodes()
169 qemu_fdt_setprop(s->fdt, name, "compatible", in fdt_add_usb_xhci_nodes()
171 qemu_fdt_setprop_sized_cells(s->fdt, name, "reg", in fdt_add_usb_xhci_nodes()
174 qemu_fdt_setprop(s->fdt, name, "clock-names", in fdt_add_usb_xhci_nodes()
176 qemu_fdt_setprop_cells(s->fdt, name, "clocks", in fdt_add_usb_xhci_nodes()
177 s->phandle.clk_25Mhz, s->phandle.clk_125Mhz); in fdt_add_usb_xhci_nodes()
178 qemu_fdt_setprop(s->fdt, name, "ranges", NULL, 0); in fdt_add_usb_xhci_nodes()
179 qemu_fdt_setprop_cell(s->fdt, name, "#address-cells", 2); in fdt_add_usb_xhci_nodes()
180 qemu_fdt_setprop_cell(s->fdt, name, "#size-cells", 2); in fdt_add_usb_xhci_nodes()
181 qemu_fdt_setprop_cell(s->fdt, name, "phandle", s->phandle.usb); in fdt_add_usb_xhci_nodes()
186 qemu_fdt_add_subnode(s->fdt, name); in fdt_add_usb_xhci_nodes()
187 qemu_fdt_setprop(s->fdt, name, "compatible", in fdt_add_usb_xhci_nodes()
189 qemu_fdt_setprop_sized_cells(s->fdt, name, "reg", in fdt_add_usb_xhci_nodes()
191 qemu_fdt_setprop(s->fdt, name, "interrupt-names", in fdt_add_usb_xhci_nodes()
193 qemu_fdt_setprop_cells(s->fdt, name, "interrupts", in fdt_add_usb_xhci_nodes()
196 qemu_fdt_setprop_cell(s->fdt, name, in fdt_add_usb_xhci_nodes()
197 "snps,quirk-frame-length-adjustment", 0x20); in fdt_add_usb_xhci_nodes()
198 qemu_fdt_setprop_cells(s->fdt, name, "#stream-id-cells", 1); in fdt_add_usb_xhci_nodes()
199 qemu_fdt_setprop_string(s->fdt, name, "dr_mode", "host"); in fdt_add_usb_xhci_nodes()
200 qemu_fdt_setprop_string(s->fdt, name, "phy-names", "usb3-phy"); in fdt_add_usb_xhci_nodes()
201 qemu_fdt_setprop(s->fdt, name, "snps,dis_u2_susphy_quirk", NULL, 0); in fdt_add_usb_xhci_nodes()
202 qemu_fdt_setprop(s->fdt, name, "snps,dis_u3_susphy_quirk", NULL, 0); in fdt_add_usb_xhci_nodes()
203 qemu_fdt_setprop(s->fdt, name, "snps,refclk_fladj", NULL, 0); in fdt_add_usb_xhci_nodes()
204 qemu_fdt_setprop(s->fdt, name, "snps,mask_phy_reset", NULL, 0); in fdt_add_usb_xhci_nodes()
205 qemu_fdt_setprop_cell(s->fdt, name, "phandle", s->phandle.dwc); in fdt_add_usb_xhci_nodes()
206 qemu_fdt_setprop_string(s->fdt, name, "maximum-speed", "high-speed"); in fdt_add_usb_xhci_nodes()
214 const char compat[] = "arm,pl011\0arm,sbsa-uart"; in fdt_add_uart_nodes()
220 qemu_fdt_add_subnode(s->fdt, name); in fdt_add_uart_nodes()
221 qemu_fdt_setprop_cell(s->fdt, name, "current-speed", 115200); in fdt_add_uart_nodes()
222 qemu_fdt_setprop_cells(s->fdt, name, "clocks", in fdt_add_uart_nodes()
223 s->phandle.clk_125Mhz, s->phandle.clk_125Mhz); in fdt_add_uart_nodes()
224 qemu_fdt_setprop(s->fdt, name, "clock-names", in fdt_add_uart_nodes()
227 qemu_fdt_setprop_cells(s->fdt, name, "interrupts", in fdt_add_uart_nodes()
230 qemu_fdt_setprop_sized_cells(s->fdt, name, "reg", in fdt_add_uart_nodes()
232 qemu_fdt_setprop(s->fdt, name, "compatible", in fdt_add_uart_nodes()
234 qemu_fdt_setprop(s->fdt, name, "u-boot,dm-pre-reloc", NULL, 0); in fdt_add_uart_nodes()
238 qemu_fdt_setprop_string(s->fdt, "/chosen", "stdout-path", name); in fdt_add_uart_nodes()
255 qemu_fdt_add_subnode(s->fdt, name); in fdt_add_canfd_nodes()
257 qemu_fdt_setprop_cell(s->fdt, name, "rx-fifo-depth", 0x40); in fdt_add_canfd_nodes()
258 qemu_fdt_setprop_cell(s->fdt, name, "tx-mailbox-count", 0x20); in fdt_add_canfd_nodes()
260 qemu_fdt_setprop_cells(s->fdt, name, "clocks", in fdt_add_canfd_nodes()
261 s->phandle.clk_25Mhz, s->phandle.clk_25Mhz); in fdt_add_canfd_nodes()
262 qemu_fdt_setprop(s->fdt, name, "clock-names", in fdt_add_canfd_nodes()
264 qemu_fdt_setprop_cells(s->fdt, name, "interrupts", in fdt_add_canfd_nodes()
267 qemu_fdt_setprop_sized_cells(s->fdt, name, "reg", in fdt_add_canfd_nodes()
269 qemu_fdt_setprop_string(s->fdt, name, "compatible", in fdt_add_canfd_nodes()
270 "xlnx,canfd-2.0"); in fdt_add_canfd_nodes()
279 char *name = g_strdup_printf("%s/fixed-link", gemname); in fdt_add_fixed_link_nodes()
281 qemu_fdt_add_subnode(s->fdt, name); in fdt_add_fixed_link_nodes()
282 qemu_fdt_setprop_cell(s->fdt, name, "phandle", phandle); in fdt_add_fixed_link_nodes()
283 qemu_fdt_setprop(s->fdt, name, "full-duplex", NULL, 0); in fdt_add_fixed_link_nodes()
284 qemu_fdt_setprop_cell(s->fdt, name, "speed", 1000); in fdt_add_fixed_link_nodes()
293 const char compat_gem[] = "cdns,zynqmp-gem\0cdns,gem"; in fdt_add_gem_nodes()
298 qemu_fdt_add_subnode(s->fdt, name); in fdt_add_gem_nodes()
300 fdt_add_fixed_link_nodes(s, name, s->phandle.ethernet_phy[i]); in fdt_add_gem_nodes()
301 qemu_fdt_setprop_string(s->fdt, name, "phy-mode", "rgmii-id"); in fdt_add_gem_nodes()
302 qemu_fdt_setprop_cell(s->fdt, name, "phy-handle", in fdt_add_gem_nodes()
303 s->phandle.ethernet_phy[i]); in fdt_add_gem_nodes()
304 qemu_fdt_setprop_cells(s->fdt, name, "clocks", in fdt_add_gem_nodes()
305 s->phandle.clk_25Mhz, s->phandle.clk_25Mhz, in fdt_add_gem_nodes()
306 s->phandle.clk_125Mhz, s->phandle.clk_125Mhz); in fdt_add_gem_nodes()
307 qemu_fdt_setprop(s->fdt, name, "clock-names", in fdt_add_gem_nodes()
309 qemu_fdt_setprop_cells(s->fdt, name, "interrupts", in fdt_add_gem_nodes()
314 qemu_fdt_setprop_sized_cells(s->fdt, name, "reg", in fdt_add_gem_nodes()
316 qemu_fdt_setprop(s->fdt, name, "compatible", in fdt_add_gem_nodes()
318 qemu_fdt_setprop_cell(s->fdt, name, "#address-cells", 1); in fdt_add_gem_nodes()
319 qemu_fdt_setprop_cell(s->fdt, name, "#size-cells", 0); in fdt_add_gem_nodes()
327 const char compat[] = "xlnx,zynqmp-dma-1.0"; in fdt_add_zdma_nodes()
330 for (i = XLNX_VERSAL_NR_ADMAS - 1; i >= 0; i--) { in fdt_add_zdma_nodes()
334 qemu_fdt_add_subnode(s->fdt, name); in fdt_add_zdma_nodes()
336 qemu_fdt_setprop_cell(s->fdt, name, "xlnx,bus-width", 64); in fdt_add_zdma_nodes()
337 qemu_fdt_setprop_cells(s->fdt, name, "clocks", in fdt_add_zdma_nodes()
338 s->phandle.clk_25Mhz, s->phandle.clk_25Mhz); in fdt_add_zdma_nodes()
339 qemu_fdt_setprop(s->fdt, name, "clock-names", in fdt_add_zdma_nodes()
341 qemu_fdt_setprop_cells(s->fdt, name, "interrupts", in fdt_add_zdma_nodes()
344 qemu_fdt_setprop_sized_cells(s->fdt, name, "reg", in fdt_add_zdma_nodes()
346 qemu_fdt_setprop(s->fdt, name, "compatible", compat, sizeof(compat)); in fdt_add_zdma_nodes()
354 const char compat[] = "arasan,sdhci-8.9a"; in fdt_add_sd_nodes()
357 for (i = ARRAY_SIZE(s->soc.pmc.iou.sd) - 1; i >= 0; i--) { in fdt_add_sd_nodes()
361 qemu_fdt_add_subnode(s->fdt, name); in fdt_add_sd_nodes()
363 qemu_fdt_setprop_cells(s->fdt, name, "clocks", in fdt_add_sd_nodes()
364 s->phandle.clk_25Mhz, s->phandle.clk_25Mhz); in fdt_add_sd_nodes()
365 qemu_fdt_setprop(s->fdt, name, "clock-names", in fdt_add_sd_nodes()
367 qemu_fdt_setprop_cells(s->fdt, name, "interrupts", in fdt_add_sd_nodes()
370 qemu_fdt_setprop_sized_cells(s->fdt, name, "reg", in fdt_add_sd_nodes()
372 qemu_fdt_setprop(s->fdt, name, "compatible", compat, sizeof(compat)); in fdt_add_sd_nodes()
379 const char compat[] = "xlnx,zynqmp-rtc"; in fdt_add_rtc_node()
383 qemu_fdt_add_subnode(s->fdt, name); in fdt_add_rtc_node()
385 qemu_fdt_setprop_cells(s->fdt, name, "interrupts", in fdt_add_rtc_node()
390 qemu_fdt_setprop(s->fdt, name, "interrupt-names", in fdt_add_rtc_node()
392 qemu_fdt_setprop_sized_cells(s->fdt, name, "reg", in fdt_add_rtc_node()
394 qemu_fdt_setprop(s->fdt, name, "compatible", compat, sizeof(compat)); in fdt_add_rtc_node()
401 const char interrupt_names[] = "bbram-error"; in fdt_add_bbram_node()
404 qemu_fdt_add_subnode(s->fdt, name); in fdt_add_bbram_node()
406 qemu_fdt_setprop_cells(s->fdt, name, "interrupts", in fdt_add_bbram_node()
409 qemu_fdt_setprop(s->fdt, name, "interrupt-names", in fdt_add_bbram_node()
411 qemu_fdt_setprop_sized_cells(s->fdt, name, "reg", in fdt_add_bbram_node()
414 qemu_fdt_setprop(s->fdt, name, "compatible", compat, sizeof(compat)); in fdt_add_bbram_node()
424 qemu_fdt_add_subnode(s->fdt, name); in fdt_add_efuse_ctrl_node()
426 qemu_fdt_setprop_cells(s->fdt, name, "interrupts", in fdt_add_efuse_ctrl_node()
429 qemu_fdt_setprop(s->fdt, name, "interrupt-names", in fdt_add_efuse_ctrl_node()
431 qemu_fdt_setprop_sized_cells(s->fdt, name, "reg", in fdt_add_efuse_ctrl_node()
434 qemu_fdt_setprop(s->fdt, name, "compatible", compat, sizeof(compat)); in fdt_add_efuse_ctrl_node()
444 qemu_fdt_add_subnode(s->fdt, name); in fdt_add_efuse_cache_node()
446 qemu_fdt_setprop_sized_cells(s->fdt, name, "reg", in fdt_add_efuse_cache_node()
449 qemu_fdt_setprop(s->fdt, name, "compatible", compat, sizeof(compat)); in fdt_add_efuse_cache_node()
505 size -= mapsize; in fdt_add_memory_nodes()
554 fdt_add_memory_nodes(s, fdt, binfo->ram_size); in versal_virt_modify_dtb()
562 *fdt_size = board->fdt_size; in versal_virt_get_dtb()
563 return board->fdt; in versal_virt_get_dtb()
580 pic_irq = qdev_get_gpio_in(DEVICE(&s->soc.fpd.apu.gic), irq); in create_virtio_regions()
581 dev = qdev_new("virtio-mmio"); in create_virtio_regions()
582 object_property_add_child(OBJECT(&s->soc), name, OBJECT(dev)); in create_virtio_regions()
586 memory_region_add_subregion(&s->soc.mr_ps, base, mr); in create_virtio_regions()
595 qemu_fdt_add_subnode(s->fdt, name); in create_virtio_regions()
596 qemu_fdt_setprop(s->fdt, name, "dma-coherent", NULL, 0); in create_virtio_regions()
597 qemu_fdt_setprop_cells(s->fdt, name, "interrupts", in create_virtio_regions()
600 qemu_fdt_setprop_sized_cells(s->fdt, name, "reg", in create_virtio_regions()
602 qemu_fdt_setprop_string(s->fdt, name, "compatible", "virtio,mmio"); in create_virtio_regions()
639 qdev_realize_and_unref(card, BUS(&sd->sdbus), in sd_plugin_card()
647 return g_strdup(s->ospi_model); in versal_get_ospi_model()
654 g_free(s->ospi_model); in versal_set_ospi_model()
655 s->ospi_model = g_strdup(value); in versal_set_ospi_model()
667 * to use the -kernel command line option. in versal_virt_init()
669 * Users can load firmware or boot-loaders with the -device loader options. in versal_virt_init()
674 * If there's no -kernel option, we generate a DTB and place it at 0x1000 in versal_virt_init()
677 * If users want to provide their own DTB, they can use the -dtb option. in versal_virt_init()
682 * as the PSCI conduit. When there's no -kernel, we assume the user in versal_virt_init()
688 if (machine->kernel_filename) { in versal_virt_init()
692 object_initialize_child(OBJECT(machine), "xlnx-versal", &s->soc, in versal_virt_init()
694 object_property_set_link(OBJECT(&s->soc), "ddr", OBJECT(machine->ram), in versal_virt_init()
696 object_property_set_link(OBJECT(&s->soc), "canbus0", OBJECT(s->canbus[0]), in versal_virt_init()
698 object_property_set_link(OBJECT(&s->soc), "canbus1", OBJECT(s->canbus[1]), in versal_virt_init()
700 sysbus_realize(SYS_BUS_DEVICE(&s->soc), &error_fatal); in versal_virt_init()
717 fdt_add_clk_node(s, "/clk125", 125000000, s->phandle.clk_125Mhz); in versal_virt_init()
718 fdt_add_clk_node(s, "/clk25", 25000000, s->phandle.clk_25Mhz); in versal_virt_init()
721 * modules unaware of multiple address-spaces. */ in versal_virt_init()
723 0, &s->soc.fpd.apu.mr, 0); in versal_virt_init()
726 bbram_attach_drive(&s->soc.pmc.bbram); in versal_virt_init()
729 efuse_attach_drive(&s->soc.pmc.efuse); in versal_virt_init()
732 for (i = 0; i < ARRAY_SIZE(s->soc.pmc.iou.sd); i++) { in versal_virt_init()
733 sd_plugin_card(&s->soc.pmc.iou.sd[i], in versal_virt_init()
737 s->binfo.ram_size = machine->ram_size; in versal_virt_init()
738 s->binfo.loader_start = 0x0; in versal_virt_init()
739 s->binfo.get_dtb = versal_virt_get_dtb; in versal_virt_init()
740 s->binfo.modify_dtb = versal_virt_modify_dtb; in versal_virt_init()
741 s->binfo.psci_conduit = psci_conduit; in versal_virt_init()
742 if (!machine->kernel_filename) { in versal_virt_init()
743 /* Some boot-loaders (e.g u-boot) don't like blobs at address 0 (NULL). in versal_virt_init()
745 s->binfo.loader_start = 0x1000; in versal_virt_init()
746 s->binfo.dtb_limit = 0x1000000; in versal_virt_init()
748 arm_load_kernel(&s->soc.fpd.apu.cpu[0], machine, &s->binfo); in versal_virt_init()
757 spi_bus = qdev_get_child_bus(DEVICE(&s->soc.pmc.iou.ospi), "spi0"); in versal_virt_init()
759 if (s->ospi_model) { in versal_virt_init()
760 flash_klass = object_class_by_name(s->ospi_model); in versal_virt_init()
765 " not a subtype of m25p80", s->ospi_model); in versal_virt_init()
770 flash_dev = qdev_new(s->ospi_model ? s->ospi_model : "mt35xu01g"); in versal_virt_init()
781 sysbus_connect_irq(SYS_BUS_DEVICE(&s->soc.pmc.iou.ospi), in versal_virt_init()
791 * User can set canbus0 and canbus1 properties to can-bus object and connect in versal_virt_machine_instance_init()
795 (Object **)&s->canbus[0], in versal_virt_machine_instance_init()
799 (Object **)&s->canbus[1], in versal_virt_machine_instance_init()
808 g_free(s->ospi_model); in versal_virt_machine_finalize()
815 mc->desc = "Xilinx Versal Virtual development board"; in versal_virt_machine_class_init()
816 mc->init = versal_virt_init; in versal_virt_machine_class_init()
817 mc->min_cpus = XLNX_VERSAL_NR_ACPUS + XLNX_VERSAL_NR_RCPUS; in versal_virt_machine_class_init()
818 mc->max_cpus = XLNX_VERSAL_NR_ACPUS + XLNX_VERSAL_NR_RCPUS; in versal_virt_machine_class_init()
819 mc->default_cpus = XLNX_VERSAL_NR_ACPUS + XLNX_VERSAL_NR_RCPUS; in versal_virt_machine_class_init()
820 mc->no_cdrom = true; in versal_virt_machine_class_init()
821 mc->default_ram_id = "ddr"; in versal_virt_machine_class_init()
822 object_class_property_add_str(oc, "ospi-flash", versal_get_ospi_model, in versal_virt_machine_class_init()
824 object_class_property_set_description(oc, "ospi-flash", in versal_virt_machine_class_init()