xref: /openbmc/qemu/include/hw/misc/imx6ul_ccm.h (revision 40d6ee94)
1 /*
2  * IMX6UL Clock Control Module
3  *
4  * Copyright (C) 2018 by Jean-Christophe Dubois <jcd@tribudubois.net>
5  *
6  * This work is licensed under the terms of the GNU GPL, version 2 or later.
7  * See the COPYING file in the top-level directory.
8  */
9 
10 #ifndef IMX6UL_CCM_H
11 #define IMX6UL_CCM_H
12 
13 #include "hw/misc/imx_ccm.h"
14 #include "qemu/bitops.h"
15 
16 #define CCM_CCR 0
17 #define CCM_CCDR 1
18 #define CCM_CSR 2
19 #define CCM_CCSR 3
20 #define CCM_CACRR 4
21 #define CCM_CBCDR 5
22 #define CCM_CBCMR 6
23 #define CCM_CSCMR1 7
24 #define CCM_CSCMR2 8
25 #define CCM_CSCDR1 9
26 #define CCM_CS1CDR 10
27 #define CCM_CS2CDR 11
28 #define CCM_CDCDR 12
29 #define CCM_CHSCCDR 13
30 #define CCM_CSCDR2 14
31 #define CCM_CSCDR3 15
32 #define CCM_CDHIPR 18
33 #define CCM_CTOR 20
34 #define CCM_CLPCR 21
35 #define CCM_CISR 22
36 #define CCM_CIMR 23
37 #define CCM_CCOSR 24
38 #define CCM_CGPR 25
39 #define CCM_CCGR0 26
40 #define CCM_CCGR1 27
41 #define CCM_CCGR2 28
42 #define CCM_CCGR3 29
43 #define CCM_CCGR4 30
44 #define CCM_CCGR5 31
45 #define CCM_CCGR6 32
46 #define CCM_CMEOR 34
47 #define CCM_MAX 35
48 
49 #define CCM_ANALOG_PLL_ARM 0
50 #define CCM_ANALOG_PLL_ARM_SET 1
51 #define CCM_ANALOG_PLL_ARM_CLR 2
52 #define CCM_ANALOG_PLL_ARM_TOG 3
53 #define CCM_ANALOG_PLL_USB1 4
54 #define CCM_ANALOG_PLL_USB1_SET 5
55 #define CCM_ANALOG_PLL_USB1_CLR 6
56 #define CCM_ANALOG_PLL_USB1_TOG 7
57 #define CCM_ANALOG_PLL_USB2 8
58 #define CCM_ANALOG_PLL_USB2_SET 9
59 #define CCM_ANALOG_PLL_USB2_CLR 10
60 #define CCM_ANALOG_PLL_USB2_TOG 11
61 #define CCM_ANALOG_PLL_SYS 12
62 #define CCM_ANALOG_PLL_SYS_SET 13
63 #define CCM_ANALOG_PLL_SYS_CLR 14
64 #define CCM_ANALOG_PLL_SYS_TOG 15
65 #define CCM_ANALOG_PLL_SYS_SS 16
66 #define CCM_ANALOG_PLL_SYS_NUM 20
67 #define CCM_ANALOG_PLL_SYS_DENOM 24
68 #define CCM_ANALOG_PLL_AUDIO 28
69 #define CCM_ANALOG_PLL_AUDIO_SET 29
70 #define CCM_ANALOG_PLL_AUDIO_CLR 30
71 #define CCM_ANALOG_PLL_AUDIO_TOG 31
72 #define CCM_ANALOG_PLL_AUDIO_NUM 32
73 #define CCM_ANALOG_PLL_AUDIO_DENOM 36
74 #define CCM_ANALOG_PLL_VIDEO 40
75 #define CCM_ANALOG_PLL_VIDEO_SET 41
76 #define CCM_ANALOG_PLL_VIDEO_CLR 42
77 #define CCM_ANALOG_PLL_VIDEO_TOG 44
78 #define CCM_ANALOG_PLL_VIDEO_NUM 46
79 #define CCM_ANALOG_PLL_VIDEO_DENOM 48
80 #define CCM_ANALOG_PLL_ENET 56
81 #define CCM_ANALOG_PLL_ENET_SET 57
82 #define CCM_ANALOG_PLL_ENET_CLR 58
83 #define CCM_ANALOG_PLL_ENET_TOG 59
84 #define CCM_ANALOG_PFD_480 60
85 #define CCM_ANALOG_PFD_480_SET 61
86 #define CCM_ANALOG_PFD_480_CLR 62
87 #define CCM_ANALOG_PFD_480_TOG 63
88 #define CCM_ANALOG_PFD_528 64
89 #define CCM_ANALOG_PFD_528_SET 65
90 #define CCM_ANALOG_PFD_528_CLR 66
91 #define CCM_ANALOG_PFD_528_TOG 67
92 
93 /* PMU registers */
94 #define PMU_REG_1P1 68
95 #define PMU_REG_3P0 72
96 #define PMU_REG_2P5 76
97 #define PMU_REG_CORE 80
98 
99 #define CCM_ANALOG_MISC0 84
100 #define PMU_MISC0 CCM_ANALOG_MISC0
101 #define CCM_ANALOG_MISC0_SET 85
102 #define PMU_MISC0_SET CCM_ANALOG_MISC0_SET
103 #define CCM_ANALOG_MISC0_CLR 86
104 #define PMU_MISC0_CLR CCM_ANALOG_MISC0_CLR
105 #define CCM_ANALOG_MISC0_TOG 87
106 #define PMU_MISC0_TOG CCM_ANALOG_MISC0_TOG
107 
108 #define CCM_ANALOG_MISC1 88
109 #define PMU_MISC1 CCM_ANALOG_MISC1
110 #define CCM_ANALOG_MISC1_SET 89
111 #define PMU_MISC1_SET CCM_ANALOG_MISC1_SET
112 #define CCM_ANALOG_MISC1_CLR 90
113 #define PMU_MISC1_CLR CCM_ANALOG_MISC1_CLR
114 #define CCM_ANALOG_MISC1_TOG 91
115 #define PMU_MISC1_TOG CCM_ANALOG_MISC1_TOG
116 
117 #define CCM_ANALOG_MISC2 92
118 #define PMU_MISC2 CCM_ANALOG_MISC2
119 #define CCM_ANALOG_MISC2_SET 93
120 #define PMU_MISC2_SET CCM_ANALOG_MISC2_SET
121 #define CCM_ANALOG_MISC2_CLR 94
122 #define PMU_MISC2_CLR CCM_ANALOG_MISC2_CLR
123 #define CCM_ANALOG_MISC2_TOG 95
124 #define PMU_MISC2_TOG CCM_ANALOG_MISC2_TOG
125 
126 #define TEMPMON_TEMPSENSE0 96
127 #define TEMPMON_TEMPSENSE0_SET 97
128 #define TEMPMON_TEMPSENSE0_CLR 98
129 #define TEMPMON_TEMPSENSE0_TOG 99
130 #define TEMPMON_TEMPSENSE1 100
131 #define TEMPMON_TEMPSENSE1_SET 101
132 #define TEMPMON_TEMPSENSE1_CLR 102
133 #define TEMPMON_TEMPSENSE1_TOG 103
134 #define TEMPMON_TEMPSENSE2 164
135 #define TEMPMON_TEMPSENSE2_SET 165
136 #define TEMPMON_TEMPSENSE2_CLR 166
137 #define TEMPMON_TEMPSENSE2_TOG 167
138 
139 #define PMU_LOWPWR_CTRL 155
140 #define PMU_LOWPWR_CTRL_SET 156
141 #define PMU_LOWPWR_CTRL_CLR 157
142 #define PMU_LOWPWR_CTRL_TOG 158
143 
144 #define USB_ANALOG_USB1_VBUS_DETECT 104
145 #define USB_ANALOG_USB1_VBUS_DETECT_SET 105
146 #define USB_ANALOG_USB1_VBUS_DETECT_CLR 106
147 #define USB_ANALOG_USB1_VBUS_DETECT_TOG 107
148 #define USB_ANALOG_USB1_CHRG_DETECT 108
149 #define USB_ANALOG_USB1_CHRG_DETECT_SET 109
150 #define USB_ANALOG_USB1_CHRG_DETECT_CLR 110
151 #define USB_ANALOG_USB1_CHRG_DETECT_TOG 111
152 #define USB_ANALOG_USB1_VBUS_DETECT_STAT 112
153 #define USB_ANALOG_USB1_CHRG_DETECT_STAT 116
154 #define USB_ANALOG_USB1_MISC 124
155 #define USB_ANALOG_USB1_MISC_SET 125
156 #define USB_ANALOG_USB1_MISC_CLR 126
157 #define USB_ANALOG_USB1_MISC_TOG 127
158 #define USB_ANALOG_USB2_VBUS_DETECT 128
159 #define USB_ANALOG_USB2_VBUS_DETECT_SET 129
160 #define USB_ANALOG_USB2_VBUS_DETECT_CLR 130
161 #define USB_ANALOG_USB2_VBUS_DETECT_TOG 131
162 #define USB_ANALOG_USB2_CHRG_DETECT 132
163 #define USB_ANALOG_USB2_CHRG_DETECT_SET 133
164 #define USB_ANALOG_USB2_CHRG_DETECT_CLR 134
165 #define USB_ANALOG_USB2_CHRG_DETECT_TOG 135
166 #define USB_ANALOG_USB2_VBUS_DETECT_STAT 136
167 #define USB_ANALOG_USB2_CHRG_DETECT_STAT 140
168 #define USB_ANALOG_USB2_MISC 148
169 #define USB_ANALOG_USB2_MISC_SET 149
170 #define USB_ANALOG_USB2_MISC_CLR 150
171 #define USB_ANALOG_USB2_MISC_TOG 151
172 #define USB_ANALOG_DIGPROG 152
173 #define CCM_ANALOG_MAX 4096
174 
175 /* CCM_CBCMR */
176 #define R_CBCMR_PRE_PERIPH_CLK_SEL_SHIFT  (18)
177 #define R_CBCMR_PRE_PERIPH_CLK_SEL_LENGTH (2)
178 #define R_CBCMR_PERIPH_CLK2_SEL_SHIFT    (12)
179 #define R_CBCMR_PERIPH_CLK2_SEL_LENGTH   (2)
180 
181 /* CCM_CBCDR */
182 #define R_CBCDR_AHB_PODF_SHIFT           (10)
183 #define R_CBCDR_AHB_PODF_LENGTH          (3)
184 #define R_CBCDR_IPG_PODF_SHIFT           (8)
185 #define R_CBCDR_IPG_PODF_LENGTH          (2)
186 #define R_CBCDR_PERIPH_CLK_SEL_SHIFT     (25)
187 #define R_CBCDR_PERIPH_CLK_SEL_LENGTH    (1)
188 #define R_CBCDR_PERIPH_CLK2_PODF_SHIFT   (27)
189 #define R_CBCDR_PERIPH_CLK2_PODF_LENGTH  (3)
190 
191 /* CCM_CSCMR1 */
192 #define R_CSCMR1_PERCLK_PODF_SHIFT        (0)
193 #define R_CSCMR1_PERCLK_PODF_LENGTH       (6)
194 #define R_CSCMR1_PERCLK_CLK_SEL_SHIFT     (6)
195 #define R_CSCMR1_PERCLK_CLK_SEL_LENGTH    (1)
196 
197 /* CCM_ANALOG_PFD_528 */
198 #define R_ANALOG_PFD_528_PFD0_FRAC_SHIFT          (0)
199 #define R_ANALOG_PFD_528_PFD0_FRAC_LENGTH         (6)
200 #define R_ANALOG_PFD_528_PFD2_FRAC_SHIFT          (16)
201 #define R_ANALOG_PFD_528_PFD2_FRAC_LENGTH         (6)
202 
203 /* CCM_ANALOG_PLL_SYS */
204 #define R_ANALOG_PLL_SYS_DIV_SELECT_SHIFT         (0)
205 #define R_ANALOG_PLL_SYS_DIV_SELECT_LENGTH        (1)
206 
207 #define CCM_ANALOG_PLL_LOCK      (1 << 31);
208 
209 #define TYPE_IMX6UL_CCM "imx6ul.ccm"
210 #define IMX6UL_CCM(obj) OBJECT_CHECK(IMX6ULCCMState, (obj), TYPE_IMX6UL_CCM)
211 
212 typedef struct IMX6ULCCMState {
213     /* <private> */
214     IMXCCMState parent_obj;
215 
216     /* <public> */
217     MemoryRegion container;
218     MemoryRegion ioccm;
219     MemoryRegion ioanalog;
220 
221     uint32_t ccm[CCM_MAX];
222     uint32_t analog[CCM_ANALOG_MAX];
223 
224 } IMX6ULCCMState;
225 
226 #endif /* IMX6UL_CCM_H */
227