xref: /qemu/include/hw/ppc/pnv_chiptod.h (revision 9a69950feb0983cde8a97f8c7d1623e81b912412)
1 /*
2  * QEMU PowerPC PowerNV Emulation of some CHIPTOD behaviour
3  *
4  * Copyright (c) 2022-2023, IBM Corporation.
5  *
6  * SPDX-License-Identifier: GPL-2.0-or-later
7  */
8 
9 #ifndef PPC_PNV_CHIPTOD_H
10 #define PPC_PNV_CHIPTOD_H
11 
12 #include "qom/object.h"
13 
14 #define TYPE_PNV_CHIPTOD "pnv-chiptod"
15 OBJECT_DECLARE_TYPE(PnvChipTOD, PnvChipTODClass, PNV_CHIPTOD)
16 #define TYPE_PNV9_CHIPTOD TYPE_PNV_CHIPTOD "-POWER9"
17 DECLARE_INSTANCE_CHECKER(PnvChipTOD, PNV9_CHIPTOD, TYPE_PNV9_CHIPTOD)
18 #define TYPE_PNV10_CHIPTOD TYPE_PNV_CHIPTOD "-POWER10"
19 DECLARE_INSTANCE_CHECKER(PnvChipTOD, PNV10_CHIPTOD, TYPE_PNV10_CHIPTOD)
20 
21 enum tod_state {
22     tod_error = 0,
23     tod_not_set = 7,
24     tod_running = 2,
25     tod_stopped = 1,
26 };
27 
28 struct PnvChipTOD {
29     DeviceState xd;
30 
31     PnvChip *chip;
32     MemoryRegion xscom_regs;
33 
34     bool primary;
35     bool secondary;
36     enum tod_state tod_state;
37     uint64_t tod_error;
38     uint64_t pss_mss_ctrl_reg;
39 };
40 
41 struct PnvChipTODClass {
42     DeviceClass parent_class;
43 
44     void (*broadcast_ttype)(PnvChipTOD *sender, uint32_t trigger);
45 
46     int xscom_size;
47 };
48 
49 #endif /* PPC_PNV_CHIPTOD_H */
50