Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa...
[deliverable/linux.git] / include / linux / usb / otg.h
CommitLineData
41dceed5 1/* USB OTG (On The Go) defines */
1da177e4 2/*
dda43a0e 3 *
1da177e4
LT
4 * These APIs may be used between USB controllers. USB device drivers
5 * (for either host or peripheral roles) don't use these calls; they
6 * continue to use just usb_device and usb_gadget.
7 */
8
dda43a0e
RD
9#ifndef __LINUX_USB_OTG_H
10#define __LINUX_USB_OTG_H
1da177e4 11
de4217d9 12#include <linux/usb/phy.h>
e9a20171 13
7a8a3a9b
HK
14struct usb_otg {
15 u8 default_a;
16
17 struct usb_phy *phy;
18 struct usb_bus *host;
19 struct usb_gadget *gadget;
20
21 /* bind/unbind the host controller */
22 int (*set_host)(struct usb_otg *otg, struct usb_bus *host);
23
24 /* bind/unbind the peripheral controller */
25 int (*set_peripheral)(struct usb_otg *otg,
26 struct usb_gadget *gadget);
27
28 /* effective for A-peripheral, ignored for B devices */
29 int (*set_vbus)(struct usb_otg *otg, bool enabled);
30
31 /* for B devices only: start session with A-Host */
32 int (*start_srp)(struct usb_otg *otg);
33
34 /* start or continue HNP role switch */
35 int (*start_hnp)(struct usb_otg *otg);
36
37};
38
42c0bf1c 39extern const char *usb_otg_state_string(enum usb_otg_state state);
1da177e4 40
c2344f13 41/* Context: can sleep */
1da177e4 42static inline int
6e13c650 43otg_start_hnp(struct usb_otg *otg)
1da177e4 44{
6e13c650
HK
45 if (otg && otg->start_hnp)
46 return otg->start_hnp(otg);
7a8a3a9b 47
136ced89 48 return -ENOTSUPP;
1da177e4
LT
49}
50
91c8a5a9
DM
51/* Context: can sleep */
52static inline int
6e13c650 53otg_set_vbus(struct usb_otg *otg, bool enabled)
91c8a5a9 54{
6e13c650
HK
55 if (otg && otg->set_vbus)
56 return otg->set_vbus(otg, enabled);
7a8a3a9b 57
136ced89 58 return -ENOTSUPP;
91c8a5a9 59}
1da177e4
LT
60
61/* for HCDs */
62static inline int
6e13c650 63otg_set_host(struct usb_otg *otg, struct usb_bus *host)
1da177e4 64{
6e13c650
HK
65 if (otg && otg->set_host)
66 return otg->set_host(otg, host);
7a8a3a9b 67
136ced89 68 return -ENOTSUPP;
1da177e4
LT
69}
70
1da177e4 71/* for usb peripheral controller drivers */
c2344f13
RJ
72
73/* Context: can sleep */
1da177e4 74static inline int
6e13c650 75otg_set_peripheral(struct usb_otg *otg, struct usb_gadget *periph)
1da177e4 76{
6e13c650
HK
77 if (otg && otg->set_peripheral)
78 return otg->set_peripheral(otg, periph);
7a8a3a9b 79
136ced89 80 return -ENOTSUPP;
1da177e4
LT
81}
82
1da177e4 83static inline int
6e13c650 84otg_start_srp(struct usb_otg *otg)
1da177e4 85{
6e13c650
HK
86 if (otg && otg->start_srp)
87 return otg->start_srp(otg);
7a8a3a9b 88
136ced89 89 return -ENOTSUPP;
1da177e4
LT
90}
91
1da177e4
LT
92/* for OTG controller drivers (and maybe other stuff) */
93extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);
dda43a0e 94
1c9af653
MG
95enum usb_dr_mode {
96 USB_DR_MODE_UNKNOWN,
97 USB_DR_MODE_HOST,
98 USB_DR_MODE_PERIPHERAL,
99 USB_DR_MODE_OTG,
100};
101
dda43a0e 102#endif /* __LINUX_USB_OTG_H */
This page took 1.455949 seconds and 5 git commands to generate.