No dwc0 on bananapi m1 with Linux 5.10 devicetree
Ian Lepore
ian at freebsd.org
Thu Apr 15 04:25:19 UTC 2021
On Mon, 2021-04-12 at 18:13 +0200, Emmanuel Vadot wrote:
> On Mon, 12 Apr 2021 08:14:21 -0600
> Ian Lepore <ian at freebsd.org> wrote:
>
> > On Mon, 2021-04-12 at 13:14 +0200, Emmanuel Vadot wrote:
> > > On Sun, 11 Apr 2021 17:06:02 -0600
> > > Ian Lepore <ian at freebsd.org> wrote:
> > >
> > > > On Sun, 2021-04-11 at 21:37 +0200, Emmanuel Vadot wrote:
> > > > > [...]
> > >
> > > 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 at 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:
> >
> > I think you should list all four RGMII values here; some day
> > another
> > board may come along that uses one of them.
>
> True.
>
> >
> > > 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
> > >
> >
> > -- Ian
> >
>
> Third time the charm :
>
> From 2c21718b1b5e8e312fbe4fb20d0f178935af1e53 Mon Sep 17 00:00:00
> 2001
> From: Emmanuel Vadot <manu at 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 | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/sys/dev/dwc/if_dwc.c b/sys/dev/dwc/if_dwc.c
> index 776d0d0dc39..429e250f48e 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,19 @@ 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:
> + case MII_CONTYPE_RGMII_RXID:
> + case MII_CONTYPE_RGMII_TXID:
> 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)
>
Looks good to me.
-- Ian
More information about the freebsd-arm
mailing list