xref: /openbmc/qemu/include/hw/timer/imx_epit.h (revision 709395f8)
1 /*
2  * i.MX EPIT Timer
3  *
4  * Copyright (c) 2008 OK Labs
5  * Copyright (c) 2011 NICTA Pty Ltd
6  * Originally written by Hans Jiang
7  * Updated by Peter Chubb
8  * Updated by Jean-Christophe Dubois <jcd@tribudubois.net>
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining a copy
11  * of this software and associated documentation files (the "Software"), to deal
12  * in the Software without restriction, including without limitation the rights
13  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14  * copies of the Software, and to permit persons to whom the Software is
15  * furnished to do so, subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be included in
18  * all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26  * THE SOFTWARE.
27  */
28 
29 #ifndef IMX_EPIT_H
30 #define IMX_EPIT_H
31 
32 #include "hw/sysbus.h"
33 #include "hw/ptimer.h"
34 #include "hw/misc/imx_ccm.h"
35 
36 /*
37  * EPIT: Enhanced periodic interrupt timer
38  */
39 
40 #define CR_EN       (1 << 0)
41 #define CR_ENMOD    (1 << 1)
42 #define CR_OCIEN    (1 << 2)
43 #define CR_RLD      (1 << 3)
44 #define CR_PRESCALE_SHIFT (4)
45 #define CR_PRESCALE_MASK  (0xfff)
46 #define CR_SWR      (1 << 16)
47 #define CR_IOVW     (1 << 17)
48 #define CR_DBGEN    (1 << 18)
49 #define CR_WAITEN   (1 << 19)
50 #define CR_DOZEN    (1 << 20)
51 #define CR_STOPEN   (1 << 21)
52 #define CR_CLKSRC_SHIFT (24)
53 #define CR_CLKSRC_MASK  (0x3 << CR_CLKSRC_SHIFT)
54 
55 #define EPIT_TIMER_MAX  0XFFFFFFFFUL
56 
57 #define TYPE_IMX_EPIT "imx.epit"
58 #define IMX_EPIT(obj) OBJECT_CHECK(IMXEPITState, (obj), TYPE_IMX_EPIT)
59 
60 typedef struct IMXEPITState{
61     /*< private >*/
62     SysBusDevice parent_obj;
63 
64     /*< public >*/
65     ptimer_state *timer_reload;
66     ptimer_state *timer_cmp;
67     MemoryRegion  iomem;
68     IMXCCMState  *ccm;
69 
70     uint32_t cr;
71     uint32_t sr;
72     uint32_t lr;
73     uint32_t cmp;
74     uint32_t cnt;
75 
76     uint32_t freq;
77     qemu_irq irq;
78 } IMXEPITState;
79 
80 #endif /* IMX_EPIT_H */
81