1 /******************************************************************************
4 * Private definitions for the Xen Virtual USB Controller. Based on
5 * drivers/usb/host/uhci.h from Linux. Copyright for the imported content is
6 * retained by the original authors.
9 * Copyright (C) 2004 Intel Research Cambridge
10 * Copyright (C) 2004, 2005 Mark Williamson
13 #ifndef __LINUX_XHCI_H
14 #define __LINUX_XHCI_H
16 #include <linux/list.h>
17 #include <linux/usb.h>
18 #include <asm-xen/xen-public/io/usbif.h>
19 #include <linux/spinlock.h>
21 /* xhci_port_t - current known state of a virtual hub ports */
23 unsigned int cs :1; /* Connection status. */
24 unsigned int cs_chg :1; /* Connection status change. */
25 unsigned int pe :1; /* Port enable. */
26 unsigned int pe_chg :1; /* Port enable change. */
27 unsigned int susp :1; /* Suspended. */
28 unsigned int lsda :1; /* Low speed device attached. */
29 unsigned int pr :1; /* Port reset. */
32 /* struct virt_root_hub - state related to the virtual root hub */
33 struct virt_root_hub {
34 struct usb_device *dev;
35 int devnum; /* Address of Root Hub endpoint */
42 struct timer_list rh_int_timer;
43 spinlock_t port_state_lock;
47 /* struct xhci - contains the state associated with a single USB interface */
53 struct proc_dir_entry *proc_entry;
56 int evtchn; /* Interdom channel to backend */
57 int irq; /* Bound to evtchn */
59 USBIF_STATE_CONNECTED = 2,
60 USBIF_STATE_DISCONNECTED = 1,
61 USBIF_STATE_CLOSED = 0
62 } state; /* State of this USB interface */
63 unsigned long recovery; /* boolean recovery in progress flag */
65 unsigned long bandwidth;
69 /* Main list of URB's currently controlled by this HC */
70 spinlock_t urb_list_lock;
71 struct list_head urb_list; /* P: xhci->urb_list_lock */
73 /* List of URB's awaiting completion callback */
74 spinlock_t complete_list_lock;
75 struct list_head complete_list; /* P: xhci->complete_list_lock */
77 struct virt_root_hub rh; /* private data of the virtual root hub */
80 usbif_front_ring_t usb_ring;
85 /* per-URB private data structure for the host controller */
88 usbif_iso_t *schedule;
89 struct usb_device *dev;
91 int in_progress : 1; /* QH was queued (not linked in) */
92 int short_control_packet : 1; /* If we get a short packet during */
93 /* a control transfer, retrigger */
94 /* the status phase */
96 int status; /* Final status */
98 unsigned long inserttime; /* In jiffies */
100 struct list_head complete_list; /* P: xhci->complete_list_lock */
106 * spinlocks are used extensively to protect the many lists and data
107 * structures we have. It's not that pretty, but it's necessary. We
108 * need to be done with all of the locks (except complete_list_lock) when
109 * we call urb->complete. I've tried to make it simple enough so I don't
110 * have to spend hours racking my brain trying to figure out if the
113 * Here's the safe locking order to prevent deadlocks:
115 * #1 xhci->urb_list_lock
117 * #3 xhci->urb_remove_list_lock
118 * #4 xhci->complete_list_lock
120 * If you're going to grab 2 or more locks at once, ALWAYS grab the lock
121 * at the lowest level FIRST and NEVER grab locks at the same level at the
124 * So, if you need xhci->urb_list_lock, grab it before you grab urb->lock
127 /* -------------------------------------------------------------------------
129 ------------------------------------------------------------------------- */
130 /* destination of request */
131 #define RH_DEVICE 0x00
132 #define RH_INTERFACE 0x01
133 #define RH_ENDPOINT 0x02
134 #define RH_OTHER 0x03
136 #define RH_CLASS 0x20
137 #define RH_VENDOR 0x40
139 /* Requests: bRequest << 8 | bmRequestType */
140 #define RH_GET_STATUS 0x0080
141 #define RH_CLEAR_FEATURE 0x0100
142 #define RH_SET_FEATURE 0x0300
143 #define RH_SET_ADDRESS 0x0500
144 #define RH_GET_DESCRIPTOR 0x0680
145 #define RH_SET_DESCRIPTOR 0x0700
146 #define RH_GET_CONFIGURATION 0x0880
147 #define RH_SET_CONFIGURATION 0x0900
148 #define RH_GET_STATE 0x0280
149 #define RH_GET_INTERFACE 0x0A80
150 #define RH_SET_INTERFACE 0x0B00
151 #define RH_SYNC_FRAME 0x0C80
152 /* Our Vendor Specific Request */
153 #define RH_SET_EP 0x2000
155 /* Hub port features */
156 #define RH_PORT_CONNECTION 0x00
157 #define RH_PORT_ENABLE 0x01
158 #define RH_PORT_SUSPEND 0x02
159 #define RH_PORT_OVER_CURRENT 0x03
160 #define RH_PORT_RESET 0x04
161 #define RH_PORT_POWER 0x08
162 #define RH_PORT_LOW_SPEED 0x09
163 #define RH_C_PORT_CONNECTION 0x10
164 #define RH_C_PORT_ENABLE 0x11
165 #define RH_C_PORT_SUSPEND 0x12
166 #define RH_C_PORT_OVER_CURRENT 0x13
167 #define RH_C_PORT_RESET 0x14
170 #define RH_C_HUB_LOCAL_POWER 0x00
171 #define RH_C_HUB_OVER_CURRENT 0x01
172 #define RH_DEVICE_REMOTE_WAKEUP 0x00
173 #define RH_ENDPOINT_STALL 0x01
175 /* Our Vendor Specific feature */
176 #define RH_REMOVE_EP 0x00
179 #define RH_REQ_ERR -1