1 // include/linux/usb_otg.h
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.
10 /* OTG defines lots of enumeration states before device reset */
12 OTG_STATE_UNDEFINED
= 0,
14 /* single-role peripheral, and dual-role default-b */
17 OTG_STATE_B_PERIPHERAL
,
19 /* extra dual-role default-b states */
20 OTG_STATE_B_WAIT_ACON
,
23 /* dual-role default-a */
25 OTG_STATE_A_WAIT_VRISE
,
26 OTG_STATE_A_WAIT_BCON
,
29 OTG_STATE_A_PERIPHERAL
,
30 OTG_STATE_A_WAIT_VFALL
,
35 * the otg driver needs to interact with both device side and host side
36 * usb controllers. it decides which controller is active at a given
37 * moment, using the transceiver, ID signal, HNP and sometimes static
38 * configuration information (including "board isn't wired for otg").
40 struct otg_transceiver
{
45 enum usb_otg_state state
;
48 struct usb_gadget
*gadget
;
50 /* to pass extra port status to the root hub */
54 /* bind/unbind the host controller */
55 int (*set_host
)(struct otg_transceiver
*otg
,
56 struct usb_bus
*host
);
58 /* bind/unbind the peripheral controller */
59 int (*set_peripheral
)(struct otg_transceiver
*otg
,
60 struct usb_gadget
*gadget
);
62 /* effective for B devices, ignored for A-peripheral */
63 int (*set_power
)(struct otg_transceiver
*otg
,
66 /* for B devices only: start session with A-Host */
67 int (*start_srp
)(struct otg_transceiver
*otg
);
69 /* start or continue HNP role switch */
70 int (*start_hnp
)(struct otg_transceiver
*otg
);
75 /* for board-specific init logic */
76 extern int otg_set_transceiver(struct otg_transceiver
*);
79 /* for usb host and peripheral controller drivers */
80 extern struct otg_transceiver
*otg_get_transceiver(void);
83 otg_start_hnp(struct otg_transceiver
*otg
)
85 return otg
->start_hnp(otg
);
91 otg_set_host(struct otg_transceiver
*otg
, struct usb_bus
*host
)
93 return otg
->set_host(otg
, host
);
97 /* for usb peripheral controller drivers */
99 otg_set_peripheral(struct otg_transceiver
*otg
, struct usb_gadget
*periph
)
101 return otg
->set_peripheral(otg
, periph
);
105 otg_set_power(struct otg_transceiver
*otg
, unsigned mA
)
107 return otg
->set_power(otg
, mA
);
111 otg_start_srp(struct otg_transceiver
*otg
)
113 return otg
->start_srp(otg
);
117 /* for OTG controller drivers (and maybe other stuff) */
118 extern int usb_bus_start_enum(struct usb_bus
*bus
, unsigned port_num
);