aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb_otg.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/linux/usb_otg.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/linux/usb_otg.h')
-rw-r--r--include/linux/usb_otg.h118
1 files changed, 118 insertions, 0 deletions
diff --git a/include/linux/usb_otg.h b/include/linux/usb_otg.h
new file mode 100644
index 000000000000..c6683146e9b0
--- /dev/null
+++ b/include/linux/usb_otg.h
@@ -0,0 +1,118 @@
1// include/linux/usb_otg.h
2
3/*
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.
7 */
8
9
10/* OTG defines lots of enumeration states before device reset */
11enum usb_otg_state {
12 OTG_STATE_UNDEFINED = 0,
13
14 /* single-role peripheral, and dual-role default-b */
15 OTG_STATE_B_IDLE,
16 OTG_STATE_B_SRP_INIT,
17 OTG_STATE_B_PERIPHERAL,
18
19 /* extra dual-role default-b states */
20 OTG_STATE_B_WAIT_ACON,
21 OTG_STATE_B_HOST,
22
23 /* dual-role default-a */
24 OTG_STATE_A_IDLE,
25 OTG_STATE_A_WAIT_VRISE,
26 OTG_STATE_A_WAIT_BCON,
27 OTG_STATE_A_HOST,
28 OTG_STATE_A_SUSPEND,
29 OTG_STATE_A_PERIPHERAL,
30 OTG_STATE_A_WAIT_VFALL,
31 OTG_STATE_A_VBUS_ERR,
32};
33
34/*
35 * the otg driver needs to interact with both device side and host side
36 * usb controllers. it decides which controller is active at a given
37 * moment, using the transceiver, ID signal, HNP and sometimes static
38 * configuration information (including "board isn't wired for otg").
39 */
40struct otg_transceiver {
41 struct device *dev;
42 const char *label;
43
44 u8 default_a;
45 enum usb_otg_state state;
46
47 struct usb_bus *host;
48 struct usb_gadget *gadget;
49
50 /* to pass extra port status to the root hub */
51 u16 port_status;
52 u16 port_change;
53
54 /* bind/unbind the host controller */
55 int (*set_host)(struct otg_transceiver *otg,
56 struct usb_bus *host);
57
58 /* bind/unbind the peripheral controller */
59 int (*set_peripheral)(struct otg_transceiver *otg,
60 struct usb_gadget *gadget);
61
62 /* effective for B devices, ignored for A-peripheral */
63 int (*set_power)(struct otg_transceiver *otg,
64 unsigned mA);
65
66 /* for B devices only: start session with A-Host */
67 int (*start_srp)(struct otg_transceiver *otg);
68
69 /* start or continue HNP role switch */
70 int (*start_hnp)(struct otg_transceiver *otg);
71
72};
73
74
75/* for board-specific init logic */
76extern int otg_set_transceiver(struct otg_transceiver *);
77
78
79/* for usb host and peripheral controller drivers */
80extern struct otg_transceiver *otg_get_transceiver(void);
81
82static inline int
83otg_start_hnp(struct otg_transceiver *otg)
84{
85 return otg->start_hnp(otg);
86}
87
88
89/* for HCDs */
90static inline int
91otg_set_host(struct otg_transceiver *otg, struct usb_bus *host)
92{
93 return otg->set_host(otg, host);
94}
95
96
97/* for usb peripheral controller drivers */
98static inline int
99otg_set_peripheral(struct otg_transceiver *otg, struct usb_gadget *periph)
100{
101 return otg->set_peripheral(otg, periph);
102}
103
104static inline int
105otg_set_power(struct otg_transceiver *otg, unsigned mA)
106{
107 return otg->set_power(otg, mA);
108}
109
110static inline int
111otg_start_srp(struct otg_transceiver *otg)
112{
113 return otg->start_srp(otg);
114}
115
116
117/* for OTG controller drivers (and maybe other stuff) */
118extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);