xref: /openbmc/qemu/include/hw/riscv/opentitan.h (revision c00506aa)
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 "qom/object.h"
26 
27 #define TYPE_RISCV_IBEX_SOC "riscv.lowrisc.ibex.soc"
28 OBJECT_DECLARE_SIMPLE_TYPE(LowRISCIbexSoCState, RISCV_IBEX_SOC)
29 
30 struct LowRISCIbexSoCState {
31     /*< private >*/
32     SysBusDevice parent_obj;
33 
34     /*< public >*/
35     RISCVHartArrayState cpus;
36     IbexPlicState plic;
37     IbexUartState uart;
38 
39     MemoryRegion flash_mem;
40     MemoryRegion rom;
41 };
42 
43 typedef struct OpenTitanState {
44     /*< private >*/
45     SysBusDevice parent_obj;
46 
47     /*< public >*/
48     LowRISCIbexSoCState soc;
49 } OpenTitanState;
50 
51 enum {
52     IBEX_DEV_ROM,
53     IBEX_DEV_RAM,
54     IBEX_DEV_FLASH,
55     IBEX_DEV_UART,
56     IBEX_DEV_GPIO,
57     IBEX_DEV_SPI,
58     IBEX_DEV_I2C,
59     IBEX_DEV_PATTGEN,
60     IBEX_DEV_RV_TIMER,
61     IBEX_DEV_SENSOR_CTRL,
62     IBEX_DEV_OTP_CTRL,
63     IBEX_DEV_PWRMGR,
64     IBEX_DEV_RSTMGR,
65     IBEX_DEV_CLKMGR,
66     IBEX_DEV_PINMUX,
67     IBEX_DEV_PADCTRL,
68     IBEX_DEV_USBDEV,
69     IBEX_DEV_FLASH_CTRL,
70     IBEX_DEV_PLIC,
71     IBEX_DEV_AES,
72     IBEX_DEV_HMAC,
73     IBEX_DEV_KMAC,
74     IBEX_DEV_KEYMGR,
75     IBEX_DEV_CSRNG,
76     IBEX_DEV_ENTROPY,
77     IBEX_DEV_EDNO,
78     IBEX_DEV_EDN1,
79     IBEX_DEV_ALERT_HANDLER,
80     IBEX_DEV_NMI_GEN,
81     IBEX_DEV_OTBN,
82 };
83 
84 enum {
85     IBEX_UART_RX_PARITY_ERR_IRQ = 0x28,
86     IBEX_UART_RX_TIMEOUT_IRQ = 0x27,
87     IBEX_UART_RX_BREAK_ERR_IRQ = 0x26,
88     IBEX_UART_RX_FRAME_ERR_IRQ = 0x25,
89     IBEX_UART_RX_OVERFLOW_IRQ = 0x24,
90     IBEX_UART_TX_EMPTY_IRQ = 0x23,
91     IBEX_UART_RX_WATERMARK_IRQ = 0x22,
92     IBEX_UART_TX_WATERMARK_IRQ = 0x21,
93 };
94 
95 #endif
96