1
2
3
4
5
6#include <linux/kernel.h>
7#include <linux/fsl/mc.h>
8
9#include "fsl-mc-private.h"
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28int dpcon_open(struct fsl_mc_io *mc_io,
29 u32 cmd_flags,
30 int dpcon_id,
31 u16 *token)
32{
33 struct fsl_mc_command cmd = { 0 };
34 struct dpcon_cmd_open *dpcon_cmd;
35 int err;
36
37
38 cmd.header = mc_encode_cmd_header(DPCON_CMDID_OPEN,
39 cmd_flags,
40 0);
41 dpcon_cmd = (struct dpcon_cmd_open *)cmd.params;
42 dpcon_cmd->dpcon_id = cpu_to_le32(dpcon_id);
43
44
45 err = mc_send_command(mc_io, &cmd);
46 if (err)
47 return err;
48
49
50 *token = mc_cmd_hdr_read_token(&cmd);
51
52 return 0;
53}
54EXPORT_SYMBOL_GPL(dpcon_open);
55
56
57
58
59
60
61
62
63
64
65
66
67int dpcon_close(struct fsl_mc_io *mc_io,
68 u32 cmd_flags,
69 u16 token)
70{
71 struct fsl_mc_command cmd = { 0 };
72
73
74 cmd.header = mc_encode_cmd_header(DPCON_CMDID_CLOSE,
75 cmd_flags,
76 token);
77
78
79 return mc_send_command(mc_io, &cmd);
80}
81EXPORT_SYMBOL_GPL(dpcon_close);
82
83
84
85
86
87
88
89
90
91int dpcon_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(DPCON_CMDID_ENABLE,
99 cmd_flags,
100 token);
101
102
103 return mc_send_command(mc_io, &cmd);
104}
105EXPORT_SYMBOL_GPL(dpcon_enable);
106
107
108
109
110
111
112
113
114
115int dpcon_disable(struct fsl_mc_io *mc_io,
116 u32 cmd_flags,
117 u16 token)
118{
119 struct fsl_mc_command cmd = { 0 };
120
121
122 cmd.header = mc_encode_cmd_header(DPCON_CMDID_DISABLE,
123 cmd_flags,
124 token);
125
126
127 return mc_send_command(mc_io, &cmd);
128}
129EXPORT_SYMBOL_GPL(dpcon_disable);
130
131
132
133
134
135
136
137
138
139int dpcon_reset(struct fsl_mc_io *mc_io,
140 u32 cmd_flags,
141 u16 token)
142{
143 struct fsl_mc_command cmd = { 0 };
144
145
146 cmd.header = mc_encode_cmd_header(DPCON_CMDID_RESET,
147 cmd_flags, token);
148
149
150 return mc_send_command(mc_io, &cmd);
151}
152EXPORT_SYMBOL_GPL(dpcon_reset);
153
154
155
156
157
158
159
160
161
162
163int dpcon_get_attributes(struct fsl_mc_io *mc_io,
164 u32 cmd_flags,
165 u16 token,
166 struct dpcon_attr *attr)
167{
168 struct fsl_mc_command cmd = { 0 };
169 struct dpcon_rsp_get_attr *dpcon_rsp;
170 int err;
171
172
173 cmd.header = mc_encode_cmd_header(DPCON_CMDID_GET_ATTR,
174 cmd_flags,
175 token);
176
177
178 err = mc_send_command(mc_io, &cmd);
179 if (err)
180 return err;
181
182
183 dpcon_rsp = (struct dpcon_rsp_get_attr *)cmd.params;
184 attr->id = le32_to_cpu(dpcon_rsp->id);
185 attr->qbman_ch_id = le16_to_cpu(dpcon_rsp->qbman_ch_id);
186 attr->num_priorities = dpcon_rsp->num_priorities;
187
188 return 0;
189}
190EXPORT_SYMBOL_GPL(dpcon_get_attributes);
191
192
193
194
195
196
197
198
199
200
201int dpcon_set_notification(struct fsl_mc_io *mc_io,
202 u32 cmd_flags,
203 u16 token,
204 struct dpcon_notification_cfg *cfg)
205{
206 struct fsl_mc_command cmd = { 0 };
207 struct dpcon_cmd_set_notification *dpcon_cmd;
208
209
210 cmd.header = mc_encode_cmd_header(DPCON_CMDID_SET_NOTIFICATION,
211 cmd_flags,
212 token);
213 dpcon_cmd = (struct dpcon_cmd_set_notification *)cmd.params;
214 dpcon_cmd->dpio_id = cpu_to_le32(cfg->dpio_id);
215 dpcon_cmd->priority = cfg->priority;
216 dpcon_cmd->user_ctx = cpu_to_le64(cfg->user_ctx);
217
218
219 return mc_send_command(mc_io, &cmd);
220}
221EXPORT_SYMBOL_GPL(dpcon_set_notification);
222