xref: /qemu/include/hw/riscv/opentitan.h (revision bc3359f7)
1 /*
2  * QEMU RISC-V Board Compatible with OpenTitan FPGA platform
3  *
4  * Copyright (c) 2020 Western Digital
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2 or later, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef HW_OPENTITAN_H
20 #define HW_OPENTITAN_H
21 
22 #include "hw/riscv/riscv_hart.h"
23 #include "hw/intc/ibex_plic.h"
24 #include "hw/char/ibex_uart.h"
25 #include "hw/timer/ibex_timer.h"
26 #include "qom/object.h"
27 
28 #define TYPE_RISCV_IBEX_SOC "riscv.lowrisc.ibex.soc"
29 OBJECT_DECLARE_SIMPLE_TYPE(LowRISCIbexSoCState, RISCV_IBEX_SOC)
30 
31 struct LowRISCIbexSoCState {
32     /*< private >*/
33     SysBusDevice parent_obj;
34 
35     /*< public >*/
36     RISCVHartArrayState cpus;
37     IbexPlicState plic;
38     IbexUartState uart;
39     IbexTimerState timer;
40 
41     MemoryRegion flash_mem;
42     MemoryRegion rom;
43 };
44 
45 typedef struct OpenTitanState {
46     /*< private >*/
47     SysBusDevice parent_obj;
48 
49     /*< public >*/
50     LowRISCIbexSoCState soc;
51 } OpenTitanState;
52 
53 enum {
54     IBEX_DEV_ROM,
55     IBEX_DEV_RAM,
56     IBEX_DEV_FLASH,
57     IBEX_DEV_UART,
58     IBEX_DEV_GPIO,
59     IBEX_DEV_SPI,
60     IBEX_DEV_I2C,
61     IBEX_DEV_PATTGEN,
62     IBEX_DEV_TIMER,
63     IBEX_DEV_SENSOR_CTRL,
64     IBEX_DEV_OTP_CTRL,
65     IBEX_DEV_PWRMGR,
66     IBEX_DEV_RSTMGR,
67     IBEX_DEV_CLKMGR,
68     IBEX_DEV_PINMUX,
69     IBEX_DEV_PADCTRL,
70     IBEX_DEV_USBDEV,
71     IBEX_DEV_FLASH_CTRL,
72     IBEX_DEV_PLIC,
73     IBEX_DEV_AES,
74     IBEX_DEV_HMAC,
75     IBEX_DEV_KMAC,
76     IBEX_DEV_KEYMGR,
77     IBEX_DEV_CSRNG,
78     IBEX_DEV_ENTROPY,
79     IBEX_DEV_EDNO,
80     IBEX_DEV_EDN1,
81     IBEX_DEV_ALERT_HANDLER,
82     IBEX_DEV_NMI_GEN,
83     IBEX_DEV_OTBN,
84 };
85 
86 enum {
87     IBEX_TIMER_TIMEREXPIRED0_0 = 125,
88     IBEX_UART0_RX_PARITY_ERR_IRQ = 8,
89     IBEX_UART0_RX_TIMEOUT_IRQ = 7,
90     IBEX_UART0_RX_BREAK_ERR_IRQ = 6,
91     IBEX_UART0_RX_FRAME_ERR_IRQ = 5,
92     IBEX_UART0_RX_OVERFLOW_IRQ = 4,
93     IBEX_UART0_TX_EMPTY_IRQ = 3,
94     IBEX_UART0_RX_WATERMARK_IRQ = 2,
95     IBEX_UART0_TX_WATERMARK_IRQ = 1,
96 };
97 
98 #endif
99