| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
/* |
| 3 |
* Freescale Management Complex (MC) bus private declarations |
| 4 |
* |
| 5 |
* Copyright (C) 2016 Freescale Semiconductor, Inc. |
| 6 |
* |
| 7 |
*/ |
| 8 |
#ifndef _FSL_MC_PRIVATE_H_ |
| 9 |
#define _FSL_MC_PRIVATE_H_ |
| 10 |
|
| 11 |
#include <linux/fsl/mc.h> |
| 12 |
#include <linux/mutex.h> |
| 13 |
#include <linux/ioctl.h> |
| 14 |
#include <linux/miscdevice.h> |
| 15 |
|
| 16 |
/* |
| 17 |
* Data Path Management Complex (DPMNG) General API |
| 18 |
*/ |
| 19 |
|
| 20 |
/* DPMNG command versioning */ |
| 21 |
#define DPMNG_CMD_BASE_VERSION 1 |
| 22 |
#define DPMNG_CMD_ID_OFFSET 4 |
| 23 |
|
| 24 |
#define DPMNG_CMD(id) (((id) << DPMNG_CMD_ID_OFFSET) | DPMNG_CMD_BASE_VERSION) |
| 25 |
|
| 26 |
/* DPMNG command IDs */ |
| 27 |
#define DPMNG_CMDID_GET_VERSION DPMNG_CMD(0x831) |
| 28 |
|
| 29 |
struct dpmng_rsp_get_version { |
| 30 |
__le32 revision; |
| 31 |
__le32 version_major; |
| 32 |
__le32 version_minor; |
| 33 |
}; |
| 34 |
|
| 35 |
/* |
| 36 |
* Data Path Management Command Portal (DPMCP) API |
| 37 |
*/ |
| 38 |
|
| 39 |
/* Minimal supported DPMCP Version */ |
| 40 |
#define DPMCP_MIN_VER_MAJOR 3 |
| 41 |
#define DPMCP_MIN_VER_MINOR 0 |
| 42 |
|
| 43 |
/* DPMCP command versioning */ |
| 44 |
#define DPMCP_CMD_BASE_VERSION 1 |
| 45 |
#define DPMCP_CMD_ID_OFFSET 4 |
| 46 |
|
| 47 |
#define DPMCP_CMD(id) (((id) << DPMCP_CMD_ID_OFFSET) | DPMCP_CMD_BASE_VERSION) |
| 48 |
|
| 49 |
/* DPMCP command IDs */ |
| 50 |
#define DPMCP_CMDID_CLOSE DPMCP_CMD(0x800) |
| 51 |
#define DPMCP_CMDID_RESET DPMCP_CMD(0x005) |
| 52 |
|
| 53 |
struct dpmcp_cmd_open { |
| 54 |
__le32 dpmcp_id; |
| 55 |
}; |
| 56 |
|
| 57 |
/* |
| 58 |
* Initialization and runtime control APIs for DPMCP |
| 59 |
*/ |
| 60 |
int dpmcp_open(struct fsl_mc_io *mc_io, |
| 61 |
u32 cmd_flags, |
| 62 |
int dpmcp_id, |
| 63 |
u16 *token); |
| 64 |
|
| 65 |
int dpmcp_close(struct fsl_mc_io *mc_io, |
| 66 |
u32 cmd_flags, |
| 67 |
u16 token); |
| 68 |
|
| 69 |
/* |
| 70 |
* Data Path Resource Container (DPRC) API |
| 71 |
*/ |
| 72 |
|
| 73 |
/* Minimal supported DPRC Version */ |
| 74 |
#define DPRC_MIN_VER_MAJOR 6 |
| 75 |
#define DPRC_MIN_VER_MINOR 0 |
| 76 |
|
| 77 |
/* DPRC command versioning */ |
| 78 |
#define DPRC_CMD_BASE_VERSION 1 |
| 79 |
#define DPRC_CMD_2ND_VERSION 2 |
| 80 |
#define DPRC_CMD_3RD_VERSION 3 |
| 81 |
#define DPRC_CMD_ID_OFFSET 4 |
| 82 |
|
| 83 |
#define DPRC_CMD(id) (((id) << DPRC_CMD_ID_OFFSET) | DPRC_CMD_BASE_VERSION) |
| 84 |
#define DPRC_CMD_V2(id) (((id) << DPRC_CMD_ID_OFFSET) | DPRC_CMD_2ND_VERSION) |
| 85 |
#define DPRC_CMD_V3(id) (((id) << DPRC_CMD_ID_OFFSET) | DPRC_CMD_3RD_VERSION) |
| 86 |
|
| 87 |
/* DPRC command IDs */ |
| 88 |
#define DPRC_CMDID_CLOSE DPRC_CMD(0x800) |
| 89 |
#define DPRC_CMDID_GET_API_VERSION DPRC_CMD(0xa05) |
| 90 |
|
| 91 |
#define DPRC_CMDID_GET_ATTR DPRC_CMD(0x004) |
| 92 |
#define DPRC_CMDID_RESET_CONT DPRC_CMD(0x005) |
| 93 |
#define DPRC_CMDID_RESET_CONT_V2 DPRC_CMD_V2(0x005) |
| 94 |
|
| 95 |
#define DPRC_CMDID_SET_IRQ DPRC_CMD(0x010) |
| 96 |
#define DPRC_CMDID_SET_IRQ_ENABLE DPRC_CMD(0x012) |
| 97 |
#define DPRC_CMDID_SET_IRQ_MASK DPRC_CMD(0x014) |
| 98 |
#define DPRC_CMDID_GET_IRQ_STATUS DPRC_CMD(0x016) |
| 99 |
#define DPRC_CMDID_CLEAR_IRQ_STATUS DPRC_CMD(0x017) |
| 100 |
|
| 101 |
#define DPRC_CMDID_GET_CONT_ID DPRC_CMD(0x830) |
| 102 |
#define DPRC_CMDID_GET_OBJ_COUNT DPRC_CMD(0x159) |
| 103 |
#define DPRC_CMDID_GET_OBJ DPRC_CMD(0x15A) |
| 104 |
#define DPRC_CMDID_GET_OBJ_REG DPRC_CMD(0x15E) |
| 105 |
#define DPRC_CMDID_GET_OBJ_REG_V2 DPRC_CMD_V2(0x15E) |
| 106 |
#define DPRC_CMDID_GET_OBJ_REG_V3 DPRC_CMD_V3(0x15E) |
| 107 |
#define DPRC_CMDID_SET_OBJ_IRQ DPRC_CMD(0x15F) |
| 108 |
|
| 109 |
#define DPRC_CMDID_GET_CONNECTION DPRC_CMD(0x16C) |
| 110 |
|
| 111 |
struct dprc_cmd_open { |
| 112 |
__le32 container_id; |
| 113 |
}; |
| 114 |
|
| 115 |
struct dprc_cmd_reset_container { |
| 116 |
__le32 child_container_id; |
| 117 |
__le32 options; |
| 118 |
}; |
| 119 |
|
| 120 |
struct dprc_cmd_set_irq { |
| 121 |
/* cmd word 0 */ |
| 122 |
__le32 irq_val; |
| 123 |
u8 irq_index; |
| 124 |
u8 pad[3]; |
| 125 |
/* cmd word 1 */ |
| 126 |
__le64 irq_addr; |
| 127 |
/* cmd word 2 */ |
| 128 |
__le32 irq_num; |
| 129 |
}; |
| 130 |
|
| 131 |
#define DPRC_ENABLE 0x1 |
| 132 |
|
| 133 |
struct dprc_cmd_set_irq_enable { |
| 134 |
u8 enable; |
| 135 |
u8 pad[3]; |
| 136 |
u8 irq_index; |
| 137 |
}; |
| 138 |
|
| 139 |
struct dprc_cmd_set_irq_mask { |
| 140 |
__le32 mask; |
| 141 |
u8 irq_index; |
| 142 |
}; |
| 143 |
|
| 144 |
struct dprc_cmd_get_irq_status { |
| 145 |
__le32 status; |
| 146 |
u8 irq_index; |
| 147 |
}; |
| 148 |
|
| 149 |
struct dprc_rsp_get_irq_status { |
| 150 |
__le32 status; |
| 151 |
}; |
| 152 |
|
| 153 |
struct dprc_cmd_clear_irq_status { |
| 154 |
__le32 status; |
| 155 |
u8 irq_index; |
| 156 |
}; |
| 157 |
|
| 158 |
struct dprc_rsp_get_attributes { |
| 159 |
/* response word 0 */ |
| 160 |
__le32 container_id; |
| 161 |
__le32 icid; |
| 162 |
/* response word 1 */ |
| 163 |
__le32 options; |
| 164 |
__le32 portal_id; |
| 165 |
}; |
| 166 |
|
| 167 |
struct dprc_rsp_get_obj_count { |
| 168 |
__le32 pad; |
| 169 |
__le32 obj_count; |
| 170 |
}; |
| 171 |
|
| 172 |
struct dprc_cmd_get_obj { |
| 173 |
__le32 obj_index; |
| 174 |
}; |
| 175 |
|
| 176 |
struct dprc_rsp_get_obj { |
| 177 |
/* response word 0 */ |
| 178 |
__le32 pad0; |
| 179 |
__le32 id; |
| 180 |
/* response word 1 */ |
| 181 |
__le16 vendor; |
| 182 |
u8 irq_count; |
| 183 |
u8 region_count; |
| 184 |
__le32 state; |
| 185 |
/* response word 2 */ |
| 186 |
__le16 version_major; |
| 187 |
__le16 version_minor; |
| 188 |
__le16 flags; |
| 189 |
__le16 pad1; |
| 190 |
/* response word 3-4 */ |
| 191 |
u8 type[16]; |
| 192 |
/* response word 5-6 */ |
| 193 |
u8 label[16]; |
| 194 |
}; |
| 195 |
|
| 196 |
struct dprc_cmd_get_obj_region { |
| 197 |
/* cmd word 0 */ |
| 198 |
__le32 obj_id; |
| 199 |
__le16 pad0; |
| 200 |
u8 region_index; |
| 201 |
u8 pad1; |
| 202 |
/* cmd word 1-2 */ |
| 203 |
__le64 pad2[2]; |
| 204 |
/* cmd word 3-4 */ |
| 205 |
u8 obj_type[16]; |
| 206 |
}; |
| 207 |
|
| 208 |
struct dprc_rsp_get_obj_region { |
| 209 |
/* response word 0 */ |
| 210 |
__le64 pad0; |
| 211 |
/* response word 1 */ |
| 212 |
__le64 base_offset; |
| 213 |
/* response word 2 */ |
| 214 |
__le32 size; |
| 215 |
u8 type; |
| 216 |
u8 pad2[3]; |
| 217 |
/* response word 3 */ |
| 218 |
__le32 flags; |
| 219 |
__le32 pad3; |
| 220 |
/* response word 4 */ |
| 221 |
/* base_addr may be zero if older MC firmware is used */ |
| 222 |
__le64 base_addr; |
| 223 |
}; |
| 224 |
|
| 225 |
struct dprc_cmd_set_obj_irq { |
| 226 |
/* cmd word 0 */ |
| 227 |
__le32 irq_val; |
| 228 |
u8 irq_index; |
| 229 |
u8 pad[3]; |
| 230 |
/* cmd word 1 */ |
| 231 |
__le64 irq_addr; |
| 232 |
/* cmd word 2 */ |
| 233 |
__le32 irq_num; |
| 234 |
__le32 obj_id; |
| 235 |
/* cmd word 3-4 */ |
| 236 |
u8 obj_type[16]; |
| 237 |
}; |
| 238 |
|
| 239 |
struct dprc_cmd_get_connection { |
| 240 |
__le32 ep1_id; |
| 241 |
__le16 ep1_interface_id; |
| 242 |
u8 pad[2]; |
| 243 |
u8 ep1_type[16]; |
| 244 |
}; |
| 245 |
|
| 246 |
struct dprc_rsp_get_connection { |
| 247 |
__le64 pad[3]; |
| 248 |
__le32 ep2_id; |
| 249 |
__le16 ep2_interface_id; |
| 250 |
__le16 pad1; |
| 251 |
u8 ep2_type[16]; |
| 252 |
__le32 state; |
| 253 |
}; |
| 254 |
|
| 255 |
/* |
| 256 |
* DPRC API for managing and querying DPAA resources |
| 257 |
*/ |
| 258 |
int dprc_open(struct fsl_mc_io *mc_io, |
| 259 |
u32 cmd_flags, |
| 260 |
int container_id, |
| 261 |
u16 *token); |
| 262 |
|
| 263 |
int dprc_close(struct fsl_mc_io *mc_io, |
| 264 |
u32 cmd_flags, |
| 265 |
u16 token); |
| 266 |
|
| 267 |
/* DPRC IRQ events */ |
| 268 |
|
| 269 |
/* IRQ event - Indicates that a new object added to the container */ |
| 270 |
#define DPRC_IRQ_EVENT_OBJ_ADDED 0x00000001 |
| 271 |
/* IRQ event - Indicates that an object was removed from the container */ |
| 272 |
#define DPRC_IRQ_EVENT_OBJ_REMOVED 0x00000002 |
| 273 |
/* |
| 274 |
* IRQ event - Indicates that one of the descendant containers that opened by |
| 275 |
* this container is destroyed |
| 276 |
*/ |
| 277 |
#define DPRC_IRQ_EVENT_CONTAINER_DESTROYED 0x00000010 |
| 278 |
|
| 279 |
/* |
| 280 |
* IRQ event - Indicates that on one of the container's opened object is |
| 281 |
* destroyed |
| 282 |
*/ |
| 283 |
#define DPRC_IRQ_EVENT_OBJ_DESTROYED 0x00000020 |
| 284 |
|
| 285 |
/* Irq event - Indicates that object is created at the container */ |
| 286 |
#define DPRC_IRQ_EVENT_OBJ_CREATED 0x00000040 |
| 287 |
|
| 288 |
/** |
| 289 |
* struct dprc_irq_cfg - IRQ configuration |
| 290 |
* @paddr: Address that must be written to signal a message-based interrupt |
| 291 |
* @val: Value to write into irq_addr address |
| 292 |
* @irq_num: A user defined number associated with this IRQ |
| 293 |
*/ |
| 294 |
struct dprc_irq_cfg { |
| 295 |
phys_addr_t paddr; |
| 296 |
u32 val; |
| 297 |
int irq_num; |
| 298 |
}; |
| 299 |
|
| 300 |
int dprc_set_irq(struct fsl_mc_io *mc_io, |
| 301 |
u32 cmd_flags, |
| 302 |
u16 token, |
| 303 |
u8 irq_index, |
| 304 |
struct dprc_irq_cfg *irq_cfg); |
| 305 |
|
| 306 |
int dprc_set_irq_enable(struct fsl_mc_io *mc_io, |
| 307 |
u32 cmd_flags, |
| 308 |
u16 token, |
| 309 |
u8 irq_index, |
| 310 |
u8 en); |
| 311 |
|
| 312 |
int dprc_set_irq_mask(struct fsl_mc_io *mc_io, |
| 313 |
u32 cmd_flags, |
| 314 |
u16 token, |
| 315 |
u8 irq_index, |
| 316 |
u32 mask); |
| 317 |
|
| 318 |
int dprc_get_irq_status(struct fsl_mc_io *mc_io, |
| 319 |
u32 cmd_flags, |
| 320 |
u16 token, |
| 321 |
u8 irq_index, |
| 322 |
u32 *status); |
| 323 |
|
| 324 |
int dprc_clear_irq_status(struct fsl_mc_io *mc_io, |
| 325 |
u32 cmd_flags, |
| 326 |
u16 token, |
| 327 |
u8 irq_index, |
| 328 |
u32 status); |
| 329 |
|
| 330 |
/** |
| 331 |
* struct dprc_attributes - Container attributes |
| 332 |
* @container_id: Container's ID |
| 333 |
* @icid: Container's ICID |
| 334 |
* @portal_id: Container's portal ID |
| 335 |
* @options: Container's options as set at container's creation |
| 336 |
*/ |
| 337 |
struct dprc_attributes { |
| 338 |
int container_id; |
| 339 |
u32 icid; |
| 340 |
int portal_id; |
| 341 |
u64 options; |
| 342 |
}; |
| 343 |
|
| 344 |
int dprc_get_attributes(struct fsl_mc_io *mc_io, |
| 345 |
u32 cmd_flags, |
| 346 |
u16 token, |
| 347 |
struct dprc_attributes *attributes); |
| 348 |
|
| 349 |
int dprc_get_obj_count(struct fsl_mc_io *mc_io, |
| 350 |
u32 cmd_flags, |
| 351 |
u16 token, |
| 352 |
int *obj_count); |
| 353 |
|
| 354 |
int dprc_get_obj(struct fsl_mc_io *mc_io, |
| 355 |
u32 cmd_flags, |
| 356 |
u16 token, |
| 357 |
int obj_index, |
| 358 |
struct fsl_mc_obj_desc *obj_desc); |
| 359 |
|
| 360 |
int dprc_set_obj_irq(struct fsl_mc_io *mc_io, |
| 361 |
u32 cmd_flags, |
| 362 |
u16 token, |
| 363 |
char *obj_type, |
| 364 |
int obj_id, |
| 365 |
u8 irq_index, |
| 366 |
struct dprc_irq_cfg *irq_cfg); |
| 367 |
/** |
| 368 |
* enum dprc_region_type - Region type |
| 369 |
* @DPRC_REGION_TYPE_MC_PORTAL: MC portal region |
| 370 |
* @DPRC_REGION_TYPE_QBMAN_PORTAL: Qbman portal region |
| 371 |
*/ |
| 372 |
enum dprc_region_type { |
| 373 |
DPRC_REGION_TYPE_MC_PORTAL, |
| 374 |
DPRC_REGION_TYPE_QBMAN_PORTAL, |
| 375 |
DPRC_REGION_TYPE_QBMAN_MEM_BACKED_PORTAL |
| 376 |
}; |
| 377 |
|
| 378 |
/** |
| 379 |
* struct dprc_region_desc - Mappable region descriptor |
| 380 |
* @base_offset: Region offset from region's base address. |
| 381 |
* For DPMCP and DPRC objects, region base is offset from SoC MC portals |
| 382 |
* base address; For DPIO, region base is offset from SoC QMan portals |
| 383 |
* base address |
| 384 |
* @size: Region size (in bytes) |
| 385 |
* @flags: Region attributes |
| 386 |
* @type: Portal region type |
| 387 |
*/ |
| 388 |
struct dprc_region_desc { |
| 389 |
u32 base_offset; |
| 390 |
u32 size; |
| 391 |
u32 flags; |
| 392 |
enum dprc_region_type type; |
| 393 |
u64 base_address; |
| 394 |
}; |
| 395 |
|
| 396 |
int dprc_get_obj_region(struct fsl_mc_io *mc_io, |
| 397 |
u32 cmd_flags, |
| 398 |
u16 token, |
| 399 |
char *obj_type, |
| 400 |
int obj_id, |
| 401 |
u8 region_index, |
| 402 |
struct dprc_region_desc *region_desc); |
| 403 |
|
| 404 |
int dprc_get_api_version(struct fsl_mc_io *mc_io, |
| 405 |
u32 cmd_flags, |
| 406 |
u16 *major_ver, |
| 407 |
u16 *minor_ver); |
| 408 |
|
| 409 |
int dprc_get_container_id(struct fsl_mc_io *mc_io, |
| 410 |
u32 cmd_flags, |
| 411 |
int *container_id); |
| 412 |
|
| 413 |
/** |
| 414 |
* struct dprc_endpoint - Endpoint description for link connect/disconnect |
| 415 |
* operations |
| 416 |
* @type: Endpoint object type: NULL terminated string |
| 417 |
* @id: Endpoint object ID |
| 418 |
* @if_id: Interface ID; should be set for endpoints with multiple |
| 419 |
* interfaces ("dpsw", "dpdmux"); for others, always set to 0 |
| 420 |
*/ |
| 421 |
struct dprc_endpoint { |
| 422 |
char type[16]; |
| 423 |
int id; |
| 424 |
u16 if_id; |
| 425 |
}; |
| 426 |
|
| 427 |
int dprc_get_connection(struct fsl_mc_io *mc_io, |
| 428 |
u32 cmd_flags, |
| 429 |
u16 token, |
| 430 |
const struct dprc_endpoint *endpoint1, |
| 431 |
struct dprc_endpoint *endpoint2, |
| 432 |
int *state); |
| 433 |
|
| 434 |
/* |
| 435 |
* Data Path Buffer Pool (DPBP) API |
| 436 |
*/ |
| 437 |
|
| 438 |
/* DPBP Version */ |
| 439 |
#define DPBP_VER_MAJOR 3 |
| 440 |
#define DPBP_VER_MINOR 2 |
| 441 |
|
| 442 |
/* Command versioning */ |
| 443 |
#define DPBP_CMD_BASE_VERSION 1 |
| 444 |
#define DPBP_CMD_ID_OFFSET 4 |
| 445 |
|
| 446 |
#define DPBP_CMD(id) (((id) << DPBP_CMD_ID_OFFSET) | DPBP_CMD_BASE_VERSION) |
| 447 |
|
| 448 |
/* Command IDs */ |
| 449 |
#define DPBP_CMDID_CLOSE DPBP_CMD(0x800) |
| 450 |
|
| 451 |
#define DPBP_CMDID_ENABLE DPBP_CMD(0x002) |
| 452 |
#define DPBP_CMDID_DISABLE DPBP_CMD(0x003) |
| 453 |
#define DPBP_CMDID_GET_ATTR DPBP_CMD(0x004) |
| 454 |
#define DPBP_CMDID_RESET DPBP_CMD(0x005) |
| 455 |
|
| 456 |
struct dpbp_cmd_open { |
| 457 |
__le32 dpbp_id; |
| 458 |
}; |
| 459 |
|
| 460 |
#define DPBP_ENABLE 0x1 |
| 461 |
|
| 462 |
struct dpbp_rsp_get_attributes { |
| 463 |
/* response word 0 */ |
| 464 |
__le16 pad; |
| 465 |
__le16 bpid; |
| 466 |
__le32 id; |
| 467 |
/* response word 1 */ |
| 468 |
__le16 version_major; |
| 469 |
__le16 version_minor; |
| 470 |
}; |
| 471 |
|
| 472 |
/* |
| 473 |
* Data Path Concentrator (DPCON) API |
| 474 |
*/ |
| 475 |
|
| 476 |
/* DPCON Version */ |
| 477 |
#define DPCON_VER_MAJOR 3 |
| 478 |
#define DPCON_VER_MINOR 2 |
| 479 |
|
| 480 |
/* Command versioning */ |
| 481 |
#define DPCON_CMD_BASE_VERSION 1 |
| 482 |
#define DPCON_CMD_ID_OFFSET 4 |
| 483 |
|
| 484 |
#define DPCON_CMD(id) (((id) << DPCON_CMD_ID_OFFSET) | DPCON_CMD_BASE_VERSION) |
| 485 |
|
| 486 |
/* Command IDs */ |
| 487 |
#define DPCON_CMDID_CLOSE DPCON_CMD(0x800) |
| 488 |
|
| 489 |
#define DPCON_CMDID_ENABLE DPCON_CMD(0x002) |
| 490 |
#define DPCON_CMDID_DISABLE DPCON_CMD(0x003) |
| 491 |
#define DPCON_CMDID_GET_ATTR DPCON_CMD(0x004) |
| 492 |
#define DPCON_CMDID_RESET DPCON_CMD(0x005) |
| 493 |
|
| 494 |
#define DPCON_CMDID_SET_NOTIFICATION DPCON_CMD(0x100) |
| 495 |
|
| 496 |
struct dpcon_cmd_open { |
| 497 |
__le32 dpcon_id; |
| 498 |
}; |
| 499 |
|
| 500 |
#define DPCON_ENABLE 1 |
| 501 |
|
| 502 |
struct dpcon_rsp_get_attr { |
| 503 |
/* response word 0 */ |
| 504 |
__le32 id; |
| 505 |
__le16 qbman_ch_id; |
| 506 |
u8 num_priorities; |
| 507 |
u8 pad; |
| 508 |
}; |
| 509 |
|
| 510 |
struct dpcon_cmd_set_notification { |
| 511 |
/* cmd word 0 */ |
| 512 |
__le32 dpio_id; |
| 513 |
u8 priority; |
| 514 |
u8 pad[3]; |
| 515 |
/* cmd word 1 */ |
| 516 |
__le64 user_ctx; |
| 517 |
}; |
| 518 |
|
| 519 |
/* |
| 520 |
* Generic FSL MC API |
| 521 |
*/ |
| 522 |
|
| 523 |
/* generic command versioning */ |
| 524 |
#define OBJ_CMD_BASE_VERSION 1 |
| 525 |
#define OBJ_CMD_ID_OFFSET 4 |
| 526 |
|
| 527 |
#define OBJ_CMD(id) (((id) << OBJ_CMD_ID_OFFSET) | OBJ_CMD_BASE_VERSION) |
| 528 |
|
| 529 |
/* open command codes */ |
| 530 |
#define DPRTC_CMDID_OPEN OBJ_CMD(0x810) |
| 531 |
#define DPNI_CMDID_OPEN OBJ_CMD(0x801) |
| 532 |
#define DPSW_CMDID_OPEN OBJ_CMD(0x802) |
| 533 |
#define DPIO_CMDID_OPEN OBJ_CMD(0x803) |
| 534 |
#define DPBP_CMDID_OPEN OBJ_CMD(0x804) |
| 535 |
#define DPRC_CMDID_OPEN OBJ_CMD(0x805) |
| 536 |
#define DPDMUX_CMDID_OPEN OBJ_CMD(0x806) |
| 537 |
#define DPCI_CMDID_OPEN OBJ_CMD(0x807) |
| 538 |
#define DPCON_CMDID_OPEN OBJ_CMD(0x808) |
| 539 |
#define DPSECI_CMDID_OPEN OBJ_CMD(0x809) |
| 540 |
#define DPAIOP_CMDID_OPEN OBJ_CMD(0x80a) |
| 541 |
#define DPMCP_CMDID_OPEN OBJ_CMD(0x80b) |
| 542 |
#define DPMAC_CMDID_OPEN OBJ_CMD(0x80c) |
| 543 |
#define DPDCEI_CMDID_OPEN OBJ_CMD(0x80d) |
| 544 |
#define DPDMAI_CMDID_OPEN OBJ_CMD(0x80e) |
| 545 |
#define DPDBG_CMDID_OPEN OBJ_CMD(0x80f) |
| 546 |
|
| 547 |
/* Generic object command IDs */ |
| 548 |
#define OBJ_CMDID_CLOSE OBJ_CMD(0x800) |
| 549 |
#define OBJ_CMDID_RESET OBJ_CMD(0x005) |
| 550 |
|
| 551 |
struct fsl_mc_obj_cmd_open { |
| 552 |
__le32 obj_id; |
| 553 |
}; |
| 554 |
|
| 555 |
/** |
| 556 |
* struct fsl_mc_resource_pool - Pool of MC resources of a given |
| 557 |
* type |
| 558 |
* @type: type of resources in the pool |
| 559 |
* @max_count: maximum number of resources in the pool |
| 560 |
* @free_count: number of free resources in the pool |
| 561 |
* @mutex: mutex to serialize access to the pool's free list |
| 562 |
* @free_list: anchor node of list of free resources in the pool |
| 563 |
* @mc_bus: pointer to the MC bus that owns this resource pool |
| 564 |
*/ |
| 565 |
struct fsl_mc_resource_pool { |
| 566 |
enum fsl_mc_pool_type type; |
| 567 |
int max_count; |
| 568 |
int free_count; |
| 569 |
struct mutex mutex; /* serializes access to free_list */ |
| 570 |
struct list_head free_list; |
| 571 |
struct fsl_mc_bus *mc_bus; |
| 572 |
}; |
| 573 |
|
| 574 |
/** |
| 575 |
* struct fsl_mc_uapi - information associated with a device file |
| 576 |
* @misc: struct miscdevice linked to the root dprc |
| 577 |
* @device: newly created device in /dev |
| 578 |
* @mutex: mutex lock to serialize the open/release operations |
| 579 |
* @local_instance_in_use: local MC I/O instance in use or not |
| 580 |
* @static_mc_io: pointer to the static MC I/O object |
| 581 |
*/ |
| 582 |
struct fsl_mc_uapi { |
| 583 |
struct miscdevice misc; |
| 584 |
struct device *device; |
| 585 |
struct mutex mutex; /* serialize open/release operations */ |
| 586 |
u32 local_instance_in_use; |
| 587 |
struct fsl_mc_io *static_mc_io; |
| 588 |
}; |
| 589 |
|
| 590 |
/** |
| 591 |
* struct fsl_mc_bus - logical bus that corresponds to a physical DPRC |
| 592 |
* @mc_dev: fsl-mc device for the bus device itself. |
| 593 |
* @resource_pools: array of resource pools (one pool per resource type) |
| 594 |
* for this MC bus. These resources represent allocatable entities |
| 595 |
* from the physical DPRC. |
| 596 |
* @irq_resources: Pointer to array of IRQ objects for the IRQ pool |
| 597 |
* @scan_mutex: Serializes bus scanning |
| 598 |
* @dprc_attr: DPRC attributes |
| 599 |
* @uapi_misc: struct that abstracts the interaction with userspace |
| 600 |
*/ |
| 601 |
struct fsl_mc_bus { |
| 602 |
struct fsl_mc_device mc_dev; |
| 603 |
struct fsl_mc_resource_pool resource_pools[FSL_MC_NUM_POOL_TYPES]; |
| 604 |
struct fsl_mc_device_irq *irq_resources; |
| 605 |
struct mutex scan_mutex; /* serializes bus scanning */ |
| 606 |
struct dprc_attributes dprc_attr; |
| 607 |
struct fsl_mc_uapi uapi_misc; |
| 608 |
int irq_enabled; |
| 609 |
}; |
| 610 |
|
| 611 |
#define to_fsl_mc_bus(_mc_dev) \ |
| 612 |
container_of(_mc_dev, struct fsl_mc_bus, mc_dev) |
| 613 |
|
| 614 |
int __must_check fsl_mc_device_add(struct fsl_mc_obj_desc *obj_desc, |
| 615 |
struct fsl_mc_io *mc_io, |
| 616 |
struct device *parent_dev, |
| 617 |
struct fsl_mc_device **new_mc_dev); |
| 618 |
|
| 619 |
void fsl_mc_device_remove(struct fsl_mc_device *mc_dev); |
| 620 |
|
| 621 |
int __init dprc_driver_init(void); |
| 622 |
|
| 623 |
void dprc_driver_exit(void); |
| 624 |
|
| 625 |
int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev, |
| 626 |
bool alloc_interrupts); |
| 627 |
|
| 628 |
int __init fsl_mc_allocator_driver_init(void); |
| 629 |
|
| 630 |
void fsl_mc_init_all_resource_pools(struct fsl_mc_device *mc_bus_dev); |
| 631 |
|
| 632 |
int __must_check fsl_mc_resource_allocate(struct fsl_mc_bus *mc_bus, |
| 633 |
enum fsl_mc_pool_type pool_type, |
| 634 |
struct fsl_mc_resource |
| 635 |
**new_resource); |
| 636 |
|
| 637 |
void fsl_mc_resource_free(struct fsl_mc_resource *resource); |
| 638 |
|
| 639 |
int fsl_mc_msi_domain_alloc_irqs(struct device *dev, |
| 640 |
unsigned int irq_count); |
| 641 |
|
| 642 |
void fsl_mc_msi_domain_free_irqs(struct device *dev); |
| 643 |
|
| 644 |
struct irq_domain *fsl_mc_find_msi_domain(struct device *dev); |
| 645 |
|
| 646 |
int __must_check fsl_create_mc_io(struct device *dev, |
| 647 |
phys_addr_t mc_portal_phys_addr, |
| 648 |
u32 mc_portal_size, |
| 649 |
struct fsl_mc_device *dpmcp_dev, |
| 650 |
u32 flags, struct fsl_mc_io **new_mc_io); |
| 651 |
|
| 652 |
void fsl_destroy_mc_io(struct fsl_mc_io *mc_io); |
| 653 |
|
| 654 |
bool fsl_mc_is_root_dprc(struct device *dev); |
| 655 |
|
| 656 |
void fsl_mc_get_root_dprc(struct device *dev, |
| 657 |
struct device **root_dprc_dev); |
| 658 |
|
| 659 |
struct fsl_mc_device *fsl_mc_device_lookup(struct fsl_mc_obj_desc *obj_desc, |
| 660 |
struct fsl_mc_device *mc_bus_dev); |
| 661 |
|
| 662 |
u16 mc_cmd_hdr_read_cmdid(struct fsl_mc_command *cmd); |
| 663 |
|
| 664 |
#ifdef CONFIG_FSL_MC_UAPI_SUPPORT |
| 665 |
|
| 666 |
int fsl_mc_uapi_create_device_file(struct fsl_mc_bus *mc_bus); |
| 667 |
|
| 668 |
void fsl_mc_uapi_remove_device_file(struct fsl_mc_bus *mc_bus); |
| 669 |
|
| 670 |
#else |
| 671 |
|
| 672 |
static inline int fsl_mc_uapi_create_device_file(struct fsl_mc_bus *mc_bus) |
| 673 |
{ |
| 674 |
return 0; |
| 675 |
} |
| 676 |
|
| 677 |
static inline void fsl_mc_uapi_remove_device_file(struct fsl_mc_bus *mc_bus) |
| 678 |
{ |
| 679 |
} |
| 680 |
|
| 681 |
#endif |
| 682 |
|
| 683 |
int disable_dprc_irq(struct fsl_mc_device *mc_dev); |
| 684 |
int enable_dprc_irq(struct fsl_mc_device *mc_dev); |
| 685 |
int get_dprc_irq_state(struct fsl_mc_device *mc_dev); |
| 686 |
|
| 687 |
#endif /* _FSL_MC_PRIVATE_H_ */ |