Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
Inaky Perez-Gonzalez | 672027a3 | 2007-02-22 16:37:53 -0800 | [diff] [blame] | 3 | * This file holds USB constants and structures that are needed for |
| 4 | * USB device APIs. These are used by the USB device model, which is |
| 5 | * defined in chapter 9 of the USB 2.0 specification and in the |
| 6 | * Wireless USB 1.0 (spread around). Linux has several APIs in C that |
| 7 | * need these: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * |
| 9 | * - the master/host side Linux-USB kernel driver API; |
| 10 | * - the "usbfs" user space API; and |
David Brownell | 5da0106 | 2005-05-31 10:21:11 -0700 | [diff] [blame] | 11 | * - the Linux "gadget" slave/device/peripheral side driver API. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | * |
| 13 | * USB 2.0 adds an additional "On The Go" (OTG) mode, which lets systems |
| 14 | * act either as a USB master/host or as a USB slave/device. That means |
David Brownell | 5da0106 | 2005-05-31 10:21:11 -0700 | [diff] [blame] | 15 | * the master and slave side APIs benefit from working well together. |
| 16 | * |
| 17 | * There's also "Wireless USB", using low power short range radios for |
| 18 | * peripheral interconnection but otherwise building on the USB framework. |
Inaky Perez-Gonzalez | 672027a3 | 2007-02-22 16:37:53 -0800 | [diff] [blame] | 19 | * |
| 20 | * Note all descriptors are declared '__attribute__((packed))' so that: |
| 21 | * |
| 22 | * [a] they never get padded, either internally (USB spec writers |
| 23 | * probably handled that) or externally; |
| 24 | * |
| 25 | * [b] so that accessing bigger-than-a-bytes fields will never |
| 26 | * generate bus errors on any platform, even when the location of |
| 27 | * its descriptor inside a bundle isn't "naturally aligned", and |
| 28 | * |
| 29 | * [c] for consistency, removing all doubt even when it appears to |
| 30 | * someone that the two other points are non-issues for that |
| 31 | * particular descriptor type. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #ifndef __LINUX_USB_CH9_H |
| 34 | #define __LINUX_USB_CH9_H |
| 35 | |
Heikki Krogerus | 63863b9 | 2015-09-21 11:14:32 +0300 | [diff] [blame] | 36 | #include <linux/device.h> |
David Howells | 5e1ddb4 | 2012-10-09 09:49:07 +0100 | [diff] [blame] | 37 | #include <uapi/linux/usb/ch9.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
Michal Nazarewicz | e538dfd | 2011-08-30 17:11:19 +0200 | [diff] [blame] | 39 | /** |
Chunfeng Yun | 4d537f3 | 2019-03-21 10:27:56 +0800 | [diff] [blame] | 40 | * usb_ep_type_string() - Returns human readable-name of the endpoint type. |
| 41 | * @ep_type: The endpoint type to return human-readable name for. If it's not |
| 42 | * any of the types: USB_ENDPOINT_XFER_{CONTROL, ISOC, BULK, INT}, |
| 43 | * usually got by usb_endpoint_type(), the string 'unknown' will be returned. |
| 44 | */ |
| 45 | extern const char *usb_ep_type_string(int ep_type); |
| 46 | |
| 47 | /** |
Michal Nazarewicz | e538dfd | 2011-08-30 17:11:19 +0200 | [diff] [blame] | 48 | * usb_speed_string() - Returns human readable-name of the speed. |
| 49 | * @speed: The speed to return human-readable name for. If it's not |
| 50 | * any of the speeds defined in usb_device_speed enum, string for |
| 51 | * USB_SPEED_UNKNOWN will be returned. |
| 52 | */ |
| 53 | extern const char *usb_speed_string(enum usb_device_speed speed); |
| 54 | |
Heikki Krogerus | 63863b9 | 2015-09-21 11:14:32 +0300 | [diff] [blame] | 55 | /** |
| 56 | * usb_get_maximum_speed - Get maximum requested speed for a given USB |
| 57 | * controller. |
| 58 | * @dev: Pointer to the given USB controller device |
| 59 | * |
| 60 | * The function gets the maximum speed string from property "maximum-speed", |
| 61 | * and returns the corresponding enum usb_device_speed. |
| 62 | */ |
| 63 | extern enum usb_device_speed usb_get_maximum_speed(struct device *dev); |
Felipe Balbi | d1e3d75 | 2013-01-24 22:29:48 +0200 | [diff] [blame] | 64 | |
| 65 | /** |
| 66 | * usb_state_string - Returns human readable name for the state. |
| 67 | * @state: The state to return a human-readable name for. If it's not |
| 68 | * any of the states devices in usb_device_state_string enum, |
| 69 | * the string UNKNOWN will be returned. |
| 70 | */ |
| 71 | extern const char *usb_state_string(enum usb_device_state state); |
| 72 | |
Robert P. J. Day | dda43a0 | 2008-03-07 13:45:32 -0500 | [diff] [blame] | 73 | #endif /* __LINUX_USB_CH9_H */ |