xref: /qemu/include/hw/timer/imx_epit.h (revision cb54d868c6a2292443645f25b295630f925474f8)
1951cd00eSJean-Christophe Dubois /*
2951cd00eSJean-Christophe Dubois  * i.MX EPIT Timer
3951cd00eSJean-Christophe Dubois  *
4951cd00eSJean-Christophe Dubois  * Copyright (c) 2008 OK Labs
5951cd00eSJean-Christophe Dubois  * Copyright (c) 2011 NICTA Pty Ltd
6951cd00eSJean-Christophe Dubois  * Originally written by Hans Jiang
7951cd00eSJean-Christophe Dubois  * Updated by Peter Chubb
8951cd00eSJean-Christophe Dubois  * Updated by Jean-Christophe Dubois <jcd@tribudubois.net>
9951cd00eSJean-Christophe Dubois  *
10951cd00eSJean-Christophe Dubois  * Permission is hereby granted, free of charge, to any person obtaining a copy
11951cd00eSJean-Christophe Dubois  * of this software and associated documentation files (the "Software"), to deal
12951cd00eSJean-Christophe Dubois  * in the Software without restriction, including without limitation the rights
13951cd00eSJean-Christophe Dubois  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14951cd00eSJean-Christophe Dubois  * copies of the Software, and to permit persons to whom the Software is
15951cd00eSJean-Christophe Dubois  * furnished to do so, subject to the following conditions:
16951cd00eSJean-Christophe Dubois  *
17951cd00eSJean-Christophe Dubois  * The above copyright notice and this permission notice shall be included in
18951cd00eSJean-Christophe Dubois  * all copies or substantial portions of the Software.
19951cd00eSJean-Christophe Dubois  *
20951cd00eSJean-Christophe Dubois  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21951cd00eSJean-Christophe Dubois  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22951cd00eSJean-Christophe Dubois  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23951cd00eSJean-Christophe Dubois  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24951cd00eSJean-Christophe Dubois  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25951cd00eSJean-Christophe Dubois  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26951cd00eSJean-Christophe Dubois  * THE SOFTWARE.
27951cd00eSJean-Christophe Dubois  */
28951cd00eSJean-Christophe Dubois 
29951cd00eSJean-Christophe Dubois #ifndef IMX_EPIT_H
30951cd00eSJean-Christophe Dubois #define IMX_EPIT_H
31951cd00eSJean-Christophe Dubois 
32951cd00eSJean-Christophe Dubois #include "hw/sysbus.h"
33951cd00eSJean-Christophe Dubois #include "hw/ptimer.h"
34*cb54d868SJean-Christophe Dubois #include "hw/misc/imx_ccm.h"
35951cd00eSJean-Christophe Dubois 
36951cd00eSJean-Christophe Dubois /*
37951cd00eSJean-Christophe Dubois  * EPIT: Enhanced periodic interrupt timer
38951cd00eSJean-Christophe Dubois  */
39951cd00eSJean-Christophe Dubois 
40951cd00eSJean-Christophe Dubois #define CR_EN       (1 << 0)
41951cd00eSJean-Christophe Dubois #define CR_ENMOD    (1 << 1)
42951cd00eSJean-Christophe Dubois #define CR_OCIEN    (1 << 2)
43951cd00eSJean-Christophe Dubois #define CR_RLD      (1 << 3)
44951cd00eSJean-Christophe Dubois #define CR_PRESCALE_SHIFT (4)
45951cd00eSJean-Christophe Dubois #define CR_PRESCALE_MASK  (0xfff)
46951cd00eSJean-Christophe Dubois #define CR_SWR      (1 << 16)
47951cd00eSJean-Christophe Dubois #define CR_IOVW     (1 << 17)
48951cd00eSJean-Christophe Dubois #define CR_DBGEN    (1 << 18)
49951cd00eSJean-Christophe Dubois #define CR_WAITEN   (1 << 19)
50951cd00eSJean-Christophe Dubois #define CR_DOZEN    (1 << 20)
51951cd00eSJean-Christophe Dubois #define CR_STOPEN   (1 << 21)
52951cd00eSJean-Christophe Dubois #define CR_CLKSRC_SHIFT (24)
53951cd00eSJean-Christophe Dubois #define CR_CLKSRC_MASK  (0x3 << CR_CLKSRC_SHIFT)
54951cd00eSJean-Christophe Dubois 
55951cd00eSJean-Christophe Dubois #define EPIT_TIMER_MAX  0XFFFFFFFFUL
56951cd00eSJean-Christophe Dubois 
57951cd00eSJean-Christophe Dubois #define TYPE_IMX_EPIT "imx.epit"
58951cd00eSJean-Christophe Dubois #define IMX_EPIT(obj) OBJECT_CHECK(IMXEPITState, (obj), TYPE_IMX_EPIT)
59951cd00eSJean-Christophe Dubois 
60951cd00eSJean-Christophe Dubois typedef struct IMXEPITState{
61951cd00eSJean-Christophe Dubois     /*< private >*/
62951cd00eSJean-Christophe Dubois     SysBusDevice parent_obj;
63951cd00eSJean-Christophe Dubois 
64951cd00eSJean-Christophe Dubois     /*< public >*/
65951cd00eSJean-Christophe Dubois     ptimer_state *timer_reload;
66951cd00eSJean-Christophe Dubois     ptimer_state *timer_cmp;
67951cd00eSJean-Christophe Dubois     MemoryRegion  iomem;
68*cb54d868SJean-Christophe Dubois     IMXCCMState  *ccm;
69951cd00eSJean-Christophe Dubois 
70951cd00eSJean-Christophe Dubois     uint32_t cr;
71951cd00eSJean-Christophe Dubois     uint32_t sr;
72951cd00eSJean-Christophe Dubois     uint32_t lr;
73951cd00eSJean-Christophe Dubois     uint32_t cmp;
74951cd00eSJean-Christophe Dubois     uint32_t cnt;
75951cd00eSJean-Christophe Dubois 
76951cd00eSJean-Christophe Dubois     uint32_t freq;
77951cd00eSJean-Christophe Dubois     qemu_irq irq;
78951cd00eSJean-Christophe Dubois } IMXEPITState;
79951cd00eSJean-Christophe Dubois 
80951cd00eSJean-Christophe Dubois #endif /* IMX_EPIT_H */
81