PabloPL / linux

Linux kernel source tree
Other
17 stars 0 forks source link

DWC2 USB is broken #39

Closed xc-racer99 closed 4 years ago

xc-racer99 commented 4 years ago

It fails to probe with error dwc2 ec000000.hsotg: dwc2_core_reset: HANG! AHB Idle timeout GRSTCTL GRSTCTL_AHBIDLE

A bisect shows fe369e1826b3efae11012ad07d1713223c37ec5d to be the first bad commit

xc-racer99 commented 4 years ago

Appears it's that things aren't properly setup there... Because in dwc2_check_core_endianness() (even after d9707490077bee0c7060ef5665a90656e1078b66) we're reading 0 for GSNPSID while in reality (ie from debugfs when it's working) it should be GSNPSID = 0x4f54281a

So this may be a clock/phy issues as opposed to a dwc2 driver issue.

xc-racer99 commented 4 years ago

Alright, all we needed was an 80uS delay after resetting the phy, like 4x12 phy does. A patch is as follows:

From a891a77e48433f85942eb6d5ea68906b64e8223e Mon Sep 17 00:00:00 2001
From: Jonathan Bakker <xc-racer2@live.ca>
Date: Sat, 16 Nov 2019 11:10:56 -0800
Subject: [PATCH] phy: samsung: s5pv210-usb2: Add delay after reset

The USB phy takes some time to reset, so make sure we give it to it. The
delay length was taken from the 4x12 phy driver.

This manifested in issues with the DWC2 driver, where the endianness check
would read the DWC ID as 0, causing endianness errors.

Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
---
 drivers/phy/samsung/phy-s5pv210-usb2.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/phy/samsung/phy-s5pv210-usb2.c b/drivers/phy/samsung/phy-s5pv210-usb2.c
index 56a5083fe6f9..796bea1457a1 100644
--- a/drivers/phy/samsung/phy-s5pv210-usb2.c
+++ b/drivers/phy/samsung/phy-s5pv210-usb2.c
@@ -139,6 +139,9 @@ static void s5pv210_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on)
        udelay(10);
        rst &= ~rstbits;
        writel(rst, drv->reg_phy + S5PV210_UPHYRST);
+
+       /* Leave some time for everything to reset */
+       udelay(80);
    } else {
        pwr = readl(drv->reg_phy + S5PV210_UPHYPWR);
        pwr |= phypwr;
-- 
2.20.1

Leaving this issue open for now

PabloPL commented 4 years ago

I think this patch should also have "Fixes" tag since it was working fine and got broken after that change. Good work with finding and bisecting it.

xc-racer99 commented 4 years ago

I think this patch should also have "Fixes" tag since it was working fine and got broken after that change. Good work with finding and bisecting it.

Debatable, as the problem was there all along, it was just uncovered after that particular commit and was never an issue beforehand as the registers weren't ready immediately. But it doesn't really matter to me :)

xc-racer99 commented 4 years ago

Closing this issue as the patch has been accepted upstream.