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:56 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-06-16 00:44:48 -0400
commit7f84eef0dafb1d318263d8b71c38700aaf2d530d (patch)
treed7de1ac3d91fb206a5cec2e85b0ad7f4a7b78b21 /drivers/usb/host/xhci.h
parenta74588f94655263b96dacbbf14aac0958d8b7409 (diff)
USB: xhci: No-op command queueing and irq handler.
xHCI host controllers can optionally implement a no-op test. This simple test ensures the OS has correctly setup all basic data structures and can correctly respond to interrupts from the host controller hardware. There are two rings exercised by the no-op test: the command ring, and the event ring. The host controller driver writes a no-op command TRB to the command ring, and rings the doorbell for the command ring (the first entry in the doorbell array). The hardware receives this event, places a command completion event on the event ring, and fires an interrupt. The host controller driver sees the interrupt, and checks the event ring for TRBs it can process, and sees the command completion event. (See the rules in xhci-ring.c for who "owns" a TRB. This is a simplified set of rules, and may not contain all the details that are in the xHCI 0.95 spec.) A timer fires every 60 seconds to debug the state of the hardware and command and event rings. This timer only runs if CONFIG_USB_XHCI_HCD_DEBUGGING is 'y'. 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.h53
1 files changed, 49 insertions, 4 deletions
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index f168fcac5999..66be134b8921 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -24,6 +24,7 @@
24#define __LINUX_XHCI_HCD_H 24#define __LINUX_XHCI_HCD_H
25 25
26#include <linux/usb.h> 26#include <linux/usb.h>
27#include <linux/timer.h>
27 28
28#include "../core/hcd.h" 29#include "../core/hcd.h"
29/* Code sharing between pci-quirks and xhci hcd */ 30/* Code sharing between pci-quirks and xhci hcd */
@@ -377,6 +378,7 @@ struct intr_reg {
377/* irq_pending bitmasks */ 378/* irq_pending bitmasks */
378#define ER_IRQ_PENDING(p) ((p) & 0x1) 379#define ER_IRQ_PENDING(p) ((p) & 0x1)
379/* bits 2:31 need to be preserved */ 380/* bits 2:31 need to be preserved */
381/* THIS IS BUGGY - FIXME - IP IS WRITE 1 TO CLEAR */
380#define ER_IRQ_CLEAR(p) ((p) & 0xfffffffe) 382#define ER_IRQ_CLEAR(p) ((p) & 0xfffffffe)
381#define ER_IRQ_ENABLE(p) ((ER_IRQ_CLEAR(p)) | 0x2) 383#define ER_IRQ_ENABLE(p) ((ER_IRQ_CLEAR(p)) | 0x2)
382#define ER_IRQ_DISABLE(p) ((ER_IRQ_CLEAR(p)) & ~(0x2)) 384#define ER_IRQ_DISABLE(p) ((ER_IRQ_CLEAR(p)) & ~(0x2))
@@ -699,11 +701,14 @@ struct xhci_link_trb {
699/* control bitfields */ 701/* control bitfields */
700#define LINK_TOGGLE (0x1<<1) 702#define LINK_TOGGLE (0x1<<1)
701 703
704/* Command completion event TRB */
705struct xhci_event_cmd {
706 /* Pointer to command TRB, or the value passed by the event data trb */
707 u32 cmd_trb[2];
708 u32 status;
709 u32 flags;
710} __attribute__ ((packed));
702 711
703union xhci_trb {
704 struct xhci_link_trb link;
705 struct xhci_transfer_event trans_event;
706};
707 712
708/* Normal TRB fields */ 713/* Normal TRB fields */
709/* transfer_len bitmasks - bits 0:16 */ 714/* transfer_len bitmasks - bits 0:16 */
@@ -737,6 +742,17 @@ union xhci_trb {
737/* Control transfer TRB specific fields */ 742/* Control transfer TRB specific fields */
738#define TRB_DIR_IN (1<<16) 743#define TRB_DIR_IN (1<<16)
739 744
745struct xhci_generic_trb {
746 u32 field[4];
747} __attribute__ ((packed));
748
749union xhci_trb {
750 struct xhci_link_trb link;
751 struct xhci_transfer_event trans_event;
752 struct xhci_event_cmd event_cmd;
753 struct xhci_generic_trb generic;
754};
755
740/* TRB bit mask */ 756/* TRB bit mask */
741#define TRB_TYPE_BITMASK (0xfc00) 757#define TRB_TYPE_BITMASK (0xfc00)
742#define TRB_TYPE(p) ((p) << 10) 758#define TRB_TYPE(p) ((p) << 10)
@@ -825,7 +841,11 @@ struct xhci_segment {
825struct xhci_ring { 841struct xhci_ring {
826 struct xhci_segment *first_seg; 842 struct xhci_segment *first_seg;
827 union xhci_trb *enqueue; 843 union xhci_trb *enqueue;
844 struct xhci_segment *enq_seg;
845 unsigned int enq_updates;
828 union xhci_trb *dequeue; 846 union xhci_trb *dequeue;
847 struct xhci_segment *deq_seg;
848 unsigned int deq_updates;
829 /* 849 /*
830 * Write the cycle state into the TRB cycle field to give ownership of 850 * Write the cycle state into the TRB cycle field to give ownership of
831 * the TRB to the host controller (if we are the producer), or to check 851 * the TRB to the host controller (if we are the producer), or to check
@@ -861,6 +881,8 @@ struct xhci_erst {
861#define ERST_SIZE 64 881#define ERST_SIZE 64
862/* Initial number of event segment rings allocated */ 882/* Initial number of event segment rings allocated */
863#define ERST_ENTRIES 1 883#define ERST_ENTRIES 1
884/* Poll every 60 seconds */
885#define POLL_TIMEOUT 60
864/* XXX: Make these module parameters */ 886/* XXX: Make these module parameters */
865 887
866 888
@@ -907,8 +929,21 @@ struct xhci_hcd {
907 /* DMA pools */ 929 /* DMA pools */
908 struct dma_pool *device_pool; 930 struct dma_pool *device_pool;
909 struct dma_pool *segment_pool; 931 struct dma_pool *segment_pool;
932
933#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING
934 /* Poll the rings - for debugging */
935 struct timer_list event_ring_timer;
936 int zombie;
937#endif
938 /* Statistics */
939 int noops_submitted;
940 int noops_handled;
941 int error_bitmask;
910}; 942};
911 943
944/* For testing purposes */
945#define NUM_TEST_NOOPS 0
946
912/* convert between an HCD pointer and the corresponding EHCI_HCD */ 947/* convert between an HCD pointer and the corresponding EHCI_HCD */
913static inline struct xhci_hcd *hcd_to_xhci(struct usb_hcd *hcd) 948static inline struct xhci_hcd *hcd_to_xhci(struct usb_hcd *hcd)
914{ 949{
@@ -956,9 +991,11 @@ void xhci_print_ir_set(struct xhci_hcd *xhci, struct intr_reg *ir_set, int set_n
956void xhci_print_registers(struct xhci_hcd *xhci); 991void xhci_print_registers(struct xhci_hcd *xhci);
957void xhci_dbg_regs(struct xhci_hcd *xhci); 992void xhci_dbg_regs(struct xhci_hcd *xhci);
958void xhci_print_run_regs(struct xhci_hcd *xhci); 993void xhci_print_run_regs(struct xhci_hcd *xhci);
994void xhci_debug_segment(struct xhci_hcd *xhci, struct xhci_segment *seg);
959void xhci_debug_ring(struct xhci_hcd *xhci, struct xhci_ring *ring); 995void xhci_debug_ring(struct xhci_hcd *xhci, struct xhci_ring *ring);
960void xhci_dbg_erst(struct xhci_hcd *xhci, struct xhci_erst *erst); 996void xhci_dbg_erst(struct xhci_hcd *xhci, struct xhci_erst *erst);
961void xhci_dbg_cmd_ptrs(struct xhci_hcd *xhci); 997void xhci_dbg_cmd_ptrs(struct xhci_hcd *xhci);
998void xhci_dbg_ring_ptrs(struct xhci_hcd *xhci, struct xhci_ring *ring);
962 999
963/* xHCI memory managment */ 1000/* xHCI memory managment */
964void xhci_mem_cleanup(struct xhci_hcd *xhci); 1001void xhci_mem_cleanup(struct xhci_hcd *xhci);
@@ -978,5 +1015,13 @@ int xhci_run(struct usb_hcd *hcd);
978void xhci_stop(struct usb_hcd *hcd); 1015void xhci_stop(struct usb_hcd *hcd);
979void xhci_shutdown(struct usb_hcd *hcd); 1016void xhci_shutdown(struct usb_hcd *hcd);
980int xhci_get_frame(struct usb_hcd *hcd); 1017int xhci_get_frame(struct usb_hcd *hcd);
1018irqreturn_t xhci_irq(struct usb_hcd *hcd);
1019
1020/* xHCI ring, segment, TRB, and TD functions */
1021dma_addr_t trb_virt_to_dma(struct xhci_segment *seg, union xhci_trb *trb);
1022void ring_cmd_db(struct xhci_hcd *xhci);
1023void *setup_one_noop(struct xhci_hcd *xhci);
1024void handle_event(struct xhci_hcd *xhci);
1025void set_hc_event_deq(struct xhci_hcd *xhci);
981 1026
982#endif /* __LINUX_XHCI_HCD_H */ 1027#endif /* __LINUX_XHCI_HCD_H */