This source file includes following definitions.
- dprtc_open
- dprtc_close
- dprtc_set_irq_enable
- dprtc_get_irq_enable
- dprtc_set_irq_mask
- dprtc_get_irq_mask
- dprtc_get_irq_status
- dprtc_clear_irq_status
1
2
3
4
5
6
7 #include <linux/fsl/mc.h>
8
9 #include "dprtc.h"
10 #include "dprtc-cmd.h"
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 int dprtc_open(struct fsl_mc_io *mc_io,
30 u32 cmd_flags,
31 int dprtc_id,
32 u16 *token)
33 {
34 struct dprtc_cmd_open *cmd_params;
35 struct fsl_mc_command cmd = { 0 };
36 int err;
37
38 cmd.header = mc_encode_cmd_header(DPRTC_CMDID_OPEN,
39 cmd_flags,
40 0);
41 cmd_params = (struct dprtc_cmd_open *)cmd.params;
42 cmd_params->dprtc_id = cpu_to_le32(dprtc_id);
43
44 err = mc_send_command(mc_io, &cmd);
45 if (err)
46 return err;
47
48 *token = mc_cmd_hdr_read_token(&cmd);
49
50 return 0;
51 }
52
53
54
55
56
57
58
59
60
61
62
63
64 int dprtc_close(struct fsl_mc_io *mc_io,
65 u32 cmd_flags,
66 u16 token)
67 {
68 struct fsl_mc_command cmd = { 0 };
69
70 cmd.header = mc_encode_cmd_header(DPRTC_CMDID_CLOSE, cmd_flags,
71 token);
72
73 return mc_send_command(mc_io, &cmd);
74 }
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91 int dprtc_set_irq_enable(struct fsl_mc_io *mc_io,
92 u32 cmd_flags,
93 u16 token,
94 u8 irq_index,
95 u8 en)
96 {
97 struct dprtc_cmd_set_irq_enable *cmd_params;
98 struct fsl_mc_command cmd = { 0 };
99
100 cmd.header = mc_encode_cmd_header(DPRTC_CMDID_SET_IRQ_ENABLE,
101 cmd_flags,
102 token);
103 cmd_params = (struct dprtc_cmd_set_irq_enable *)cmd.params;
104 cmd_params->irq_index = irq_index;
105 cmd_params->en = en;
106
107 return mc_send_command(mc_io, &cmd);
108 }
109
110
111
112
113
114
115
116
117
118
119
120 int dprtc_get_irq_enable(struct fsl_mc_io *mc_io,
121 u32 cmd_flags,
122 u16 token,
123 u8 irq_index,
124 u8 *en)
125 {
126 struct dprtc_rsp_get_irq_enable *rsp_params;
127 struct dprtc_cmd_get_irq *cmd_params;
128 struct fsl_mc_command cmd = { 0 };
129 int err;
130
131 cmd.header = mc_encode_cmd_header(DPRTC_CMDID_GET_IRQ_ENABLE,
132 cmd_flags,
133 token);
134 cmd_params = (struct dprtc_cmd_get_irq *)cmd.params;
135 cmd_params->irq_index = irq_index;
136
137 err = mc_send_command(mc_io, &cmd);
138 if (err)
139 return err;
140
141 rsp_params = (struct dprtc_rsp_get_irq_enable *)cmd.params;
142 *en = rsp_params->en;
143
144 return 0;
145 }
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163 int dprtc_set_irq_mask(struct fsl_mc_io *mc_io,
164 u32 cmd_flags,
165 u16 token,
166 u8 irq_index,
167 u32 mask)
168 {
169 struct dprtc_cmd_set_irq_mask *cmd_params;
170 struct fsl_mc_command cmd = { 0 };
171
172 cmd.header = mc_encode_cmd_header(DPRTC_CMDID_SET_IRQ_MASK,
173 cmd_flags,
174 token);
175 cmd_params = (struct dprtc_cmd_set_irq_mask *)cmd.params;
176 cmd_params->mask = cpu_to_le32(mask);
177 cmd_params->irq_index = irq_index;
178
179 return mc_send_command(mc_io, &cmd);
180 }
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195 int dprtc_get_irq_mask(struct fsl_mc_io *mc_io,
196 u32 cmd_flags,
197 u16 token,
198 u8 irq_index,
199 u32 *mask)
200 {
201 struct dprtc_rsp_get_irq_mask *rsp_params;
202 struct dprtc_cmd_get_irq *cmd_params;
203 struct fsl_mc_command cmd = { 0 };
204 int err;
205
206 cmd.header = mc_encode_cmd_header(DPRTC_CMDID_GET_IRQ_MASK,
207 cmd_flags,
208 token);
209 cmd_params = (struct dprtc_cmd_get_irq *)cmd.params;
210 cmd_params->irq_index = irq_index;
211
212 err = mc_send_command(mc_io, &cmd);
213 if (err)
214 return err;
215
216 rsp_params = (struct dprtc_rsp_get_irq_mask *)cmd.params;
217 *mask = le32_to_cpu(rsp_params->mask);
218
219 return 0;
220 }
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235 int dprtc_get_irq_status(struct fsl_mc_io *mc_io,
236 u32 cmd_flags,
237 u16 token,
238 u8 irq_index,
239 u32 *status)
240 {
241 struct dprtc_cmd_get_irq_status *cmd_params;
242 struct dprtc_rsp_get_irq_status *rsp_params;
243 struct fsl_mc_command cmd = { 0 };
244 int err;
245
246 cmd.header = mc_encode_cmd_header(DPRTC_CMDID_GET_IRQ_STATUS,
247 cmd_flags,
248 token);
249 cmd_params = (struct dprtc_cmd_get_irq_status *)cmd.params;
250 cmd_params->status = cpu_to_le32(*status);
251 cmd_params->irq_index = irq_index;
252
253 err = mc_send_command(mc_io, &cmd);
254 if (err)
255 return err;
256
257 rsp_params = (struct dprtc_rsp_get_irq_status *)cmd.params;
258 *status = le32_to_cpu(rsp_params->status);
259
260 return 0;
261 }
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276 int dprtc_clear_irq_status(struct fsl_mc_io *mc_io,
277 u32 cmd_flags,
278 u16 token,
279 u8 irq_index,
280 u32 status)
281 {
282 struct dprtc_cmd_clear_irq_status *cmd_params;
283 struct fsl_mc_command cmd = { 0 };
284
285 cmd.header = mc_encode_cmd_header(DPRTC_CMDID_CLEAR_IRQ_STATUS,
286 cmd_flags,
287 token);
288 cmd_params = (struct dprtc_cmd_clear_irq_status *)cmd.params;
289 cmd_params->irq_index = irq_index;
290 cmd_params->status = cpu_to_le32(status);
291
292 return mc_send_command(mc_io, &cmd);
293 }