From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 40B63C77B7E for ; Thu, 1 Jun 2023 12:13:28 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1F0AE862F2; Thu, 1 Jun 2023 14:13:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1685621606; bh=EfloolENmGyy7yOVuW/6C/W610PpojV4XXnYkbtk7/8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=hPpfC7DXaLZZJgHmOebD/aKZd785zRpBC4kGShDTwduJsLBkB6hoqEA01EJXlnzok vPfZYoLYhc5vkWm1PqvveL1C9HYCOoUO2BVATfYp7rb+VHbOGMDU08M0G33FNCRItw jOn9k07GjJ00NJI0z+kfJholN+cbXP4KzRkYetBBEIHG+ZvNgOuuptYwt3aIvceI5k FVs3fftfR8/LNi3eyHALybVSK+5k92BvNTynmjI09QIqzf+i/rL2qc/5G01M53WaLL c80D4lqHf/9oIjMBe/PhR1wiEdRMMxk8LdnIyLizRPGlzCaghAq46JlMYn0h32RWLE C4WlmFYPYHBGg== Received: from wsk (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: lukma@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id C897C8627B; Thu, 1 Jun 2023 14:13:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1685621603; bh=EfloolENmGyy7yOVuW/6C/W610PpojV4XXnYkbtk7/8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Hg3HoX86Jo69hU+dul4ScWdYD6dcdPRTfg9zuqb8vMdMwBdvDZXtyCaXiVWvbKxvb BLYELRytDHyglp1ccFg6liDAByGjtgAzd7qTrosoRMZwJA0wgoabcIVPoO59sFHZuL tUg96TCYv5xZHFNXAqdjZibHhOvuPAZaFOGCO68MYIi5H1qGPySk8mtkA5/fjaLsB6 7QCjcJjX2K4DOOZSFbDRY0IXw3GcjabGyoGmRHkxbLOggIubI4g4MgUwHB8g+CMmUL SQwh+ohJG7GMzdMSpOsvRXRw4fWxOgZElDmykrkBK7Pu5776VlGV2ECJMiAxU1w+jr QBQCg4+kVFBnw== Date: Thu, 1 Jun 2023 14:13:14 +0200 From: Lukasz Majewski To: Marek Vasut Cc: u-boot@lists.denx.de, Tom Rini , Anatolij Gustschin , Ramon Fried , Joe Hershberger , Marek Vasut , Michal Simek Subject: Re: [PATCH v1 6/6] net: mv88e61xx: Reset switch PHYs when bootstrapped to !NO_CPU Message-ID: <20230601141314.50a3f642@wsk> In-Reply-To: <7fbf5592-f85d-24d6-878a-bf96480ec668@mailbox.org> References: <20230601100005.2216345-1-lukma@denx.de> <20230601100005.2216345-7-lukma@denx.de> <7fbf5592-f85d-24d6-878a-bf96480ec668@mailbox.org> Organization: denx.de X-Mailer: Claws Mail 3.19.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/Kp_wJl2Xiv33+B=BPl=+GdR"; protocol="application/pgp-signature"; micalg=pgp-sha512 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean --Sig_/Kp_wJl2Xiv33+B=BPl=+GdR Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi Marek, > On 6/1/23 12:00, Lukasz Majewski wrote: > > Some devices, when configured in bootstrap to 'no cpu' mode require > > PHY manual reset to get them operational and responding to reading > > their ID registers. > >=20 > > Without this step - the PHYLIB probing will fail. > >=20 > > In more details - the bootstrap configuration from switch must be > > read. The value of CONFIG Data1 (0x71) of Scratch and Misc register > > is read to check if 'no_cpu' and 'addr4' bits were set. > >=20 > > Signed-off-by: Lukasz Majewski > > Reviewed-by: Ramon Fried > >=20 > > --- > >=20 > > drivers/net/phy/mv88e61xx.c | 63 > > +++++++++++++++++++++++++++++++++++-- 1 file changed, 61 > > insertions(+), 2 deletions(-) > >=20 > > diff --git a/drivers/net/phy/mv88e61xx.c > > b/drivers/net/phy/mv88e61xx.c index 69a87bead469..cf8f5e833e82 > > 100644 --- a/drivers/net/phy/mv88e61xx.c > > +++ b/drivers/net/phy/mv88e61xx.c > > @@ -194,6 +194,17 @@ struct mv88e61xx_phy_priv { > > u8 phy_ctrl1_en_det_width; /* Width of 'EDet' bit field */ > > u8 phy_ctrl1_en_det_ctrl; /* 'EDet' control value */ > > u8 direct_access; /* Access switch device > > directly */ > > + /* > > + * Bootstrap configuration: > > + * > > + * If addr4 =3D 1 device is accessible from 0x10 address on > > MDIO bus. > > + */ > > + u8 addr4; > > + /* > > + * If no_cpu =3D 1 switch is automatically setup, otherwise > > PHY reset is > > + * required from CPU for normal operation. > > + */ > > + u8 no_cpu; > > }; > > =20 > > static inline int smi_cmd(int cmd, int addr, int reg) > > @@ -1218,6 +1229,33 @@ U_BOOT_PHY_DRIVER(mv88e6071) =3D { > > .shutdown =3D &genphy_shutdown, > > }; > > =20 > > +static int mv88e61xx_read_bootstrap(struct phy_device *phydev) > > +{ > > + struct mv88e61xx_phy_priv *priv =3D phydev->priv; > > + struct mii_dev *mdio_bus =3D priv->mdio_bus; > > + int val; > > + > > + /* mv88e6020 - ID =3D 0x0200 (REG 3 on non PHY port) */ > > + if (priv->id =3D=3D PORT_SWITCH_ID_6020) { > > + /* Prepare to read scratch and misc register */ > > + mdio_bus->write(mdio_bus, priv->global2, 0, > > + 0x1a /*MV_SCRATCH_MISC*/, > > + (0x71 /*MV_CONFIG_DATA1*/ << 8)); =20 >=20 > Introduce macros for these magic values. Frankly speaking, this is more readable than macros as it is in sync with vendor's documentation. In other words - it is easier to find this information in documentation when presented like above. >=20 > > + val =3D mdio_bus->read(mdio_bus, priv->global2, 0, > > + 0x1a /*MV_SCRATCH_MISC*/); > > + > > + if (val & (1 << 0)) > > + priv->no_cpu =3D 1; > > + if (val & (1 << 4)) =20 >=20 > Macros, and also BIT() >=20 > [..] Ok. Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de --Sig_/Kp_wJl2Xiv33+B=BPl=+GdR Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEgAyFJ+N6uu6+XupJAR8vZIA0zr0FAmR4i1oACgkQAR8vZIA0 zr18Vwf/eJSf4vRzmy00qfcNnlhBII1n3CHlpIPdAuR8emRYF93fhTkAdErPT09G D5477gGXMBekgSA/9InTw0kk+yKmctz7nLcSO2mEVvh2Z4HKjnq1Q2ug7cMJ21MG Q+SZavV2iZmCFFPdznOYPBW2n/5e4s6OKYsLcDwQHshUg0Tj/SLDA3fiEa/Ncj4r FaA4JQH4prB2GZECkKbmOpkmUpqmnuEsUG0wq2/E6oOUgJrICObPudhMP0WKGHiy MuW2JfAzohQXp9VSUcRXk5TukVverKMjC+LC0EkAusFmTtdYTSu9Q4DJ9t13p4bn 8Ik64LjWB/SJ+w/thz7jrR2BsbOxCQ== =Pg3G -----END PGP SIGNATURE----- --Sig_/Kp_wJl2Xiv33+B=BPl=+GdR--