2 * Copyright (C) 2013-2015 Freescale Semiconductor
4 * SPDX-License-Identifier: GPL-2.0+
7 #include <fsl-mc/fsl_mc_sys.h>
8 #include <fsl-mc/fsl_mc_cmd.h>
9 #include <fsl-mc/fsl_dpio.h>
11 int dpio_open(struct fsl_mc_io *mc_io, int dpio_id, uint16_t *token)
13 struct mc_command cmd = { 0 };
17 cmd.header = mc_encode_cmd_header(DPIO_CMDID_OPEN,
19 DPIO_CMD_OPEN(cmd, dpio_id);
21 /* send command to mc*/
22 err = mc_send_command(mc_io, &cmd);
26 /* retrieve response parameters */
27 *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
32 int dpio_close(struct fsl_mc_io *mc_io, uint16_t token)
34 struct mc_command cmd = { 0 };
37 cmd.header = mc_encode_cmd_header(DPIO_CMDID_CLOSE,
38 MC_CMD_PRI_HIGH, token);
40 /* send command to mc*/
41 return mc_send_command(mc_io, &cmd);
44 int dpio_enable(struct fsl_mc_io *mc_io, uint16_t token)
46 struct mc_command cmd = { 0 };
49 cmd.header = mc_encode_cmd_header(DPIO_CMDID_ENABLE,
50 MC_CMD_PRI_LOW, token);
52 /* send command to mc*/
53 return mc_send_command(mc_io, &cmd);
56 int dpio_disable(struct fsl_mc_io *mc_io, uint16_t token)
58 struct mc_command cmd = { 0 };
61 cmd.header = mc_encode_cmd_header(DPIO_CMDID_DISABLE,
65 /* send command to mc*/
66 return mc_send_command(mc_io, &cmd);
69 int dpio_reset(struct fsl_mc_io *mc_io, uint16_t token)
71 struct mc_command cmd = { 0 };
74 cmd.header = mc_encode_cmd_header(DPIO_CMDID_RESET,
75 MC_CMD_PRI_LOW, token);
77 /* send command to mc*/
78 return mc_send_command(mc_io, &cmd);
81 int dpio_get_attributes(struct fsl_mc_io *mc_io,
83 struct dpio_attr *attr)
85 struct mc_command cmd = { 0 };
89 cmd.header = mc_encode_cmd_header(DPIO_CMDID_GET_ATTR,
93 /* send command to mc*/
94 err = mc_send_command(mc_io, &cmd);
98 /* retrieve response parameters */
99 DPIO_RSP_GET_ATTR(cmd, attr);