]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
tegra20: usb: rework set_host_mode
authorLucas Stach <dev@lynxeye.de>
Tue, 7 Aug 2012 08:19:15 +0000 (08:19 +0000)
committerTom Warren <twarren@nvidia.com>
Mon, 10 Sep 2012 20:01:21 +0000 (13:01 -0700)
This allows for two things:
- VBus GPIO may be used on other ports than the OTG one
- VBus GPIO may be low active if specified by DT

Signed-off-by: Lucas Stach <dev@lynxeye.de>
CC: Stephen Warren <swarren@wwwdotorg.org>
CC: Tom Warren <TWarren@nvidia.com>
Signed-off-by: Tom Warren <twarren@nvidia.com>
arch/arm/cpu/armv7/tegra20/usb.c

index 178bb130c28e7523762ffc66d2d8cfc0fac06c90..cac0918ff315882531cac2ccacfc5d9f6379a115 100644 (file)
@@ -137,24 +137,29 @@ static const u8 utmip_elastic_limit = 16;
 /* UTMIP High Speed Sync Start Delay */
 static const u8 utmip_hs_sync_start_delay = 9;
 
-/* Put the port into host mode (this only works for OTG ports) */
+/* Put the port into host mode */
 static void set_host_mode(struct fdt_usb *config)
 {
-       if (config->dr_mode == DR_MODE_OTG) {
-               /* Check whether remote host from USB1 is driving VBus */
-               if (readl(&config->reg->phy_vbus_sensors) & VBUS_VLD_STS)
-                       return;
-
-               /*
-                * If not driving, we set the GPIO to enable VBUS. We assume
-                * that the pinmux is set up correctly for this.
-                */
-               if (fdt_gpio_isvalid(&config->vbus_gpio)) {
-                       fdtdec_setup_gpio(&config->vbus_gpio);
-                       gpio_direction_output(config->vbus_gpio.gpio, 1);
-                       debug("set_host_mode: GPIO %d high\n",
-                             config->vbus_gpio.gpio);
-               }
+       /*
+        * If we are an OTG port, check if remote host is driving VBus and
+        * bail out in this case.
+        */
+       if (config->dr_mode == DR_MODE_OTG &&
+               (readl(&config->reg->phy_vbus_sensors) & VBUS_VLD_STS))
+               return;
+
+       /*
+        * If not driving, we set the GPIO to enable VBUS. We assume
+        * that the pinmux is set up correctly for this.
+        */
+       if (fdt_gpio_isvalid(&config->vbus_gpio)) {
+               fdtdec_setup_gpio(&config->vbus_gpio);
+               gpio_direction_output(config->vbus_gpio.gpio,
+                       (config->vbus_gpio.flags & FDT_GPIO_ACTIVE_LOW) ?
+                                0 : 1);
+               debug("set_host_mode: GPIO %d %s\n", config->vbus_gpio.gpio,
+                       (config->vbus_gpio.flags & FDT_GPIO_ACTIVE_LOW) ?
+                               "low" : "high");
        }
 }