1eb637edbSMichael Clark /* 2eb637edbSMichael Clark * SiFive E series machine interface 3eb637edbSMichael Clark * 4eb637edbSMichael Clark * Copyright (c) 2017 SiFive, Inc. 5eb637edbSMichael Clark * 6eb637edbSMichael Clark * This program is free software; you can redistribute it and/or modify it 7eb637edbSMichael Clark * under the terms and conditions of the GNU General Public License, 8eb637edbSMichael Clark * version 2 or later, as published by the Free Software Foundation. 9eb637edbSMichael Clark * 10eb637edbSMichael Clark * This program is distributed in the hope it will be useful, but WITHOUT 11eb637edbSMichael Clark * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12eb637edbSMichael Clark * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13eb637edbSMichael Clark * more details. 14eb637edbSMichael Clark * 15eb637edbSMichael Clark * You should have received a copy of the GNU General Public License along with 16eb637edbSMichael Clark * this program. If not, see <http://www.gnu.org/licenses/>. 17eb637edbSMichael Clark */ 18eb637edbSMichael Clark 19eb637edbSMichael Clark #ifndef HW_SIFIVE_E_H 20eb637edbSMichael Clark #define HW_SIFIVE_E_H 21eb637edbSMichael Clark 22ec150c7eSMarkus Armbruster #include "hw/riscv/riscv_hart.h" 2320f41c86SBin Meng #include "hw/riscv/sifive_cpu.h" 244921a0ceSBin Meng #include "hw/gpio/sifive_gpio.h" 25*82193640STommy Wu #include "hw/misc/sifive_e_aon.h" 269dfa6c2aSBernhard Beschow #include "hw/boards.h" 2730efbf33SFabien Chouteau 28651cd8b7SAlistair Francis #define TYPE_RISCV_E_SOC "riscv.sifive.e.soc" 29651cd8b7SAlistair Francis #define RISCV_E_SOC(obj) \ 30651cd8b7SAlistair Francis OBJECT_CHECK(SiFiveESoCState, (obj), TYPE_RISCV_E_SOC) 31651cd8b7SAlistair Francis 32651cd8b7SAlistair Francis typedef struct SiFiveESoCState { 33651cd8b7SAlistair Francis /*< private >*/ 34589b1be0SMarkus Armbruster DeviceState parent_obj; 35651cd8b7SAlistair Francis 36651cd8b7SAlistair Francis /*< public >*/ 37651cd8b7SAlistair Francis RISCVHartArrayState cpus; 38651cd8b7SAlistair Francis DeviceState *plic; 39*82193640STommy Wu SiFiveEAONState aon; 4030efbf33SFabien Chouteau SIFIVEGPIOState gpio; 41c988de41SPalmer Dabbelt MemoryRegion xip_mem; 42c988de41SPalmer Dabbelt MemoryRegion mask_rom; 43651cd8b7SAlistair Francis } SiFiveESoCState; 44651cd8b7SAlistair Francis 45eb637edbSMichael Clark typedef struct SiFiveEState { 46eb637edbSMichael Clark /*< private >*/ 479dfa6c2aSBernhard Beschow MachineState parent_obj; 48eb637edbSMichael Clark 49eb637edbSMichael Clark /*< public >*/ 50651cd8b7SAlistair Francis SiFiveESoCState soc; 515a842062SAlistair Francis bool revb; 52eb637edbSMichael Clark } SiFiveEState; 53eb637edbSMichael Clark 540869490bSAlistair Francis #define TYPE_RISCV_E_MACHINE MACHINE_TYPE_NAME("sifive_e") 550869490bSAlistair Francis #define RISCV_E_MACHINE(obj) \ 560869490bSAlistair Francis OBJECT_CHECK(SiFiveEState, (obj), TYPE_RISCV_E_MACHINE) 570869490bSAlistair Francis 58eb637edbSMichael Clark enum { 595488f276SEduardo Habkost SIFIVE_E_DEV_DEBUG, 605488f276SEduardo Habkost SIFIVE_E_DEV_MROM, 615488f276SEduardo Habkost SIFIVE_E_DEV_OTP, 625488f276SEduardo Habkost SIFIVE_E_DEV_CLINT, 635488f276SEduardo Habkost SIFIVE_E_DEV_PLIC, 645488f276SEduardo Habkost SIFIVE_E_DEV_AON, 655488f276SEduardo Habkost SIFIVE_E_DEV_PRCI, 665488f276SEduardo Habkost SIFIVE_E_DEV_OTP_CTRL, 675488f276SEduardo Habkost SIFIVE_E_DEV_GPIO0, 685488f276SEduardo Habkost SIFIVE_E_DEV_UART0, 695488f276SEduardo Habkost SIFIVE_E_DEV_QSPI0, 705488f276SEduardo Habkost SIFIVE_E_DEV_PWM0, 715488f276SEduardo Habkost SIFIVE_E_DEV_UART1, 725488f276SEduardo Habkost SIFIVE_E_DEV_QSPI1, 735488f276SEduardo Habkost SIFIVE_E_DEV_PWM1, 745488f276SEduardo Habkost SIFIVE_E_DEV_QSPI2, 755488f276SEduardo Habkost SIFIVE_E_DEV_PWM2, 765488f276SEduardo Habkost SIFIVE_E_DEV_XIP, 775488f276SEduardo Habkost SIFIVE_E_DEV_DTIM 78eb637edbSMichael Clark }; 79eb637edbSMichael Clark 80eb637edbSMichael Clark enum { 81*82193640STommy Wu SIFIVE_E_AON_WDT_IRQ = 1, 82eb637edbSMichael Clark SIFIVE_E_UART0_IRQ = 3, 8330efbf33SFabien Chouteau SIFIVE_E_UART1_IRQ = 4, 8430efbf33SFabien Chouteau SIFIVE_E_GPIO0_IRQ0 = 8 85eb637edbSMichael Clark }; 86eb637edbSMichael Clark 87eb637edbSMichael Clark #define SIFIVE_E_PLIC_HART_CONFIG "M" 883a20cd12SBin Meng /* 893a20cd12SBin Meng * Freedom E310 G002 and G003 supports 52 interrupt sources while 903a20cd12SBin Meng * Freedom E310 G000 supports 51 interrupt sources. We use the value 913a20cd12SBin Meng * of G002 and G003, so it is 53 (including interrupt source 0). 923a20cd12SBin Meng */ 933a20cd12SBin Meng #define SIFIVE_E_PLIC_NUM_SOURCES 53 94eb637edbSMichael Clark #define SIFIVE_E_PLIC_NUM_PRIORITIES 7 955decd2c5SBin Meng #define SIFIVE_E_PLIC_PRIORITY_BASE 0x00 96eb637edbSMichael Clark #define SIFIVE_E_PLIC_PENDING_BASE 0x1000 97eb637edbSMichael Clark #define SIFIVE_E_PLIC_ENABLE_BASE 0x2000 98eb637edbSMichael Clark #define SIFIVE_E_PLIC_ENABLE_STRIDE 0x80 99eb637edbSMichael Clark #define SIFIVE_E_PLIC_CONTEXT_BASE 0x200000 100eb637edbSMichael Clark #define SIFIVE_E_PLIC_CONTEXT_STRIDE 0x1000 101eb637edbSMichael Clark 102eb637edbSMichael Clark #endif 103