diff options
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/dwc3/debugfs.c | 11 | ||||
-rw-r--r-- | drivers/usb/dwc3/dwc3-omap.c | 30 |
2 files changed, 33 insertions, 8 deletions
diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c index 9ac37fe1b6a..0cc5a015451 100644 --- a/drivers/usb/dwc3/debugfs.c +++ b/drivers/usb/dwc3/debugfs.c @@ -27,6 +27,7 @@ #include <linux/uaccess.h> #include <linux/usb/ch9.h> +#include <linux/usb/drd.h> #include "core.h" #include "gadget.h" @@ -412,7 +413,15 @@ static ssize_t dwc3_mode_write(struct file *file, if (mode) { spin_lock_irqsave(&dwc->lock, flags); - dwc3_set_mode(dwc, mode); + if (mode & DWC3_GCTL_PRTCAP_HOST) { + dwc3_omap_usbvbus_id_handler(dwc->dev->parent, + OMAP_DWC3_ID_GROUND); + mode = 0; + } else if (mode & DWC3_GCTL_PRTCAP_DEVICE) { + dwc3_omap_usbvbus_id_handler(dwc->dev->parent, + OMAP_DWC3_VBUS_VALID); + mode = 1; + } spin_unlock_irqrestore(&dwc->lock, flags); } return count; diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index 4ccdef7333c..96b4c46cbbd 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c @@ -32,6 +32,7 @@ #include <linux/regulator/consumer.h> #include <linux/usb/otg.h> +#include <linux/usb/drd.h> /* * All these registers belong to OMAP's Wrapper around the @@ -137,13 +138,6 @@ struct dwc3_omap { struct regulator *vbus_reg; }; -enum omap_dwc3_vbus_id_status { - OMAP_DWC3_ID_FLOAT, - OMAP_DWC3_ID_GROUND, - OMAP_DWC3_VBUS_OFF, - OMAP_DWC3_VBUS_VALID, -}; - static inline u32 dwc3_omap_readl(void __iomem *base, u32 offset) { return readl(base + offset); @@ -278,6 +272,28 @@ static void dwc3_omap_set_mailbox(struct dwc3_omap *omap, } } +int dwc3_omap_usbvbus_id_handler(struct device *dev, + enum omap_dwc3_vbus_id_status status) +{ + struct dwc3_omap *omap; + struct platform_device *pdev; + + if (!dev) + return -ENODEV; + + dev_dbg(omap->dev, "VBUS Connect\n"); + + pdev = to_platform_device(dev); + omap = platform_get_drvdata(pdev); + if (!omap) + return -ENODEV; + + dwc3_omap_set_mailbox(omap, status); + + return 0; +} +EXPORT_SYMBOL(dwc3_omap_usbvbus_id_handler); + static irqreturn_t dwc3_omap_interrupt(int irq, void *_omap) { struct dwc3_omap *omap = _omap; |