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