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 X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10605C433C1 for ; Tue, 30 Mar 2021 14:50:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DBC5D60C41 for ; Tue, 30 Mar 2021 14:50:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231719AbhC3OuE (ORCPT ); Tue, 30 Mar 2021 10:50:04 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:54972 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232285AbhC3Otc (ORCPT ); Tue, 30 Mar 2021 10:49:32 -0400 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1lRFgO-00E2Bg-LN; Tue, 30 Mar 2021 16:49:28 +0200 Date: Tue, 30 Mar 2021 16:49:28 +0200 From: Andrew Lunn To: Oleksij Rempel Cc: Shawn Guo , Sascha Hauer , Florian Fainelli , Heiner Kallweit , Fugang Duan , kernel@pengutronix.de, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com, Fabio Estevam , David Jander , Russell King , Philippe Schenker Subject: Re: [PATCH net-next v1 2/3] net: phy: at803x: AR8085: add loopback support Message-ID: References: <20210330135407.17010-1-o.rempel@pengutronix.de> <20210330135407.17010-3-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210330135407.17010-3-o.rempel@pengutronix.de> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Tue, Mar 30, 2021 at 03:54:06PM +0200, Oleksij Rempel wrote: > PHY loopback is needed for the ethernet controller self test support. > This PHY was tested with the FEC sefltest. > > Signed-off-by: Oleksij Rempel > --- > drivers/net/phy/at803x.c | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > > diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c > index d7799beb811c..8679738cf2ab 100644 > --- a/drivers/net/phy/at803x.c > +++ b/drivers/net/phy/at803x.c > @@ -326,6 +326,30 @@ static int at803x_resume(struct phy_device *phydev) > return phy_modify(phydev, MII_BMCR, BMCR_PDOWN | BMCR_ISOLATE, 0); > } > > +static int at803x_loopback(struct phy_device *phydev, bool enable) > +{ > + int ret; > + > + if (enable) > + ret = phy_clear_bits(phydev, MII_BMCR, BMCR_ANENABLE); > + else > + ret = phy_set_bits(phydev, MII_BMCR, BMCR_ANENABLE); Auto-neg might of been turned off when entering self test. So you should leave it off when existing self test. Or maybe call phy_config_aneg() which should reconfigure the PHY back how it was. Andrew