156
157
struct xhci_op_regs {
162
u32 dev_notification;
163
__le32 dev_notification;
164
165
/* rsvd: offset 0x20-2F */
168
169
/* rsvd: offset 0x3C-3FF */
170
__le32 reserved4[241];
170
171
/* port 1 registers, which serve as a base address for other ports */
171
u32 port_status_base;
172
__le32 port_status_base;
173
__le32 port_power_base;
174
__le32 port_link_base;
175
176
/* registers for ports 2-255 */
176
u32 reserved6[NUM_PORT_REGS*254];
177
__le32 reserved6[NUM_PORT_REGS*254];
179
180
/* USBCMD - USB command - command bitmasks */
348
349
/* Initiate a warm port reset - complete when PORT_WRC is '1' */
349
350
#define PORT_WR (1 << 31)
352
/* We mark duplicate entries with -1 */
353
#define DUPLICATE_ENTRY ((u8)(-1))
351
355
/* Port Power Management Status and Control - port_power_base bitmasks */
352
356
/* Inactivity timer value for transitions into U1, in microseconds.
353
357
* Timeout can be up to 127us. 0xFF means an infinite timeout.
556
560
#define SLOT_STATE (0x1f << 27)
557
561
#define GET_SLOT_STATE(p) (((p) & (0x1f << 27)) >> 27)
563
#define SLOT_STATE_DISABLED 0
564
#define SLOT_STATE_ENABLED SLOT_STATE_DISABLED
565
#define SLOT_STATE_DEFAULT 1
566
#define SLOT_STATE_ADDRESSED 2
567
#define SLOT_STATE_CONFIGURED 3
561
570
* struct xhci_ep_ctx
800
809
struct xhci_device_context_array {
801
810
/* 64-bit device addresses; we only write 32-bit addresses */
802
u64 dev_context_ptrs[MAX_HC_SLOTS];
811
__le64 dev_context_ptrs[MAX_HC_SLOTS];
803
812
/* private xHCD pointers */
813
822
struct xhci_transfer_event {
814
823
/* 64-bit buffer address, or immediate data */
817
826
/* This field is interpreted differently based on the type of TRB */
821
830
/** Transfer Event bit fields **/
873
884
#define COMP_CMD_ABORT 25
874
885
/* Stopped - transfer was terminated by a stop endpoint command */
875
886
#define COMP_STOP 26
876
/* Same as COMP_EP_STOPPED, but the transfered length in the event is invalid */
887
/* Same as COMP_EP_STOPPED, but the transferred length in the event is invalid */
877
888
#define COMP_STOP_INVAL 27
878
889
/* Control Abort Error - Debug Capability - control pipe aborted */
879
890
#define COMP_DBG_ABORT 28
880
/* TRB type 29 and 30 reserved */
891
/* Max Exit Latency Too Large Error */
892
#define COMP_MEL_ERR 29
893
/* TRB type 30 reserved */
881
894
/* Isoc Buffer Overrun - an isoc IN ep sent more data than could fit in TD */
882
895
#define COMP_BUFF_OVER 31
883
896
/* Event Lost Error - xHC has an "internal event overrun condition" */
939
952
/* Interrupter Target - which MSI-X vector to target the completion event at */
940
953
#define TRB_INTR_TARGET(p) (((p) & 0x3ff) << 22)
941
954
#define GET_INTR_TARGET(p) (((p) >> 22) & 0x3ff)
955
#define TRB_TBC(p) (((p) & 0x3) << 7)
956
#define TRB_TLBPC(p) (((p) & 0xf) << 16)
943
958
/* Cycle bit - indicates TRB ownership by HC or HCD */
944
959
#define TRB_CYCLE (1<<0)
958
973
/* The buffer pointer contains immediate data */
959
974
#define TRB_IDT (1<<6)
976
/* Block Event Interrupt */
977
#define TRB_BEI (1<<9)
962
979
/* Control transfer TRB specific fields */
963
980
#define TRB_DIR_IN (1<<16)
981
#define TRB_TX_TYPE(p) ((p) << 16)
982
#define TRB_DATA_OUT 2
983
#define TRB_DATA_IN 3
965
985
/* Isochronous TRB specific fields */
966
986
#define TRB_SIA (1<<31)
968
988
struct xhci_generic_trb {
1276
1297
#define XHCI_LINK_TRB_QUIRK (1 << 0)
1277
1298
#define XHCI_RESET_EP_QUIRK (1 << 1)
1278
1299
#define XHCI_NEC_HOST (1 << 2)
1300
#define XHCI_AMD_PLL_FIX (1 << 3)
1301
#define XHCI_SPURIOUS_SUCCESS (1 << 4)
1303
* Certain Intel host controllers have a limit to the number of endpoint
1304
* contexts they can handle. Ideally, they would signal that they can't handle
1305
* anymore endpoint contexts by returning a Resource Error for the Configure
1306
* Endpoint command, but they don't. Instead they expect software to keep track
1307
* of the number of active endpoints for them, across configure endpoint
1308
* commands, reset device commands, disable slot commands, and address device
1311
#define XHCI_EP_LIMIT_QUIRK (1 << 5)
1312
#define XHCI_BROKEN_MSI (1 << 6)
1313
#define XHCI_RESET_ON_RESUME (1 << 7)
1314
unsigned int num_active_eps;
1315
unsigned int limit_active_eps;
1279
1316
/* There are two roothubs to keep track of bus suspend info for */
1280
1317
struct xhci_bus_state bus_state[2];
1281
1318
/* Is each xHCI roothub port a USB 3.0, USB 2.0, or USB 1.1 port? */
1282
1319
u8 *port_array;
1283
1320
/* Array of pointers to USB 3.0 PORTSC registers */
1284
u32 __iomem **usb3_ports;
1321
__le32 __iomem **usb3_ports;
1285
1322
unsigned int num_usb3_ports;
1286
1323
/* Array of pointers to USB 2.0 PORTSC registers */
1287
u32 __iomem **usb2_ports;
1324
__le32 __iomem **usb2_ports;
1288
1325
unsigned int num_usb2_ports;
1317
1354
/* TODO: copied from ehci.h - can be refactored? */
1318
1355
/* xHCI spec says all registers are little endian */
1319
1356
static inline unsigned int xhci_readl(const struct xhci_hcd *xhci,
1320
__u32 __iomem *regs)
1357
__le32 __iomem *regs)
1322
1359
return readl(regs);
1324
1361
static inline void xhci_writel(struct xhci_hcd *xhci,
1325
const unsigned int val, __u32 __iomem *regs)
1362
const unsigned int val, __le32 __iomem *regs)
1328
"`MEM_WRITE_DWORD(3'b000, 32'h%p, 32'h%0x, 4'hf);\n",
1330
1364
writel(val, regs);
1348
1382
return val_lo + (val_hi << 32);
1350
1384
static inline void xhci_write_64(struct xhci_hcd *xhci,
1351
const u64 val, __u64 __iomem *regs)
1385
const u64 val, __le64 __iomem *regs)
1353
1387
__u32 __iomem *ptr = (__u32 __iomem *) regs;
1354
1388
u32 val_lo = lower_32_bits(val);
1355
1389
u32 val_hi = upper_32_bits(val);
1358
"`MEM_WRITE_DWORD(3'b000, 64'h%p, 64'h%0lx, 4'hf);\n",
1359
regs, (long unsigned int) val);
1360
1391
writel(val_lo, ptr);
1361
1392
writel(val_hi, ptr + 1);
1425
1456
void xhci_setup_no_streams_ep_input_ctx(struct xhci_hcd *xhci,
1426
1457
struct xhci_ep_ctx *ep_ctx,
1427
1458
struct xhci_virt_ep *ep);
1459
void xhci_free_device_endpoint_resources(struct xhci_hcd *xhci,
1460
struct xhci_virt_device *virt_dev, bool drop_control_ep);
1428
1461
struct xhci_ring *xhci_dma_to_transfer_ring(
1429
1462
struct xhci_virt_ep *ep,