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