Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Freescale Layerscape MC I/O wrapper |
| 3 | * |
| 4 | * Copyright (C) 2013-2015 Freescale Semiconductor, Inc. |
| 5 | * Author: German Rivera <German.Rivera@freescale.com> |
| 6 | * |
| 7 | * SPDX-License-Identifier: GPL-2.0+ |
| 8 | */ |
| 9 | #ifndef _FSL_DPRC_H |
| 10 | #define _FSL_DPRC_H |
| 11 | |
| 12 | /* DPRC Version */ |
Prabhakar Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 13 | #define DPRC_VER_MAJOR 4 |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 14 | #define DPRC_VER_MINOR 0 |
| 15 | |
| 16 | /* Command IDs */ |
| 17 | #define DPRC_CMDID_CLOSE 0x800 |
| 18 | #define DPRC_CMDID_OPEN 0x805 |
| 19 | |
| 20 | #define DPRC_CMDID_GET_ATTR 0x004 |
| 21 | #define DPRC_CMDID_RESET_CONT 0x005 |
| 22 | |
| 23 | #define DPRC_CMDID_GET_CONT_ID 0x830 |
| 24 | #define DPRC_CMDID_GET_OBJ_COUNT 0x159 |
| 25 | #define DPRC_CMDID_GET_OBJ 0x15A |
| 26 | #define DPRC_CMDID_GET_RES_COUNT 0x15B |
| 27 | #define DPRC_CMDID_GET_RES_IDS 0x15C |
| 28 | #define DPRC_CMDID_GET_OBJ_REG 0x15E |
| 29 | |
| 30 | #define DPRC_CMDID_CONNECT 0x167 |
| 31 | #define DPRC_CMDID_DISCONNECT 0x168 |
| 32 | #define DPRC_CMDID_GET_CONNECTION 0x16C |
| 33 | |
| 34 | /* cmd, param, offset, width, type, arg_name */ |
| 35 | #define DPRC_RSP_GET_CONTAINER_ID(cmd, container_id) \ |
| 36 | MC_RSP_OP(cmd, 0, 0, 32, int, container_id) |
| 37 | |
| 38 | /* cmd, param, offset, width, type, arg_name */ |
| 39 | #define DPRC_CMD_OPEN(cmd, container_id) \ |
| 40 | MC_CMD_OP(cmd, 0, 0, 32, int, container_id) |
| 41 | |
| 42 | /* cmd, param, offset, width, type, arg_name */ |
| 43 | #define DPRC_CMD_RESET_CONTAINER(cmd, child_container_id) \ |
| 44 | MC_CMD_OP(cmd, 0, 0, 32, int, child_container_id) |
| 45 | |
| 46 | /* cmd, param, offset, width, type, arg_name */ |
| 47 | #define DPRC_RSP_GET_ATTRIBUTES(cmd, attr) \ |
| 48 | do { \ |
| 49 | MC_RSP_OP(cmd, 0, 0, 32, int, attr->container_id); \ |
| 50 | MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->icid); \ |
| 51 | MC_RSP_OP(cmd, 1, 0, 32, uint32_t, attr->options);\ |
| 52 | MC_RSP_OP(cmd, 1, 32, 32, int, attr->portal_id); \ |
| 53 | MC_RSP_OP(cmd, 2, 0, 16, uint16_t, attr->version.major);\ |
| 54 | MC_RSP_OP(cmd, 2, 16, 16, uint16_t, attr->version.minor);\ |
| 55 | } while (0) |
| 56 | |
| 57 | /* cmd, param, offset, width, type, arg_name */ |
| 58 | #define DPRC_RSP_GET_OBJ_COUNT(cmd, obj_count) \ |
| 59 | MC_RSP_OP(cmd, 0, 32, 32, int, obj_count) |
| 60 | |
| 61 | /* cmd, param, offset, width, type, arg_name */ |
| 62 | #define DPRC_CMD_GET_OBJ(cmd, obj_index) \ |
| 63 | MC_CMD_OP(cmd, 0, 0, 32, int, obj_index) |
| 64 | |
| 65 | /* cmd, param, offset, width, type, arg_name */ |
| 66 | #define DPRC_RSP_GET_OBJ(cmd, obj_desc) \ |
| 67 | do { \ |
| 68 | MC_RSP_OP(cmd, 0, 32, 32, int, obj_desc->id); \ |
| 69 | MC_RSP_OP(cmd, 1, 0, 16, uint16_t, obj_desc->vendor); \ |
| 70 | MC_RSP_OP(cmd, 1, 16, 8, uint8_t, obj_desc->irq_count); \ |
| 71 | MC_RSP_OP(cmd, 1, 24, 8, uint8_t, obj_desc->region_count); \ |
| 72 | MC_RSP_OP(cmd, 1, 32, 32, uint32_t, obj_desc->state);\ |
| 73 | MC_RSP_OP(cmd, 2, 0, 16, uint16_t, obj_desc->ver_major);\ |
| 74 | MC_RSP_OP(cmd, 2, 16, 16, uint16_t, obj_desc->ver_minor);\ |
| 75 | MC_RSP_OP(cmd, 3, 0, 8, char, obj_desc->type[0]);\ |
| 76 | MC_RSP_OP(cmd, 3, 8, 8, char, obj_desc->type[1]);\ |
| 77 | MC_RSP_OP(cmd, 3, 16, 8, char, obj_desc->type[2]);\ |
| 78 | MC_RSP_OP(cmd, 3, 24, 8, char, obj_desc->type[3]);\ |
| 79 | MC_RSP_OP(cmd, 3, 32, 8, char, obj_desc->type[4]);\ |
| 80 | MC_RSP_OP(cmd, 3, 40, 8, char, obj_desc->type[5]);\ |
| 81 | MC_RSP_OP(cmd, 3, 48, 8, char, obj_desc->type[6]);\ |
| 82 | MC_RSP_OP(cmd, 3, 56, 8, char, obj_desc->type[7]);\ |
| 83 | MC_RSP_OP(cmd, 4, 0, 8, char, obj_desc->type[8]);\ |
| 84 | MC_RSP_OP(cmd, 4, 8, 8, char, obj_desc->type[9]);\ |
| 85 | MC_RSP_OP(cmd, 4, 16, 8, char, obj_desc->type[10]);\ |
| 86 | MC_RSP_OP(cmd, 4, 24, 8, char, obj_desc->type[11]);\ |
| 87 | MC_RSP_OP(cmd, 4, 32, 8, char, obj_desc->type[12]);\ |
| 88 | MC_RSP_OP(cmd, 4, 40, 8, char, obj_desc->type[13]);\ |
| 89 | MC_RSP_OP(cmd, 4, 48, 8, char, obj_desc->type[14]);\ |
| 90 | MC_RSP_OP(cmd, 4, 56, 8, char, obj_desc->type[15]);\ |
Prabhakar Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 91 | MC_RSP_OP(cmd, 5, 0, 8, char, obj_desc->label[0]);\ |
| 92 | MC_RSP_OP(cmd, 5, 8, 8, char, obj_desc->label[1]);\ |
| 93 | MC_RSP_OP(cmd, 5, 16, 8, char, obj_desc->label[2]);\ |
| 94 | MC_RSP_OP(cmd, 5, 24, 8, char, obj_desc->label[3]);\ |
| 95 | MC_RSP_OP(cmd, 5, 32, 8, char, obj_desc->label[4]);\ |
| 96 | MC_RSP_OP(cmd, 5, 40, 8, char, obj_desc->label[5]);\ |
| 97 | MC_RSP_OP(cmd, 5, 48, 8, char, obj_desc->label[6]);\ |
| 98 | MC_RSP_OP(cmd, 5, 56, 8, char, obj_desc->label[7]);\ |
| 99 | MC_RSP_OP(cmd, 6, 0, 8, char, obj_desc->label[8]);\ |
| 100 | MC_RSP_OP(cmd, 6, 8, 8, char, obj_desc->label[9]);\ |
| 101 | MC_RSP_OP(cmd, 6, 16, 8, char, obj_desc->label[10]);\ |
| 102 | MC_RSP_OP(cmd, 6, 24, 8, char, obj_desc->label[11]);\ |
| 103 | MC_RSP_OP(cmd, 6, 32, 8, char, obj_desc->label[12]);\ |
| 104 | MC_RSP_OP(cmd, 6, 40, 8, char, obj_desc->label[13]);\ |
| 105 | MC_RSP_OP(cmd, 6, 48, 8, char, obj_desc->label[14]);\ |
| 106 | MC_RSP_OP(cmd, 6, 56, 8, char, obj_desc->label[15]);\ |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 107 | } while (0) |
| 108 | |
| 109 | /* cmd, param, offset, width, type, arg_name */ |
| 110 | #define DPRC_CMD_GET_RES_COUNT(cmd, type) \ |
| 111 | do { \ |
| 112 | MC_CMD_OP(cmd, 1, 0, 8, char, type[0]);\ |
| 113 | MC_CMD_OP(cmd, 1, 8, 8, char, type[1]);\ |
| 114 | MC_CMD_OP(cmd, 1, 16, 8, char, type[2]);\ |
| 115 | MC_CMD_OP(cmd, 1, 24, 8, char, type[3]);\ |
| 116 | MC_CMD_OP(cmd, 1, 32, 8, char, type[4]);\ |
| 117 | MC_CMD_OP(cmd, 1, 40, 8, char, type[5]);\ |
| 118 | MC_CMD_OP(cmd, 1, 48, 8, char, type[6]);\ |
| 119 | MC_CMD_OP(cmd, 1, 56, 8, char, type[7]);\ |
| 120 | MC_CMD_OP(cmd, 2, 0, 8, char, type[8]);\ |
| 121 | MC_CMD_OP(cmd, 2, 8, 8, char, type[9]);\ |
| 122 | MC_CMD_OP(cmd, 2, 16, 8, char, type[10]);\ |
| 123 | MC_CMD_OP(cmd, 2, 24, 8, char, type[11]);\ |
| 124 | MC_CMD_OP(cmd, 2, 32, 8, char, type[12]);\ |
| 125 | MC_CMD_OP(cmd, 2, 40, 8, char, type[13]);\ |
| 126 | MC_CMD_OP(cmd, 2, 48, 8, char, type[14]);\ |
| 127 | MC_CMD_OP(cmd, 2, 56, 8, char, type[15]);\ |
| 128 | } while (0) |
| 129 | |
| 130 | /* cmd, param, offset, width, type, arg_name */ |
| 131 | #define DPRC_RSP_GET_RES_COUNT(cmd, res_count) \ |
| 132 | MC_RSP_OP(cmd, 0, 0, 32, int, res_count) |
| 133 | |
| 134 | /* cmd, param, offset, width, type, arg_name */ |
| 135 | #define DPRC_CMD_GET_RES_IDS(cmd, range_desc, type) \ |
| 136 | do { \ |
| 137 | MC_CMD_OP(cmd, 0, 42, 7, enum dprc_iter_status, \ |
| 138 | range_desc->iter_status); \ |
| 139 | MC_CMD_OP(cmd, 1, 0, 32, int, range_desc->base_id); \ |
| 140 | MC_CMD_OP(cmd, 1, 32, 32, int, range_desc->last_id);\ |
| 141 | MC_CMD_OP(cmd, 2, 0, 8, char, type[0]);\ |
| 142 | MC_CMD_OP(cmd, 2, 8, 8, char, type[1]);\ |
| 143 | MC_CMD_OP(cmd, 2, 16, 8, char, type[2]);\ |
| 144 | MC_CMD_OP(cmd, 2, 24, 8, char, type[3]);\ |
| 145 | MC_CMD_OP(cmd, 2, 32, 8, char, type[4]);\ |
| 146 | MC_CMD_OP(cmd, 2, 40, 8, char, type[5]);\ |
| 147 | MC_CMD_OP(cmd, 2, 48, 8, char, type[6]);\ |
| 148 | MC_CMD_OP(cmd, 2, 56, 8, char, type[7]);\ |
| 149 | MC_CMD_OP(cmd, 3, 0, 8, char, type[8]);\ |
| 150 | MC_CMD_OP(cmd, 3, 8, 8, char, type[9]);\ |
| 151 | MC_CMD_OP(cmd, 3, 16, 8, char, type[10]);\ |
| 152 | MC_CMD_OP(cmd, 3, 24, 8, char, type[11]);\ |
| 153 | MC_CMD_OP(cmd, 3, 32, 8, char, type[12]);\ |
| 154 | MC_CMD_OP(cmd, 3, 40, 8, char, type[13]);\ |
| 155 | MC_CMD_OP(cmd, 3, 48, 8, char, type[14]);\ |
| 156 | MC_CMD_OP(cmd, 3, 56, 8, char, type[15]);\ |
| 157 | } while (0) |
| 158 | |
| 159 | /* cmd, param, offset, width, type, arg_name */ |
| 160 | #define DPRC_RSP_GET_RES_IDS(cmd, range_desc) \ |
| 161 | do { \ |
| 162 | MC_RSP_OP(cmd, 0, 42, 7, enum dprc_iter_status, \ |
| 163 | range_desc->iter_status);\ |
| 164 | MC_RSP_OP(cmd, 1, 0, 32, int, range_desc->base_id); \ |
| 165 | MC_RSP_OP(cmd, 1, 32, 32, int, range_desc->last_id);\ |
| 166 | } while (0) |
| 167 | |
| 168 | /* cmd, param, offset, width, type, arg_name */ |
| 169 | #define DPRC_CMD_GET_OBJ_REGION(cmd, obj_type, obj_id, region_index) \ |
| 170 | do { \ |
| 171 | MC_CMD_OP(cmd, 0, 0, 32, int, obj_id); \ |
| 172 | MC_CMD_OP(cmd, 0, 48, 8, uint8_t, region_index);\ |
| 173 | MC_CMD_OP(cmd, 3, 0, 8, char, obj_type[0]);\ |
| 174 | MC_CMD_OP(cmd, 3, 8, 8, char, obj_type[1]);\ |
| 175 | MC_CMD_OP(cmd, 3, 16, 8, char, obj_type[2]);\ |
| 176 | MC_CMD_OP(cmd, 3, 24, 8, char, obj_type[3]);\ |
| 177 | MC_CMD_OP(cmd, 3, 32, 8, char, obj_type[4]);\ |
| 178 | MC_CMD_OP(cmd, 3, 40, 8, char, obj_type[5]);\ |
| 179 | MC_CMD_OP(cmd, 3, 48, 8, char, obj_type[6]);\ |
| 180 | MC_CMD_OP(cmd, 3, 56, 8, char, obj_type[7]);\ |
| 181 | MC_CMD_OP(cmd, 4, 0, 8, char, obj_type[8]);\ |
| 182 | MC_CMD_OP(cmd, 4, 8, 8, char, obj_type[9]);\ |
| 183 | MC_CMD_OP(cmd, 4, 16, 8, char, obj_type[10]);\ |
| 184 | MC_CMD_OP(cmd, 4, 24, 8, char, obj_type[11]);\ |
| 185 | MC_CMD_OP(cmd, 4, 32, 8, char, obj_type[12]);\ |
| 186 | MC_CMD_OP(cmd, 4, 40, 8, char, obj_type[13]);\ |
| 187 | MC_CMD_OP(cmd, 4, 48, 8, char, obj_type[14]);\ |
| 188 | MC_CMD_OP(cmd, 4, 56, 8, char, obj_type[15]);\ |
| 189 | } while (0) |
| 190 | |
| 191 | /* param, offset, width, type, arg_name */ |
| 192 | #define DPRC_RSP_GET_OBJ_REGION(cmd, region_desc) \ |
| 193 | do { \ |
Prabhakar Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 194 | MC_RSP_OP(cmd, 1, 0, 64, uint64_t, region_desc->base_offset);\ |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 195 | MC_RSP_OP(cmd, 2, 0, 32, uint32_t, region_desc->size); \ |
| 196 | } while (0) |
| 197 | |
| 198 | /* cmd, param, offset, width, type, arg_name */ |
Prabhakar Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 199 | #define DPRC_CMD_SET_OBJ_LABEL(cmd, obj_index, label) \ |
| 200 | do { \ |
| 201 | MC_CMD_OP(cmd, 0, 0, 32, int, obj_index); \ |
| 202 | MC_CMD_OP(cmd, 1, 0, 8, char, label[0]);\ |
| 203 | MC_CMD_OP(cmd, 1, 8, 8, char, label[1]);\ |
| 204 | MC_CMD_OP(cmd, 1, 16, 8, char, label[2]);\ |
| 205 | MC_CMD_OP(cmd, 1, 24, 8, char, label[3]);\ |
| 206 | MC_CMD_OP(cmd, 1, 32, 8, char, label[4]);\ |
| 207 | MC_CMD_OP(cmd, 1, 40, 8, char, label[5]);\ |
| 208 | MC_CMD_OP(cmd, 1, 48, 8, char, label[6]);\ |
| 209 | MC_CMD_OP(cmd, 1, 56, 8, char, label[7]);\ |
| 210 | MC_CMD_OP(cmd, 2, 0, 8, char, label[8]);\ |
| 211 | MC_CMD_OP(cmd, 2, 8, 8, char, label[9]);\ |
| 212 | MC_CMD_OP(cmd, 2, 16, 8, char, label[10]);\ |
| 213 | MC_CMD_OP(cmd, 2, 24, 8, char, label[11]);\ |
| 214 | MC_CMD_OP(cmd, 2, 32, 8, char, label[12]);\ |
| 215 | MC_CMD_OP(cmd, 2, 40, 8, char, label[13]);\ |
| 216 | MC_CMD_OP(cmd, 2, 48, 8, char, label[14]);\ |
| 217 | MC_CMD_OP(cmd, 2, 56, 8, char, label[15]);\ |
| 218 | } while (0) |
| 219 | |
| 220 | /* cmd, param, offset, width, type, arg_name */ |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 221 | #define DPRC_CMD_CONNECT(cmd, endpoint1, endpoint2) \ |
| 222 | do { \ |
| 223 | MC_CMD_OP(cmd, 0, 0, 32, int, endpoint1->id); \ |
| 224 | MC_CMD_OP(cmd, 0, 32, 32, int, endpoint1->interface_id); \ |
| 225 | MC_CMD_OP(cmd, 1, 0, 32, int, endpoint2->id); \ |
| 226 | MC_CMD_OP(cmd, 1, 32, 32, int, endpoint2->interface_id); \ |
| 227 | MC_CMD_OP(cmd, 2, 0, 8, char, endpoint1->type[0]); \ |
| 228 | MC_CMD_OP(cmd, 2, 8, 8, char, endpoint1->type[1]); \ |
| 229 | MC_CMD_OP(cmd, 2, 16, 8, char, endpoint1->type[2]); \ |
| 230 | MC_CMD_OP(cmd, 2, 24, 8, char, endpoint1->type[3]); \ |
| 231 | MC_CMD_OP(cmd, 2, 32, 8, char, endpoint1->type[4]); \ |
| 232 | MC_CMD_OP(cmd, 2, 40, 8, char, endpoint1->type[5]); \ |
| 233 | MC_CMD_OP(cmd, 2, 48, 8, char, endpoint1->type[6]); \ |
| 234 | MC_CMD_OP(cmd, 2, 56, 8, char, endpoint1->type[7]); \ |
| 235 | MC_CMD_OP(cmd, 3, 0, 8, char, endpoint1->type[8]); \ |
| 236 | MC_CMD_OP(cmd, 3, 8, 8, char, endpoint1->type[9]); \ |
| 237 | MC_CMD_OP(cmd, 3, 16, 8, char, endpoint1->type[10]); \ |
| 238 | MC_CMD_OP(cmd, 3, 24, 8, char, endpoint1->type[11]); \ |
| 239 | MC_CMD_OP(cmd, 3, 32, 8, char, endpoint1->type[12]); \ |
| 240 | MC_CMD_OP(cmd, 3, 40, 8, char, endpoint1->type[13]); \ |
| 241 | MC_CMD_OP(cmd, 3, 48, 8, char, endpoint1->type[14]); \ |
| 242 | MC_CMD_OP(cmd, 3, 56, 8, char, endpoint1->type[15]); \ |
| 243 | MC_CMD_OP(cmd, 5, 0, 8, char, endpoint2->type[0]); \ |
| 244 | MC_CMD_OP(cmd, 5, 8, 8, char, endpoint2->type[1]); \ |
| 245 | MC_CMD_OP(cmd, 5, 16, 8, char, endpoint2->type[2]); \ |
| 246 | MC_CMD_OP(cmd, 5, 24, 8, char, endpoint2->type[3]); \ |
| 247 | MC_CMD_OP(cmd, 5, 32, 8, char, endpoint2->type[4]); \ |
| 248 | MC_CMD_OP(cmd, 5, 40, 8, char, endpoint2->type[5]); \ |
| 249 | MC_CMD_OP(cmd, 5, 48, 8, char, endpoint2->type[6]); \ |
| 250 | MC_CMD_OP(cmd, 5, 56, 8, char, endpoint2->type[7]); \ |
| 251 | MC_CMD_OP(cmd, 6, 0, 8, char, endpoint2->type[8]); \ |
| 252 | MC_CMD_OP(cmd, 6, 8, 8, char, endpoint2->type[9]); \ |
| 253 | MC_CMD_OP(cmd, 6, 16, 8, char, endpoint2->type[10]); \ |
| 254 | MC_CMD_OP(cmd, 6, 24, 8, char, endpoint2->type[11]); \ |
| 255 | MC_CMD_OP(cmd, 6, 32, 8, char, endpoint2->type[12]); \ |
| 256 | MC_CMD_OP(cmd, 6, 40, 8, char, endpoint2->type[13]); \ |
| 257 | MC_CMD_OP(cmd, 6, 48, 8, char, endpoint2->type[14]); \ |
| 258 | MC_CMD_OP(cmd, 6, 56, 8, char, endpoint2->type[15]); \ |
| 259 | } while (0) |
| 260 | |
| 261 | /* cmd, param, offset, width, type, arg_name */ |
| 262 | #define DPRC_CMD_DISCONNECT(cmd, endpoint) \ |
| 263 | do { \ |
| 264 | MC_CMD_OP(cmd, 0, 0, 32, int, endpoint->id); \ |
| 265 | MC_CMD_OP(cmd, 0, 32, 32, int, endpoint->interface_id); \ |
| 266 | MC_CMD_OP(cmd, 1, 0, 8, char, endpoint->type[0]); \ |
| 267 | MC_CMD_OP(cmd, 1, 8, 8, char, endpoint->type[1]); \ |
| 268 | MC_CMD_OP(cmd, 1, 16, 8, char, endpoint->type[2]); \ |
| 269 | MC_CMD_OP(cmd, 1, 24, 8, char, endpoint->type[3]); \ |
| 270 | MC_CMD_OP(cmd, 1, 32, 8, char, endpoint->type[4]); \ |
| 271 | MC_CMD_OP(cmd, 1, 40, 8, char, endpoint->type[5]); \ |
| 272 | MC_CMD_OP(cmd, 1, 48, 8, char, endpoint->type[6]); \ |
| 273 | MC_CMD_OP(cmd, 1, 56, 8, char, endpoint->type[7]); \ |
| 274 | MC_CMD_OP(cmd, 2, 0, 8, char, endpoint->type[8]); \ |
| 275 | MC_CMD_OP(cmd, 2, 8, 8, char, endpoint->type[9]); \ |
| 276 | MC_CMD_OP(cmd, 2, 16, 8, char, endpoint->type[10]); \ |
| 277 | MC_CMD_OP(cmd, 2, 24, 8, char, endpoint->type[11]); \ |
| 278 | MC_CMD_OP(cmd, 2, 32, 8, char, endpoint->type[12]); \ |
| 279 | MC_CMD_OP(cmd, 2, 40, 8, char, endpoint->type[13]); \ |
| 280 | MC_CMD_OP(cmd, 2, 48, 8, char, endpoint->type[14]); \ |
| 281 | MC_CMD_OP(cmd, 2, 56, 8, char, endpoint->type[15]); \ |
| 282 | } while (0) |
| 283 | |
| 284 | /* cmd, param, offset, width, type, arg_name */ |
| 285 | #define DPRC_CMD_GET_CONNECTION(cmd, endpoint1) \ |
| 286 | do { \ |
| 287 | MC_CMD_OP(cmd, 0, 0, 32, int, endpoint1->id); \ |
| 288 | MC_CMD_OP(cmd, 0, 32, 32, int, endpoint1->interface_id); \ |
| 289 | MC_CMD_OP(cmd, 1, 0, 8, char, endpoint1->type[0]); \ |
| 290 | MC_CMD_OP(cmd, 1, 8, 8, char, endpoint1->type[1]); \ |
| 291 | MC_CMD_OP(cmd, 1, 16, 8, char, endpoint1->type[2]); \ |
| 292 | MC_CMD_OP(cmd, 1, 24, 8, char, endpoint1->type[3]); \ |
| 293 | MC_CMD_OP(cmd, 1, 32, 8, char, endpoint1->type[4]); \ |
| 294 | MC_CMD_OP(cmd, 1, 40, 8, char, endpoint1->type[5]); \ |
| 295 | MC_CMD_OP(cmd, 1, 48, 8, char, endpoint1->type[6]); \ |
| 296 | MC_CMD_OP(cmd, 1, 56, 8, char, endpoint1->type[7]); \ |
| 297 | MC_CMD_OP(cmd, 2, 0, 8, char, endpoint1->type[8]); \ |
| 298 | MC_CMD_OP(cmd, 2, 8, 8, char, endpoint1->type[9]); \ |
| 299 | MC_CMD_OP(cmd, 2, 16, 8, char, endpoint1->type[10]); \ |
| 300 | MC_CMD_OP(cmd, 2, 24, 8, char, endpoint1->type[11]); \ |
| 301 | MC_CMD_OP(cmd, 2, 32, 8, char, endpoint1->type[12]); \ |
| 302 | MC_CMD_OP(cmd, 2, 40, 8, char, endpoint1->type[13]); \ |
| 303 | MC_CMD_OP(cmd, 2, 48, 8, char, endpoint1->type[14]); \ |
| 304 | MC_CMD_OP(cmd, 2, 56, 8, char, endpoint1->type[15]); \ |
| 305 | } while (0) |
| 306 | |
| 307 | |
| 308 | /* cmd, param, offset, width, type, arg_name */ |
| 309 | #define DPRC_RSP_GET_CONNECTION(cmd, endpoint2, state) \ |
| 310 | do { \ |
| 311 | MC_RSP_OP(cmd, 3, 0, 32, int, endpoint2->id); \ |
| 312 | MC_RSP_OP(cmd, 3, 32, 32, int, endpoint2->interface_id); \ |
| 313 | MC_RSP_OP(cmd, 4, 0, 8, char, endpoint2->type[0]); \ |
| 314 | MC_RSP_OP(cmd, 4, 8, 8, char, endpoint2->type[1]); \ |
| 315 | MC_RSP_OP(cmd, 4, 16, 8, char, endpoint2->type[2]); \ |
| 316 | MC_RSP_OP(cmd, 4, 24, 8, char, endpoint2->type[3]); \ |
| 317 | MC_RSP_OP(cmd, 4, 32, 8, char, endpoint2->type[4]); \ |
| 318 | MC_RSP_OP(cmd, 4, 40, 8, char, endpoint2->type[5]); \ |
| 319 | MC_RSP_OP(cmd, 4, 48, 8, char, endpoint2->type[6]); \ |
| 320 | MC_RSP_OP(cmd, 4, 56, 8, char, endpoint2->type[7]); \ |
| 321 | MC_RSP_OP(cmd, 5, 0, 8, char, endpoint2->type[8]); \ |
| 322 | MC_RSP_OP(cmd, 5, 8, 8, char, endpoint2->type[9]); \ |
| 323 | MC_RSP_OP(cmd, 5, 16, 8, char, endpoint2->type[10]); \ |
| 324 | MC_RSP_OP(cmd, 5, 24, 8, char, endpoint2->type[11]); \ |
| 325 | MC_RSP_OP(cmd, 5, 32, 8, char, endpoint2->type[12]); \ |
| 326 | MC_RSP_OP(cmd, 5, 40, 8, char, endpoint2->type[13]); \ |
| 327 | MC_RSP_OP(cmd, 5, 48, 8, char, endpoint2->type[14]); \ |
| 328 | MC_RSP_OP(cmd, 5, 56, 8, char, endpoint2->type[15]); \ |
| 329 | MC_RSP_OP(cmd, 6, 0, 32, int, state); \ |
| 330 | } while (0) |
| 331 | |
| 332 | /* Data Path Resource Container API |
| 333 | * Contains DPRC API for managing and querying DPAA resources |
| 334 | */ |
Prabhakar Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 335 | |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 336 | struct fsl_mc_io; |
| 337 | |
| 338 | /** |
| 339 | * Set this value as the icid value in dprc_cfg structure when creating a |
| 340 | * container, in case the ICID is not selected by the user and should be |
| 341 | * allocated by the DPRC from the pool of ICIDs. |
| 342 | */ |
| 343 | #define DPRC_GET_ICID_FROM_POOL (uint16_t)(~(0)) |
| 344 | |
| 345 | /** |
| 346 | * Set this value as the portal_id value in dprc_cfg structure when creating a |
| 347 | * container, in case the portal ID is not specifically selected by the |
| 348 | * user and should be allocated by the DPRC from the pool of portal ids. |
| 349 | */ |
| 350 | #define DPRC_GET_PORTAL_ID_FROM_POOL (int)(~(0)) |
| 351 | |
| 352 | /** |
| 353 | * dprc_get_container_id() - Get container ID associated with a given portal. |
| 354 | * @mc_io: Pointer to MC portal's I/O object |
| 355 | * @container_id: Requested container ID |
| 356 | * |
| 357 | * Return: '0' on Success; Error code otherwise. |
| 358 | */ |
| 359 | int dprc_get_container_id(struct fsl_mc_io *mc_io, int *container_id); |
| 360 | |
| 361 | /** |
| 362 | * dprc_open() - Open DPRC object for use |
| 363 | * @mc_io: Pointer to MC portal's I/O object |
| 364 | * @container_id: Container ID to open |
| 365 | * @token: Returned token of DPRC object |
| 366 | * |
| 367 | * Return: '0' on Success; Error code otherwise. |
| 368 | * |
| 369 | * @warning Required before any operation on the object. |
| 370 | */ |
| 371 | int dprc_open(struct fsl_mc_io *mc_io, int container_id, uint16_t *token); |
| 372 | |
| 373 | /** |
| 374 | * dprc_close() - Close the control session of the object |
| 375 | * @mc_io: Pointer to MC portal's I/O object |
| 376 | * @token: Token of DPRC object |
| 377 | * |
| 378 | * After this function is called, no further operations are |
| 379 | * allowed on the object without opening a new control session. |
| 380 | * |
| 381 | * Return: '0' on Success; Error code otherwise. |
| 382 | */ |
| 383 | int dprc_close(struct fsl_mc_io *mc_io, uint16_t token); |
| 384 | |
| 385 | /** |
| 386 | * Container general options |
| 387 | * |
| 388 | * These options may be selected at container creation by the container creator |
| 389 | * and can be retrieved using dprc_get_attributes() |
| 390 | */ |
| 391 | |
| 392 | /* Spawn Policy Option allowed - Indicates that the new container is allowed |
| 393 | * to spawn and have its own child containers. |
| 394 | */ |
| 395 | #define DPRC_CFG_OPT_SPAWN_ALLOWED 0x00000001 |
| 396 | |
| 397 | /* General Container allocation policy - Indicates that the new container is |
| 398 | * allowed to allocate requested resources from its parent container; if not |
| 399 | * set, the container is only allowed to use resources in its own pools; Note |
| 400 | * that this is a container's global policy, but the parent container may |
| 401 | * override it and set specific quota per resource type. |
| 402 | */ |
| 403 | #define DPRC_CFG_OPT_ALLOC_ALLOWED 0x00000002 |
| 404 | |
| 405 | /* Object initialization allowed - software context associated with this |
| 406 | * container is allowed to invoke object initialization operations. |
| 407 | */ |
Prabhakar Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 408 | #define DPRC_CFG_OPT_OBJ_CREATE_ALLOWED 0x00000004 |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 409 | |
| 410 | /* Topology change allowed - software context associated with this |
| 411 | * container is allowed to invoke topology operations, such as attach/detach |
| 412 | * of network objects. |
| 413 | */ |
| 414 | #define DPRC_CFG_OPT_TOPOLOGY_CHANGES_ALLOWED 0x00000008 |
| 415 | |
| 416 | /* IOMMU bypass - indicates whether objects of this container are permitted |
| 417 | * to bypass the IOMMU. |
| 418 | */ |
| 419 | #define DPRC_CFG_OPT_IOMMU_BYPASS 0x00000010 |
| 420 | |
| 421 | /* AIOP - Indicates that container belongs to AIOP. */ |
| 422 | #define DPRC_CFG_OPT_AIOP 0x00000020 |
| 423 | |
| 424 | /** |
| 425 | * struct dprc_cfg - Container configuration options |
| 426 | * @icid: Container's ICID; if set to 'DPRC_GET_ICID_FROM_POOL', a free |
| 427 | * ICID value is allocated by the DPRC |
| 428 | * @portal_id: Portal ID; if set to 'DPRC_GET_PORTAL_ID_FROM_POOL', a free |
| 429 | * portal ID is allocated by the DPRC |
| 430 | * @options: Combination of 'DPRC_CFG_OPT_<X>' options |
Prabhakar Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 431 | * @label: Object's label |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 432 | */ |
| 433 | struct dprc_cfg { |
| 434 | uint16_t icid; |
| 435 | int portal_id; |
| 436 | uint64_t options; |
Prabhakar Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 437 | char label[16]; |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 438 | }; |
| 439 | |
| 440 | /** |
| 441 | * dprc_reset_container - Reset child container. |
| 442 | * @mc_io: Pointer to MC portal's I/O object |
| 443 | * @token: Token of DPRC object |
| 444 | * @child_container_id: ID of the container to reset |
| 445 | * |
| 446 | * In case a software context crashes or becomes non-responsive, the parent |
| 447 | * may wish to reset its resources container before the software context is |
| 448 | * restarted. |
| 449 | * |
| 450 | * This routine informs all objects assigned to the child container that the |
| 451 | * container is being reset, so they may perform any cleanup operations that are |
| 452 | * needed. All objects handles that were owned by the child container shall be |
| 453 | * closed. |
| 454 | * |
| 455 | * Note that such request may be submitted even if the child software context |
| 456 | * has not crashed, but the resulting object cleanup operations will not be |
| 457 | * aware of that. |
| 458 | * |
| 459 | * Return: '0' on Success; Error code otherwise. |
| 460 | */ |
| 461 | int dprc_reset_container(struct fsl_mc_io *mc_io, |
| 462 | uint16_t token, |
| 463 | int child_container_id); |
| 464 | |
| 465 | /** |
| 466 | * struct dprc_attributes - Container attributes |
| 467 | * @container_id: Container's ID |
| 468 | * @icid: Container's ICID |
| 469 | * @portal_id: Container's portal ID |
| 470 | * @options: Container's options as set at container's creation |
| 471 | * @version: DPRC version |
| 472 | */ |
| 473 | struct dprc_attributes { |
| 474 | int container_id; |
| 475 | uint16_t icid; |
| 476 | int portal_id; |
| 477 | uint64_t options; |
| 478 | /** |
| 479 | * struct version - DPRC version |
| 480 | * @major: DPRC major version |
| 481 | * @minor: DPRC minor version |
| 482 | */ |
| 483 | struct { |
| 484 | uint16_t major; |
| 485 | uint16_t minor; |
| 486 | } version; |
| 487 | }; |
| 488 | |
| 489 | /** |
| 490 | * dprc_get_attributes() - Obtains container attributes |
| 491 | * @mc_io: Pointer to MC portal's I/O object |
| 492 | * @token: Token of DPRC object |
| 493 | * @attributes Returned container attributes |
| 494 | * |
| 495 | * Return: '0' on Success; Error code otherwise. |
| 496 | */ |
| 497 | int dprc_get_attributes(struct fsl_mc_io *mc_io, |
| 498 | uint16_t token, |
| 499 | struct dprc_attributes *attributes); |
| 500 | |
| 501 | /** |
| 502 | * dprc_get_obj_count() - Obtains the number of objects in the DPRC |
| 503 | * @mc_io: Pointer to MC portal's I/O object |
| 504 | * @token: Token of DPRC object |
| 505 | * @obj_count: Number of objects assigned to the DPRC |
| 506 | * |
| 507 | * Return: '0' on Success; Error code otherwise. |
| 508 | */ |
| 509 | int dprc_get_obj_count(struct fsl_mc_io *mc_io, uint16_t token, int *obj_count); |
| 510 | |
| 511 | /* Objects Attributes Flags */ |
| 512 | |
| 513 | /* Opened state - Indicates that an object is open by at least one owner */ |
| 514 | #define DPRC_OBJ_STATE_OPEN 0x00000001 |
| 515 | /* Plugged state - Indicates that the object is plugged */ |
| 516 | #define DPRC_OBJ_STATE_PLUGGED 0x00000002 |
| 517 | |
| 518 | /** |
| 519 | * struct dprc_obj_desc - Object descriptor, returned from dprc_get_obj() |
| 520 | * @type: Type of object: NULL terminated string |
| 521 | * @id: ID of logical object resource |
| 522 | * @vendor: Object vendor identifier |
| 523 | * @ver_major: Major version number |
| 524 | * @ver_minor: Minor version number |
| 525 | * @irq_count: Number of interrupts supported by the object |
| 526 | * @region_count: Number of mappable regions supported by the object |
| 527 | * @state: Object state: combination of DPRC_OBJ_STATE_ states |
Prabhakar Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 528 | * @label: Object label |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 529 | */ |
| 530 | struct dprc_obj_desc { |
| 531 | char type[16]; |
| 532 | int id; |
| 533 | uint16_t vendor; |
| 534 | uint16_t ver_major; |
| 535 | uint16_t ver_minor; |
| 536 | uint8_t irq_count; |
| 537 | uint8_t region_count; |
| 538 | uint32_t state; |
Prabhakar Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 539 | char label[16]; |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 540 | }; |
| 541 | |
| 542 | /** |
| 543 | * dprc_get_obj() - Get general information on an object |
| 544 | * @mc_io: Pointer to MC portal's I/O object |
| 545 | * @token: Token of DPRC object |
| 546 | * @obj_index: Index of the object to be queried (< obj_count) |
| 547 | * @obj_desc: Returns the requested object descriptor |
| 548 | * |
| 549 | * The object descriptors are retrieved one by one by incrementing |
| 550 | * obj_index up to (not including) the value of obj_count returned |
| 551 | * from dprc_get_obj_count(). dprc_get_obj_count() must |
| 552 | * be called prior to dprc_get_obj(). |
| 553 | * |
| 554 | * Return: '0' on Success; Error code otherwise. |
| 555 | */ |
| 556 | int dprc_get_obj(struct fsl_mc_io *mc_io, |
| 557 | uint16_t token, |
| 558 | int obj_index, |
| 559 | struct dprc_obj_desc *obj_desc); |
| 560 | |
| 561 | /** |
Prabhakar Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 562 | * dprc_get_res_count() - Obtains the number of free resources that are |
| 563 | * assigned to this container, by pool type |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 564 | * @mc_io: Pointer to MC portal's I/O object |
| 565 | * @token: Token of DPRC object |
| 566 | * @type: pool type |
| 567 | * @res_count: Returned number of free resources of the given |
| 568 | * resource type that are assigned to this DPRC |
| 569 | * |
| 570 | * Return: '0' on Success; Error code otherwise. |
| 571 | */ |
| 572 | int dprc_get_res_count(struct fsl_mc_io *mc_io, |
| 573 | uint16_t token, |
| 574 | char *type, |
| 575 | int *res_count); |
| 576 | |
| 577 | /** |
| 578 | * enum dprc_iter_status - Iteration status |
| 579 | * @DPRC_ITER_STATUS_FIRST: Perform first iteration |
| 580 | * @DPRC_ITER_STATUS_MORE: Indicates more/next iteration is needed |
| 581 | * @DPRC_ITER_STATUS_LAST: Indicates last iteration |
| 582 | */ |
| 583 | enum dprc_iter_status { |
| 584 | DPRC_ITER_STATUS_FIRST = 0, |
| 585 | DPRC_ITER_STATUS_MORE = 1, |
| 586 | DPRC_ITER_STATUS_LAST = 2 |
| 587 | }; |
| 588 | |
| 589 | /** |
| 590 | * struct dprc_res_ids_range_desc - Resource ID range descriptor |
| 591 | * @base_id: Base resource ID of this range |
| 592 | * @last_id: Last resource ID of this range |
| 593 | * @iter_status: Iteration status - should be set to DPRC_ITER_STATUS_FIRST at |
| 594 | * first iteration; while the returned marker is DPRC_ITER_STATUS_MORE, |
| 595 | * additional iterations are needed, until the returned marker is |
| 596 | * DPRC_ITER_STATUS_LAST |
| 597 | */ |
| 598 | struct dprc_res_ids_range_desc { |
| 599 | int base_id; |
| 600 | int last_id; |
| 601 | enum dprc_iter_status iter_status; |
| 602 | }; |
| 603 | |
| 604 | /** |
| 605 | * dprc_get_res_ids() - Obtains IDs of free resources in the container |
| 606 | * @mc_io: Pointer to MC portal's I/O object |
| 607 | * @token: Token of DPRC object |
| 608 | * @type: pool type |
| 609 | * @range_desc: range descriptor |
| 610 | * |
| 611 | * Return: '0' on Success; Error code otherwise. |
| 612 | */ |
| 613 | int dprc_get_res_ids(struct fsl_mc_io *mc_io, |
| 614 | uint16_t token, |
| 615 | char *type, |
| 616 | struct dprc_res_ids_range_desc *range_desc); |
| 617 | |
| 618 | /** |
| 619 | * struct dprc_region_desc - Mappable region descriptor |
Prabhakar Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 620 | * @base_offset: Region offset from region's base address. |
| 621 | * For DPMCP and DPRC objects, region base is offset from SoC MC portals |
| 622 | * base address; For DPIO, region base is offset from SoC QMan portals |
| 623 | * base address |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 624 | * @size: Region size (in bytes) |
| 625 | */ |
| 626 | struct dprc_region_desc { |
Prabhakar Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 627 | uint64_t base_offset; |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 628 | uint32_t size; |
| 629 | }; |
| 630 | |
| 631 | /** |
| 632 | * dprc_get_obj_region() - Get region information for a specified object. |
| 633 | * @mc_io: Pointer to MC portal's I/O object |
| 634 | * @token: Token of DPRC object |
| 635 | * @obj_type; Object type as returned in dprc_get_obj() |
| 636 | * @obj_id: Unique object instance as returned in dprc_get_obj() |
| 637 | * @region_index: The specific region to query |
| 638 | * @region_desc: Returns the requested region descriptor |
| 639 | * |
| 640 | * Return: '0' on Success; Error code otherwise. |
| 641 | */ |
| 642 | int dprc_get_obj_region(struct fsl_mc_io *mc_io, |
| 643 | uint16_t token, |
| 644 | char *obj_type, |
| 645 | int obj_id, |
| 646 | uint8_t region_index, |
| 647 | struct dprc_region_desc *region_desc); |
| 648 | /** |
| 649 | * struct dprc_endpoint - Endpoint description for link connect/disconnect |
| 650 | * operations |
| 651 | * @type: Endpoint object type: NULL terminated string |
| 652 | * @id: Endpoint object ID |
| 653 | * @interface_id: Interface ID; should be set for endpoints with multiple |
| 654 | * interfaces ("dpsw", "dpdmux"); for others, always set to 0 |
| 655 | */ |
| 656 | struct dprc_endpoint { |
| 657 | char type[16]; |
| 658 | int id; |
| 659 | int interface_id; |
| 660 | }; |
| 661 | |
| 662 | /** |
| 663 | * dprc_connect() - Connect two endpoints to create a network link between them |
| 664 | * @mc_io: Pointer to MC portal's I/O object |
| 665 | * @token: Token of DPRC object |
| 666 | * @endpoint1: Endpoint 1 configuration parameters |
| 667 | * @endpoint2: Endpoint 2 configuration parameters |
| 668 | * |
| 669 | * Return: '0' on Success; Error code otherwise. |
| 670 | */ |
| 671 | int dprc_connect(struct fsl_mc_io *mc_io, |
| 672 | uint16_t token, |
| 673 | const struct dprc_endpoint *endpoint1, |
| 674 | const struct dprc_endpoint *endpoint2); |
| 675 | |
| 676 | /** |
| 677 | * dprc_disconnect() - Disconnect one endpoint to remove its network connection |
| 678 | * @mc_io: Pointer to MC portal's I/O object |
| 679 | * @token: Token of DPRC object |
| 680 | * @endpoint: Endpoint configuration parameters |
| 681 | * |
| 682 | * Return: '0' on Success; Error code otherwise. |
| 683 | */ |
| 684 | int dprc_disconnect(struct fsl_mc_io *mc_io, |
| 685 | uint16_t token, |
| 686 | const struct dprc_endpoint *endpoint); |
| 687 | |
| 688 | /** |
| 689 | * dprc_get_connection() - Get connected endpoint and link status if connection |
| 690 | * exists. |
Prabhakar Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 691 | * @mc_io Pointer to MC portal's I/O object |
| 692 | * @token Token of DPRC object |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 693 | * @endpoint1 Endpoint 1 configuration parameters |
| 694 | * @endpoint2 Returned endpoint 2 configuration parameters |
| 695 | * @state: Returned link state: 1 - link is up, 0 - link is down |
| 696 | * |
| 697 | * Return: '0' on Success; -ENAVAIL if connection does not exist. |
| 698 | */ |
| 699 | int dprc_get_connection(struct fsl_mc_io *mc_io, |
| 700 | uint16_t token, |
| 701 | const struct dprc_endpoint *endpoint1, |
| 702 | struct dprc_endpoint *endpoint2, |
| 703 | int *state); |
| 704 | |
| 705 | #endif /* _FSL_DPRC_H */ |