48 { .
name =
"xhci.message" };
52 { .
name =
"xhci.stream" };
56 { .
name =
"xhci.event" };
60 { .
name =
"xhci.transfer" };
64 __einfo_error ( EINFO_EIO_DATA ) 65 #define EINFO_EIO_DATA \ 66 __einfo_uniqify ( EINFO_EIO, ( 2 - 0 ), \ 69 __einfo_error ( EINFO_EIO_BABBLE ) 70 #define EINFO_EIO_BABBLE \ 71 __einfo_uniqify ( EINFO_EIO, ( 3 - 0 ), \ 74 __einfo_error ( EINFO_EIO_USB ) 75 #define EINFO_EIO_USB \ 76 __einfo_uniqify ( EINFO_EIO, ( 4 - 0 ), \ 77 "USB transaction error" ) 79 __einfo_error ( EINFO_EIO_TRB ) 80 #define EINFO_EIO_TRB \ 81 __einfo_uniqify ( EINFO_EIO, ( 5 - 0 ), \ 84 __einfo_error ( EINFO_EIO_STALL ) 85 #define EINFO_EIO_STALL \ 86 __einfo_uniqify ( EINFO_EIO, ( 6 - 0 ), \ 88 #define EIO_RESOURCE \ 89 __einfo_error ( EINFO_EIO_RESOURCE ) 90 #define EINFO_EIO_RESOURCE \ 91 __einfo_uniqify ( EINFO_EIO, ( 7 - 0 ), \ 93 #define EIO_BANDWIDTH \ 94 __einfo_error ( EINFO_EIO_BANDWIDTH ) 95 #define EINFO_EIO_BANDWIDTH \ 96 __einfo_uniqify ( EINFO_EIO, ( 8 - 0 ), \ 98 #define EIO_NO_SLOTS \ 99 __einfo_error ( EINFO_EIO_NO_SLOTS ) 100 #define EINFO_EIO_NO_SLOTS \ 101 __einfo_uniqify ( EINFO_EIO, ( 9 - 0 ), \ 102 "No slots available" ) 103 #define EIO_STREAM_TYPE \ 104 __einfo_error ( EINFO_EIO_STREAM_TYPE ) 105 #define EINFO_EIO_STREAM_TYPE \ 106 __einfo_uniqify ( EINFO_EIO, ( 10 - 0 ), \ 107 "Invalid stream type" ) 109 __einfo_error ( EINFO_EIO_SLOT ) 110 #define EINFO_EIO_SLOT \ 111 __einfo_uniqify ( EINFO_EIO, ( 11 - 0 ), \ 113 #define EIO_ENDPOINT \ 114 __einfo_error ( EINFO_EIO_ENDPOINT ) 115 #define EINFO_EIO_ENDPOINT \ 116 __einfo_uniqify ( EINFO_EIO, ( 12 - 0 ), \ 117 "Endpoint not enabled" ) 119 __einfo_error ( EINFO_EIO_SHORT ) 120 #define EINFO_EIO_SHORT \ 121 __einfo_uniqify ( EINFO_EIO, ( 13 - 0 ), \ 123 #define EIO_UNDERRUN \ 124 __einfo_error ( EINFO_EIO_UNDERRUN ) 125 #define EINFO_EIO_UNDERRUN \ 126 __einfo_uniqify ( EINFO_EIO, ( 14 - 0 ), \ 128 #define EIO_OVERRUN \ 129 __einfo_error ( EINFO_EIO_OVERRUN ) 130 #define EINFO_EIO_OVERRUN \ 131 __einfo_uniqify ( EINFO_EIO, ( 15 - 0 ), \ 133 #define EIO_VF_RING_FULL \ 134 __einfo_error ( EINFO_EIO_VF_RING_FULL ) 135 #define EINFO_EIO_VF_RING_FULL \ 136 __einfo_uniqify ( EINFO_EIO, ( 16 - 0 ), \ 137 "Virtual function event ring full" ) 138 #define EIO_PARAMETER \ 139 __einfo_error ( EINFO_EIO_PARAMETER ) 140 #define EINFO_EIO_PARAMETER \ 141 __einfo_uniqify ( EINFO_EIO, ( 17 - 0 ), \ 143 #define EIO_BANDWIDTH_OVERRUN \ 144 __einfo_error ( EINFO_EIO_BANDWIDTH_OVERRUN ) 145 #define EINFO_EIO_BANDWIDTH_OVERRUN \ 146 __einfo_uniqify ( EINFO_EIO, ( 18 - 0 ), \ 147 "Bandwidth overrun" ) 148 #define EIO_CONTEXT \ 149 __einfo_error ( EINFO_EIO_CONTEXT ) 150 #define EINFO_EIO_CONTEXT \ 151 __einfo_uniqify ( EINFO_EIO, ( 19 - 0 ), \ 152 "Context state error" ) 153 #define EIO_NO_PING \ 154 __einfo_error ( EINFO_EIO_NO_PING ) 155 #define EINFO_EIO_NO_PING \ 156 __einfo_uniqify ( EINFO_EIO, ( 20 - 0 ), \ 158 #define EIO_RING_FULL \ 159 __einfo_error ( EINFO_EIO_RING_FULL ) 160 #define EINFO_EIO_RING_FULL \ 161 __einfo_uniqify ( EINFO_EIO, ( 21 - 0 ), \ 163 #define EIO_INCOMPATIBLE \ 164 __einfo_error ( EINFO_EIO_INCOMPATIBLE ) 165 #define EINFO_EIO_INCOMPATIBLE \ 166 __einfo_uniqify ( EINFO_EIO, ( 22 - 0 ), \ 167 "Incompatible device" ) 169 __einfo_error ( EINFO_EIO_MISSED ) 170 #define EINFO_EIO_MISSED \ 171 __einfo_uniqify ( EINFO_EIO, ( 23 - 0 ), \ 172 "Missed service error" ) 173 #define EIO_CMD_STOPPED \ 174 __einfo_error ( EINFO_EIO_CMD_STOPPED ) 175 #define EINFO_EIO_CMD_STOPPED \ 176 __einfo_uniqify ( EINFO_EIO, ( 24 - 0 ), \ 177 "Command ring stopped" ) 178 #define EIO_CMD_ABORTED \ 179 __einfo_error ( EINFO_EIO_CMD_ABORTED ) 180 #define EINFO_EIO_CMD_ABORTED \ 181 __einfo_uniqify ( EINFO_EIO, ( 25 - 0 ), \ 184 __einfo_error ( EINFO_EIO_STOP ) 185 #define EINFO_EIO_STOP \ 186 __einfo_uniqify ( EINFO_EIO, ( 26 - 0 ), \ 188 #define EIO_STOP_LEN \ 189 __einfo_error ( EINFO_EIO_STOP_LEN ) 190 #define EINFO_EIO_STOP_LEN \ 191 __einfo_uniqify ( EINFO_EIO, ( 27 - 0 ), \ 192 "Stopped - length invalid" ) 193 #define EIO_STOP_SHORT \ 194 __einfo_error ( EINFO_EIO_STOP_SHORT ) 195 #define EINFO_EIO_STOP_SHORT \ 196 __einfo_uniqify ( EINFO_EIO, ( 28 - 0 ), \ 197 "Stopped - short packet" ) 198 #define EIO_LATENCY \ 199 __einfo_error ( EINFO_EIO_LATENCY ) 200 #define EINFO_EIO_LATENCY \ 201 __einfo_uniqify ( EINFO_EIO, ( 29 - 0 ), \ 202 "Maximum exit latency too large" ) 204 __einfo_error ( EINFO_EIO_ISOCH ) 205 #define EINFO_EIO_ISOCH \ 206 __einfo_uniqify ( EINFO_EIO, ( 31 - 0 ), \ 207 "Isochronous buffer overrun" ) 208 #define EPROTO_LOST \ 209 __einfo_error ( EINFO_EPROTO_LOST ) 210 #define EINFO_EPROTO_LOST \ 211 __einfo_uniqify ( EINFO_EPROTO, ( 32 - 32 ), \ 213 #define EPROTO_UNDEFINED \ 214 __einfo_error ( EINFO_EPROTO_UNDEFINED ) 215 #define EINFO_EPROTO_UNDEFINED \ 216 __einfo_uniqify ( EINFO_EPROTO, ( 33 - 32 ), \ 218 #define EPROTO_STREAM_ID \ 219 __einfo_error ( EINFO_EPROTO_STREAM_ID ) 220 #define EINFO_EPROTO_STREAM_ID \ 221 __einfo_uniqify ( EINFO_EPROTO, ( 34 - 32 ), \ 222 "Invalid stream ID" ) 223 #define EPROTO_SECONDARY \ 224 __einfo_error ( EINFO_EPROTO_SECONDARY ) 225 #define EINFO_EPROTO_SECONDARY \ 226 __einfo_uniqify ( EINFO_EPROTO, ( 35 - 32 ), \ 227 "Secondary bandwidth error" ) 228 #define EPROTO_SPLIT \ 229 __einfo_error ( EINFO_EPROTO_SPLIT ) 230 #define EINFO_EPROTO_SPLIT \ 231 __einfo_uniqify ( EINFO_EPROTO, ( 36 - 32 ), \ 232 "Split transaction error" ) 233 #define ECODE(code) \ 234 ( ( (code) < 32 ) ? \ 235 EUNIQ ( EINFO_EIO, ( (code) & 31 ), EIO_DATA, EIO_BABBLE, \ 236 EIO_USB, EIO_TRB, EIO_STALL, EIO_RESOURCE, \ 237 EIO_BANDWIDTH, EIO_NO_SLOTS, EIO_STREAM_TYPE, \ 238 EIO_SLOT, EIO_ENDPOINT, EIO_SHORT, EIO_UNDERRUN, \ 239 EIO_OVERRUN, EIO_VF_RING_FULL, EIO_PARAMETER, \ 240 EIO_BANDWIDTH_OVERRUN, EIO_CONTEXT, EIO_NO_PING, \ 241 EIO_RING_FULL, EIO_INCOMPATIBLE, EIO_MISSED, \ 242 EIO_CMD_STOPPED, EIO_CMD_ABORTED, EIO_STOP, \ 243 EIO_STOP_LEN, EIO_STOP_SHORT, EIO_LATENCY, \ 246 EUNIQ ( EINFO_EPROTO, ( (code) & 31 ), EPROTO_LOST, \ 247 EPROTO_UNDEFINED, EPROTO_STREAM_ID, \ 248 EPROTO_SECONDARY, EPROTO_SPLIT ) : \ 278 xhci->
op = ( xhci->
cap + caplength );
279 xhci->
run = ( xhci->
cap + rtsoff );
280 xhci->
db = ( xhci->
cap + dboff );
281 DBGC2 ( xhci,
"XHCI %s cap %08lx op %08lx run %08lx db %08lx\n",
291 DBGC ( xhci,
"XHCI %s has %d slots %d intrs %d ports\n",
297 DBGC2 ( xhci,
"XHCI %s needs %d scratchpads\n",
311 DBGC2 ( xhci,
"XHCI %s page size %zd bytes\n",
373 if ( (
value & ~0xffffffffULL ) && ! xhci->
addr64 ) {
374 DBGC ( xhci,
"XHCI %s cannot access address %lx\n",
455 DBGC ( xhci,
"XHCI %s USBCMD %08x%s%s\n", xhci->
name, usbcmd,
461 DBGC ( xhci,
"XHCI %s USBSTS %08x%s\n", xhci->
name, usbsts,
466 DBGC ( xhci,
"XHCI %s PAGESIZE %08x\n", xhci->
name, pagesize );
470 DBGC ( xhci,
"XHCI %s DNCTRL %08x\n", xhci->
name, dnctrl );
474 DBGC ( xhci,
"XHCI %s CONFIG %08x\n", xhci->
name, config );
484 unsigned int port ) {
496 DBGC ( xhci,
"XHCI %s-%d PORTSC %08x%s%s%s%s psiv=%d\n",
506 DBGC ( xhci,
"XHCI %s-%d PORTPMSC %08x\n", xhci->
name,
port, portpmsc );
510 DBGC ( xhci,
"XHCI %s-%d PORTLI %08x\n", xhci->
name,
port, portli );
514 DBGC ( xhci,
"XHCI %s-%d PORTHLPMC %08x\n",
541 DBGC ( xhci,
"XHCI %s has no USB legacy support capability\n",
550 DBGC ( xhci,
"XHCI %s USB legacy support already disabled\n",
583 DBGC ( xhci,
"XHCI %s claimed ownership from BIOS\n",
588 DBGC ( xhci,
"XHCI %s warning: BIOS retained " 589 "SMIs: %08x\n", xhci->
name, ctlsts );
601 DBGC ( xhci,
"XHCI %s could not claim ownership from BIOS: forcibly " 602 "disabling SMIs\n", xhci->
name );
619 DBGC ( xhci,
"XHCI %s not releasing ownership to BIOS\n",
626 DBGC ( xhci,
"XHCI %s released ownership to BIOS\n", xhci->
name );
643 static const char *exponents[4] = {
"",
"k",
"M",
"G" };
644 static char buf[ 10 ];
645 unsigned int mantissa;
646 unsigned int exponent;
653 snprintf ( buf,
sizeof ( buf ),
"%d%sbps",
654 mantissa, exponents[exponent] );
666 unsigned int port ) {
687 DBGC ( xhci,
"XHCI %s-%d has no supported protocol\n",
700 unsigned int port ) {
731 DBGC2 ( xhci,
"XHCI %s-%d %sv%04x type %d",
736 DBGC2 ( xhci,
" speeds" );
737 for ( i = 0 ; i < psic ; i++ ) {
741 DBGC2 ( xhci,
" %d:%s", psiv,
746 DBGC2 ( xhci,
" (ignored)" );
747 DBGC2 ( xhci,
"\n" );
785 unsigned int psiv ) {
788 unsigned int mantissa;
789 unsigned int exponent;
807 for ( i = 0 ; i < psic ; i++ ) {
813 speed =
USB_SPEED ( mantissa, exponent );
820 DBGC ( xhci,
"XHCI %s-%d spurious PSI value %d: " 821 "assuming PSI table is invalid\n",
834 DBGC ( xhci,
"XHCI %s-%d unrecognised PSI value %d\n",
849 unsigned int speed ) {
852 unsigned int mantissa;
853 unsigned int exponent;
875 DBGC ( xhci,
"XHCI %s-%d non-standard speed %d\n",
882 for ( i = 0 ; i < psic ; i++ ) {
886 if ( speed ==
USB_SPEED ( mantissa, exponent ) ) {
892 DBGC ( xhci,
"XHCI %s-%d unrepresentable speed %#x\n",
924 DBGC ( xhci,
"XHCI %s could not allocate DCBAA\n", xhci->
name );
936 DBGC2 ( xhci,
"XHCI %s DCBAA at [%08lx,%08lx)\n", xhci->
name,
957 for ( i = 0 ; i <= xhci->
slots ; i++ )
990 if ( ! scratch->
count )
997 if ( ! scratch->
buffer ) {
998 DBGC ( xhci,
"XHCI %s could not allocate scratchpad buffers\n",
1006 array_len = ( scratch->
count *
sizeof ( scratch->
array[0] ) );
1009 if ( ! scratch->
array ) {
1010 DBGC ( xhci,
"XHCI %s could not allocate scratchpad buffer " 1011 "array\n", xhci->
name );
1013 goto err_alloc_array;
1019 for ( i = 0 ; i < scratch->
count ; i++ ) {
1029 DBGC2 ( xhci,
"XHCI %s scratchpad [%08lx,%08lx) array [%08lx,%08lx)\n",
1054 if ( ! scratch->
count )
1062 array_len = ( scratch->
count *
sizeof ( scratch->
array[0] ) );
1126 DBGC ( xhci,
"XHCI %s timed out waiting for stop\n", xhci->
name );
1164 DBGC ( xhci,
"XHCI %s timed out waiting for reset\n", xhci->
name );
1213 unsigned int shift,
unsigned int slot,
1214 unsigned int target,
unsigned int stream ) {
1223 memset ( ring, 0,
sizeof ( *ring ) );
1224 ring->
shift = shift;
1225 count = ( 1U << shift );
1227 ring->
len = ( (
count + 1 ) *
sizeof ( ring->
trb[0] ) );
1228 ring->
db = ( xhci->
db + (
slot *
sizeof ( ring->
dbval ) ) );
1233 if ( ! ring->
iobuf ) {
1235 goto err_alloc_iobuf;
1241 if ( ! ring->
trb ) {
1290 for ( i = 0 ; i <
count ; i++ )
1326 prod = ring->
prod++;
1329 index = ( prod & mask );
1388 unsigned int count ) {
1420 }
while ( iobuf ==
NULL );
1457 goto err_ring_alloc;
1465 DBGC2 ( xhci,
"XHCI %s CRCR at [%08lx,%08lx)\n", xhci->
name,
1507 len = (
count *
sizeof (
event->trb[0] ) );
1510 if ( ! event->trb ) {
1517 event->segment =
dma_alloc ( xhci->
dma, &event->segment_map,
1518 sizeof ( event->segment[0] ),
1520 if ( ! event->segment ) {
1522 goto err_alloc_segment;
1524 memset ( event->segment, 0, sizeof ( event->segment[0] ) );
1533 goto err_writeq_erdp;
1535 dma ( &event->segment_map, event->segment ),
1537 goto err_writeq_erstba;
1539 DBGC2 ( xhci,
"XHCI %s event ring [%08lx,%08lx) table [%08lx,%08lx)\n",
1544 sizeof ( event->segment[0] ) ) );
1551 dma_free ( &event->segment_map, event->segment,
1552 sizeof ( event->segment[0] ) );
1575 dma_free ( &event->segment_map, event->segment,
1576 sizeof ( event->segment[0] ) );
1580 len = (
count *
sizeof (
event->trb[0] ) );
1603 DBGC ( xhci,
"XHCI %s transfer event invalid slot %d:\n",
1605 DBGC_HDA ( xhci, 0, trb,
sizeof ( *trb ) );
1612 DBGC ( xhci,
"XHCI %s slot %d transfer event invalid epid " 1614 DBGC_HDA ( xhci, 0, trb,
sizeof ( *trb ) );
1631 DBGC ( xhci,
"XHCI %s slot %d ctx %d failed (code %d): %s\n",
1634 DBGC_HDA ( xhci, 0, trb,
sizeof ( *trb ) );
1669 DBGC2 ( xhci,
"XHCI %s command ring stopped\n", xhci->
name );
1676 DBGC ( xhci,
"XHCI %s unexpected completion (code %d): %s\n",
1678 DBGC_HDA ( xhci, 0, trb,
sizeof ( *trb ) );
1730 DBGC ( xhci,
"XHCI %s host controller event (code %d): %s\n",
1743 unsigned int count = ( 1 << shift );
1744 unsigned int mask = (
count - 1 );
1745 unsigned int consumed;
1754 for ( consumed = 0 ; ; consumed++ ) {
1758 trb = &
event->trb[
event->cons & mask ];
1787 DBGC ( xhci,
"XHCI %s unrecognised event %#x\n:",
1788 xhci->
name, ( event->cons - 1 ) );
1790 trb,
sizeof ( *trb ) );
1813 DBGC2 ( xhci,
"XHCI %s aborting command\n", xhci->
name );
1828 DBGC ( xhci,
"XHCI %s failed to abort command\n", xhci->
name );
1864 DBGC ( xhci,
"XHCI %s command ring busy\n", xhci->
name );
1889 DBGC ( xhci,
"XHCI %s command failed (code " 1890 "%d): %s\n", xhci->
name, complete->
code,
1892 DBGC_HDA ( xhci, 0, trb,
sizeof ( *trb ) );
1903 DBGC ( xhci,
"XHCI %s timed out waiting for completion\n", xhci->
name );
1934 DBGC ( xhci,
"XHCI %s NOP failed: %s\n",
1939 DBGC2 ( xhci,
"XHCI %s NOP completed successfully\n", xhci->
name );
1951 unsigned int type ) {
1959 memset ( enable, 0,
sizeof ( *enable ) );
1965 DBGC ( xhci,
"XHCI %s could not enable new slot: %s\n",
1973 DBGC2 ( xhci,
"XHCI %s slot %d enabled\n", xhci->
name,
slot );
1985 unsigned int slot ) {
1991 memset ( disable, 0,
sizeof ( *disable ) );
1997 DBGC ( xhci,
"XHCI %s could not disable slot %d: %s\n",
2002 DBGC2 ( xhci,
"XHCI %s slot %d disabled\n", xhci->
name,
slot );
2040 populate ( xhci,
slot, endpoint,
input );
2043 memset ( context, 0,
sizeof ( *context ) );
2079 control_ctx =
input;
2118 DBGC ( xhci,
"XHCI %s slot %d could not assign address: %s\n",
2124 slot_ctx = (
slot->context +
2127 DBGC2 ( xhci,
"XHCI %s slot %d assigned address %d to %s\n",
2151 control_ctx =
input;
2153 ( 1 << endpoint->
ctx ) );
2158 (
slot->ports ? 1 : 0 ),
2190 DBGC ( xhci,
"XHCI %s slot %d ctx %d could not configure: %s\n",
2195 DBGC2 ( xhci,
"XHCI %s slot %d ctx %d configured\n",
2217 control_ctx =
input;
2244 DBGC ( xhci,
"XHCI %s slot %d ctx %d could not deconfigure: " 2250 DBGC2 ( xhci,
"XHCI %s slot %d ctx %d deconfigured\n",
2272 control_ctx =
input;
2274 ( 1 << endpoint->
ctx ) );
2303 DBGC ( xhci,
"XHCI %s slot %d ctx %d could not (re-)evaluate: " 2309 DBGC2 ( xhci,
"XHCI %s slot %d ctx %d (re-)evaluated\n",
2330 memset ( reset, 0,
sizeof ( *reset ) );
2337 DBGC ( xhci,
"XHCI %s slot %d ctx %d could not reset endpoint " 2362 memset ( stop, 0,
sizeof ( *stop ) );
2369 DBGC ( xhci,
"XHCI %s slot %d ctx %d could not stop endpoint " 2401 memset ( dequeue, 0,
sizeof ( *dequeue ) );
2414 DBGC ( xhci,
"XHCI %s slot %d ctx %d could not set TR dequeue " 2415 "pointer in state %d: %s\n", xhci->
name,
slot->id,
2465 endpoint =
zalloc (
sizeof ( *endpoint ) );
2471 slot->endpoint[
ctx] = endpoint;
2478 endpoint->
context = ( ( (
void * )
slot->context ) +
2485 goto err_ring_alloc;
2490 goto err_configure_endpoint;
2492 DBGC2 (
xhci,
"XHCI %s slot %d ctx %d ring [%08lx,%08lx)\n",
2498 err_configure_endpoint:
2517 unsigned int ctx = endpoint->
ctx;
2559 DBGC ( xhci,
"XHCI %s slot %d ctx %d reset\n",
2609 memset ( trbs, 0,
sizeof ( trbs ) );
2611 packet = iobuf->
data;
2612 iob_pull ( iobuf,
sizeof ( *packet ) );
2613 setup = &(trb++)->setup;
2646 ( trb - trbs ) ) ) != 0 )
2675 if ( zlp || (
count == 0 ) )
2714 memset ( &trbs, 0,
sizeof ( trbs ) );
2715 for ( i = 0 ; i <
count ; i ++ ) {
2719 if ( trb_len >
len )
2736 if ( zlp && (
count > 1 ) )
2786 DBGC (
xhci,
"XHCI %s-%d has no slot type\n",
2795 goto err_enable_slot;
2797 assert ( (
id > 0 ) && ( (
unsigned int ) id <= xhci->slots ) );
2813 slot->tt_id = tt_slot->
id;
2821 if ( !
slot->context ) {
2823 goto err_alloc_context;
2832 DBGC2 (
xhci,
"XHCI %s slot %d device context [%08lx,%08lx) for %s\n",
2858 unsigned int id =
slot->id;
2871 DBGC ( xhci,
"XHCI %s slot %d leaking context memory\n",
2877 if (
slot->context ) {
2939 if ( ! xhci->
slot ) {
2941 goto err_slot_alloc;
2946 goto err_dcbaa_alloc;
2950 goto err_scratchpad_alloc;
2954 goto err_command_alloc;
2958 goto err_event_alloc;
2971 err_scratchpad_alloc:
2990 for ( i = 0 ; i <= xhci->
slots ; i++ )
3078 for ( i = 1 ; i <= xhci->
ports ; i++ ) {
3091 for ( i = 1 ; i <= xhci->
ports ; i++ ) {
3152 DBGC ( xhci,
"XHCI %s-%d timed out waiting for port to enable\n",
3209 DBGC2 ( xhci,
"XHCI %s-%d status is %08x\n",
3210 xhci->
name,
port->address, portsc );
3217 port->disconnected |= csc;
3242 port->speed = speed;
3259 DBGC ( xhci,
"XHCI %s-%d nonsensical CLEAR_TT for %s %s\n", xhci->
name,
3325 DBGC ( xhci,
"XHCI %s enabling SuperSpeed on ports %08x\n",
3336 DBGC ( xhci,
"XHCI %s routing ports %08x from EHCI to xHCI\n",
3369 unsigned long bar_start;
3375 xhci =
zalloc (
sizeof ( *xhci ) );
3390 if ( ! xhci->
regs ) {
3418 if ( ! xhci->
bus ) {
3426 for ( i = 1 ; i <= xhci->
ports ; i++ ) {
3472 DBGC ( xhci,
"XHCI %s DMA was disabled\n", xhci->
name );
3499 PCI_ROM ( 0xffff, 0xffff,
"xhci",
"xHCI", 0 ),
#define XHCI_BAD_PSIV
Invalid protocol speed ID values quirk.
static __always_inline void struct dma_mapping size_t size_t align
#define iob_pull(iobuf, len)
uint8_t burst
Maximum burst size.
#define XHCI_USBLEGSUP_MAX_WAIT_MS
Maximum time to wait for BIOS to release ownership.
#define XHCI_SUPPORTED_PORTS
Supported protocol ports.
A disable slot transfer request block.
static int xhci_root_speed(struct usb_hub *hub, struct usb_port *port)
Update root hub port speed.
#define XHCI_SUPPORTED_SLOT_TYPE(slot)
Supported protocol slot type.
static void usb_endpoint_set_hostdata(struct usb_endpoint *ep, void *priv)
Set USB endpoint host controller private data.
static void xhci_command_free(struct xhci_device *xhci)
Free command ring.
#define XHCI_TRB_TC
Transfer request block toggle cycle bit flag.
uint8_t type
Endpoint type.
#define PCI_CLASS_ID(base, sub, progif)
Construct PCI class ID.
struct arbelprm_rc_send_wqe rc
#define XHCI_STATUS_IN
Input status direction.
A status stage transfer request block.
struct xhci_trb_context context
Input context TRB.
uint64_t command
Command TRB pointer.
A transfer request block.
uint8_t readb(volatile uint8_t *io_addr)
Read byte from memory-mapped device.
uint32_t dbval
Doorbell register value.
static struct io_buffer * xhci_dequeue(struct xhci_trb_ring *ring)
Dequeue a transfer request block.
struct dma_device dma
DMA device.
struct xhci_trb_common common
Common fields.
static int xhci_root_clear_tt(struct usb_hub *hub, struct usb_port *port, struct usb_endpoint *ep)
Clear transaction translator buffer.
static void xhci_evaluate_context_input(struct xhci_device *xhci, struct xhci_slot *slot __unused, struct xhci_endpoint *endpoint, void *input)
Populate evaluate context input context.
static struct profiler xhci_message_profiler __profiler
Message transfer profiler.
unsigned int ports
Number of ports.
#define XHCI_CONFIG_MAX_SLOTS_EN(slots)
Maximum device slots enabled.
static int xhci_stop(struct xhci_device *xhci)
Stop xHCI device.
struct xhci_dcbaa dcbaa
Device context base address array.
static int xhci_device_open(struct usb_device *usb)
Open device.
#define EBUSY
Device or resource busy.
struct arbelprm_completion_queue_entry normal
#define XHCI_TRB_ENABLE_SLOT
An enable slot transfer request block.
static unsigned int unsigned int reg
static physaddr_t xhci_ring_consumed(struct xhci_trb_ring *ring)
Calculate physical address of most recently consumed TRB.
#define XHCI_OP_USBSTS
USB status register.
#define XHCI_USBLEGSUP_BIOS_OWNED
USB legacy support BIOS ownership flag.
#define XHCI_PORTSC_PSIV(portsc)
Port speed ID value.
static int xhci_address_device(struct xhci_device *xhci, struct xhci_slot *slot)
Address device.
#define XHCI_CTX_END
End of contexts.
#define XHCI_ICI(ctx)
Input context index.
static void xhci_hub_close(struct usb_hub *hub __unused)
Close hub.
#define XHCI_XECP_NEXT(xecp)
Next xHCI extended capability pointer.
static unsigned int xhci_extended_capability(struct xhci_device *xhci, unsigned int id, unsigned int offset)
Find extended capability.
struct xhci_device * xhci
xHCI device
#define XHCI_TRB_SET_TR_DEQUEUE_POINTER
A set transfer ring dequeue pointer transfer request block.
unsigned int cons
Consumer counter.
uint32_t next
Next descriptor address.
static size_t xhci_device_context_offset(struct xhci_device *xhci, unsigned int ctx)
Calculate device context offset.
void * run
Runtime registers.
A set transfer ring dequeue pointer transfer request block.
struct usb_bus * alloc_usb_bus(struct device *dev, unsigned int ports, size_t mtu, struct usb_host_operations *op)
Allocate USB bus.
#define XHCI_PORT_RESET_MAX_WAIT_MS
Maximum time to wait for a port reset to complete.
#define USB_ENDPOINT_ATTR_TYPE_MASK
Endpoint attribute transfer type mask.
size_t len
Length of transfer request blocks.
#define XHCI_SUPPORTED_SLOT
Supported protocol slot.
An input control context.
#define XHCI_HCSPARAMS1_PORTS(params)
Number of ports.
static size_t xhci_align(size_t len)
Calculate buffer alignment.
unsigned long driver_data
Arbitrary driver data.
struct xhci_trb_ring command
Command ring.
static unsigned int xhci_ring_fill(struct xhci_trb_ring *ring)
Calculate space used in TRB ring.
A command completion event transfer request block.
#define XHCI_TRB_DISABLE_SLOT
A disable slot transfer request block.
uint8_t state
Endpoint state.
struct pci_device_id * ids
PCI ID table.
static void usb_set_hostdata(struct usb_device *usb, void *priv)
Set USB device host controller private data.
uint32_t type
Operating system type.
#define XHCI_PCH_XUSB2PR
Intel PCH USB2 port routing register.
struct xhci_trb_transfer transfer
Transfer event.
#define EPIPE
Broken pipe.
A port status change transfer request block.
uint16_t trb_len
Average TRB length.
union xhci_trb * pending
Current command (if any)
#define XHCI_SUPPORTED_PSI_VALUE(psi)
Supported protocol PSI value.
#define XHCI_EP_TYPE(type)
Endpoint type.
physaddr_t dma_phys(struct dma_mapping *map, physaddr_t addr)
Get DMA address from physical address.
struct xhci_endpoint * endpoint[XHCI_CTX_END]
Endpoints, indexed by context ID.
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
unsigned long user_to_phys(userptr_t userptr, off_t offset)
Convert user pointer to physical address.
static int xhci_set_tr_dequeue_pointer(struct xhci_device *xhci, struct xhci_slot *slot, struct xhci_endpoint *endpoint)
Set transfer ring dequeue pointer.
#define XHCI_XECP_ID_SUPPORTED
Supported protocol extended capability.
static int xhci_context(struct xhci_device *xhci, struct xhci_slot *slot, struct xhci_endpoint *endpoint, unsigned int type, void(*populate)(struct xhci_device *xhci, struct xhci_slot *slot, struct xhci_endpoint *endpoint, void *input))
Issue context-based command and wait for completion.
struct dma_mapping map
DMA mapping.
struct pci_driver xhci_driver __pci_driver
XHCI PCI driver.
#define XHCI_EP_TYPE_CONTROL
Control endpoint type.
uint8_t code
Completion code.
struct xhci_trb_disable_slot disable
Disable slot TRB.
#define XHCI_HCSPARAMS1_INTRS(params)
Number of interrupters.
#define ENOENT
No such file or directory.
static __always_inline void dma_set_mask_64bit(struct dma_device *dma)
Set 64-bit addressable space mask.
An enable slot transfer request block.
struct usb_device * usb
Currently attached device (if in use)
#define XHCI_SETUP_OUT
Setup stage output data direction.
static void xhci_deconfigure_endpoint_input(struct xhci_device *xhci __unused, struct xhci_slot *slot __unused, struct xhci_endpoint *endpoint, void *input)
Populate deconfigure endpoint input context.
#define XHCI_OP_PORTHLPMC(port)
Port hardware link power management control register.
struct usb_bus * bus
USB bus.
struct xhci_trb_enable_slot enable
Enable slot TRB.
static void xhci_ring_free(struct xhci_trb_ring *ring)
Free transfer request block ring.
struct dma_mapping buffer_map
Buffer DMA mapping.
static int xhci_configure_endpoint(struct xhci_device *xhci, struct xhci_slot *slot, struct xhci_endpoint *endpoint)
Configure endpoint.
#define cpu_to_le64(value)
unsigned int count
Number of page-sized scratchpad buffers.
int pci_read_config_word(struct pci_device *pci, unsigned int where, uint16_t *value)
Read 16-bit word from PCI configuration space.
static int xhci_command_alloc(struct xhci_device *xhci)
Allocate command ring.
A data stage transfer request block.
uint8_t code
Completion code.
void * db
Doorbell register.
static void xhci_init(struct xhci_device *xhci, void *regs)
Initialise device.
#define XHCI_TRB_RESET_ENDPOINT
A reset endpoint transfer request block.
#define PCI_COMMAND
PCI command.
#define XHCI_TRANSFER_TRBS_LOG2
Number of TRBs in a transfer ring.
#define XHCI_DATA_IN
Input data direction.
#define XHCI_TRB_PORT_STATUS
A port status change transfer request block.
static __always_inline int iob_map(struct io_buffer *iobuf, struct dma_device *dma, size_t len, int flags)
Map I/O buffer for DMA.
#define XHCI_PORTSC_CSC
Connect status change.
uint8_t direction
Transfer direction.
struct golan_eq_context ctx
A data structure for storing profiling information.
static int xhci_endpoint_stream(struct usb_endpoint *ep, struct io_buffer *iobuf, int zlp)
Enqueue stream transfer.
#define XHCI_RESET_MAX_WAIT_MS
Maximum time to wait for reset to complete.
static void profile_stop(struct profiler *profiler)
Stop profiling.
#define XHCI_COMMAND_ABORT_DELAY_MS
Time to delay after aborting a command.
#define XHCI_OP_PORTLI(port)
Port link info register.
#define XHCI_PORTSC_PRESERVE
Port status and control bits which should be preserved.
uint8_t endpoint
Endpoint ID.
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
uint64_t dequeue
Dequeue pointer.
struct device dev
Generic device.
#define XHCI_TRB_STATUS
A status stage transfer request block.
static struct pci_device_id xhci_ids[]
XHCI PCI device IDs.
unsigned int slots
Number of device slots.
uint32_t add
Add context flags.
uint32_t enabled
Bitmask of enabled AENQ groups (host -> device)
uint64_t dequeue
Transfer ring dequeue pointer.
struct xhci_scratchpad scratch
Scratchpad buffer.
#define XHCI_USBLEGSUP_OS
USB legacy support OS owned semaphore.
unsigned int address
Device address, if assigned.
static unsigned int xhci_ring_remaining(struct xhci_trb_ring *ring)
Calculate space remaining in TRB ring.
#define PCI_CLASS_SERIAL_USB_XHCI
xHCI USB controller
uint64_t * array
Scratchpad array.
static int xhci_endpoint_mtu(struct usb_endpoint *ep)
Update MTU.
void writeb(uint8_t data, volatile uint8_t *io_addr)
Write byte to memory-mapped device.
unsigned int speed
Device speed.
uint8_t address
USB address.
#define ECANCELED
Operation canceled.
#define XHCI_TRB_ADDRESS_DEVICE
An address device transfer request block.
#define ENOTSUP
Operation not supported.
uint8_t ports
Number of downstream ports.
#define STARTUP_LATE
Late startup.
void usb_port_changed(struct usb_port *port)
Report port status change.
Dynamic memory allocation.
static int xhci_port_psiv(struct xhci_device *xhci, unsigned int port, unsigned int speed)
Find protocol speed ID value.
#define XHCI_DATA_OUT
Output data direction.
static void xhci_transfer(struct xhci_device *xhci, struct xhci_trb_transfer *trb)
Handle transfer event.
static void usb_bus_set_hostdata(struct usb_bus *bus, void *priv)
Set USB bus host controller private data.
unsigned int type
Endpoint type.
struct xhci_trb_host_controller host
Host controller event.
#define XHCI_EP_DCS
Endpoint dequeue cycle state.
uint64_t input
Input context.
#define XHCI_EP_TYPE_IN
Input endpoint type.
static const char * xhci_speed_name(uint32_t psi)
Transcribe port speed (for debugging)
static int xhci_root_enable(struct usb_hub *hub, struct usb_port *port)
Enable port.
#define XHCI_PORTSC_PP
Port power.
A startup/shutdown function.
#define PCI_COMMAND_MASTER
Bus master.
static void xhci_bus_poll(struct usb_bus *bus)
Poll USB bus.
#define XHCI_PORTSC_CCS
Current connect status.
void memset_user(userptr_t userptr, off_t offset, int c, size_t len)
Fill user buffer with a constant byte.
static void xhci_ring_reset(struct xhci_trb_ring *ring)
Reset transfer request block ring.
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
#define ENOMEM
Not enough space.
#define XHCI_COMMAND_MAX_WAIT_MS
Maximum time to wait for a command to complete.
struct usb_device * usb
Underlying USB device, if any.
struct dma_mapping array_map
Array DMA mapping.
static int xhci_enable_slot(struct xhci_device *xhci, unsigned int type)
Enable slot.
uint8_t endpoint
Endpoint ID.
#define XHCI_OP_CRCR
Command ring control register.
union xhci_trb * trb
Transfer request blocks.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define XHCI_TRB_COMPLETE
A command completion event transfer request block.
static int xhci_probe(struct pci_device *pci)
Probe PCI device.
struct xhci_pch pch
Intel PCH quirk.
#define XHCI_CAP_RTSOFF
Runtime register space offset.
#define __unused
Declare a variable or data structure as unused.
A reset endpoint transfer request block.
void dma_free(struct dma_mapping *map, void *addr, size_t len)
Unmap and free DMA-coherent buffer.
static int xhci_port_slot_type(struct xhci_device *xhci, unsigned int port)
Find port slot type.
void unregister_usb_bus(struct usb_bus *bus)
Unregister USB bus.
struct usb_port * port
USB port.
union xhci_trb * trb
Transfer request blocks.
uint32_t drop
Drop context flags.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define XHCI_EP_TYPE_PERIODIC
Periodic endpoint type.
static void xhci_device_close(struct usb_device *usb)
Close device.
int pci_read_config_dword(struct pci_device *pci, unsigned int where, uint32_t *value)
Read 32-bit dword from PCI configuration space.
#define XHCI_TRB_DATA
A data stage transfer request block.
struct xhci_trb_stop_endpoint stop
Stop endpoint TRB.
#define XHCI_MTU
Maximum transfer size.
struct xhci_trb_template template
Template.
static void xhci_dump_port(struct xhci_device *xhci, unsigned int port)
Dump port registers.
unsigned int ctx
Context index.
pseudo_bit_t value[0x00020]
struct usb_device * usb
USB device.
static int xhci_device_address(struct usb_device *usb)
Assign device address.
uint32_t xusb2pr
USB2 port routing register original value.
static __always_inline void iob_unmap(struct io_buffer *iobuf)
Unmap I/O buffer for DMA.
#define XHCI_PORTSC_CHANGE
Port status change mask.
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
uint8_t port
Root hub port number.
#define XHCI_SLOT_INFO(entries, hub, speed, route)
Construct slot context device info.
#define XHCI_TRB_TRANSFER
A transfer event transfer request block.
#define XHCI_USBLEGSUP_CTLSTS
USB legacy support control/status.
A setup stage transfer request block.
uint16_t mtu
Maximum packet size.
A transfer event transfer request block.
unsigned int burst
Maximum burst size.
static void xhci_bus_close(struct usb_bus *bus)
Close USB bus.
#define XHCI_PCH
Intel PCH quirk flag.
#define XHCI_TRB_NOP_CMD
A no-op command transfer request block.
#define XHCI_TRB_SETUP
A setup stage transfer request block.
static __always_inline physaddr_t iob_dma(struct io_buffer *iobuf)
Get I/O buffer DMA address.
static int xhci_root_open(struct usb_hub *hub)
Open root hub.
#define DMA_TX
Device will read data from host memory.
u32 link
Link to next descriptor.
uint16_t count
Number of entries.
unsigned long pci_bar_start(struct pci_device *pci, unsigned int reg)
Find the start of a PCI BAR.
uint32_t usb3pssen
USB3 port SuperSpeed enable register original value.
static int xhci_fail(struct xhci_device *xhci)
Mark xHCI device as permanently failed.
#define USB_DIR_IN
Data transfer is from device to host.
static void profile_start(struct profiler *profiler)
Start profiling.
static void xhci_legacy_claim(struct xhci_device *xhci)
Claim ownership from BIOS.
unsigned int ports
Number of ports.
static void xhci_event_free(struct xhci_device *xhci)
Free event ring.
#define USB_SPEED(mantissa, exponent)
Define a USB speed.
uint32_t info
Device info.
struct xhci_slot * slot
xHCI slot
#define XHCI_SUPPORTED_PORTS_PSIC(ports)
Supported protocol PSI count.
struct xhci_endpoint_context * context
Endpoint context.
#define cpu_to_le32(value)
uint8_t id
Request identifier.
uint32_t revision
Entry point revision.
#define XHCI_PORTSC_LWS
Port link state write strobe.
#define XHCI_DCI(ctx)
Device context index.
static int xhci_deconfigure_endpoint(struct xhci_device *xhci, struct xhci_slot *slot, struct xhci_endpoint *endpoint)
Deconfigure endpoint.
#define XHCI_OP_DCBAAP
Device context base address array pointer.
A context transfer request block.
#define XHCI_TRB_STOP_ENDPOINT
A stop endpoint transfer request block.
#define XHCI_TRB_HOST_CONTROLLER
A port status change transfer request block.
#define iob_unput(iobuf, len)
#define XHCI_SUPPORTED_PSI(index)
Supported protocol PSI.
static int xhci_bus_open(struct usb_bus *bus)
Open USB bus.
char * strerror(int errno)
Retrieve string representation of error number.
static int xhci_enqueue_multi(struct xhci_trb_ring *ring, struct io_buffer *iobuf, const union xhci_trb *trbs, unsigned int count)
Enqueue multiple transfer request blocks.
static void(* free)(struct refcnt *refcnt))
static void xhci_shutdown(int booting)
Prepare for exit.
static int xhci_root_disable(struct usb_hub *hub, struct usb_port *port)
Disable port.
void * zalloc(size_t size)
Allocate cleared memory.
#define XHCI_XECP_ID(xecp)
xHCI extended capability ID
uint16_t cons
Consumer index.
int failed
Command mechanism has permanently failed.
#define PCI_CLASS_SERIAL_USB
A link transfer request block.
A transfer request block.
static void xhci_dcbaa_free(struct xhci_device *xhci)
Free device context base address array.
unsigned int usb_route_string(struct usb_device *usb)
Get USB route string.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
static void xhci_root_close(struct usb_hub *hub __unused)
Close root hub.
#define XHCI_USBLEGSUP_BIOS
USB legacy support BIOS owned semaphore.
#define XHCI_USBLEGSUP_OS_OWNED
USB legacy support OS ownership flag.
#define XHCI_OP_PORTPMSC(port)
Port power management status and control register.
uint64_t * context
Context base addresses.
#define ENODEV
No such device.
#define XHCI_HCCPARAMS1_XECP(params)
xHCI extended capabilities pointer
static int xhci_scratchpad_alloc(struct xhci_device *xhci)
Allocate scratchpad buffers.
#define XHCI_BAR
xHCI PCI BAR
#define XHCI_HCCPARAMS1_ADDR64(params)
64-bit addressing capability
#define XHCI_CAP_CAPLENGTH
Capability register length.
static void xhci_dump(struct xhci_device *xhci)
Dump host controller registers.
static int xhci_endpoint_open(struct usb_endpoint *ep)
Open endpoint.
static void xhci_remove(struct pci_device *pci)
Remove PCI device.
unsigned int intrs
Number of interrupters.
static int xhci_writeq(struct xhci_device *xhci, physaddr_t value, void *reg)
Write potentially 64-bit register.
static void * usb_get_hostdata(struct usb_device *usb)
Get USB device host controller private data.
unsigned int prod
Producer counter.
#define XHCI_EP0_TRB_LEN
Control endpoint average TRB length.
struct xhci_trb_complete complete
Command completion event.
struct xhci_trb_set_tr_dequeue_pointer dequeue
Set transfer ring dequeue pointer TRB.
#define XHCI_SUPPORTED_PORTS_COUNT(ports)
Supported protocol port count.
static __always_inline int struct dma_mapping * map
A PCI device ID list entry.
static int xhci_endpoint_message(struct usb_endpoint *ep, struct io_buffer *iobuf)
Enqueue message transfer.
#define le16_to_cpu(value)
#define XHCI_HCSPARAMS1_SLOTS(params)
Number of device slots.
const char * usb_endpoint_name(struct usb_endpoint *ep)
Get USB endpoint name (for debugging)
void * cap
Capability registers.
struct usb_port * usb_root_hub_port(struct usb_device *usb)
Get USB root hub port.
unsigned int xecp
xHCI extended capabilities offset
static void xhci_abort(struct xhci_device *xhci)
Abort command.
#define XHCI_OP_PAGESIZE
Page size register.
#define XHCI_RUN_ERSTBA(intr)
Event ring segment table base address register.
#define XHCI_SUPPORTED_REVISION
Supported protocol revision.
A normal transfer request block.
#define XHCI_TRB_IDT
Transfer request block immediate data flag.
#define XHCI_XECP_ID_LEGACY
USB legacy support extended capability.
int addr64
64-bit addressing capability
size_t mtu
Maximum transfer size.
#define XHCI_USBCMD_HCRST
Host controller reset.
A port status change transfer request block.
struct xhci_trb_normal normal
Normal TRB.
struct startup_fn xhci_startup __startup_fn(STARTUP_LATE)
Startup/shutdown function.
#define DMA_RX
Device will write data to host memory.
static void xhci_configure_endpoint_input(struct xhci_device *xhci, struct xhci_slot *slot, struct xhci_endpoint *endpoint, void *input)
Populate configure endpoint input context.
void * dma_alloc(struct dma_device *dma, struct dma_mapping *map, size_t len, size_t align)
Allocate and map DMA-coherent buffer.
static int xhci_reset(struct xhci_device *xhci)
Reset xHCI device.
struct usb_port * usb_transaction_translator(struct usb_device *usb)
Get USB transaction translator.
userptr_t buffer
Scratchpad buffer area.
static void xhci_run(struct xhci_device *xhci)
Start xHCI device.
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
#define XHCI_DBVAL(target, stream)
Calculate doorbell register value.
static struct io_buffer * xhci_dequeue_multi(struct xhci_trb_ring *ring)
Dequeue multiple transfer request blocks.
#define XHCI_PAGESIZE(pagesize)
Page size.
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
#define XHCI_PORTSC_PLS_RXDETECT
RxDetect port link state.
struct xhci_trb_reset_endpoint reset
Reset endpoint TRB.
#define XHCI_TRB_CONFIGURE_ENDPOINT
A configure endpoint transfer request block.
#define XHCI_SUPPORTED_PORTS_OFFSET(ports)
Supported protocol port offset.
static unsigned int xhci_supported_protocol(struct xhci_device *xhci, unsigned int port)
Find supported protocol extended capability for a port.
#define XHCI_OP_CONFIG
Configure register.
USB eXtensible Host Controller Interface (xHCI) driver.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
void dma_ufree(struct dma_mapping *map, userptr_t addr, size_t len)
Unmap and free DMA-coherent buffer from external (user) memory.
#define XHCI_PCH_USB3PSSEN
Intel PCH SuperSpeed enable register.
#define XHCI_OP_PORTSC(port)
Port status and control register.
static void * usb_bus_get_hostdata(struct usb_bus *bus)
Get USB bus host controller private data.
static int xhci_disable_slot(struct xhci_device *xhci, unsigned int slot)
Disable slot.
uint8_t tt_id
TT hub slot ID.
static void xhci_pch_fix(struct xhci_device *xhci, struct pci_device *pci)
Fix Intel PCH-specific quirks.
struct usb_endpoint * ep
USB endpoint.
#define XHCI_CTX(address)
Calculate context index from USB endpoint address.
#define XHCI_STOP_MAX_WAIT_MS
Maximum time to wait for host controller to stop.
#define XHCI_TRB_NORMAL
A normal transfer request block.
#define ENOBUFS
No buffer space available.
size_t pagesize
Page size.
Universal Serial Bus (USB)
#define XHCI_PORT_POWER_DELAY_MS
Time to delay after enabling power to a port.
int register_usb_bus(struct usb_bus *bus)
Register USB bus.
static void xhci_event_poll(struct xhci_device *xhci)
Poll event ring.
#define XHCI_CRCR_RCS
Command ring cycle state.
A stop endpoint transfer request block.
unsigned int mask
Ring counter mask.
static void xhci_scratchpad_free(struct xhci_device *xhci)
Free scratchpad buffers.
#define XHCI_TRB_TYPE_MASK
Transfer request block type mask.
static void usb_complete(struct usb_endpoint *ep, struct io_buffer *iobuf)
Complete transfer (without error)
uint8_t interval
Polling interval.
uint8_t tt_port
TT port number.
unsigned int address
Port address.
void * data
Start of data.
static void xhci_host_controller(struct xhci_device *xhci, struct xhci_trb_host_controller *trb)
Handle host controller event.
struct usb_hub * hub
USB hub.
struct dma_mapping map
DMA mapping.
struct io_buffer ** iobuf
I/O buffers.
#define XHCI_TRB_EVALUATE_CONTEXT
An evaluate context transfer request block.
static void xhci_complete(struct xhci_device *xhci, struct xhci_trb_complete *trb)
Handle command completion event.
#define XHCI_CAP_DBOFF
Doorbell offset.
struct usb_endpoint * ep[32]
Endpoint list.
static int xhci_port_speed(struct xhci_device *xhci, unsigned int port, unsigned int psiv)
Find port speed.
struct xhci_trb_ring ring
Transfer ring.
unsigned int interval
Interval (in microframes)
struct pci_device_id * id
Driver device ID.
static int xhci_stop_endpoint(struct xhci_device *xhci, struct xhci_slot *slot, struct xhci_endpoint *endpoint)
Stop endpoint.
static size_t xhci_input_context_offset(struct xhci_device *xhci, unsigned int ctx)
Calculate input context offset.
#define XHCI_HCCPARAMS1_CSZ_SHIFT(params)
Context size shift.
#define XHCI_CRCR_CA
Command abort.
struct usb_endpoint_host_operations endpoint
Endpoint operations.
int pci_write_config_dword(struct pci_device *pci, unsigned int where, uint32_t value)
Write 32-bit dword to PCI configuration space.
#define XHCI_PCH_USB3PRM
Intel PCH USB3 port routing mask register.
#define cpu_to_le16(value)
static void xhci_pch_undo(struct xhci_device *xhci, struct pci_device *pci)
Undo Intel PCH-specific quirk fixes.
#define XHCI_USBCMD_RUN
Run/stop.
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" return dest
void iounmap(volatile const void *io_addr)
Unmap I/O address.
uint8_t data[48]
Additional event data.
#define XHCI_TRB_CH
Transfer request block chain flag.
#define XHCI_CAP_HCSPARAMS1
Structural parameters 1.
USB host controller operations.
#define USB_ENDPOINT_ATTR_CONTROL
Control endpoint transfer type.
struct xhci_trb_port_status port
Port status changed event.
struct dma_device * dma
DMA device.
static int xhci_endpoint_reset(struct usb_endpoint *ep)
Reset endpoint.
static int xhci_enqueue(struct xhci_trb_ring *ring, struct io_buffer *iobuf, const union xhci_trb *trb)
Enqueue a transfer request block.
static int xhci_evaluate_context(struct xhci_device *xhci, struct xhci_slot *slot, struct xhci_endpoint *endpoint)
Evaluate context.
static void xhci_doorbell(struct xhci_trb_ring *ring)
Ring doorbell register.
static unsigned int xhci_port_protocol(struct xhci_device *xhci, unsigned int port)
Find port protocol.
uint16_t residual
Residual transfer length.
#define XHCI_PORTSC_PR
Port reset.
unsigned int legacy
USB legacy support capability (if present and enabled)
struct usb_hub * hub
Root hub.
#define XHCI_CRCR_CRR
Command ring running.
#define XHCI_CONFIG_MAX_SLOTS_EN_MASK
Maximum device slots enabled mask.
#define XHCI_PORTSC_PED
Port enabled.
struct xhci_trb_link * link
Link TRB (if applicable)
#define XHCI_CAP_HCCPARAMS1
Capability parameters.
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
unsigned int shift
Ring size (log2)
A transfer request block command/transfer ring.
userptr_t dma_umalloc(struct dma_device *dma, struct dma_mapping *map, size_t len, size_t align)
Allocate and map DMA-coherent buffer from external (user) memory.
static void usb_hub_set_drvdata(struct usb_hub *hub, void *priv)
Set USB hub driver private data.
struct usb_device * usb
USB device.
static void xhci_address_device_input(struct xhci_device *xhci, struct xhci_slot *slot, struct xhci_endpoint *endpoint, void *input)
Populate address device input context.
uint16_t offset
Offset to command line.
uint64_t transfer
Transfer TRB pointer.
static struct usb_port * usb_port(struct usb_hub *hub, unsigned int address)
Get USB port.
unsigned int csz_shift
Context size shift.
#define XHCI_EVENT_TRBS_LOG2
Number of TRBs in the event ring.
struct usb_setup_packet packet
Setup packet.
#define XHCI_SUPPORTED_PSI_MANTISSA(psi)
Supported protocol PSI mantissa.
#define XHCI_MIN_ALIGN
Minimum alignment required for data structures.
uint16_t protocol
Protocol ID.
void * db
Doorbell registers.
#define XHCI_TRB_LINK
A link transfer request block.
unsigned int interval
Endpoint interval.
#define XHCI_SETUP_IN
Setup stage input data direction.
#define XHCI_PORTSC_PLS_DISABLED
Disabled port link state.
static int xhci_reset_endpoint(struct xhci_device *xhci, struct xhci_slot *slot, struct xhci_endpoint *endpoint)
Reset endpoint.
int(* open)(struct usb_endpoint *ep)
Open endpoint.
#define XHCI_SUPPORTED_REVISION_VER(revision)
Supported protocol minor revision.
#define XHCI_OP_USBCMD
USB command register.
uint8_t endpoint
Endpoint ID.
#define XHCI_RUN_ERSTSZ(intr)
Event ring segment table size register.
#define XHCI_HCSPARAMS2_SCRATCHPADS(params)
Number of page-sized scratchpad buffers.
#define XHCI_STATUS_OUT
Output status direction.
uint8_t code
Completion code.
uint32_t supported
Bitmask of supported AENQ groups (device -> host)
static __always_inline physaddr_t dma(struct dma_mapping *map, void *addr)
Get DMA address from virtual address.
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
#define XHCI_PCH_XUSB2PRM
Intel PCH USB2 port routing mask register.
#define XHCI_USBSTS_HCH
Host controller halted.
struct usb_bus * bus
USB bus.
#define fls(x)
Find last (i.e.
#define le64_to_cpu(value)
struct xhci_trb_link link
Link TRB.
static void xhci_legacy_init(struct xhci_device *xhci)
Initialise USB legacy support.
struct xhci_slot ** slot
Device slots, indexed by slot ID.
#define XHCI_TRB_C
Transfer request block cycle bit flag.
#define XHCI_CAP_HCSPARAMS2
Structural parameters 2.
static int xhci_event_alloc(struct xhci_device *xhci)
Allocate event ring.
static int xhci_command(struct xhci_device *xhci, union xhci_trb *trb)
Issue command and wait for completion.
unsigned int quirks
Quirks.
#define NULL
NULL pointer (VOID *)
uint64_t parameter
Parameter.
#define XHCI_SUPPORTED_PSI_EXPONENT(psi)
Supported protocol PSI exponent.
struct xhci_device * xhci
xHCI device
#define ETIMEDOUT
Connection timed out.
#define PCI_ROM(_vendor, _device, _name, _description, _data)
struct xhci_event_ring event
Event ring.
static unsigned int xhci_endpoint_count(size_t len, int zlp)
Calculate number of TRBs.
#define XHCI_LINK_STATE_DELAY_MS
Time to delay after writing the port link state.
unsigned int attributes
Attributes.
static int xhci_legacy_prevent_release
Prevent the release of ownership back to BIOS.
#define XHCI_OP_DNCTRL
Device notifcation control register.
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.
void * op
Operational registers.
unsigned int address
Endpoint address.
#define XHCI_RUN_ERDP(intr)
Event ring dequeue pointer register.
void free_usb_bus(struct usb_bus *bus)
Free USB bus.
static int xhci_nop(struct xhci_device *xhci)
Issue NOP and wait for completion.
#define XHCI_CTX_EP0
Endpoint zero context index.
#define XHCI_PORTSC_PLS_MASK
Port link state mask.
uint8_t endpoint
Endpoint ID.
#define XHCI_TRB_IOC
Transfer request block interrupt on completion flag.
static int xhci_hub_open(struct usb_hub *hub)
Open hub.
static void xhci_port_status(struct xhci_device *xhci, struct xhci_trb_port_status *trb)
Handle port status event.
static int xhci_ring_alloc(struct xhci_device *xhci, struct xhci_trb_ring *ring, unsigned int shift, unsigned int slot, unsigned int target, unsigned int stream)
Allocate transfer request block ring.
void usb_complete_err(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete transfer (possibly with error)
#define XHCI_ENDPOINT_STATE_MASK
Endpoint state mask.
static void * usb_hub_get_drvdata(struct usb_hub *hub)
Get USB hub driver private data.
#define XHCI_CMD_TRBS_LOG2
Number of TRBs (excluding Link TRB) in the command ring.
static struct usb_host_operations xhci_operations
USB host controller operations.
static void * usb_endpoint_get_hostdata(struct usb_endpoint *ep)
Get USB endpoint host controller private data.
static void xhci_legacy_release(struct xhci_device *xhci)
Release ownership back to BIOS.
static int xhci_dcbaa_alloc(struct xhci_device *xhci)
Allocate device context base address array.
#define XHCI_SUPPORTED_NAME
Supported protocol name.
void * memset(void *dest, int character, size_t len) __nonnull
#define XHCI_CTX_SLOT
Slot context index.
static void xhci_endpoint_close(struct usb_endpoint *ep)
Close endpoint.