signal: Fix sending signals with siginfo
[cris-mirror.git] / include / linux / usb / otg.h
blob67929df86df5df44ffb3db4fd89ad0a317a6c3cd
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 #include <linux/phy/phy.h>
13 #include <linux/usb/phy.h>
15 struct usb_otg {
16 u8 default_a;
18 struct phy *phy;
19 /* old usb_phy interface */
20 struct usb_phy *usb_phy;
21 struct usb_bus *host;
22 struct usb_gadget *gadget;
24 enum usb_otg_state state;
26 /* bind/unbind the host controller */
27 int (*set_host)(struct usb_otg *otg, struct usb_bus *host);
29 /* bind/unbind the peripheral controller */
30 int (*set_peripheral)(struct usb_otg *otg,
31 struct usb_gadget *gadget);
33 /* effective for A-peripheral, ignored for B devices */
34 int (*set_vbus)(struct usb_otg *otg, bool enabled);
36 /* for B devices only: start session with A-Host */
37 int (*start_srp)(struct usb_otg *otg);
39 /* start or continue HNP role switch */
40 int (*start_hnp)(struct usb_otg *otg);
44 /**
45 * struct usb_otg_caps - describes the otg capabilities of the device
46 * @otg_rev: The OTG revision number the device is compliant with, it's
47 * in binary-coded decimal (i.e. 2.0 is 0200H).
48 * @hnp_support: Indicates if the device supports HNP.
49 * @srp_support: Indicates if the device supports SRP.
50 * @adp_support: Indicates if the device supports ADP.
52 struct usb_otg_caps {
53 u16 otg_rev;
54 bool hnp_support;
55 bool srp_support;
56 bool adp_support;
59 extern const char *usb_otg_state_string(enum usb_otg_state state);
61 /* Context: can sleep */
62 static inline int
63 otg_start_hnp(struct usb_otg *otg)
65 if (otg && otg->start_hnp)
66 return otg->start_hnp(otg);
68 return -ENOTSUPP;
71 /* Context: can sleep */
72 static inline int
73 otg_set_vbus(struct usb_otg *otg, bool enabled)
75 if (otg && otg->set_vbus)
76 return otg->set_vbus(otg, enabled);
78 return -ENOTSUPP;
81 /* for HCDs */
82 static inline int
83 otg_set_host(struct usb_otg *otg, struct usb_bus *host)
85 if (otg && otg->set_host)
86 return otg->set_host(otg, host);
88 return -ENOTSUPP;
91 /* for usb peripheral controller drivers */
93 /* Context: can sleep */
94 static inline int
95 otg_set_peripheral(struct usb_otg *otg, struct usb_gadget *periph)
97 if (otg && otg->set_peripheral)
98 return otg->set_peripheral(otg, periph);
100 return -ENOTSUPP;
103 static inline int
104 otg_start_srp(struct usb_otg *otg)
106 if (otg && otg->start_srp)
107 return otg->start_srp(otg);
109 return -ENOTSUPP;
112 /* for OTG controller drivers (and maybe other stuff) */
113 extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);
115 enum usb_dr_mode {
116 USB_DR_MODE_UNKNOWN,
117 USB_DR_MODE_HOST,
118 USB_DR_MODE_PERIPHERAL,
119 USB_DR_MODE_OTG,
123 * usb_get_dr_mode - Get dual role mode for given device
124 * @dev: Pointer to the given device
126 * The function gets phy interface string from property 'dr_mode',
127 * and returns the correspondig enum usb_dr_mode
129 extern enum usb_dr_mode usb_get_dr_mode(struct device *dev);
131 #endif /* __LINUX_USB_OTG_H */