xref: /openbmc/qemu/include/hw/misc/imx7_ccm.h (revision 709395f8)
1 /*
2  * Copyright (c) 2017, Impinj, Inc.
3  *
4  * i.MX7 CCM, PMU and ANALOG IP blocks emulation code
5  *
6  * Author: Andrey Smirnov <andrew.smirnov@gmail.com>
7  *
8  * This work is licensed under the terms of the GNU GPL, version 2 or later.
9  * See the COPYING file in the top-level directory.
10  */
11 
12 #ifndef IMX7_CCM_H
13 #define IMX7_CCM_H
14 
15 #include "hw/misc/imx_ccm.h"
16 #include "qemu/bitops.h"
17 
18 enum IMX7AnalogRegisters {
19     ANALOG_PLL_ARM,
20     ANALOG_PLL_ARM_SET,
21     ANALOG_PLL_ARM_CLR,
22     ANALOG_PLL_ARM_TOG,
23     ANALOG_PLL_DDR,
24     ANALOG_PLL_DDR_SET,
25     ANALOG_PLL_DDR_CLR,
26     ANALOG_PLL_DDR_TOG,
27     ANALOG_PLL_DDR_SS,
28     ANALOG_PLL_DDR_SS_SET,
29     ANALOG_PLL_DDR_SS_CLR,
30     ANALOG_PLL_DDR_SS_TOG,
31     ANALOG_PLL_DDR_NUM,
32     ANALOG_PLL_DDR_NUM_SET,
33     ANALOG_PLL_DDR_NUM_CLR,
34     ANALOG_PLL_DDR_NUM_TOG,
35     ANALOG_PLL_DDR_DENOM,
36     ANALOG_PLL_DDR_DENOM_SET,
37     ANALOG_PLL_DDR_DENOM_CLR,
38     ANALOG_PLL_DDR_DENOM_TOG,
39     ANALOG_PLL_480,
40     ANALOG_PLL_480_SET,
41     ANALOG_PLL_480_CLR,
42     ANALOG_PLL_480_TOG,
43     ANALOG_PLL_480A,
44     ANALOG_PLL_480A_SET,
45     ANALOG_PLL_480A_CLR,
46     ANALOG_PLL_480A_TOG,
47     ANALOG_PLL_480B,
48     ANALOG_PLL_480B_SET,
49     ANALOG_PLL_480B_CLR,
50     ANALOG_PLL_480B_TOG,
51     ANALOG_PLL_ENET,
52     ANALOG_PLL_ENET_SET,
53     ANALOG_PLL_ENET_CLR,
54     ANALOG_PLL_ENET_TOG,
55     ANALOG_PLL_AUDIO,
56     ANALOG_PLL_AUDIO_SET,
57     ANALOG_PLL_AUDIO_CLR,
58     ANALOG_PLL_AUDIO_TOG,
59     ANALOG_PLL_AUDIO_SS,
60     ANALOG_PLL_AUDIO_SS_SET,
61     ANALOG_PLL_AUDIO_SS_CLR,
62     ANALOG_PLL_AUDIO_SS_TOG,
63     ANALOG_PLL_AUDIO_NUM,
64     ANALOG_PLL_AUDIO_NUM_SET,
65     ANALOG_PLL_AUDIO_NUM_CLR,
66     ANALOG_PLL_AUDIO_NUM_TOG,
67     ANALOG_PLL_AUDIO_DENOM,
68     ANALOG_PLL_AUDIO_DENOM_SET,
69     ANALOG_PLL_AUDIO_DENOM_CLR,
70     ANALOG_PLL_AUDIO_DENOM_TOG,
71     ANALOG_PLL_VIDEO,
72     ANALOG_PLL_VIDEO_SET,
73     ANALOG_PLL_VIDEO_CLR,
74     ANALOG_PLL_VIDEO_TOG,
75     ANALOG_PLL_VIDEO_SS,
76     ANALOG_PLL_VIDEO_SS_SET,
77     ANALOG_PLL_VIDEO_SS_CLR,
78     ANALOG_PLL_VIDEO_SS_TOG,
79     ANALOG_PLL_VIDEO_NUM,
80     ANALOG_PLL_VIDEO_NUM_SET,
81     ANALOG_PLL_VIDEO_NUM_CLR,
82     ANALOG_PLL_VIDEO_NUM_TOG,
83     ANALOG_PLL_VIDEO_DENOM,
84     ANALOG_PLL_VIDEO_DENOM_SET,
85     ANALOG_PLL_VIDEO_DENOM_CLR,
86     ANALOG_PLL_VIDEO_DENOM_TOG,
87     ANALOG_PLL_MISC0,
88     ANALOG_PLL_MISC0_SET,
89     ANALOG_PLL_MISC0_CLR,
90     ANALOG_PLL_MISC0_TOG,
91 
92     ANALOG_DIGPROG = 0x800 / sizeof(uint32_t),
93     ANALOG_MAX,
94 
95     ANALOG_PLL_LOCK = BIT(31)
96 };
97 
98 enum IMX7CCMRegisters {
99     CCM_MAX = 0xBE00 / sizeof(uint32_t) + 1,
100 };
101 
102 enum IMX7PMURegisters {
103     PMU_MAX = 0x140 / sizeof(uint32_t),
104 };
105 
106 #define TYPE_IMX7_CCM "imx7.ccm"
107 #define IMX7_CCM(obj) OBJECT_CHECK(IMX7CCMState, (obj), TYPE_IMX7_CCM)
108 
109 typedef struct IMX7CCMState {
110     /* <private> */
111     IMXCCMState parent_obj;
112 
113     /* <public> */
114     MemoryRegion iomem;
115 
116     uint32_t ccm[CCM_MAX];
117 } IMX7CCMState;
118 
119 
120 #define TYPE_IMX7_ANALOG "imx7.analog"
121 #define IMX7_ANALOG(obj) OBJECT_CHECK(IMX7AnalogState, (obj), TYPE_IMX7_ANALOG)
122 
123 typedef struct IMX7AnalogState {
124     /* <private> */
125     IMXCCMState parent_obj;
126 
127     /* <public> */
128     struct {
129         MemoryRegion container;
130         MemoryRegion analog;
131         MemoryRegion digprog;
132         MemoryRegion pmu;
133     } mmio;
134 
135     uint32_t analog[ANALOG_MAX];
136     uint32_t pmu[PMU_MAX];
137 } IMX7AnalogState;
138 
139 #endif /* IMX7_CCM_H */
140