2008-01-31 06:21:33 +07:00
|
|
|
/* USB OTG (On The Go) defines */
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
2008-03-08 01:45:32 +07:00
|
|
|
*
|
2005-04-17 05:20:36 +07:00
|
|
|
* These APIs may be used between USB controllers. USB device drivers
|
|
|
|
* (for either host or peripheral roles) don't use these calls; they
|
|
|
|
* continue to use just usb_device and usb_gadget.
|
|
|
|
*/
|
|
|
|
|
2008-03-08 01:45:32 +07:00
|
|
|
#ifndef __LINUX_USB_OTG_H
|
|
|
|
#define __LINUX_USB_OTG_H
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2014-10-31 00:41:15 +07:00
|
|
|
#include <linux/phy/phy.h>
|
2012-09-04 15:55:58 +07:00
|
|
|
#include <linux/usb/phy.h>
|
2009-12-17 18:01:36 +07:00
|
|
|
|
2012-02-13 18:24:04 +07:00
|
|
|
struct usb_otg {
|
|
|
|
u8 default_a;
|
|
|
|
|
2014-10-31 00:41:15 +07:00
|
|
|
struct phy *phy;
|
|
|
|
/* old usb_phy interface */
|
2014-10-31 00:41:14 +07:00
|
|
|
struct usb_phy *usb_phy;
|
2012-02-13 18:24:04 +07:00
|
|
|
struct usb_bus *host;
|
|
|
|
struct usb_gadget *gadget;
|
|
|
|
|
2014-10-31 00:41:13 +07:00
|
|
|
enum usb_otg_state state;
|
|
|
|
|
2012-02-13 18:24:04 +07:00
|
|
|
/* bind/unbind the host controller */
|
|
|
|
int (*set_host)(struct usb_otg *otg, struct usb_bus *host);
|
|
|
|
|
|
|
|
/* bind/unbind the peripheral controller */
|
|
|
|
int (*set_peripheral)(struct usb_otg *otg,
|
|
|
|
struct usb_gadget *gadget);
|
|
|
|
|
|
|
|
/* effective for A-peripheral, ignored for B devices */
|
|
|
|
int (*set_vbus)(struct usb_otg *otg, bool enabled);
|
|
|
|
|
|
|
|
/* for B devices only: start session with A-Host */
|
|
|
|
int (*start_srp)(struct usb_otg *otg);
|
|
|
|
|
|
|
|
/* start or continue HNP role switch */
|
|
|
|
int (*start_hnp)(struct usb_otg *otg);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2015-07-09 14:18:40 +07:00
|
|
|
/**
|
|
|
|
* struct usb_otg_caps - describes the otg capabilities of the device
|
|
|
|
* @otg_rev: The OTG revision number the device is compliant with, it's
|
|
|
|
* in binary-coded decimal (i.e. 2.0 is 0200H).
|
|
|
|
* @hnp_support: Indicates if the device supports HNP.
|
|
|
|
* @srp_support: Indicates if the device supports SRP.
|
|
|
|
* @adp_support: Indicates if the device supports ADP.
|
|
|
|
*/
|
|
|
|
struct usb_otg_caps {
|
|
|
|
u16 otg_rev;
|
|
|
|
bool hnp_support;
|
|
|
|
bool srp_support;
|
|
|
|
bool adp_support;
|
|
|
|
};
|
|
|
|
|
2013-03-07 15:39:57 +07:00
|
|
|
extern const char *usb_otg_state_string(enum usb_otg_state state);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-01-25 14:54:31 +07:00
|
|
|
/* Context: can sleep */
|
2005-04-17 05:20:36 +07:00
|
|
|
static inline int
|
2012-02-13 18:24:20 +07:00
|
|
|
otg_start_hnp(struct usb_otg *otg)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2012-02-13 18:24:20 +07:00
|
|
|
if (otg && otg->start_hnp)
|
|
|
|
return otg->start_hnp(otg);
|
2012-02-13 18:24:04 +07:00
|
|
|
|
2012-02-13 18:24:19 +07:00
|
|
|
return -ENOTSUPP;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2009-10-15 21:09:34 +07:00
|
|
|
/* Context: can sleep */
|
|
|
|
static inline int
|
2012-02-13 18:24:20 +07:00
|
|
|
otg_set_vbus(struct usb_otg *otg, bool enabled)
|
2009-10-15 21:09:34 +07:00
|
|
|
{
|
2012-02-13 18:24:20 +07:00
|
|
|
if (otg && otg->set_vbus)
|
|
|
|
return otg->set_vbus(otg, enabled);
|
2012-02-13 18:24:04 +07:00
|
|
|
|
2012-02-13 18:24:19 +07:00
|
|
|
return -ENOTSUPP;
|
2009-10-15 21:09:34 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* for HCDs */
|
|
|
|
static inline int
|
2012-02-13 18:24:20 +07:00
|
|
|
otg_set_host(struct usb_otg *otg, struct usb_bus *host)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2012-02-13 18:24:20 +07:00
|
|
|
if (otg && otg->set_host)
|
|
|
|
return otg->set_host(otg, host);
|
2012-02-13 18:24:04 +07:00
|
|
|
|
2012-02-13 18:24:19 +07:00
|
|
|
return -ENOTSUPP;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* for usb peripheral controller drivers */
|
2009-01-25 14:54:31 +07:00
|
|
|
|
|
|
|
/* Context: can sleep */
|
2005-04-17 05:20:36 +07:00
|
|
|
static inline int
|
2012-02-13 18:24:20 +07:00
|
|
|
otg_set_peripheral(struct usb_otg *otg, struct usb_gadget *periph)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2012-02-13 18:24:20 +07:00
|
|
|
if (otg && otg->set_peripheral)
|
|
|
|
return otg->set_peripheral(otg, periph);
|
2012-02-13 18:24:04 +07:00
|
|
|
|
2012-02-13 18:24:19 +07:00
|
|
|
return -ENOTSUPP;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
2012-02-13 18:24:20 +07:00
|
|
|
otg_start_srp(struct usb_otg *otg)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2012-02-13 18:24:20 +07:00
|
|
|
if (otg && otg->start_srp)
|
|
|
|
return otg->start_srp(otg);
|
2012-02-13 18:24:04 +07:00
|
|
|
|
2012-02-13 18:24:19 +07:00
|
|
|
return -ENOTSUPP;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* for OTG controller drivers (and maybe other stuff) */
|
|
|
|
extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);
|
2008-03-08 01:45:32 +07:00
|
|
|
|
2013-06-13 21:59:55 +07:00
|
|
|
enum usb_dr_mode {
|
|
|
|
USB_DR_MODE_UNKNOWN,
|
|
|
|
USB_DR_MODE_HOST,
|
|
|
|
USB_DR_MODE_PERIPHERAL,
|
|
|
|
USB_DR_MODE_OTG,
|
|
|
|
};
|
|
|
|
|
2008-03-08 01:45:32 +07:00
|
|
|
#endif /* __LINUX_USB_OTG_H */
|