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 | /* |
| 3 | * Freescale Layerscape MC I/O wrapper |
| 4 | * |
Yogesh Gaur | a6f2a6e | 2018-05-09 10:52:17 +0530 | [diff] [blame] | 5 | * Copyright 2013-2016 Freescale Semiconductor, Inc. |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 6 | * Copyright 2017 NXP |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 7 | */ |
| 8 | /*! |
| 9 | * @file fsl_dpbp.h |
| 10 | * @brief Data Path Buffer Pool API |
| 11 | */ |
| 12 | #ifndef __FSL_DPBP_H |
| 13 | #define __FSL_DPBP_H |
| 14 | |
| 15 | /* DPBP Version */ |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 16 | #define DPBP_VER_MAJOR 3 |
| 17 | #define DPBP_VER_MINOR 3 |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 18 | |
| 19 | /* Command IDs */ |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 20 | #define DPBP_CMDID_CLOSE 0x8001 |
| 21 | #define DPBP_CMDID_OPEN 0x8041 |
| 22 | #define DPBP_CMDID_CREATE 0x9041 |
| 23 | #define DPBP_CMDID_DESTROY 0x9841 |
| 24 | #define DPBP_CMDID_GET_API_VERSION 0xa041 |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 25 | |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 26 | #define DPBP_CMDID_ENABLE 0x0021 |
| 27 | #define DPBP_CMDID_DISABLE 0x0031 |
| 28 | #define DPBP_CMDID_GET_ATTR 0x0041 |
| 29 | #define DPBP_CMDID_RESET 0x0051 |
| 30 | #define DPBP_CMDID_IS_ENABLED 0x0061 |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 31 | |
| 32 | /* cmd, param, offset, width, type, arg_name */ |
| 33 | #define DPBP_CMD_OPEN(cmd, dpbp_id) \ |
| 34 | MC_CMD_OP(cmd, 0, 0, 32, int, dpbp_id) |
| 35 | |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 36 | /* cmd, param, offset, width, type, arg_name */ |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 37 | #define DPBP_RSP_GET_ATTRIBUTES(cmd, attr) \ |
| 38 | do { \ |
| 39 | MC_RSP_OP(cmd, 0, 16, 16, uint16_t, attr->bpid); \ |
| 40 | MC_RSP_OP(cmd, 0, 32, 32, int, attr->id);\ |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 41 | } while (0) |
| 42 | |
| 43 | /* Data Path Buffer Pool API |
| 44 | * Contains initialization APIs and runtime control APIs for DPBP |
| 45 | */ |
| 46 | |
| 47 | struct fsl_mc_io; |
| 48 | |
| 49 | /** |
| 50 | * dpbp_open() - Open a control session for the specified object. |
| 51 | * @mc_io: Pointer to MC portal's I/O object |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 52 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 53 | * @dpbp_id: DPBP unique ID |
| 54 | * @token: Returned token; use in subsequent API calls |
| 55 | * |
| 56 | * This function can be used to open a control session for an |
| 57 | * already created object; an object may have been declared in |
| 58 | * the DPL or by calling the dpbp_create function. |
| 59 | * This function returns a unique authentication token, |
| 60 | * associated with the specific object ID and the specific MC |
| 61 | * portal; this token must be used in all subsequent commands for |
| 62 | * this specific object |
| 63 | * |
| 64 | * Return: '0' on Success; Error code otherwise. |
| 65 | */ |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 66 | int dpbp_open(struct fsl_mc_io *mc_io, |
| 67 | uint32_t cmd_flags, |
| 68 | int dpbp_id, |
| 69 | uint16_t *token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 70 | |
| 71 | /** |
| 72 | * dpbp_close() - Close the control session of the object |
| 73 | * @mc_io: Pointer to MC portal's I/O object |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 74 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 75 | * @token: Token of DPBP object |
| 76 | * |
| 77 | * After this function is called, no further operations are |
| 78 | * allowed on the object without opening a new control session. |
| 79 | * |
| 80 | * Return: '0' on Success; Error code otherwise. |
| 81 | */ |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 82 | int dpbp_close(struct fsl_mc_io *mc_io, |
| 83 | uint32_t cmd_flags, |
| 84 | uint16_t token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 85 | |
| 86 | /** |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 87 | * struct dpbp_cfg - Structure representing DPBP configuration |
| 88 | * @options: place holder |
| 89 | */ |
| 90 | struct dpbp_cfg { |
| 91 | uint32_t options; |
| 92 | }; |
| 93 | |
| 94 | /** |
| 95 | * dpbp_create() - Create the DPBP object. |
| 96 | * @mc_io: Pointer to MC portal's I/O object |
| 97 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 98 | * @cfg: Configuration structure |
| 99 | * @token: Returned token; use in subsequent API calls |
| 100 | * |
| 101 | * Create the DPBP object, allocate required resources and |
| 102 | * perform required initialization. |
| 103 | * |
| 104 | * The object can be created either by declaring it in the |
| 105 | * DPL file, or by calling this function. |
| 106 | * This function returns a unique authentication token, |
| 107 | * associated with the specific object ID and the specific MC |
| 108 | * portal; this token must be used in all subsequent calls to |
| 109 | * this specific object. For objects that are created using the |
| 110 | * DPL file, call dpbp_open function to get an authentication |
| 111 | * token first. |
| 112 | * |
| 113 | * Return: '0' on Success; Error code otherwise. |
| 114 | */ |
| 115 | int dpbp_create(struct fsl_mc_io *mc_io, |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 116 | uint16_t dprc_token, |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 117 | uint32_t cmd_flags, |
| 118 | const struct dpbp_cfg *cfg, |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 119 | uint32_t *obj_id); |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 120 | |
| 121 | /** |
| 122 | * dpbp_destroy() - Destroy the DPBP object and release all its resources. |
| 123 | * @mc_io: Pointer to MC portal's I/O object |
| 124 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 125 | * @token: Token of DPBP object |
| 126 | * |
| 127 | * Return: '0' on Success; error code otherwise. |
| 128 | */ |
| 129 | int dpbp_destroy(struct fsl_mc_io *mc_io, |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 130 | uint16_t dprc_token, |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 131 | uint32_t cmd_flags, |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 132 | uint32_t obj_id); |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 133 | |
| 134 | /** |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 135 | * dpbp_enable() - Enable the DPBP. |
| 136 | * @mc_io: Pointer to MC portal's I/O object |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 137 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 138 | * @token: Token of DPBP object |
| 139 | * |
| 140 | * Return: '0' on Success; Error code otherwise. |
| 141 | */ |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 142 | int dpbp_enable(struct fsl_mc_io *mc_io, |
| 143 | uint32_t cmd_flags, |
| 144 | uint16_t token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 145 | |
| 146 | /** |
| 147 | * dpbp_disable() - Disable the DPBP. |
| 148 | * @mc_io: Pointer to MC portal's I/O object |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 149 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 150 | * @token: Token of DPBP object |
| 151 | * |
| 152 | * Return: '0' on Success; Error code otherwise. |
| 153 | */ |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 154 | int dpbp_disable(struct fsl_mc_io *mc_io, |
| 155 | uint32_t cmd_flags, |
| 156 | uint16_t token); |
| 157 | |
| 158 | /** |
| 159 | * dpbp_is_enabled() - Check if the DPBP is enabled. |
| 160 | * @mc_io: Pointer to MC portal's I/O object |
| 161 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 162 | * @token: Token of DPBP object |
| 163 | * @en: Returns '1' if object is enabled; '0' otherwise |
| 164 | * |
| 165 | * Return: '0' on Success; Error code otherwise. |
| 166 | */ |
| 167 | int dpbp_is_enabled(struct fsl_mc_io *mc_io, |
| 168 | uint32_t cmd_flags, |
| 169 | uint16_t token, |
| 170 | int *en); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 171 | |
| 172 | /** |
| 173 | * dpbp_reset() - Reset the DPBP, returns the object to initial state. |
| 174 | * @mc_io: Pointer to MC portal's I/O object |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 175 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 176 | * @token: Token of DPBP object |
| 177 | * |
| 178 | * Return: '0' on Success; Error code otherwise. |
| 179 | */ |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 180 | int dpbp_reset(struct fsl_mc_io *mc_io, |
| 181 | uint32_t cmd_flags, |
| 182 | uint16_t token); |
| 183 | |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 184 | |
| 185 | /** |
| 186 | * struct dpbp_attr - Structure representing DPBP attributes |
| 187 | * @id: DPBP object ID |
| 188 | * @version: DPBP version |
| 189 | * @bpid: Hardware buffer pool ID; should be used as an argument in |
| 190 | * acquire/release operations on buffers |
| 191 | */ |
| 192 | struct dpbp_attr { |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 193 | uint32_t id; |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 194 | uint16_t bpid; |
| 195 | }; |
| 196 | |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 197 | /** |
| 198 | * dpbp_get_attributes - Retrieve DPBP attributes. |
| 199 | * |
| 200 | * @mc_io: Pointer to MC portal's I/O object |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 201 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 202 | * @token: Token of DPBP object |
| 203 | * @attr: Returned object's attributes |
| 204 | * |
| 205 | * Return: '0' on Success; Error code otherwise. |
| 206 | */ |
| 207 | int dpbp_get_attributes(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 208 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 209 | uint16_t token, |
| 210 | struct dpbp_attr *attr); |
| 211 | |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 212 | /** |
| 213 | * dpbp_get_api_version - Retrieve DPBP Major and Minor version info. |
| 214 | * |
| 215 | * @mc_io: Pointer to MC portal's I/O object |
| 216 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 217 | * @major_ver: DPBP major version |
| 218 | * @minor_ver: DPBP minor version |
| 219 | * |
| 220 | * Return: '0' on Success; Error code otherwise. |
| 221 | */ |
| 222 | int dpbp_get_api_version(struct fsl_mc_io *mc_io, |
| 223 | u32 cmd_flags, |
| 224 | u16 *major_ver, |
| 225 | u16 *minor_ver); |
| 226 | |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 227 | /** @} */ |
| 228 | |
| 229 | #endif /* __FSL_DPBP_H */ |