1
2
3
4
5
6
7
8
9#ifndef __LINUX_USB_OTG_H
10#define __LINUX_USB_OTG_H
11
12
13enum usb_otg_state {
14 OTG_STATE_UNDEFINED = 0,
15
16
17 OTG_STATE_B_IDLE,
18 OTG_STATE_B_SRP_INIT,
19 OTG_STATE_B_PERIPHERAL,
20
21
22 OTG_STATE_B_WAIT_ACON,
23 OTG_STATE_B_HOST,
24
25
26 OTG_STATE_A_IDLE,
27 OTG_STATE_A_WAIT_VRISE,
28 OTG_STATE_A_WAIT_BCON,
29 OTG_STATE_A_HOST,
30 OTG_STATE_A_SUSPEND,
31 OTG_STATE_A_PERIPHERAL,
32 OTG_STATE_A_WAIT_VFALL,
33 OTG_STATE_A_VBUS_ERR,
34};
35
36
37
38
39
40
41
42struct otg_transceiver {
43 struct device *dev;
44 const char *label;
45
46 u8 default_a;
47 enum usb_otg_state state;
48
49 struct usb_bus *host;
50 struct usb_gadget *gadget;
51
52
53 u16 port_status;
54 u16 port_change;
55
56
57 int (*set_host)(struct otg_transceiver *otg,
58 struct usb_bus *host);
59
60
61 int (*set_peripheral)(struct otg_transceiver *otg,
62 struct usb_gadget *gadget);
63
64
65 int (*set_power)(struct otg_transceiver *otg,
66 unsigned mA);
67
68
69 int (*set_suspend)(struct otg_transceiver *otg,
70 int suspend);
71
72
73 int (*start_srp)(struct otg_transceiver *otg);
74
75
76 int (*start_hnp)(struct otg_transceiver *otg);
77
78};
79
80
81
82extern int otg_set_transceiver(struct otg_transceiver *);
83
84
85extern void usb_nop_xceiv_register(void);
86extern void usb_nop_xceiv_unregister(void);
87
88
89
90extern struct otg_transceiver *otg_get_transceiver(void);
91extern void otg_put_transceiver(struct otg_transceiver *);
92
93
94static inline int
95otg_start_hnp(struct otg_transceiver *otg)
96{
97 return otg->start_hnp(otg);
98}
99
100
101
102static inline int
103otg_set_host(struct otg_transceiver *otg, struct usb_bus *host)
104{
105 return otg->set_host(otg, host);
106}
107
108
109
110
111
112static inline int
113otg_set_peripheral(struct otg_transceiver *otg, struct usb_gadget *periph)
114{
115 return otg->set_peripheral(otg, periph);
116}
117
118static inline int
119otg_set_power(struct otg_transceiver *otg, unsigned mA)
120{
121 return otg->set_power(otg, mA);
122}
123
124
125static inline int
126otg_set_suspend(struct otg_transceiver *otg, int suspend)
127{
128 if (otg->set_suspend != NULL)
129 return otg->set_suspend(otg, suspend);
130 else
131 return 0;
132}
133
134static inline int
135otg_start_srp(struct otg_transceiver *otg)
136{
137 return otg->start_srp(otg);
138}
139
140
141
142extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);
143
144#endif
145