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.h205
1 files changed, 104 insertions, 101 deletions
diff --git a/include/linux/usb.h b/include/linux/usb.h
index d7ace1b80f09..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
@@ -122,7 +109,6 @@ enum usb_interface_condition {
122 * number from the USB core by calling usb_register_dev(). 109 * number from the USB core by calling usb_register_dev().
123 * @condition: binding state of the interface: not bound, binding 110 * @condition: binding state of the interface: not bound, binding
124 * (in probe()), bound to a driver, or unbinding (in disconnect()) 111 * (in probe()), bound to a driver, or unbinding (in disconnect())
125 * @is_active: flag set when the interface is bound and not suspended.
126 * @sysfs_files_created: sysfs attributes exist 112 * @sysfs_files_created: sysfs attributes exist
127 * @ep_devs_created: endpoint child pseudo-devices exist 113 * @ep_devs_created: endpoint child pseudo-devices exist
128 * @unregistering: flag set when the interface is being unregistered 114 * @unregistering: flag set when the interface is being unregistered
@@ -135,8 +121,7 @@ enum usb_interface_condition {
135 * @dev: driver model's view of this device 121 * @dev: driver model's view of this device
136 * @usb_dev: if an interface is bound to the USB major, this will point 122 * @usb_dev: if an interface is bound to the USB major, this will point
137 * to the sysfs representation for that device. 123 * to the sysfs representation for that device.
138 * @pm_usage_cnt: PM usage counter for this interface; autosuspend is not 124 * @pm_usage_cnt: PM usage counter for this interface
139 * allowed unless the counter is 0.
140 * @reset_ws: Used for scheduling resets from atomic context. 125 * @reset_ws: Used for scheduling resets from atomic context.
141 * @reset_running: set to 1 if the interface is currently running a 126 * @reset_running: set to 1 if the interface is currently running a
142 * queued reset so that usb_cancel_queued_reset() doesn't try to 127 * queued reset so that usb_cancel_queued_reset() doesn't try to
@@ -184,7 +169,6 @@ struct usb_interface {
184 int minor; /* minor number this interface is 169 int minor; /* minor number this interface is
185 * bound to */ 170 * bound to */
186 enum usb_interface_condition condition; /* state of binding */ 171 enum usb_interface_condition condition; /* state of binding */
187 unsigned is_active:1; /* the interface is not suspended */
188 unsigned sysfs_files_created:1; /* the sysfs attributes exist */ 172 unsigned sysfs_files_created:1; /* the sysfs attributes exist */
189 unsigned ep_devs_created:1; /* endpoint "devices" exist */ 173 unsigned ep_devs_created:1; /* endpoint "devices" exist */
190 unsigned unregistering:1; /* unregistration is in progress */ 174 unsigned unregistering:1; /* unregistration is in progress */
@@ -200,8 +184,6 @@ struct usb_interface {
200 struct work_struct reset_ws; /* for resets in atomic context */ 184 struct work_struct reset_ws; /* for resets in atomic context */
201}; 185};
202#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)
203#define interface_to_usbdev(intf) \
204 container_of(intf->dev.parent, struct usb_device, dev)
205 187
206static inline void *usb_get_intfdata(struct usb_interface *intf) 188static inline void *usb_get_intfdata(struct usb_interface *intf)
207{ 189{
@@ -218,7 +200,7 @@ void usb_put_intf(struct usb_interface *intf);
218 200
219/* this maximum is arbitrary */ 201/* this maximum is arbitrary */
220#define USB_MAXINTERFACES 32 202#define USB_MAXINTERFACES 32
221#define USB_MAXIADS USB_MAXINTERFACES/2 203#define USB_MAXIADS (USB_MAXINTERFACES/2)
222 204
223/** 205/**
224 * struct usb_interface_cache - long-term representation of a device interface 206 * struct usb_interface_cache - long-term representation of a device interface
@@ -339,6 +321,7 @@ struct usb_bus {
339 321
340 struct usb_devmap devmap; /* device address allocation map */ 322 struct usb_devmap devmap; /* device address allocation map */
341 struct usb_device *root_hub; /* Root hub */ 323 struct usb_device *root_hub; /* Root hub */
324 struct usb_bus *hs_companion; /* Companion EHCI bus, if any */
342 struct list_head bus_list; /* list of busses */ 325 struct list_head bus_list; /* list of busses */
343 326
344 int bandwidth_allocated; /* on this bus: how much of the time 327 int bandwidth_allocated; /* on this bus: how much of the time
@@ -400,7 +383,6 @@ struct usb_tt;
400 * @portnum: parent port number (origin 1) 383 * @portnum: parent port number (origin 1)
401 * @level: number of USB hub ancestors 384 * @level: number of USB hub ancestors
402 * @can_submit: URBs may be submitted 385 * @can_submit: URBs may be submitted
403 * @discon_suspended: disconnected while suspended
404 * @persist_enabled: USB_PERSIST enabled for this device 386 * @persist_enabled: USB_PERSIST enabled for this device
405 * @have_langid: whether string_langid is valid 387 * @have_langid: whether string_langid is valid
406 * @authorized: policy has said we can use it; 388 * @authorized: policy has said we can use it;
@@ -420,20 +402,14 @@ struct usb_tt;
420 * @usbfs_dentry: usbfs dentry entry for the device 402 * @usbfs_dentry: usbfs dentry entry for the device
421 * @maxchild: number of ports if hub 403 * @maxchild: number of ports if hub
422 * @children: child devices - USB devices that are attached to this hub 404 * @children: child devices - USB devices that are attached to this hub
423 * @pm_usage_cnt: usage counter for autosuspend
424 * @quirks: quirks of the whole device 405 * @quirks: quirks of the whole device
425 * @urbnum: number of URBs submitted for the whole device 406 * @urbnum: number of URBs submitted for the whole device
426 * @active_duration: total time device is not suspended 407 * @active_duration: total time device is not suspended
427 * @autosuspend: for delayed autosuspends
428 * @autoresume: for autoresumes requested while in_interrupt
429 * @pm_mutex: protects PM operations
430 * @last_busy: time of last use 408 * @last_busy: time of last use
431 * @autosuspend_delay: in jiffies 409 * @autosuspend_delay: in jiffies
432 * @connect_time: time device was first connected 410 * @connect_time: time device was first connected
433 * @do_remote_wakeup: remote wakeup should be enabled 411 * @do_remote_wakeup: remote wakeup should be enabled
434 * @reset_resume: needs reset instead of resume 412 * @reset_resume: needs reset instead of resume
435 * @autosuspend_disabled: autosuspend disabled by the user
436 * @skip_sys_resume: skip the next system resume
437 * @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
438 * specific data for the device. 414 * specific data for the device.
439 * @slot_id: Slot ID assigned by xHCI 415 * @slot_id: Slot ID assigned by xHCI
@@ -444,7 +420,7 @@ struct usb_tt;
444 */ 420 */
445struct usb_device { 421struct usb_device {
446 int devnum; 422 int devnum;
447 char devpath [16]; 423 char devpath[16];
448 u32 route; 424 u32 route;
449 enum usb_device_state state; 425 enum usb_device_state state;
450 enum usb_device_speed speed; 426 enum usb_device_speed speed;
@@ -474,11 +450,10 @@ struct usb_device {
474 u8 level; 450 u8 level;
475 451
476 unsigned can_submit:1; 452 unsigned can_submit:1;
477 unsigned discon_suspended:1;
478 unsigned persist_enabled:1; 453 unsigned persist_enabled:1;
479 unsigned have_langid:1; 454 unsigned have_langid:1;
480 unsigned authorized:1; 455 unsigned authorized:1;
481 unsigned authenticated:1; 456 unsigned authenticated:1;
482 unsigned wusb:1; 457 unsigned wusb:1;
483 int string_langid; 458 int string_langid;
484 459
@@ -498,38 +473,36 @@ struct usb_device {
498 int maxchild; 473 int maxchild;
499 struct usb_device *children[USB_MAXCHILDREN]; 474 struct usb_device *children[USB_MAXCHILDREN];
500 475
501 int pm_usage_cnt;
502 u32 quirks; 476 u32 quirks;
503 atomic_t urbnum; 477 atomic_t urbnum;
504 478
505 unsigned long active_duration; 479 unsigned long active_duration;
506 480
507#ifdef CONFIG_PM 481#ifdef CONFIG_PM
508 struct delayed_work autosuspend;
509 struct work_struct autoresume;
510 struct mutex pm_mutex;
511
512 unsigned long last_busy; 482 unsigned long last_busy;
513 int autosuspend_delay; 483 int autosuspend_delay;
514 unsigned long connect_time; 484 unsigned long connect_time;
515 485
516 unsigned do_remote_wakeup:1; 486 unsigned do_remote_wakeup:1;
517 unsigned reset_resume:1; 487 unsigned reset_resume:1;
518 unsigned autosuspend_disabled:1;
519 unsigned skip_sys_resume:1;
520#endif 488#endif
521 struct wusb_dev *wusb_dev; 489 struct wusb_dev *wusb_dev;
522 int slot_id; 490 int slot_id;
523}; 491};
524#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)
525 493
494static inline struct usb_device *interface_to_usbdev(struct usb_interface *intf)
495{
496 return to_usb_device(intf->dev.parent);
497}
498
526extern struct usb_device *usb_get_dev(struct usb_device *dev); 499extern struct usb_device *usb_get_dev(struct usb_device *dev);
527extern void usb_put_dev(struct usb_device *dev); 500extern void usb_put_dev(struct usb_device *dev);
528 501
529/* USB device locking */ 502/* USB device locking */
530#define usb_lock_device(udev) down(&(udev)->dev.sem) 503#define usb_lock_device(udev) device_lock(&(udev)->dev)
531#define usb_unlock_device(udev) up(&(udev)->dev.sem) 504#define usb_unlock_device(udev) device_unlock(&(udev)->dev)
532#define usb_trylock_device(udev) down_trylock(&(udev)->dev.sem) 505#define usb_trylock_device(udev) device_trylock(&(udev)->dev)
533extern int usb_lock_device_for_reset(struct usb_device *udev, 506extern int usb_lock_device_for_reset(struct usb_device *udev,
534 const struct usb_interface *iface); 507 const struct usb_interface *iface);
535 508
@@ -537,25 +510,18 @@ extern int usb_lock_device_for_reset(struct usb_device *udev,
537extern int usb_reset_device(struct usb_device *dev); 510extern int usb_reset_device(struct usb_device *dev);
538extern void usb_queue_reset_device(struct usb_interface *dev); 511extern void usb_queue_reset_device(struct usb_interface *dev);
539 512
540extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id);
541 513
542/* USB autosuspend and autoresume */ 514/* USB autosuspend and autoresume */
543#ifdef CONFIG_USB_SUSPEND 515#ifdef CONFIG_USB_SUSPEND
516extern void usb_enable_autosuspend(struct usb_device *udev);
517extern void usb_disable_autosuspend(struct usb_device *udev);
518
544extern int usb_autopm_get_interface(struct usb_interface *intf); 519extern int usb_autopm_get_interface(struct usb_interface *intf);
545extern void usb_autopm_put_interface(struct usb_interface *intf); 520extern void usb_autopm_put_interface(struct usb_interface *intf);
546extern int usb_autopm_get_interface_async(struct usb_interface *intf); 521extern int usb_autopm_get_interface_async(struct usb_interface *intf);
547extern void usb_autopm_put_interface_async(struct usb_interface *intf); 522extern void usb_autopm_put_interface_async(struct usb_interface *intf);
548 523extern void usb_autopm_get_interface_no_resume(struct usb_interface *intf);
549static inline void usb_autopm_get_interface_no_resume( 524extern void usb_autopm_put_interface_no_suspend(struct usb_interface *intf);
550 struct usb_interface *intf)
551{
552 atomic_inc(&intf->pm_usage_cnt);
553}
554static inline void usb_autopm_put_interface_no_suspend(
555 struct usb_interface *intf)
556{
557 atomic_dec(&intf->pm_usage_cnt);
558}
559 525
560static inline void usb_mark_last_busy(struct usb_device *udev) 526static inline void usb_mark_last_busy(struct usb_device *udev)
561{ 527{
@@ -564,6 +530,11 @@ static inline void usb_mark_last_busy(struct usb_device *udev)
564 530
565#else 531#else
566 532
533static inline int usb_enable_autosuspend(struct usb_device *udev)
534{ return 0; }
535static inline int usb_disable_autosuspend(struct usb_device *udev)
536{ return 0; }
537
567static inline int usb_autopm_get_interface(struct usb_interface *intf) 538static inline int usb_autopm_get_interface(struct usb_interface *intf)
568{ return 0; } 539{ return 0; }
569static inline int usb_autopm_get_interface_async(struct usb_interface *intf) 540static inline int usb_autopm_get_interface_async(struct usb_interface *intf)
@@ -588,6 +559,16 @@ static inline void usb_mark_last_busy(struct usb_device *udev)
588/* for drivers using iso endpoints */ 559/* for drivers using iso endpoints */
589extern int usb_get_current_frame_number(struct usb_device *usb_dev); 560extern int usb_get_current_frame_number(struct usb_device *usb_dev);
590 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
591/* used these for multi-interface device registration */ 572/* used these for multi-interface device registration */
592extern int usb_driver_claim_interface(struct usb_driver *driver, 573extern int usb_driver_claim_interface(struct usb_driver *driver,
593 struct usb_interface *iface, void *priv); 574 struct usb_interface *iface, void *priv);
@@ -683,7 +664,7 @@ static inline int usb_make_path(struct usb_device *dev, char *buf, size_t size)
683 * 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
684 * specific device. 665 * specific device.
685 */ 666 */
686#define USB_DEVICE(vend,prod) \ 667#define USB_DEVICE(vend, prod) \
687 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, \ 668 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, \
688 .idVendor = (vend), \ 669 .idVendor = (vend), \
689 .idProduct = (prod) 670 .idProduct = (prod)
@@ -974,17 +955,25 @@ extern int usb_disabled(void);
974#define URB_ISO_ASAP 0x0002 /* iso-only, urb->start_frame 955#define URB_ISO_ASAP 0x0002 /* iso-only, urb->start_frame
975 * ignored */ 956 * ignored */
976#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 */
977#define URB_NO_SETUP_DMA_MAP 0x0008 /* urb->setup_dma valid on submit */
978#define URB_NO_FSBR 0x0020 /* UHCI-specific */ 958#define URB_NO_FSBR 0x0020 /* UHCI-specific */
979#define URB_ZERO_PACKET 0x0040 /* Finish bulk OUT with short packet */ 959#define URB_ZERO_PACKET 0x0040 /* Finish bulk OUT with short packet */
980#define URB_NO_INTERRUPT 0x0080 /* HINT: no non-error interrupt 960#define URB_NO_INTERRUPT 0x0080 /* HINT: no non-error interrupt
981 * needed */ 961 * needed */
982#define URB_FREE_BUFFER 0x0100 /* Free transfer buffer with the URB */ 962#define URB_FREE_BUFFER 0x0100 /* Free transfer buffer with the URB */
983 963
964/* The following flags are used internally by usbcore and HCDs */
984#define URB_DIR_IN 0x0200 /* Transfer from device to host */ 965#define URB_DIR_IN 0x0200 /* Transfer from device to host */
985#define URB_DIR_OUT 0 966#define URB_DIR_OUT 0
986#define URB_DIR_MASK URB_DIR_IN 967#define URB_DIR_MASK URB_DIR_IN
987 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
988struct usb_iso_packet_descriptor { 977struct usb_iso_packet_descriptor {
989 unsigned int offset; 978 unsigned int offset;
990 unsigned int length; /* expected length */ 979 unsigned int length; /* expected length */
@@ -1061,17 +1050,14 @@ typedef void (*usb_complete_t)(struct urb *);
1061 * @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
1062 * of setup data. Control transfers always start by sending this data 1051 * of setup data. Control transfers always start by sending this data
1063 * 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.
1064 * @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
1065 * device driver has provided this DMA address for the setup packet. 1054 * this field; setup_packet must point to a valid buffer.
1066 * The host controller driver should use this in preference to
1067 * setup_packet, but the HCD may chose to ignore the address if it must
1068 * copy the setup packet into internal structures. Therefore, setup_packet
1069 * must always point to a valid buffer.
1070 * @start_frame: Returns the initial frame for isochronous transfers. 1055 * @start_frame: Returns the initial frame for isochronous transfers.
1071 * @number_of_packets: Lists the number of ISO transfer buffers. 1056 * @number_of_packets: Lists the number of ISO transfer buffers.
1072 * @interval: Specifies the polling interval for interrupt or isochronous 1057 * @interval: Specifies the polling interval for interrupt or isochronous
1073 * transfers. The units are frames (milliseconds) for full and low 1058 * transfers. The units are frames (milliseconds) for full and low
1074 * speed devices, and microframes (1/8 millisecond) for highspeed ones. 1059 * speed devices, and microframes (1/8 millisecond) for highspeed
1060 * and SuperSpeed devices.
1075 * @error_count: Returns the number of ISO transfers that reported errors. 1061 * @error_count: Returns the number of ISO transfers that reported errors.
1076 * @context: For use in completion functions. This normally points to 1062 * @context: For use in completion functions. This normally points to
1077 * request-specific driver context. 1063 * request-specific driver context.
@@ -1097,13 +1083,14 @@ typedef void (*usb_complete_t)(struct urb *);
1097 * bounce buffer or talking to an IOMMU), 1083 * bounce buffer or talking to an IOMMU),
1098 * although they're cheap on commodity x86 and ppc hardware. 1084 * although they're cheap on commodity x86 and ppc hardware.
1099 * 1085 *
1100 * 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,
1101 * 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
1102 * 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
1103 * allocate a DMA buffer with usb_buffer_alloc() or call usb_buffer_map(). 1090 * allocate a DMA buffer with usb_alloc_coherent() or call usb_buffer_map().
1104 * When these transfer flags are provided, host controller drivers will 1091 * When this transfer flag is provided, host controller drivers will
1105 * 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
1106 * setup_dma fields rather than determining a dma address themselves. 1093 * field rather than determining a dma address themselves.
1107 * 1094 *
1108 * Note that transfer_buffer must still be set if the controller 1095 * Note that transfer_buffer must still be set if the controller
1109 * 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
@@ -1126,11 +1113,9 @@ typedef void (*usb_complete_t)(struct urb *);
1126 * 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
1127 * extra zero length packet. 1114 * extra zero length packet.
1128 * 1115 *
1129 * Control URBs must provide a setup_packet. The setup_packet and 1116 * Control URBs must provide a valid pointer in the setup_packet field.
1130 * 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
1131 * the other. The transfer_flags bits URB_NO_TRANSFER_DMA_MAP and 1118 * beforehand.
1132 * URB_NO_SETUP_DMA_MAP indicate which buffers have already been mapped.
1133 * URB_NO_SETUP_DMA_MAP is ignored for non-control URBs.
1134 * 1119 *
1135 * Interrupt URBs must provide an interval, saying how often (in milliseconds 1120 * Interrupt URBs must provide an interval, saying how often (in milliseconds
1136 * or, for highspeed devices, 125 microsecond units) 1121 * or, for highspeed devices, 125 microsecond units)
@@ -1201,14 +1186,15 @@ struct urb {
1201 * current owner */ 1186 * current owner */
1202 struct list_head anchor_list; /* the URB may be anchored */ 1187 struct list_head anchor_list; /* the URB may be anchored */
1203 struct usb_anchor *anchor; 1188 struct usb_anchor *anchor;
1204 struct usb_device *dev; /* (in) pointer to associated device */ 1189 struct usb_device *dev; /* (in) pointer to associated device */
1205 struct usb_host_endpoint *ep; /* (internal) pointer to endpoint */ 1190 struct usb_host_endpoint *ep; /* (internal) pointer to endpoint */
1206 unsigned int pipe; /* (in) pipe information */ 1191 unsigned int pipe; /* (in) pipe information */
1192 unsigned int stream_id; /* (in) stream ID */
1207 int status; /* (return) non-ISO status */ 1193 int status; /* (return) non-ISO status */
1208 unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/ 1194 unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/
1209 void *transfer_buffer; /* (in) associated data buffer */ 1195 void *transfer_buffer; /* (in) associated data buffer */
1210 dma_addr_t transfer_dma; /* (in) dma addr for transfer_buffer */ 1196 dma_addr_t transfer_dma; /* (in) dma addr for transfer_buffer */
1211 struct usb_sg_request *sg; /* (in) scatter gather buffer list */ 1197 struct scatterlist *sg; /* (in) scatter gather buffer list */
1212 int num_sgs; /* (in) number of entries in the sg list */ 1198 int num_sgs; /* (in) number of entries in the sg list */
1213 u32 transfer_buffer_length; /* (in) data buffer length */ 1199 u32 transfer_buffer_length; /* (in) data buffer length */
1214 u32 actual_length; /* (return) actual transfer length */ 1200 u32 actual_length; /* (return) actual transfer length */
@@ -1302,9 +1288,16 @@ static inline void usb_fill_bulk_urb(struct urb *urb,
1302 * 1288 *
1303 * Initializes a interrupt urb with the proper information needed to submit 1289 * Initializes a interrupt urb with the proper information needed to submit
1304 * it to a device. 1290 * it to a device.
1305 * Note that high speed interrupt endpoints use a logarithmic encoding of 1291 *
1306 * the endpoint interval, and express polling intervals in microframes 1292 * Note that High Speed and SuperSpeed interrupt endpoints use a logarithmic
1307 * (eight per millisecond) rather than in frames (one per millisecond). 1293 * encoding of the endpoint interval, and express polling intervals in
1294 * microframes (eight per millisecond) rather than in frames (one per
1295 * millisecond).
1296 *
1297 * Wireless USB also uses the logarithmic encoding, but specifies it in units of
1298 * 128us instead of 125us. For Wireless USB devices, the interval is passed
1299 * through to the host controller, rather than being translated into microframe
1300 * units.
1308 */ 1301 */
1309static inline void usb_fill_int_urb(struct urb *urb, 1302static inline void usb_fill_int_urb(struct urb *urb,
1310 struct usb_device *dev, 1303 struct usb_device *dev,
@@ -1321,7 +1314,7 @@ static inline void usb_fill_int_urb(struct urb *urb,
1321 urb->transfer_buffer_length = buffer_length; 1314 urb->transfer_buffer_length = buffer_length;
1322 urb->complete = complete_fn; 1315 urb->complete = complete_fn;
1323 urb->context = context; 1316 urb->context = context;
1324 if (dev->speed == USB_SPEED_HIGH) 1317 if (dev->speed == USB_SPEED_HIGH || dev->speed == USB_SPEED_SUPER)
1325 urb->interval = 1 << (interval - 1); 1318 urb->interval = 1 << (interval - 1);
1326 else 1319 else
1327 urb->interval = interval; 1320 urb->interval = interval;
@@ -1374,9 +1367,9 @@ static inline int usb_urb_dir_out(struct urb *urb)
1374 return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT; 1367 return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT;
1375} 1368}
1376 1369
1377void *usb_buffer_alloc(struct usb_device *dev, size_t size, 1370void *usb_alloc_coherent(struct usb_device *dev, size_t size,
1378 gfp_t mem_flags, dma_addr_t *dma); 1371 gfp_t mem_flags, dma_addr_t *dma);
1379void usb_buffer_free(struct usb_device *dev, size_t size, 1372void usb_free_coherent(struct usb_device *dev, size_t size,
1380 void *addr, dma_addr_t dma); 1373 void *addr, dma_addr_t dma);
1381 1374
1382#if 0 1375#if 0
@@ -1463,8 +1456,6 @@ struct usb_sg_request {
1463 1456
1464 struct usb_device *dev; 1457 struct usb_device *dev;
1465 int pipe; 1458 int pipe;
1466 struct scatterlist *sg;
1467 int nents;
1468 1459
1469 int entries; 1460 int entries;
1470 struct urb **urbs; 1461 struct urb **urbs;
@@ -1532,23 +1523,31 @@ static inline unsigned int __create_pipe(struct usb_device *dev,
1532} 1523}
1533 1524
1534/* Create various pipes... */ 1525/* Create various pipes... */
1535#define usb_sndctrlpipe(dev,endpoint) \ 1526#define usb_sndctrlpipe(dev, endpoint) \
1536 ((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint)) 1527 ((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint))
1537#define usb_rcvctrlpipe(dev,endpoint) \ 1528#define usb_rcvctrlpipe(dev, endpoint) \
1538 ((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) 1529 ((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN)
1539#define usb_sndisocpipe(dev,endpoint) \ 1530#define usb_sndisocpipe(dev, endpoint) \
1540 ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint)) 1531 ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint))
1541#define usb_rcvisocpipe(dev,endpoint) \ 1532#define usb_rcvisocpipe(dev, endpoint) \
1542 ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) 1533 ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN)
1543#define usb_sndbulkpipe(dev,endpoint) \ 1534#define usb_sndbulkpipe(dev, endpoint) \
1544 ((PIPE_BULK << 30) | __create_pipe(dev, endpoint)) 1535 ((PIPE_BULK << 30) | __create_pipe(dev, endpoint))
1545#define usb_rcvbulkpipe(dev,endpoint) \ 1536#define usb_rcvbulkpipe(dev, endpoint) \
1546 ((PIPE_BULK << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) 1537 ((PIPE_BULK << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN)
1547#define usb_sndintpipe(dev,endpoint) \ 1538#define usb_sndintpipe(dev, endpoint) \
1548 ((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint)) 1539 ((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint))
1549#define usb_rcvintpipe(dev,endpoint) \ 1540#define usb_rcvintpipe(dev, endpoint) \
1550 ((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) 1541 ((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN)
1551 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
1552/*-------------------------------------------------------------------------*/ 1551/*-------------------------------------------------------------------------*/
1553 1552
1554static inline __u16 1553static inline __u16
@@ -1582,14 +1581,18 @@ extern void usb_register_notify(struct notifier_block *nb);
1582extern void usb_unregister_notify(struct notifier_block *nb); 1581extern void usb_unregister_notify(struct notifier_block *nb);
1583 1582
1584#ifdef DEBUG 1583#ifdef DEBUG
1585#define dbg(format, arg...) printk(KERN_DEBUG "%s: " format "\n" , \ 1584#define dbg(format, arg...) \
1586 __FILE__ , ## arg) 1585 printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg)
1587#else 1586#else
1588#define dbg(format, arg...) do {} while (0) 1587#define dbg(format, arg...) \
1588do { \
1589 if (0) \
1590 printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \
1591} while (0)
1589#endif 1592#endif
1590 1593
1591#define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \ 1594#define err(format, arg...) \
1592 format "\n" , ## arg) 1595 printk(KERN_ERR KBUILD_MODNAME ": " format "\n", ##arg)
1593 1596
1594/* debugfs stuff */ 1597/* debugfs stuff */
1595extern struct dentry *usb_debug_root; 1598extern struct dentry *usb_debug_root;