From owner-freebsd-arm@freebsd.org Thu Apr 15 04:25:19 2021 Return-Path: Delivered-To: freebsd-arm@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 38FD65DEAA0 for ; Thu, 15 Apr 2021 04:25:19 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound4s.ore.mailhop.org (outbound4s.ore.mailhop.org [54.185.97.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4FLR8Z4m9Nz4rKf for ; Thu, 15 Apr 2021 04:25:18 +0000 (UTC) (envelope-from ian@freebsd.org) ARC-Seal: i=1; a=rsa-sha256; t=1618460717; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=qrM+E4ZUpNDmHdYeZHyVogidiYrpv2HrPSO8pAY446deabv6N0cphtFV26N51ipcqgYq0au2WzR0G dlaoRJrggN8nHwqZHbLROMN0N7HlOY6jWTkE6xVkehYW1fSkVLJdD4LXLgcziBqEqx3oHKQSN5VaTk Ida0aVKgh9umjBdIaI/Mn3Myq/5+cRj8JMBvwdxjaemEt3jo5TjFicIy8QU/3BohWmMRlSgDNbfSNw DbiNK7aFiWKwnLU0Ns32hkKwu8kgwT3b/g7Mvx6Bp+L5Fpp1WrFJcukW+XpkjugIz8zdTesXJlK/Ie KKTJs+XRIrbfegLQMXLfZEiUgXRC9NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:cc:to:from:subject:message-id:dkim-signature:from; bh=7ZIY+uI1AbLQoIYfIadHnvEBxludlz42EnD+8jlVduE=; b=MKGxZWVwpEecZ+wyb9WnaSgZlpVCTZ07rB1cBXtaRzKF//Qpc2ozUn0R0PK67RZjCVlueKX/iJZO+ TPn8CegR+j9rlHSaEb+EJ9jHQ1hz5w4N2W/JNKKEHueJj2Y6XJJlVnHo/oOEHkpcNLAv3bl+olHyCU ohGmJ3GZ7AGiWhE95cYkB91ApVF9F4eFnYJr6k3fjLOHOGOCYwQZvwm2oAtcRAP3AA8R+fvYgk3N1o VVfmJz67KMXeLjJ2LzkVQErXxxMfbFYeEADZKXrFemDyUG/F/JMraAuqB8Fokb+NJA7jGuOabd7qzJ YvRhZDcx0A6ZQDMTWkUunsIkfnjK6nA== ARC-Authentication-Results: i=1; outbound4.ore.mailhop.org; spf=softfail smtp.mailfrom=freebsd.org smtp.remote-ip=67.177.211.60; dmarc=none header.from=freebsd.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:cc:to:from:subject:message-id:from; bh=7ZIY+uI1AbLQoIYfIadHnvEBxludlz42EnD+8jlVduE=; b=TSsVGuPPzik4N399toGnUNuQOSSsXsUeHdLUdB3xEkq38rbI7dtEc5zT/lo4oAFywkYJ/xrd4y4I5 dfXoXlllcVU+lQx16wcuCTaYmO6hY9sB/jEAo+fgmKnFK4Py6O24KSPvniWJ8xqiD4yxbYjPeLaWPf tsH8KF7WkNO4RdlwQlkSZJ/D2tMmpTleEEK3VSyR8duMkdFcxZ5/PgQM25Wsa8hiZ3hTCRQiO70bVS 359da5vNkVVTNVIkOh6wZ2TMC19Z8ZXpqo8cKyaZZPaebAd/y+w2w8RcT0JLfSm06xq1cklBoQGSZW YJ+COoJxFe+3lvyY2EQKpRGzO9f3dTA== X-Originating-IP: 67.177.211.60 X-MHO-RoutePath: aGlwcGll X-MHO-User: 92f8e8c5-9da2-11eb-a64e-89389772cfc7 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (c-67-177-211-60.hsd1.co.comcast.net [67.177.211.60]) by outbound4.ore.mailhop.org (Halon) with ESMTPSA id 92f8e8c5-9da2-11eb-a64e-89389772cfc7; Thu, 15 Apr 2021 04:25:16 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id 13F4PDqd026058; Wed, 14 Apr 2021 22:25:13 -0600 (MDT) (envelope-from ian@freebsd.org) Message-ID: <207fbb0b660fc4dff972a076ba6f2734b4f4f35f.camel@freebsd.org> Subject: Re: No dwc0 on bananapi m1 with Linux 5.10 devicetree From: Ian Lepore To: Emmanuel Vadot Cc: "freebsd-arm@FreeBSD.org" Date: Wed, 14 Apr 2021 22:25:13 -0600 In-Reply-To: <20210412181337.aaa5514ab50bdced2919b716@bidouilliste.com> References: <1sKA_1f0z4MvqNKPTG1kiNCHauRdILGumygIn6w0H-XBzxg_cTV0c-01SCnrUcmzy96RCoE2zA4khWzwo6DQQymVphL7zpjOVx5c48lXAXU=@protonmail.com> <20210411213728.7a53a7a91c2aa3c930f5abc6@bidouilliste.com> <20210412131422.68ebcd1dd748c17f2d57efb1@bidouilliste.com> <2d946b70e771c42ebd21c9b1b224b9c3ac39dcc2.camel@freebsd.org> <20210412181337.aaa5514ab50bdced2919b716@bidouilliste.com> Content-Type: text/plain; charset="ASCII" X-Mailer: Evolution 3.28.5 FreeBSD GNOME Team Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4FLR8Z4m9Nz4rKf X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [0.00 / 15.00]; local_wl_from(0.00)[freebsd.org]; ASN(0.00)[asn:16509, ipnet:54.184.0.0/15, country:US] X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Porting FreeBSD to ARM processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Apr 2021 04:25:19 -0000 On Mon, 2021-04-12 at 18:13 +0200, Emmanuel Vadot wrote: > On Mon, 12 Apr 2021 08:14:21 -0600 > Ian Lepore wrote: > > > On Mon, 2021-04-12 at 13:14 +0200, Emmanuel Vadot wrote: > > > On Sun, 11 Apr 2021 17:06:02 -0600 > > > Ian Lepore 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 > > > 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 > > > #include > > > #include > > > +#include > > > > > > #ifdef EXT_RESOURCES > > > #include > > > @@ -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 > 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 > #include > #include > +#include > > #ifdef EXT_RESOURCES > #include > @@ -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