1
2
3
4
5
6
7
8
9#ifndef __LINUX_USB_OTG_H
10#define __LINUX_USB_OTG_H
11
12#include <linux/usb/phy.h>
13
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
22 int (*set_host)(struct usb_otg *otg, struct usb_bus *host);
23
24
25 int (*set_peripheral)(struct usb_otg *otg,
26 struct usb_gadget *gadget);
27
28
29 int (*set_vbus)(struct usb_otg *otg, bool enabled);
30
31
32 int (*start_srp)(struct usb_otg *otg);
33
34
35 int (*start_hnp)(struct usb_otg *otg);
36
37};
38
39extern const char *usb_otg_state_string(enum usb_otg_state state);
40
41
42static inline int
43otg_start_hnp(struct usb_otg *otg)
44{
45 if (otg && otg->start_hnp)
46 return otg->start_hnp(otg);
47
48 return -ENOTSUPP;
49}
50
51
52static inline int
53otg_set_vbus(struct usb_otg *otg, bool enabled)
54{
55 if (otg && otg->set_vbus)
56 return otg->set_vbus(otg, enabled);
57
58 return -ENOTSUPP;
59}
60
61
62static inline int
63otg_set_host(struct usb_otg *otg, struct usb_bus *host)
64{
65 if (otg && otg->set_host)
66 return otg->set_host(otg, host);
67
68 return -ENOTSUPP;
69}
70
71
72
73
74static inline int
75otg_set_peripheral(struct usb_otg *otg, struct usb_gadget *periph)
76{
77 if (otg && otg->set_peripheral)
78 return otg->set_peripheral(otg, periph);
79
80 return -ENOTSUPP;
81}
82
83static inline int
84otg_start_srp(struct usb_otg *otg)
85{
86 if (otg && otg->start_srp)
87 return otg->start_srp(otg);
88
89 return -ENOTSUPP;
90}
91
92
93extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);
94
95#endif
96