From: Benoit Goby Date: Tue, 3 Aug 2010 03:22:58 +0000 (-0700) Subject: usb: host: Fix tegra EHCI suspend in OTG mode X-Git-Tag: firefly_0821_release~9833^2~295 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=73254f0cceafec8b1aae03a9025db565239d1c05;p=firefly-linux-kernel-4.4.55.git usb: host: Fix tegra EHCI suspend in OTG mode Change-Id: Ia46830dfbb8bc39de1280b00ce30efe6022f6bd3 Signed-off-by: Benoit Goby --- diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index 6c3618291d20..d9ea852ccc89 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c @@ -215,6 +215,7 @@ static void tegra_ehci_irq_work(struct work_struct *irq_work) tegra_ehci_restart(hcd); } else if (tegra->transceiver->state == OTG_STATE_A_SUSPEND && tegra->host_reinited) { + clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); tegra_ehci_power_down(hcd); tegra->host_reinited = 0; } @@ -455,6 +456,8 @@ static int tegra_ehci_probe(struct platform_device *pdev) tegra->transceiver = otg_get_transceiver(); #endif + tegra->host_reinited = 1; + err = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED); if (err != 0) { dev_err(&pdev->dev, "Failed to add USB HCD\n"); @@ -495,8 +498,6 @@ static int tegra_ehci_probe(struct platform_device *pdev) /* Check if we detect any device connected */ if (temp & TEGRA_USB_ID_PIN_STATUS) tegra_ehci_power_down(hcd); - else - tegra_ehci_power_up(hcd); } return err; @@ -522,11 +523,20 @@ static int tegra_ehci_resume(struct platform_device *pdev) struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev); struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci); + if (tegra->transceiver) { + if (tegra->transceiver->state == OTG_STATE_A_HOST) + set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); + else + return 0; + } + if (!tegra->host_resumed) { tegra_ehci_power_up(hcd); tegra_ehci_restart(hcd); } + tegra->host_reinited = 1; + return 0; } @@ -536,17 +546,15 @@ static int tegra_ehci_suspend(struct platform_device *pdev, pm_message_t state) struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci); if (tegra->transceiver) { - if (tegra->transceiver->state != OTG_STATE_A_HOST) { - /* we are not in host mode, return */ - return 0; - } else { - tegra->host_reinited = 0; - ehci_halt(tegra->ehci); + if (tegra->transceiver->state == OTG_STATE_A_HOST) /* indicate hcd flags, that hardware is not accessable now */ clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); - } + else + return 0; } + tegra->host_reinited = 0; + if (tegra->host_resumed) tegra_ehci_power_down(hcd);