Message ID | 20230406131127.383006-1-lukma@denx.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1019451vqo; Thu, 6 Apr 2023 06:18:12 -0700 (PDT) X-Google-Smtp-Source: AKy350aIoEjAB0oOCeNdOxtu0O/vQwWNeR6i9e4tjkY3a3/ni3qNxrILvyBfB5Vm0Ob8PpWdaGKE X-Received: by 2002:a05:6402:2059:b0:4fa:733f:8abb with SMTP id bc25-20020a056402205900b004fa733f8abbmr4214847edb.32.1680787092585; Thu, 06 Apr 2023 06:18:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680787092; cv=none; d=google.com; s=arc-20160816; b=SF8UVlTfR0SGiEU0XpJ3x8AkDvA5PFySFgbBVNNZ1QA37QbLEQHJjRgO29QBawkElR zUM1Wf12gLzt1KlP2/CEB+o7uftv7zdAqmQ+VJBVXQ1YisOa9ROsESCyo+le1OMerYjl +xI/b1Shptlj0DqiJbiJ+eanNcoTxhdV2YcqwcujVCX8e8536xqjt9J2CjrqXKQAvMrh YWvIbIL0Xr0IfSuMvkXyRbIp7r/lOPCKtESoM4fGzd7khB8mHxJiSVOxojqXooKAieWR zq2e+uKyQ1XjODkF1wupQDIFlHuCvqywnj2mXh9NjBnVIPUWqgNV6s7G0HV/f2qQe05+ xTjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=KpoO1U+rDZspedrciHnBZ+SkMkfYySSQvrLMdTK/I0M=; b=TOgdz8vGg5rxgQ233qwD/EbRQrTHqeqEq879tgZ/+d6ptPfVyFxmsFP4nYVnJtC/dn q8NMqIfeLuGOLQAg+9wIkIi0R+DOCBWqhAn41oP7sLKW3oPqvsc4k2wfGTXOcy/7U0Ti LvOYRjMQxtKINLxRYnou9pW+v118s/hRvPbmRZo7K547hxSeEx6aj8AW+a559utzgJxF oMyRrfZWxXRK709u+RileoZZIO0plHDfne1QSnLKQnXV7/3Tp0ljU/UmIYXPOjj/LE4P BH4N5DdPBYdewUJ2J51Yyub2+ZyEMfqVCSjBqDpzK5UN5LUSOKhO+BcctInHpsb/xGYq 6w2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=RtTGNGqV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d17-20020aa7ce11000000b00502030dd391si1281413edv.46.2023.04.06.06.17.47; Thu, 06 Apr 2023 06:18:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=RtTGNGqV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236760AbjDFNMG (ORCPT <rfc822;lkml4gm@gmail.com> + 99 others); Thu, 6 Apr 2023 09:12:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229671AbjDFNME (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 6 Apr 2023 09:12:04 -0400 Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 414258690; Thu, 6 Apr 2023 06:12:02 -0700 (PDT) Received: from localhost.localdomain (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 035C780B98; Thu, 6 Apr 2023 15:11:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1680786719; bh=KpoO1U+rDZspedrciHnBZ+SkMkfYySSQvrLMdTK/I0M=; h=From:To:Cc:Subject:Date:From; b=RtTGNGqV7/wQVBz9Dai8umyDUbYuueyCHr132f0kG6b3K27JvWe0/H5P53J1Q4z1N tG+0CfjzQJEdb5HS8bcjNrqY6KoNuX1BUslUGd0NKAzf/VMvKBSOld1Jvd/5N6n23j bj+8P0ErZUJBNgts6cAsehgoqZ9eAEOkhPDzDaY+ViFhVBTm2HUGoWEDvK0HtJHPyR ogufalfMrAB2CZl4AjFEs5wPncrnFGXTA49kq5X9z5LCgVC1RiWC++nHjJOYVrB5/D aSkc1x43V7EmeigcPu0L1GVift7tCJY6rsRVfoNmXlTpKv5jfaW7R/op/HwYdnNYsB MfDpFifTS63ag== From: Lukasz Majewski <lukma@denx.de> To: Andrew Lunn <andrew@lunn.ch>, Heiner Kallweit <hkallweit1@gmail.com> Cc: Eric Dumazet <edumazet@google.com>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Russell King <linux@armlinux.org.uk>, Paolo Abeni <pabeni@redhat.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Lukasz Majewski <lukma@denx.de> Subject: [PATCH] phy: smsc: Implement .aneg_done callback for LAN8720Ai Date: Thu, 6 Apr 2023 15:11:27 +0200 Message-Id: <20230406131127.383006-1-lukma@denx.de> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762433006375806147?= X-GMAIL-MSGID: =?utf-8?q?1762433006375806147?= |
Series |
phy: smsc: Implement .aneg_done callback for LAN8720Ai
|
|
Commit Message
Lukasz Majewski
April 6, 2023, 1:11 p.m. UTC
The LAN8720Ai has special bit (12) in the PHY SPECIAL
CONTROL/STATUS REGISTER (dec 31) to indicate if the
AutoNeg is finished.
Signed-off-by: Lukasz Majewski <lukma@denx.de>
---
drivers/net/phy/smsc.c | 8 ++++++++
include/linux/smscphy.h | 2 ++
2 files changed, 10 insertions(+)
Comments
On Thu, Apr 06, 2023 at 03:11:27PM +0200, Lukasz Majewski wrote: > The LAN8720Ai has special bit (12) in the PHY SPECIAL > CONTROL/STATUS REGISTER (dec 31) to indicate if the > AutoNeg is finished. > > Signed-off-by: Lukasz Majewski <lukma@denx.de> Hi Lukasz, I think you need to rebase this on net-next. If you repost please also include 'net-next' in the subject: [PATCH net-next v2]. And a note about the changes between v1 and v2.
On Thu, Apr 06, 2023 at 03:48:43PM +0200, Simon Horman wrote: > On Thu, Apr 06, 2023 at 03:11:27PM +0200, Lukasz Majewski wrote: > > The LAN8720Ai has special bit (12) in the PHY SPECIAL > > CONTROL/STATUS REGISTER (dec 31) to indicate if the > > AutoNeg is finished. > > > > Signed-off-by: Lukasz Majewski <lukma@denx.de> > > Hi Lukasz, > > I think you need to rebase this on net-next. > > If you repost please also include 'net-next' in the subject: > [PATCH net-next v2]. > > And a note about the changes between v1 and v2. This actually seems like a fix. So it should probably be based on net, and have a Fixes: tag. Lukasz, how does this bit differ to the one in BMSR? Is the BMSR bit broken? Is there an errata for this? It would be good to describe the problem you see which this patch fixes. Andrew
Hi Andrew, > On Thu, Apr 06, 2023 at 03:48:43PM +0200, Simon Horman wrote: > > On Thu, Apr 06, 2023 at 03:11:27PM +0200, Lukasz Majewski wrote: > > > The LAN8720Ai has special bit (12) in the PHY SPECIAL > > > CONTROL/STATUS REGISTER (dec 31) to indicate if the > > > AutoNeg is finished. > > > > > > Signed-off-by: Lukasz Majewski <lukma@denx.de> > > > > Hi Lukasz, > > > > I think you need to rebase this on net-next. > > > > If you repost please also include 'net-next' in the subject: > > [PATCH net-next v2]. > > > > And a note about the changes between v1 and v2. > > This actually seems like a fix. So it should probably be based on net, > and have a Fixes: tag. I've rebased it on the newest vanila kernel. And this patch come from the work on LAN8720Ai based system (speed up of the boot time). It turned out that this IC has a dedicated bit (in vendor specific register) to show explicitly if auto neg is done. > > Lukasz, how does this bit differ to the one in BMSR? In the BMSR - bit 5 (Auto Negotiate Complete) - shows the same kind of information. The only difference is that this bit is described as "Auto Negotiate Complete" and the bit in this patch indicates "Auto Negotiation Done". > Is the BMSR bit > broken? This bit works as expected. > Is there an errata for this? No, errata doesn't mention it. I just was wondering if shall we do use the "vendor specific" indication bit or the "standard one" from BMSR register. I try to figure out why SMSC put bit from this patch in the SoC... > It would be good to describe the > problem you see which this patch fixes. > > Andrew 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
> > This actually seems like a fix. So it should probably be based on net, > > and have a Fixes: tag. > > I've rebased it on the newest vanila kernel. Please see the netdev FAQ. It talks about the two git trees used for networking. > It turned out that this IC has a dedicated bit (in vendor specific > register) to show explicitly if auto neg is done. > > > > > Lukasz, how does this bit differ to the one in BMSR? > > In the BMSR - bit 5 (Auto Negotiate Complete) - shows the same kind of > information. > > The only difference is that this bit is described as "Auto > Negotiate Complete" and the bit in this patch indicates "Auto > Negotiation Done". > > > Is the BMSR bit > > broken? > > This bit works as expected. I would avoid the vendor bit, if it has no benefit. A lot of developers understand the BMSR bit, where as very few know this vendor bit. BMSR can probably be handled with generic code, where as the vendor bit requires vendor specific code etc. Andrew
On Thu, Apr 06, 2023 at 03:11:27PM +0200, Lukasz Majewski wrote: > The LAN8720Ai has special bit (12) in the PHY SPECIAL > CONTROL/STATUS REGISTER (dec 31) to indicate if the > AutoNeg is finished. > > Signed-off-by: Lukasz Majewski <lukma@denx.de> > --- > drivers/net/phy/smsc.c | 8 ++++++++ > include/linux/smscphy.h | 2 ++ > 2 files changed, 10 insertions(+) > > diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c > index ac7481ce2fc1..58e5f06ef453 100644 > --- a/drivers/net/phy/smsc.c > +++ b/drivers/net/phy/smsc.c > @@ -83,6 +83,13 @@ static int smsc_phy_config_intr(struct phy_device *phydev) > return rc < 0 ? rc : 0; > } > > +static int smsc_phy_aneg_done(struct phy_device *phydev) > +{ > + int rc = phy_read(phydev, MII_LAN83C185_PHY_CTRL_STS); > + > + return rc & MII_LAN87XX_AUTODONE; > +} > + > static irqreturn_t smsc_phy_handle_interrupt(struct phy_device *phydev) > { > struct smsc_phy_priv *priv = phydev->priv; > @@ -416,6 +423,7 @@ static struct phy_driver smsc_phy_driver[] = { > .config_init = smsc_phy_config_init, > .soft_reset = smsc_phy_reset, > .config_aneg = lan95xx_config_aneg_ext, > + .aneg_done = smsc_phy_aneg_done, > > /* IRQ related */ > .config_intr = smsc_phy_config_intr, > diff --git a/include/linux/smscphy.h b/include/linux/smscphy.h > index 1a136271ba6a..0debebe999d6 100644 > --- a/include/linux/smscphy.h > +++ b/include/linux/smscphy.h > @@ -4,6 +4,7 @@ > > #define MII_LAN83C185_ISF 29 /* Interrupt Source Flags */ > #define MII_LAN83C185_IM 30 /* Interrupt Mask */ > +#define MII_LAN83C185_PHY_CTRL_STS 31 /* PHY Special Control/Status Register */ Looks like this is a new register. > #define MII_LAN83C185_CTRL_STATUS 17 /* Mode/Status Register */ > #define MII_LAN83C185_SPECIAL_MODES 18 /* Special Modes Register */ > > @@ -22,6 +23,7 @@ > MII_LAN83C185_ISF_INT7) > > #define MII_LAN83C185_EDPWRDOWN (1 << 13) /* EDPWRDOWN */ > +#define MII_LAN87XX_AUTODONE (1 << 12) /* AUTODONE */ Is this somehow related to the two definitions either side of it? How do we know which register this definition corresponds to? In fact, how do we know which registers any of these bits correspond with? Bunging new definitions for new registers amongst other definitions for other registers isn't particularly helpful when someone who doesn't know the driver has to look at the code. > #define MII_LAN83C185_ENERGYON (1 << 1) /* ENERGYON */ > > #define MII_LAN83C185_MODE_MASK 0xE0 > -- > 2.20.1 > >
Hi Andrew, > > > This actually seems like a fix. So it should probably be based on > > > net, and have a Fixes: tag. > > > > I've rebased it on the newest vanila kernel. > > Please see the netdev FAQ. It talks about the two git trees used for > networking. Thanks for the information. > > > It turned out that this IC has a dedicated bit (in vendor specific > > register) to show explicitly if auto neg is done. > > > > > > > > Lukasz, how does this bit differ to the one in BMSR? > > > > In the BMSR - bit 5 (Auto Negotiate Complete) - shows the same kind > > of information. > > > > The only difference is that this bit is described as "Auto > > Negotiate Complete" and the bit in this patch indicates "Auto > > Negotiation Done". > > > > > Is the BMSR bit > > > broken? > > > > This bit works as expected. > > I would avoid the vendor bit, if it has no benefit. A lot of > developers understand the BMSR bit, where as very few know this vendor > bit. BMSR can probably be handled with generic code, where as the > vendor bit requires vendor specific code etc. Ok. Then, this patch shall be dropped. Thanks for the clarification :) > > Andrew 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
diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c index ac7481ce2fc1..58e5f06ef453 100644 --- a/drivers/net/phy/smsc.c +++ b/drivers/net/phy/smsc.c @@ -83,6 +83,13 @@ static int smsc_phy_config_intr(struct phy_device *phydev) return rc < 0 ? rc : 0; } +static int smsc_phy_aneg_done(struct phy_device *phydev) +{ + int rc = phy_read(phydev, MII_LAN83C185_PHY_CTRL_STS); + + return rc & MII_LAN87XX_AUTODONE; +} + static irqreturn_t smsc_phy_handle_interrupt(struct phy_device *phydev) { struct smsc_phy_priv *priv = phydev->priv; @@ -416,6 +423,7 @@ static struct phy_driver smsc_phy_driver[] = { .config_init = smsc_phy_config_init, .soft_reset = smsc_phy_reset, .config_aneg = lan95xx_config_aneg_ext, + .aneg_done = smsc_phy_aneg_done, /* IRQ related */ .config_intr = smsc_phy_config_intr, diff --git a/include/linux/smscphy.h b/include/linux/smscphy.h index 1a136271ba6a..0debebe999d6 100644 --- a/include/linux/smscphy.h +++ b/include/linux/smscphy.h @@ -4,6 +4,7 @@ #define MII_LAN83C185_ISF 29 /* Interrupt Source Flags */ #define MII_LAN83C185_IM 30 /* Interrupt Mask */ +#define MII_LAN83C185_PHY_CTRL_STS 31 /* PHY Special Control/Status Register */ #define MII_LAN83C185_CTRL_STATUS 17 /* Mode/Status Register */ #define MII_LAN83C185_SPECIAL_MODES 18 /* Special Modes Register */ @@ -22,6 +23,7 @@ MII_LAN83C185_ISF_INT7) #define MII_LAN83C185_EDPWRDOWN (1 << 13) /* EDPWRDOWN */ +#define MII_LAN87XX_AUTODONE (1 << 12) /* AUTODONE */ #define MII_LAN83C185_ENERGYON (1 << 1) /* ENERGYON */ #define MII_LAN83C185_MODE_MASK 0xE0