]>
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 LT |
11 | |
12 | /* OTG defines lots of enumeration states before device reset */ | |
13 | enum usb_otg_state { | |
14 | OTG_STATE_UNDEFINED = 0, | |
15 | ||
16 | /* single-role peripheral, and dual-role default-b */ | |
17 | OTG_STATE_B_IDLE, | |
18 | OTG_STATE_B_SRP_INIT, | |
19 | OTG_STATE_B_PERIPHERAL, | |
20 | ||
21 | /* extra dual-role default-b states */ | |
22 | OTG_STATE_B_WAIT_ACON, | |
23 | OTG_STATE_B_HOST, | |
24 | ||
25 | /* dual-role default-a */ | |
26 | OTG_STATE_A_IDLE, | |
27 | OTG_STATE_A_WAIT_VRISE, | |
28 | OTG_STATE_A_WAIT_BCON, | |
29 | OTG_STATE_A_HOST, | |
30 | OTG_STATE_A_SUSPEND, | |
31 | OTG_STATE_A_PERIPHERAL, | |
32 | OTG_STATE_A_WAIT_VFALL, | |
33 | OTG_STATE_A_VBUS_ERR, | |
34 | }; | |
35 | ||
36 | /* | |
37 | * the otg driver needs to interact with both device side and host side | |
38 | * usb controllers. it decides which controller is active at a given | |
39 | * moment, using the transceiver, ID signal, HNP and sometimes static | |
40 | * configuration information (including "board isn't wired for otg"). | |
41 | */ | |
42 | struct otg_transceiver { | |
43 | struct device *dev; | |
44 | const char *label; | |
45 | ||
46 | u8 default_a; | |
47 | enum usb_otg_state state; | |
48 | ||
49 | struct usb_bus *host; | |
50 | struct usb_gadget *gadget; | |
51 | ||
52 | /* to pass extra port status to the root hub */ | |
53 | u16 port_status; | |
54 | u16 port_change; | |
55 | ||
56 | /* bind/unbind the host controller */ | |
3a16f7b4 | 57 | int (*set_host)(struct otg_transceiver *otg, |
1da177e4 LT |
58 | struct usb_bus *host); |
59 | ||
60 | /* bind/unbind the peripheral controller */ | |
61 | int (*set_peripheral)(struct otg_transceiver *otg, | |
62 | struct usb_gadget *gadget); | |
63 | ||
64 | /* effective for B devices, ignored for A-peripheral */ | |
65 | int (*set_power)(struct otg_transceiver *otg, | |
66 | unsigned mA); | |
67 | ||
4e67185a JY |
68 | /* for non-OTG B devices: set transceiver into suspend mode */ |
69 | int (*set_suspend)(struct otg_transceiver *otg, | |
70 | int suspend); | |
71 | ||
1da177e4 LT |
72 | /* for B devices only: start session with A-Host */ |
73 | int (*start_srp)(struct otg_transceiver *otg); | |
74 | ||
75 | /* start or continue HNP role switch */ | |
76 | int (*start_hnp)(struct otg_transceiver *otg); | |
77 | ||
78 | }; | |
79 | ||
80 | ||
81 | /* for board-specific init logic */ | |
82 | extern int otg_set_transceiver(struct otg_transceiver *); | |
83 | ||
84 | ||
85 | /* for usb host and peripheral controller drivers */ | |
86 | extern struct otg_transceiver *otg_get_transceiver(void); | |
68144e0c | 87 | extern void otg_put_transceiver(struct otg_transceiver *); |
1da177e4 | 88 | |
c2344f13 | 89 | /* Context: can sleep */ |
1da177e4 LT |
90 | static inline int |
91 | otg_start_hnp(struct otg_transceiver *otg) | |
92 | { | |
93 | return otg->start_hnp(otg); | |
94 | } | |
95 | ||
96 | ||
97 | /* for HCDs */ | |
98 | static inline int | |
99 | otg_set_host(struct otg_transceiver *otg, struct usb_bus *host) | |
100 | { | |
101 | return otg->set_host(otg, host); | |
102 | } | |
103 | ||
104 | ||
105 | /* for usb peripheral controller drivers */ | |
c2344f13 RJ |
106 | |
107 | /* Context: can sleep */ | |
1da177e4 LT |
108 | static inline int |
109 | otg_set_peripheral(struct otg_transceiver *otg, struct usb_gadget *periph) | |
110 | { | |
111 | return otg->set_peripheral(otg, periph); | |
112 | } | |
113 | ||
114 | static inline int | |
115 | otg_set_power(struct otg_transceiver *otg, unsigned mA) | |
116 | { | |
117 | return otg->set_power(otg, mA); | |
118 | } | |
119 | ||
c2344f13 | 120 | /* Context: can sleep */ |
4e67185a JY |
121 | static inline int |
122 | otg_set_suspend(struct otg_transceiver *otg, int suspend) | |
123 | { | |
124 | if (otg->set_suspend != NULL) | |
125 | return otg->set_suspend(otg, suspend); | |
126 | else | |
127 | return 0; | |
128 | } | |
129 | ||
1da177e4 LT |
130 | static inline int |
131 | otg_start_srp(struct otg_transceiver *otg) | |
132 | { | |
133 | return otg->start_srp(otg); | |
134 | } | |
135 | ||
136 | ||
137 | /* for OTG controller drivers (and maybe other stuff) */ | |
138 | extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num); | |
dda43a0e RD |
139 | |
140 | #endif /* __LINUX_USB_OTG_H */ |