aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/xhci.h
diff options
context:
space:
mode:
authorSarah Sharp <sarah.a.sharp@linux.intel.com>2009-04-27 22:53:42 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-06-16 00:44:48 -0400
commita74588f94655263b96dacbbf14aac0958d8b7409 (patch)
tree0c4a53d0e6aa00fe9226c9c915f22da9171043ad /drivers/usb/host/xhci.h
parent0ebbab37422315a5d0cb29792271085bafdf38c0 (diff)
USB: xhci: Device context array allocation.
Instead of keeping a "frame list" like older host controllers, the xHCI host controller keeps internal representations of the USB devices, with a transfer ring per endpoint. The host controller queues Transfer Request Blocks (TRBs) to the endpoint ring, and then "rings the doorbell" for that device. The host controller processes the transfer, places a transfer completion event on the event ring, and interrupts the system. The device context base address array must be allocated by the xHCI host controller driver, along with the device contexts it points to. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host/xhci.h')
-rw-r--r--drivers/usb/host/xhci.h175
1 files changed, 175 insertions, 0 deletions
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index ed331310f1a8..f168fcac5999 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -436,6 +436,180 @@ struct xhci_doorbell_array {
436#define DB_MASK (0xff << 8) 436#define DB_MASK (0xff << 8)
437 437
438 438
439/**
440 * struct xhci_slot_ctx
441 * @dev_info: Route string, device speed, hub info, and last valid endpoint
442 * @dev_info2: Max exit latency for device number, root hub port number
443 * @tt_info: tt_info is used to construct split transaction tokens
444 * @dev_state: slot state and device address
445 *
446 * Slot Context - section 6.2.1.1. This assumes the HC uses 32-byte context
447 * structures. If the HC uses 64-byte contexts, there is an additional 32 bytes
448 * reserved at the end of the slot context for HC internal use.
449 */
450struct xhci_slot_ctx {
451 u32 dev_info;
452 u32 dev_info2;
453 u32 tt_info;
454 u32 dev_state;
455 /* offset 0x10 to 0x1f reserved for HC internal use */
456 u32 reserved[4];
457} __attribute__ ((packed));
458
459/* dev_info bitmasks */
460/* Route String - 0:19 */
461#define ROUTE_STRING_MASK (0xfffff)
462/* Device speed - values defined by PORTSC Device Speed field - 20:23 */
463#define DEV_SPEED (0xf << 20)
464/* bit 24 reserved */
465/* Is this LS/FS device connected through a HS hub? - bit 25 */
466#define DEV_MTT (0x1 << 25)
467/* Set if the device is a hub - bit 26 */
468#define DEV_HUB (0x1 << 26)
469/* Index of the last valid endpoint context in this device context - 27:31 */
470#define LAST_EP_MASK (0x1f << 27)
471#define LAST_EP(p) ((p) << 27)
472
473/* dev_info2 bitmasks */
474/* Max Exit Latency (ms) - worst case time to wake up all links in dev path */
475#define MAX_EXIT (0xffff)
476/* Root hub port number that is needed to access the USB device */
477#define ROOT_HUB_PORT (0xff << 16)
478
479/* tt_info bitmasks */
480/*
481 * TT Hub Slot ID - for low or full speed devices attached to a high-speed hub
482 * The Slot ID of the hub that isolates the high speed signaling from
483 * this low or full-speed device. '0' if attached to root hub port.
484 */
485#define TT_SLOT (0xff)
486/*
487 * The number of the downstream facing port of the high-speed hub
488 * '0' if the device is not low or full speed.
489 */
490#define TT_PORT (0xff << 8)
491
492/* dev_state bitmasks */
493/* USB device address - assigned by the HC */
494#define DEV_ADDR (0xff)
495/* bits 8:26 reserved */
496/* Slot state */
497#define SLOT_STATE (0x1f << 27)
498
499
500/**
501 * struct xhci_ep_ctx
502 * @ep_info: endpoint state, streams, mult, and interval information.
503 * @ep_info2: information on endpoint type, max packet size, max burst size,
504 * error count, and whether the HC will force an event for all
505 * transactions.
506 * @ep_ring: 64-bit ring address. If the endpoint only defines one flow,
507 * this points to the endpoint transfer ring. Otherwise, it points
508 * to a flow context array, which has a ring pointer for each flow.
509 * @intr_target:
510 * 64-bit address of the Interrupter Target that will receive
511 * events from this endpoint.
512 *
513 * Endpoint Context - section 6.2.1.2. This assumes the HC uses 32-byte context
514 * structures. If the HC uses 64-byte contexts, there is an additional 32 bytes
515 * reserved at the end of the endpoint context for HC internal use.
516 */
517struct xhci_ep_ctx {
518 u32 ep_info;
519 u32 ep_info2;
520 /* 64-bit endpoint ring address */
521 u32 ep_ring[2];
522 /* 64-bit address of the interrupter target */
523 u32 intr_target[2];
524 /* offset 0x14 - 0x1f reserved for HC internal use */
525 u32 reserved[2];
526} __attribute__ ((packed));
527
528/* ep_info bitmasks */
529/*
530 * Endpoint State - bits 0:2
531 * 0 - disabled
532 * 1 - running
533 * 2 - halted due to halt condition - ok to manipulate endpoint ring
534 * 3 - stopped
535 * 4 - TRB error
536 * 5-7 - reserved
537 */
538#define EP_STATE (0xf)
539/* Mult - Max number of burtst within an interval, in EP companion desc. */
540#define EP_MULT(p) ((p & 0x3) << 8)
541/* bits 10:14 are Max Primary Streams */
542/* bit 15 is Linear Stream Array */
543/* Interval - period between requests to an endpoint - 125u increments. */
544#define EP_INTERVAL (0xff << 16)
545
546/* ep_info2 bitmasks */
547/*
548 * Force Event - generate transfer events for all TRBs for this endpoint
549 * This will tell the HC to ignore the IOC and ISP flags (for debugging only).
550 */
551#define FORCE_EVENT (0x1)
552#define ERROR_COUNT(p) (((p) & 0x3) << 1)
553#define EP_TYPE(p) ((p) << 3)
554#define ISOC_OUT_EP 1
555#define BULK_OUT_EP 2
556#define INT_OUT_EP 3
557#define CTRL_EP 4
558#define ISOC_IN_EP 5
559#define BULK_IN_EP 6
560#define INT_IN_EP 7
561/* bit 6 reserved */
562/* bit 7 is Host Initiate Disable - for disabling stream selection */
563#define MAX_BURST(p) (((p)&0xff) << 8)
564#define MAX_PACKET(p) (((p)&0xffff) << 16)
565
566
567/**
568 * struct xhci_device_control
569 * Input/Output context; see section 6.2.5.
570 *
571 * @drop_context: set the bit of the endpoint context you want to disable
572 * @add_context: set the bit of the endpoint context you want to enable
573 */
574struct xhci_device_control {
575 u32 drop_flags;
576 u32 add_flags;
577 u32 rsvd[6];
578 struct xhci_slot_ctx slot;
579 struct xhci_ep_ctx ep[31];
580} __attribute__ ((packed));
581
582/* drop context bitmasks */
583#define DROP_EP(x) (0x1 << x)
584/* add context bitmasks */
585#define ADD_EP(x) (0x1 << x)
586
587
588/**
589 * struct xhci_device_context_array
590 * @dev_context_ptr array of 64-bit DMA addresses for device contexts
591 */
592struct xhci_device_context_array {
593 /* 64-bit device addresses; we only write 32-bit addresses */
594 u32 dev_context_ptrs[2*MAX_HC_SLOTS];
595 /* private xHCD pointers */
596 dma_addr_t dma;
597} __attribute__ ((packed));
598/* TODO: write function to set the 64-bit device DMA address */
599/*
600 * TODO: change this to be dynamically sized at HC mem init time since the HC
601 * might not be able to handle the maximum number of devices possible.
602 */
603
604
605struct xhci_stream_ctx {
606 /* 64-bit stream ring address, cycle state, and stream type */
607 u32 stream_ring[2];
608 /* offset 0x14 - 0x1f reserved for HC internal use */
609 u32 reserved[2];
610} __attribute__ ((packed));
611
612
439struct xhci_transfer_event { 613struct xhci_transfer_event {
440 /* 64-bit buffer address, or immediate data */ 614 /* 64-bit buffer address, or immediate data */
441 u32 buffer[2]; 615 u32 buffer[2];
@@ -725,6 +899,7 @@ struct xhci_hcd {
725 int msix_count; 899 int msix_count;
726 struct msix_entry *msix_entries; 900 struct msix_entry *msix_entries;
727 /* data structures */ 901 /* data structures */
902 struct xhci_device_context_array *dcbaa;
728 struct xhci_ring *cmd_ring; 903 struct xhci_ring *cmd_ring;
729 struct xhci_ring *event_ring; 904 struct xhci_ring *event_ring;
730 struct xhci_erst erst; 905 struct xhci_erst erst;