xref: /openbmc/qemu/include/hw/misc/npcm7xx_clk.h (revision 60efffa4)
1 /*
2  * Nuvoton NPCM7xx Clock Control Registers.
3  *
4  * Copyright 2020 Google LLC
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the
8  * Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14  * for more details.
15  */
16 #ifndef NPCM7XX_CLK_H
17 #define NPCM7XX_CLK_H
18 
19 #include "exec/memory.h"
20 #include "hw/sysbus.h"
21 
22 /*
23  * The reference clock frequency for the timer modules, and the SECCNT and
24  * CNTR25M registers in this module, is always 25 MHz.
25  */
26 #define NPCM7XX_TIMER_REF_HZ            (25000000)
27 
28 /*
29  * Number of registers in our device state structure. Don't change this without
30  * incrementing the version_id in the vmstate.
31  */
32 #define NPCM7XX_CLK_NR_REGS             (0x70 / sizeof(uint32_t))
33 
34 typedef struct NPCM7xxCLKState {
35     SysBusDevice parent;
36 
37     MemoryRegion iomem;
38 
39     uint32_t regs[NPCM7XX_CLK_NR_REGS];
40 
41     /* Time reference for SECCNT and CNTR25M, initialized by power on reset */
42     int64_t ref_ns;
43 } NPCM7xxCLKState;
44 
45 #define TYPE_NPCM7XX_CLK "npcm7xx-clk"
46 #define NPCM7XX_CLK(obj) OBJECT_CHECK(NPCM7xxCLKState, (obj), TYPE_NPCM7XX_CLK)
47 
48 #endif /* NPCM7XX_CLK_H */
49