debuggers.hg

view linux-2.6.10-xen-sparse/drivers/xen/usbfront/xhci.h @ 3692:03c49d1bcd6b

bitkeeper revision 1.1159.243.1 (42042ba8OAh4EZUckgdGWWSqRLutaQ)

Various cleanups, including a move to the new ring macros.
author mwilli2@equilibrium.research
date Sat Feb 05 02:12:56 2005 +0000 (2005-02-05)
parents d295396360fb
children 924777207448
line source
1 #ifndef __LINUX_XHCI_H
2 #define __LINUX_XHCI_H
4 #include <linux/list.h>
5 #include <linux/usb.h>
6 #include <asm-xen/xen-public/io/usbif.h>
7 #include <linux/spinlock.h>
9 #define XHCI_NUMFRAMES 1024 /* in the frame list [array] */
10 #define XHCI_MAX_SOF_NUMBER 2047 /* in an SOF packet */
11 #define CAN_SCHEDULE_FRAMES 1000 /* how far future frames can be scheduled */
13 /* In the absence of actual hardware state, we maintain the current known state
14 * of the virtual hub ports in this data structure.
15 */
16 typedef struct
17 {
18 unsigned int cs :1; /* Connection status. do we really need this /and/ ccs? */
19 unsigned int cs_chg :1; /* Connection status change. */
20 unsigned int pe :1; /* Port enable. */
21 unsigned int pe_chg :1; /* Port enable change. */
22 unsigned int ccs :1; /* Current connect status. */
23 unsigned int susp :1; /* Suspended. */
24 unsigned int lsda :1; /* Low speed device attached. */
25 unsigned int pr :1; /* Port reset. */
27 /* Device info? */
28 } xhci_port_t;
30 struct xhci_frame_list {
31 __u32 frame[XHCI_NUMFRAMES];
33 void *frame_cpu[XHCI_NUMFRAMES];
34 };
36 struct urb_priv;
38 #define xhci_status_bits(ctrl_sts) (ctrl_sts & 0xFE0000)
39 #define xhci_actual_length(ctrl_sts) ((ctrl_sts + 1) & TD_CTRL_ACTLEN_MASK) /* 1-based */
41 #define xhci_maxlen(token) ((token) >> 21)
42 #define xhci_expected_length(info) (((info >> 21) + 1) & TD_TOKEN_EXPLEN_MASK) /* 1-based */
43 #define xhci_toggle(token) (((token) >> TD_TOKEN_TOGGLE_SHIFT) & 1)
44 #define xhci_endpoint(token) (((token) >> 15) & 0xf)
45 #define xhci_devaddr(token) (((token) >> 8) & 0x7f)
46 #define xhci_devep(token) (((token) >> 8) & 0x7ff)
47 #define xhci_packetid(token) ((token) & TD_TOKEN_PID_MASK)
48 #define xhci_packetout(token) (xhci_packetid(token) != USB_PID_IN)
49 #define xhci_packetin(token) (xhci_packetid(token) == USB_PID_IN)
51 struct virt_root_hub {
52 struct usb_device *dev;
53 int devnum; /* Address of Root Hub endpoint */
54 struct urb *urb;
55 void *int_addr;
56 int send;
57 int interval;
58 int numports;
59 int c_p_r[8];
60 struct timer_list rh_int_timer;
61 spinlock_t port_state_lock;
62 xhci_port_t *ports; /* */
63 };
65 /*
66 * This describes the full xhci information.
67 *
68 * Note how the "proper" USB information is just
69 * a subset of what the full implementation needs.
70 */
71 struct xhci {
73 #ifdef CONFIG_PROC_FS
74 /* procfs */
75 int num;
76 struct proc_dir_entry *proc_entry;
77 #endif
79 int evtchn; /* Interdom channel to backend */
80 int irq; /* Bound to evtchn */
81 int state; /* State of this USB interface */
82 unsigned long bandwidth;
83 int handle;
85 struct usb_bus *bus;
87 spinlock_t frame_list_lock;
88 struct xhci_frame_list *fl; /* P: xhci->frame_list_lock */
89 int is_suspended;
91 /* Main list of URB's currently controlled by this HC */
92 spinlock_t urb_list_lock;
93 struct list_head urb_list; /* P: xhci->urb_list_lock */
95 /* List of asynchronously unlinked URB's */
96 spinlock_t urb_remove_list_lock;
97 struct list_head urb_remove_list; /* P: xhci->urb_remove_list_lock */
99 /* List of URB's awaiting completion callback */
100 spinlock_t complete_list_lock;
101 struct list_head complete_list; /* P: xhci->complete_list_lock */
103 struct virt_root_hub rh; /* private data of the virtual root hub */
105 spinlock_t response_lock;
107 usbif_front_ring_t usb_ring;
108 int usb_resp_cons;
109 };
111 struct urb_priv {
112 struct urb *urb;
113 usbif_iso_t *schedule;
114 struct usb_device *dev;
116 int in_progress : 1; /* QH was queued (not linked in) */
117 int short_control_packet : 1; /* If we get a short packet during */
118 /* a control transfer, retrigger */
119 /* the status phase */
121 int status; /* Final status */
123 unsigned long inserttime; /* In jiffies */
125 struct list_head queue_list; /* P: xhci->frame_list_lock */
126 struct list_head complete_list; /* P: xhci->complete_list_lock */
127 };
129 /*
130 * Locking in xhci.c
131 *
132 * spinlocks are used extensively to protect the many lists and data
133 * structures we have. It's not that pretty, but it's necessary. We
134 * need to be done with all of the locks (except complete_list_lock) when
135 * we call urb->complete. I've tried to make it simple enough so I don't
136 * have to spend hours racking my brain trying to figure out if the
137 * locking is safe.
138 *
139 * Here's the safe locking order to prevent deadlocks:
140 *
141 * #1 xhci->urb_list_lock
142 * #2 urb->lock
143 * #3 xhci->urb_remove_list_lock, xhci->frame_list_lock,
144 * xhci->qh_remove_list_lock
145 * #4 xhci->complete_list_lock
146 *
147 * If you're going to grab 2 or more locks at once, ALWAYS grab the lock
148 * at the lowest level FIRST and NEVER grab locks at the same level at the
149 * same time.
150 *
151 * So, if you need xhci->urb_list_lock, grab it before you grab urb->lock
152 */
154 /* -------------------------------------------------------------------------
155 Virtual Root HUB
156 ------------------------------------------------------------------------- */
157 /* destination of request */
158 #define RH_DEVICE 0x00
159 #define RH_INTERFACE 0x01
160 #define RH_ENDPOINT 0x02
161 #define RH_OTHER 0x03
163 #define RH_CLASS 0x20
164 #define RH_VENDOR 0x40
166 /* Requests: bRequest << 8 | bmRequestType */
167 #define RH_GET_STATUS 0x0080
168 #define RH_CLEAR_FEATURE 0x0100
169 #define RH_SET_FEATURE 0x0300
170 #define RH_SET_ADDRESS 0x0500
171 #define RH_GET_DESCRIPTOR 0x0680
172 #define RH_SET_DESCRIPTOR 0x0700
173 #define RH_GET_CONFIGURATION 0x0880
174 #define RH_SET_CONFIGURATION 0x0900
175 #define RH_GET_STATE 0x0280
176 #define RH_GET_INTERFACE 0x0A80
177 #define RH_SET_INTERFACE 0x0B00
178 #define RH_SYNC_FRAME 0x0C80
179 /* Our Vendor Specific Request */
180 #define RH_SET_EP 0x2000
182 /* Hub port features */
183 #define RH_PORT_CONNECTION 0x00
184 #define RH_PORT_ENABLE 0x01
185 #define RH_PORT_SUSPEND 0x02
186 #define RH_PORT_OVER_CURRENT 0x03
187 #define RH_PORT_RESET 0x04
188 #define RH_PORT_POWER 0x08
189 #define RH_PORT_LOW_SPEED 0x09
190 #define RH_C_PORT_CONNECTION 0x10
191 #define RH_C_PORT_ENABLE 0x11
192 #define RH_C_PORT_SUSPEND 0x12
193 #define RH_C_PORT_OVER_CURRENT 0x13
194 #define RH_C_PORT_RESET 0x14
196 /* Hub features */
197 #define RH_C_HUB_LOCAL_POWER 0x00
198 #define RH_C_HUB_OVER_CURRENT 0x01
199 #define RH_DEVICE_REMOTE_WAKEUP 0x00
200 #define RH_ENDPOINT_STALL 0x01
202 /* Our Vendor Specific feature */
203 #define RH_REMOVE_EP 0x00
205 #define RH_ACK 0x01
206 #define RH_REQ_ERR -1
207 #define RH_NACK 0x00
209 #endif