1 /* USB OTG (On The Go) defines */
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.
9 #ifndef __LINUX_USB_OTG_H
10 #define __LINUX_USB_OTG_H
12 #include <linux/usb/phy.h>
19 struct usb_gadget *gadget;
21 /* bind/unbind the host controller */
22 int (*set_host)(struct usb_otg *otg, struct usb_bus *host);
24 /* bind/unbind the peripheral controller */
25 int (*set_peripheral)(struct usb_otg *otg,
26 struct usb_gadget *gadget);
28 /* effective for A-peripheral, ignored for B devices */
29 int (*set_vbus)(struct usb_otg *otg, bool enabled);
31 /* for B devices only: start session with A-Host */
32 int (*start_srp)(struct usb_otg *otg);
34 /* start or continue HNP role switch */
35 int (*start_hnp)(struct usb_otg *otg);
39 extern const char *usb_otg_state_string(enum usb_otg_state state);
41 /* Context: can sleep */
43 otg_start_hnp(struct usb_otg *otg)
45 if (otg && otg->start_hnp)
46 return otg->start_hnp(otg);
51 /* Context: can sleep */
53 otg_set_vbus(struct usb_otg *otg, bool enabled)
55 if (otg && otg->set_vbus)
56 return otg->set_vbus(otg, enabled);
63 otg_set_host(struct usb_otg *otg, struct usb_bus *host)
65 if (otg && otg->set_host)
66 return otg->set_host(otg, host);
71 /* for usb peripheral controller drivers */
73 /* Context: can sleep */
75 otg_set_peripheral(struct usb_otg *otg, struct usb_gadget *periph)
77 if (otg && otg->set_peripheral)
78 return otg->set_peripheral(otg, periph);
84 otg_start_srp(struct usb_otg *otg)
86 if (otg && otg->start_srp)
87 return otg->start_srp(otg);
92 /* for OTG controller drivers (and maybe other stuff) */
93 extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);
95 #endif /* __LINUX_USB_OTG_H */