summary refs log tree commit diff stats
path: root/include/hw/arm/xlnx-versal.h
blob: e1fb1f4cf5b3dade7da55cae6f7aa24eb5f5e2f8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
 * AMD/Xilinx Versal family SoC model.
 *
 * Copyright (c) 2018 Xilinx Inc.
 * Copyright (c) 2025 Advanced Micro Devices, Inc.
 * Written by Edgar E. Iglesias
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 or
 * (at your option) any later version.
 */

#ifndef XLNX_VERSAL_H
#define XLNX_VERSAL_H

#include "hw/sysbus.h"
#include "qom/object.h"
#include "net/can_emu.h"
#include "hw/arm/xlnx-versal-version.h"

#define TYPE_XLNX_VERSAL_BASE "xlnx-versal-base"
OBJECT_DECLARE_TYPE(Versal, VersalClass, XLNX_VERSAL_BASE)

#define TYPE_XLNX_VERSAL "xlnx-versal"
#define TYPE_XLNX_VERSAL2 "xlnx-versal2"

struct Versal {
    /*< private >*/
    SysBusDevice parent_obj;

    /*< public >*/
    GArray *intc;
    MemoryRegion mr_ps;

    struct {
        uint32_t clk_25mhz;
        uint32_t clk_125mhz;
        uint32_t gic;
    } phandle;

    struct {
        MemoryRegion *mr_ddr;
        CanBusState **canbus;
        void *fdt;
    } cfg;
};

struct VersalClass {
    SysBusDeviceClass parent;

    VersalVersion version;
};

static inline void versal_set_fdt(Versal *s, void *fdt)
{
    g_assert(!qdev_is_realized(DEVICE(s)));
    s->cfg.fdt = fdt;
}

void versal_fdt_add_memory_nodes(Versal *s, uint64_t ram_size);

DeviceState *versal_get_boot_cpu(Versal *s);
void versal_sdhci_plug_card(Versal *s, int sd_idx, BlockBackend *blk);
void versal_efuse_attach_drive(Versal *s, BlockBackend *blk);
void versal_bbram_attach_drive(Versal *s, BlockBackend *blk);
void versal_ospi_create_flash(Versal *s, int flash_idx, const char *flash_mdl,
                              BlockBackend *blk);

qemu_irq versal_get_reserved_irq(Versal *s, int idx, int *dtb_idx);
hwaddr versal_get_reserved_mmio_addr(Versal *s);

int versal_get_num_cpu(VersalVersion version);
int versal_get_num_can(VersalVersion version);
int versal_get_num_sdhci(VersalVersion version);

static inline const char *versal_get_class(VersalVersion version)
{
    switch (version) {
    case VERSAL_VER_VERSAL:
        return TYPE_XLNX_VERSAL;

    case VERSAL_VER_VERSAL2:
        return TYPE_XLNX_VERSAL2;

    default:
        g_assert_not_reached();
    }
}

#endif