1*2ed98337SAymeric Wibo /*- 2*2ed98337SAymeric Wibo * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3*2ed98337SAymeric Wibo * 4*2ed98337SAymeric Wibo * Copyright (c) 2022 Scott Long 5*2ed98337SAymeric Wibo * All rights reserved. 6*2ed98337SAymeric Wibo * 7*2ed98337SAymeric Wibo * Redistribution and use in source and binary forms, with or without 8*2ed98337SAymeric Wibo * modification, are permitted provided that the following conditions 9*2ed98337SAymeric Wibo * are met: 10*2ed98337SAymeric Wibo * 1. Redistributions of source code must retain the above copyright 11*2ed98337SAymeric Wibo * notice, this list of conditions and the following disclaimer. 12*2ed98337SAymeric Wibo * 2. Redistributions in binary form must reproduce the above copyright 13*2ed98337SAymeric Wibo * notice, this list of conditions and the following disclaimer in the 14*2ed98337SAymeric Wibo * documentation and/or other materials provided with the distribution. 15*2ed98337SAymeric Wibo * 16*2ed98337SAymeric Wibo * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17*2ed98337SAymeric Wibo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18*2ed98337SAymeric Wibo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19*2ed98337SAymeric Wibo * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20*2ed98337SAymeric Wibo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21*2ed98337SAymeric Wibo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22*2ed98337SAymeric Wibo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23*2ed98337SAymeric Wibo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24*2ed98337SAymeric Wibo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25*2ed98337SAymeric Wibo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26*2ed98337SAymeric Wibo * SUCH DAMAGE. 27*2ed98337SAymeric Wibo * 28*2ed98337SAymeric Wibo * Thunderbolt 3 register definitions 29*2ed98337SAymeric Wibo */ 30*2ed98337SAymeric Wibo 31*2ed98337SAymeric Wibo /* $FreeBSD$ */ 32*2ed98337SAymeric Wibo 33*2ed98337SAymeric Wibo #ifndef _NHI_REG_H 34*2ed98337SAymeric Wibo #define _NHI_REG_H 35*2ed98337SAymeric Wibo 36*2ed98337SAymeric Wibo /* Some common definitions */ 37*2ed98337SAymeric Wibo #define TBT_SEC_NONE 0x00 38*2ed98337SAymeric Wibo #define TBT_SEC_USER 0x01 39*2ed98337SAymeric Wibo #define TBT_SEC_SECURE 0x02 40*2ed98337SAymeric Wibo #define TBT_SEC_DP 0x03 41*2ed98337SAymeric Wibo 42*2ed98337SAymeric Wibo #define GENMASK(h, l) (((~0U) >> (31 - (h))) ^ ((~0U) >> (31 - (l)) >> 1)) 43*2ed98337SAymeric Wibo 44*2ed98337SAymeric Wibo /* PCI Vendor and Device ID's */ 45*2ed98337SAymeric Wibo #define VENDOR_INTEL 0x8086 46*2ed98337SAymeric Wibo #define DEVICE_AR_2C_NHI 0x1575 47*2ed98337SAymeric Wibo #define DEVICE_AR_DP_B_NHI 0x1577 48*2ed98337SAymeric Wibo #define DEVICE_AR_DP_C_NHI 0x15d2 49*2ed98337SAymeric Wibo #define DEVICE_AR_LP_NHI 0x15bf 50*2ed98337SAymeric Wibo #define DEVICE_ICL_NHI_0 0x8a17 51*2ed98337SAymeric Wibo #define DEVICE_ICL_NHI_1 0x8a0d 52*2ed98337SAymeric Wibo 53*2ed98337SAymeric Wibo #define VENDOR_AMD 0x1022 54*2ed98337SAymeric Wibo #define DEVICE_PINK_SARDINE_0 0x1668 55*2ed98337SAymeric Wibo #define DEVICE_PINK_SARDINE_1 0x1669 56*2ed98337SAymeric Wibo 57*2ed98337SAymeric Wibo /* * * MMIO Registers 58*2ed98337SAymeric Wibo * * Ring buffer registers 59*2ed98337SAymeric Wibo * 60*2ed98337SAymeric Wibo * 32 transmit and receive rings are available, with Ring 0 being the most 61*2ed98337SAymeric Wibo * important one. The ring descriptors are 16 bytes each, and each set of 62*2ed98337SAymeric Wibo * TX and RX descriptors are packed together. There are only definitions 63*2ed98337SAymeric Wibo * for the Ring 0 addresses, others can be directly computed. 64*2ed98337SAymeric Wibo */ 65*2ed98337SAymeric Wibo #define NHI_TX_RING_ADDR_LO 0x00000 66*2ed98337SAymeric Wibo #define NHI_TX_RING_ADDR_HI 0x00004 67*2ed98337SAymeric Wibo #define NHI_TX_RING_PICI 0x00008 68*2ed98337SAymeric Wibo #define TX_RING_CI_MASK GENMASK(15, 0) 69*2ed98337SAymeric Wibo #define TX_RING_PI_SHIFT 16 70*2ed98337SAymeric Wibo #define NHI_TX_RING_SIZE 0x0000c 71*2ed98337SAymeric Wibo 72*2ed98337SAymeric Wibo #define NHI_RX_RING_ADDR_LO 0x08000 73*2ed98337SAymeric Wibo #define NHI_RX_RING_ADDR_HI 0x08004 74*2ed98337SAymeric Wibo #define NHI_RX_RING_PICI 0x08008 75*2ed98337SAymeric Wibo #define RX_RING_CI_MASK GENMASK(15, 0) 76*2ed98337SAymeric Wibo #define RX_RING_PI_SHIFT 16 77*2ed98337SAymeric Wibo #define NHI_RX_RING_SIZE 0x0800c 78*2ed98337SAymeric Wibo #define RX_RING_BUF_SIZE_SHIFT 16 79*2ed98337SAymeric Wibo 80*2ed98337SAymeric Wibo /* 81*2ed98337SAymeric Wibo * One 32-bit status register encodes one status bit per ring indicates that 82*2ed98337SAymeric Wibo * the watermark from the control descriptor has been reached. 83*2ed98337SAymeric Wibo */ 84*2ed98337SAymeric Wibo #define NHI_RX_RING_STATUS 0x19400 85*2ed98337SAymeric Wibo 86*2ed98337SAymeric Wibo /* 87*2ed98337SAymeric Wibo * TX and RX Tables. These are 32 byte control fields for each ring. 88*2ed98337SAymeric Wibo * Only 8 bytes are controllable by the host software, the rest are a 89*2ed98337SAymeric Wibo * shadow copy by the controller of the current packet that's being 90*2ed98337SAymeric Wibo * processed. 91*2ed98337SAymeric Wibo */ 92*2ed98337SAymeric Wibo #define NHI_TX_RING_TABLE_BASE0 0x19800 93*2ed98337SAymeric Wibo #define TX_TABLE_INTERVAL_MASK GENMASK(23,0) /* Isoch interval 256ns */ 94*2ed98337SAymeric Wibo #define TX_TABLE_ITE (1 << 27) /* Isoch tx enable */ 95*2ed98337SAymeric Wibo #define TX_TABLE_E2E (1 << 28) /* End-to-end flow control */ 96*2ed98337SAymeric Wibo #define TX_TABLE_NS (1 << 29) /* PCIe No Snoop */ 97*2ed98337SAymeric Wibo #define TX_TABLE_RAW (1 << 30) /* Raw (1)/frame(0) mode */ 98*2ed98337SAymeric Wibo #define TX_TABLE_VALID (1 << 31) /* Table entry is valid */ 99*2ed98337SAymeric Wibo #define NHI_TX_RING_TABLE_TIMESTAMP 0x19804 100*2ed98337SAymeric Wibo 101*2ed98337SAymeric Wibo #define NHI_RX_RING_TABLE_BASE0 0x29800 102*2ed98337SAymeric Wibo #define RX_TABLE_TX_E2E_HOPID_SHIFT (1 << 12) 103*2ed98337SAymeric Wibo #define RX_TABLE_E2E (1 << 28) /* End-to-end flow control */ 104*2ed98337SAymeric Wibo #define RX_TABLE_NS (1 << 29) /* PCIe No Snoop */ 105*2ed98337SAymeric Wibo #define RX_TABLE_RAW (1 << 30) /* Raw (1)/frame(0) mode */ 106*2ed98337SAymeric Wibo #define RX_TABLE_VALID (1 << 31) /* Table entry is valid */ 107*2ed98337SAymeric Wibo #define NHI_RX_RING_TABLE_BASE1 0x29804 108*2ed98337SAymeric Wibo #define RX_TABLE_EOF_MASK (1 << 0) 109*2ed98337SAymeric Wibo #define RX_TABLE_SOF_MASK (1 << 16) 110*2ed98337SAymeric Wibo 111*2ed98337SAymeric Wibo /* * Interrupt Control/Status Registers 112*2ed98337SAymeric Wibo * Interrupt Status Register (ISR) 113*2ed98337SAymeric Wibo * Interrupt status for RX, TX, and Nearly Empty events, one bit per 114*2ed98337SAymeric Wibo * MSI-X vector. Clear on read. 115*2ed98337SAymeric Wibo * Only 12 bits per operation, instead of 16? I guess it relates to the 116*2ed98337SAymeric Wibo * number paths, advertised in the HOST_CAPS register, which is wired to 117*2ed98337SAymeric Wibo * 0x0c for Alpine Ridge. 118*2ed98337SAymeric Wibo */ 119*2ed98337SAymeric Wibo #define NHI_ISR0 0x37800 120*2ed98337SAymeric Wibo #define ISR0_TX_DESC_SHIFT 0 121*2ed98337SAymeric Wibo #define ISR0_RX_DESC_SHIFT 12 122*2ed98337SAymeric Wibo #define ISR0_RX_EMPTY_SHIFT 24 123*2ed98337SAymeric Wibo #define NHI_ISR1 0x37804 124*2ed98337SAymeric Wibo #define ISR1_RX_EMPTY_SHIFT 0 125*2ed98337SAymeric Wibo 126*2ed98337SAymeric Wibo /* * Interrupt Status Clear, corresponds to ISR0/ISR1. Write Only */ 127*2ed98337SAymeric Wibo #define NHI_ISC0 0x37808 128*2ed98337SAymeric Wibo #define NHI_ISC1 0x3780c 129*2ed98337SAymeric Wibo 130*2ed98337SAymeric Wibo /* * Interrupt Status Set, corresponds to ISR0/ISR1. Write Only */ 131*2ed98337SAymeric Wibo #define NHI_ISS0 0x37810 132*2ed98337SAymeric Wibo #define NHI_ISS1 0x37814 133*2ed98337SAymeric Wibo 134*2ed98337SAymeric Wibo /* * Interrupt Mask, corresponds to ISR0/ISR1. Read-Write */ 135*2ed98337SAymeric Wibo #define NHI_IMR0 0x38200 136*2ed98337SAymeric Wibo #define NHI_IMR1 0x38204 137*2ed98337SAymeric Wibo #define IMR_TX_OFFSET 0 138*2ed98337SAymeric Wibo #define IMR_RX_OFFSET 12 139*2ed98337SAymeric Wibo #define IMR_NE_OFFSET 24 140*2ed98337SAymeric Wibo 141*2ed98337SAymeric Wibo /* * Interrupt Mask Clear, corresponds to ISR0/ISR1. Write-only */ 142*2ed98337SAymeric Wibo #define NHI_IMC0 0x38208 143*2ed98337SAymeric Wibo #define NHI_IMC1 0x3820c 144*2ed98337SAymeric Wibo 145*2ed98337SAymeric Wibo /* * Interrupt Mask Set, corresponds to ISR0/ISR1. Write-only */ 146*2ed98337SAymeric Wibo #define NHI_IMS0 0x38210 147*2ed98337SAymeric Wibo #define NHI_IMS1 0x38214 148*2ed98337SAymeric Wibo 149*2ed98337SAymeric Wibo /* 150*2ed98337SAymeric Wibo * Interrupt Throttle Rate. One 32 bit register per interrupt, 151*2ed98337SAymeric Wibo * 16 registers for the 16 MSI-X interrupts. Interval is in 256ns 152*2ed98337SAymeric Wibo * increments. 153*2ed98337SAymeric Wibo */ 154*2ed98337SAymeric Wibo #define NHI_ITR0 0x38c00 155*2ed98337SAymeric Wibo #define ITR_INTERVAL_SHIFT 0 156*2ed98337SAymeric Wibo #define ITR_COUNTER_SHIFT 16 157*2ed98337SAymeric Wibo 158*2ed98337SAymeric Wibo /* 159*2ed98337SAymeric Wibo * Interrupt Vector Allocation. 160*2ed98337SAymeric Wibo * There are 12 4-bit descriptors for TX, 12 4-bit descriptors for RX, 161*2ed98337SAymeric Wibo * and 12 4-bit descriptors for Nearly Empty. Each descriptor holds 162*2ed98337SAymeric Wibo * the numerical value of the MSI-X vector that will receive the 163*2ed98337SAymeric Wibo * corresponding interrupt. 164*2ed98337SAymeric Wibo * Bits 0-31 of IVR0 and 0-15 of IVR1 are for TX 165*2ed98337SAymeric Wibo * Bits 16-31 of IVR1 and 0-31 of IVR2 are for RX 166*2ed98337SAymeric Wibo * Bits 0-31 of IVR3 and 0-15 of IVR4 are for Nearly Empty 167*2ed98337SAymeric Wibo */ 168*2ed98337SAymeric Wibo #define NHI_IVR0 0x38c40 169*2ed98337SAymeric Wibo #define NHI_IVR1 0x38c44 170*2ed98337SAymeric Wibo #define NHI_IVR2 0x38c48 171*2ed98337SAymeric Wibo #define NHI_IVR3 0x38c4c 172*2ed98337SAymeric Wibo #define NHI_IVR4 0x38c50 173*2ed98337SAymeric Wibo #define IVR_TX_OFFSET 0 174*2ed98337SAymeric Wibo #define IVR_RX_OFFSET 12 175*2ed98337SAymeric Wibo #define IVR_NE_OFFSET 24 176*2ed98337SAymeric Wibo 177*2ed98337SAymeric Wibo /* Native Host Interface Control registers */ 178*2ed98337SAymeric Wibo #define NHI_HOST_CAPS 0x39640 179*2ed98337SAymeric Wibo #define GET_HOST_CAPS_PATHS(val) ((val) & 0x3f) 180*2ed98337SAymeric Wibo 181*2ed98337SAymeric Wibo /* 182*2ed98337SAymeric Wibo * This definition comes from the Linux driver. In the USB4 spec, this 183*2ed98337SAymeric Wibo * register is named Host Interface Control, and the Interrupt Autoclear bit 184*2ed98337SAymeric Wibo * is at bit17, not bit2. The Linux driver doesn't seem to acknowledge this. 185*2ed98337SAymeric Wibo */ 186*2ed98337SAymeric Wibo #define NHI_DMA_MISC 0x39864 187*2ed98337SAymeric Wibo #define DMA_MISC_INT_AUTOCLEAR (1 << 2) 188*2ed98337SAymeric Wibo 189*2ed98337SAymeric Wibo /* Thunderbolt firmware mailbox registers */ 190*2ed98337SAymeric Wibo #define TBT_INMAILDATA 0x39900 191*2ed98337SAymeric Wibo 192*2ed98337SAymeric Wibo #define TBT_INMAILCMD 0x39904 193*2ed98337SAymeric Wibo #define INMAILCMD_CMD_MASK 0xff 194*2ed98337SAymeric Wibo #define INMAILCMD_SAVE_CONNECTED 0x05 195*2ed98337SAymeric Wibo #define INMAILCMD_DISCONNECT_PCIE 0x06 196*2ed98337SAymeric Wibo #define INMAILCMD_DRIVER_UNLOAD_DISCONNECT 0x07 197*2ed98337SAymeric Wibo #define INMAILCMD_DISCONNECT_PORTA 0x10 198*2ed98337SAymeric Wibo #define INMAILCMD_DISCONNECT_PORTB 0x11 199*2ed98337SAymeric Wibo #define INMAILCMD_SETMODE_CERT_TB_1ST_DEPTH 0x20 200*2ed98337SAymeric Wibo #define INMAILCMD_SETMODE_ANY_TB_1ST_DEPTH 0x21 201*2ed98337SAymeric Wibo #define INMAILCMD_SETMODE_CERT_TB_ANY_DEPTH 0x22 202*2ed98337SAymeric Wibo #define INMAILCMD_SETMODE_ANY_TB_ANY_DEPTH 0x23 203*2ed98337SAymeric Wibo #define INMAILCMD_CIO_RESET 0xf0 204*2ed98337SAymeric Wibo #define INMAILCMD_ERROR (1 << 30) 205*2ed98337SAymeric Wibo #define INMAILCMD_OPREQ (1 << 31) 206*2ed98337SAymeric Wibo 207*2ed98337SAymeric Wibo #define TBT_OUTMAILCMD 0x3990c 208*2ed98337SAymeric Wibo #define OUTMAILCMD_STATUS_BUSY (1 << 12) 209*2ed98337SAymeric Wibo #define OUTMAILCMD_OPMODE_MASK 0xf00 210*2ed98337SAymeric Wibo #define OUTMAILCMD_OPMODE_SAFE 0x000 211*2ed98337SAymeric Wibo #define OUTMAILCMD_OPMODE_AUTH 0x100 212*2ed98337SAymeric Wibo #define OUTMAILCMD_OPMODE_ENDPOINT 0x200 213*2ed98337SAymeric Wibo #define OUTMAILCMD_OPMODE_CM_FULL 0x300 214*2ed98337SAymeric Wibo 215*2ed98337SAymeric Wibo #define TBT_FW_STATUS 0x39944 216*2ed98337SAymeric Wibo #define FWSTATUS_ENABLE (1 << 0) 217*2ed98337SAymeric Wibo #define FWSTATUS_INVERT (1 << 1) 218*2ed98337SAymeric Wibo #define FWSTATUS_START (1 << 2) 219*2ed98337SAymeric Wibo #define FWSTATUS_CIO_RESET (1 << 30) 220*2ed98337SAymeric Wibo #define FWSTATUS_CM_READY (1 << 31) 221*2ed98337SAymeric Wibo 222*2ed98337SAymeric Wibo /* 223*2ed98337SAymeric Wibo * Link Controller (LC) registers. These are in the Vendor Specific 224*2ed98337SAymeric Wibo * Extended Capability registers in PCICFG. 225*2ed98337SAymeric Wibo */ 226*2ed98337SAymeric Wibo #define AR_LC_MBOX_OUT 0x4c 227*2ed98337SAymeric Wibo #define ICL_LC_MBOX_OUT 0xf0 228*2ed98337SAymeric Wibo #define LC_MBOXOUT_VALID (1 << 0) 229*2ed98337SAymeric Wibo #define LC_MBOXOUT_CMD_SHIFT 1 230*2ed98337SAymeric Wibo #define LC_MBOXOUT_CMD_MASK (0x7f << LC_MBOXOUT_CMD_SHIFT) 231*2ed98337SAymeric Wibo #define LC_MBOXOUT_CMD_GO2SX (0x02 << LC_MBOXOUT_CMD_SHIFT) 232*2ed98337SAymeric Wibo #define LC_MBOXOUT_CMD_GO2SX_NOWAKE (0x03 << LC_MBOXOUT_CMD_SHIFT) 233*2ed98337SAymeric Wibo #define LC_MBOXOUT_CMD_SXEXIT_TBT (0x04 << LC_MBOXOUT_CMD_SHIFT) 234*2ed98337SAymeric Wibo #define LC_MBOXOUT_CMD_SXEXIT_NOTBT (0x05 << LC_MBOXOUT_CMD_SHIFT) 235*2ed98337SAymeric Wibo #define LC_MBOXOUT_CMD_OS_UP (0x06 << LC_MBOXOUT_CMD_SHIFT) 236*2ed98337SAymeric Wibo #define LC_MBOXOUT_DATA_SHIFT 8 237*2ed98337SAymeric Wibo #define SET_LC_MBOXOUT_DATA(val) ((val) << LC_MBOXOUT_DATA_SHIFT) 238*2ed98337SAymeric Wibo 239*2ed98337SAymeric Wibo #define AR_LC_MBOX_IN 0x48 240*2ed98337SAymeric Wibo #define ICL_LC_MBOX_IN 0xec 241*2ed98337SAymeric Wibo #define LC_MBOXIN_DONE (1 << 0) 242*2ed98337SAymeric Wibo #define LC_MBOXIN_CMD_SHIFT 1 243*2ed98337SAymeric Wibo #define LC_MBOXIN_CMD_MASK (0x7f << LC_MBOXIN_CMD_SHIFT) 244*2ed98337SAymeric Wibo #define LC_MBOXIN_DATA_SHIFT 8 245*2ed98337SAymeric Wibo #define GET_LC_MBOXIN_DATA(val) ((val) >> LC_MBOXIN_DATA_SHIFT) 246*2ed98337SAymeric Wibo 247*2ed98337SAymeric Wibo /* Other Vendor Specific registers */ 248*2ed98337SAymeric Wibo #define AR_VSCAP_1C 0x1c 249*2ed98337SAymeric Wibo #define AR_VSCAP_B0 0xb0 250*2ed98337SAymeric Wibo 251*2ed98337SAymeric Wibo #define ICL_VSCAP_9 0xc8 252*2ed98337SAymeric Wibo #define ICL_VSCAP9_FWREADY (1 << 31) 253*2ed98337SAymeric Wibo #define ICL_VSCAP_10 0xcc 254*2ed98337SAymeric Wibo #define ICL_VSCAP_11 0xd0 255*2ed98337SAymeric Wibo #define ICL_VSCAP_22 0xfc 256*2ed98337SAymeric Wibo #define ICL_VSCAP22_FORCEPWR (1 << 1) 257*2ed98337SAymeric Wibo 258*2ed98337SAymeric Wibo /* * Data structures 259*2ed98337SAymeric Wibo * Transmit buffer descriptor, 12.3.1. Must be aligned on a 4byte boundary. 260*2ed98337SAymeric Wibo */ 261*2ed98337SAymeric Wibo struct nhi_tx_buffer_desc { 262*2ed98337SAymeric Wibo uint32_t addr_lo; 263*2ed98337SAymeric Wibo uint32_t addr_hi; 264*2ed98337SAymeric Wibo uint16_t eof_len; 265*2ed98337SAymeric Wibo #define TX_BUFFER_DESC_LEN_MASK 0xfff 266*2ed98337SAymeric Wibo #define TX_BUFFER_DESC_EOF_SHIFT 12 267*2ed98337SAymeric Wibo uint8_t flags_sof; 268*2ed98337SAymeric Wibo #define TX_BUFFER_DESC_SOF_MASK 0xf 269*2ed98337SAymeric Wibo #define TX_BUFFER_DESC_IDE (1 << 4) /* Isoch DMA enable */ 270*2ed98337SAymeric Wibo #define TX_BUFFER_DESC_DONE (1 << 5) /* Descriptor Done */ 271*2ed98337SAymeric Wibo #define TX_BUFFER_DESC_RS (1 << 6) /* Request Status/Done */ 272*2ed98337SAymeric Wibo #define TX_BUFFER_DESC_IE (1 << 7) /* Interrupt Enable */ 273*2ed98337SAymeric Wibo uint8_t offset; 274*2ed98337SAymeric Wibo uint32_t payload_time; 275*2ed98337SAymeric Wibo } __packed; 276*2ed98337SAymeric Wibo 277*2ed98337SAymeric Wibo /* 278*2ed98337SAymeric Wibo * Receive buffer descriptor, 12.4.1. 4 byte aligned. This goes into 279*2ed98337SAymeric Wibo * the descriptor ring, but changes into the _post form when the 280*2ed98337SAymeric Wibo * controller uses it. 281*2ed98337SAymeric Wibo */ 282*2ed98337SAymeric Wibo struct nhi_rx_buffer_desc { 283*2ed98337SAymeric Wibo uint32_t addr_lo; 284*2ed98337SAymeric Wibo uint32_t addr_hi; 285*2ed98337SAymeric Wibo uint16_t reserved0; 286*2ed98337SAymeric Wibo uint8_t flags; 287*2ed98337SAymeric Wibo #define RX_BUFFER_DESC_RS (1 << 6) /* Request Status/Done */ 288*2ed98337SAymeric Wibo #define RX_BUFFER_DESC_IE (1 << 7) /* Interrupt Enable */ 289*2ed98337SAymeric Wibo uint8_t offset; 290*2ed98337SAymeric Wibo uint32_t reserved1; 291*2ed98337SAymeric Wibo } __packed; 292*2ed98337SAymeric Wibo 293*2ed98337SAymeric Wibo /* 294*2ed98337SAymeric Wibo * Receive buffer descriptor, after the controller fills it in 295*2ed98337SAymeric Wibo */ 296*2ed98337SAymeric Wibo struct nhi_rx_post_desc { 297*2ed98337SAymeric Wibo uint32_t addr_lo; 298*2ed98337SAymeric Wibo uint32_t addr_hi; 299*2ed98337SAymeric Wibo uint16_t eof_len; 300*2ed98337SAymeric Wibo #define RX_BUFFER_DESC_LEN_MASK 0xfff 301*2ed98337SAymeric Wibo #define RX_BUFFER_DESC_EOF_SHIFT 12 302*2ed98337SAymeric Wibo uint8_t flags_sof; 303*2ed98337SAymeric Wibo #define RX_BUFFER_DESC_SOF_MASK 0xf 304*2ed98337SAymeric Wibo #define RX_BUFFER_DESC_CRC_ERROR (1 << 4) /* CRC error (frame mode) */ 305*2ed98337SAymeric Wibo #define RX_BUFFER_DESC_DONE (1 << 5) /* Descriptor Done */ 306*2ed98337SAymeric Wibo #define RX_BUFFER_DESC_OVERRUN (1 << 6) /* Buffer overrun */ 307*2ed98337SAymeric Wibo #define RX_BUFFER_DESC_IE (1 << 7) /* Interrupt Enable */ 308*2ed98337SAymeric Wibo uint8_t offset; 309*2ed98337SAymeric Wibo uint32_t payload_time; 310*2ed98337SAymeric Wibo } __packed; 311*2ed98337SAymeric Wibo 312*2ed98337SAymeric Wibo union nhi_ring_desc { 313*2ed98337SAymeric Wibo struct nhi_tx_buffer_desc tx; 314*2ed98337SAymeric Wibo struct nhi_rx_buffer_desc rx; 315*2ed98337SAymeric Wibo struct nhi_rx_post_desc rxpost; 316*2ed98337SAymeric Wibo uint32_t dword[4]; 317*2ed98337SAymeric Wibo }; 318*2ed98337SAymeric Wibo 319*2ed98337SAymeric Wibo /* Protocol Defined Field (PDF) */ 320*2ed98337SAymeric Wibo #define PDF_READ 0x01 321*2ed98337SAymeric Wibo #define PDF_WRITE 0x02 322*2ed98337SAymeric Wibo #define PDF_NOTIFY 0x03 323*2ed98337SAymeric Wibo #define PDF_NOTIFY_ACK 0x04 324*2ed98337SAymeric Wibo #define PDF_HOTPLUG 0x05 325*2ed98337SAymeric Wibo #define PDF_XDOMAIN_REQ 0x06 326*2ed98337SAymeric Wibo #define PDF_XDOMAIN_RESP 0x07 327*2ed98337SAymeric Wibo /* Thunderbolt-only */ 328*2ed98337SAymeric Wibo #define PDF_CM_EVENT 0x0a 329*2ed98337SAymeric Wibo #define PDF_CM_REQ 0x0b 330*2ed98337SAymeric Wibo #define PDF_CM_RESP 0x0c 331*2ed98337SAymeric Wibo 332*2ed98337SAymeric Wibo #endif /* _NHI_REG_H */ 333