xref: /openbmc/qemu/include/hw/misc/sifive_e_aon.h (revision 2df1eb27)
1 /*
2  * SiFive HiFive1 AON (Always On Domain) interface.
3  *
4  * Copyright (c) 2022 SiFive, Inc. All rights reserved.
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_SIFIVE_AON_H
20 #define HW_SIFIVE_AON_H
21 
22 #include "hw/sysbus.h"
23 #include "qom/object.h"
24 
25 #define TYPE_SIFIVE_E_AON "riscv.sifive.e.aon"
26 OBJECT_DECLARE_SIMPLE_TYPE(SiFiveEAONState, SIFIVE_E_AON)
27 
28 #define SIFIVE_E_AON_WDOGKEY (0x51F15E)
29 #define SIFIVE_E_AON_WDOGFEED (0xD09F00D)
30 #define SIFIVE_E_LFCLK_DEFAULT_FREQ (32768)
31 
32 enum {
33     SIFIVE_E_AON_WDT    = 0x0,
34     SIFIVE_E_AON_RTC    = 0x40,
35     SIFIVE_E_AON_LFROSC = 0x70,
36     SIFIVE_E_AON_BACKUP = 0x80,
37     SIFIVE_E_AON_PMU    = 0x100,
38     SIFIVE_E_AON_MAX    = 0x150
39 };
40 
41 struct SiFiveEAONState {
42     /*< private >*/
43     SysBusDevice parent_obj;
44 
45     /*< public >*/
46     MemoryRegion mmio;
47 
48     /*< watchdog timer >*/
49     QEMUTimer *wdog_timer;
50     qemu_irq wdog_irq;
51     uint64_t wdog_restart_time;
52     uint64_t wdogclk_freq;
53 
54     uint32_t wdogcfg;
55     uint16_t wdogcmp0;
56     uint32_t wdogcount;
57     uint8_t wdogunlock;
58 };
59 
60 #endif
61