This source file includes following definitions.
- dpio_open
- dpio_close
- dpio_enable
- dpio_disable
- dpio_get_attributes
- dpio_set_stashing_destination
- dpio_get_api_version
- dpio_reset
1
2
3
4
5
6
7 #include <linux/kernel.h>
8 #include <linux/fsl/mc.h>
9
10 #include "dpio.h"
11 #include "dpio-cmd.h"
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 int dpio_open(struct fsl_mc_io *mc_io,
36 u32 cmd_flags,
37 int dpio_id,
38 u16 *token)
39 {
40 struct fsl_mc_command cmd = { 0 };
41 struct dpio_cmd_open *dpio_cmd;
42 int err;
43
44
45 cmd.header = mc_encode_cmd_header(DPIO_CMDID_OPEN,
46 cmd_flags,
47 0);
48 dpio_cmd = (struct dpio_cmd_open *)cmd.params;
49 dpio_cmd->dpio_id = cpu_to_le32(dpio_id);
50
51 err = mc_send_command(mc_io, &cmd);
52 if (err)
53 return err;
54
55
56 *token = mc_cmd_hdr_read_token(&cmd);
57
58 return 0;
59 }
60
61
62
63
64
65
66
67
68
69 int dpio_close(struct fsl_mc_io *mc_io,
70 u32 cmd_flags,
71 u16 token)
72 {
73 struct fsl_mc_command cmd = { 0 };
74
75
76 cmd.header = mc_encode_cmd_header(DPIO_CMDID_CLOSE,
77 cmd_flags,
78 token);
79
80 return mc_send_command(mc_io, &cmd);
81 }
82
83
84
85
86
87
88
89
90
91 int dpio_enable(struct fsl_mc_io *mc_io,
92 u32 cmd_flags,
93 u16 token)
94 {
95 struct fsl_mc_command cmd = { 0 };
96
97
98 cmd.header = mc_encode_cmd_header(DPIO_CMDID_ENABLE,
99 cmd_flags,
100 token);
101
102 return mc_send_command(mc_io, &cmd);
103 }
104
105
106
107
108
109
110
111
112
113 int dpio_disable(struct fsl_mc_io *mc_io,
114 u32 cmd_flags,
115 u16 token)
116 {
117 struct fsl_mc_command cmd = { 0 };
118
119
120 cmd.header = mc_encode_cmd_header(DPIO_CMDID_DISABLE,
121 cmd_flags,
122 token);
123
124 return mc_send_command(mc_io, &cmd);
125 }
126
127
128
129
130
131
132
133
134
135
136 int dpio_get_attributes(struct fsl_mc_io *mc_io,
137 u32 cmd_flags,
138 u16 token,
139 struct dpio_attr *attr)
140 {
141 struct fsl_mc_command cmd = { 0 };
142 struct dpio_rsp_get_attr *dpio_rsp;
143 int err;
144
145
146 cmd.header = mc_encode_cmd_header(DPIO_CMDID_GET_ATTR,
147 cmd_flags,
148 token);
149
150 err = mc_send_command(mc_io, &cmd);
151 if (err)
152 return err;
153
154
155 dpio_rsp = (struct dpio_rsp_get_attr *)cmd.params;
156 attr->id = le32_to_cpu(dpio_rsp->id);
157 attr->qbman_portal_id = le16_to_cpu(dpio_rsp->qbman_portal_id);
158 attr->num_priorities = dpio_rsp->num_priorities;
159 attr->channel_mode = dpio_rsp->channel_mode & DPIO_CHANNEL_MODE_MASK;
160 attr->qbman_portal_ce_offset =
161 le64_to_cpu(dpio_rsp->qbman_portal_ce_addr);
162 attr->qbman_portal_ci_offset =
163 le64_to_cpu(dpio_rsp->qbman_portal_ci_addr);
164 attr->qbman_version = le32_to_cpu(dpio_rsp->qbman_version);
165
166 return 0;
167 }
168
169 int dpio_set_stashing_destination(struct fsl_mc_io *mc_io,
170 u32 cmd_flags,
171 u16 token,
172 u8 sdest)
173 {
174 struct fsl_mc_command cmd = { 0 };
175 struct dpio_stashing_dest *dpio_cmd;
176
177 cmd.header = mc_encode_cmd_header(DPIO_CMDID_SET_STASHING_DEST,
178 cmd_flags, token);
179 dpio_cmd = (struct dpio_stashing_dest *)cmd.params;
180 dpio_cmd->sdest = sdest;
181
182 return mc_send_command(mc_io, &cmd);
183 }
184
185
186
187
188
189
190
191
192
193
194 int dpio_get_api_version(struct fsl_mc_io *mc_io,
195 u32 cmd_flags,
196 u16 *major_ver,
197 u16 *minor_ver)
198 {
199 struct fsl_mc_command cmd = { 0 };
200 int err;
201
202
203 cmd.header = mc_encode_cmd_header(DPIO_CMDID_GET_API_VERSION,
204 cmd_flags, 0);
205
206 err = mc_send_command(mc_io, &cmd);
207 if (err)
208 return err;
209
210
211 mc_cmd_read_api_version(&cmd, major_ver, minor_ver);
212
213 return 0;
214 }
215
216
217
218
219
220
221
222
223
224 int dpio_reset(struct fsl_mc_io *mc_io,
225 u32 cmd_flags,
226 u16 token)
227 {
228 struct fsl_mc_command cmd = { 0 };
229
230
231 cmd.header = mc_encode_cmd_header(DPIO_CMDID_RESET,
232 cmd_flags,
233 token);
234
235
236 return mc_send_command(mc_io, &cmd);
237 }