Commit | Line | Data |
---|---|---|
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 | |
48bcc180 | 12 | #include <linux/phy/phy.h> |
de4217d9 | 13 | #include <linux/usb/phy.h> |
e9a20171 | 14 | |
7a8a3a9b HK |
15 | struct usb_otg { |
16 | u8 default_a; | |
17 | ||
48bcc180 AT |
18 | struct phy *phy; |
19 | /* old usb_phy interface */ | |
19c1eac2 | 20 | struct usb_phy *usb_phy; |
7a8a3a9b HK |
21 | struct usb_bus *host; |
22 | struct usb_gadget *gadget; | |
23 | ||
e47d9254 AT |
24 | enum usb_otg_state state; |
25 | ||
7a8a3a9b HK |
26 | /* bind/unbind the host controller */ |
27 | int (*set_host)(struct usb_otg *otg, struct usb_bus *host); | |
28 | ||
29 | /* bind/unbind the peripheral controller */ | |
30 | int (*set_peripheral)(struct usb_otg *otg, | |
31 | struct usb_gadget *gadget); | |
32 | ||
33 | /* effective for A-peripheral, ignored for B devices */ | |
34 | int (*set_vbus)(struct usb_otg *otg, bool enabled); | |
35 | ||
36 | /* for B devices only: start session with A-Host */ | |
37 | int (*start_srp)(struct usb_otg *otg); | |
38 | ||
39 | /* start or continue HNP role switch */ | |
40 | int (*start_hnp)(struct usb_otg *otg); | |
41 | ||
42 | }; | |
43 | ||
42c0bf1c | 44 | extern const char *usb_otg_state_string(enum usb_otg_state state); |
1da177e4 | 45 | |
c2344f13 | 46 | /* Context: can sleep */ |
1da177e4 | 47 | static inline int |
6e13c650 | 48 | otg_start_hnp(struct usb_otg *otg) |
1da177e4 | 49 | { |
6e13c650 HK |
50 | if (otg && otg->start_hnp) |
51 | return otg->start_hnp(otg); | |
7a8a3a9b | 52 | |
136ced89 | 53 | return -ENOTSUPP; |
1da177e4 LT |
54 | } |
55 | ||
91c8a5a9 DM |
56 | /* Context: can sleep */ |
57 | static inline int | |
6e13c650 | 58 | otg_set_vbus(struct usb_otg *otg, bool enabled) |
91c8a5a9 | 59 | { |
6e13c650 HK |
60 | if (otg && otg->set_vbus) |
61 | return otg->set_vbus(otg, enabled); | |
7a8a3a9b | 62 | |
136ced89 | 63 | return -ENOTSUPP; |
91c8a5a9 | 64 | } |
1da177e4 LT |
65 | |
66 | /* for HCDs */ | |
67 | static inline int | |
6e13c650 | 68 | otg_set_host(struct usb_otg *otg, struct usb_bus *host) |
1da177e4 | 69 | { |
6e13c650 HK |
70 | if (otg && otg->set_host) |
71 | return otg->set_host(otg, host); | |
7a8a3a9b | 72 | |
136ced89 | 73 | return -ENOTSUPP; |
1da177e4 LT |
74 | } |
75 | ||
1da177e4 | 76 | /* for usb peripheral controller drivers */ |
c2344f13 RJ |
77 | |
78 | /* Context: can sleep */ | |
1da177e4 | 79 | static inline int |
6e13c650 | 80 | otg_set_peripheral(struct usb_otg *otg, struct usb_gadget *periph) |
1da177e4 | 81 | { |
6e13c650 HK |
82 | if (otg && otg->set_peripheral) |
83 | return otg->set_peripheral(otg, periph); | |
7a8a3a9b | 84 | |
136ced89 | 85 | return -ENOTSUPP; |
1da177e4 LT |
86 | } |
87 | ||
1da177e4 | 88 | static inline int |
6e13c650 | 89 | otg_start_srp(struct usb_otg *otg) |
1da177e4 | 90 | { |
6e13c650 HK |
91 | if (otg && otg->start_srp) |
92 | return otg->start_srp(otg); | |
7a8a3a9b | 93 | |
136ced89 | 94 | return -ENOTSUPP; |
1da177e4 LT |
95 | } |
96 | ||
1da177e4 LT |
97 | /* for OTG controller drivers (and maybe other stuff) */ |
98 | extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num); | |
dda43a0e | 99 | |
1c9af653 MG |
100 | enum usb_dr_mode { |
101 | USB_DR_MODE_UNKNOWN, | |
102 | USB_DR_MODE_HOST, | |
103 | USB_DR_MODE_PERIPHERAL, | |
104 | USB_DR_MODE_OTG, | |
105 | }; | |
106 | ||
dda43a0e | 107 | #endif /* __LINUX_USB_OTG_H */ |