Date: Mon, 12 Apr 2021 13:14:22 +0200 From: Emmanuel Vadot <manu@bidouilliste.com> To: Ian Lepore <ian@freebsd.org> Cc: "freebsd-arm@FreeBSD.org" <freebsd-arm@FreeBSD.org> Subject: Re: No dwc0 on bananapi m1 with Linux 5.10 devicetree Message-ID: <20210412131422.68ebcd1dd748c17f2d57efb1@bidouilliste.com> In-Reply-To: <b6a9fab3914a54d0a78cf5e80a7bd9dc07807b60.camel@freebsd.org> References: <1sKA_1f0z4MvqNKPTG1kiNCHauRdILGumygIn6w0H-XBzxg_cTV0c-01SCnrUcmzy96RCoE2zA4khWzwo6DQQymVphL7zpjOVx5c48lXAXU=@protonmail.com> <20210411213728.7a53a7a91c2aa3c930f5abc6@bidouilliste.com> <b6a9fab3914a54d0a78cf5e80a7bd9dc07807b60.camel@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 11 Apr 2021 17:06:02 -0600 Ian Lepore <ian@freebsd.org> wrote: > On Sun, 2021-04-11 at 21:37 +0200, Emmanuel Vadot wrote: > > On Sun, 11 Apr 2021 09:24:33 +0000 > > qroxana via freebsd-arm <freebsd-arm@freebsd.org> wrote: > > > > > It seems the dwc0 no longer works after > > > 6be3386466ab79a84b48429ae66244f21526d3df > > > > > > dwc0: <A20 Gigabit Ethernet Controller> mem 0x1c50000-0x1c5ffff irq > > > 72 on simplebus0 > > > dwc0: Can't reset DWC. > > > device_attach: dwc0 attach returned 6 > > > > > > I've tried to revert this change on my bananapi m1 and dwc0 worked > > > again. > > > > > > commit e7ffa3b5ce04742455c6bd4d8af0fdedd9978c77 > > > Author: Emmanuel Vadot <manu@FreeBSD.org> > > > Date: Sun Jan 17 19:02:46 2021 +0100 > > > > > > Import devicetree files from Linux 5.10 > > > > > > diff --git a/src/arm/sun7i-a20-bananapi.dts b/src/arm/sun7i-a20- > > > bananapi.dts > > > index bb3987e..0b3d9ae 100644 > > > --- a/src/arm/sun7i-a20-bananapi.dts > > > +++ b/src/arm/sun7i-a20-bananapi.dts > > > @@ -132,7 +132,7 @@ > > > pinctrl-names = "default"; > > > pinctrl-0 = <&gmac_rgmii_pins>; > > > phy-handle = <&phy1>; > > > - phy-mode = "rgmii"; > > > + phy-mode = "rgmii-id"; > > > phy-supply = <®_gmac_3v3>; > > > status = "okay"; > > > }; > > > > > > Hi, > > > > Sorry about that, > > Upstream did warned me about this change but I was sure that we did > > nothing with the phy-mode in dwc, should have check better. > > > > Please try this patch (I have no allwinner dwc based board here) : > > From 72c709db9ec3eb9a132ffe893b1e95e29bca62ac Mon Sep 17 00:00:00 > > 2001 > > From: Emmanuel Vadot <manu@FreeBSD.org> > > Date: Sun, 11 Apr 2021 21:34:57 +0200 > > Subject: [PATCH] dwc: Cope with recent dts changes > > > > Add rgmii-id to the list of mode where we need to configure it as > > rgmii. > > --- > > sys/dev/dwc/if_dwc.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/sys/dev/dwc/if_dwc.c b/sys/dev/dwc/if_dwc.c > > index 776d0d0dc39..0549874a977 100644 > > --- a/sys/dev/dwc/if_dwc.c > > +++ b/sys/dev/dwc/if_dwc.c > > @@ -1575,7 +1575,7 @@ dwc_attach(device_t dev) > > > > node = ofw_bus_get_node(dev); > > if (OF_getprop_alloc(node, "phy-mode", (void **)&phy_mode)) { > > - if (strcmp(phy_mode, "rgmii") == 0) > > + if (strcmp(phy_mode, "rgmii") == 0 || strcmp(phy_mode, > > "rgmii-id") == 0) sc->phy_mode = PHY_MODE_RGMII; > > if (strcmp(phy_mode, "rmii") == 0) > > sc->phy_mode = PHY_MODE_RMII; > > > > This should probably be: > > node = ofw_bus_get_node(dev); > if (mii_contype_is_rgmii(mii_fdt_get_contype(node))) > sc->phy_mode = PHY_MODE_RGMII; > > -- Ian Thanks, I didn't knew about those helpers. New patch inline, only build tested. >From e1f901a3dce3df965a3955ae1341ba809aa28394 Mon Sep 17 00:00:00 2001 From: Emmanuel Vadot <manu@FreeBSD.org> Date: Sun, 11 Apr 2021 21:34:57 +0200 Subject: [PATCH] dwc: Use mii_fdt function Use the helper function to get phy mode and configure dwc accordingly. --- sys/dev/dwc/if_dwc.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sys/dev/dwc/if_dwc.c b/sys/dev/dwc/if_dwc.c index 776d0d0dc39..563769f8406 100644 --- a/sys/dev/dwc/if_dwc.c +++ b/sys/dev/dwc/if_dwc.c @@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$"); #include <dev/mii/miivar.h> #include <dev/ofw/ofw_bus.h> #include <dev/ofw/ofw_bus_subr.h> +#include <dev/mii/mii_fdt.h> #ifdef EXT_RESOURCES #include <dev/extres/clk/clk.h> @@ -1559,7 +1560,6 @@ dwc_attach(device_t dev) struct ifnet *ifp; int error, i; uint32_t reg; - char *phy_mode; phandle_t node; uint32_t txpbl, rxpbl, pbl; bool nopblx8 = false; @@ -1574,12 +1574,17 @@ dwc_attach(device_t dev) sc->mactype = IF_DWC_MAC_TYPE(dev); node = ofw_bus_get_node(dev); - if (OF_getprop_alloc(node, "phy-mode", (void **)&phy_mode)) { - if (strcmp(phy_mode, "rgmii") == 0) + switch (mii_fdt_get_contype(node)) { + case MII_CONTYPE_RGMII: + case MII_CONTYPE_RGMII_ID: sc->phy_mode = PHY_MODE_RGMII; - if (strcmp(phy_mode, "rmii") == 0) + break; + case MII_CONTYPE_RMII: sc->phy_mode = PHY_MODE_RMII; - OF_prop_free(phy_mode); + break; + default: + device_printf(dev, "Unsupported MII type\n"); + return (ENXIO); } if (OF_getencprop(node, "snps,pbl", &pbl, sizeof(uint32_t)) <= 0) -- 2.31.1 -- Emmanuel Vadot <manu@bidouilliste.com> <manu@FreeBSD.org>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20210412131422.68ebcd1dd748c17f2d57efb1>