| 1 | /* |
| 2 | * AMD/Xilinx Versal family SoC model. |
| 3 | * |
| 4 | * Copyright (c) 2018 Xilinx Inc. |
| 5 | * Copyright (c) 2025 Advanced Micro Devices, Inc. |
| 6 | * Written by Edgar E. Iglesias |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 or |
| 10 | * (at your option) any later version. |
| 11 | */ |
| 12 | |
| 13 | #ifndef XLNX_VERSAL_H |
| 14 | #define XLNX_VERSAL_H |
| 15 | |
| 16 | #include "hw/core/sysbus.h" |
| 17 | #include "qom/object.h" |
| 18 | #include "net/can_emu.h" |
| 19 | #include "hw/arm/xlnx-versal-version.h" |
| 20 | |
| 21 | #define TYPE_XLNX_VERSAL_BASE "xlnx-versal-base" |
| 22 | OBJECT_DECLARE_TYPE(Versal, VersalClass, XLNX_VERSAL_BASE) |
| 23 | |
| 24 | #define TYPE_XLNX_VERSAL "xlnx-versal" |
| 25 | #define TYPE_XLNX_VERSAL2 "xlnx-versal2" |
| 26 | |
| 27 | struct Versal { |
| 28 | /*< private >*/ |
| 29 | SysBusDevice parent_obj; |
| 30 | |
| 31 | /*< public >*/ |
| 32 | GArray *intc; |
| 33 | MemoryRegion mr_ps; |
| 34 | |
| 35 | struct { |
| 36 | uint32_t clk_25mhz; |
| 37 | uint32_t clk_125mhz; |
| 38 | uint32_t gic; |
| 39 | } phandle; |
| 40 | |
| 41 | struct { |
| 42 | MemoryRegion *mr_ddr; |
| 43 | CanBusState **canbus; |
| 44 | void *fdt; |
| 45 | } cfg; |
| 46 | }; |
| 47 | |
| 48 | struct VersalClass { |
| 49 | SysBusDeviceClass parent; |
| 50 | |
| 51 | VersalVersion version; |
| 52 | }; |
| 53 | |
| 54 | static inline void versal_set_fdt(Versal *s, void *fdt) |
| 55 | { |
| 56 | g_assert(!qdev_is_realized(DEVICE(s))); |
| 57 | s->cfg.fdt = fdt; |
| 58 | } |
| 59 | |
| 60 | void versal_fdt_add_memory_nodes(Versal *s, uint64_t ram_size); |
| 61 | |
| 62 | DeviceState *versal_get_boot_cpu(Versal *s); |
| 63 | void versal_sdhci_plug_card(Versal *s, int sd_idx, BlockBackend *blk); |
| 64 | void versal_efuse_attach_drive(Versal *s, BlockBackend *blk); |
| 65 | void versal_bbram_attach_drive(Versal *s, BlockBackend *blk); |
| 66 | void versal_ospi_create_flash(Versal *s, int flash_idx, const char *flash_mdl, |
| 67 | BlockBackend *blk); |
| 68 | |
| 69 | qemu_irq versal_get_reserved_irq(Versal *s, int idx, int *dtb_idx); |
| 70 | hwaddr versal_get_reserved_mmio_addr(Versal *s); |
| 71 | |
| 72 | int versal_get_num_cpu(VersalVersion version); |
| 73 | int versal_get_num_can(VersalVersion version); |
| 74 | int versal_get_num_sdhci(VersalVersion version); |
| 75 | |
| 76 | static inline const char *versal_get_class(VersalVersion version) |
| 77 | { |
| 78 | switch (version) { |
| 79 | case VERSAL_VER_VERSAL: |
| 80 | return TYPE_XLNX_VERSAL; |
| 81 | |
| 82 | case VERSAL_VER_VERSAL2: |
| 83 | return TYPE_XLNX_VERSAL2; |
| 84 | |
| 85 | default: |
| 86 | g_assert_not_reached(); |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | #endif |