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