xref: /openbmc/qemu/include/hw/arm/xlnx-versal.h (revision 99b16e8e)
1 /*
2  * Model of the Xilinx Versal
3  *
4  * Copyright (c) 2018 Xilinx Inc.
5  * Written by Edgar E. Iglesias
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 or
9  * (at your option) any later version.
10  */
11 
12 #ifndef XLNX_VERSAL_H
13 #define XLNX_VERSAL_H
14 
15 #include "hw/sysbus.h"
16 #include "hw/cpu/cluster.h"
17 #include "hw/or-irq.h"
18 #include "hw/sd/sdhci.h"
19 #include "hw/intc/arm_gicv3.h"
20 #include "hw/char/pl011.h"
21 #include "hw/dma/xlnx-zdma.h"
22 #include "hw/net/cadence_gem.h"
23 #include "hw/rtc/xlnx-zynqmp-rtc.h"
24 #include "qom/object.h"
25 #include "hw/usb/xlnx-usb-subsystem.h"
26 #include "hw/misc/xlnx-versal-xramc.h"
27 #include "hw/nvram/xlnx-bbram.h"
28 #include "hw/nvram/xlnx-versal-efuse.h"
29 #include "hw/ssi/xlnx-versal-ospi.h"
30 #include "hw/dma/xlnx_csu_dma.h"
31 #include "hw/misc/xlnx-versal-crl.h"
32 #include "hw/misc/xlnx-versal-pmc-iou-slcr.h"
33 #include "hw/net/xlnx-versal-canfd.h"
34 #include "hw/misc/xlnx-versal-cfu.h"
35 #include "hw/misc/xlnx-versal-cframe-reg.h"
36 
37 #define TYPE_XLNX_VERSAL "xlnx-versal"
38 OBJECT_DECLARE_SIMPLE_TYPE(Versal, XLNX_VERSAL)
39 
40 #define XLNX_VERSAL_NR_ACPUS   2
41 #define XLNX_VERSAL_NR_RCPUS   2
42 #define XLNX_VERSAL_NR_UARTS   2
43 #define XLNX_VERSAL_NR_GEMS    2
44 #define XLNX_VERSAL_NR_ADMAS   8
45 #define XLNX_VERSAL_NR_SDS     2
46 #define XLNX_VERSAL_NR_XRAM    4
47 #define XLNX_VERSAL_NR_IRQS    192
48 #define XLNX_VERSAL_NR_CANFD   2
49 #define XLNX_VERSAL_CANFD_REF_CLK (24 * 1000 * 1000)
50 #define XLNX_VERSAL_NR_CFRAME  15
51 
52 struct Versal {
53     /*< private >*/
54     SysBusDevice parent_obj;
55 
56     /*< public >*/
57     struct {
58         struct {
59             MemoryRegion mr;
60             CPUClusterState cluster;
61             ARMCPU cpu[XLNX_VERSAL_NR_ACPUS];
62             GICv3State gic;
63         } apu;
64     } fpd;
65 
66     MemoryRegion mr_ps;
67 
68     struct {
69         /* 4 ranges to access DDR.  */
70         MemoryRegion mr_ddr_ranges[4];
71     } noc;
72 
73     struct {
74         MemoryRegion mr_ocm;
75 
76         struct {
77             PL011State uart[XLNX_VERSAL_NR_UARTS];
78             CadenceGEMState gem[XLNX_VERSAL_NR_GEMS];
79             XlnxZDMA adma[XLNX_VERSAL_NR_ADMAS];
80             VersalUsb2 usb;
81             CanBusState *canbus[XLNX_VERSAL_NR_CANFD];
82             XlnxVersalCANFDState canfd[XLNX_VERSAL_NR_CANFD];
83         } iou;
84 
85         /* Real-time Processing Unit.  */
86         struct {
87             MemoryRegion mr;
88             MemoryRegion mr_ps_alias;
89 
90             CPUClusterState cluster;
91             ARMCPU cpu[XLNX_VERSAL_NR_RCPUS];
92         } rpu;
93 
94         struct {
95             OrIRQState irq_orgate;
96             XlnxXramCtrl ctrl[XLNX_VERSAL_NR_XRAM];
97         } xram;
98 
99         XlnxVersalCRL crl;
100     } lpd;
101 
102     /* The Platform Management Controller subsystem.  */
103     struct {
104         struct {
105             SDHCIState sd[XLNX_VERSAL_NR_SDS];
106             XlnxVersalPmcIouSlcr slcr;
107 
108             struct {
109                 XlnxVersalOspi ospi;
110                 XlnxCSUDMA dma_src;
111                 XlnxCSUDMA dma_dst;
112                 MemoryRegion linear_mr;
113                 OrIRQState irq_orgate;
114             } ospi;
115         } iou;
116 
117         XlnxZynqMPRTC rtc;
118         XlnxBBRam bbram;
119         XlnxEFuse efuse;
120         XlnxVersalEFuseCtrl efuse_ctrl;
121         XlnxVersalEFuseCache efuse_cache;
122         XlnxVersalCFUAPB cfu_apb;
123         XlnxVersalCFUFDRO cfu_fdro;
124         XlnxVersalCFUSFR cfu_sfr;
125         XlnxVersalCFrameReg cframe[XLNX_VERSAL_NR_CFRAME];
126         XlnxVersalCFrameBcastReg cframe_bcast;
127 
128         OrIRQState apb_irq_orgate;
129     } pmc;
130 
131     struct {
132         MemoryRegion *mr_ddr;
133     } cfg;
134 };
135 
136 /* Memory-map and IRQ definitions. Copied a subset from
137  * auto-generated files.  */
138 
139 #define VERSAL_GIC_MAINT_IRQ        9
140 #define VERSAL_TIMER_VIRT_IRQ       11
141 #define VERSAL_TIMER_S_EL1_IRQ      13
142 #define VERSAL_TIMER_NS_EL1_IRQ     14
143 #define VERSAL_TIMER_NS_EL2_IRQ     10
144 
145 #define VERSAL_CRL_IRQ             10
146 #define VERSAL_UART0_IRQ_0         18
147 #define VERSAL_UART1_IRQ_0         19
148 #define VERSAL_CANFD0_IRQ_0        20
149 #define VERSAL_CANFD1_IRQ_0        21
150 #define VERSAL_USB0_IRQ_0          22
151 #define VERSAL_GEM0_IRQ_0          56
152 #define VERSAL_GEM0_WAKE_IRQ_0     57
153 #define VERSAL_GEM1_IRQ_0          58
154 #define VERSAL_GEM1_WAKE_IRQ_0     59
155 #define VERSAL_ADMA_IRQ_0          60
156 #define VERSAL_XRAM_IRQ_0          79
157 #define VERSAL_CFU_IRQ_0           120
158 #define VERSAL_PMC_APB_IRQ         121
159 #define VERSAL_OSPI_IRQ            124
160 #define VERSAL_SD0_IRQ_0           126
161 #define VERSAL_EFUSE_IRQ           139
162 #define VERSAL_RTC_ALARM_IRQ       142
163 #define VERSAL_RTC_SECONDS_IRQ     143
164 
165 /* Architecturally reserved IRQs suitable for virtualization.  */
166 #define VERSAL_RSVD_IRQ_FIRST 111
167 #define VERSAL_RSVD_IRQ_LAST  118
168 
169 #define MM_TOP_RSVD                 0xa0000000U
170 #define MM_TOP_RSVD_SIZE            0x4000000
171 #define MM_GIC_APU_DIST_MAIN        0xf9000000U
172 #define MM_GIC_APU_DIST_MAIN_SIZE   0x10000
173 #define MM_GIC_APU_REDIST_0         0xf9080000U
174 #define MM_GIC_APU_REDIST_0_SIZE    0x80000
175 
176 #define MM_UART0                    0xff000000U
177 #define MM_UART0_SIZE               0x10000
178 #define MM_UART1                    0xff010000U
179 #define MM_UART1_SIZE               0x10000
180 
181 #define MM_CANFD0                   0xff060000U
182 #define MM_CANFD0_SIZE              0x10000
183 #define MM_CANFD1                   0xff070000U
184 #define MM_CANFD1_SIZE              0x10000
185 
186 #define MM_GEM0                     0xff0c0000U
187 #define MM_GEM0_SIZE                0x10000
188 #define MM_GEM1                     0xff0d0000U
189 #define MM_GEM1_SIZE                0x10000
190 
191 #define MM_ADMA_CH0                 0xffa80000U
192 #define MM_ADMA_CH0_SIZE            0x10000
193 
194 #define MM_OCM                      0xfffc0000U
195 #define MM_OCM_SIZE                 0x40000
196 
197 #define MM_XRAM                     0xfe800000
198 #define MM_XRAMC                    0xff8e0000
199 #define MM_XRAMC_SIZE               0x10000
200 
201 #define MM_USB2_CTRL_REGS           0xFF9D0000
202 #define MM_USB2_CTRL_REGS_SIZE      0x10000
203 
204 #define MM_USB_0                    0xFE200000
205 #define MM_USB_0_SIZE               0x10000
206 
207 #define MM_TOP_DDR                  0x0
208 #define MM_TOP_DDR_SIZE             0x80000000U
209 #define MM_TOP_DDR_2                0x800000000ULL
210 #define MM_TOP_DDR_2_SIZE           0x800000000ULL
211 #define MM_TOP_DDR_3                0xc000000000ULL
212 #define MM_TOP_DDR_3_SIZE           0x4000000000ULL
213 #define MM_TOP_DDR_4                0x10000000000ULL
214 #define MM_TOP_DDR_4_SIZE           0xb780000000ULL
215 
216 #define MM_PSM_START                0xffc80000U
217 #define MM_PSM_END                  0xffcf0000U
218 
219 #define MM_CRL                      0xff5e0000U
220 #define MM_CRL_SIZE                 0x300000
221 #define MM_IOU_SCNTR                0xff130000U
222 #define MM_IOU_SCNTR_SIZE           0x10000
223 #define MM_IOU_SCNTRS               0xff140000U
224 #define MM_IOU_SCNTRS_SIZE          0x10000
225 #define MM_FPD_CRF                  0xfd1a0000U
226 #define MM_FPD_CRF_SIZE             0x140000
227 #define MM_FPD_FPD_APU              0xfd5c0000
228 #define MM_FPD_FPD_APU_SIZE         0x100
229 
230 #define MM_PMC_PMC_IOU_SLCR         0xf1060000
231 #define MM_PMC_PMC_IOU_SLCR_SIZE    0x10000
232 
233 #define MM_PMC_OSPI                 0xf1010000
234 #define MM_PMC_OSPI_SIZE            0x10000
235 
236 #define MM_PMC_OSPI_DAC             0xc0000000
237 #define MM_PMC_OSPI_DAC_SIZE        0x20000000
238 
239 #define MM_PMC_OSPI_DMA_DST         0xf1011800
240 #define MM_PMC_OSPI_DMA_SRC         0xf1011000
241 
242 #define MM_PMC_SD0                  0xf1040000U
243 #define MM_PMC_SD0_SIZE             0x10000
244 #define MM_PMC_BBRAM_CTRL           0xf11f0000
245 #define MM_PMC_BBRAM_CTRL_SIZE      0x00050
246 #define MM_PMC_EFUSE_CTRL           0xf1240000
247 #define MM_PMC_EFUSE_CTRL_SIZE      0x00104
248 #define MM_PMC_EFUSE_CACHE          0xf1250000
249 #define MM_PMC_EFUSE_CACHE_SIZE     0x00C00
250 
251 #define MM_PMC_CFU_APB              0xf12b0000
252 #define MM_PMC_CFU_APB_SIZE         0x10000
253 #define MM_PMC_CFU_STREAM           0xf12c0000
254 #define MM_PMC_CFU_STREAM_SIZE      0x1000
255 #define MM_PMC_CFU_SFR              0xf12c1000
256 #define MM_PMC_CFU_SFR_SIZE         0x1000
257 #define MM_PMC_CFU_FDRO             0xf12c2000
258 #define MM_PMC_CFU_FDRO_SIZE        0x1000
259 #define MM_PMC_CFU_STREAM_2         0xf1f80000
260 #define MM_PMC_CFU_STREAM_2_SIZE    0x40000
261 
262 #define MM_PMC_CFRAME0_REG          0xf12d0000
263 #define MM_PMC_CFRAME0_REG_SIZE     0x1000
264 #define MM_PMC_CFRAME0_FDRI         0xf12d1000
265 #define MM_PMC_CFRAME0_FDRI_SIZE    0x1000
266 #define MM_PMC_CFRAME1_REG          0xf12d2000
267 #define MM_PMC_CFRAME1_REG_SIZE     0x1000
268 #define MM_PMC_CFRAME1_FDRI         0xf12d3000
269 #define MM_PMC_CFRAME1_FDRI_SIZE    0x1000
270 #define MM_PMC_CFRAME2_REG          0xf12d4000
271 #define MM_PMC_CFRAME2_REG_SIZE     0x1000
272 #define MM_PMC_CFRAME2_FDRI         0xf12d5000
273 #define MM_PMC_CFRAME2_FDRI_SIZE    0x1000
274 #define MM_PMC_CFRAME3_REG          0xf12d6000
275 #define MM_PMC_CFRAME3_REG_SIZE     0x1000
276 #define MM_PMC_CFRAME3_FDRI         0xf12d7000
277 #define MM_PMC_CFRAME3_FDRI_SIZE    0x1000
278 #define MM_PMC_CFRAME4_REG          0xf12d8000
279 #define MM_PMC_CFRAME4_REG_SIZE     0x1000
280 #define MM_PMC_CFRAME4_FDRI         0xf12d9000
281 #define MM_PMC_CFRAME4_FDRI_SIZE    0x1000
282 #define MM_PMC_CFRAME5_REG          0xf12da000
283 #define MM_PMC_CFRAME5_REG_SIZE     0x1000
284 #define MM_PMC_CFRAME5_FDRI         0xf12db000
285 #define MM_PMC_CFRAME5_FDRI_SIZE    0x1000
286 #define MM_PMC_CFRAME6_REG          0xf12dc000
287 #define MM_PMC_CFRAME6_REG_SIZE     0x1000
288 #define MM_PMC_CFRAME6_FDRI         0xf12dd000
289 #define MM_PMC_CFRAME6_FDRI_SIZE    0x1000
290 #define MM_PMC_CFRAME7_REG          0xf12de000
291 #define MM_PMC_CFRAME7_REG_SIZE     0x1000
292 #define MM_PMC_CFRAME7_FDRI         0xf12df000
293 #define MM_PMC_CFRAME7_FDRI_SIZE    0x1000
294 #define MM_PMC_CFRAME8_REG          0xf12e0000
295 #define MM_PMC_CFRAME8_REG_SIZE     0x1000
296 #define MM_PMC_CFRAME8_FDRI         0xf12e1000
297 #define MM_PMC_CFRAME8_FDRI_SIZE    0x1000
298 #define MM_PMC_CFRAME9_REG          0xf12e2000
299 #define MM_PMC_CFRAME9_REG_SIZE     0x1000
300 #define MM_PMC_CFRAME9_FDRI         0xf12e3000
301 #define MM_PMC_CFRAME9_FDRI_SIZE    0x1000
302 #define MM_PMC_CFRAME10_REG         0xf12e4000
303 #define MM_PMC_CFRAME10_REG_SIZE    0x1000
304 #define MM_PMC_CFRAME10_FDRI        0xf12e5000
305 #define MM_PMC_CFRAME10_FDRI_SIZE   0x1000
306 #define MM_PMC_CFRAME11_REG         0xf12e6000
307 #define MM_PMC_CFRAME11_REG_SIZE    0x1000
308 #define MM_PMC_CFRAME11_FDRI        0xf12e7000
309 #define MM_PMC_CFRAME11_FDRI_SIZE   0x1000
310 #define MM_PMC_CFRAME12_REG         0xf12e8000
311 #define MM_PMC_CFRAME12_REG_SIZE    0x1000
312 #define MM_PMC_CFRAME12_FDRI        0xf12e9000
313 #define MM_PMC_CFRAME12_FDRI_SIZE   0x1000
314 #define MM_PMC_CFRAME13_REG         0xf12ea000
315 #define MM_PMC_CFRAME13_REG_SIZE    0x1000
316 #define MM_PMC_CFRAME13_FDRI        0xf12eb000
317 #define MM_PMC_CFRAME13_FDRI_SIZE   0x1000
318 #define MM_PMC_CFRAME14_REG         0xf12ec000
319 #define MM_PMC_CFRAME14_REG_SIZE    0x1000
320 #define MM_PMC_CFRAME14_FDRI        0xf12ed000
321 #define MM_PMC_CFRAME14_FDRI_SIZE   0x1000
322 #define MM_PMC_CFRAME_BCAST_REG       0xf12ee000
323 #define MM_PMC_CFRAME_BCAST_REG_SIZE  0x1000
324 #define MM_PMC_CFRAME_BCAST_FDRI      0xf12ef000
325 #define MM_PMC_CFRAME_BCAST_FDRI_SIZE 0x1000
326 
327 #define MM_PMC_CRP                  0xf1260000U
328 #define MM_PMC_CRP_SIZE             0x10000
329 #define MM_PMC_RTC                  0xf12a0000
330 #define MM_PMC_RTC_SIZE             0x10000
331 #endif
332