/* SPDX-License-Identifier: GPL-2.01*2* Driver for AMD network controllers and boards3*4* Copyright (C) 2021, Xilinx, Inc.5* Copyright (C) 2022-2023, Advanced Micro Devices, Inc.6*/78#ifndef MC_CDX_PCOL_H9#define MC_CDX_PCOL_H1011/* The current version of the MCDI protocol. */12#define MCDI_PCOL_VERSION 21314/*15* Each MCDI request starts with an MCDI_HEADER, which is a 32bit16* structure, filled in by the client.17*18* 0 7 8 16 20 22 23 24 3119* | CODE | R | LEN | SEQ | Rsvd | E | R | XFLAGS |20* | | |21* | | \--- Response22* | \------- Error23* \------------------------------ Resync (always set)24*25* The client writes its request into MC shared memory, and rings the26* doorbell. Each request is completed either by the MC writing27* back into shared memory, or by writing out an event.28*29* All MCDI commands support completion by shared memory response. Each30* request may also contain additional data (accounted for by HEADER.LEN),31* and some responses may also contain additional data (again, accounted32* for by HEADER.LEN).33*34* Some MCDI commands support completion by event, in which any associated35* response data is included in the event.36*37* The protocol requires one response to be delivered for every request; a38* request should not be sent unless the response for the previous request39* has been received (either by polling shared memory, or by receiving40* an event).41*/4243/** Request/Response structure */44#define MCDI_HEADER_OFST 045#define MCDI_HEADER_CODE_LBN 046#define MCDI_HEADER_CODE_WIDTH 747#define MCDI_HEADER_RESYNC_LBN 748#define MCDI_HEADER_RESYNC_WIDTH 149#define MCDI_HEADER_DATALEN_LBN 850#define MCDI_HEADER_DATALEN_WIDTH 851#define MCDI_HEADER_SEQ_LBN 1652#define MCDI_HEADER_SEQ_WIDTH 453#define MCDI_HEADER_RSVD_LBN 2054#define MCDI_HEADER_RSVD_WIDTH 155#define MCDI_HEADER_NOT_EPOCH_LBN 2156#define MCDI_HEADER_NOT_EPOCH_WIDTH 157#define MCDI_HEADER_ERROR_LBN 2258#define MCDI_HEADER_ERROR_WIDTH 159#define MCDI_HEADER_RESPONSE_LBN 2360#define MCDI_HEADER_RESPONSE_WIDTH 161#define MCDI_HEADER_XFLAGS_LBN 2462#define MCDI_HEADER_XFLAGS_WIDTH 863/* Request response using event */64#define MCDI_HEADER_XFLAGS_EVREQ 0x0165/* Request (and signal) early doorbell return */66#define MCDI_HEADER_XFLAGS_DBRET 0x026768/* Maximum number of payload bytes */69#define MCDI_CTL_SDU_LEN_MAX_V2 0x4007071#define MCDI_CTL_SDU_LEN_MAX MCDI_CTL_SDU_LEN_MAX_V27273/*74* The MC can generate events for two reasons:75* - To advance a shared memory request if XFLAGS_EVREQ was set76* - As a notification (link state, i2c event), controlled77* via MC_CMD_LOG_CTRL78*79* Both events share a common structure:80*81* 0 32 33 36 44 52 6082* | Data | Cont | Level | Src | Code | Rsvd |83* |84* \ There is another event pending in this notification85*86* If Code==CMDDONE, then the fields are further interpreted as:87*88* - LEVEL==INFO Command succeeded89* - LEVEL==ERR Command failed90*91* 0 8 16 24 3292* | Seq | Datalen | Errno | Rsvd |93*94* These fields are taken directly out of the standard MCDI header, i.e.,95* LEVEL==ERR, Datalen == 0 => Reboot96*97* Events can be squirted out of the UART (using LOG_CTRL) without a98* MCDI header. An event can be distinguished from a MCDI response by99* examining the first byte which is 0xc0. This corresponds to the100* non-existent MCDI command MC_CMD_DEBUG_LOG.101*102* 0 7 8103* | command | Resync | = 0xc0104*105* Since the event is written in big-endian byte order, this works106* providing bits 56-63 of the event are 0xc0.107*108* 56 60 63109* | Rsvd | Code | = 0xc0110*111* Which means for convenience the event code is 0xc for all MC112* generated events.113*/114115/*116* the errno value may be followed by the (0-based) number of the117* first argument that could not be processed.118*/119#define MC_CMD_ERR_ARG_OFST 4120121/* MC_CMD_ERR MCDI error codes. */122/* Operation not permitted. */123#define MC_CMD_ERR_EPERM 0x1124/* Non-existent command target */125#define MC_CMD_ERR_ENOENT 0x2126/* assert() has killed the MC */127#define MC_CMD_ERR_EINTR 0x4128/* I/O failure */129#define MC_CMD_ERR_EIO 0x5130/* Already exists */131#define MC_CMD_ERR_EEXIST 0x6132/* Try again */133#define MC_CMD_ERR_EAGAIN 0xb134/* Out of memory */135#define MC_CMD_ERR_ENOMEM 0xc136/* Caller does not hold required locks */137#define MC_CMD_ERR_EACCES 0xd138/* Resource is currently unavailable (e.g. lock contention) */139#define MC_CMD_ERR_EBUSY 0x10140/* No such device */141#define MC_CMD_ERR_ENODEV 0x13142/* Invalid argument to target */143#define MC_CMD_ERR_EINVAL 0x16144/* No space */145#define MC_CMD_ERR_ENOSPC 0x1c146/* Read-only */147#define MC_CMD_ERR_EROFS 0x1e148/* Broken pipe */149#define MC_CMD_ERR_EPIPE 0x20150/* Out of range */151#define MC_CMD_ERR_ERANGE 0x22152/* Non-recursive resource is already acquired */153#define MC_CMD_ERR_EDEADLK 0x23154/* Operation not implemented */155#define MC_CMD_ERR_ENOSYS 0x26156/* Operation timed out */157#define MC_CMD_ERR_ETIME 0x3e158/* Link has been severed */159#define MC_CMD_ERR_ENOLINK 0x43160/* Protocol error */161#define MC_CMD_ERR_EPROTO 0x47162/* Bad message */163#define MC_CMD_ERR_EBADMSG 0x4a164/* Operation not supported */165#define MC_CMD_ERR_ENOTSUP 0x5f166/* Address not available */167#define MC_CMD_ERR_EADDRNOTAVAIL 0x63168/* Not connected */169#define MC_CMD_ERR_ENOTCONN 0x6b170/* Operation already in progress */171#define MC_CMD_ERR_EALREADY 0x72172/* Stale handle. The handle references resource that no longer exists */173#define MC_CMD_ERR_ESTALE 0x74174/* Resource allocation failed. */175#define MC_CMD_ERR_ALLOC_FAIL 0x1000176/* V-adaptor not found. */177#define MC_CMD_ERR_NO_VADAPTOR 0x1001178/* EVB port not found. */179#define MC_CMD_ERR_NO_EVB_PORT 0x1002180/* V-switch not found. */181#define MC_CMD_ERR_NO_VSWITCH 0x1003182/* Too many VLAN tags. */183#define MC_CMD_ERR_VLAN_LIMIT 0x1004184/* Bad PCI function number. */185#define MC_CMD_ERR_BAD_PCI_FUNC 0x1005186/* Invalid VLAN mode. */187#define MC_CMD_ERR_BAD_VLAN_MODE 0x1006188/* Invalid v-switch type. */189#define MC_CMD_ERR_BAD_VSWITCH_TYPE 0x1007190/* Invalid v-port type. */191#define MC_CMD_ERR_BAD_VPORT_TYPE 0x1008192/* MAC address exists. */193#define MC_CMD_ERR_MAC_EXIST 0x1009194/* Slave core not present */195#define MC_CMD_ERR_SLAVE_NOT_PRESENT 0x100a196/* The datapath is disabled. */197#define MC_CMD_ERR_DATAPATH_DISABLED 0x100b198/* The requesting client is not a function */199#define MC_CMD_ERR_CLIENT_NOT_FN 0x100c200/*201* The requested operation might require the command to be passed between202* MCs, and the transport doesn't support that. Should only ever been seen over203* the UART.204*/205#define MC_CMD_ERR_NO_PRIVILEGE 0x1013206/*207* Workaround 26807 could not be turned on/off because some functions208* have already installed filters. See the comment at209* MC_CMD_WORKAROUND_BUG26807. May also returned for other operations such as210* sub-variant switching.211*/212#define MC_CMD_ERR_FILTERS_PRESENT 0x1014213/* The clock whose frequency you've attempted to set doesn't exist */214#define MC_CMD_ERR_NO_CLOCK 0x1015215/*216* Returned by MC_CMD_TESTASSERT if the action that should have caused an217* assertion failed to do so.218*/219#define MC_CMD_ERR_UNREACHABLE 0x1016220/*221* This command needs to be processed in the background but there were no222* resources to do so. Send it again after a command has completed.223*/224#define MC_CMD_ERR_QUEUE_FULL 0x1017225/*226* The operation could not be completed because the PCIe link has gone227* away. This error code is never expected to be returned over the TLP228* transport.229*/230#define MC_CMD_ERR_NO_PCIE 0x1018231/*232* The operation could not be completed because the datapath has gone233* away. This is distinct from MC_CMD_ERR_DATAPATH_DISABLED in that the234* datapath absence may be temporary235*/236#define MC_CMD_ERR_NO_DATAPATH 0x1019237/* The operation could not complete because some VIs are allocated */238#define MC_CMD_ERR_VIS_PRESENT 0x101a239/*240* The operation could not complete because some PIO buffers are241* allocated242*/243#define MC_CMD_ERR_PIOBUFS_PRESENT 0x101b244245/***********************************/246/*247* MC_CMD_CDX_BUS_ENUM_BUSES248* CDX bus hosts devices (functions) that are implemented using the Composable249* DMA subsystem and directly mapped into the memory space of the FGPA PSX250* Application Processors (APUs). As such, they only apply to the PSX APU side,251* not the host (PCIe). Unlike PCIe, these devices have no native configuration252* space or enumeration mechanism, so this message set provides a minimal253* interface for discovery and management (bus reset, FLR, BME) of such254* devices. This command returns the number of CDX buses present in the system.255*/256#define MC_CMD_CDX_BUS_ENUM_BUSES 0x1257#define MC_CMD_CDX_BUS_ENUM_BUSES_MSGSET 0x1258#undef MC_CMD_0x1_PRIVILEGE_CTG259260#define MC_CMD_0x1_PRIVILEGE_CTG SRIOV_CTG_ADMIN261262/* MC_CMD_CDX_BUS_ENUM_BUSES_IN msgrequest */263#define MC_CMD_CDX_BUS_ENUM_BUSES_IN_LEN 0264265/* MC_CMD_CDX_BUS_ENUM_BUSES_OUT msgresponse */266#define MC_CMD_CDX_BUS_ENUM_BUSES_OUT_LEN 4267/*268* Number of CDX buses present in the system. Buses are numbered 0 to269* BUS_COUNT-1270*/271#define MC_CMD_CDX_BUS_ENUM_BUSES_OUT_BUS_COUNT_OFST 0272#define MC_CMD_CDX_BUS_ENUM_BUSES_OUT_BUS_COUNT_LEN 4273274/***********************************/275/*276* MC_CMD_CDX_BUS_ENUM_DEVICES277* Enumerate CDX bus devices on a given bus278*/279#define MC_CMD_CDX_BUS_ENUM_DEVICES 0x2280#define MC_CMD_CDX_BUS_ENUM_DEVICES_MSGSET 0x2281#undef MC_CMD_0x2_PRIVILEGE_CTG282283#define MC_CMD_0x2_PRIVILEGE_CTG SRIOV_CTG_ADMIN284285/* MC_CMD_CDX_BUS_ENUM_DEVICES_IN msgrequest */286#define MC_CMD_CDX_BUS_ENUM_DEVICES_IN_LEN 4287/*288* Bus number to enumerate, in range 0 to BUS_COUNT-1, as returned by289* MC_CMD_CDX_BUS_ENUM_BUSES_OUT290*/291#define MC_CMD_CDX_BUS_ENUM_DEVICES_IN_BUS_OFST 0292#define MC_CMD_CDX_BUS_ENUM_DEVICES_IN_BUS_LEN 4293294/* MC_CMD_CDX_BUS_ENUM_DEVICES_OUT msgresponse */295#define MC_CMD_CDX_BUS_ENUM_DEVICES_OUT_LEN 4296/*297* Number of devices present on the bus. Devices on the bus are numbered 0 to298* DEVICE_COUNT-1. Returns EAGAIN if number of devices unknown or if the target299* devices are not ready (e.g. undergoing a bus reset)300*/301#define MC_CMD_CDX_BUS_ENUM_DEVICES_OUT_DEVICE_COUNT_OFST 0302#define MC_CMD_CDX_BUS_ENUM_DEVICES_OUT_DEVICE_COUNT_LEN 4303304/***********************************/305/*306* MC_CMD_CDX_BUS_GET_DEVICE_CONFIG307* Returns device identification and MMIO/MSI resource data for a CDX device.308* The expected usage is for the caller to first retrieve the number of devices309* on the bus using MC_CMD_BUS_ENUM_DEVICES, then loop through the range (0,310* DEVICE_COUNT - 1), retrieving device resource data. May return EAGAIN if the311* number of exposed devices or device resources change during enumeration (due312* to e.g. a PL reload / bus reset), in which case the caller is expected to313* restart the enumeration loop. MMIO addresses are specified in terms of bus314* addresses (prior to any potential IOMMU translation). For versal-net, these315* are equivalent to APU physical addresses. Implementation note - for this to316* work, the implementation needs to keep state (generation count) per client.317*/318#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG 0x3319#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_MSGSET 0x3320#undef MC_CMD_0x3_PRIVILEGE_CTG321322#define MC_CMD_0x3_PRIVILEGE_CTG SRIOV_CTG_ADMIN323324/* MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_IN msgrequest */325#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_IN_LEN 8326/* Device bus number, in range 0 to BUS_COUNT-1 */327#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_IN_BUS_OFST 0328#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_IN_BUS_LEN 4329/* Device number relative to the bus, in range 0 to DEVICE_COUNT-1 for that bus */330#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_IN_DEVICE_OFST 4331#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_IN_DEVICE_LEN 4332333/* MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT msgresponse */334#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_LEN 88335/* 16-bit Vendor identifier, compliant with PCI-SIG VendorID assignment. */336#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_VENDOR_ID_OFST 0337#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_VENDOR_ID_LEN 2338/* 16-bit Device ID assigned by the vendor */339#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_DEVICE_ID_OFST 2340#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_DEVICE_ID_LEN 2341/*342* 16-bit Subsystem Vendor ID, , compliant with PCI-SIG VendorID assignment.343* For further device differentiation, as required. 0 if unused.344*/345#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_SUBSYS_VENDOR_ID_OFST 4346#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_SUBSYS_VENDOR_ID_LEN 2347/*348* 16-bit Subsystem Device ID assigned by the vendor. For further device349* differentiation, as required. 0 if unused.350*/351#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_SUBSYS_DEVICE_ID_OFST 6352#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_SUBSYS_DEVICE_ID_LEN 2353/* 24-bit Device Class code, compliant with PCI-SIG Device Class codes */354#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_DEVICE_CLASS_OFST 8355#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_DEVICE_CLASS_LEN 3356/* 8-bit vendor-assigned revision */357#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_DEVICE_REVISION_OFST 11358#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_DEVICE_REVISION_LEN 1359/* Reserved (alignment) */360#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_RESERVED_OFST 12361#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_RESERVED_LEN 4362/* MMIO region 0 base address (bus address), 0 if unused */363#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION0_BASE_OFST 16364#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION0_BASE_LEN 8365#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION0_BASE_LO_OFST 16366#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION0_BASE_LO_LEN 4367#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION0_BASE_LO_LBN 128368#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION0_BASE_LO_WIDTH 32369#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION0_BASE_HI_OFST 20370#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION0_BASE_HI_LEN 4371#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION0_BASE_HI_LBN 160372#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION0_BASE_HI_WIDTH 32373/* MMIO region 0 size, 0 if unused */374#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION0_SIZE_OFST 24375#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION0_SIZE_LEN 8376#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION0_SIZE_LO_OFST 24377#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION0_SIZE_LO_LEN 4378#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION0_SIZE_LO_LBN 192379#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION0_SIZE_LO_WIDTH 32380#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION0_SIZE_HI_OFST 28381#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION0_SIZE_HI_LEN 4382#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION0_SIZE_HI_LBN 224383#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION0_SIZE_HI_WIDTH 32384/* MMIO region 1 base address (bus address), 0 if unused */385#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION1_BASE_OFST 32386#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION1_BASE_LEN 8387#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION1_BASE_LO_OFST 32388#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION1_BASE_LO_LEN 4389#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION1_BASE_LO_LBN 256390#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION1_BASE_LO_WIDTH 32391#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION1_BASE_HI_OFST 36392#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION1_BASE_HI_LEN 4393#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION1_BASE_HI_LBN 288394#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION1_BASE_HI_WIDTH 32395/* MMIO region 1 size, 0 if unused */396#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION1_SIZE_OFST 40397#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION1_SIZE_LEN 8398#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION1_SIZE_LO_OFST 40399#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION1_SIZE_LO_LEN 4400#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION1_SIZE_LO_LBN 320401#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION1_SIZE_LO_WIDTH 32402#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION1_SIZE_HI_OFST 44403#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION1_SIZE_HI_LEN 4404#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION1_SIZE_HI_LBN 352405#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION1_SIZE_HI_WIDTH 32406/* MMIO region 2 base address (bus address), 0 if unused */407#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION2_BASE_OFST 48408#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION2_BASE_LEN 8409#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION2_BASE_LO_OFST 48410#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION2_BASE_LO_LEN 4411#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION2_BASE_LO_LBN 384412#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION2_BASE_LO_WIDTH 32413#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION2_BASE_HI_OFST 52414#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION2_BASE_HI_LEN 4415#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION2_BASE_HI_LBN 416416#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION2_BASE_HI_WIDTH 32417/* MMIO region 2 size, 0 if unused */418#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION2_SIZE_OFST 56419#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION2_SIZE_LEN 8420#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION2_SIZE_LO_OFST 56421#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION2_SIZE_LO_LEN 4422#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION2_SIZE_LO_LBN 448423#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION2_SIZE_LO_WIDTH 32424#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION2_SIZE_HI_OFST 60425#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION2_SIZE_HI_LEN 4426#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION2_SIZE_HI_LBN 480427#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION2_SIZE_HI_WIDTH 32428/* MMIO region 3 base address (bus address), 0 if unused */429#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION3_BASE_OFST 64430#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION3_BASE_LEN 8431#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION3_BASE_LO_OFST 64432#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION3_BASE_LO_LEN 4433#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION3_BASE_LO_LBN 512434#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION3_BASE_LO_WIDTH 32435#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION3_BASE_HI_OFST 68436#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION3_BASE_HI_LEN 4437#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION3_BASE_HI_LBN 544438#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION3_BASE_HI_WIDTH 32439/* MMIO region 3 size, 0 if unused */440#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION3_SIZE_OFST 72441#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION3_SIZE_LEN 8442#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION3_SIZE_LO_OFST 72443#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION3_SIZE_LO_LEN 4444#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION3_SIZE_LO_LBN 576445#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION3_SIZE_LO_WIDTH 32446#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION3_SIZE_HI_OFST 76447#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION3_SIZE_HI_LEN 4448#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION3_SIZE_HI_LBN 608449#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MMIO_REGION3_SIZE_HI_WIDTH 32450/* MSI vector count */451#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MSI_COUNT_OFST 80452#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_MSI_COUNT_LEN 4453/* Requester ID used by device (SMMU StreamID, GIC ITS DeviceID) */454#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_REQUESTER_ID_OFST 84455#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_REQUESTER_ID_LEN 4456457/* MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_V2 msgresponse */458#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_V2_LEN 92459/* Requester ID used by device for GIC ITS DeviceID */460#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_V2_REQUESTER_DEVICE_ID_OFST 88461#define MC_CMD_CDX_BUS_GET_DEVICE_CONFIG_OUT_V2_REQUESTER_DEVICE_ID_LEN 4462463/***********************************/464/*465* MC_CMD_CDX_BUS_DOWN466* Asserting reset on the CDX bus causes all devices on the bus to be quiesced.467* DMA bus mastering is disabled and any pending DMA request are flushed. Once468* the response is returned, the devices are guaranteed to no longer issue DMA469* requests or raise MSI interrupts. Further device MMIO accesses may have470* undefined results. While the bus reset is asserted, any of the enumeration471* or device configuration MCDIs will fail with EAGAIN. It is only legal to472* reload the relevant PL region containing CDX devices if the corresponding CDX473* bus is in reset. Depending on the implementation, the firmware may or may474* not enforce this restriction and it is up to the caller to make sure this475* requirement is satisfied.476*/477#define MC_CMD_CDX_BUS_DOWN 0x4478#define MC_CMD_CDX_BUS_DOWN_MSGSET 0x4479480/* MC_CMD_CDX_BUS_DOWN_IN msgrequest */481#define MC_CMD_CDX_BUS_DOWN_IN_LEN 4482/* Bus number to put in reset, in range 0 to BUS_COUNT-1 */483#define MC_CMD_CDX_BUS_DOWN_IN_BUS_OFST 0484#define MC_CMD_CDX_BUS_DOWN_IN_BUS_LEN 4485486/*487* MC_CMD_CDX_BUS_DOWN_OUT msgresponse: The bus is quiesced, no further488* upstream traffic for devices on this bus.489*/490#define MC_CMD_CDX_BUS_DOWN_OUT_LEN 0491492/***********************************/493/*494* MC_CMD_CDX_BUS_UP495* After bus reset is de-asserted, devices are in a state which is functionally496* equivalent to each device having been reset with MC_CMD_CDX_DEVICE_RESET. In497* other words, device logic is reset in a hardware-specific way, MMIO accesses498* are forwarded to the device, DMA bus mastering is disabled and needs to be499* re-enabled with MC_CMD_CDX_DEVICE_DMA_ENABLE once the driver is ready to500* start servicing DMA. If the underlying number of devices or device resources501* changed (e.g. if PL was reloaded) while the bus was in reset, the bus driver502* is expected to re-enumerate the bus. Returns EALREADY if the bus was already503* up before the call.504*/505#define MC_CMD_CDX_BUS_UP 0x5506#define MC_CMD_CDX_BUS_UP_MSGSET 0x5507508/* MC_CMD_CDX_BUS_UP_IN msgrequest */509#define MC_CMD_CDX_BUS_UP_IN_LEN 4510/* Bus number to take out of reset, in range 0 to BUS_COUNT-1 */511#define MC_CMD_CDX_BUS_UP_IN_BUS_OFST 0512#define MC_CMD_CDX_BUS_UP_IN_BUS_LEN 4513514/* MC_CMD_CDX_BUS_UP_OUT msgresponse: The bus can now be enumerated. */515#define MC_CMD_CDX_BUS_UP_OUT_LEN 0516517/***********************************/518/*519* MC_CMD_CDX_DEVICE_RESET520* After this call completes, device DMA and interrupts are quiesced, devices521* logic is reset in a hardware-specific way and DMA bus mastering is disabled.522*/523#define MC_CMD_CDX_DEVICE_RESET 0x6524#define MC_CMD_CDX_DEVICE_RESET_MSGSET 0x6525#undef MC_CMD_0x6_PRIVILEGE_CTG526527#define MC_CMD_0x6_PRIVILEGE_CTG SRIOV_CTG_ADMIN528529/* MC_CMD_CDX_DEVICE_RESET_IN msgrequest */530#define MC_CMD_CDX_DEVICE_RESET_IN_LEN 8531/* Device bus number, in range 0 to BUS_COUNT-1 */532#define MC_CMD_CDX_DEVICE_RESET_IN_BUS_OFST 0533#define MC_CMD_CDX_DEVICE_RESET_IN_BUS_LEN 4534/* Device number relative to the bus, in range 0 to DEVICE_COUNT-1 for that bus */535#define MC_CMD_CDX_DEVICE_RESET_IN_DEVICE_OFST 4536#define MC_CMD_CDX_DEVICE_RESET_IN_DEVICE_LEN 4537538/*539* MC_CMD_CDX_DEVICE_RESET_OUT msgresponse: The device is quiesced and all540* pending device initiated DMA has completed.541*/542#define MC_CMD_CDX_DEVICE_RESET_OUT_LEN 0543544/***********************************/545/*546* MC_CMD_CDX_DEVICE_CONTROL_SET547* If BUS_MASTER is set to disabled, device DMA and interrupts are quiesced.548* Pending DMA requests and MSI interrupts are flushed and no further DMA or549* interrupts are issued after this command returns. If BUS_MASTER is set to550* enabled, device is allowed to initiate DMA. Whether interrupts are enabled551* also depends on the value of MSI_ENABLE bit. Note that, in this case, the552* device may start DMA before the host receives and processes the MCDI553* response. MSI_ENABLE masks or unmasks device interrupts only. Note that for554* interrupts to be delivered to the host, both BUS_MASTER and MSI_ENABLE needs555* to be set. MMIO_REGIONS_ENABLE enables or disables host accesses to device556* MMIO regions. Note that an implementation is allowed to permanently set this557* bit to 1, in which case MC_CMD_CDX_DEVICE_CONTROL_GET will always return 1558* for this bit, regardless of the value set here.559*/560#define MC_CMD_CDX_DEVICE_CONTROL_SET 0x7561#define MC_CMD_CDX_DEVICE_CONTROL_SET_MSGSET 0x7562#undef MC_CMD_0x7_PRIVILEGE_CTG563564#define MC_CMD_0x7_PRIVILEGE_CTG SRIOV_CTG_ADMIN565566/* MC_CMD_CDX_DEVICE_CONTROL_SET_IN msgrequest */567#define MC_CMD_CDX_DEVICE_CONTROL_SET_IN_LEN 12568/* Device bus number, in range 0 to BUS_COUNT-1 */569#define MC_CMD_CDX_DEVICE_CONTROL_SET_IN_BUS_OFST 0570#define MC_CMD_CDX_DEVICE_CONTROL_SET_IN_BUS_LEN 4571/* Device number relative to the bus, in range 0 to DEVICE_COUNT-1 for that bus */572#define MC_CMD_CDX_DEVICE_CONTROL_SET_IN_DEVICE_OFST 4573#define MC_CMD_CDX_DEVICE_CONTROL_SET_IN_DEVICE_LEN 4574#define MC_CMD_CDX_DEVICE_CONTROL_SET_IN_FLAGS_OFST 8575#define MC_CMD_CDX_DEVICE_CONTROL_SET_IN_FLAGS_LEN 4576#define MC_CMD_CDX_DEVICE_CONTROL_SET_IN_BUS_MASTER_ENABLE_OFST 8577#define MC_CMD_CDX_DEVICE_CONTROL_SET_IN_BUS_MASTER_ENABLE_LBN 0578#define MC_CMD_CDX_DEVICE_CONTROL_SET_IN_BUS_MASTER_ENABLE_WIDTH 1579#define MC_CMD_CDX_DEVICE_CONTROL_SET_IN_MSI_ENABLE_OFST 8580#define MC_CMD_CDX_DEVICE_CONTROL_SET_IN_MSI_ENABLE_LBN 1581#define MC_CMD_CDX_DEVICE_CONTROL_SET_IN_MSI_ENABLE_WIDTH 1582#define MC_CMD_CDX_DEVICE_CONTROL_SET_IN_MMIO_REGIONS_ENABLE_OFST 8583#define MC_CMD_CDX_DEVICE_CONTROL_SET_IN_MMIO_REGIONS_ENABLE_LBN 2584#define MC_CMD_CDX_DEVICE_CONTROL_SET_IN_MMIO_REGIONS_ENABLE_WIDTH 1585586/* MC_CMD_CDX_DEVICE_CONTROL_SET_OUT msgresponse */587#define MC_CMD_CDX_DEVICE_CONTROL_SET_OUT_LEN 0588589/***********************************/590/*591* MC_CMD_CDX_DEVICE_CONTROL_GET592* Returns device DMA, interrupt and MMIO region access control bits. See593* MC_CMD_CDX_DEVICE_CONTROL_SET for definition of the available control bits.594*/595#define MC_CMD_CDX_DEVICE_CONTROL_GET 0x8596#define MC_CMD_CDX_DEVICE_CONTROL_GET_MSGSET 0x8597#undef MC_CMD_0x8_PRIVILEGE_CTG598599#define MC_CMD_0x8_PRIVILEGE_CTG SRIOV_CTG_ADMIN600601/* MC_CMD_CDX_DEVICE_CONTROL_GET_IN msgrequest */602#define MC_CMD_CDX_DEVICE_CONTROL_GET_IN_LEN 8603/* Device bus number, in range 0 to BUS_COUNT-1 */604#define MC_CMD_CDX_DEVICE_CONTROL_GET_IN_BUS_OFST 0605#define MC_CMD_CDX_DEVICE_CONTROL_GET_IN_BUS_LEN 4606/* Device number relative to the bus, in range 0 to DEVICE_COUNT-1 for that bus */607#define MC_CMD_CDX_DEVICE_CONTROL_GET_IN_DEVICE_OFST 4608#define MC_CMD_CDX_DEVICE_CONTROL_GET_IN_DEVICE_LEN 4609610/* MC_CMD_CDX_DEVICE_CONTROL_GET_OUT msgresponse */611#define MC_CMD_CDX_DEVICE_CONTROL_GET_OUT_LEN 4612#define MC_CMD_CDX_DEVICE_CONTROL_GET_OUT_FLAGS_OFST 0613#define MC_CMD_CDX_DEVICE_CONTROL_GET_OUT_FLAGS_LEN 4614#define MC_CMD_CDX_DEVICE_CONTROL_GET_OUT_BUS_MASTER_ENABLE_OFST 0615#define MC_CMD_CDX_DEVICE_CONTROL_GET_OUT_BUS_MASTER_ENABLE_LBN 0616#define MC_CMD_CDX_DEVICE_CONTROL_GET_OUT_BUS_MASTER_ENABLE_WIDTH 1617#define MC_CMD_CDX_DEVICE_CONTROL_GET_OUT_MSI_ENABLE_OFST 0618#define MC_CMD_CDX_DEVICE_CONTROL_GET_OUT_MSI_ENABLE_LBN 1619#define MC_CMD_CDX_DEVICE_CONTROL_GET_OUT_MSI_ENABLE_WIDTH 1620#define MC_CMD_CDX_DEVICE_CONTROL_GET_OUT_MMIO_REGIONS_ENABLE_OFST 0621#define MC_CMD_CDX_DEVICE_CONTROL_GET_OUT_MMIO_REGIONS_ENABLE_LBN 2622#define MC_CMD_CDX_DEVICE_CONTROL_GET_OUT_MMIO_REGIONS_ENABLE_WIDTH 1623624/***********************************/625/*626* MC_CMD_CDX_DEVICE_WRITE_MSI_MSG627* Populates the MSI message to be used by the hardware to raise the specified628* interrupt vector. Versal-net implementation specific limitations are that629* only 4 CDX devices with MSI interrupt capability are supported and all630* vectors within a device must use the same write address. The command will631* return EINVAL if any of these limitations is violated.632*/633#define MC_CMD_CDX_DEVICE_WRITE_MSI_MSG 0x9634#define MC_CMD_CDX_DEVICE_WRITE_MSI_MSG_MSGSET 0x9635#undef MC_CMD_0x9_PRIVILEGE_CTG636637#define MC_CMD_0x9_PRIVILEGE_CTG SRIOV_CTG_ADMIN638639/* MC_CMD_CDX_DEVICE_WRITE_MSI_MSG_IN msgrequest */640#define MC_CMD_CDX_DEVICE_WRITE_MSI_MSG_IN_LEN 28641/* Device bus number, in range 0 to BUS_COUNT-1 */642#define MC_CMD_CDX_DEVICE_WRITE_MSI_MSG_IN_BUS_OFST 0643#define MC_CMD_CDX_DEVICE_WRITE_MSI_MSG_IN_BUS_LEN 4644/* Device number relative to the bus, in range 0 to DEVICE_COUNT-1 for that bus */645#define MC_CMD_CDX_DEVICE_WRITE_MSI_MSG_IN_DEVICE_OFST 4646#define MC_CMD_CDX_DEVICE_WRITE_MSI_MSG_IN_DEVICE_LEN 4647/*648* Device-relative MSI vector number. Must be < MSI_COUNT reported for the649* device.650*/651#define MC_CMD_CDX_DEVICE_WRITE_MSI_MSG_IN_MSI_VECTOR_OFST 8652#define MC_CMD_CDX_DEVICE_WRITE_MSI_MSG_IN_MSI_VECTOR_LEN 4653/* Reserved (alignment) */654#define MC_CMD_CDX_DEVICE_WRITE_MSI_MSG_IN_RESERVED_OFST 12655#define MC_CMD_CDX_DEVICE_WRITE_MSI_MSG_IN_RESERVED_LEN 4656/*657* MSI address to be used by the hardware. Typically, on ARM systems this658* address is translated by the IOMMU (if enabled) and it is the responsibility659* of the entity managing the IOMMU (APU kernel) to supply the correct IOVA660* here.661*/662#define MC_CMD_CDX_DEVICE_WRITE_MSI_MSG_IN_MSI_ADDRESS_OFST 16663#define MC_CMD_CDX_DEVICE_WRITE_MSI_MSG_IN_MSI_ADDRESS_LEN 8664#define MC_CMD_CDX_DEVICE_WRITE_MSI_MSG_IN_MSI_ADDRESS_LO_OFST 16665#define MC_CMD_CDX_DEVICE_WRITE_MSI_MSG_IN_MSI_ADDRESS_LO_LEN 4666#define MC_CMD_CDX_DEVICE_WRITE_MSI_MSG_IN_MSI_ADDRESS_LO_LBN 128667#define MC_CMD_CDX_DEVICE_WRITE_MSI_MSG_IN_MSI_ADDRESS_LO_WIDTH 32668#define MC_CMD_CDX_DEVICE_WRITE_MSI_MSG_IN_MSI_ADDRESS_HI_OFST 20669#define MC_CMD_CDX_DEVICE_WRITE_MSI_MSG_IN_MSI_ADDRESS_HI_LEN 4670#define MC_CMD_CDX_DEVICE_WRITE_MSI_MSG_IN_MSI_ADDRESS_HI_LBN 160671#define MC_CMD_CDX_DEVICE_WRITE_MSI_MSG_IN_MSI_ADDRESS_HI_WIDTH 32672/*673* MSI data to be used by the hardware. On versal-net, only the lower 16-bits674* are used, the remaining bits are ignored and should be set to zero.675*/676#define MC_CMD_CDX_DEVICE_WRITE_MSI_MSG_IN_MSI_DATA_OFST 24677#define MC_CMD_CDX_DEVICE_WRITE_MSI_MSG_IN_MSI_DATA_LEN 4678679/* MC_CMD_CDX_DEVICE_WRITE_MSI_MSG_OUT msgresponse */680#define MC_CMD_CDX_DEVICE_WRITE_MSI_MSG_OUT_LEN 0681682/***********************************/683/* MC_CMD_V2_EXTN - Encapsulation for a v2 extended command */684#define MC_CMD_V2_EXTN 0x7f685686/* MC_CMD_V2_EXTN_IN msgrequest */687#define MC_CMD_V2_EXTN_IN_LEN 4688/* the extended command number */689#define MC_CMD_V2_EXTN_IN_EXTENDED_CMD_LBN 0690#define MC_CMD_V2_EXTN_IN_EXTENDED_CMD_WIDTH 15691#define MC_CMD_V2_EXTN_IN_UNUSED_LBN 15692#define MC_CMD_V2_EXTN_IN_UNUSED_WIDTH 1693/* the actual length of the encapsulated command */694#define MC_CMD_V2_EXTN_IN_ACTUAL_LEN_LBN 16695#define MC_CMD_V2_EXTN_IN_ACTUAL_LEN_WIDTH 10696#define MC_CMD_V2_EXTN_IN_UNUSED2_LBN 26697#define MC_CMD_V2_EXTN_IN_UNUSED2_WIDTH 2698/* Type of command/response */699#define MC_CMD_V2_EXTN_IN_MESSAGE_TYPE_LBN 28700#define MC_CMD_V2_EXTN_IN_MESSAGE_TYPE_WIDTH 4701/*702* enum: MCDI command directed to versal-net. MCDI responses of this type703* are not defined.704*/705#define MC_CMD_V2_EXTN_IN_MCDI_MESSAGE_TYPE_PLATFORM 0x2706707#endif /* MC_CDX_PCOL_H */708709710