summaryrefslogtreecommitdiffstats
path: root/include/hw/misc/xlnx-versal-xramc.h
blob: d3d1862676fc1b1661fea7661d900fd7b96df269 (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
91
92
93
94
95
96
97
/*
 * QEMU model of the Xilinx XRAM Controller.
 *
 * Copyright (c) 2021 Xilinx Inc.
 * SPDX-License-Identifier: GPL-2.0-or-later
 * Written by Edgar E. Iglesias <edgar.iglesias@xilinx.com>
 */

#ifndef XLNX_VERSAL_XRAMC_H
#define XLNX_VERSAL_XRAMC_H

#include "hw/sysbus.h"
#include "hw/register.h"

#define TYPE_XLNX_XRAM_CTRL "xlnx.versal-xramc"

#define XLNX_XRAM_CTRL(obj) \
     OBJECT_CHECK(XlnxXramCtrl, (obj), TYPE_XLNX_XRAM_CTRL)

REG32(XRAM_ERR_CTRL, 0x0)
    FIELD(XRAM_ERR_CTRL, UE_RES, 3, 1)
    FIELD(XRAM_ERR_CTRL, PWR_ERR_RES, 2, 1)
    FIELD(XRAM_ERR_CTRL, PZ_ERR_RES, 1, 1)
    FIELD(XRAM_ERR_CTRL, APB_ERR_RES, 0, 1)
REG32(XRAM_ISR, 0x4)
    FIELD(XRAM_ISR, INV_APB, 0, 1)
REG32(XRAM_IMR, 0x8)
    FIELD(XRAM_IMR, INV_APB, 0, 1)
REG32(XRAM_IEN, 0xc)
    FIELD(XRAM_IEN, INV_APB, 0, 1)
REG32(XRAM_IDS, 0x10)
    FIELD(XRAM_IDS, INV_APB, 0, 1)
REG32(XRAM_ECC_CNTL, 0x14)
    FIELD(XRAM_ECC_CNTL, FI_MODE, 2, 1)
    FIELD(XRAM_ECC_CNTL, DET_ONLY, 1, 1)
    FIELD(XRAM_ECC_CNTL, ECC_ON_OFF, 0, 1)
REG32(XRAM_CLR_EXE, 0x18)
    FIELD(XRAM_CLR_EXE, MON_7, 7, 1)
    FIELD(XRAM_CLR_EXE, MON_6, 6, 1)
    FIELD(XRAM_CLR_EXE, MON_5, 5, 1)
    FIELD(XRAM_CLR_EXE, MON_4, 4, 1)
    FIELD(XRAM_CLR_EXE, MON_3, 3, 1)
    FIELD(XRAM_CLR_EXE, MON_2, 2, 1)
    FIELD(XRAM_CLR_EXE, MON_1, 1, 1)
    FIELD(XRAM_CLR_EXE, MON_0, 0, 1)
REG32(XRAM_CE_FFA, 0x1c)
    FIELD(XRAM_CE_FFA, ADDR, 0, 20)
REG32(XRAM_CE_FFD0, 0x20)
REG32(XRAM_CE_FFD1, 0x24)
REG32(XRAM_CE_FFD2, 0x28)
REG32(XRAM_CE_FFD3, 0x2c)
REG32(XRAM_CE_FFE, 0x30)
    FIELD(XRAM_CE_FFE, SYNDROME, 0, 16)
REG32(XRAM_UE_FFA, 0x34)
    FIELD(XRAM_UE_FFA, ADDR, 0, 20)
REG32(XRAM_UE_FFD0, 0x38)
REG32(XRAM_UE_FFD1, 0x3c)
REG32(XRAM_UE_FFD2, 0x40)
REG32(XRAM_UE_FFD3, 0x44)
REG32(XRAM_UE_FFE, 0x48)
    FIELD(XRAM_UE_FFE, SYNDROME, 0, 16)
REG32(XRAM_FI_D0, 0x4c)
REG32(XRAM_FI_D1, 0x50)
REG32(XRAM_FI_D2, 0x54)
REG32(XRAM_FI_D3, 0x58)
REG32(XRAM_FI_SY, 0x5c)
    FIELD(XRAM_FI_SY, DATA, 0, 16)
REG32(XRAM_RMW_UE_FFA, 0x70)
    FIELD(XRAM_RMW_UE_FFA, ADDR, 0, 20)
REG32(XRAM_FI_CNTR, 0x74)
    FIELD(XRAM_FI_CNTR, COUNT, 0, 24)
REG32(XRAM_IMP, 0x80)
    FIELD(XRAM_IMP, SIZE, 0, 4)
REG32(XRAM_PRDY_DBG, 0x84)
    FIELD(XRAM_PRDY_DBG, ISLAND3, 12, 4)
    FIELD(XRAM_PRDY_DBG, ISLAND2, 8, 4)
    FIELD(XRAM_PRDY_DBG, ISLAND1, 4, 4)
    FIELD(XRAM_PRDY_DBG, ISLAND0, 0, 4)
REG32(XRAM_SAFETY_CHK, 0xff8)

#define XRAM_CTRL_R_MAX (R_XRAM_SAFETY_CHK + 1)

typedef struct XlnxXramCtrl {
    SysBusDevice parent_obj;
    MemoryRegion ram;
    qemu_irq irq;

    struct {
        uint64_t size;
        unsigned int encoded_size;
    } cfg;

    RegisterInfoArray *reg_array;
    uint32_t regs[XRAM_CTRL_R_MAX];
    RegisterInfo regs_info[XRAM_CTRL_R_MAX];
} XlnxXramCtrl;
#endif