]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
a2a55e51 | 2 | /* |
a6f2a6ea | 3 | * Copyright 2013-2016 Freescale Semiconductor, Inc. |
2557c5a9 | 4 | * Copyright 2017 NXP |
a2a55e51 PK |
5 | */ |
6 | ||
7 | #ifndef _FSL_DPIO_H | |
8 | #define _FSL_DPIO_H | |
9 | ||
10 | /* DPIO Version */ | |
2557c5a9 | 11 | #define DPIO_VER_MAJOR 4 |
53e353fc | 12 | #define DPIO_VER_MINOR 2 |
a2a55e51 PK |
13 | |
14 | /* Command IDs */ | |
2557c5a9 YG |
15 | #define DPIO_CMDID_CLOSE 0x8001 |
16 | #define DPIO_CMDID_OPEN 0x8031 | |
17 | #define DPIO_CMDID_CREATE 0x9031 | |
18 | #define DPIO_CMDID_DESTROY 0x9831 | |
19 | #define DPIO_CMDID_GET_API_VERSION 0xa031 | |
a2a55e51 | 20 | |
2557c5a9 YG |
21 | #define DPIO_CMDID_ENABLE 0x0021 |
22 | #define DPIO_CMDID_DISABLE 0x0031 | |
23 | #define DPIO_CMDID_GET_ATTR 0x0041 | |
24 | #define DPIO_CMDID_RESET 0x0051 | |
a2a55e51 PK |
25 | |
26 | /* cmd, param, offset, width, type, arg_name */ | |
27 | #define DPIO_CMD_OPEN(cmd, dpio_id) \ | |
28 | MC_CMD_OP(cmd, 0, 0, 32, int, dpio_id) | |
29 | ||
1ebbe4fc PK |
30 | /* cmd, param, offset, width, type, arg_name */ |
31 | #define DPIO_CMD_CREATE(cmd, cfg) \ | |
32 | do { \ | |
33 | MC_CMD_OP(cmd, 0, 16, 2, enum dpio_channel_mode, \ | |
34 | cfg->channel_mode);\ | |
35 | MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->num_priorities);\ | |
36 | } while (0) | |
37 | ||
a2a55e51 PK |
38 | /* cmd, param, offset, width, type, arg_name */ |
39 | #define DPIO_RSP_GET_ATTR(cmd, attr) \ | |
40 | do { \ | |
41 | MC_RSP_OP(cmd, 0, 0, 32, int, attr->id);\ | |
42 | MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->qbman_portal_id);\ | |
43 | MC_RSP_OP(cmd, 0, 48, 8, uint8_t, attr->num_priorities);\ | |
44 | MC_RSP_OP(cmd, 0, 56, 4, enum dpio_channel_mode, attr->channel_mode);\ | |
1f1c25c7 PK |
45 | MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->qbman_portal_ce_offset);\ |
46 | MC_RSP_OP(cmd, 2, 0, 64, uint64_t, attr->qbman_portal_ci_offset);\ | |
53e353fc | 47 | MC_RSP_OP(cmd, 3, 32, 32, uint32_t, attr->qbman_version);\ |
a2a55e51 PK |
48 | } while (0) |
49 | ||
50 | /* Data Path I/O Portal API | |
51 | * Contains initialization APIs and runtime control APIs for DPIO | |
52 | */ | |
53 | ||
54 | struct fsl_mc_io; | |
1f1c25c7 | 55 | |
a2a55e51 PK |
56 | /** |
57 | * dpio_open() - Open a control session for the specified object | |
58 | * @mc_io: Pointer to MC portal's I/O object | |
87457d11 | 59 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
a2a55e51 PK |
60 | * @dpio_id: DPIO unique ID |
61 | * @token: Returned token; use in subsequent API calls | |
62 | * | |
63 | * This function can be used to open a control session for an | |
64 | * already created object; an object may have been declared in | |
65 | * the DPL or by calling the dpio_create() function. | |
66 | * This function returns a unique authentication token, | |
67 | * associated with the specific object ID and the specific MC | |
68 | * portal; this token must be used in all subsequent commands for | |
69 | * this specific object. | |
70 | * | |
71 | * Return: '0' on Success; Error code otherwise. | |
72 | */ | |
87457d11 PK |
73 | int dpio_open(struct fsl_mc_io *mc_io, |
74 | uint32_t cmd_flags, | |
2557c5a9 | 75 | uint32_t dpio_id, |
87457d11 | 76 | uint16_t *token); |
a2a55e51 PK |
77 | |
78 | /** | |
1f1c25c7 | 79 | * dpio_close() - Close the control session of the object |
a2a55e51 | 80 | * @mc_io: Pointer to MC portal's I/O object |
87457d11 | 81 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
1f1c25c7 | 82 | * @token: Token of DPIO object |
a2a55e51 PK |
83 | * |
84 | * Return: '0' on Success; Error code otherwise. | |
85 | */ | |
87457d11 PK |
86 | int dpio_close(struct fsl_mc_io *mc_io, |
87 | uint32_t cmd_flags, | |
88 | uint16_t token); | |
a2a55e51 PK |
89 | |
90 | /** | |
91 | * enum dpio_channel_mode - DPIO notification channel mode | |
92 | * @DPIO_NO_CHANNEL: No support for notification channel | |
93 | * @DPIO_LOCAL_CHANNEL: Notifications on data availability can be received by a | |
94 | * dedicated channel in the DPIO; user should point the queue's | |
95 | * destination in the relevant interface to this DPIO | |
96 | */ | |
97 | enum dpio_channel_mode { | |
98 | DPIO_NO_CHANNEL = 0, | |
99 | DPIO_LOCAL_CHANNEL = 1, | |
100 | }; | |
101 | ||
1ebbe4fc PK |
102 | /** |
103 | * struct dpio_cfg - Structure representing DPIO configuration | |
104 | * @channel_mode: Notification channel mode | |
105 | * @num_priorities: Number of priorities for the notification channel (1-8); | |
106 | * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL' | |
107 | */ | |
108 | struct dpio_cfg { | |
109 | enum dpio_channel_mode channel_mode; | |
110 | uint8_t num_priorities; | |
111 | }; | |
112 | ||
113 | /** | |
114 | * dpio_create() - Create the DPIO object. | |
115 | * @mc_io: Pointer to MC portal's I/O object | |
2557c5a9 | 116 | * @token: Authentication token. |
1ebbe4fc PK |
117 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
118 | * @cfg: Configuration structure | |
2557c5a9 | 119 | * @obj_id: Returned obj_id; use in subsequent API calls |
1ebbe4fc PK |
120 | * |
121 | * Create the DPIO object, allocate required resources and | |
122 | * perform required initialization. | |
123 | * | |
124 | * The object can be created either by declaring it in the | |
125 | * DPL file, or by calling this function. | |
126 | * | |
127 | * This function returns a unique authentication token, | |
128 | * associated with the specific object ID and the specific MC | |
129 | * portal; this token must be used in all subsequent calls to | |
130 | * this specific object. For objects that are created using the | |
131 | * DPL file, call dpio_open() function to get an authentication | |
132 | * token first. | |
133 | * | |
134 | * Return: '0' on Success; Error code otherwise. | |
135 | */ | |
136 | int dpio_create(struct fsl_mc_io *mc_io, | |
2557c5a9 | 137 | uint16_t token, |
1ebbe4fc PK |
138 | uint32_t cmd_flags, |
139 | const struct dpio_cfg *cfg, | |
2557c5a9 | 140 | uint32_t *obj_id); |
1ebbe4fc PK |
141 | |
142 | /** | |
143 | * dpio_destroy() - Destroy the DPIO object and release all its resources. | |
144 | * @mc_io: Pointer to MC portal's I/O object | |
2557c5a9 | 145 | * @token: Authentication token. |
1ebbe4fc | 146 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
2557c5a9 | 147 | * @obj_id: Object ID of DPIO |
1ebbe4fc PK |
148 | * |
149 | * Return: '0' on Success; Error code otherwise | |
150 | */ | |
151 | int dpio_destroy(struct fsl_mc_io *mc_io, | |
2557c5a9 | 152 | uint16_t token, |
1ebbe4fc | 153 | uint32_t cmd_flags, |
2557c5a9 | 154 | uint32_t obj_id); |
1ebbe4fc | 155 | |
a2a55e51 PK |
156 | /** |
157 | * dpio_enable() - Enable the DPIO, allow I/O portal operations. | |
158 | * @mc_io: Pointer to MC portal's I/O object | |
87457d11 | 159 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
a2a55e51 PK |
160 | * @token: Token of DPIO object |
161 | * | |
162 | * Return: '0' on Success; Error code otherwise | |
163 | */ | |
87457d11 PK |
164 | int dpio_enable(struct fsl_mc_io *mc_io, |
165 | uint32_t cmd_flags, | |
166 | uint16_t token); | |
a2a55e51 PK |
167 | |
168 | /** | |
169 | * dpio_disable() - Disable the DPIO, stop any I/O portal operation. | |
170 | * @mc_io: Pointer to MC portal's I/O object | |
87457d11 | 171 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
a2a55e51 PK |
172 | * @token: Token of DPIO object |
173 | * | |
174 | * Return: '0' on Success; Error code otherwise | |
175 | */ | |
87457d11 PK |
176 | int dpio_disable(struct fsl_mc_io *mc_io, |
177 | uint32_t cmd_flags, | |
178 | uint16_t token); | |
a2a55e51 PK |
179 | |
180 | /** | |
181 | * dpio_reset() - Reset the DPIO, returns the object to initial state. | |
182 | * @mc_io: Pointer to MC portal's I/O object | |
87457d11 | 183 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
a2a55e51 PK |
184 | * @token: Token of DPIO object |
185 | * | |
186 | * Return: '0' on Success; Error code otherwise. | |
187 | */ | |
87457d11 PK |
188 | int dpio_reset(struct fsl_mc_io *mc_io, |
189 | uint32_t cmd_flags, | |
190 | uint16_t token); | |
a2a55e51 PK |
191 | |
192 | /** | |
193 | * struct dpio_attr - Structure representing DPIO attributes | |
194 | * @id: DPIO object ID | |
195 | * @version: DPIO version | |
1f1c25c7 PK |
196 | * @qbman_portal_ce_offset: offset of the software portal cache-enabled area |
197 | * @qbman_portal_ci_offset: offset of the software portal cache-inhibited area | |
a2a55e51 PK |
198 | * @qbman_portal_id: Software portal ID |
199 | * @channel_mode: Notification channel mode | |
200 | * @num_priorities: Number of priorities for the notification channel (1-8); | |
201 | * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL' | |
53e353fc | 202 | * @qbman_version: QBMAN version |
a2a55e51 PK |
203 | */ |
204 | struct dpio_attr { | |
2557c5a9 | 205 | uint32_t id; |
1f1c25c7 PK |
206 | uint64_t qbman_portal_ce_offset; |
207 | uint64_t qbman_portal_ci_offset; | |
a2a55e51 PK |
208 | uint16_t qbman_portal_id; |
209 | enum dpio_channel_mode channel_mode; | |
210 | uint8_t num_priorities; | |
53e353fc | 211 | uint32_t qbman_version; |
a2a55e51 PK |
212 | }; |
213 | ||
214 | /** | |
215 | * dpio_get_attributes() - Retrieve DPIO attributes | |
216 | * @mc_io: Pointer to MC portal's I/O object | |
87457d11 | 217 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
a2a55e51 PK |
218 | * @token: Token of DPIO object |
219 | * @attr: Returned object's attributes | |
220 | * | |
221 | * Return: '0' on Success; Error code otherwise | |
222 | */ | |
223 | int dpio_get_attributes(struct fsl_mc_io *mc_io, | |
87457d11 | 224 | uint32_t cmd_flags, |
a2a55e51 PK |
225 | uint16_t token, |
226 | struct dpio_attr *attr); | |
227 | ||
2557c5a9 YG |
228 | /** |
229 | * dpio_get_api_version - Retrieve DPIO Major and Minor version info. | |
230 | * | |
231 | * @mc_io: Pointer to MC portal's I/O object | |
232 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' | |
233 | * @major_ver: DPIO major version | |
234 | * @minor_ver: DPIO minor version | |
235 | * | |
236 | * Return: '0' on Success; Error code otherwise. | |
237 | */ | |
238 | int dpio_get_api_version(struct fsl_mc_io *mc_io, | |
239 | u32 cmd_flags, | |
240 | u16 *major_ver, | |
241 | u16 *minor_ver); | |
242 | ||
a2a55e51 | 243 | #endif /* _FSL_DPIO_H */ |