From owner-freebsd-arm@freebsd.org Mon Apr 12 16:13:42 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 2A5765D6101 for ; Mon, 12 Apr 2021 16:13:42 +0000 (UTC) (envelope-from manu@bidouilliste.com) Received: from mx.blih.net (mx.blih.net [212.83.155.74]) (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-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mx.blih.net", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FJv1K0Ljmz4dTS; Mon, 12 Apr 2021 16:13:40 +0000 (UTC) (envelope-from manu@bidouilliste.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bidouilliste.com; s=mx; t=1618244017; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+GFuB04IfXmr0muBGRYyzSQ9lUtsDaWGwcl2OEAHgDQ=; b=pDHX9POpqTFm5qK81jOJpAAHTGl44kxe5TAYR4leDsNkZ+5Foc0IzmZi1UTS8hhxA69cbL +Gpuvs9rz4Fs0tLeS4uFIWeZ1ooeRFuJKjZsYTeYFjV+XIGOadVrwmwgklyyzUA8dg1uly z3olPs7rrWfqD8V6FuB6vVBzfXCkkI4= Received: from amy (j1a01-1-78-205-69-41.fbx.proxad.net [78.205.69.41]) by mx.blih.net (OpenSMTPD) with ESMTPSA id 3215180c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 12 Apr 2021 16:13:37 +0000 (UTC) Date: Mon, 12 Apr 2021 18:13:37 +0200 From: Emmanuel Vadot To: Ian Lepore Cc: "freebsd-arm@FreeBSD.org" Subject: Re: No dwc0 on bananapi m1 with Linux 5.10 devicetree Message-Id: <20210412181337.aaa5514ab50bdced2919b716@bidouilliste.com> In-Reply-To: <2d946b70e771c42ebd21c9b1b224b9c3ac39dcc2.camel@freebsd.org> References: <1sKA_1f0z4MvqNKPTG1kiNCHauRdILGumygIn6w0H-XBzxg_cTV0c-01SCnrUcmzy96RCoE2zA4khWzwo6DQQymVphL7zpjOVx5c48lXAXU=@protonmail.com> <20210411213728.7a53a7a91c2aa3c930f5abc6@bidouilliste.com> <20210412131422.68ebcd1dd748c17f2d57efb1@bidouilliste.com> <2d946b70e771c42ebd21c9b1b224b9c3ac39dcc2.camel@freebsd.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; amd64-portbld-freebsd14.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4FJv1K0Ljmz4dTS X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bidouilliste.com header.s=mx header.b=pDHX9POp; dmarc=pass (policy=none) header.from=bidouilliste.com; spf=pass (mx1.freebsd.org: domain of manu@bidouilliste.com designates 212.83.155.74 as permitted sender) smtp.mailfrom=manu@bidouilliste.com X-Spamd-Result: default: False [-1.50 / 15.00]; TO_DN_EQ_ADDR_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; MV_CASE(0.50)[]; R_SPF_ALLOW(-0.20)[+mx]; DKIM_TRACE(0.00)[bidouilliste.com:+]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[bidouilliste.com,none]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RBL_DBL_DONT_QUERY_IPS(0.00)[212.83.155.74:from]; ASN(0.00)[asn:12876, ipnet:212.83.128.0/19, country:FR]; MID_RHS_MATCH_FROM(0.00)[]; RECEIVED_SPAMHAUS_PBL(0.00)[78.205.69.41:received]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[bidouilliste.com:s=mx]; FREEFALL_USER(0.00)[manu]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; SPAMHAUS_ZRD(0.00)[212.83.155.74:from:127.0.2.255]; NEURAL_SPAM_LONG(1.00)[1.000]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-arm] 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: Mon, 12 Apr 2021 16:13:42 -0000 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) -- 2.31.1 -- Emmanuel Vadot