0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef __LINUX_USB_OTG_H
0011 #define __LINUX_USB_OTG_H
0012
0013 #include <linux/phy/phy.h>
0014 #include <linux/usb/phy.h>
0015
0016 struct usb_otg {
0017 u8 default_a;
0018
0019 struct phy *phy;
0020
0021 struct usb_phy *usb_phy;
0022 struct usb_bus *host;
0023 struct usb_gadget *gadget;
0024
0025 enum usb_otg_state state;
0026
0027
0028 int (*set_host)(struct usb_otg *otg, struct usb_bus *host);
0029
0030
0031 int (*set_peripheral)(struct usb_otg *otg,
0032 struct usb_gadget *gadget);
0033
0034
0035 int (*set_vbus)(struct usb_otg *otg, bool enabled);
0036
0037
0038 int (*start_srp)(struct usb_otg *otg);
0039
0040
0041 int (*start_hnp)(struct usb_otg *otg);
0042
0043 };
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053 struct usb_otg_caps {
0054 u16 otg_rev;
0055 bool hnp_support;
0056 bool srp_support;
0057 bool adp_support;
0058 };
0059
0060 extern const char *usb_otg_state_string(enum usb_otg_state state);
0061
0062
0063 static inline int
0064 otg_start_hnp(struct usb_otg *otg)
0065 {
0066 if (otg && otg->start_hnp)
0067 return otg->start_hnp(otg);
0068
0069 return -ENOTSUPP;
0070 }
0071
0072
0073 static inline int
0074 otg_set_vbus(struct usb_otg *otg, bool enabled)
0075 {
0076 if (otg && otg->set_vbus)
0077 return otg->set_vbus(otg, enabled);
0078
0079 return -ENOTSUPP;
0080 }
0081
0082
0083 static inline int
0084 otg_set_host(struct usb_otg *otg, struct usb_bus *host)
0085 {
0086 if (otg && otg->set_host)
0087 return otg->set_host(otg, host);
0088
0089 return -ENOTSUPP;
0090 }
0091
0092
0093
0094
0095 static inline int
0096 otg_set_peripheral(struct usb_otg *otg, struct usb_gadget *periph)
0097 {
0098 if (otg && otg->set_peripheral)
0099 return otg->set_peripheral(otg, periph);
0100
0101 return -ENOTSUPP;
0102 }
0103
0104 static inline int
0105 otg_start_srp(struct usb_otg *otg)
0106 {
0107 if (otg && otg->start_srp)
0108 return otg->start_srp(otg);
0109
0110 return -ENOTSUPP;
0111 }
0112
0113
0114 extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);
0115
0116 enum usb_dr_mode {
0117 USB_DR_MODE_UNKNOWN,
0118 USB_DR_MODE_HOST,
0119 USB_DR_MODE_PERIPHERAL,
0120 USB_DR_MODE_OTG,
0121 };
0122
0123
0124
0125
0126
0127
0128
0129
0130 extern enum usb_dr_mode usb_get_dr_mode(struct device *dev);
0131 extern enum usb_dr_mode usb_get_role_switch_default_mode(struct device *dev);
0132
0133 #endif