Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013-2015 Freescale Semiconductor |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #ifndef _FSL_DPIO_H |
| 8 | #define _FSL_DPIO_H |
| 9 | |
| 10 | /* DPIO Version */ |
Prabhakar Kushwaha | fd5d127 | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 11 | #define DPIO_VER_MAJOR 3 |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 12 | #define DPIO_VER_MINOR 1 |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 13 | |
| 14 | /* Command IDs */ |
| 15 | #define DPIO_CMDID_CLOSE 0x800 |
| 16 | #define DPIO_CMDID_OPEN 0x803 |
Prabhakar Kushwaha | cf0c8cf | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 17 | #define DPIO_CMDID_CREATE 0x903 |
| 18 | #define DPIO_CMDID_DESTROY 0x900 |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 19 | |
| 20 | #define DPIO_CMDID_ENABLE 0x002 |
| 21 | #define DPIO_CMDID_DISABLE 0x003 |
| 22 | #define DPIO_CMDID_GET_ATTR 0x004 |
| 23 | #define DPIO_CMDID_RESET 0x005 |
| 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 | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 46 | MC_RSP_OP(cmd, 3, 0, 16, uint16_t, attr->version.major);\ |
| 47 | MC_RSP_OP(cmd, 3, 16, 16, uint16_t, attr->version.minor);\ |
| 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 | fd5d127 | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 55 | |
Prabhakar Kushwaha | cfd9fbf | 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 | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 59 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | cfd9fbf | 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 | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 73 | int dpio_open(struct fsl_mc_io *mc_io, |
| 74 | uint32_t cmd_flags, |
| 75 | int dpio_id, |
| 76 | uint16_t *token); |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 77 | |
| 78 | /** |
Prabhakar Kushwaha | fd5d127 | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 79 | * dpio_close() - Close the control session of the object |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 80 | * @mc_io: Pointer to MC portal's I/O object |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 81 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | fd5d127 | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 82 | * @token: Token of DPIO object |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 83 | * |
| 84 | * Return: '0' on Success; Error code otherwise. |
| 85 | */ |
Prabhakar Kushwaha | 9564df6 | 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 | cfd9fbf | 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 | cf0c8cf | 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 |
| 116 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 117 | * @cfg: Configuration structure |
| 118 | * @token: Returned token; use in subsequent API calls |
| 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, |
| 136 | uint32_t cmd_flags, |
| 137 | const struct dpio_cfg *cfg, |
| 138 | uint16_t *token); |
| 139 | |
| 140 | /** |
| 141 | * dpio_destroy() - Destroy the DPIO object and release all its resources. |
| 142 | * @mc_io: Pointer to MC portal's I/O object |
| 143 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 144 | * @token: Token of DPIO object |
| 145 | * |
| 146 | * Return: '0' on Success; Error code otherwise |
| 147 | */ |
| 148 | int dpio_destroy(struct fsl_mc_io *mc_io, |
| 149 | uint32_t cmd_flags, |
| 150 | uint16_t token); |
| 151 | |
| 152 | /** |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 153 | * dpio_enable() - Enable the DPIO, allow I/O portal operations. |
| 154 | * @mc_io: Pointer to MC portal's I/O object |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 155 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 156 | * @token: Token of DPIO object |
| 157 | * |
| 158 | * Return: '0' on Success; Error code otherwise |
| 159 | */ |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 160 | int dpio_enable(struct fsl_mc_io *mc_io, |
| 161 | uint32_t cmd_flags, |
| 162 | uint16_t token); |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 163 | |
| 164 | /** |
| 165 | * dpio_disable() - Disable the DPIO, stop any I/O portal operation. |
| 166 | * @mc_io: Pointer to MC portal's I/O object |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 167 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 168 | * @token: Token of DPIO object |
| 169 | * |
| 170 | * Return: '0' on Success; Error code otherwise |
| 171 | */ |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 172 | int dpio_disable(struct fsl_mc_io *mc_io, |
| 173 | uint32_t cmd_flags, |
| 174 | uint16_t token); |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 175 | |
| 176 | /** |
| 177 | * dpio_reset() - Reset the DPIO, returns the object to initial state. |
| 178 | * @mc_io: Pointer to MC portal's I/O object |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 179 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 180 | * @token: Token of DPIO object |
| 181 | * |
| 182 | * Return: '0' on Success; Error code otherwise. |
| 183 | */ |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 184 | int dpio_reset(struct fsl_mc_io *mc_io, |
| 185 | uint32_t cmd_flags, |
| 186 | uint16_t token); |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 187 | |
| 188 | /** |
| 189 | * struct dpio_attr - Structure representing DPIO attributes |
| 190 | * @id: DPIO object ID |
| 191 | * @version: DPIO version |
Prabhakar Kushwaha | fd5d127 | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 192 | * @qbman_portal_ce_offset: offset of the software portal cache-enabled area |
| 193 | * @qbman_portal_ci_offset: offset of the software portal cache-inhibited area |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 194 | * @qbman_portal_id: Software portal ID |
| 195 | * @channel_mode: Notification channel mode |
| 196 | * @num_priorities: Number of priorities for the notification channel (1-8); |
| 197 | * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL' |
| 198 | */ |
| 199 | struct dpio_attr { |
| 200 | int id; |
| 201 | /** |
| 202 | * struct version - DPIO version |
| 203 | * @major: DPIO major version |
| 204 | * @minor: DPIO minor version |
| 205 | */ |
| 206 | struct { |
| 207 | uint16_t major; |
| 208 | uint16_t minor; |
| 209 | } version; |
Prabhakar Kushwaha | fd5d127 | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 210 | uint64_t qbman_portal_ce_offset; |
| 211 | uint64_t qbman_portal_ci_offset; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 212 | uint16_t qbman_portal_id; |
| 213 | enum dpio_channel_mode channel_mode; |
| 214 | uint8_t num_priorities; |
| 215 | }; |
| 216 | |
| 217 | /** |
| 218 | * dpio_get_attributes() - Retrieve DPIO attributes |
| 219 | * @mc_io: Pointer to MC portal's I/O object |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 220 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 221 | * @token: Token of DPIO object |
| 222 | * @attr: Returned object's attributes |
| 223 | * |
| 224 | * Return: '0' on Success; Error code otherwise |
| 225 | */ |
| 226 | int dpio_get_attributes(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 227 | uint32_t cmd_flags, |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 228 | uint16_t token, |
| 229 | struct dpio_attr *attr); |
| 230 | |
| 231 | #endif /* _FSL_DPIO_H */ |