summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhishek Aggarwal <aaggarwal@nvidia.com>2010-05-24 18:42:19 +0530
committerGary King <gking@nvidia.com>2010-05-27 07:40:09 -0700
commitae3a36307f58e03f9a1e1d3d4e790a96cd4e23ef (patch)
tree2a663a1985e1b138df54f87304c08bc7d5cde7cf
parent10f48922980ac0717b180e23416f6530f3152fbe (diff)
ldk usb: usb device detection at boot-time on USB1 (OTG)
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: I66c82fe33228734dddba325a203ed54347993b1d Bug: 682618 Reviewed-on: http://git-master/r/1541 Tested-by: Abhishek Aggarwal <aaggarwal@nvidia.com> Reviewed-by: Hanumanth Venkateswa Moganty <vmoganty@nvidia.com> Tested-by: Hanumanth Venkateswa Moganty <vmoganty@nvidia.com> Reviewed-by: Gary King <gking@nvidia.com>
-rw-r--r--[-rwxr-xr-x]arch/arm/mach-tegra/nvddk/nvddk_usbphy.c12
-rw-r--r--[-rwxr-xr-x]drivers/usb/host/ehci-tegra.c8
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 5d2dc57f3acf..01cfb0059b8f 100755..100644
--- a/arch/arm/mach-tegra/nvddk/nvddk_usbphy.c
+++ b/arch/arm/mach-tegra/nvddk/nvddk_usbphy.c
@@ -705,6 +705,8 @@ NvDdkUsbPhyPowerDown(
NvBool IsDpd)
{
NvError e = NvSuccess;
+ NvDdkUsbPhyIoctl_VBusStatusOutputArgs VBusStatus;
+ NvU32 TimeOut = USB_PHY_HW_TIMEOUT_US;
NV_ASSERT(hUsbPhy);
@@ -725,6 +727,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 c6f16b9a60b0..0aaf1439fda1 100755..100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -142,11 +142,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);
}
}
}
@@ -603,10 +603,10 @@ 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 {
dev_err(&pdev->dev, "Cannot get OTG transceiver\n");
e = -ENODEV;