2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
7 * Copyright 2013-2016 Freescale Semiconductor Inc.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * * Neither the name of the above-listed copyright holders nor the
17 * names of any contributors may be used to endorse or promote products
18 * derived from this software without specific prior written permission.
22 * ALTERNATIVELY, this software may be distributed under the terms of the
23 * GNU General Public License ("GPL") as published by the Free Software
24 * Foundation, either version 2 of that License or (at your option) any
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
31 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
39 #include <fsl_mc_sys.h>
40 #include <fsl_mc_cmd.h>
42 #include <fsl_dpci_cmd.h>
44 int dpci_open(struct fsl_mc_io *mc_io,
49 struct mc_command cmd = { 0 };
53 cmd.header = mc_encode_cmd_header(DPCI_CMDID_OPEN,
56 DPCI_CMD_OPEN(cmd, dpci_id);
58 /* send command to mc*/
59 err = mc_send_command(mc_io, &cmd);
63 /* retrieve response parameters */
64 *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
69 int dpci_close(struct fsl_mc_io *mc_io,
73 struct mc_command cmd = { 0 };
76 cmd.header = mc_encode_cmd_header(DPCI_CMDID_CLOSE,
80 /* send command to mc*/
81 return mc_send_command(mc_io, &cmd);
84 int dpci_create(struct fsl_mc_io *mc_io,
87 const struct dpci_cfg *cfg,
90 struct mc_command cmd = { 0 };
94 cmd.header = mc_encode_cmd_header(DPCI_CMDID_CREATE,
97 DPCI_CMD_CREATE(cmd, cfg);
99 /* send command to mc*/
100 err = mc_send_command(mc_io, &cmd);
104 /* retrieve response parameters */
105 CMD_CREATE_RSP_GET_OBJ_ID_PARAM0(cmd, *obj_id);
110 int dpci_destroy(struct fsl_mc_io *mc_io,
115 struct mc_command cmd = { 0 };
117 /* prepare command */
118 cmd.header = mc_encode_cmd_header(DPCI_CMDID_DESTROY,
121 /* set object id to destroy */
122 CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, object_id);
123 /* send command to mc*/
124 return mc_send_command(mc_io, &cmd);
127 int dpci_enable(struct fsl_mc_io *mc_io,
131 struct mc_command cmd = { 0 };
133 /* prepare command */
134 cmd.header = mc_encode_cmd_header(DPCI_CMDID_ENABLE,
138 /* send command to mc*/
139 return mc_send_command(mc_io, &cmd);
142 int dpci_disable(struct fsl_mc_io *mc_io,
146 struct mc_command cmd = { 0 };
148 /* prepare command */
149 cmd.header = mc_encode_cmd_header(DPCI_CMDID_DISABLE,
153 /* send command to mc*/
154 return mc_send_command(mc_io, &cmd);
157 int dpci_is_enabled(struct fsl_mc_io *mc_io,
162 struct mc_command cmd = { 0 };
164 /* prepare command */
165 cmd.header = mc_encode_cmd_header(DPCI_CMDID_IS_ENABLED, cmd_flags,
168 /* send command to mc*/
169 err = mc_send_command(mc_io, &cmd);
173 /* retrieve response parameters */
174 DPCI_RSP_IS_ENABLED(cmd, *en);
179 int dpci_reset(struct fsl_mc_io *mc_io,
183 struct mc_command cmd = { 0 };
185 /* prepare command */
186 cmd.header = mc_encode_cmd_header(DPCI_CMDID_RESET,
190 /* send command to mc*/
191 return mc_send_command(mc_io, &cmd);
194 int dpci_get_attributes(struct fsl_mc_io *mc_io,
197 struct dpci_attr *attr)
199 struct mc_command cmd = { 0 };
202 /* prepare command */
203 cmd.header = mc_encode_cmd_header(DPCI_CMDID_GET_ATTR,
207 /* send command to mc*/
208 err = mc_send_command(mc_io, &cmd);
212 /* retrieve response parameters */
213 DPCI_RSP_GET_ATTRIBUTES(cmd, attr);
218 int dpci_set_rx_queue(struct fsl_mc_io *mc_io,
222 const struct dpci_rx_queue_cfg *cfg)
224 struct mc_command cmd = { 0 };
226 /* prepare command */
227 cmd.header = mc_encode_cmd_header(DPCI_CMDID_SET_RX_QUEUE,
230 DPCI_CMD_SET_RX_QUEUE(cmd, priority, cfg);
232 /* send command to mc*/
233 return mc_send_command(mc_io, &cmd);
236 int dpci_get_rx_queue(struct fsl_mc_io *mc_io,
240 struct dpci_rx_queue_attr *attr)
242 struct mc_command cmd = { 0 };
245 /* prepare command */
246 cmd.header = mc_encode_cmd_header(DPCI_CMDID_GET_RX_QUEUE,
249 DPCI_CMD_GET_RX_QUEUE(cmd, priority);
251 /* send command to mc*/
252 err = mc_send_command(mc_io, &cmd);
256 /* retrieve response parameters */
257 DPCI_RSP_GET_RX_QUEUE(cmd, attr);
262 int dpci_get_tx_queue(struct fsl_mc_io *mc_io,
266 struct dpci_tx_queue_attr *attr)
268 struct mc_command cmd = { 0 };
271 /* prepare command */
272 cmd.header = mc_encode_cmd_header(DPCI_CMDID_GET_TX_QUEUE,
275 DPCI_CMD_GET_TX_QUEUE(cmd, priority);
277 /* send command to mc*/
278 err = mc_send_command(mc_io, &cmd);
282 /* retrieve response parameters */
283 DPCI_RSP_GET_TX_QUEUE(cmd, attr);
288 int dpci_get_api_version(struct fsl_mc_io *mc_io,
293 struct mc_command cmd = { 0 };
296 cmd.header = mc_encode_cmd_header(DPCI_CMDID_GET_API_VERSION,
300 err = mc_send_command(mc_io, &cmd);
304 DPCI_RSP_GET_API_VERSION(cmd, *major_ver, *minor_ver);