diff options
Diffstat (limited to 'include/linux/usb.h')
| -rw-r--r-- | include/linux/usb.h | 210 |
1 files changed, 108 insertions, 102 deletions
diff --git a/include/linux/usb.h b/include/linux/usb.h index d7ace1b80f09..35fe6ab222bb 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h | |||
| @@ -45,27 +45,14 @@ struct wusb_dev; | |||
| 45 | 45 | ||
| 46 | struct ep_device; | 46 | struct 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 | */ | ||
| 55 | struct 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 | */ |
| 76 | struct usb_host_endpoint { | 63 | struct 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,13 +121,14 @@ 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 |
| 143 | * remove from the workqueue when running inside the worker | 128 | * remove from the workqueue when running inside the worker |
| 144 | * thread. See __usb_queue_reset_device(). | 129 | * thread. See __usb_queue_reset_device(). |
| 130 | * @resetting_device: USB core reset the device, so use alt setting 0 as | ||
| 131 | * current; needs bandwidth alloc after reset. | ||
| 145 | * | 132 | * |
| 146 | * USB device drivers attach to interfaces on a physical device. Each | 133 | * USB device drivers attach to interfaces on a physical device. Each |
| 147 | * interface encapsulates a single high level function, such as feeding | 134 | * interface encapsulates a single high level function, such as feeding |
| @@ -184,7 +171,6 @@ struct usb_interface { | |||
| 184 | int minor; /* minor number this interface is | 171 | int minor; /* minor number this interface is |
| 185 | * bound to */ | 172 | * bound to */ |
| 186 | enum usb_interface_condition condition; /* state of binding */ | 173 | 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 */ | 174 | unsigned sysfs_files_created:1; /* the sysfs attributes exist */ |
| 189 | unsigned ep_devs_created:1; /* endpoint "devices" exist */ | 175 | unsigned ep_devs_created:1; /* endpoint "devices" exist */ |
| 190 | unsigned unregistering:1; /* unregistration is in progress */ | 176 | unsigned unregistering:1; /* unregistration is in progress */ |
| @@ -200,8 +186,6 @@ struct usb_interface { | |||
| 200 | struct work_struct reset_ws; /* for resets in atomic context */ | 186 | struct work_struct reset_ws; /* for resets in atomic context */ |
| 201 | }; | 187 | }; |
| 202 | #define to_usb_interface(d) container_of(d, struct usb_interface, dev) | 188 | #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 | 189 | ||
| 206 | static inline void *usb_get_intfdata(struct usb_interface *intf) | 190 | static inline void *usb_get_intfdata(struct usb_interface *intf) |
| 207 | { | 191 | { |
| @@ -218,7 +202,7 @@ void usb_put_intf(struct usb_interface *intf); | |||
| 218 | 202 | ||
| 219 | /* this maximum is arbitrary */ | 203 | /* this maximum is arbitrary */ |
| 220 | #define USB_MAXINTERFACES 32 | 204 | #define USB_MAXINTERFACES 32 |
| 221 | #define USB_MAXIADS USB_MAXINTERFACES/2 | 205 | #define USB_MAXIADS (USB_MAXINTERFACES/2) |
| 222 | 206 | ||
| 223 | /** | 207 | /** |
| 224 | * struct usb_interface_cache - long-term representation of a device interface | 208 | * struct usb_interface_cache - long-term representation of a device interface |
| @@ -339,6 +323,7 @@ struct usb_bus { | |||
| 339 | 323 | ||
| 340 | struct usb_devmap devmap; /* device address allocation map */ | 324 | struct usb_devmap devmap; /* device address allocation map */ |
| 341 | struct usb_device *root_hub; /* Root hub */ | 325 | struct usb_device *root_hub; /* Root hub */ |
| 326 | struct usb_bus *hs_companion; /* Companion EHCI bus, if any */ | ||
| 342 | struct list_head bus_list; /* list of busses */ | 327 | struct list_head bus_list; /* list of busses */ |
| 343 | 328 | ||
| 344 | int bandwidth_allocated; /* on this bus: how much of the time | 329 | int bandwidth_allocated; /* on this bus: how much of the time |
| @@ -400,7 +385,6 @@ struct usb_tt; | |||
| 400 | * @portnum: parent port number (origin 1) | 385 | * @portnum: parent port number (origin 1) |
| 401 | * @level: number of USB hub ancestors | 386 | * @level: number of USB hub ancestors |
| 402 | * @can_submit: URBs may be submitted | 387 | * @can_submit: URBs may be submitted |
| 403 | * @discon_suspended: disconnected while suspended | ||
| 404 | * @persist_enabled: USB_PERSIST enabled for this device | 388 | * @persist_enabled: USB_PERSIST enabled for this device |
| 405 | * @have_langid: whether string_langid is valid | 389 | * @have_langid: whether string_langid is valid |
| 406 | * @authorized: policy has said we can use it; | 390 | * @authorized: policy has said we can use it; |
| @@ -420,20 +404,14 @@ struct usb_tt; | |||
| 420 | * @usbfs_dentry: usbfs dentry entry for the device | 404 | * @usbfs_dentry: usbfs dentry entry for the device |
| 421 | * @maxchild: number of ports if hub | 405 | * @maxchild: number of ports if hub |
| 422 | * @children: child devices - USB devices that are attached to this hub | 406 | * @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 | 407 | * @quirks: quirks of the whole device |
| 425 | * @urbnum: number of URBs submitted for the whole device | 408 | * @urbnum: number of URBs submitted for the whole device |
| 426 | * @active_duration: total time device is not suspended | 409 | * @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 | 410 | * @last_busy: time of last use |
| 431 | * @autosuspend_delay: in jiffies | 411 | * @autosuspend_delay: in jiffies |
| 432 | * @connect_time: time device was first connected | 412 | * @connect_time: time device was first connected |
| 433 | * @do_remote_wakeup: remote wakeup should be enabled | 413 | * @do_remote_wakeup: remote wakeup should be enabled |
| 434 | * @reset_resume: needs reset instead of resume | 414 | * @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 | 415 | * @wusb_dev: if this is a Wireless USB device, link to the WUSB |
| 438 | * specific data for the device. | 416 | * specific data for the device. |
| 439 | * @slot_id: Slot ID assigned by xHCI | 417 | * @slot_id: Slot ID assigned by xHCI |
| @@ -444,7 +422,7 @@ struct usb_tt; | |||
| 444 | */ | 422 | */ |
| 445 | struct usb_device { | 423 | struct usb_device { |
| 446 | int devnum; | 424 | int devnum; |
| 447 | char devpath [16]; | 425 | char devpath[16]; |
| 448 | u32 route; | 426 | u32 route; |
| 449 | enum usb_device_state state; | 427 | enum usb_device_state state; |
| 450 | enum usb_device_speed speed; | 428 | enum usb_device_speed speed; |
| @@ -474,11 +452,10 @@ struct usb_device { | |||
| 474 | u8 level; | 452 | u8 level; |
| 475 | 453 | ||
| 476 | unsigned can_submit:1; | 454 | unsigned can_submit:1; |
| 477 | unsigned discon_suspended:1; | ||
| 478 | unsigned persist_enabled:1; | 455 | unsigned persist_enabled:1; |
| 479 | unsigned have_langid:1; | 456 | unsigned have_langid:1; |
| 480 | unsigned authorized:1; | 457 | unsigned authorized:1; |
| 481 | unsigned authenticated:1; | 458 | unsigned authenticated:1; |
| 482 | unsigned wusb:1; | 459 | unsigned wusb:1; |
| 483 | int string_langid; | 460 | int string_langid; |
| 484 | 461 | ||
| @@ -498,38 +475,36 @@ struct usb_device { | |||
| 498 | int maxchild; | 475 | int maxchild; |
| 499 | struct usb_device *children[USB_MAXCHILDREN]; | 476 | struct usb_device *children[USB_MAXCHILDREN]; |
| 500 | 477 | ||
| 501 | int pm_usage_cnt; | ||
| 502 | u32 quirks; | 478 | u32 quirks; |
| 503 | atomic_t urbnum; | 479 | atomic_t urbnum; |
| 504 | 480 | ||
| 505 | unsigned long active_duration; | 481 | unsigned long active_duration; |
| 506 | 482 | ||
| 507 | #ifdef CONFIG_PM | 483 | #ifdef CONFIG_PM |
| 508 | struct delayed_work autosuspend; | ||
| 509 | struct work_struct autoresume; | ||
| 510 | struct mutex pm_mutex; | ||
| 511 | |||
| 512 | unsigned long last_busy; | 484 | unsigned long last_busy; |
| 513 | int autosuspend_delay; | 485 | int autosuspend_delay; |
| 514 | unsigned long connect_time; | 486 | unsigned long connect_time; |
| 515 | 487 | ||
| 516 | unsigned do_remote_wakeup:1; | 488 | unsigned do_remote_wakeup:1; |
| 517 | unsigned reset_resume:1; | 489 | unsigned reset_resume:1; |
| 518 | unsigned autosuspend_disabled:1; | ||
| 519 | unsigned skip_sys_resume:1; | ||
| 520 | #endif | 490 | #endif |
| 521 | struct wusb_dev *wusb_dev; | 491 | struct wusb_dev *wusb_dev; |
| 522 | int slot_id; | 492 | int slot_id; |
| 523 | }; | 493 | }; |
| 524 | #define to_usb_device(d) container_of(d, struct usb_device, dev) | 494 | #define to_usb_device(d) container_of(d, struct usb_device, dev) |
| 525 | 495 | ||
| 496 | static inline struct usb_device *interface_to_usbdev(struct usb_interface *intf) | ||
| 497 | { | ||
| 498 | return to_usb_device(intf->dev.parent); | ||
| 499 | } | ||
| 500 | |||
| 526 | extern struct usb_device *usb_get_dev(struct usb_device *dev); | 501 | extern struct usb_device *usb_get_dev(struct usb_device *dev); |
| 527 | extern void usb_put_dev(struct usb_device *dev); | 502 | extern void usb_put_dev(struct usb_device *dev); |
| 528 | 503 | ||
| 529 | /* USB device locking */ | 504 | /* USB device locking */ |
| 530 | #define usb_lock_device(udev) down(&(udev)->dev.sem) | 505 | #define usb_lock_device(udev) device_lock(&(udev)->dev) |
| 531 | #define usb_unlock_device(udev) up(&(udev)->dev.sem) | 506 | #define usb_unlock_device(udev) device_unlock(&(udev)->dev) |
| 532 | #define usb_trylock_device(udev) down_trylock(&(udev)->dev.sem) | 507 | #define usb_trylock_device(udev) device_trylock(&(udev)->dev) |
| 533 | extern int usb_lock_device_for_reset(struct usb_device *udev, | 508 | extern int usb_lock_device_for_reset(struct usb_device *udev, |
| 534 | const struct usb_interface *iface); | 509 | const struct usb_interface *iface); |
| 535 | 510 | ||
| @@ -537,25 +512,18 @@ extern int usb_lock_device_for_reset(struct usb_device *udev, | |||
| 537 | extern int usb_reset_device(struct usb_device *dev); | 512 | extern int usb_reset_device(struct usb_device *dev); |
| 538 | extern void usb_queue_reset_device(struct usb_interface *dev); | 513 | extern void usb_queue_reset_device(struct usb_interface *dev); |
| 539 | 514 | ||
| 540 | extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id); | ||
| 541 | 515 | ||
| 542 | /* USB autosuspend and autoresume */ | 516 | /* USB autosuspend and autoresume */ |
| 543 | #ifdef CONFIG_USB_SUSPEND | 517 | #ifdef CONFIG_USB_SUSPEND |
| 518 | extern void usb_enable_autosuspend(struct usb_device *udev); | ||
| 519 | extern void usb_disable_autosuspend(struct usb_device *udev); | ||
| 520 | |||
| 544 | extern int usb_autopm_get_interface(struct usb_interface *intf); | 521 | extern int usb_autopm_get_interface(struct usb_interface *intf); |
| 545 | extern void usb_autopm_put_interface(struct usb_interface *intf); | 522 | extern void usb_autopm_put_interface(struct usb_interface *intf); |
| 546 | extern int usb_autopm_get_interface_async(struct usb_interface *intf); | 523 | extern int usb_autopm_get_interface_async(struct usb_interface *intf); |
| 547 | extern void usb_autopm_put_interface_async(struct usb_interface *intf); | 524 | extern void usb_autopm_put_interface_async(struct usb_interface *intf); |
| 548 | 525 | extern void usb_autopm_get_interface_no_resume(struct usb_interface *intf); | |
| 549 | static inline void usb_autopm_get_interface_no_resume( | 526 | extern 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 | } | ||
| 554 | static inline void usb_autopm_put_interface_no_suspend( | ||
| 555 | struct usb_interface *intf) | ||
| 556 | { | ||
| 557 | atomic_dec(&intf->pm_usage_cnt); | ||
| 558 | } | ||
| 559 | 527 | ||
| 560 | static inline void usb_mark_last_busy(struct usb_device *udev) | 528 | static inline void usb_mark_last_busy(struct usb_device *udev) |
| 561 | { | 529 | { |
| @@ -564,6 +532,11 @@ static inline void usb_mark_last_busy(struct usb_device *udev) | |||
| 564 | 532 | ||
| 565 | #else | 533 | #else |
| 566 | 534 | ||
| 535 | static inline int usb_enable_autosuspend(struct usb_device *udev) | ||
| 536 | { return 0; } | ||
| 537 | static inline int usb_disable_autosuspend(struct usb_device *udev) | ||
| 538 | { return 0; } | ||
| 539 | |||
| 567 | static inline int usb_autopm_get_interface(struct usb_interface *intf) | 540 | static inline int usb_autopm_get_interface(struct usb_interface *intf) |
| 568 | { return 0; } | 541 | { return 0; } |
| 569 | static inline int usb_autopm_get_interface_async(struct usb_interface *intf) | 542 | static inline int usb_autopm_get_interface_async(struct usb_interface *intf) |
| @@ -588,6 +561,16 @@ static inline void usb_mark_last_busy(struct usb_device *udev) | |||
| 588 | /* for drivers using iso endpoints */ | 561 | /* for drivers using iso endpoints */ |
| 589 | extern int usb_get_current_frame_number(struct usb_device *usb_dev); | 562 | extern int usb_get_current_frame_number(struct usb_device *usb_dev); |
| 590 | 563 | ||
| 564 | /* Sets up a group of bulk endpoints to support multiple stream IDs. */ | ||
| 565 | extern int usb_alloc_streams(struct usb_interface *interface, | ||
| 566 | struct usb_host_endpoint **eps, unsigned int num_eps, | ||
| 567 | unsigned int num_streams, gfp_t mem_flags); | ||
| 568 | |||
| 569 | /* Reverts a group of bulk endpoints back to not using stream IDs. */ | ||
| 570 | extern void usb_free_streams(struct usb_interface *interface, | ||
| 571 | struct usb_host_endpoint **eps, unsigned int num_eps, | ||
| 572 | gfp_t mem_flags); | ||
| 573 | |||
| 591 | /* used these for multi-interface device registration */ | 574 | /* used these for multi-interface device registration */ |
| 592 | extern int usb_driver_claim_interface(struct usb_driver *driver, | 575 | extern int usb_driver_claim_interface(struct usb_driver *driver, |
| 593 | struct usb_interface *iface, void *priv); | 576 | struct usb_interface *iface, void *priv); |
| @@ -683,7 +666,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 | 666 | * This macro is used to create a struct usb_device_id that matches a |
| 684 | * specific device. | 667 | * specific device. |
| 685 | */ | 668 | */ |
| 686 | #define USB_DEVICE(vend,prod) \ | 669 | #define USB_DEVICE(vend, prod) \ |
| 687 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE, \ | 670 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE, \ |
| 688 | .idVendor = (vend), \ | 671 | .idVendor = (vend), \ |
| 689 | .idProduct = (prod) | 672 | .idProduct = (prod) |
| @@ -862,7 +845,7 @@ struct usb_driver { | |||
| 862 | 845 | ||
| 863 | void (*disconnect) (struct usb_interface *intf); | 846 | void (*disconnect) (struct usb_interface *intf); |
| 864 | 847 | ||
| 865 | int (*ioctl) (struct usb_interface *intf, unsigned int code, | 848 | int (*unlocked_ioctl) (struct usb_interface *intf, unsigned int code, |
| 866 | void *buf); | 849 | void *buf); |
| 867 | 850 | ||
| 868 | int (*suspend) (struct usb_interface *intf, pm_message_t message); | 851 | int (*suspend) (struct usb_interface *intf, pm_message_t message); |
| @@ -974,17 +957,25 @@ extern int usb_disabled(void); | |||
| 974 | #define URB_ISO_ASAP 0x0002 /* iso-only, urb->start_frame | 957 | #define URB_ISO_ASAP 0x0002 /* iso-only, urb->start_frame |
| 975 | * ignored */ | 958 | * ignored */ |
| 976 | #define URB_NO_TRANSFER_DMA_MAP 0x0004 /* urb->transfer_dma valid on submit */ | 959 | #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 */ | 960 | #define URB_NO_FSBR 0x0020 /* UHCI-specific */ |
| 979 | #define URB_ZERO_PACKET 0x0040 /* Finish bulk OUT with short packet */ | 961 | #define URB_ZERO_PACKET 0x0040 /* Finish bulk OUT with short packet */ |
| 980 | #define URB_NO_INTERRUPT 0x0080 /* HINT: no non-error interrupt | 962 | #define URB_NO_INTERRUPT 0x0080 /* HINT: no non-error interrupt |
| 981 | * needed */ | 963 | * needed */ |
| 982 | #define URB_FREE_BUFFER 0x0100 /* Free transfer buffer with the URB */ | 964 | #define URB_FREE_BUFFER 0x0100 /* Free transfer buffer with the URB */ |
| 983 | 965 | ||
| 966 | /* The following flags are used internally by usbcore and HCDs */ | ||
| 984 | #define URB_DIR_IN 0x0200 /* Transfer from device to host */ | 967 | #define URB_DIR_IN 0x0200 /* Transfer from device to host */ |
| 985 | #define URB_DIR_OUT 0 | 968 | #define URB_DIR_OUT 0 |
| 986 | #define URB_DIR_MASK URB_DIR_IN | 969 | #define URB_DIR_MASK URB_DIR_IN |
| 987 | 970 | ||
| 971 | #define URB_DMA_MAP_SINGLE 0x00010000 /* Non-scatter-gather mapping */ | ||
| 972 | #define URB_DMA_MAP_PAGE 0x00020000 /* HCD-unsupported S-G */ | ||
| 973 | #define URB_DMA_MAP_SG 0x00040000 /* HCD-supported S-G */ | ||
| 974 | #define URB_MAP_LOCAL 0x00080000 /* HCD-local-memory mapping */ | ||
| 975 | #define URB_SETUP_MAP_SINGLE 0x00100000 /* Setup packet DMA mapped */ | ||
| 976 | #define URB_SETUP_MAP_LOCAL 0x00200000 /* HCD-local setup packet */ | ||
| 977 | #define URB_DMA_SG_COMBINED 0x00400000 /* S-G entries were combined */ | ||
| 978 | |||
| 988 | struct usb_iso_packet_descriptor { | 979 | struct usb_iso_packet_descriptor { |
| 989 | unsigned int offset; | 980 | unsigned int offset; |
| 990 | unsigned int length; /* expected length */ | 981 | unsigned int length; /* expected length */ |
| @@ -1026,6 +1017,7 @@ typedef void (*usb_complete_t)(struct urb *); | |||
| 1026 | * is a different endpoint (and pipe) from "out" endpoint two. | 1017 | * is a different endpoint (and pipe) from "out" endpoint two. |
| 1027 | * The current configuration controls the existence, type, and | 1018 | * The current configuration controls the existence, type, and |
| 1028 | * maximum packet size of any given endpoint. | 1019 | * maximum packet size of any given endpoint. |
| 1020 | * @stream_id: the endpoint's stream ID for bulk streams | ||
| 1029 | * @dev: Identifies the USB device to perform the request. | 1021 | * @dev: Identifies the USB device to perform the request. |
| 1030 | * @status: This is read in non-iso completion functions to get the | 1022 | * @status: This is read in non-iso completion functions to get the |
| 1031 | * status of the particular request. ISO requests only use it | 1023 | * status of the particular request. ISO requests only use it |
| @@ -1061,17 +1053,14 @@ typedef void (*usb_complete_t)(struct urb *); | |||
| 1061 | * @setup_packet: Only used for control transfers, this points to eight bytes | 1053 | * @setup_packet: Only used for control transfers, this points to eight bytes |
| 1062 | * of setup data. Control transfers always start by sending this data | 1054 | * of setup data. Control transfers always start by sending this data |
| 1063 | * to the device. Then transfer_buffer is read or written, if needed. | 1055 | * 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 | 1056 | * @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. | 1057 | * 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. | 1058 | * @start_frame: Returns the initial frame for isochronous transfers. |
| 1071 | * @number_of_packets: Lists the number of ISO transfer buffers. | 1059 | * @number_of_packets: Lists the number of ISO transfer buffers. |
| 1072 | * @interval: Specifies the polling interval for interrupt or isochronous | 1060 | * @interval: Specifies the polling interval for interrupt or isochronous |
| 1073 | * transfers. The units are frames (milliseconds) for full and low | 1061 | * transfers. The units are frames (milliseconds) for full and low |
| 1074 | * speed devices, and microframes (1/8 millisecond) for highspeed ones. | 1062 | * speed devices, and microframes (1/8 millisecond) for highspeed |
| 1063 | * and SuperSpeed devices. | ||
| 1075 | * @error_count: Returns the number of ISO transfers that reported errors. | 1064 | * @error_count: Returns the number of ISO transfers that reported errors. |
| 1076 | * @context: For use in completion functions. This normally points to | 1065 | * @context: For use in completion functions. This normally points to |
| 1077 | * request-specific driver context. | 1066 | * request-specific driver context. |
| @@ -1097,13 +1086,14 @@ typedef void (*usb_complete_t)(struct urb *); | |||
| 1097 | * bounce buffer or talking to an IOMMU), | 1086 | * bounce buffer or talking to an IOMMU), |
| 1098 | * although they're cheap on commodity x86 and ppc hardware. | 1087 | * although they're cheap on commodity x86 and ppc hardware. |
| 1099 | * | 1088 | * |
| 1100 | * Alternatively, drivers may pass the URB_NO_xxx_DMA_MAP transfer flags, | 1089 | * 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 | 1090 | * which tells the host controller driver that no such mapping is needed for |
| 1091 | * the transfer_buffer since | ||
| 1102 | * the device driver is DMA-aware. For example, a device driver might | 1092 | * 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(). | 1093 | * allocate a DMA buffer with usb_alloc_coherent() or call usb_buffer_map(). |
| 1104 | * When these transfer flags are provided, host controller drivers will | 1094 | * When this transfer flag is provided, host controller drivers will |
| 1105 | * attempt to use the dma addresses found in the transfer_dma and/or | 1095 | * attempt to use the dma address found in the transfer_dma |
| 1106 | * setup_dma fields rather than determining a dma address themselves. | 1096 | * field rather than determining a dma address themselves. |
| 1107 | * | 1097 | * |
| 1108 | * Note that transfer_buffer must still be set if the controller | 1098 | * 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 | 1099 | * does not support DMA (as indicated by bus.uses_dma) and when talking |
| @@ -1126,11 +1116,9 @@ typedef void (*usb_complete_t)(struct urb *); | |||
| 1126 | * should always terminate with a short packet, even if it means adding an | 1116 | * should always terminate with a short packet, even if it means adding an |
| 1127 | * extra zero length packet. | 1117 | * extra zero length packet. |
| 1128 | * | 1118 | * |
| 1129 | * Control URBs must provide a setup_packet. The setup_packet and | 1119 | * 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 | 1120 | * 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 | 1121 | * 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 | * | 1122 | * |
| 1135 | * Interrupt URBs must provide an interval, saying how often (in milliseconds | 1123 | * Interrupt URBs must provide an interval, saying how often (in milliseconds |
| 1136 | * or, for highspeed devices, 125 microsecond units) | 1124 | * or, for highspeed devices, 125 microsecond units) |
| @@ -1201,14 +1189,15 @@ struct urb { | |||
| 1201 | * current owner */ | 1189 | * current owner */ |
| 1202 | struct list_head anchor_list; /* the URB may be anchored */ | 1190 | struct list_head anchor_list; /* the URB may be anchored */ |
| 1203 | struct usb_anchor *anchor; | 1191 | struct usb_anchor *anchor; |
| 1204 | struct usb_device *dev; /* (in) pointer to associated device */ | 1192 | struct usb_device *dev; /* (in) pointer to associated device */ |
| 1205 | struct usb_host_endpoint *ep; /* (internal) pointer to endpoint */ | 1193 | struct usb_host_endpoint *ep; /* (internal) pointer to endpoint */ |
| 1206 | unsigned int pipe; /* (in) pipe information */ | 1194 | unsigned int pipe; /* (in) pipe information */ |
| 1195 | unsigned int stream_id; /* (in) stream ID */ | ||
| 1207 | int status; /* (return) non-ISO status */ | 1196 | int status; /* (return) non-ISO status */ |
| 1208 | unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/ | 1197 | unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/ |
| 1209 | void *transfer_buffer; /* (in) associated data buffer */ | 1198 | void *transfer_buffer; /* (in) associated data buffer */ |
| 1210 | dma_addr_t transfer_dma; /* (in) dma addr for transfer_buffer */ | 1199 | dma_addr_t transfer_dma; /* (in) dma addr for transfer_buffer */ |
| 1211 | struct usb_sg_request *sg; /* (in) scatter gather buffer list */ | 1200 | struct scatterlist *sg; /* (in) scatter gather buffer list */ |
| 1212 | int num_sgs; /* (in) number of entries in the sg list */ | 1201 | int num_sgs; /* (in) number of entries in the sg list */ |
| 1213 | u32 transfer_buffer_length; /* (in) data buffer length */ | 1202 | u32 transfer_buffer_length; /* (in) data buffer length */ |
| 1214 | u32 actual_length; /* (return) actual transfer length */ | 1203 | u32 actual_length; /* (return) actual transfer length */ |
| @@ -1302,9 +1291,16 @@ static inline void usb_fill_bulk_urb(struct urb *urb, | |||
| 1302 | * | 1291 | * |
| 1303 | * Initializes a interrupt urb with the proper information needed to submit | 1292 | * Initializes a interrupt urb with the proper information needed to submit |
| 1304 | * it to a device. | 1293 | * it to a device. |
| 1305 | * Note that high speed interrupt endpoints use a logarithmic encoding of | 1294 | * |
| 1306 | * the endpoint interval, and express polling intervals in microframes | 1295 | * Note that High Speed and SuperSpeed interrupt endpoints use a logarithmic |
| 1307 | * (eight per millisecond) rather than in frames (one per millisecond). | 1296 | * encoding of the endpoint interval, and express polling intervals in |
| 1297 | * microframes (eight per millisecond) rather than in frames (one per | ||
| 1298 | * millisecond). | ||
| 1299 | * | ||
| 1300 | * Wireless USB also uses the logarithmic encoding, but specifies it in units of | ||
| 1301 | * 128us instead of 125us. For Wireless USB devices, the interval is passed | ||
| 1302 | * through to the host controller, rather than being translated into microframe | ||
| 1303 | * units. | ||
| 1308 | */ | 1304 | */ |
| 1309 | static inline void usb_fill_int_urb(struct urb *urb, | 1305 | static inline void usb_fill_int_urb(struct urb *urb, |
| 1310 | struct usb_device *dev, | 1306 | struct usb_device *dev, |
| @@ -1321,7 +1317,7 @@ static inline void usb_fill_int_urb(struct urb *urb, | |||
| 1321 | urb->transfer_buffer_length = buffer_length; | 1317 | urb->transfer_buffer_length = buffer_length; |
| 1322 | urb->complete = complete_fn; | 1318 | urb->complete = complete_fn; |
| 1323 | urb->context = context; | 1319 | urb->context = context; |
| 1324 | if (dev->speed == USB_SPEED_HIGH) | 1320 | if (dev->speed == USB_SPEED_HIGH || dev->speed == USB_SPEED_SUPER) |
| 1325 | urb->interval = 1 << (interval - 1); | 1321 | urb->interval = 1 << (interval - 1); |
| 1326 | else | 1322 | else |
| 1327 | urb->interval = interval; | 1323 | urb->interval = interval; |
| @@ -1374,9 +1370,9 @@ static inline int usb_urb_dir_out(struct urb *urb) | |||
| 1374 | return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT; | 1370 | return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT; |
| 1375 | } | 1371 | } |
| 1376 | 1372 | ||
| 1377 | void *usb_buffer_alloc(struct usb_device *dev, size_t size, | 1373 | void *usb_alloc_coherent(struct usb_device *dev, size_t size, |
| 1378 | gfp_t mem_flags, dma_addr_t *dma); | 1374 | gfp_t mem_flags, dma_addr_t *dma); |
| 1379 | void usb_buffer_free(struct usb_device *dev, size_t size, | 1375 | void usb_free_coherent(struct usb_device *dev, size_t size, |
| 1380 | void *addr, dma_addr_t dma); | 1376 | void *addr, dma_addr_t dma); |
| 1381 | 1377 | ||
| 1382 | #if 0 | 1378 | #if 0 |
| @@ -1463,8 +1459,6 @@ struct usb_sg_request { | |||
| 1463 | 1459 | ||
| 1464 | struct usb_device *dev; | 1460 | struct usb_device *dev; |
| 1465 | int pipe; | 1461 | int pipe; |
| 1466 | struct scatterlist *sg; | ||
| 1467 | int nents; | ||
| 1468 | 1462 | ||
| 1469 | int entries; | 1463 | int entries; |
| 1470 | struct urb **urbs; | 1464 | struct urb **urbs; |
| @@ -1532,23 +1526,31 @@ static inline unsigned int __create_pipe(struct usb_device *dev, | |||
| 1532 | } | 1526 | } |
| 1533 | 1527 | ||
| 1534 | /* Create various pipes... */ | 1528 | /* Create various pipes... */ |
| 1535 | #define usb_sndctrlpipe(dev,endpoint) \ | 1529 | #define usb_sndctrlpipe(dev, endpoint) \ |
| 1536 | ((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint)) | 1530 | ((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint)) |
| 1537 | #define usb_rcvctrlpipe(dev,endpoint) \ | 1531 | #define usb_rcvctrlpipe(dev, endpoint) \ |
| 1538 | ((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) | 1532 | ((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) |
| 1539 | #define usb_sndisocpipe(dev,endpoint) \ | 1533 | #define usb_sndisocpipe(dev, endpoint) \ |
| 1540 | ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint)) | 1534 | ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint)) |
| 1541 | #define usb_rcvisocpipe(dev,endpoint) \ | 1535 | #define usb_rcvisocpipe(dev, endpoint) \ |
| 1542 | ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) | 1536 | ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) |
| 1543 | #define usb_sndbulkpipe(dev,endpoint) \ | 1537 | #define usb_sndbulkpipe(dev, endpoint) \ |
| 1544 | ((PIPE_BULK << 30) | __create_pipe(dev, endpoint)) | 1538 | ((PIPE_BULK << 30) | __create_pipe(dev, endpoint)) |
| 1545 | #define usb_rcvbulkpipe(dev,endpoint) \ | 1539 | #define usb_rcvbulkpipe(dev, endpoint) \ |
| 1546 | ((PIPE_BULK << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) | 1540 | ((PIPE_BULK << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) |
| 1547 | #define usb_sndintpipe(dev,endpoint) \ | 1541 | #define usb_sndintpipe(dev, endpoint) \ |
| 1548 | ((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint)) | 1542 | ((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint)) |
| 1549 | #define usb_rcvintpipe(dev,endpoint) \ | 1543 | #define usb_rcvintpipe(dev, endpoint) \ |
| 1550 | ((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) | 1544 | ((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN) |
| 1551 | 1545 | ||
| 1546 | static inline struct usb_host_endpoint * | ||
| 1547 | usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe) | ||
| 1548 | { | ||
| 1549 | struct usb_host_endpoint **eps; | ||
| 1550 | eps = usb_pipein(pipe) ? dev->ep_in : dev->ep_out; | ||
| 1551 | return eps[usb_pipeendpoint(pipe)]; | ||
| 1552 | } | ||
| 1553 | |||
| 1552 | /*-------------------------------------------------------------------------*/ | 1554 | /*-------------------------------------------------------------------------*/ |
| 1553 | 1555 | ||
| 1554 | static inline __u16 | 1556 | static inline __u16 |
| @@ -1582,14 +1584,18 @@ extern void usb_register_notify(struct notifier_block *nb); | |||
| 1582 | extern void usb_unregister_notify(struct notifier_block *nb); | 1584 | extern void usb_unregister_notify(struct notifier_block *nb); |
| 1583 | 1585 | ||
| 1584 | #ifdef DEBUG | 1586 | #ifdef DEBUG |
| 1585 | #define dbg(format, arg...) printk(KERN_DEBUG "%s: " format "\n" , \ | 1587 | #define dbg(format, arg...) \ |
| 1586 | __FILE__ , ## arg) | 1588 | printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg) |
| 1587 | #else | 1589 | #else |
| 1588 | #define dbg(format, arg...) do {} while (0) | 1590 | #define dbg(format, arg...) \ |
| 1591 | do { \ | ||
| 1592 | if (0) \ | ||
| 1593 | printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \ | ||
| 1594 | } while (0) | ||
| 1589 | #endif | 1595 | #endif |
| 1590 | 1596 | ||
| 1591 | #define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \ | 1597 | #define err(format, arg...) \ |
| 1592 | format "\n" , ## arg) | 1598 | printk(KERN_ERR KBUILD_MODNAME ": " format "\n", ##arg) |
| 1593 | 1599 | ||
| 1594 | /* debugfs stuff */ | 1600 | /* debugfs stuff */ |
| 1595 | extern struct dentry *usb_debug_root; | 1601 | extern struct dentry *usb_debug_root; |
