aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorTatyana Brokhman <tlinder@codeaurora.org>2011-06-28 09:33:53 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-06-28 14:20:15 -0400
commita59d6b91cbca52235e3ed9f7f9e34c4f2f3e1996 (patch)
tree664cd1de638695c0f4ad8c73df27382a3ecc6659 /drivers/usb
parent7c884fe4d74d17efc83b19f3dc898a75f03859e9 (diff)
usb: gadget: add streams support to the gadget framework
This patch defines necessary fields to support streaming for USB3.0. It implements a new function, called usb_ep_autoconfig_ss(), to be used instead of the existing usb_ep_autoconfig() when working in SuperSpeed mode and there is a need to search for an endpoint according to the number of required streams. [ balbi@ti.com : slight changes to commit log ] Signed-off-by: Maya Erez <merez@codeaurora.org> Signed-off-by: Tatyana Brokhman <tlinder@codeaurora.org> Signed-off-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/epautoconf.c125
1 files changed, 100 insertions, 25 deletions
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 0022d44060ae..91c032fbdf1c 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -63,13 +63,16 @@ static int
63ep_matches ( 63ep_matches (
64 struct usb_gadget *gadget, 64 struct usb_gadget *gadget,
65 struct usb_ep *ep, 65 struct usb_ep *ep,
66 struct usb_endpoint_descriptor *desc 66 struct usb_endpoint_descriptor *desc,
67 struct usb_ss_ep_comp_descriptor *ep_comp
67) 68)
68{ 69{
69 u8 type; 70 u8 type;
70 const char *tmp; 71 const char *tmp;
71 u16 max; 72 u16 max;
72 73
74 int num_req_streams = 0;
75
73 /* endpoint already claimed? */ 76 /* endpoint already claimed? */
74 if (NULL != ep->driver_data) 77 if (NULL != ep->driver_data)
75 return 0; 78 return 0;
@@ -129,6 +132,22 @@ ep_matches (
129 } 132 }
130 133
131 /* 134 /*
135 * Get the number of required streams from the EP companion
136 * descriptor and see if the EP matches it
137 */
138 if (usb_endpoint_xfer_bulk(desc)) {
139 if (ep_comp) {
140 num_req_streams = ep_comp->bmAttributes & 0x1f;
141 if (num_req_streams > ep->max_streams)
142 return 0;
143 /* Update the ep_comp descriptor if needed */
144 if (num_req_streams != ep->max_streams)
145 ep_comp->bmAttributes = ep->max_streams;
146 }
147
148 }
149
150 /*
132 * If the protocol driver hasn't yet decided on wMaxPacketSize 151 * If the protocol driver hasn't yet decided on wMaxPacketSize
133 * and wants to know the maximum possible, provide the info. 152 * and wants to know the maximum possible, provide the info.
134 */ 153 */
@@ -208,38 +227,53 @@ find_ep (struct usb_gadget *gadget, const char *name)
208} 227}
209 228
210/** 229/**
211 * usb_ep_autoconfig - choose an endpoint matching the descriptor 230 * usb_ep_autoconfig_ss() - choose an endpoint matching the ep
231 * descriptor and ep companion descriptor
212 * @gadget: The device to which the endpoint must belong. 232 * @gadget: The device to which the endpoint must belong.
213 * @desc: Endpoint descriptor, with endpoint direction and transfer mode 233 * @desc: Endpoint descriptor, with endpoint direction and transfer mode
214 * initialized. For periodic transfers, the maximum packet 234 * initialized. For periodic transfers, the maximum packet
215 * size must also be initialized. This is modified on success. 235 * size must also be initialized. This is modified on
236 * success.
237 * @ep_comp: Endpoint companion descriptor, with the required
238 * number of streams. Will be modified when the chosen EP
239 * supports a different number of streams.
216 * 240 *
217 * By choosing an endpoint to use with the specified descriptor, this 241 * This routine replaces the usb_ep_autoconfig when needed
218 * routine simplifies writing gadget drivers that work with multiple 242 * superspeed enhancments. If such enhancemnets are required,
219 * USB device controllers. The endpoint would be passed later to 243 * the FD should call usb_ep_autoconfig_ss directly and provide
220 * usb_ep_enable(), along with some descriptor. 244 * the additional ep_comp parameter.
245 *
246 * By choosing an endpoint to use with the specified descriptor,
247 * this routine simplifies writing gadget drivers that work with
248 * multiple USB device controllers. The endpoint would be
249 * passed later to usb_ep_enable(), along with some descriptor.
221 * 250 *
222 * That second descriptor won't always be the same as the first one. 251 * That second descriptor won't always be the same as the first one.
223 * For example, isochronous endpoints can be autoconfigured for high 252 * For example, isochronous endpoints can be autoconfigured for high
224 * bandwidth, and then used in several lower bandwidth altsettings. 253 * bandwidth, and then used in several lower bandwidth altsettings.
225 * Also, high and full speed descriptors will be different. 254 * Also, high and full speed descriptors will be different.
226 * 255 *
227 * Be sure to examine and test the results of autoconfiguration on your 256 * Be sure to examine and test the results of autoconfiguration
228 * hardware. This code may not make the best choices about how to use the 257 * on your hardware. This code may not make the best choices
229 * USB controller, and it can't know all the restrictions that may apply. 258 * about how to use the USB controller, and it can't know all
230 * Some combinations of driver and hardware won't be able to autoconfigure. 259 * the restrictions that may apply. Some combinations of driver
260 * and hardware won't be able to autoconfigure.
231 * 261 *
232 * On success, this returns an un-claimed usb_ep, and modifies the endpoint 262 * On success, this returns an un-claimed usb_ep, and modifies the endpoint
233 * descriptor bEndpointAddress. For bulk endpoints, the wMaxPacket value 263 * descriptor bEndpointAddress. For bulk endpoints, the wMaxPacket value
234 * is initialized as if the endpoint were used at full speed. To prevent 264 * is initialized as if the endpoint were used at full speed and
235 * the endpoint from being returned by a later autoconfig call, claim it 265 * the bmAttribute field in the ep companion descriptor is
236 * by assigning ep->driver_data to some non-null value. 266 * updated with the assigned number of streams if it is
267 * different from the original value. To prevent the endpoint
268 * from being returned by a later autoconfig call, claim it by
269 * assigning ep->driver_data to some non-null value.
237 * 270 *
238 * On failure, this returns a null endpoint descriptor. 271 * On failure, this returns a null endpoint descriptor.
239 */ 272 */
240struct usb_ep *usb_ep_autoconfig ( 273struct usb_ep *usb_ep_autoconfig_ss(
241 struct usb_gadget *gadget, 274 struct usb_gadget *gadget,
242 struct usb_endpoint_descriptor *desc 275 struct usb_endpoint_descriptor *desc,
276 struct usb_ss_ep_comp_descriptor *ep_comp
243) 277)
244{ 278{
245 struct usb_ep *ep; 279 struct usb_ep *ep;
@@ -253,23 +287,24 @@ struct usb_ep *usb_ep_autoconfig (
253 if (gadget_is_net2280 (gadget) && type == USB_ENDPOINT_XFER_INT) { 287 if (gadget_is_net2280 (gadget) && type == USB_ENDPOINT_XFER_INT) {
254 /* ep-e, ep-f are PIO with only 64 byte fifos */ 288 /* ep-e, ep-f are PIO with only 64 byte fifos */
255 ep = find_ep (gadget, "ep-e"); 289 ep = find_ep (gadget, "ep-e");
256 if (ep && ep_matches (gadget, ep, desc)) 290 if (ep && ep_matches(gadget, ep, desc, ep_comp))
257 return ep; 291 return ep;
258 ep = find_ep (gadget, "ep-f"); 292 ep = find_ep (gadget, "ep-f");
259 if (ep && ep_matches (gadget, ep, desc)) 293 if (ep && ep_matches(gadget, ep, desc, ep_comp))
260 return ep; 294 return ep;
261 295
262 } else if (gadget_is_goku (gadget)) { 296 } else if (gadget_is_goku (gadget)) {
263 if (USB_ENDPOINT_XFER_INT == type) { 297 if (USB_ENDPOINT_XFER_INT == type) {
264 /* single buffering is enough */ 298 /* single buffering is enough */
265 ep = find_ep (gadget, "ep3-bulk"); 299 ep = find_ep(gadget, "ep3-bulk");
266 if (ep && ep_matches (gadget, ep, desc)) 300 if (ep && ep_matches(gadget, ep, desc, ep_comp))
267 return ep; 301 return ep;
268 } else if (USB_ENDPOINT_XFER_BULK == type 302 } else if (USB_ENDPOINT_XFER_BULK == type
269 && (USB_DIR_IN & desc->bEndpointAddress)) { 303 && (USB_DIR_IN & desc->bEndpointAddress)) {
270 /* DMA may be available */ 304 /* DMA may be available */
271 ep = find_ep (gadget, "ep2-bulk"); 305 ep = find_ep(gadget, "ep2-bulk");
272 if (ep && ep_matches (gadget, ep, desc)) 306 if (ep && ep_matches(gadget, ep, desc,
307 ep_comp))
273 return ep; 308 return ep;
274 } 309 }
275 310
@@ -288,14 +323,14 @@ struct usb_ep *usb_ep_autoconfig (
288 ep = find_ep(gadget, "ep2out"); 323 ep = find_ep(gadget, "ep2out");
289 } else 324 } else
290 ep = NULL; 325 ep = NULL;
291 if (ep && ep_matches (gadget, ep, desc)) 326 if (ep && ep_matches(gadget, ep, desc, ep_comp))
292 return ep; 327 return ep;
293#endif 328#endif
294 } 329 }
295 330
296 /* Second, look at endpoints until an unclaimed one looks usable */ 331 /* Second, look at endpoints until an unclaimed one looks usable */
297 list_for_each_entry (ep, &gadget->ep_list, ep_list) { 332 list_for_each_entry (ep, &gadget->ep_list, ep_list) {
298 if (ep_matches (gadget, ep, desc)) 333 if (ep_matches(gadget, ep, desc, ep_comp))
299 return ep; 334 return ep;
300 } 335 }
301 336
@@ -304,6 +339,46 @@ struct usb_ep *usb_ep_autoconfig (
304} 339}
305 340
306/** 341/**
342 * usb_ep_autoconfig() - choose an endpoint matching the
343 * descriptor
344 * @gadget: The device to which the endpoint must belong.
345 * @desc: Endpoint descriptor, with endpoint direction and transfer mode
346 * initialized. For periodic transfers, the maximum packet
347 * size must also be initialized. This is modified on success.
348 *
349 * By choosing an endpoint to use with the specified descriptor, this
350 * routine simplifies writing gadget drivers that work with multiple
351 * USB device controllers. The endpoint would be passed later to
352 * usb_ep_enable(), along with some descriptor.
353 *
354 * That second descriptor won't always be the same as the first one.
355 * For example, isochronous endpoints can be autoconfigured for high
356 * bandwidth, and then used in several lower bandwidth altsettings.
357 * Also, high and full speed descriptors will be different.
358 *
359 * Be sure to examine and test the results of autoconfiguration on your
360 * hardware. This code may not make the best choices about how to use the
361 * USB controller, and it can't know all the restrictions that may apply.
362 * Some combinations of driver and hardware won't be able to autoconfigure.
363 *
364 * On success, this returns an un-claimed usb_ep, and modifies the endpoint
365 * descriptor bEndpointAddress. For bulk endpoints, the wMaxPacket value
366 * is initialized as if the endpoint were used at full speed. To prevent
367 * the endpoint from being returned by a later autoconfig call, claim it
368 * by assigning ep->driver_data to some non-null value.
369 *
370 * On failure, this returns a null endpoint descriptor.
371 */
372struct usb_ep *usb_ep_autoconfig(
373 struct usb_gadget *gadget,
374 struct usb_endpoint_descriptor *desc
375)
376{
377 return usb_ep_autoconfig_ss(gadget, desc, NULL);
378}
379
380
381/**
307 * usb_ep_autoconfig_reset - reset endpoint autoconfig state 382 * usb_ep_autoconfig_reset - reset endpoint autoconfig state
308 * @gadget: device for which autoconfig state will be reset 383 * @gadget: device for which autoconfig state will be reset
309 * 384 *