]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/kernel-video.git/commitdiff
usb: dwc3: dra7xx: control drvvbus for usb1/2 using gpio6
authorRavi Babu <ravibabu@ti.com>
Mon, 3 Mar 2014 14:10:37 +0000 (19:40 +0530)
committerPraneeth Bajjuri <praneeth@ti.com>
Fri, 14 Mar 2014 21:35:28 +0000 (16:35 -0500)
-drive the drvvbus using gpio control
-by default the VBUS is set high

Change-Id: Icdd3a6ab0f45c93db16278cdb7aa53bc653e35d8
Signed-off-by: Shankar Rao <shankar.nrao@ti.com>
Signed-off-by: Ravi Babu <ravibabu@ti.com>
arch/arm/boot/dts/dra7-evm.dts
arch/arm/boot/dts/dra7.dtsi
drivers/usb/dwc3/core.c
drivers/usb/dwc3/core.h
drivers/usb/dwc3/otg.c

index 76c817df1ed39bae0dbaf39baff3f6e731380519..4bcf9877f25ec5490e60dd0bc6e43bb059ff503d 100644 (file)
 
        usb_pins: pinmux_usb_pins {
                 pinctrl-single,pins = <
-                       0x280   0xc0000 /* DRV1_VBUS SLEW | PULLDEN | MODE0 */
-                       0x284   0xc0000 /* DRV2_VBUS SLEW | PULLDEN | MODE0 */
+                       0x280   0xc000e /* DRV1_VBUS SLEW | PULLDEN | MODE14 */
+                       0x284   0xc000e /* DRV2_VBUS SLEW | PULLDEN | MODE14 */
                 >;
         };
 
index c9143716755e34bf050eac882bcd2be4e5bfcf5d..2a6503cce4eb901bb92d002002d8a665b126e88d 100644 (file)
                                 tx-fifo-resize;
                                 dr_mode = "peripheral";
                                maximum-speed = "superspeed";
+                               gpios = <&gpio6 12 0>;
                         };
                 };
 
                                 tx-fifo-resize;
                                 dr_mode = "host";
                                maximum-speed = "highspeed";
+                               gpios = <&gpio6 13 0>;
                         };
                 };
 
index ec7c5f767bbf5d6b1445d1c8123ac191f770b9bf..4086df9cee133c98f612f538f0e15987eef19191 100644 (file)
@@ -55,6 +55,9 @@
 #include <linux/usb/gadget.h>
 #include <linux/usb/of.h>
 #include <linux/usb/dwc3-omap.h>
+#include <linux/gpio.h>
+#include <linux/of_gpio.h>
+
 
 #include "core.h"
 #include "gadget.h"
@@ -519,16 +522,27 @@ static int dwc3_probe(struct platform_device *pdev)
                dev_warn(dev, "dwc3 mode set to otg default\n");
        }
 
+       if (mode != USB_DR_MODE_PERIPHERAL) {
+               dwc->gpio_count = of_gpio_count(node);
+               if (dwc->gpio_count < 1) {
+                       dev_err(dev, "No gpio to configure\n");
+                       goto err1;
+               }
+               dwc->gpio = of_get_gpio(node, 0);
+               if (gpio_is_valid(dwc->gpio)) {
+                       gpio_request(dwc->gpio, NULL);
+                       gpio_direction_output(dwc->gpio, 1);
+               }
+       }
+
        switch (mode) {
        case USB_DR_MODE_PERIPHERAL:
                /* dra7xx-dwc3 in peripheral mode does not detect
                 * vbus change event, hence set vbus and session
                 * to cause connect to host-machine
                 */
-               if (of_device_is_compatible(node, "synopsys,dra7xx-dwc3")) {
-                       dwc3_omap_usbvbus_id_handler(dwc->dev->parent,
+               dwc3_omap_usbvbus_id_handler(dwc->dev->parent,
                                OMAP_DWC3_VBUS_VALID);
-               }
 
                dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
                ret = dwc3_gadget_init(dwc);
@@ -538,6 +552,8 @@ static int dwc3_probe(struct platform_device *pdev)
                }
                break;
        case USB_DR_MODE_HOST:
+               dwc3_omap_usbvbus_id_handler(dwc->dev->parent,
+                       OMAP_DWC3_ID_GROUND);
                dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
                ret = dwc3_host_init(dwc);
                if (ret) {
index d63c7cc045d58be51522ac65cd068abe9b862c32..fee9192eb393f73fcb3c5378996a6586f0d4ccd8 100644 (file)
@@ -722,6 +722,8 @@ struct dwc3 {
        u32                     oevt;
        u8                      xhci_loaded;
        u8                      gadget_loaded;
+       u8                      gpio_count;
+       u32                     gpio;
 };
 
 /* -------------------------------------------------------------------------- */
index 3d58a3484db1e9cd7772314ac907e8128da3e234..de0031eec710f74eb2b149343d4540d59c5a76cf 100644 (file)
@@ -23,6 +23,8 @@
 #include "core.h"
 #include "io.h"
 #include "../host/xhci.h"
+#include <linux/gpio.h>
+#include <linux/of_gpio.h>
 
 #define DWC3_GSTS_OTG_IP       (1 << 10)
 #define DWC3_OSTS_CONID_STS    (1 << 0)
@@ -116,6 +118,9 @@ int dwc3_otg_role_switch(void *_dwc, int mode)
                dwc3_writel(dwc->regs, DWC3_OCTL, 0x20);
                dwc->drd_state = 0;
        }
+       /* drive vbus always ON */
+       gpio_request(dwc->gpio, NULL);
+       gpio_set_value(dwc->gpio, 1);
 
        return IRQ_HANDLED;
 }