xref: /qemu/include/hw/timer/imx_epit.h (revision d365cb0b9d14eb562ce85d3acfe36e8aad13df3f)
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"
34cb54d868SJean-Christophe Dubois #include "hw/misc/imx_ccm.h"
35db1015e9SEduardo Habkost #include "qom/object.h"
36951cd00eSJean-Christophe Dubois 
37951cd00eSJean-Christophe Dubois /*
38951cd00eSJean-Christophe Dubois  * EPIT: Enhanced periodic interrupt timer
39951cd00eSJean-Christophe Dubois  */
40951cd00eSJean-Christophe Dubois 
41951cd00eSJean-Christophe Dubois #define CR_EN       (1 << 0)
42951cd00eSJean-Christophe Dubois #define CR_ENMOD    (1 << 1)
43951cd00eSJean-Christophe Dubois #define CR_OCIEN    (1 << 2)
44951cd00eSJean-Christophe Dubois #define CR_RLD      (1 << 3)
45951cd00eSJean-Christophe Dubois #define CR_PRESCALE_SHIFT (4)
46018ee794SAxel Heider #define CR_PRESCALE_BITS  (12)
47951cd00eSJean-Christophe Dubois #define CR_SWR      (1 << 16)
48951cd00eSJean-Christophe Dubois #define CR_IOVW     (1 << 17)
49951cd00eSJean-Christophe Dubois #define CR_DBGEN    (1 << 18)
50951cd00eSJean-Christophe Dubois #define CR_WAITEN   (1 << 19)
51951cd00eSJean-Christophe Dubois #define CR_DOZEN    (1 << 20)
52951cd00eSJean-Christophe Dubois #define CR_STOPEN   (1 << 21)
53951cd00eSJean-Christophe Dubois #define CR_CLKSRC_SHIFT (24)
54018ee794SAxel Heider #define CR_CLKSRC_BITS  (2)
55951cd00eSJean-Christophe Dubois 
56*1ead962eSAxel Heider #define SR_OCIF     (1 << 0)
57*1ead962eSAxel Heider 
58951cd00eSJean-Christophe Dubois #define EPIT_TIMER_MAX  0XFFFFFFFFUL
59951cd00eSJean-Christophe Dubois 
60951cd00eSJean-Christophe Dubois #define TYPE_IMX_EPIT "imx.epit"
618063396bSEduardo Habkost OBJECT_DECLARE_SIMPLE_TYPE(IMXEPITState, IMX_EPIT)
62951cd00eSJean-Christophe Dubois 
63db1015e9SEduardo Habkost struct IMXEPITState {
64951cd00eSJean-Christophe Dubois     /*< private >*/
65951cd00eSJean-Christophe Dubois     SysBusDevice parent_obj;
66951cd00eSJean-Christophe Dubois 
67951cd00eSJean-Christophe Dubois     /*< public >*/
68951cd00eSJean-Christophe Dubois     ptimer_state *timer_reload;
69951cd00eSJean-Christophe Dubois     ptimer_state *timer_cmp;
70951cd00eSJean-Christophe Dubois     MemoryRegion  iomem;
71cb54d868SJean-Christophe Dubois     IMXCCMState  *ccm;
72951cd00eSJean-Christophe Dubois 
73951cd00eSJean-Christophe Dubois     uint32_t cr;
74951cd00eSJean-Christophe Dubois     uint32_t sr;
75951cd00eSJean-Christophe Dubois     uint32_t lr;
76951cd00eSJean-Christophe Dubois     uint32_t cmp;
77951cd00eSJean-Christophe Dubois 
78951cd00eSJean-Christophe Dubois     qemu_irq irq;
79db1015e9SEduardo Habkost };
80951cd00eSJean-Christophe Dubois 
81951cd00eSJean-Christophe Dubois #endif /* IMX_EPIT_H */
82