2 * Copyright (C) 2013-2016 Freescale Semiconductor
5 * SPDX-License-Identifier: GPL-2.0+
8 #include <fsl-mc/fsl_mc_sys.h>
9 #include <fsl-mc/fsl_mc_cmd.h>
10 #include <fsl-mc/fsl_dpio.h>
12 int dpio_open(struct fsl_mc_io *mc_io,
17 struct mc_command cmd = { 0 };
21 cmd.header = mc_encode_cmd_header(DPIO_CMDID_OPEN,
24 DPIO_CMD_OPEN(cmd, dpio_id);
26 /* send command to mc*/
27 err = mc_send_command(mc_io, &cmd);
31 /* retrieve response parameters */
32 *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
37 int dpio_close(struct fsl_mc_io *mc_io,
41 struct mc_command cmd = { 0 };
44 cmd.header = mc_encode_cmd_header(DPIO_CMDID_CLOSE,
48 /* send command to mc*/
49 return mc_send_command(mc_io, &cmd);
52 int dpio_create(struct fsl_mc_io *mc_io,
55 const struct dpio_cfg *cfg,
58 struct mc_command cmd = { 0 };
62 cmd.header = mc_encode_cmd_header(DPIO_CMDID_CREATE,
65 DPIO_CMD_CREATE(cmd, cfg);
67 /* send command to mc*/
68 err = mc_send_command(mc_io, &cmd);
72 /* retrieve response parameters */
73 MC_CMD_READ_OBJ_ID(cmd, *obj_id);
78 int dpio_destroy(struct fsl_mc_io *mc_io,
83 struct mc_command cmd = { 0 };
86 cmd.header = mc_encode_cmd_header(DPIO_CMDID_DESTROY,
90 /* set object id to destroy */
91 CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, obj_id);
93 /* send command to mc*/
94 return mc_send_command(mc_io, &cmd);
97 int dpio_enable(struct fsl_mc_io *mc_io,
101 struct mc_command cmd = { 0 };
103 /* prepare command */
104 cmd.header = mc_encode_cmd_header(DPIO_CMDID_ENABLE,
108 /* send command to mc*/
109 return mc_send_command(mc_io, &cmd);
112 int dpio_disable(struct fsl_mc_io *mc_io,
116 struct mc_command cmd = { 0 };
118 /* prepare command */
119 cmd.header = mc_encode_cmd_header(DPIO_CMDID_DISABLE,
123 /* send command to mc*/
124 return mc_send_command(mc_io, &cmd);
127 int dpio_reset(struct fsl_mc_io *mc_io,
131 struct mc_command cmd = { 0 };
133 /* prepare command */
134 cmd.header = mc_encode_cmd_header(DPIO_CMDID_RESET,
138 /* send command to mc*/
139 return mc_send_command(mc_io, &cmd);
142 int dpio_get_attributes(struct fsl_mc_io *mc_io,
145 struct dpio_attr *attr)
147 struct mc_command cmd = { 0 };
150 /* prepare command */
151 cmd.header = mc_encode_cmd_header(DPIO_CMDID_GET_ATTR,
155 /* send command to mc*/
156 err = mc_send_command(mc_io, &cmd);
160 /* retrieve response parameters */
161 DPIO_RSP_GET_ATTR(cmd, attr);
166 int dpio_get_api_version(struct fsl_mc_io *mc_io,
171 struct mc_command cmd = { 0 };
174 /* prepare command */
175 cmd.header = mc_encode_cmd_header(DPIO_CMDID_GET_API_VERSION,
178 /* send command to mc */
179 err = mc_send_command(mc_io, &cmd);
183 /* retrieve response parameters */
184 mc_cmd_read_api_version(&cmd, major_ver, minor_ver);