diff options
Diffstat (limited to 'drivers/usb/host/xhci.h')
-rw-r--r-- | drivers/usb/host/xhci.h | 145 |
1 files changed, 77 insertions, 68 deletions
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index ba1be6b7cc6d..e12db7cfb9bb 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h | |||
@@ -57,13 +57,13 @@ | |||
57 | * @run_regs_off: RTSOFF - Runtime register space offset | 57 | * @run_regs_off: RTSOFF - Runtime register space offset |
58 | */ | 58 | */ |
59 | struct xhci_cap_regs { | 59 | struct xhci_cap_regs { |
60 | u32 hc_capbase; | 60 | __le32 hc_capbase; |
61 | u32 hcs_params1; | 61 | __le32 hcs_params1; |
62 | u32 hcs_params2; | 62 | __le32 hcs_params2; |
63 | u32 hcs_params3; | 63 | __le32 hcs_params3; |
64 | u32 hcc_params; | 64 | __le32 hcc_params; |
65 | u32 db_off; | 65 | __le32 db_off; |
66 | u32 run_regs_off; | 66 | __le32 run_regs_off; |
67 | /* Reserved up to (CAPLENGTH - 0x1C) */ | 67 | /* Reserved up to (CAPLENGTH - 0x1C) */ |
68 | }; | 68 | }; |
69 | 69 | ||
@@ -155,26 +155,26 @@ struct xhci_cap_regs { | |||
155 | * devices. | 155 | * devices. |
156 | */ | 156 | */ |
157 | struct xhci_op_regs { | 157 | struct xhci_op_regs { |
158 | u32 command; | 158 | __le32 command; |
159 | u32 status; | 159 | __le32 status; |
160 | u32 page_size; | 160 | __le32 page_size; |
161 | u32 reserved1; | 161 | __le32 reserved1; |
162 | u32 reserved2; | 162 | __le32 reserved2; |
163 | u32 dev_notification; | 163 | __le32 dev_notification; |
164 | u64 cmd_ring; | 164 | __le64 cmd_ring; |
165 | /* rsvd: offset 0x20-2F */ | 165 | /* rsvd: offset 0x20-2F */ |
166 | u32 reserved3[4]; | 166 | __le32 reserved3[4]; |
167 | u64 dcbaa_ptr; | 167 | __le64 dcbaa_ptr; |
168 | u32 config_reg; | 168 | __le32 config_reg; |
169 | /* rsvd: offset 0x3C-3FF */ | 169 | /* rsvd: offset 0x3C-3FF */ |
170 | u32 reserved4[241]; | 170 | __le32 reserved4[241]; |
171 | /* port 1 registers, which serve as a base address for other ports */ | 171 | /* port 1 registers, which serve as a base address for other ports */ |
172 | u32 port_status_base; | 172 | __le32 port_status_base; |
173 | u32 port_power_base; | 173 | __le32 port_power_base; |
174 | u32 port_link_base; | 174 | __le32 port_link_base; |
175 | u32 reserved5; | 175 | __le32 reserved5; |
176 | /* registers for ports 2-255 */ | 176 | /* registers for ports 2-255 */ |
177 | u32 reserved6[NUM_PORT_REGS*254]; | 177 | __le32 reserved6[NUM_PORT_REGS*254]; |
178 | }; | 178 | }; |
179 | 179 | ||
180 | /* USBCMD - USB command - command bitmasks */ | 180 | /* USBCMD - USB command - command bitmasks */ |
@@ -382,12 +382,12 @@ struct xhci_op_regs { | |||
382 | * updates the dequeue pointer. | 382 | * updates the dequeue pointer. |
383 | */ | 383 | */ |
384 | struct xhci_intr_reg { | 384 | struct xhci_intr_reg { |
385 | u32 irq_pending; | 385 | __le32 irq_pending; |
386 | u32 irq_control; | 386 | __le32 irq_control; |
387 | u32 erst_size; | 387 | __le32 erst_size; |
388 | u32 rsvd; | 388 | __le32 rsvd; |
389 | u64 erst_base; | 389 | __le64 erst_base; |
390 | u64 erst_dequeue; | 390 | __le64 erst_dequeue; |
391 | }; | 391 | }; |
392 | 392 | ||
393 | /* irq_pending bitmasks */ | 393 | /* irq_pending bitmasks */ |
@@ -432,8 +432,8 @@ struct xhci_intr_reg { | |||
432 | * or larger accesses" | 432 | * or larger accesses" |
433 | */ | 433 | */ |
434 | struct xhci_run_regs { | 434 | struct xhci_run_regs { |
435 | u32 microframe_index; | 435 | __le32 microframe_index; |
436 | u32 rsvd[7]; | 436 | __le32 rsvd[7]; |
437 | struct xhci_intr_reg ir_set[128]; | 437 | struct xhci_intr_reg ir_set[128]; |
438 | }; | 438 | }; |
439 | 439 | ||
@@ -447,7 +447,7 @@ struct xhci_run_regs { | |||
447 | * Section 5.6 | 447 | * Section 5.6 |
448 | */ | 448 | */ |
449 | struct xhci_doorbell_array { | 449 | struct xhci_doorbell_array { |
450 | u32 doorbell[256]; | 450 | __le32 doorbell[256]; |
451 | }; | 451 | }; |
452 | 452 | ||
453 | #define DB_VALUE(ep, stream) ((((ep) + 1) & 0xff) | ((stream) << 16)) | 453 | #define DB_VALUE(ep, stream) ((((ep) + 1) & 0xff) | ((stream) << 16)) |
@@ -504,12 +504,12 @@ struct xhci_container_ctx { | |||
504 | * reserved at the end of the slot context for HC internal use. | 504 | * reserved at the end of the slot context for HC internal use. |
505 | */ | 505 | */ |
506 | struct xhci_slot_ctx { | 506 | struct xhci_slot_ctx { |
507 | u32 dev_info; | 507 | __le32 dev_info; |
508 | u32 dev_info2; | 508 | __le32 dev_info2; |
509 | u32 tt_info; | 509 | __le32 tt_info; |
510 | u32 dev_state; | 510 | __le32 dev_state; |
511 | /* offset 0x10 to 0x1f reserved for HC internal use */ | 511 | /* offset 0x10 to 0x1f reserved for HC internal use */ |
512 | u32 reserved[4]; | 512 | __le32 reserved[4]; |
513 | }; | 513 | }; |
514 | 514 | ||
515 | /* dev_info bitmasks */ | 515 | /* dev_info bitmasks */ |
@@ -580,12 +580,12 @@ struct xhci_slot_ctx { | |||
580 | * reserved at the end of the endpoint context for HC internal use. | 580 | * reserved at the end of the endpoint context for HC internal use. |
581 | */ | 581 | */ |
582 | struct xhci_ep_ctx { | 582 | struct xhci_ep_ctx { |
583 | u32 ep_info; | 583 | __le32 ep_info; |
584 | u32 ep_info2; | 584 | __le32 ep_info2; |
585 | u64 deq; | 585 | __le64 deq; |
586 | u32 tx_info; | 586 | __le32 tx_info; |
587 | /* offset 0x14 - 0x1f reserved for HC internal use */ | 587 | /* offset 0x14 - 0x1f reserved for HC internal use */ |
588 | u32 reserved[3]; | 588 | __le32 reserved[3]; |
589 | }; | 589 | }; |
590 | 590 | ||
591 | /* ep_info bitmasks */ | 591 | /* ep_info bitmasks */ |
@@ -660,9 +660,9 @@ struct xhci_ep_ctx { | |||
660 | * @add_context: set the bit of the endpoint context you want to enable | 660 | * @add_context: set the bit of the endpoint context you want to enable |
661 | */ | 661 | */ |
662 | struct xhci_input_control_ctx { | 662 | struct xhci_input_control_ctx { |
663 | u32 drop_flags; | 663 | __le32 drop_flags; |
664 | u32 add_flags; | 664 | __le32 add_flags; |
665 | u32 rsvd2[6]; | 665 | __le32 rsvd2[6]; |
666 | }; | 666 | }; |
667 | 667 | ||
668 | /* Represents everything that is needed to issue a command on the command ring. | 668 | /* Represents everything that is needed to issue a command on the command ring. |
@@ -688,9 +688,9 @@ struct xhci_command { | |||
688 | 688 | ||
689 | struct xhci_stream_ctx { | 689 | struct xhci_stream_ctx { |
690 | /* 64-bit stream ring address, cycle state, and stream type */ | 690 | /* 64-bit stream ring address, cycle state, and stream type */ |
691 | u64 stream_ring; | 691 | __le64 stream_ring; |
692 | /* offset 0x14 - 0x1f reserved for HC internal use */ | 692 | /* offset 0x14 - 0x1f reserved for HC internal use */ |
693 | u32 reserved[2]; | 693 | __le32 reserved[2]; |
694 | }; | 694 | }; |
695 | 695 | ||
696 | /* Stream Context Types (section 6.4.1) - bits 3:1 of stream ctx deq ptr */ | 696 | /* Stream Context Types (section 6.4.1) - bits 3:1 of stream ctx deq ptr */ |
@@ -803,7 +803,7 @@ struct xhci_virt_device { | |||
803 | */ | 803 | */ |
804 | struct xhci_device_context_array { | 804 | struct xhci_device_context_array { |
805 | /* 64-bit device addresses; we only write 32-bit addresses */ | 805 | /* 64-bit device addresses; we only write 32-bit addresses */ |
806 | u64 dev_context_ptrs[MAX_HC_SLOTS]; | 806 | __le64 dev_context_ptrs[MAX_HC_SLOTS]; |
807 | /* private xHCD pointers */ | 807 | /* private xHCD pointers */ |
808 | dma_addr_t dma; | 808 | dma_addr_t dma; |
809 | }; | 809 | }; |
@@ -816,10 +816,10 @@ struct xhci_device_context_array { | |||
816 | 816 | ||
817 | struct xhci_transfer_event { | 817 | struct xhci_transfer_event { |
818 | /* 64-bit buffer address, or immediate data */ | 818 | /* 64-bit buffer address, or immediate data */ |
819 | u64 buffer; | 819 | __le64 buffer; |
820 | u32 transfer_len; | 820 | __le32 transfer_len; |
821 | /* This field is interpreted differently based on the type of TRB */ | 821 | /* This field is interpreted differently based on the type of TRB */ |
822 | u32 flags; | 822 | __le32 flags; |
823 | }; | 823 | }; |
824 | 824 | ||
825 | /** Transfer Event bit fields **/ | 825 | /** Transfer Event bit fields **/ |
@@ -881,7 +881,9 @@ struct xhci_transfer_event { | |||
881 | #define COMP_STOP_INVAL 27 | 881 | #define COMP_STOP_INVAL 27 |
882 | /* Control Abort Error - Debug Capability - control pipe aborted */ | 882 | /* Control Abort Error - Debug Capability - control pipe aborted */ |
883 | #define COMP_DBG_ABORT 28 | 883 | #define COMP_DBG_ABORT 28 |
884 | /* TRB type 29 and 30 reserved */ | 884 | /* Max Exit Latency Too Large Error */ |
885 | #define COMP_MEL_ERR 29 | ||
886 | /* TRB type 30 reserved */ | ||
885 | /* Isoc Buffer Overrun - an isoc IN ep sent more data than could fit in TD */ | 887 | /* Isoc Buffer Overrun - an isoc IN ep sent more data than could fit in TD */ |
886 | #define COMP_BUFF_OVER 31 | 888 | #define COMP_BUFF_OVER 31 |
887 | /* Event Lost Error - xHC has an "internal event overrun condition" */ | 889 | /* Event Lost Error - xHC has an "internal event overrun condition" */ |
@@ -898,9 +900,9 @@ struct xhci_transfer_event { | |||
898 | 900 | ||
899 | struct xhci_link_trb { | 901 | struct xhci_link_trb { |
900 | /* 64-bit segment pointer*/ | 902 | /* 64-bit segment pointer*/ |
901 | u64 segment_ptr; | 903 | __le64 segment_ptr; |
902 | u32 intr_target; | 904 | __le32 intr_target; |
903 | u32 control; | 905 | __le32 control; |
904 | }; | 906 | }; |
905 | 907 | ||
906 | /* control bitfields */ | 908 | /* control bitfields */ |
@@ -909,9 +911,9 @@ struct xhci_link_trb { | |||
909 | /* Command completion event TRB */ | 911 | /* Command completion event TRB */ |
910 | struct xhci_event_cmd { | 912 | struct xhci_event_cmd { |
911 | /* Pointer to command TRB, or the value passed by the event data trb */ | 913 | /* Pointer to command TRB, or the value passed by the event data trb */ |
912 | u64 cmd_trb; | 914 | __le64 cmd_trb; |
913 | u32 status; | 915 | __le32 status; |
914 | u32 flags; | 916 | __le32 flags; |
915 | }; | 917 | }; |
916 | 918 | ||
917 | /* flags bitmasks */ | 919 | /* flags bitmasks */ |
@@ -943,6 +945,8 @@ struct xhci_event_cmd { | |||
943 | /* Interrupter Target - which MSI-X vector to target the completion event at */ | 945 | /* Interrupter Target - which MSI-X vector to target the completion event at */ |
944 | #define TRB_INTR_TARGET(p) (((p) & 0x3ff) << 22) | 946 | #define TRB_INTR_TARGET(p) (((p) & 0x3ff) << 22) |
945 | #define GET_INTR_TARGET(p) (((p) >> 22) & 0x3ff) | 947 | #define GET_INTR_TARGET(p) (((p) >> 22) & 0x3ff) |
948 | #define TRB_TBC(p) (((p) & 0x3) << 7) | ||
949 | #define TRB_TLBPC(p) (((p) & 0xf) << 16) | ||
946 | 950 | ||
947 | /* Cycle bit - indicates TRB ownership by HC or HCD */ | 951 | /* Cycle bit - indicates TRB ownership by HC or HCD */ |
948 | #define TRB_CYCLE (1<<0) | 952 | #define TRB_CYCLE (1<<0) |
@@ -962,15 +966,20 @@ struct xhci_event_cmd { | |||
962 | /* The buffer pointer contains immediate data */ | 966 | /* The buffer pointer contains immediate data */ |
963 | #define TRB_IDT (1<<6) | 967 | #define TRB_IDT (1<<6) |
964 | 968 | ||
969 | /* Block Event Interrupt */ | ||
970 | #define TRB_BEI (1<<9) | ||
965 | 971 | ||
966 | /* Control transfer TRB specific fields */ | 972 | /* Control transfer TRB specific fields */ |
967 | #define TRB_DIR_IN (1<<16) | 973 | #define TRB_DIR_IN (1<<16) |
974 | #define TRB_TX_TYPE(p) ((p) << 16) | ||
975 | #define TRB_DATA_OUT 2 | ||
976 | #define TRB_DATA_IN 3 | ||
968 | 977 | ||
969 | /* Isochronous TRB specific fields */ | 978 | /* Isochronous TRB specific fields */ |
970 | #define TRB_SIA (1<<31) | 979 | #define TRB_SIA (1<<31) |
971 | 980 | ||
972 | struct xhci_generic_trb { | 981 | struct xhci_generic_trb { |
973 | u32 field[4]; | 982 | __le32 field[4]; |
974 | }; | 983 | }; |
975 | 984 | ||
976 | union xhci_trb { | 985 | union xhci_trb { |
@@ -1118,10 +1127,10 @@ struct xhci_ring { | |||
1118 | 1127 | ||
1119 | struct xhci_erst_entry { | 1128 | struct xhci_erst_entry { |
1120 | /* 64-bit event ring segment address */ | 1129 | /* 64-bit event ring segment address */ |
1121 | u64 seg_addr; | 1130 | __le64 seg_addr; |
1122 | u32 seg_size; | 1131 | __le32 seg_size; |
1123 | /* Set to zero */ | 1132 | /* Set to zero */ |
1124 | u32 rsvd; | 1133 | __le32 rsvd; |
1125 | }; | 1134 | }; |
1126 | 1135 | ||
1127 | struct xhci_erst { | 1136 | struct xhci_erst { |
@@ -1286,10 +1295,10 @@ struct xhci_hcd { | |||
1286 | /* Is each xHCI roothub port a USB 3.0, USB 2.0, or USB 1.1 port? */ | 1295 | /* Is each xHCI roothub port a USB 3.0, USB 2.0, or USB 1.1 port? */ |
1287 | u8 *port_array; | 1296 | u8 *port_array; |
1288 | /* Array of pointers to USB 3.0 PORTSC registers */ | 1297 | /* Array of pointers to USB 3.0 PORTSC registers */ |
1289 | u32 __iomem **usb3_ports; | 1298 | __le32 __iomem **usb3_ports; |
1290 | unsigned int num_usb3_ports; | 1299 | unsigned int num_usb3_ports; |
1291 | /* Array of pointers to USB 2.0 PORTSC registers */ | 1300 | /* Array of pointers to USB 2.0 PORTSC registers */ |
1292 | u32 __iomem **usb2_ports; | 1301 | __le32 __iomem **usb2_ports; |
1293 | unsigned int num_usb2_ports; | 1302 | unsigned int num_usb2_ports; |
1294 | }; | 1303 | }; |
1295 | 1304 | ||
@@ -1322,12 +1331,12 @@ static inline struct usb_hcd *xhci_to_hcd(struct xhci_hcd *xhci) | |||
1322 | /* TODO: copied from ehci.h - can be refactored? */ | 1331 | /* TODO: copied from ehci.h - can be refactored? */ |
1323 | /* xHCI spec says all registers are little endian */ | 1332 | /* xHCI spec says all registers are little endian */ |
1324 | static inline unsigned int xhci_readl(const struct xhci_hcd *xhci, | 1333 | static inline unsigned int xhci_readl(const struct xhci_hcd *xhci, |
1325 | __u32 __iomem *regs) | 1334 | __le32 __iomem *regs) |
1326 | { | 1335 | { |
1327 | return readl(regs); | 1336 | return readl(regs); |
1328 | } | 1337 | } |
1329 | static inline void xhci_writel(struct xhci_hcd *xhci, | 1338 | static inline void xhci_writel(struct xhci_hcd *xhci, |
1330 | const unsigned int val, __u32 __iomem *regs) | 1339 | const unsigned int val, __le32 __iomem *regs) |
1331 | { | 1340 | { |
1332 | xhci_dbg(xhci, | 1341 | xhci_dbg(xhci, |
1333 | "`MEM_WRITE_DWORD(3'b000, 32'h%p, 32'h%0x, 4'hf);\n", | 1342 | "`MEM_WRITE_DWORD(3'b000, 32'h%p, 32'h%0x, 4'hf);\n", |
@@ -1345,7 +1354,7 @@ static inline void xhci_writel(struct xhci_hcd *xhci, | |||
1345 | * the high dword, and write order is irrelevant. | 1354 | * the high dword, and write order is irrelevant. |
1346 | */ | 1355 | */ |
1347 | static inline u64 xhci_read_64(const struct xhci_hcd *xhci, | 1356 | static inline u64 xhci_read_64(const struct xhci_hcd *xhci, |
1348 | __u64 __iomem *regs) | 1357 | __le64 __iomem *regs) |
1349 | { | 1358 | { |
1350 | __u32 __iomem *ptr = (__u32 __iomem *) regs; | 1359 | __u32 __iomem *ptr = (__u32 __iomem *) regs; |
1351 | u64 val_lo = readl(ptr); | 1360 | u64 val_lo = readl(ptr); |
@@ -1353,7 +1362,7 @@ static inline u64 xhci_read_64(const struct xhci_hcd *xhci, | |||
1353 | return val_lo + (val_hi << 32); | 1362 | return val_lo + (val_hi << 32); |
1354 | } | 1363 | } |
1355 | static inline void xhci_write_64(struct xhci_hcd *xhci, | 1364 | static inline void xhci_write_64(struct xhci_hcd *xhci, |
1356 | const u64 val, __u64 __iomem *regs) | 1365 | const u64 val, __le64 __iomem *regs) |
1357 | { | 1366 | { |
1358 | __u32 __iomem *ptr = (__u32 __iomem *) regs; | 1367 | __u32 __iomem *ptr = (__u32 __iomem *) regs; |
1359 | u32 val_lo = lower_32_bits(val); | 1368 | u32 val_lo = lower_32_bits(val); |