ACPI: simplify acpi_pci_irq_add_prt() API
[linux-2.6/linux-acpi-2.6.git] / include / linux / usb / otg.h
blob1aaa826396a1462555925b871f22f95ff8870299
1 /* USB OTG (On The Go) defines */
2 /*
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 */
9 #ifndef __LINUX_USB_OTG_H
10 #define __LINUX_USB_OTG_H
12 /* OTG defines lots of enumeration states before device reset */
13 enum usb_otg_state {
14 OTG_STATE_UNDEFINED = 0,
16 /* single-role peripheral, and dual-role default-b */
17 OTG_STATE_B_IDLE,
18 OTG_STATE_B_SRP_INIT,
19 OTG_STATE_B_PERIPHERAL,
21 /* extra dual-role default-b states */
22 OTG_STATE_B_WAIT_ACON,
23 OTG_STATE_B_HOST,
25 /* dual-role default-a */
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,
37 * the otg driver needs to interact with both device side and host side
38 * usb controllers. it decides which controller is active at a given
39 * moment, using the transceiver, ID signal, HNP and sometimes static
40 * configuration information (including "board isn't wired for otg").
42 struct otg_transceiver {
43 struct device *dev;
44 const char *label;
46 u8 default_a;
47 enum usb_otg_state state;
49 struct usb_bus *host;
50 struct usb_gadget *gadget;
52 /* to pass extra port status to the root hub */
53 u16 port_status;
54 u16 port_change;
56 /* bind/unbind the host controller */
57 int (*set_host)(struct otg_transceiver *otg,
58 struct usb_bus *host);
60 /* bind/unbind the peripheral controller */
61 int (*set_peripheral)(struct otg_transceiver *otg,
62 struct usb_gadget *gadget);
64 /* effective for B devices, ignored for A-peripheral */
65 int (*set_power)(struct otg_transceiver *otg,
66 unsigned mA);
68 /* for non-OTG B devices: set transceiver into suspend mode */
69 int (*set_suspend)(struct otg_transceiver *otg,
70 int suspend);
72 /* for B devices only: start session with A-Host */
73 int (*start_srp)(struct otg_transceiver *otg);
75 /* start or continue HNP role switch */
76 int (*start_hnp)(struct otg_transceiver *otg);
81 /* for board-specific init logic */
82 extern int otg_set_transceiver(struct otg_transceiver *);
83 #ifdef CONFIG_NOP_USB_XCEIV
84 extern void usb_nop_xceiv_register(void);
85 extern void usb_nop_xceiv_unregister(void);
86 #endif
89 /* for usb host and peripheral controller drivers */
90 extern struct otg_transceiver *otg_get_transceiver(void);
91 extern void otg_put_transceiver(struct otg_transceiver *);
93 /* Context: can sleep */
94 static inline int
95 otg_start_hnp(struct otg_transceiver *otg)
97 return otg->start_hnp(otg);
101 /* for HCDs */
102 static inline int
103 otg_set_host(struct otg_transceiver *otg, struct usb_bus *host)
105 return otg->set_host(otg, host);
109 /* for usb peripheral controller drivers */
111 /* Context: can sleep */
112 static inline int
113 otg_set_peripheral(struct otg_transceiver *otg, struct usb_gadget *periph)
115 return otg->set_peripheral(otg, periph);
118 static inline int
119 otg_set_power(struct otg_transceiver *otg, unsigned mA)
121 return otg->set_power(otg, mA);
124 /* Context: can sleep */
125 static inline int
126 otg_set_suspend(struct otg_transceiver *otg, int suspend)
128 if (otg->set_suspend != NULL)
129 return otg->set_suspend(otg, suspend);
130 else
131 return 0;
134 static inline int
135 otg_start_srp(struct otg_transceiver *otg)
137 return otg->start_srp(otg);
141 /* for OTG controller drivers (and maybe other stuff) */
142 extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);
144 #endif /* __LINUX_USB_OTG_H */