[BUG]odroid-c2 does not hotplug usb-devices

Anand Moon linux.amoon at gmail.com
Sat Dec 19 14:53:37 EST 2020


Hi Martin,

On Sat, 19 Dec 2020 at 19:29, Martin Blumenstingl
<martin.blumenstingl at googlemail.com> wrote:
>
> Hi Otto,
>
> On Mon, Dec 14, 2020 at 8:34 PM Otto Meier <gf435 at gmx.net> wrote:
> >
> > Hi Martin,
> >
> > Am 13.12.20 um 19:46 schrieb Martin Blumenstingl:
> > > Hi Otto,
> > >
> > > On Mon, Dec 7, 2020 at 1:43 PM Otto Meier <gf435 at gmx.net> wrote:
> > > [...]
> > >>>> So with the latest u-boot and the kernel from https://github.com/chewitt/linux/tree/amlogic-5.10.y
> > >>>> commit 725fc8df7898102f9031ba2075f763884ffa3ee8 everything is working again.
> > >>>> USB does hotplugging as expected.
> > >>> So, this fixes USB under Linux ?? It's not clear
> > > if you have time it would be great if you could figure out which of
> > > the patches from Christian's tree fixes USB hotplugging for you.
> > > Or is it fixed in Linux 5.10-rcX even without any patches?
> > >
> > The new mainline kernel 5.10.0 from Linus, without any other patches
> > does detect USB hotpluging,
> > when using u-boot DMI: Hardkernel Co., Ltd. ODROID-C2/ODROID-C2, BIOS
> > 2021.01-rc3-00039-gec79f5ce22-dirty 12/08/2020
> > and the following u-boot patch:
> [...]
> > When i use the last unpatched emmc bootable u-boot 2020.04 the kernel
> > boots, but usb hotplugging
> > does not work.
> Thank you for testing this!
>
> > Hope this describes my findings. If i can help further, please give me a
> > note.
> to be honest: I am a bit lost here. I don't understand how the BOOT_*
> pins interfere with USB.
> I also don't have any Odroid-C2 board myself so I cannot do any
> experiments myself.
> Neil, please let me know if you have any idea here.
>
>
> Best regards,
> Martin
>

I was also looking into this issue so I made some changes in the
phy driver to resolve the issue. Plz share your thoughts on the changes below.

Best Regards
-Anand

amoon at ThinkPad-T440s:~/mainline/linux-aml-5.y-devel$ git diff
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
index 7c029f552a23..363dd2ac17e6 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
@@ -20,6 +20,7 @@ usb0_phy: phy at c0000000 {
                        #phy-cells = <0>;
                        reg = <0x0 0xc0000000 0x0 0x20>;
                        resets = <&reset RESET_USB_OTG>;
+                       reset-names = "phy-reset";
                        clocks = <&clkc CLKID_USB>, <&clkc CLKID_USB0>;
                        clock-names = "usb_general", "usb";
                        status = "disabled";
@@ -30,6 +31,7 @@ usb1_phy: phy at c0000020 {
                        #phy-cells = <0>;
                        reg = <0x0 0xc0000020 0x0 0x20>;
                        resets = <&reset RESET_USB_OTG>;
+                       reset-names = "phy-reset";
                        clocks = <&clkc CLKID_USB>, <&clkc CLKID_USB1>;
                        clock-names = "usb_general", "usb";
                        status = "disabled";
diff --git a/drivers/phy/amlogic/phy-meson8b-usb2.c
b/drivers/phy/amlogic/phy-meson8b-usb2.c
index 03c061dd5f0d..31523becc878 100644
--- a/drivers/phy/amlogic/phy-meson8b-usb2.c
+++ b/drivers/phy/amlogic/phy-meson8b-usb2.c
@@ -143,14 +143,6 @@ static int phy_meson8b_usb2_power_on(struct phy *phy)
        u32 reg;
        int ret;

-       if (!IS_ERR_OR_NULL(priv->reset)) {
-               ret = reset_control_reset(priv->reset);
-               if (ret) {
-                       dev_err(&phy->dev, "Failed to trigger USB reset\n");
-                       return ret;
-               }
-       }
-
        ret = clk_prepare_enable(priv->clk_usb_general);
        if (ret) {
                dev_err(&phy->dev, "Failed to enable USB general clock\n");
@@ -222,9 +214,23 @@ static int phy_meson8b_usb2_power_off(struct phy *phy)
        return 0;
 }

+static int phy_meson8b_usb2_reset(struct phy *phy)
+{
+       struct phy_meson8b_usb2_priv *priv = phy_get_drvdata(phy);
+
+       if (priv->reset) {
+               reset_control_assert(priv->reset);
+               udelay(10);
+               reset_control_deassert(priv->reset);
+       }
+
+       return 0;
+}
+
 static const struct phy_ops phy_meson8b_usb2_ops = {
        .power_on       = phy_meson8b_usb2_power_on,
        .power_off      = phy_meson8b_usb2_power_off,
+       .reset          = phy_meson8b_usb2_reset,
        .owner          = THIS_MODULE,
 };

@@ -271,6 +277,10 @@ static int phy_meson8b_usb2_probe(struct
platform_device *pdev)
                return -EINVAL;
        }

+       priv->reset = of_reset_control_get_shared(pdev->dev.of_node,
"phy-reset");
+       if (IS_ERR(priv->reset))
+               priv->reset = NULL;
+
        phy = devm_phy_create(&pdev->dev, NULL, &phy_meson8b_usb2_ops);
        if (IS_ERR(phy)) {
                dev_err(&pdev->dev, "failed to create PHY\n");

> _______________________________________________
> linux-amlogic mailing list
> linux-amlogic at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-amlogic



More information about the linux-amlogic mailing list