Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 2 | /* |
Yogesh Gaur | a6f2a6e | 2018-05-09 10:52:17 +0530 | [diff] [blame^] | 3 | * Copyright 2013-2016 Freescale Semiconductor, Inc. |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 4 | * Copyright 2017 NXP |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef _FSL_DPIO_H |
| 8 | #define _FSL_DPIO_H |
| 9 | |
| 10 | /* DPIO Version */ |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 11 | #define DPIO_VER_MAJOR 4 |
Prabhakar Kushwaha | 53e353f | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 12 | #define DPIO_VER_MINOR 2 |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 13 | |
| 14 | /* Command IDs */ |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 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 |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 20 | |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 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 |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 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 | |
| 30 | /* cmd, param, offset, width, type, arg_name */ |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 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 | |
| 38 | /* cmd, param, offset, width, type, arg_name */ |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 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);\ |
Prabhakar Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 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);\ |
Prabhakar Kushwaha | 53e353f | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 47 | MC_RSP_OP(cmd, 3, 32, 32, uint32_t, attr->qbman_version);\ |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 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; |
Prabhakar Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 55 | |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 56 | /** |
| 57 | * dpio_open() - Open a control session for the specified object |
| 58 | * @mc_io: Pointer to MC portal's I/O object |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 59 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 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 | */ |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 73 | int dpio_open(struct fsl_mc_io *mc_io, |
| 74 | uint32_t cmd_flags, |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 75 | uint32_t dpio_id, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 76 | uint16_t *token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 77 | |
| 78 | /** |
Prabhakar Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 79 | * dpio_close() - Close the control session of the object |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 80 | * @mc_io: Pointer to MC portal's I/O object |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 81 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 82 | * @token: Token of DPIO object |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 83 | * |
| 84 | * Return: '0' on Success; Error code otherwise. |
| 85 | */ |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 86 | int dpio_close(struct fsl_mc_io *mc_io, |
| 87 | uint32_t cmd_flags, |
| 88 | uint16_t token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 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 | |
| 102 | /** |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 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 |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 116 | * @token: Authentication token. |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 117 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 118 | * @cfg: Configuration structure |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 119 | * @obj_id: Returned obj_id; use in subsequent API calls |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 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, |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 137 | uint16_t token, |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 138 | uint32_t cmd_flags, |
| 139 | const struct dpio_cfg *cfg, |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 140 | uint32_t *obj_id); |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 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 |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 145 | * @token: Authentication token. |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 146 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 147 | * @obj_id: Object ID of DPIO |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 148 | * |
| 149 | * Return: '0' on Success; Error code otherwise |
| 150 | */ |
| 151 | int dpio_destroy(struct fsl_mc_io *mc_io, |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 152 | uint16_t token, |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 153 | uint32_t cmd_flags, |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 154 | uint32_t obj_id); |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 155 | |
| 156 | /** |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 157 | * dpio_enable() - Enable the DPIO, allow I/O portal operations. |
| 158 | * @mc_io: Pointer to MC portal's I/O object |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 159 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 160 | * @token: Token of DPIO object |
| 161 | * |
| 162 | * Return: '0' on Success; Error code otherwise |
| 163 | */ |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 164 | int dpio_enable(struct fsl_mc_io *mc_io, |
| 165 | uint32_t cmd_flags, |
| 166 | uint16_t token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 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 |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 171 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 172 | * @token: Token of DPIO object |
| 173 | * |
| 174 | * Return: '0' on Success; Error code otherwise |
| 175 | */ |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 176 | int dpio_disable(struct fsl_mc_io *mc_io, |
| 177 | uint32_t cmd_flags, |
| 178 | uint16_t token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 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 |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 183 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 184 | * @token: Token of DPIO object |
| 185 | * |
| 186 | * Return: '0' on Success; Error code otherwise. |
| 187 | */ |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 188 | int dpio_reset(struct fsl_mc_io *mc_io, |
| 189 | uint32_t cmd_flags, |
| 190 | uint16_t token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 191 | |
| 192 | /** |
| 193 | * struct dpio_attr - Structure representing DPIO attributes |
| 194 | * @id: DPIO object ID |
| 195 | * @version: DPIO version |
Prabhakar Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 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 |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 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' |
Prabhakar Kushwaha | 53e353f | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 202 | * @qbman_version: QBMAN version |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 203 | */ |
| 204 | struct dpio_attr { |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 205 | uint32_t id; |
Prabhakar Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 206 | uint64_t qbman_portal_ce_offset; |
| 207 | uint64_t qbman_portal_ci_offset; |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 208 | uint16_t qbman_portal_id; |
| 209 | enum dpio_channel_mode channel_mode; |
| 210 | uint8_t num_priorities; |
Prabhakar Kushwaha | 53e353f | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 211 | uint32_t qbman_version; |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 212 | }; |
| 213 | |
| 214 | /** |
| 215 | * dpio_get_attributes() - Retrieve DPIO attributes |
| 216 | * @mc_io: Pointer to MC portal's I/O object |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 217 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 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, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 224 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 225 | uint16_t token, |
| 226 | struct dpio_attr *attr); |
| 227 | |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 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 | |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 243 | #endif /* _FSL_DPIO_H */ |