diff options
author | Abhishek Aggarwal <aaggarwal@nvidia.com> | 2010-05-24 18:42:19 +0530 |
---|---|---|
committer | Gary King <gking@nvidia.com> | 2010-05-28 17:50:44 -0700 |
commit | 547de0b298e7113b4e5a8b63d56396b478163007 (patch) | |
tree | 25a1c26c01fa8750648bb95abb969de48a20bcb6 | |
parent | 1f8151757685553dd859d1e4c9d00d3f9c006d6c (diff) |
ehci-tegra: fix OTG state detection at boot-time on USB1
The USB device connected to USB1(OTG) port was not getting detected at
boot time. Reason being that on phy power down (host mode), there was
some delay in VBUS getting disabled. Because of this the OTG state was
getting set to "peripheral" instead of "host".
Fixed this by waiting for VBUS to be disabled in phy power down with a
max wait time of phy hardware time out (1 sec).
Change-Id: I78e561e28d942fa9931dfb88656281b02264859f
Reviewed-on: http://git-master/r/1837
Reviewed-by: Gary King <gking@nvidia.com>
Tested-by: Gary King <gking@nvidia.com>
-rw-r--r-- | arch/arm/mach-tegra/nvddk/nvddk_usbphy.c | 12 | ||||
-rw-r--r-- | drivers/usb/host/ehci-tegra.c | 8 |
2 files changed, 16 insertions, 4 deletions
diff --git a/arch/arm/mach-tegra/nvddk/nvddk_usbphy.c b/arch/arm/mach-tegra/nvddk/nvddk_usbphy.c index a3d53f4807cf..630f7623dba8 100644 --- a/arch/arm/mach-tegra/nvddk/nvddk_usbphy.c +++ b/arch/arm/mach-tegra/nvddk/nvddk_usbphy.c @@ -700,6 +700,8 @@ NvDdkUsbPhyPowerDown( NvBool IsDpd) { NvError e = NvSuccess; + NvDdkUsbPhyIoctl_VBusStatusOutputArgs VBusStatus; + NvU32 TimeOut = USB_PHY_HW_TIMEOUT_US; NV_ASSERT(hUsbPhy); @@ -720,6 +722,16 @@ NvDdkUsbPhyPowerDown( if (IsHostMode) { UsbPrivEnableVbus(hUsbPhy, NV_FALSE); + /* Wait till Vbus is turned off */ + do + { + NvOsWaitUS(1000); + TimeOut -= 1000; + e = hUsbPhy->Ioctl(hUsbPhy, + NvDdkUsbPhyIoctlType_VBusStatus, + NULL, + &VBusStatus); + } while (VBusStatus.VBusDetected && TimeOut); } // Power down the USB Phy NV_CHECK_ERROR_CLEANUP(hUsbPhy->PowerDown(hUsbPhy)); diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index 71b561e9a7d1..54360baf4be0 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c @@ -140,11 +140,11 @@ static int tegra_ehci_hub_control ( temp = ehci_readl(ehci, status_reg); if (!(temp & (PORT_CONNECT | PORT_CSC | PORT_PE | PORT_PEC)) && ehci->host_reinited) { + /* indicate hcd flags, that hardware is not accessable now */ + clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); tegra_ehci_power_down(hcd); ehci->transceiver->state = OTG_STATE_UNDEFINED; ehci->host_reinited = 0; - /* indicate hcd flags, that hardware is not accessable now */ - clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); } } } @@ -579,11 +579,11 @@ static int tegra_ehci_probe(struct platform_device *pdev) temp = readl(hcd->regs + TEGRA_USB_USBMODE_REG_OFFSET); writel((temp & ~TEGRA_USB_USBMODE_HOST), (hcd->regs + TEGRA_USB_USBMODE_REG_OFFSET)); - tegra_ehci_power_down(hcd); - ehci->host_reinited = 0; /* indicate hcd flags, that hardware is not accessable now * in host mode*/ clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); + tegra_ehci_power_down(hcd); + ehci->host_reinited = 0; } else #endif { |