1
2
3
4
5
6
7
8#include <fsl-mc/fsl_mc_sys.h>
9#include <fsl-mc/fsl_mc_cmd.h>
10#include <fsl-mc/fsl_dpbp.h>
11
12int dpbp_open(struct fsl_mc_io *mc_io,
13 uint32_t cmd_flags,
14 int dpbp_id,
15 uint16_t *token)
16{
17 struct mc_command cmd = { 0 };
18 int err;
19
20
21 cmd.header = mc_encode_cmd_header(DPBP_CMDID_OPEN,
22 cmd_flags,
23 0);
24 DPBP_CMD_OPEN(cmd, dpbp_id);
25
26
27 err = mc_send_command(mc_io, &cmd);
28 if (err)
29 return err;
30
31
32 *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
33
34 return err;
35}
36
37int dpbp_close(struct fsl_mc_io *mc_io,
38 uint32_t cmd_flags,
39 uint16_t token)
40{
41 struct mc_command cmd = { 0 };
42
43
44 cmd.header = mc_encode_cmd_header(DPBP_CMDID_CLOSE, cmd_flags,
45 token);
46
47
48 return mc_send_command(mc_io, &cmd);
49}
50
51int dpbp_create(struct fsl_mc_io *mc_io,
52 uint16_t dprc_token,
53 uint32_t cmd_flags,
54 const struct dpbp_cfg *cfg,
55 uint32_t *obj_id)
56{
57 struct mc_command cmd = { 0 };
58 int err;
59
60 (void)(cfg);
61
62
63 cmd.header = mc_encode_cmd_header(DPBP_CMDID_CREATE,
64 cmd_flags,
65 dprc_token);
66
67
68 err = mc_send_command(mc_io, &cmd);
69 if (err)
70 return err;
71
72
73 MC_CMD_READ_OBJ_ID(cmd, *obj_id);
74
75 return 0;
76}
77
78int dpbp_destroy(struct fsl_mc_io *mc_io,
79 uint16_t dprc_token,
80 uint32_t cmd_flags,
81 uint32_t obj_id)
82{
83 struct mc_command cmd = { 0 };
84
85
86 cmd.header = mc_encode_cmd_header(DPBP_CMDID_DESTROY,
87 cmd_flags,
88 dprc_token);
89
90
91 CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, obj_id);
92
93
94 return mc_send_command(mc_io, &cmd);
95}
96
97int dpbp_enable(struct fsl_mc_io *mc_io,
98 uint32_t cmd_flags,
99 uint16_t token)
100{
101 struct mc_command cmd = { 0 };
102
103
104 cmd.header = mc_encode_cmd_header(DPBP_CMDID_ENABLE, cmd_flags,
105 token);
106
107
108 return mc_send_command(mc_io, &cmd);
109}
110
111int dpbp_disable(struct fsl_mc_io *mc_io,
112 uint32_t cmd_flags,
113 uint16_t token)
114{
115 struct mc_command cmd = { 0 };
116
117
118 cmd.header = mc_encode_cmd_header(DPBP_CMDID_DISABLE,
119 cmd_flags,
120 token);
121
122
123 return mc_send_command(mc_io, &cmd);
124}
125
126int dpbp_reset(struct fsl_mc_io *mc_io,
127 uint32_t cmd_flags,
128 uint16_t token)
129{
130 struct mc_command cmd = { 0 };
131
132
133 cmd.header = mc_encode_cmd_header(DPBP_CMDID_RESET,
134 cmd_flags,
135 token);
136
137
138 return mc_send_command(mc_io, &cmd);
139}
140
141int dpbp_get_attributes(struct fsl_mc_io *mc_io,
142 uint32_t cmd_flags,
143 uint16_t token,
144 struct dpbp_attr *attr)
145{
146 struct mc_command cmd = { 0 };
147 int err;
148
149
150 cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_ATTR,
151 cmd_flags,
152 token);
153
154
155 err = mc_send_command(mc_io, &cmd);
156 if (err)
157 return err;
158
159
160 DPBP_RSP_GET_ATTRIBUTES(cmd, attr);
161
162 return 0;
163}
164
165int dpbp_get_api_version(struct fsl_mc_io *mc_io,
166 u32 cmd_flags,
167 u16 *major_ver,
168 u16 *minor_ver)
169{
170 struct mc_command cmd = { 0 };
171 int err;
172
173
174 cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_API_VERSION,
175 cmd_flags, 0);
176
177
178 err = mc_send_command(mc_io, &cmd);
179 if (err)
180 return err;
181
182
183 mc_cmd_read_api_version(&cmd, major_ver, minor_ver);
184
185 return 0;
186}
187