diff options
author | Sarah Sharp <sarah.a.sharp@linux.intel.com> | 2009-04-27 22:57:12 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-06-16 00:44:48 -0400 |
commit | 0f2a79300a1471cf92ab43af165ea13555c8b0a5 (patch) | |
tree | a46c63777a6040708500aefdbc31e0a0404d2e4a /drivers/usb | |
parent | 7206b00164a1c3ca533e01db285955617e1019f8 (diff) |
USB: xhci: Root hub support.
Add functionality for getting port status and hub descriptor for xHCI root
hubs. This is WIP because the USB 3.0 hub descriptor is different from
the USB 2.0 hub descriptor. For now, we lie about the root hub descriptor
because the changes won't effect how the core talks to the root hub.
Later we will need to add the USB 3.0 hub descriptor for real hubs, and
this code might change.
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')
-rw-r--r-- | drivers/usb/host/xhci-dbg.c | 26 | ||||
-rw-r--r-- | drivers/usb/host/xhci-hcd.c | 3 | ||||
-rw-r--r-- | drivers/usb/host/xhci-hub.c | 308 | ||||
-rw-r--r-- | drivers/usb/host/xhci-pci.c | 4 | ||||
-rw-r--r-- | drivers/usb/host/xhci-ring.c | 43 | ||||
-rw-r--r-- | drivers/usb/host/xhci.h | 11 |
6 files changed, 390 insertions, 5 deletions
diff --git a/drivers/usb/host/xhci-dbg.c b/drivers/usb/host/xhci-dbg.c index 6dbf7d856f80..570cd4820458 100644 --- a/drivers/usb/host/xhci-dbg.c +++ b/drivers/usb/host/xhci-dbg.c | |||
@@ -152,6 +152,31 @@ void xhci_print_op_regs(struct xhci_hcd *xhci) | |||
152 | xhci_print_status(xhci); | 152 | xhci_print_status(xhci); |
153 | } | 153 | } |
154 | 154 | ||
155 | void xhci_print_ports(struct xhci_hcd *xhci) | ||
156 | { | ||
157 | u32 __iomem *addr; | ||
158 | int i, j; | ||
159 | int ports; | ||
160 | char *names[NUM_PORT_REGS] = { | ||
161 | "status", | ||
162 | "power", | ||
163 | "link", | ||
164 | "reserved", | ||
165 | }; | ||
166 | |||
167 | ports = HCS_MAX_PORTS(xhci->hcs_params1); | ||
168 | addr = &xhci->op_regs->port_status_base; | ||
169 | for (i = 0; i < ports; i++) { | ||
170 | for (j = 0; j < NUM_PORT_REGS; ++j) { | ||
171 | xhci_dbg(xhci, "0x%x port %s reg = 0x%x\n", | ||
172 | (unsigned int) addr, | ||
173 | names[j], | ||
174 | (unsigned int) xhci_readl(xhci, addr)); | ||
175 | addr++; | ||
176 | } | ||
177 | } | ||
178 | } | ||
179 | |||
155 | void xhci_print_ir_set(struct xhci_hcd *xhci, struct intr_reg *ir_set, int set_num) | 180 | void xhci_print_ir_set(struct xhci_hcd *xhci, struct intr_reg *ir_set, int set_num) |
156 | { | 181 | { |
157 | void *addr; | 182 | void *addr; |
@@ -228,6 +253,7 @@ void xhci_print_registers(struct xhci_hcd *xhci) | |||
228 | { | 253 | { |
229 | xhci_print_cap_regs(xhci); | 254 | xhci_print_cap_regs(xhci); |
230 | xhci_print_op_regs(xhci); | 255 | xhci_print_op_regs(xhci); |
256 | xhci_print_ports(xhci); | ||
231 | } | 257 | } |
232 | 258 | ||
233 | void xhci_print_trb_offsets(struct xhci_hcd *xhci, union xhci_trb *trb) | 259 | void xhci_print_trb_offsets(struct xhci_hcd *xhci, union xhci_trb *trb) |
diff --git a/drivers/usb/host/xhci-hcd.c b/drivers/usb/host/xhci-hcd.c index a99c119e9fd9..d7c2fed55978 100644 --- a/drivers/usb/host/xhci-hcd.c +++ b/drivers/usb/host/xhci-hcd.c | |||
@@ -349,6 +349,9 @@ int xhci_run(struct usb_hcd *hcd) | |||
349 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); | 349 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); |
350 | void (*doorbell)(struct xhci_hcd *) = NULL; | 350 | void (*doorbell)(struct xhci_hcd *) = NULL; |
351 | 351 | ||
352 | hcd->uses_new_polling = 1; | ||
353 | hcd->poll_rh = 0; | ||
354 | |||
352 | xhci_dbg(xhci, "xhci_run\n"); | 355 | xhci_dbg(xhci, "xhci_run\n"); |
353 | #if 0 /* FIXME: MSI not setup yet */ | 356 | #if 0 /* FIXME: MSI not setup yet */ |
354 | /* Do this at the very last minute */ | 357 | /* Do this at the very last minute */ |
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c new file mode 100644 index 000000000000..eac5b53aa9e7 --- /dev/null +++ b/drivers/usb/host/xhci-hub.c | |||
@@ -0,0 +1,308 @@ | |||
1 | /* | ||
2 | * xHCI host controller driver | ||
3 | * | ||
4 | * Copyright (C) 2008 Intel Corp. | ||
5 | * | ||
6 | * Author: Sarah Sharp | ||
7 | * Some code borrowed from the Linux EHCI driver. | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, but | ||
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
16 | * for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software Foundation, | ||
20 | * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
21 | */ | ||
22 | |||
23 | #include <asm/unaligned.h> | ||
24 | |||
25 | #include "xhci.h" | ||
26 | |||
27 | static void xhci_hub_descriptor(struct xhci_hcd *xhci, | ||
28 | struct usb_hub_descriptor *desc) | ||
29 | { | ||
30 | int ports; | ||
31 | u16 temp; | ||
32 | |||
33 | ports = HCS_MAX_PORTS(xhci->hcs_params1); | ||
34 | |||
35 | /* USB 3.0 hubs have a different descriptor, but we fake this for now */ | ||
36 | desc->bDescriptorType = 0x29; | ||
37 | desc->bPwrOn2PwrGood = 10; /* xhci section 5.4.9 says 20ms max */ | ||
38 | desc->bHubContrCurrent = 0; | ||
39 | |||
40 | desc->bNbrPorts = ports; | ||
41 | temp = 1 + (ports / 8); | ||
42 | desc->bDescLength = 7 + 2 * temp; | ||
43 | |||
44 | /* Why does core/hcd.h define bitmap? It's just confusing. */ | ||
45 | memset(&desc->DeviceRemovable[0], 0, temp); | ||
46 | memset(&desc->DeviceRemovable[temp], 0xff, temp); | ||
47 | |||
48 | /* Ugh, these should be #defines, FIXME */ | ||
49 | /* Using table 11-13 in USB 2.0 spec. */ | ||
50 | temp = 0; | ||
51 | /* Bits 1:0 - support port power switching, or power always on */ | ||
52 | if (HCC_PPC(xhci->hcc_params)) | ||
53 | temp |= 0x0001; | ||
54 | else | ||
55 | temp |= 0x0002; | ||
56 | /* Bit 2 - root hubs are not part of a compound device */ | ||
57 | /* Bits 4:3 - individual port over current protection */ | ||
58 | temp |= 0x0008; | ||
59 | /* Bits 6:5 - no TTs in root ports */ | ||
60 | /* Bit 7 - no port indicators */ | ||
61 | desc->wHubCharacteristics = (__force __u16) cpu_to_le16(temp); | ||
62 | } | ||
63 | |||
64 | static unsigned int xhci_port_speed(unsigned int port_status) | ||
65 | { | ||
66 | if (DEV_LOWSPEED(port_status)) | ||
67 | return 1 << USB_PORT_FEAT_LOWSPEED; | ||
68 | if (DEV_HIGHSPEED(port_status)) | ||
69 | return 1 << USB_PORT_FEAT_HIGHSPEED; | ||
70 | if (DEV_SUPERSPEED(port_status)) | ||
71 | return 1 << USB_PORT_FEAT_SUPERSPEED; | ||
72 | /* | ||
73 | * FIXME: Yes, we should check for full speed, but the core uses that as | ||
74 | * a default in portspeed() in usb/core/hub.c (which is the only place | ||
75 | * USB_PORT_FEAT_*SPEED is used). | ||
76 | */ | ||
77 | return 0; | ||
78 | } | ||
79 | |||
80 | /* | ||
81 | * These bits are Read Only (RO) and should be saved and written to the | ||
82 | * registers: 0, 3, 10:13, 30 | ||
83 | * connect status, over-current status, port speed, and device removable. | ||
84 | * connect status and port speed are also sticky - meaning they're in | ||
85 | * the AUX well and they aren't changed by a hot, warm, or cold reset. | ||
86 | */ | ||
87 | #define XHCI_PORT_RO ((1<<0) | (1<<3) | (0xf<<10) | (1<<30)) | ||
88 | /* | ||
89 | * These bits are RW; writing a 0 clears the bit, writing a 1 sets the bit: | ||
90 | * bits 5:8, 9, 14:15, 25:27 | ||
91 | * link state, port power, port indicator state, "wake on" enable state | ||
92 | */ | ||
93 | #define XHCI_PORT_RWS ((0xf<<5) | (1<<9) | (0x3<<14) | (0x7<<25)) | ||
94 | /* | ||
95 | * These bits are RW; writing a 1 sets the bit, writing a 0 has no effect: | ||
96 | * bit 4 (port reset) | ||
97 | */ | ||
98 | #define XHCI_PORT_RW1S ((1<<4)) | ||
99 | /* | ||
100 | * These bits are RW; writing a 1 clears the bit, writing a 0 has no effect: | ||
101 | * bits 1, 17, 18, 19, 20, 21, 22, 23 | ||
102 | * port enable/disable, and | ||
103 | * change bits: connect, PED, warm port reset changed (reserved zero for USB 2.0 ports), | ||
104 | * over-current, reset, link state, and L1 change | ||
105 | */ | ||
106 | #define XHCI_PORT_RW1CS ((1<<1) | (0x7f<<17)) | ||
107 | /* | ||
108 | * Bit 16 is RW, and writing a '1' to it causes the link state control to be | ||
109 | * latched in | ||
110 | */ | ||
111 | #define XHCI_PORT_RW ((1<<16)) | ||
112 | /* | ||
113 | * These bits are Reserved Zero (RsvdZ) and zero should be written to them: | ||
114 | * bits 2, 24, 28:31 | ||
115 | */ | ||
116 | #define XHCI_PORT_RZ ((1<<2) | (1<<24) | (0xf<<28)) | ||
117 | |||
118 | /* | ||
119 | * Given a port state, this function returns a value that would result in the | ||
120 | * port being in the same state, if the value was written to the port status | ||
121 | * control register. | ||
122 | * Save Read Only (RO) bits and save read/write bits where | ||
123 | * writing a 0 clears the bit and writing a 1 sets the bit (RWS). | ||
124 | * For all other types (RW1S, RW1CS, RW, and RZ), writing a '0' has no effect. | ||
125 | */ | ||
126 | static u32 xhci_port_state_to_neutral(u32 state) | ||
127 | { | ||
128 | /* Save read-only status and port state */ | ||
129 | return (state & XHCI_PORT_RO) | (state & XHCI_PORT_RWS); | ||
130 | } | ||
131 | |||
132 | int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | ||
133 | u16 wIndex, char *buf, u16 wLength) | ||
134 | { | ||
135 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); | ||
136 | int ports; | ||
137 | unsigned long flags; | ||
138 | u32 temp, status; | ||
139 | int retval = 0; | ||
140 | u32 __iomem *addr; | ||
141 | char *port_change_bit; | ||
142 | |||
143 | ports = HCS_MAX_PORTS(xhci->hcs_params1); | ||
144 | |||
145 | spin_lock_irqsave(&xhci->lock, flags); | ||
146 | switch (typeReq) { | ||
147 | case GetHubStatus: | ||
148 | /* No power source, over-current reported per port */ | ||
149 | memset(buf, 0, 4); | ||
150 | break; | ||
151 | case GetHubDescriptor: | ||
152 | xhci_hub_descriptor(xhci, (struct usb_hub_descriptor *) buf); | ||
153 | break; | ||
154 | case GetPortStatus: | ||
155 | if (!wIndex || wIndex > ports) | ||
156 | goto error; | ||
157 | wIndex--; | ||
158 | status = 0; | ||
159 | addr = &xhci->op_regs->port_status_base + NUM_PORT_REGS*(wIndex & 0xff); | ||
160 | temp = xhci_readl(xhci, addr); | ||
161 | xhci_dbg(xhci, "get port status, actual port %d status = 0x%x\n", wIndex, temp); | ||
162 | |||
163 | /* wPortChange bits */ | ||
164 | if (temp & PORT_CSC) | ||
165 | status |= 1 << USB_PORT_FEAT_C_CONNECTION; | ||
166 | if (temp & PORT_PEC) | ||
167 | status |= 1 << USB_PORT_FEAT_C_ENABLE; | ||
168 | if ((temp & PORT_OCC)) | ||
169 | status |= 1 << USB_PORT_FEAT_C_OVER_CURRENT; | ||
170 | /* | ||
171 | * FIXME ignoring suspend, reset, and USB 2.1/3.0 specific | ||
172 | * changes | ||
173 | */ | ||
174 | if (temp & PORT_CONNECT) { | ||
175 | status |= 1 << USB_PORT_FEAT_CONNECTION; | ||
176 | status |= xhci_port_speed(temp); | ||
177 | } | ||
178 | if (temp & PORT_PE) | ||
179 | status |= 1 << USB_PORT_FEAT_ENABLE; | ||
180 | if (temp & PORT_OC) | ||
181 | status |= 1 << USB_PORT_FEAT_OVER_CURRENT; | ||
182 | if (temp & PORT_RESET) | ||
183 | status |= 1 << USB_PORT_FEAT_RESET; | ||
184 | if (temp & PORT_POWER) | ||
185 | status |= 1 << USB_PORT_FEAT_POWER; | ||
186 | xhci_dbg(xhci, "Get port status returned 0x%x\n", status); | ||
187 | put_unaligned(cpu_to_le32(status), (__le32 *) buf); | ||
188 | break; | ||
189 | case SetPortFeature: | ||
190 | wIndex &= 0xff; | ||
191 | if (!wIndex || wIndex > ports) | ||
192 | goto error; | ||
193 | wIndex--; | ||
194 | addr = &xhci->op_regs->port_status_base + NUM_PORT_REGS*(wIndex & 0xff); | ||
195 | temp = xhci_readl(xhci, addr); | ||
196 | temp = xhci_port_state_to_neutral(temp); | ||
197 | switch (wValue) { | ||
198 | case USB_PORT_FEAT_POWER: | ||
199 | /* | ||
200 | * Turn on ports, even if there isn't per-port switching. | ||
201 | * HC will report connect events even before this is set. | ||
202 | * However, khubd will ignore the roothub events until | ||
203 | * the roothub is registered. | ||
204 | */ | ||
205 | xhci_writel(xhci, temp | PORT_POWER, addr); | ||
206 | |||
207 | temp = xhci_readl(xhci, addr); | ||
208 | xhci_dbg(xhci, "set port power, actual port %d status = 0x%x\n", wIndex, temp); | ||
209 | break; | ||
210 | case USB_PORT_FEAT_RESET: | ||
211 | temp = (temp | PORT_RESET); | ||
212 | xhci_writel(xhci, temp, addr); | ||
213 | |||
214 | temp = xhci_readl(xhci, addr); | ||
215 | xhci_dbg(xhci, "set port reset, actual port %d status = 0x%x\n", wIndex, temp); | ||
216 | break; | ||
217 | default: | ||
218 | goto error; | ||
219 | } | ||
220 | temp = xhci_readl(xhci, addr); /* unblock any posted writes */ | ||
221 | break; | ||
222 | case ClearPortFeature: | ||
223 | if (!wIndex || wIndex > ports) | ||
224 | goto error; | ||
225 | wIndex--; | ||
226 | addr = &xhci->op_regs->port_status_base + | ||
227 | NUM_PORT_REGS*(wIndex & 0xff); | ||
228 | temp = xhci_readl(xhci, addr); | ||
229 | temp = xhci_port_state_to_neutral(temp); | ||
230 | switch (wValue) { | ||
231 | case USB_PORT_FEAT_C_RESET: | ||
232 | status = PORT_RC; | ||
233 | port_change_bit = "reset"; | ||
234 | break; | ||
235 | case USB_PORT_FEAT_C_CONNECTION: | ||
236 | status = PORT_CSC; | ||
237 | port_change_bit = "connect"; | ||
238 | break; | ||
239 | case USB_PORT_FEAT_C_OVER_CURRENT: | ||
240 | status = PORT_OCC; | ||
241 | port_change_bit = "over-current"; | ||
242 | break; | ||
243 | default: | ||
244 | goto error; | ||
245 | } | ||
246 | /* Change bits are all write 1 to clear */ | ||
247 | xhci_writel(xhci, temp | status, addr); | ||
248 | temp = xhci_readl(xhci, addr); | ||
249 | xhci_dbg(xhci, "clear port %s change, actual port %d status = 0x%x\n", | ||
250 | port_change_bit, wIndex, temp); | ||
251 | temp = xhci_readl(xhci, addr); /* unblock any posted writes */ | ||
252 | break; | ||
253 | default: | ||
254 | error: | ||
255 | /* "stall" on error */ | ||
256 | retval = -EPIPE; | ||
257 | } | ||
258 | spin_unlock_irqrestore(&xhci->lock, flags); | ||
259 | return retval; | ||
260 | } | ||
261 | |||
262 | /* | ||
263 | * Returns 0 if the status hasn't changed, or the number of bytes in buf. | ||
264 | * Ports are 0-indexed from the HCD point of view, | ||
265 | * and 1-indexed from the USB core pointer of view. | ||
266 | * xHCI instances can have up to 127 ports, so FIXME if you see more than 15. | ||
267 | * | ||
268 | * Note that the status change bits will be cleared as soon as a port status | ||
269 | * change event is generated, so we use the saved status from that event. | ||
270 | */ | ||
271 | int xhci_hub_status_data(struct usb_hcd *hcd, char *buf) | ||
272 | { | ||
273 | unsigned long flags; | ||
274 | u32 temp, status; | ||
275 | int i, retval; | ||
276 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); | ||
277 | int ports; | ||
278 | u32 __iomem *addr; | ||
279 | |||
280 | ports = HCS_MAX_PORTS(xhci->hcs_params1); | ||
281 | |||
282 | /* Initial status is no changes */ | ||
283 | buf[0] = 0; | ||
284 | status = 0; | ||
285 | if (ports > 7) { | ||
286 | buf[1] = 0; | ||
287 | retval = 2; | ||
288 | } else { | ||
289 | retval = 1; | ||
290 | } | ||
291 | |||
292 | spin_lock_irqsave(&xhci->lock, flags); | ||
293 | /* For each port, did anything change? If so, set that bit in buf. */ | ||
294 | for (i = 0; i < ports; i++) { | ||
295 | addr = &xhci->op_regs->port_status_base + | ||
296 | NUM_PORT_REGS*i; | ||
297 | temp = xhci_readl(xhci, addr); | ||
298 | if (temp & (PORT_CSC | PORT_PEC | PORT_OCC)) { | ||
299 | if (i < 7) | ||
300 | buf[0] |= 1 << (i + 1); | ||
301 | else | ||
302 | buf[1] |= 1 << (i - 7); | ||
303 | status = 1; | ||
304 | } | ||
305 | } | ||
306 | spin_unlock_irqrestore(&xhci->lock, flags); | ||
307 | return status ? retval : 0; | ||
308 | } | ||
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 89614af80d20..005c5b264a7c 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c | |||
@@ -113,7 +113,9 @@ static const struct hc_driver xhci_pci_hc_driver = { | |||
113 | */ | 113 | */ |
114 | .get_frame_number = xhci_get_frame, | 114 | .get_frame_number = xhci_get_frame, |
115 | 115 | ||
116 | /* Implement root hub support later. */ | 116 | /* Root hub support */ |
117 | .hub_control = xhci_hub_control, | ||
118 | .hub_status_data = xhci_hub_status_data, | ||
117 | }; | 119 | }; |
118 | 120 | ||
119 | /*-------------------------------------------------------------------------*/ | 121 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index c7e3c7142b9d..9d6bb3d730c4 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c | |||
@@ -284,9 +284,38 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, | |||
284 | inc_deq(xhci, xhci->cmd_ring, false); | 284 | inc_deq(xhci, xhci->cmd_ring, false); |
285 | } | 285 | } |
286 | 286 | ||
287 | static void handle_port_status(struct xhci_hcd *xhci, | ||
288 | union xhci_trb *event) | ||
289 | { | ||
290 | u32 port_id; | ||
291 | |||
292 | /* Port status change events always have a successful completion code */ | ||
293 | if (GET_COMP_CODE(event->generic.field[2]) != COMP_SUCCESS) { | ||
294 | xhci_warn(xhci, "WARN: xHC returned failed port status event\n"); | ||
295 | xhci->error_bitmask |= 1 << 8; | ||
296 | } | ||
297 | /* FIXME: core doesn't care about all port link state changes yet */ | ||
298 | port_id = GET_PORT_ID(event->generic.field[0]); | ||
299 | xhci_dbg(xhci, "Port Status Change Event for port %d\n", port_id); | ||
300 | |||
301 | /* Update event ring dequeue pointer before dropping the lock */ | ||
302 | inc_deq(xhci, xhci->event_ring, true); | ||
303 | set_hc_event_deq(xhci); | ||
304 | |||
305 | spin_unlock(&xhci->lock); | ||
306 | /* Pass this up to the core */ | ||
307 | usb_hcd_poll_rh_status(xhci_to_hcd(xhci)); | ||
308 | spin_lock(&xhci->lock); | ||
309 | } | ||
310 | |||
311 | /* | ||
312 | * This function handles all OS-owned events on the event ring. It may drop | ||
313 | * xhci->lock between event processing (e.g. to pass up port status changes). | ||
314 | */ | ||
287 | void handle_event(struct xhci_hcd *xhci) | 315 | void handle_event(struct xhci_hcd *xhci) |
288 | { | 316 | { |
289 | union xhci_trb *event; | 317 | union xhci_trb *event; |
318 | int update_ptrs = 1; | ||
290 | 319 | ||
291 | if (!xhci->event_ring || !xhci->event_ring->dequeue) { | 320 | if (!xhci->event_ring || !xhci->event_ring->dequeue) { |
292 | xhci->error_bitmask |= 1 << 1; | 321 | xhci->error_bitmask |= 1 << 1; |
@@ -301,18 +330,24 @@ void handle_event(struct xhci_hcd *xhci) | |||
301 | return; | 330 | return; |
302 | } | 331 | } |
303 | 332 | ||
304 | /* FIXME: Only handles command completion events. */ | 333 | /* FIXME: Handle more event types. */ |
305 | switch ((event->event_cmd.flags & TRB_TYPE_BITMASK)) { | 334 | switch ((event->event_cmd.flags & TRB_TYPE_BITMASK)) { |
306 | case TRB_TYPE(TRB_COMPLETION): | 335 | case TRB_TYPE(TRB_COMPLETION): |
307 | handle_cmd_completion(xhci, &event->event_cmd); | 336 | handle_cmd_completion(xhci, &event->event_cmd); |
308 | break; | 337 | break; |
338 | case TRB_TYPE(TRB_PORT_STATUS): | ||
339 | handle_port_status(xhci, event); | ||
340 | update_ptrs = 0; | ||
341 | break; | ||
309 | default: | 342 | default: |
310 | xhci->error_bitmask |= 1 << 3; | 343 | xhci->error_bitmask |= 1 << 3; |
311 | } | 344 | } |
312 | 345 | ||
313 | /* Update SW and HC event ring dequeue pointer */ | 346 | if (update_ptrs) { |
314 | inc_deq(xhci, xhci->event_ring, true); | 347 | /* Update SW and HC event ring dequeue pointer */ |
315 | set_hc_event_deq(xhci); | 348 | inc_deq(xhci, xhci->event_ring, true); |
349 | set_hc_event_deq(xhci); | ||
350 | } | ||
316 | /* Are there more items on the event ring? */ | 351 | /* Are there more items on the event ring? */ |
317 | handle_event(xhci); | 352 | handle_event(xhci); |
318 | } | 353 | } |
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 66be134b8921..059c659d3f39 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h | |||
@@ -35,6 +35,8 @@ | |||
35 | 35 | ||
36 | /* Max number of USB devices for any host controller - limit in section 6.1 */ | 36 | /* Max number of USB devices for any host controller - limit in section 6.1 */ |
37 | #define MAX_HC_SLOTS 256 | 37 | #define MAX_HC_SLOTS 256 |
38 | /* Section 5.3.3 - MaxPorts */ | ||
39 | #define MAX_HC_PORTS 127 | ||
38 | 40 | ||
39 | /* | 41 | /* |
40 | * xHCI register interface. | 42 | * xHCI register interface. |
@@ -710,6 +712,10 @@ struct xhci_event_cmd { | |||
710 | } __attribute__ ((packed)); | 712 | } __attribute__ ((packed)); |
711 | 713 | ||
712 | 714 | ||
715 | /* Port Status Change Event TRB fields */ | ||
716 | /* Port ID - bits 31:24 */ | ||
717 | #define GET_PORT_ID(p) (((p) & (0xff << 24)) >> 24) | ||
718 | |||
713 | /* Normal TRB fields */ | 719 | /* Normal TRB fields */ |
714 | /* transfer_len bitmasks - bits 0:16 */ | 720 | /* transfer_len bitmasks - bits 0:16 */ |
715 | #define TRB_LEN(p) ((p) & 0x1ffff) | 721 | #define TRB_LEN(p) ((p) & 0x1ffff) |
@@ -1024,4 +1030,9 @@ void *setup_one_noop(struct xhci_hcd *xhci); | |||
1024 | void handle_event(struct xhci_hcd *xhci); | 1030 | void handle_event(struct xhci_hcd *xhci); |
1025 | void set_hc_event_deq(struct xhci_hcd *xhci); | 1031 | void set_hc_event_deq(struct xhci_hcd *xhci); |
1026 | 1032 | ||
1033 | /* xHCI roothub code */ | ||
1034 | int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, | ||
1035 | char *buf, u16 wLength); | ||
1036 | int xhci_hub_status_data(struct usb_hcd *hcd, char *buf); | ||
1037 | |||
1027 | #endif /* __LINUX_XHCI_HCD_H */ | 1038 | #endif /* __LINUX_XHCI_HCD_H */ |