This source file includes following definitions.
- otg_start_hnp
- otg_set_vbus
- otg_set_host
- otg_set_peripheral
- otg_start_srp
1
2
3
4
5
6
7
8
9
10 #ifndef __LINUX_USB_OTG_H
11 #define __LINUX_USB_OTG_H
12
13 #include <linux/phy/phy.h>
14 #include <linux/usb/phy.h>
15
16 struct usb_otg {
17 u8 default_a;
18
19 struct phy *phy;
20
21 struct usb_phy *usb_phy;
22 struct usb_bus *host;
23 struct usb_gadget *gadget;
24
25 enum usb_otg_state state;
26
27
28 int (*set_host)(struct usb_otg *otg, struct usb_bus *host);
29
30
31 int (*set_peripheral)(struct usb_otg *otg,
32 struct usb_gadget *gadget);
33
34
35 int (*set_vbus)(struct usb_otg *otg, bool enabled);
36
37
38 int (*start_srp)(struct usb_otg *otg);
39
40
41 int (*start_hnp)(struct usb_otg *otg);
42
43 };
44
45
46
47
48
49
50
51
52
53 struct usb_otg_caps {
54 u16 otg_rev;
55 bool hnp_support;
56 bool srp_support;
57 bool adp_support;
58 };
59
60 extern const char *usb_otg_state_string(enum usb_otg_state state);
61
62
63 static inline int
64 otg_start_hnp(struct usb_otg *otg)
65 {
66 if (otg && otg->start_hnp)
67 return otg->start_hnp(otg);
68
69 return -ENOTSUPP;
70 }
71
72
73 static inline int
74 otg_set_vbus(struct usb_otg *otg, bool enabled)
75 {
76 if (otg && otg->set_vbus)
77 return otg->set_vbus(otg, enabled);
78
79 return -ENOTSUPP;
80 }
81
82
83 static inline int
84 otg_set_host(struct usb_otg *otg, struct usb_bus *host)
85 {
86 if (otg && otg->set_host)
87 return otg->set_host(otg, host);
88
89 return -ENOTSUPP;
90 }
91
92
93
94
95 static inline int
96 otg_set_peripheral(struct usb_otg *otg, struct usb_gadget *periph)
97 {
98 if (otg && otg->set_peripheral)
99 return otg->set_peripheral(otg, periph);
100
101 return -ENOTSUPP;
102 }
103
104 static inline int
105 otg_start_srp(struct usb_otg *otg)
106 {
107 if (otg && otg->start_srp)
108 return otg->start_srp(otg);
109
110 return -ENOTSUPP;
111 }
112
113
114 extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);
115
116 enum usb_dr_mode {
117 USB_DR_MODE_UNKNOWN,
118 USB_DR_MODE_HOST,
119 USB_DR_MODE_PERIPHERAL,
120 USB_DR_MODE_OTG,
121 };
122
123
124
125
126
127
128
129
130 extern enum usb_dr_mode usb_get_dr_mode(struct device *dev);
131
132 #endif