1 /* Copyright 2013-2016 Freescale Semiconductor Inc.
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are met:
5 * * Redistributions of source code must retain the above copyright
6 * notice, this list of conditions and the following disclaimer.
7 * * Redistributions in binary form must reproduce the above copyright
8 * notice, this list of conditions and the following disclaimer in the
9 * documentation and/or other materials provided with the distribution.
10 * * Neither the name of the above-listed copyright holders nor the
11 * names of any contributors may be used to endorse or promote products
12 * derived from this software without specific prior written permission.
15 * ALTERNATIVELY, this software may be distributed under the terms of the
16 * GNU General Public License ("GPL") as published by the Free Software
17 * Foundation, either version 2 of that License or (at your option) any
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
32 #include <fsl_mc_sys.h>
33 #include <fsl_mc_cmd.h>
34 #include <fsl_dpcon.h>
35 #include <fsl_dpcon_cmd.h>
37 int dpcon_open(struct fsl_mc_io *mc_io,
42 struct mc_command cmd = { 0 };
46 cmd.header = mc_encode_cmd_header(DPCON_CMDID_OPEN,
49 DPCON_CMD_OPEN(cmd, dpcon_id);
51 /* send command to mc*/
52 err = mc_send_command(mc_io, &cmd);
56 /* retrieve response parameters */
57 *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
62 int dpcon_close(struct fsl_mc_io *mc_io,
66 struct mc_command cmd = { 0 };
69 cmd.header = mc_encode_cmd_header(DPCON_CMDID_CLOSE,
73 /* send command to mc*/
74 return mc_send_command(mc_io, &cmd);
77 int dpcon_create(struct fsl_mc_io *mc_io,
80 const struct dpcon_cfg *cfg,
83 struct mc_command cmd = { 0 };
87 cmd.header = mc_encode_cmd_header(DPCON_CMDID_CREATE,
90 DPCON_CMD_CREATE(cmd, cfg);
92 /* send command to mc*/
93 err = mc_send_command(mc_io, &cmd);
97 /* retrieve response parameters */
98 CMD_CREATE_RSP_GET_OBJ_ID_PARAM0(cmd, *obj_id);
103 int dpcon_destroy(struct fsl_mc_io *mc_io,
108 struct mc_command cmd = { 0 };
110 /* prepare command */
111 cmd.header = mc_encode_cmd_header(DPCON_CMDID_DESTROY,
114 /* set object id to destroy */
115 CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, object_id);
116 /* send command to mc*/
117 return mc_send_command(mc_io, &cmd);
120 int dpcon_enable(struct fsl_mc_io *mc_io,
124 struct mc_command cmd = { 0 };
126 /* prepare command */
127 cmd.header = mc_encode_cmd_header(DPCON_CMDID_ENABLE,
131 /* send command to mc*/
132 return mc_send_command(mc_io, &cmd);
135 int dpcon_disable(struct fsl_mc_io *mc_io,
139 struct mc_command cmd = { 0 };
141 /* prepare command */
142 cmd.header = mc_encode_cmd_header(DPCON_CMDID_DISABLE,
146 /* send command to mc*/
147 return mc_send_command(mc_io, &cmd);
150 int dpcon_is_enabled(struct fsl_mc_io *mc_io,
155 struct mc_command cmd = { 0 };
157 /* prepare command */
158 cmd.header = mc_encode_cmd_header(DPCON_CMDID_IS_ENABLED,
162 /* send command to mc*/
163 err = mc_send_command(mc_io, &cmd);
167 /* retrieve response parameters */
168 DPCON_RSP_IS_ENABLED(cmd, *en);
173 int dpcon_reset(struct fsl_mc_io *mc_io,
177 struct mc_command cmd = { 0 };
179 /* prepare command */
180 cmd.header = mc_encode_cmd_header(DPCON_CMDID_RESET,
183 /* send command to mc*/
184 return mc_send_command(mc_io, &cmd);
187 int dpcon_get_attributes(struct fsl_mc_io *mc_io,
190 struct dpcon_attr *attr)
192 struct mc_command cmd = { 0 };
195 /* prepare command */
196 cmd.header = mc_encode_cmd_header(DPCON_CMDID_GET_ATTR,
200 /* send command to mc*/
201 err = mc_send_command(mc_io, &cmd);
205 /* retrieve response parameters */
206 DPCON_RSP_GET_ATTR(cmd, attr);
211 int dpcon_get_api_version(struct fsl_mc_io *mc_io,
216 struct mc_command cmd = { 0 };
219 cmd.header = mc_encode_cmd_header(DPCON_CMDID_GET_API_VERSION,
223 err = mc_send_command(mc_io, &cmd);
227 DPCON_RSP_GET_API_VERSION(cmd, *major_ver, *minor_ver);