2 * IMX6UL Clock Control Module
4 * Copyright (C) 2018 by Jean-Christophe Dubois <jcd@tribudubois.net>
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.
13 #include "hw/misc/imx_ccm.h"
14 #include "qemu/bitops.h"
15 #include "qom/object.h"
30 #define CCM_CHSCCDR 13
50 #define CCM_ANALOG_PLL_ARM 0
51 #define CCM_ANALOG_PLL_ARM_SET 1
52 #define CCM_ANALOG_PLL_ARM_CLR 2
53 #define CCM_ANALOG_PLL_ARM_TOG 3
54 #define CCM_ANALOG_PLL_USB1 4
55 #define CCM_ANALOG_PLL_USB1_SET 5
56 #define CCM_ANALOG_PLL_USB1_CLR 6
57 #define CCM_ANALOG_PLL_USB1_TOG 7
58 #define CCM_ANALOG_PLL_USB2 8
59 #define CCM_ANALOG_PLL_USB2_SET 9
60 #define CCM_ANALOG_PLL_USB2_CLR 10
61 #define CCM_ANALOG_PLL_USB2_TOG 11
62 #define CCM_ANALOG_PLL_SYS 12
63 #define CCM_ANALOG_PLL_SYS_SET 13
64 #define CCM_ANALOG_PLL_SYS_CLR 14
65 #define CCM_ANALOG_PLL_SYS_TOG 15
66 #define CCM_ANALOG_PLL_SYS_SS 16
67 #define CCM_ANALOG_PLL_SYS_NUM 20
68 #define CCM_ANALOG_PLL_SYS_DENOM 24
69 #define CCM_ANALOG_PLL_AUDIO 28
70 #define CCM_ANALOG_PLL_AUDIO_SET 29
71 #define CCM_ANALOG_PLL_AUDIO_CLR 30
72 #define CCM_ANALOG_PLL_AUDIO_TOG 31
73 #define CCM_ANALOG_PLL_AUDIO_NUM 32
74 #define CCM_ANALOG_PLL_AUDIO_DENOM 36
75 #define CCM_ANALOG_PLL_VIDEO 40
76 #define CCM_ANALOG_PLL_VIDEO_SET 41
77 #define CCM_ANALOG_PLL_VIDEO_CLR 42
78 #define CCM_ANALOG_PLL_VIDEO_TOG 44
79 #define CCM_ANALOG_PLL_VIDEO_NUM 46
80 #define CCM_ANALOG_PLL_VIDEO_DENOM 48
81 #define CCM_ANALOG_PLL_ENET 56
82 #define CCM_ANALOG_PLL_ENET_SET 57
83 #define CCM_ANALOG_PLL_ENET_CLR 58
84 #define CCM_ANALOG_PLL_ENET_TOG 59
85 #define CCM_ANALOG_PFD_480 60
86 #define CCM_ANALOG_PFD_480_SET 61
87 #define CCM_ANALOG_PFD_480_CLR 62
88 #define CCM_ANALOG_PFD_480_TOG 63
89 #define CCM_ANALOG_PFD_528 64
90 #define CCM_ANALOG_PFD_528_SET 65
91 #define CCM_ANALOG_PFD_528_CLR 66
92 #define CCM_ANALOG_PFD_528_TOG 67
95 #define PMU_REG_1P1 68
96 #define PMU_REG_3P0 72
97 #define PMU_REG_2P5 76
98 #define PMU_REG_CORE 80
100 #define CCM_ANALOG_MISC0 84
101 #define PMU_MISC0 CCM_ANALOG_MISC0
102 #define CCM_ANALOG_MISC0_SET 85
103 #define PMU_MISC0_SET CCM_ANALOG_MISC0_SET
104 #define CCM_ANALOG_MISC0_CLR 86
105 #define PMU_MISC0_CLR CCM_ANALOG_MISC0_CLR
106 #define CCM_ANALOG_MISC0_TOG 87
107 #define PMU_MISC0_TOG CCM_ANALOG_MISC0_TOG
109 #define CCM_ANALOG_MISC1 88
110 #define PMU_MISC1 CCM_ANALOG_MISC1
111 #define CCM_ANALOG_MISC1_SET 89
112 #define PMU_MISC1_SET CCM_ANALOG_MISC1_SET
113 #define CCM_ANALOG_MISC1_CLR 90
114 #define PMU_MISC1_CLR CCM_ANALOG_MISC1_CLR
115 #define CCM_ANALOG_MISC1_TOG 91
116 #define PMU_MISC1_TOG CCM_ANALOG_MISC1_TOG
118 #define CCM_ANALOG_MISC2 92
119 #define PMU_MISC2 CCM_ANALOG_MISC2
120 #define CCM_ANALOG_MISC2_SET 93
121 #define PMU_MISC2_SET CCM_ANALOG_MISC2_SET
122 #define CCM_ANALOG_MISC2_CLR 94
123 #define PMU_MISC2_CLR CCM_ANALOG_MISC2_CLR
124 #define CCM_ANALOG_MISC2_TOG 95
125 #define PMU_MISC2_TOG CCM_ANALOG_MISC2_TOG
127 #define TEMPMON_TEMPSENSE0 96
128 #define TEMPMON_TEMPSENSE0_SET 97
129 #define TEMPMON_TEMPSENSE0_CLR 98
130 #define TEMPMON_TEMPSENSE0_TOG 99
131 #define TEMPMON_TEMPSENSE1 100
132 #define TEMPMON_TEMPSENSE1_SET 101
133 #define TEMPMON_TEMPSENSE1_CLR 102
134 #define TEMPMON_TEMPSENSE1_TOG 103
135 #define TEMPMON_TEMPSENSE2 164
136 #define TEMPMON_TEMPSENSE2_SET 165
137 #define TEMPMON_TEMPSENSE2_CLR 166
138 #define TEMPMON_TEMPSENSE2_TOG 167
140 #define PMU_LOWPWR_CTRL 155
141 #define PMU_LOWPWR_CTRL_SET 156
142 #define PMU_LOWPWR_CTRL_CLR 157
143 #define PMU_LOWPWR_CTRL_TOG 158
145 #define USB_ANALOG_USB1_VBUS_DETECT 104
146 #define USB_ANALOG_USB1_VBUS_DETECT_SET 105
147 #define USB_ANALOG_USB1_VBUS_DETECT_CLR 106
148 #define USB_ANALOG_USB1_VBUS_DETECT_TOG 107
149 #define USB_ANALOG_USB1_CHRG_DETECT 108
150 #define USB_ANALOG_USB1_CHRG_DETECT_SET 109
151 #define USB_ANALOG_USB1_CHRG_DETECT_CLR 110
152 #define USB_ANALOG_USB1_CHRG_DETECT_TOG 111
153 #define USB_ANALOG_USB1_VBUS_DETECT_STAT 112
154 #define USB_ANALOG_USB1_CHRG_DETECT_STAT 116
155 #define USB_ANALOG_USB1_MISC 124
156 #define USB_ANALOG_USB1_MISC_SET 125
157 #define USB_ANALOG_USB1_MISC_CLR 126
158 #define USB_ANALOG_USB1_MISC_TOG 127
159 #define USB_ANALOG_USB2_VBUS_DETECT 128
160 #define USB_ANALOG_USB2_VBUS_DETECT_SET 129
161 #define USB_ANALOG_USB2_VBUS_DETECT_CLR 130
162 #define USB_ANALOG_USB2_VBUS_DETECT_TOG 131
163 #define USB_ANALOG_USB2_CHRG_DETECT 132
164 #define USB_ANALOG_USB2_CHRG_DETECT_SET 133
165 #define USB_ANALOG_USB2_CHRG_DETECT_CLR 134
166 #define USB_ANALOG_USB2_CHRG_DETECT_TOG 135
167 #define USB_ANALOG_USB2_VBUS_DETECT_STAT 136
168 #define USB_ANALOG_USB2_CHRG_DETECT_STAT 140
169 #define USB_ANALOG_USB2_MISC 148
170 #define USB_ANALOG_USB2_MISC_SET 149
171 #define USB_ANALOG_USB2_MISC_CLR 150
172 #define USB_ANALOG_USB2_MISC_TOG 151
173 #define USB_ANALOG_DIGPROG 152
174 #define CCM_ANALOG_MAX 4096
177 #define R_CBCMR_PRE_PERIPH_CLK_SEL_SHIFT (18)
178 #define R_CBCMR_PRE_PERIPH_CLK_SEL_LENGTH (2)
179 #define R_CBCMR_PERIPH_CLK2_SEL_SHIFT (12)
180 #define R_CBCMR_PERIPH_CLK2_SEL_LENGTH (2)
183 #define R_CBCDR_AHB_PODF_SHIFT (10)
184 #define R_CBCDR_AHB_PODF_LENGTH (3)
185 #define R_CBCDR_IPG_PODF_SHIFT (8)
186 #define R_CBCDR_IPG_PODF_LENGTH (2)
187 #define R_CBCDR_PERIPH_CLK_SEL_SHIFT (25)
188 #define R_CBCDR_PERIPH_CLK_SEL_LENGTH (1)
189 #define R_CBCDR_PERIPH_CLK2_PODF_SHIFT (27)
190 #define R_CBCDR_PERIPH_CLK2_PODF_LENGTH (3)
193 #define R_CSCMR1_PERCLK_PODF_SHIFT (0)
194 #define R_CSCMR1_PERCLK_PODF_LENGTH (6)
195 #define R_CSCMR1_PERCLK_CLK_SEL_SHIFT (6)
196 #define R_CSCMR1_PERCLK_CLK_SEL_LENGTH (1)
198 /* CCM_ANALOG_PFD_528 */
199 #define R_ANALOG_PFD_528_PFD0_FRAC_SHIFT (0)
200 #define R_ANALOG_PFD_528_PFD0_FRAC_LENGTH (6)
201 #define R_ANALOG_PFD_528_PFD2_FRAC_SHIFT (16)
202 #define R_ANALOG_PFD_528_PFD2_FRAC_LENGTH (6)
204 /* CCM_ANALOG_PLL_SYS */
205 #define R_ANALOG_PLL_SYS_DIV_SELECT_SHIFT (0)
206 #define R_ANALOG_PLL_SYS_DIV_SELECT_LENGTH (1)
208 #define CCM_ANALOG_PLL_LOCK (1 << 31);
210 #define TYPE_IMX6UL_CCM "imx6ul.ccm"
211 OBJECT_DECLARE_SIMPLE_TYPE(IMX6ULCCMState
, IMX6UL_CCM
)
213 struct IMX6ULCCMState
{
215 IMXCCMState parent_obj
;
218 MemoryRegion container
;
220 MemoryRegion ioanalog
;
222 uint32_t ccm
[CCM_MAX
];
223 uint32_t analog
[CCM_ANALOG_MAX
];
227 #endif /* IMX6UL_CCM_H */