From owner-freebsd-arm@freebsd.org Mon Apr 12 11:14:29 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 A61535CBE8F for ; Mon, 12 Apr 2021 11:14:29 +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 4FJmN44b1cz3rdJ; Mon, 12 Apr 2021 11:14:28 +0000 (UTC) (envelope-from manu@bidouilliste.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bidouilliste.com; s=mx; t=1618226063; 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=n4SB8BHXUZXBdptJJ4Mdk0Kaa8mulds23oWG50TcT5w=; b=FeD8wqFATE9FDtGznCYy0MWkfsqnqNWnJPOfksGKK6ZoBwy0Hb0QDfkKzs0W0czjEY9A1Q /CRjaA/Fdh27qo83QiKtSN6ui40CxRtlEC9ygX/q6PyQG2A982DzgFCJEVJYtGyvsC9z8k Fd7fA/E8Q+J5VrM7H0jDgsiQiJaYh8A= Received: from amy (j1a01-1-78-205-69-41.fbx.proxad.net [78.205.69.41]) by mx.blih.net (OpenSMTPD) with ESMTPSA id 21116129 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 12 Apr 2021 11:14:23 +0000 (UTC) Date: Mon, 12 Apr 2021 13:14:22 +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: <20210412131422.68ebcd1dd748c17f2d57efb1@bidouilliste.com> In-Reply-To: References: <1sKA_1f0z4MvqNKPTG1kiNCHauRdILGumygIn6w0H-XBzxg_cTV0c-01SCnrUcmzy96RCoE2zA4khWzwo6DQQymVphL7zpjOVx5c48lXAXU=@protonmail.com> <20210411213728.7a53a7a91c2aa3c930f5abc6@bidouilliste.com> 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: 4FJmN44b1cz3rdJ X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bidouilliste.com header.s=mx header.b=FeD8wqFA; 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 11:14:29 -0000 On Sun, 11 Apr 2021 17:06:02 -0600 Ian Lepore 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 wrote: > > > > > It seems the dwc0 no longer works after > > > 6be3386466ab79a84b48429ae66244f21526d3df > > > > > > dwc0: 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 > > > 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 > > 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 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: 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