[PATCH] bcm43xx: Fix array overrun in bcm43xx_geo_init
[linux-2.6/kmemtrace.git] / include / linux / usb_otg.h
blobf827f6e203c219249b39cd41929a44aae6aa77e9
1 // include/linux/usb_otg.h
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 */
10 /* OTG defines lots of enumeration states before device reset */
11 enum usb_otg_state {
12 OTG_STATE_UNDEFINED = 0,
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,
19 /* extra dual-role default-b states */
20 OTG_STATE_B_WAIT_ACON,
21 OTG_STATE_B_HOST,
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,
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").
40 struct otg_transceiver {
41 struct device *dev;
42 const char *label;
44 u8 default_a;
45 enum usb_otg_state state;
47 struct usb_bus *host;
48 struct usb_gadget *gadget;
50 /* to pass extra port status to the root hub */
51 u16 port_status;
52 u16 port_change;
54 /* bind/unbind the host controller */
55 int (*set_host)(struct otg_transceiver *otg,
56 struct usb_bus *host);
58 /* bind/unbind the peripheral controller */
59 int (*set_peripheral)(struct otg_transceiver *otg,
60 struct usb_gadget *gadget);
62 /* effective for B devices, ignored for A-peripheral */
63 int (*set_power)(struct otg_transceiver *otg,
64 unsigned mA);
66 /* for non-OTG B devices: set transceiver into suspend mode */
67 int (*set_suspend)(struct otg_transceiver *otg,
68 int suspend);
70 /* for B devices only: start session with A-Host */
71 int (*start_srp)(struct otg_transceiver *otg);
73 /* start or continue HNP role switch */
74 int (*start_hnp)(struct otg_transceiver *otg);
79 /* for board-specific init logic */
80 extern int otg_set_transceiver(struct otg_transceiver *);
83 /* for usb host and peripheral controller drivers */
84 extern struct otg_transceiver *otg_get_transceiver(void);
86 static inline int
87 otg_start_hnp(struct otg_transceiver *otg)
89 return otg->start_hnp(otg);
93 /* for HCDs */
94 static inline int
95 otg_set_host(struct otg_transceiver *otg, struct usb_bus *host)
97 return otg->set_host(otg, host);
101 /* for usb peripheral controller drivers */
102 static inline int
103 otg_set_peripheral(struct otg_transceiver *otg, struct usb_gadget *periph)
105 return otg->set_peripheral(otg, periph);
108 static inline int
109 otg_set_power(struct otg_transceiver *otg, unsigned mA)
111 return otg->set_power(otg, mA);
114 static inline int
115 otg_set_suspend(struct otg_transceiver *otg, int suspend)
117 if (otg->set_suspend != NULL)
118 return otg->set_suspend(otg, suspend);
119 else
120 return 0;
123 static inline int
124 otg_start_srp(struct otg_transceiver *otg)
126 return otg->start_srp(otg);
130 /* for OTG controller drivers (and maybe other stuff) */
131 extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);