1 #ifndef _VC4_HDMI_REGS_H_
2 #define _VC4_HDMI_REGS_H_
3
4 #include "vc4_hdmi.h"
5
6 #define VC4_HDMI_PACKET_STRIDE 0x24
7
8 enum vc4_hdmi_regs {
9 VC4_INVALID = 0,
10 VC4_HDMI,
11 VC4_HD,
12 VC5_CEC,
13 VC5_CSC,
14 VC5_DVP,
15 VC5_PHY,
16 VC5_RAM,
17 VC5_RM,
18 };
19
20 enum vc4_hdmi_field {
21 HDMI_AUDIO_PACKET_CONFIG,
22 HDMI_CEC_CNTRL_1,
23 HDMI_CEC_CNTRL_2,
24 HDMI_CEC_CNTRL_3,
25 HDMI_CEC_CNTRL_4,
26 HDMI_CEC_CNTRL_5,
27 HDMI_CEC_CPU_CLEAR,
28 HDMI_CEC_CPU_MASK_CLEAR,
29 HDMI_CEC_CPU_MASK_SET,
30 HDMI_CEC_CPU_MASK_STATUS,
31 HDMI_CEC_CPU_STATUS,
32 HDMI_CEC_CPU_SET,
33
34 /*
35 * Transmit data, first byte is low byte of the 32-bit reg.
36 * MSB of each byte transmitted first.
37 */
38 HDMI_CEC_RX_DATA_1,
39 HDMI_CEC_RX_DATA_2,
40 HDMI_CEC_RX_DATA_3,
41 HDMI_CEC_RX_DATA_4,
42 HDMI_CEC_TX_DATA_1,
43 HDMI_CEC_TX_DATA_2,
44 HDMI_CEC_TX_DATA_3,
45 HDMI_CEC_TX_DATA_4,
46 HDMI_CLOCK_STOP,
47 HDMI_CORE_REV,
48 HDMI_CRP_CFG,
49 HDMI_CSC_12_11,
50 HDMI_CSC_14_13,
51 HDMI_CSC_22_21,
52 HDMI_CSC_24_23,
53 HDMI_CSC_32_31,
54 HDMI_CSC_34_33,
55 HDMI_CSC_CTL,
56
57 /*
58 * 20-bit fields containing CTS values to be transmitted if
59 * !EXTERNAL_CTS_EN
60 */
61 HDMI_CTS_0,
62 HDMI_CTS_1,
63 HDMI_DEEP_COLOR_CONFIG_1,
64 HDMI_DVP_CTL,
65 HDMI_FIFO_CTL,
66 HDMI_FRAME_COUNT,
67 HDMI_GCP_CONFIG,
68 HDMI_GCP_WORD_1,
69 HDMI_HORZA,
70 HDMI_HORZB,
71 HDMI_HOTPLUG,
72 HDMI_HOTPLUG_INT,
73
74 /*
75 * 3 bits per field, where each field maps from that
76 * corresponding MAI bus channel to the given HDMI channel.
77 */
78 HDMI_MAI_CHANNEL_MAP,
79 HDMI_MAI_CONFIG,
80 HDMI_MAI_CTL,
81
82 /*
83 * Register for DMAing in audio data to be transported over
84 * the MAI bus to the Falcon core.
85 */
86 HDMI_MAI_DATA,
87
88 /* Format header to be placed on the MAI data. Unused. */
89 HDMI_MAI_FMT,
90
91 /* Last received format word on the MAI bus. */
92 HDMI_MAI_FORMAT,
93 HDMI_MAI_SMP,
94 HDMI_MAI_THR,
95 HDMI_M_CTL,
96 HDMI_RAM_PACKET_CONFIG,
97 HDMI_RAM_PACKET_START,
98 HDMI_RAM_PACKET_STATUS,
99 HDMI_RM_CONTROL,
100 HDMI_RM_FORMAT,
101 HDMI_RM_OFFSET,
102 HDMI_SCHEDULER_CONTROL,
103 HDMI_SCRAMBLER_CTL,
104 HDMI_SW_RESET_CONTROL,
105 HDMI_TX_PHY_CHANNEL_SWAP,
106 HDMI_TX_PHY_CLK_DIV,
107 HDMI_TX_PHY_CTL_0,
108 HDMI_TX_PHY_CTL_1,
109 HDMI_TX_PHY_CTL_2,
110 HDMI_TX_PHY_CTL_3,
111 HDMI_TX_PHY_PLL_CALIBRATION_CONFIG_1,
112 HDMI_TX_PHY_PLL_CALIBRATION_CONFIG_2,
113 HDMI_TX_PHY_PLL_CALIBRATION_CONFIG_4,
114 HDMI_TX_PHY_PLL_CFG,
115 HDMI_TX_PHY_PLL_CTL_0,
116 HDMI_TX_PHY_PLL_CTL_1,
117 HDMI_TX_PHY_POWERDOWN_CTL,
118 HDMI_TX_PHY_RESET_CTL,
119 HDMI_TX_PHY_TMDS_CLK_WORD_SEL,
120 HDMI_VEC_INTERFACE_XBAR,
121 HDMI_VERTA0,
122 HDMI_VERTA1,
123 HDMI_VERTB0,
124 HDMI_VERTB1,
125 HDMI_VID_CTL,
126 HDMI_MISC_CONTROL,
127 };
128
129 struct vc4_hdmi_register {
130 char *name;
131 enum vc4_hdmi_regs reg;
132 unsigned int offset;
133 };
134
135 #define _VC4_REG(_base, _reg, _offset) \
136 [_reg] = { \
137 .name = #_reg, \
138 .reg = _base, \
139 .offset = _offset, \
140 }
141
142 #define VC4_HD_REG(reg, offset) _VC4_REG(VC4_HD, reg, offset)
143 #define VC4_HDMI_REG(reg, offset) _VC4_REG(VC4_HDMI, reg, offset)
144 #define VC5_CEC_REG(reg, offset) _VC4_REG(VC5_CEC, reg, offset)
145 #define VC5_CSC_REG(reg, offset) _VC4_REG(VC5_CSC, reg, offset)
146 #define VC5_DVP_REG(reg, offset) _VC4_REG(VC5_DVP, reg, offset)
147 #define VC5_PHY_REG(reg, offset) _VC4_REG(VC5_PHY, reg, offset)
148 #define VC5_RAM_REG(reg, offset) _VC4_REG(VC5_RAM, reg, offset)
149 #define VC5_RM_REG(reg, offset) _VC4_REG(VC5_RM, reg, offset)
150
151 static const struct vc4_hdmi_register __maybe_unused vc4_hdmi_fields[] = {
152 VC4_HD_REG(HDMI_M_CTL, 0x000c),
153 VC4_HD_REG(HDMI_MAI_CTL, 0x0014),
154 VC4_HD_REG(HDMI_MAI_THR, 0x0018),
155 VC4_HD_REG(HDMI_MAI_FMT, 0x001c),
156 VC4_HD_REG(HDMI_MAI_DATA, 0x0020),
157 VC4_HD_REG(HDMI_MAI_SMP, 0x002c),
158 VC4_HD_REG(HDMI_VID_CTL, 0x0038),
159 VC4_HD_REG(HDMI_CSC_CTL, 0x0040),
160 VC4_HD_REG(HDMI_CSC_12_11, 0x0044),
161 VC4_HD_REG(HDMI_CSC_14_13, 0x0048),
162 VC4_HD_REG(HDMI_CSC_22_21, 0x004c),
163 VC4_HD_REG(HDMI_CSC_24_23, 0x0050),
164 VC4_HD_REG(HDMI_CSC_32_31, 0x0054),
165 VC4_HD_REG(HDMI_CSC_34_33, 0x0058),
166 VC4_HD_REG(HDMI_FRAME_COUNT, 0x0068),
167
168 VC4_HDMI_REG(HDMI_CORE_REV, 0x0000),
169 VC4_HDMI_REG(HDMI_SW_RESET_CONTROL, 0x0004),
170 VC4_HDMI_REG(HDMI_HOTPLUG_INT, 0x0008),
171 VC4_HDMI_REG(HDMI_HOTPLUG, 0x000c),
172 VC4_HDMI_REG(HDMI_FIFO_CTL, 0x005c),
173 VC4_HDMI_REG(HDMI_MAI_CHANNEL_MAP, 0x0090),
174 VC4_HDMI_REG(HDMI_MAI_CONFIG, 0x0094),
175 VC4_HDMI_REG(HDMI_MAI_FORMAT, 0x0098),
176 VC4_HDMI_REG(HDMI_AUDIO_PACKET_CONFIG, 0x009c),
177 VC4_HDMI_REG(HDMI_RAM_PACKET_CONFIG, 0x00a0),
178 VC4_HDMI_REG(HDMI_RAM_PACKET_STATUS, 0x00a4),
179 VC4_HDMI_REG(HDMI_CRP_CFG, 0x00a8),
180 VC4_HDMI_REG(HDMI_CTS_0, 0x00ac),
181 VC4_HDMI_REG(HDMI_CTS_1, 0x00b0),
182 VC4_HDMI_REG(HDMI_SCHEDULER_CONTROL, 0x00c0),
183 VC4_HDMI_REG(HDMI_HORZA, 0x00c4),
184 VC4_HDMI_REG(HDMI_HORZB, 0x00c8),
185 VC4_HDMI_REG(HDMI_VERTA0, 0x00cc),
186 VC4_HDMI_REG(HDMI_VERTB0, 0x00d0),
187 VC4_HDMI_REG(HDMI_VERTA1, 0x00d4),
188 VC4_HDMI_REG(HDMI_VERTB1, 0x00d8),
189 VC4_HDMI_REG(HDMI_CEC_CNTRL_1, 0x00e8),
190 VC4_HDMI_REG(HDMI_CEC_CNTRL_2, 0x00ec),
191 VC4_HDMI_REG(HDMI_CEC_CNTRL_3, 0x00f0),
192 VC4_HDMI_REG(HDMI_CEC_CNTRL_4, 0x00f4),
193 VC4_HDMI_REG(HDMI_CEC_CNTRL_5, 0x00f8),
194 VC4_HDMI_REG(HDMI_CEC_TX_DATA_1, 0x00fc),
195 VC4_HDMI_REG(HDMI_CEC_TX_DATA_2, 0x0100),
196 VC4_HDMI_REG(HDMI_CEC_TX_DATA_3, 0x0104),
197 VC4_HDMI_REG(HDMI_CEC_TX_DATA_4, 0x0108),
198 VC4_HDMI_REG(HDMI_CEC_RX_DATA_1, 0x010c),
199 VC4_HDMI_REG(HDMI_CEC_RX_DATA_2, 0x0110),
200 VC4_HDMI_REG(HDMI_CEC_RX_DATA_3, 0x0114),
201 VC4_HDMI_REG(HDMI_CEC_RX_DATA_4, 0x0118),
202 VC4_HDMI_REG(HDMI_TX_PHY_RESET_CTL, 0x02c0),
203 VC4_HDMI_REG(HDMI_TX_PHY_CTL_0, 0x02c4),
204 VC4_HDMI_REG(HDMI_CEC_CPU_STATUS, 0x0340),
205 VC4_HDMI_REG(HDMI_CEC_CPU_SET, 0x0344),
206 VC4_HDMI_REG(HDMI_CEC_CPU_CLEAR, 0x0348),
207 VC4_HDMI_REG(HDMI_CEC_CPU_MASK_STATUS, 0x034c),
208 VC4_HDMI_REG(HDMI_CEC_CPU_MASK_SET, 0x0350),
209 VC4_HDMI_REG(HDMI_CEC_CPU_MASK_CLEAR, 0x0354),
210 VC4_HDMI_REG(HDMI_RAM_PACKET_START, 0x0400),
211 };
212
213 static const struct vc4_hdmi_register __maybe_unused vc5_hdmi_hdmi0_fields[] = {
214 VC4_HD_REG(HDMI_DVP_CTL, 0x0000),
215 VC4_HD_REG(HDMI_MAI_CTL, 0x0010),
216 VC4_HD_REG(HDMI_MAI_THR, 0x0014),
217 VC4_HD_REG(HDMI_MAI_FMT, 0x0018),
218 VC4_HD_REG(HDMI_MAI_DATA, 0x001c),
219 VC4_HD_REG(HDMI_MAI_SMP, 0x0020),
220 VC4_HD_REG(HDMI_VID_CTL, 0x0044),
221 VC4_HD_REG(HDMI_FRAME_COUNT, 0x0060),
222
223 VC4_HDMI_REG(HDMI_FIFO_CTL, 0x074),
224 VC4_HDMI_REG(HDMI_AUDIO_PACKET_CONFIG, 0x0b8),
225 VC4_HDMI_REG(HDMI_RAM_PACKET_CONFIG, 0x0bc),
226 VC4_HDMI_REG(HDMI_RAM_PACKET_STATUS, 0x0c4),
227 VC4_HDMI_REG(HDMI_CRP_CFG, 0x0c8),
228 VC4_HDMI_REG(HDMI_CTS_0, 0x0cc),
229 VC4_HDMI_REG(HDMI_CTS_1, 0x0d0),
230 VC4_HDMI_REG(HDMI_SCHEDULER_CONTROL, 0x0e0),
231 VC4_HDMI_REG(HDMI_HORZA, 0x0e4),
232 VC4_HDMI_REG(HDMI_HORZB, 0x0e8),
233 VC4_HDMI_REG(HDMI_VERTA0, 0x0ec),
234 VC4_HDMI_REG(HDMI_VERTB0, 0x0f0),
235 VC4_HDMI_REG(HDMI_VERTA1, 0x0f4),
236 VC4_HDMI_REG(HDMI_VERTB1, 0x0f8),
237 VC4_HDMI_REG(HDMI_MISC_CONTROL, 0x100),
238 VC4_HDMI_REG(HDMI_MAI_CHANNEL_MAP, 0x09c),
239 VC4_HDMI_REG(HDMI_MAI_CONFIG, 0x0a0),
240 VC4_HDMI_REG(HDMI_DEEP_COLOR_CONFIG_1, 0x170),
241 VC4_HDMI_REG(HDMI_GCP_CONFIG, 0x178),
242 VC4_HDMI_REG(HDMI_GCP_WORD_1, 0x17c),
243 VC4_HDMI_REG(HDMI_HOTPLUG, 0x1a8),
244 VC4_HDMI_REG(HDMI_SCRAMBLER_CTL, 0x1c4),
245
246 VC5_DVP_REG(HDMI_CLOCK_STOP, 0x0bc),
247 VC5_DVP_REG(HDMI_VEC_INTERFACE_XBAR, 0x0f0),
248
249 VC5_PHY_REG(HDMI_TX_PHY_RESET_CTL, 0x000),
250 VC5_PHY_REG(HDMI_TX_PHY_POWERDOWN_CTL, 0x004),
251 VC5_PHY_REG(HDMI_TX_PHY_CTL_0, 0x008),
252 VC5_PHY_REG(HDMI_TX_PHY_CTL_1, 0x00c),
253 VC5_PHY_REG(HDMI_TX_PHY_CTL_2, 0x010),
254 VC5_PHY_REG(HDMI_TX_PHY_CTL_3, 0x014),
255 VC5_PHY_REG(HDMI_TX_PHY_PLL_CTL_0, 0x01c),
256 VC5_PHY_REG(HDMI_TX_PHY_PLL_CTL_1, 0x020),
257 VC5_PHY_REG(HDMI_TX_PHY_CLK_DIV, 0x028),
258 VC5_PHY_REG(HDMI_TX_PHY_PLL_CFG, 0x034),
259 VC5_PHY_REG(HDMI_TX_PHY_TMDS_CLK_WORD_SEL, 0x044),
260 VC5_PHY_REG(HDMI_TX_PHY_CHANNEL_SWAP, 0x04c),
261 VC5_PHY_REG(HDMI_TX_PHY_PLL_CALIBRATION_CONFIG_1, 0x050),
262 VC5_PHY_REG(HDMI_TX_PHY_PLL_CALIBRATION_CONFIG_2, 0x054),
263 VC5_PHY_REG(HDMI_TX_PHY_PLL_CALIBRATION_CONFIG_4, 0x05c),
264
265 VC5_RM_REG(HDMI_RM_CONTROL, 0x000),
266 VC5_RM_REG(HDMI_RM_OFFSET, 0x018),
267 VC5_RM_REG(HDMI_RM_FORMAT, 0x01c),
268
269 VC5_RAM_REG(HDMI_RAM_PACKET_START, 0x000),
270
271 VC5_CEC_REG(HDMI_CEC_CNTRL_1, 0x010),
272 VC5_CEC_REG(HDMI_CEC_CNTRL_2, 0x014),
273 VC5_CEC_REG(HDMI_CEC_CNTRL_3, 0x018),
274 VC5_CEC_REG(HDMI_CEC_CNTRL_4, 0x01c),
275 VC5_CEC_REG(HDMI_CEC_CNTRL_5, 0x020),
276 VC5_CEC_REG(HDMI_CEC_TX_DATA_1, 0x028),
277 VC5_CEC_REG(HDMI_CEC_TX_DATA_2, 0x02c),
278 VC5_CEC_REG(HDMI_CEC_TX_DATA_3, 0x030),
279 VC5_CEC_REG(HDMI_CEC_TX_DATA_4, 0x034),
280 VC5_CEC_REG(HDMI_CEC_RX_DATA_1, 0x038),
281 VC5_CEC_REG(HDMI_CEC_RX_DATA_2, 0x03c),
282 VC5_CEC_REG(HDMI_CEC_RX_DATA_3, 0x040),
283 VC5_CEC_REG(HDMI_CEC_RX_DATA_4, 0x044),
284
285 VC5_CSC_REG(HDMI_CSC_CTL, 0x000),
286 VC5_CSC_REG(HDMI_CSC_12_11, 0x004),
287 VC5_CSC_REG(HDMI_CSC_14_13, 0x008),
288 VC5_CSC_REG(HDMI_CSC_22_21, 0x00c),
289 VC5_CSC_REG(HDMI_CSC_24_23, 0x010),
290 VC5_CSC_REG(HDMI_CSC_32_31, 0x014),
291 VC5_CSC_REG(HDMI_CSC_34_33, 0x018),
292 };
293
294 static const struct vc4_hdmi_register __maybe_unused vc5_hdmi_hdmi1_fields[] = {
295 VC4_HD_REG(HDMI_DVP_CTL, 0x0000),
296 VC4_HD_REG(HDMI_MAI_CTL, 0x0030),
297 VC4_HD_REG(HDMI_MAI_THR, 0x0034),
298 VC4_HD_REG(HDMI_MAI_FMT, 0x0038),
299 VC4_HD_REG(HDMI_MAI_DATA, 0x003c),
300 VC4_HD_REG(HDMI_MAI_SMP, 0x0040),
301 VC4_HD_REG(HDMI_VID_CTL, 0x0048),
302 VC4_HD_REG(HDMI_FRAME_COUNT, 0x0064),
303
304 VC4_HDMI_REG(HDMI_FIFO_CTL, 0x074),
305 VC4_HDMI_REG(HDMI_AUDIO_PACKET_CONFIG, 0x0b8),
306 VC4_HDMI_REG(HDMI_RAM_PACKET_CONFIG, 0x0bc),
307 VC4_HDMI_REG(HDMI_RAM_PACKET_STATUS, 0x0c4),
308 VC4_HDMI_REG(HDMI_CRP_CFG, 0x0c8),
309 VC4_HDMI_REG(HDMI_CTS_0, 0x0cc),
310 VC4_HDMI_REG(HDMI_CTS_1, 0x0d0),
311 VC4_HDMI_REG(HDMI_SCHEDULER_CONTROL, 0x0e0),
312 VC4_HDMI_REG(HDMI_HORZA, 0x0e4),
313 VC4_HDMI_REG(HDMI_HORZB, 0x0e8),
314 VC4_HDMI_REG(HDMI_VERTA0, 0x0ec),
315 VC4_HDMI_REG(HDMI_VERTB0, 0x0f0),
316 VC4_HDMI_REG(HDMI_VERTA1, 0x0f4),
317 VC4_HDMI_REG(HDMI_VERTB1, 0x0f8),
318 VC4_HDMI_REG(HDMI_MISC_CONTROL, 0x100),
319 VC4_HDMI_REG(HDMI_MAI_CHANNEL_MAP, 0x09c),
320 VC4_HDMI_REG(HDMI_MAI_CONFIG, 0x0a0),
321 VC4_HDMI_REG(HDMI_DEEP_COLOR_CONFIG_1, 0x170),
322 VC4_HDMI_REG(HDMI_GCP_CONFIG, 0x178),
323 VC4_HDMI_REG(HDMI_GCP_WORD_1, 0x17c),
324 VC4_HDMI_REG(HDMI_HOTPLUG, 0x1a8),
325 VC4_HDMI_REG(HDMI_SCRAMBLER_CTL, 0x1c4),
326
327 VC5_DVP_REG(HDMI_CLOCK_STOP, 0x0bc),
328 VC5_DVP_REG(HDMI_VEC_INTERFACE_XBAR, 0x0f0),
329
330 VC5_PHY_REG(HDMI_TX_PHY_RESET_CTL, 0x000),
331 VC5_PHY_REG(HDMI_TX_PHY_POWERDOWN_CTL, 0x004),
332 VC5_PHY_REG(HDMI_TX_PHY_CTL_0, 0x008),
333 VC5_PHY_REG(HDMI_TX_PHY_CTL_1, 0x00c),
334 VC5_PHY_REG(HDMI_TX_PHY_CTL_2, 0x010),
335 VC5_PHY_REG(HDMI_TX_PHY_CTL_3, 0x014),
336 VC5_PHY_REG(HDMI_TX_PHY_PLL_CTL_0, 0x01c),
337 VC5_PHY_REG(HDMI_TX_PHY_PLL_CTL_1, 0x020),
338 VC5_PHY_REG(HDMI_TX_PHY_CLK_DIV, 0x028),
339 VC5_PHY_REG(HDMI_TX_PHY_PLL_CFG, 0x034),
340 VC5_PHY_REG(HDMI_TX_PHY_CHANNEL_SWAP, 0x04c),
341 VC5_PHY_REG(HDMI_TX_PHY_TMDS_CLK_WORD_SEL, 0x044),
342 VC5_PHY_REG(HDMI_TX_PHY_PLL_CALIBRATION_CONFIG_1, 0x050),
343 VC5_PHY_REG(HDMI_TX_PHY_PLL_CALIBRATION_CONFIG_2, 0x054),
344 VC5_PHY_REG(HDMI_TX_PHY_PLL_CALIBRATION_CONFIG_4, 0x05c),
345
346 VC5_RM_REG(HDMI_RM_CONTROL, 0x000),
347 VC5_RM_REG(HDMI_RM_OFFSET, 0x018),
348 VC5_RM_REG(HDMI_RM_FORMAT, 0x01c),
349
350 VC5_RAM_REG(HDMI_RAM_PACKET_START, 0x000),
351
352 VC5_CEC_REG(HDMI_CEC_CNTRL_1, 0x010),
353 VC5_CEC_REG(HDMI_CEC_CNTRL_2, 0x014),
354 VC5_CEC_REG(HDMI_CEC_CNTRL_3, 0x018),
355 VC5_CEC_REG(HDMI_CEC_CNTRL_4, 0x01c),
356 VC5_CEC_REG(HDMI_CEC_CNTRL_5, 0x020),
357 VC5_CEC_REG(HDMI_CEC_TX_DATA_1, 0x028),
358 VC5_CEC_REG(HDMI_CEC_TX_DATA_2, 0x02c),
359 VC5_CEC_REG(HDMI_CEC_TX_DATA_3, 0x030),
360 VC5_CEC_REG(HDMI_CEC_TX_DATA_4, 0x034),
361 VC5_CEC_REG(HDMI_CEC_RX_DATA_1, 0x038),
362 VC5_CEC_REG(HDMI_CEC_RX_DATA_2, 0x03c),
363 VC5_CEC_REG(HDMI_CEC_RX_DATA_3, 0x040),
364 VC5_CEC_REG(HDMI_CEC_RX_DATA_4, 0x044),
365
366 VC5_CSC_REG(HDMI_CSC_CTL, 0x000),
367 VC5_CSC_REG(HDMI_CSC_12_11, 0x004),
368 VC5_CSC_REG(HDMI_CSC_14_13, 0x008),
369 VC5_CSC_REG(HDMI_CSC_22_21, 0x00c),
370 VC5_CSC_REG(HDMI_CSC_24_23, 0x010),
371 VC5_CSC_REG(HDMI_CSC_32_31, 0x014),
372 VC5_CSC_REG(HDMI_CSC_34_33, 0x018),
373 };
374
375 static inline
__vc4_hdmi_get_field_base(struct vc4_hdmi * hdmi,enum vc4_hdmi_regs reg)376 void __iomem *__vc4_hdmi_get_field_base(struct vc4_hdmi *hdmi,
377 enum vc4_hdmi_regs reg)
378 {
379 switch (reg) {
380 case VC4_HD:
381 return hdmi->hd_regs;
382
383 case VC4_HDMI:
384 return hdmi->hdmicore_regs;
385
386 case VC5_CSC:
387 return hdmi->csc_regs;
388
389 case VC5_CEC:
390 return hdmi->cec_regs;
391
392 case VC5_DVP:
393 return hdmi->dvp_regs;
394
395 case VC5_PHY:
396 return hdmi->phy_regs;
397
398 case VC5_RAM:
399 return hdmi->ram_regs;
400
401 case VC5_RM:
402 return hdmi->rm_regs;
403
404 default:
405 return NULL;
406 }
407
408 return NULL;
409 }
410
vc4_hdmi_read(struct vc4_hdmi * hdmi,enum vc4_hdmi_field reg)411 static inline u32 vc4_hdmi_read(struct vc4_hdmi *hdmi,
412 enum vc4_hdmi_field reg)
413 {
414 const struct vc4_hdmi_register *field;
415 const struct vc4_hdmi_variant *variant = hdmi->variant;
416 void __iomem *base;
417
418 if (reg >= variant->num_registers) {
419 dev_warn(&hdmi->pdev->dev,
420 "Invalid register ID %u\n", reg);
421 return 0;
422 }
423
424 field = &variant->registers[reg];
425 base = __vc4_hdmi_get_field_base(hdmi, field->reg);
426 if (!base) {
427 dev_warn(&hdmi->pdev->dev,
428 "Unknown register ID %u\n", reg);
429 return 0;
430 }
431
432 return readl(base + field->offset);
433 }
434 #define HDMI_READ(reg) vc4_hdmi_read(vc4_hdmi, reg)
435
vc4_hdmi_write(struct vc4_hdmi * hdmi,enum vc4_hdmi_field reg,u32 value)436 static inline void vc4_hdmi_write(struct vc4_hdmi *hdmi,
437 enum vc4_hdmi_field reg,
438 u32 value)
439 {
440 const struct vc4_hdmi_register *field;
441 const struct vc4_hdmi_variant *variant = hdmi->variant;
442 void __iomem *base;
443
444 if (reg >= variant->num_registers) {
445 dev_warn(&hdmi->pdev->dev,
446 "Invalid register ID %u\n", reg);
447 return;
448 }
449
450 field = &variant->registers[reg];
451 base = __vc4_hdmi_get_field_base(hdmi, field->reg);
452 if (!base)
453 return;
454
455 writel(value, base + field->offset);
456 }
457 #define HDMI_WRITE(reg, val) vc4_hdmi_write(vc4_hdmi, reg, val)
458
459 #endif /* _VC4_HDMI_REGS_H_ */
460