aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/usb.h')
-rw-r--r--include/linux/usb.h137
1 files changed, 66 insertions, 71 deletions
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 739f1fd1cc15..d5922a877994 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -45,27 +45,14 @@ struct wusb_dev;
45 45
46struct ep_device; 46struct ep_device;
47 47
48/* For SS devices */
49/**
50 * struct usb_host_ss_ep_comp - Valid for SuperSpeed devices only
51 * @desc: endpoint companion descriptor, wMaxPacketSize in native byteorder
52 * @extra: descriptors following this endpoint companion descriptor
53 * @extralen: how many bytes of "extra" are valid
54 */
55struct usb_host_ss_ep_comp {
56 struct usb_ss_ep_comp_descriptor desc;
57 unsigned char *extra; /* Extra descriptors */
58 int extralen;
59};
60
61/** 48/**
62 * struct usb_host_endpoint - host-side endpoint descriptor and queue 49 * struct usb_host_endpoint - host-side endpoint descriptor and queue
63 * @desc: descriptor for this endpoint, wMaxPacketSize in native byteorder 50 * @desc: descriptor for this endpoint, wMaxPacketSize in native byteorder
51 * @ss_ep_comp: SuperSpeed companion descriptor for this endpoint
64 * @urb_list: urbs queued to this endpoint; maintained by usbcore 52 * @urb_list: urbs queued to this endpoint; maintained by usbcore
65 * @hcpriv: for use by HCD; typically holds hardware dma queue head (QH) 53 * @hcpriv: for use by HCD; typically holds hardware dma queue head (QH)
66 * with one or more transfer descriptors (TDs) per urb 54 * with one or more transfer descriptors (TDs) per urb
67 * @ep_dev: ep_device for sysfs info 55 * @ep_dev: ep_device for sysfs info
68 * @ss_ep_comp: companion descriptor information for this endpoint
69 * @extra: descriptors following this endpoint in the configuration 56 * @extra: descriptors following this endpoint in the configuration
70 * @extralen: how many bytes of "extra" are valid 57 * @extralen: how many bytes of "extra" are valid
71 * @enabled: URBs may be submitted to this endpoint 58 * @enabled: URBs may be submitted to this endpoint
@@ -74,11 +61,11 @@ struct usb_host_ss_ep_comp {
74 * descriptor within an active interface in a given USB configuration. 61 * descriptor within an active interface in a given USB configuration.
75 */ 62 */
76struct usb_host_endpoint { 63struct usb_host_endpoint {
77 struct usb_endpoint_descriptor desc; 64 struct usb_endpoint_descriptor desc;
65 struct usb_ss_ep_comp_descriptor ss_ep_comp;
78 struct list_head urb_list; 66 struct list_head urb_list;
79 void *hcpriv; 67 void *hcpriv;
80 struct ep_device *ep_dev; /* For sysfs info */ 68 struct ep_device *ep_dev; /* For sysfs info */
81 struct usb_host_ss_ep_comp *ss_ep_comp; /* For SS devices */
82 69
83 unsigned char *extra; /* Extra descriptors */ 70 unsigned char *extra; /* Extra descriptors */
84 int extralen; 71 int extralen;
@@ -109,8 +96,8 @@ enum usb_interface_condition {
109/** 96/**
110 * struct usb_interface - what usb device drivers talk to 97 * struct usb_interface - what usb device drivers talk to
111 * @altsetting: array of interface structures, one for each alternate 98 * @altsetting: array of interface structures, one for each alternate
112 * setting that may be selected. Each one includes a set of 99 * setting that may be selected. Each one includes a set of
113 * endpoint configurations. They will be in no particular order. 100 * endpoint configurations. They will be in no particular order.
114 * @cur_altsetting: the current altsetting. 101 * @cur_altsetting: the current altsetting.
115 * @num_altsetting: number of altsettings defined. 102 * @num_altsetting: number of altsettings defined.
116 * @intf_assoc: interface association descriptor 103 * @intf_assoc: interface association descriptor
@@ -197,8 +184,6 @@ struct usb_interface {
197 struct work_struct reset_ws; /* for resets in atomic context */ 184 struct work_struct reset_ws; /* for resets in atomic context */
198}; 185};
199#define to_usb_interface(d) container_of(d, struct usb_interface, dev) 186#define to_usb_interface(d) container_of(d, struct usb_interface, dev)
200#define interface_to_usbdev(intf) \
201 container_of(intf->dev.parent, struct usb_device, dev)
202 187
203static inline void *usb_get_intfdata(struct usb_interface *intf) 188static inline void *usb_get_intfdata(struct usb_interface *intf)
204{ 189{
@@ -215,7 +200,7 @@ void usb_put_intf(struct usb_interface *intf);
215 200
216/* this maximum is arbitrary */ 201/* this maximum is arbitrary */
217#define USB_MAXINTERFACES 32 202#define USB_MAXINTERFACES 32
218#define USB_MAXIADS USB_MAXINTERFACES/2 203#define USB_MAXIADS (USB_MAXINTERFACES/2)
219 204
220/** 205/**
221 * struct usb_interface_cache - long-term representation of a device interface 206 * struct usb_interface_cache - long-term representation of a device interface
@@ -425,7 +410,6 @@ struct usb_tt;
425 * @connect_time: time device was first connected 410 * @connect_time: time device was first connected
426 * @do_remote_wakeup: remote wakeup should be enabled 411 * @do_remote_wakeup: remote wakeup should be enabled
427 * @reset_resume: needs reset instead of resume 412 * @reset_resume: needs reset instead of resume
428 * @autosuspend_disabled: autosuspend disabled by the user
429 * @wusb_dev: if this is a Wireless USB device, link to the WUSB 413 * @wusb_dev: if this is a Wireless USB device, link to the WUSB
430 * specific data for the device. 414 * specific data for the device.
431 * @slot_id: Slot ID assigned by xHCI 415 * @slot_id: Slot ID assigned by xHCI
@@ -436,7 +420,7 @@ struct usb_tt;
436 */ 420 */
437struct usb_device { 421struct usb_device {
438 int devnum; 422 int devnum;
439 char devpath [16]; 423 char devpath[16];
440 u32 route; 424 u32 route;
441 enum usb_device_state state; 425 enum usb_device_state state;
442 enum usb_device_speed speed; 426 enum usb_device_speed speed;
@@ -469,7 +453,7 @@ struct usb_device {
469 unsigned persist_enabled:1; 453 unsigned persist_enabled:1;
470 unsigned have_langid:1; 454 unsigned have_langid:1;
471 unsigned authorized:1; 455 unsigned authorized:1;
472 unsigned authenticated:1; 456 unsigned authenticated:1;
473 unsigned wusb:1; 457 unsigned wusb:1;
474 int string_langid; 458 int string_langid;
475 459
@@ -501,13 +485,17 @@ struct usb_device {
501 485
502 unsigned do_remote_wakeup:1; 486 unsigned do_remote_wakeup:1;
503 unsigned reset_resume:1; 487 unsigned reset_resume:1;
504 unsigned autosuspend_disabled:1;
505#endif 488#endif
506 struct wusb_dev *wusb_dev; 489 struct wusb_dev *wusb_dev;
507 int slot_id; 490 int slot_id;
508}; 491};
509#define to_usb_device(d) container_of(d, struct usb_device, dev) 492#define to_usb_device(d) container_of(d, struct usb_device, dev)
510 493
494static inline struct usb_device *interface_to_usbdev(struct usb_interface *intf)
495{
496 return to_usb_device(intf->dev.parent);
497}
498
511extern struct usb_device *usb_get_dev(struct usb_device *dev); 499extern struct usb_device *usb_get_dev(struct usb_device *dev);
512extern void usb_put_dev(struct usb_device *dev); 500extern void usb_put_dev(struct usb_device *dev);
513 501
@@ -522,12 +510,11 @@ extern int usb_lock_device_for_reset(struct usb_device *udev,
522extern int usb_reset_device(struct usb_device *dev); 510extern int usb_reset_device(struct usb_device *dev);
523extern void usb_queue_reset_device(struct usb_interface *dev); 511extern void usb_queue_reset_device(struct usb_interface *dev);
524 512
525extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id);
526 513
527/* USB autosuspend and autoresume */ 514/* USB autosuspend and autoresume */
528#ifdef CONFIG_USB_SUSPEND 515#ifdef CONFIG_USB_SUSPEND
529extern int usb_enable_autosuspend(struct usb_device *udev); 516extern void usb_enable_autosuspend(struct usb_device *udev);
530extern int usb_disable_autosuspend(struct usb_device *udev); 517extern void usb_disable_autosuspend(struct usb_device *udev);
531 518
532extern int usb_autopm_get_interface(struct usb_interface *intf); 519extern int usb_autopm_get_interface(struct usb_interface *intf);
533extern void usb_autopm_put_interface(struct usb_interface *intf); 520extern void usb_autopm_put_interface(struct usb_interface *intf);
@@ -572,6 +559,16 @@ static inline void usb_mark_last_busy(struct usb_device *udev)
572/* for drivers using iso endpoints */ 559/* for drivers using iso endpoints */
573extern int usb_get_current_frame_number(struct usb_device *usb_dev); 560extern int usb_get_current_frame_number(struct usb_device *usb_dev);
574 561
562/* Sets up a group of bulk endpoints to support multiple stream IDs. */
563extern int usb_alloc_streams(struct usb_interface *interface,
564 struct usb_host_endpoint **eps, unsigned int num_eps,
565 unsigned int num_streams, gfp_t mem_flags);
566
567/* Reverts a group of bulk endpoints back to not using stream IDs. */
568extern void usb_free_streams(struct usb_interface *interface,
569 struct usb_host_endpoint **eps, unsigned int num_eps,
570 gfp_t mem_flags);
571
575/* used these for multi-interface device registration */ 572/* used these for multi-interface device registration */
576extern int usb_driver_claim_interface(struct usb_driver *driver, 573extern int usb_driver_claim_interface(struct usb_driver *driver,
577 struct usb_interface *iface, void *priv); 574 struct usb_interface *iface, void *priv);
@@ -667,7 +664,7 @@ static inline int usb_make_path(struct usb_device *dev, char *buf, size_t size)
667 * This macro is used to create a struct usb_device_id that matches a 664 * This macro is used to create a struct usb_device_id that matches a
668 * specific device. 665 * specific device.
669 */ 666 */
670#define USB_DEVICE(vend,prod) \ 667#define USB_DEVICE(vend, prod) \
671 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, \ 668 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, \
672 .idVendor = (vend), \ 669 .idVendor = (vend), \
673 .idProduct = (prod) 670 .idProduct = (prod)
@@ -958,17 +955,25 @@ extern int usb_disabled(void);
958#define URB_ISO_ASAP 0x0002 /* iso-only, urb->start_frame 955#define URB_ISO_ASAP 0x0002 /* iso-only, urb->start_frame
959 * ignored */ 956 * ignored */
960#define URB_NO_TRANSFER_DMA_MAP 0x0004 /* urb->transfer_dma valid on submit */ 957#define URB_NO_TRANSFER_DMA_MAP 0x0004 /* urb->transfer_dma valid on submit */
961#define URB_NO_SETUP_DMA_MAP 0x0008 /* urb->setup_dma valid on submit */
962#define URB_NO_FSBR 0x0020 /* UHCI-specific */ 958#define URB_NO_FSBR 0x0020 /* UHCI-specific */
963#define URB_ZERO_PACKET 0x0040 /* Finish bulk OUT with short packet */ 959#define URB_ZERO_PACKET 0x0040 /* Finish bulk OUT with short packet */
964#define URB_NO_INTERRUPT 0x0080 /* HINT: no non-error interrupt 960#define URB_NO_INTERRUPT 0x0080 /* HINT: no non-error interrupt
965 * needed */ 961 * needed */
966#define URB_FREE_BUFFER 0x0100 /* Free transfer buffer with the URB */ 962#define URB_FREE_BUFFER 0x0100 /* Free transfer buffer with the URB */
967 963
964/* The following flags are used internally by usbcore and HCDs */
968#define URB_DIR_IN 0x0200 /* Transfer from device to host */ 965#define URB_DIR_IN 0x0200 /* Transfer from device to host */
969#define URB_DIR_OUT 0 966#define URB_DIR_OUT 0
970#define URB_DIR_MASK URB_DIR_IN 967#define URB_DIR_MASK URB_DIR_IN
971 968
969#define URB_DMA_MAP_SINGLE 0x00010000 /* Non-scatter-gather mapping */
970#define URB_DMA_MAP_PAGE 0x00020000 /* HCD-unsupported S-G */
971#define URB_DMA_MAP_SG 0x00040000 /* HCD-supported S-G */
972#define URB_MAP_LOCAL 0x00080000 /* HCD-local-memory mapping */
973#define URB_SETUP_MAP_SINGLE 0x00100000 /* Setup packet DMA mapped */
974#define URB_SETUP_MAP_LOCAL 0x00200000 /* HCD-local setup packet */
975#define URB_DMA_SG_COMBINED 0x00400000 /* S-G entries were combined */
976
972struct usb_iso_packet_descriptor { 977struct usb_iso_packet_descriptor {
973 unsigned int offset; 978 unsigned int offset;
974 unsigned int length; /* expected length */ 979 unsigned int length; /* expected length */
@@ -1045,12 +1050,8 @@ typedef void (*usb_complete_t)(struct urb *);
1045 * @setup_packet: Only used for control transfers, this points to eight bytes 1050 * @setup_packet: Only used for control transfers, this points to eight bytes
1046 * of setup data. Control transfers always start by sending this data 1051 * of setup data. Control transfers always start by sending this data
1047 * to the device. Then transfer_buffer is read or written, if needed. 1052 * to the device. Then transfer_buffer is read or written, if needed.
1048 * @setup_dma: For control transfers with URB_NO_SETUP_DMA_MAP set, the 1053 * @setup_dma: DMA pointer for the setup packet. The caller must not use
1049 * device driver has provided this DMA address for the setup packet. 1054 * this field; setup_packet must point to a valid buffer.
1050 * The host controller driver should use this in preference to
1051 * setup_packet, but the HCD may chose to ignore the address if it must
1052 * copy the setup packet into internal structures. Therefore, setup_packet
1053 * must always point to a valid buffer.
1054 * @start_frame: Returns the initial frame for isochronous transfers. 1055 * @start_frame: Returns the initial frame for isochronous transfers.
1055 * @number_of_packets: Lists the number of ISO transfer buffers. 1056 * @number_of_packets: Lists the number of ISO transfer buffers.
1056 * @interval: Specifies the polling interval for interrupt or isochronous 1057 * @interval: Specifies the polling interval for interrupt or isochronous
@@ -1082,13 +1083,14 @@ typedef void (*usb_complete_t)(struct urb *);
1082 * bounce buffer or talking to an IOMMU), 1083 * bounce buffer or talking to an IOMMU),
1083 * although they're cheap on commodity x86 and ppc hardware. 1084 * although they're cheap on commodity x86 and ppc hardware.
1084 * 1085 *
1085 * Alternatively, drivers may pass the URB_NO_xxx_DMA_MAP transfer flags, 1086 * Alternatively, drivers may pass the URB_NO_TRANSFER_DMA_MAP transfer flag,
1086 * which tell the host controller driver that no such mapping is needed since 1087 * which tells the host controller driver that no such mapping is needed for
1088 * the transfer_buffer since
1087 * the device driver is DMA-aware. For example, a device driver might 1089 * the device driver is DMA-aware. For example, a device driver might
1088 * allocate a DMA buffer with usb_alloc_coherent() or call usb_buffer_map(). 1090 * allocate a DMA buffer with usb_alloc_coherent() or call usb_buffer_map().
1089 * When these transfer flags are provided, host controller drivers will 1091 * When this transfer flag is provided, host controller drivers will
1090 * attempt to use the dma addresses found in the transfer_dma and/or 1092 * attempt to use the dma address found in the transfer_dma
1091 * setup_dma fields rather than determining a dma address themselves. 1093 * field rather than determining a dma address themselves.
1092 * 1094 *
1093 * Note that transfer_buffer must still be set if the controller 1095 * Note that transfer_buffer must still be set if the controller
1094 * does not support DMA (as indicated by bus.uses_dma) and when talking 1096 * does not support DMA (as indicated by bus.uses_dma) and when talking
@@ -1111,11 +1113,9 @@ typedef void (*usb_complete_t)(struct urb *);
1111 * should always terminate with a short packet, even if it means adding an 1113 * should always terminate with a short packet, even if it means adding an
1112 * extra zero length packet. 1114 * extra zero length packet.
1113 * 1115 *
1114 * Control URBs must provide a setup_packet. The setup_packet and 1116 * Control URBs must provide a valid pointer in the setup_packet field.
1115 * transfer_buffer may each be mapped for DMA or not, independently of 1117 * Unlike the transfer_buffer, the setup_packet may not be mapped for DMA
1116 * the other. The transfer_flags bits URB_NO_TRANSFER_DMA_MAP and 1118 * beforehand.
1117 * URB_NO_SETUP_DMA_MAP indicate which buffers have already been mapped.
1118 * URB_NO_SETUP_DMA_MAP is ignored for non-control URBs.
1119 * 1119 *
1120 * Interrupt URBs must provide an interval, saying how often (in milliseconds 1120 * Interrupt URBs must provide an interval, saying how often (in milliseconds
1121 * or, for highspeed devices, 125 microsecond units) 1121 * or, for highspeed devices, 125 microsecond units)
@@ -1186,14 +1186,15 @@ struct urb {
1186 * current owner */ 1186 * current owner */
1187 struct list_head anchor_list; /* the URB may be anchored */ 1187 struct list_head anchor_list; /* the URB may be anchored */
1188 struct usb_anchor *anchor; 1188 struct usb_anchor *anchor;
1189 struct usb_device *dev; /* (in) pointer to associated device */ 1189 struct usb_device *dev; /* (in) pointer to associated device */
1190 struct usb_host_endpoint *ep; /* (internal) pointer to endpoint */ 1190 struct usb_host_endpoint *ep; /* (internal) pointer to endpoint */
1191 unsigned int pipe; /* (in) pipe information */ 1191 unsigned int pipe; /* (in) pipe information */
1192 unsigned int stream_id; /* (in) stream ID */
1192 int status; /* (return) non-ISO status */ 1193 int status; /* (return) non-ISO status */
1193 unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/ 1194 unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/
1194 void *transfer_buffer; /* (in) associated data buffer */ 1195 void *transfer_buffer; /* (in) associated data buffer */
1195 dma_addr_t transfer_dma; /* (in) dma addr for transfer_buffer */ 1196 dma_addr_t transfer_dma; /* (in) dma addr for transfer_buffer */
1196 struct usb_sg_request *sg; /* (in) scatter gather buffer list */ 1197 struct scatterlist *sg; /* (in) scatter gather buffer list */
1197 int num_sgs; /* (in) number of entries in the sg list */ 1198 int num_sgs; /* (in) number of entries in the sg list */
1198 u32 transfer_buffer_length; /* (in) data buffer length */ 1199 u32 transfer_buffer_length; /* (in) data buffer length */
1199 u32 actual_length; /* (return) actual transfer length */ 1200 u32 actual_length; /* (return) actual transfer length */
@@ -1371,18 +1372,6 @@ void *usb_alloc_coherent(struct usb_device *dev, size_t size,
1371void usb_free_coherent(struct usb_device *dev, size_t size, 1372void usb_free_coherent(struct usb_device *dev, size_t size,
1372 void *addr, dma_addr_t dma); 1373 void *addr, dma_addr_t dma);
1373 1374
1374/* Compatible macros while we switch over */
1375static inline void *usb_buffer_alloc(struct usb_device *dev, size_t size,
1376 gfp_t mem_flags, dma_addr_t *dma)
1377{
1378 return usb_alloc_coherent(dev, size, mem_flags, dma);
1379}
1380static inline void usb_buffer_free(struct usb_device *dev, size_t size,
1381 void *addr, dma_addr_t dma)
1382{
1383 return usb_free_coherent(dev, size, addr, dma);
1384}
1385
1386#if 0 1375#if 0
1387struct urb *usb_buffer_map(struct urb *urb); 1376struct urb *usb_buffer_map(struct urb *urb);
1388void usb_buffer_dmasync(struct urb *urb); 1377void usb_buffer_dmasync(struct urb *urb);
@@ -1467,8 +1456,6 @@ struct usb_sg_request {
1467 1456
1468 struct usb_device *dev; 1457 struct usb_device *dev;
1469 int pipe; 1458 int pipe;
1470 struct scatterlist *sg;
1471 int nents;
1472 1459
1473 int entries; 1460 int entries;
1474 struct urb **urbs; 1461 struct urb **urbs;
@@ -1536,23 +1523,31 @@ static inline unsigned int __create_pipe(struct usb_device *dev,
1536} 1523}
1537 1524
1538/* Create various pipes... */ 1525/* Create various pipes... */
1539#define usb_sndctrlpipe(dev,endpoint) \ 1526#define usb_sndctrlpipe(dev, endpoint) \
1540 ((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint)) 1527 ((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint))
1541#define usb_rcvctrlpipe(dev,endpoint) \ 1528#define usb_rcvctrlpipe(dev, endpoint) \
1542 ((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) 1529 ((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN)
1543#define usb_sndisocpipe(dev,endpoint) \ 1530#define usb_sndisocpipe(dev, endpoint) \
1544 ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint)) 1531 ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint))
1545#define usb_rcvisocpipe(dev,endpoint) \ 1532#define usb_rcvisocpipe(dev, endpoint) \
1546 ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) 1533 ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN)
1547#define usb_sndbulkpipe(dev,endpoint) \ 1534#define usb_sndbulkpipe(dev, endpoint) \
1548 ((PIPE_BULK << 30) | __create_pipe(dev, endpoint)) 1535 ((PIPE_BULK << 30) | __create_pipe(dev, endpoint))
1549#define usb_rcvbulkpipe(dev,endpoint) \ 1536#define usb_rcvbulkpipe(dev, endpoint) \
1550 ((PIPE_BULK << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) 1537 ((PIPE_BULK << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN)
1551#define usb_sndintpipe(dev,endpoint) \ 1538#define usb_sndintpipe(dev, endpoint) \
1552 ((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint)) 1539 ((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint))
1553#define usb_rcvintpipe(dev,endpoint) \ 1540#define usb_rcvintpipe(dev, endpoint) \
1554 ((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) 1541 ((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN)
1555 1542
1543static inline struct usb_host_endpoint *
1544usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe)
1545{
1546 struct usb_host_endpoint **eps;
1547 eps = usb_pipein(pipe) ? dev->ep_in : dev->ep_out;
1548 return eps[usb_pipeendpoint(pipe)];
1549}
1550
1556/*-------------------------------------------------------------------------*/ 1551/*-------------------------------------------------------------------------*/
1557 1552
1558static inline __u16 1553static inline __u16