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=-17.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,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 47946C48BDF for ; Fri, 18 Jun 2021 08:19:32 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 995B46121D for ; Fri, 18 Jun 2021 08:19:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 995B46121D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8A6F682B33; Fri, 18 Jun 2021 10:19:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="O3uFvlrJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2FC7982B33; Fri, 18 Jun 2021 10:19:27 +0200 (CEST) Received: from mail-oo1-xc2a.google.com (mail-oo1-xc2a.google.com [IPv6:2607:f8b0:4864:20::c2a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A591D80092 for ; Fri, 18 Jun 2021 10:19:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rfried.dev@gmail.com Received: by mail-oo1-xc2a.google.com with SMTP id b24-20020a4a34180000b029024b199e7d4dso1934861ooa.4 for ; Fri, 18 Jun 2021 01:19:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=k2EdyusBaj74nfSalkHt7dXNfgcTGWuJN2NCrXixCnI=; b=O3uFvlrJpKCaaev7uZWBYdl9KX2zoz4l3d7S54eTRLMYIHinlSYYnHTBakR6VtgbG8 PUDMLVO26ATEmS2cIXD+b49L8CNYt7hqxXvxrYOhPCsjL5dSgffKIhTjqMHc6S42dthv R5XnnKeC3o6NCJfnISSo68a9EX/V938AIEZ+CyvtBe63gMgxY24vYNpXnOmxioXr5Y5n J2L0BNCWS6rSPDPeE3Gk+vXQM3OnnhyNZqT5l68wAvLMpWBMjYImX+BSQot6AYklQRGa iZakqSOWoh2K2sTDfx5KOPJcakKSXmrDuKmE4H2kOYDCAT1pV7+QQS92Ur85kO+HgMGD Joew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=k2EdyusBaj74nfSalkHt7dXNfgcTGWuJN2NCrXixCnI=; b=D7XHbIKvPk/6f4NE9/wP/LFIyQrtDc7hx87gVBfTA7cHaLnAvwplK0AwthdI+BlSG1 30MORlQddO0cec5ydEGcLuSAi9Ycf/n6XQ2pNk9yabMaYkyjrh6hjtErrotu/Hm64Rdr MA1mbo2v/dAoSUWs53WSDNVhDhkC2aKDqsENCsO3ILJA9nsOPI24IuCUZt1uZfr2jI1d sAC9Ani4g8gomyc/crkEv+9i8ucbfGTiNIe4kaUw87HYyeKgPcTGLCwf3qBMXxO8d6kB rDVpDnMrbA+mPn5hswZxUFn/3rSMyY6TXjm2ouFZS6QwkTWtmQYGby9rBd+5gA08+p09 +Kcw== X-Gm-Message-State: AOAM530xJQwVZMpbnJxz8wCCrb8gpSswyNs8QJ4zlwXck2xbo3tC6QX7 N39FG0AVLNgPv8uqAuPBAW+J6Usx8zRaMajK6J4= X-Google-Smtp-Source: ABdhPJxJrHsOs6Msy3dRNP8nBqAG9iGAXKHQ6MqUPwb71Di+HNrUMZz7khrNAdGRUbWpQiMzzJJ11D9jwGZzeExHlKU= X-Received: by 2002:a4a:b402:: with SMTP id y2mr8017412oon.87.1624004362169; Fri, 18 Jun 2021 01:19:22 -0700 (PDT) MIME-Version: 1.0 References: <20210617222604.2563375-1-vladimir.oltean@nxp.com> <20210617222604.2563375-7-vladimir.oltean@nxp.com> In-Reply-To: <20210617222604.2563375-7-vladimir.oltean@nxp.com> From: Ramon Fried Date: Fri, 18 Jun 2021 11:19:11 +0300 Message-ID: Subject: Re: [PATCH v2 6/6] drivers: net: fsl_enetc: force the RGMII MAC speed/duplex instead of using in-band signaling To: Vladimir Oltean Cc: Joe Hershberger , U-Boot Mailing List , Claudiu Manoil , Priyanka Jain , Bin Meng Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean On Fri, Jun 18, 2021 at 1:26 AM Vladimir Oltean wrote: > > The RGMII spec supports optional in-band status reporting for the speed > and duplex negotiated on the copper side, and the ENETC driver enables > this feature by default. > > However, this does not work when the PHY does not implement the in-band > reporting, or when there is a MAC-to-MAC connection described using a > fixed-link. In that case, it would be better to disable the feature in > the ENETC MAC and always force the speed and duplex to the values that > were negotiated and retrieved over MDIO once the autoneg is finished. > Since this works always, we just do it unconditionally and drop the > in-band code. > > Note that because we need to wait for the autoneg to complete, we need > to move enetc_setup_mac_iface() after phy_startup() returns, and then > pass the phydev pointer all the way to enetc_init_rgmii(). > > The same considerations have led to a similar Linux driver patch as well: > https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=c76a97218dcbb2cb7cec1404ace43ef96c87d874 > > Signed-off-by: Vladimir Oltean > --- > v1->v2: reword commit message > > drivers/net/fsl_enetc.c | 44 ++++++++++++++++++++++++++++++----------- > drivers/net/fsl_enetc.h | 5 +++++ > 2 files changed, 38 insertions(+), 11 deletions(-) > > diff --git a/drivers/net/fsl_enetc.c b/drivers/net/fsl_enetc.c > index 5961775024ff..de1e42f907e7 100644 > --- a/drivers/net/fsl_enetc.c > +++ b/drivers/net/fsl_enetc.c > @@ -178,21 +178,43 @@ static int enetc_init_sgmii(struct udevice *dev) > } > > /* set up MAC for RGMII */ > -static int enetc_init_rgmii(struct udevice *dev) > +static void enetc_init_rgmii(struct udevice *dev, struct phy_device *phydev) > { > struct enetc_priv *priv = dev_get_priv(dev); > - u32 if_mode; > + u32 old_val, val; > > - /* enable RGMII AN */ > - if_mode = enetc_read_port(priv, ENETC_PM_IF_MODE); > - if_mode |= ENETC_PM_IF_MODE_AN_ENA; > - enetc_write_port(priv, ENETC_PM_IF_MODE, if_mode); > + old_val = val = enetc_read_port(priv, ENETC_PM_IF_MODE); > > - return 0; > + /* disable unreliable RGMII in-band signaling and force the MAC into > + * the speed negotiated by the PHY. > + */ > + val &= ~ENETC_PM_IF_MODE_AN_ENA; > + > + if (phydev->speed == SPEED_1000) { > + val &= ~ENETC_PM_IFM_SSP_MASK; > + val |= ENETC_PM_IFM_SSP_1000; > + } else if (phydev->speed == SPEED_100) { > + val &= ~ENETC_PM_IFM_SSP_MASK; > + val |= ENETC_PM_IFM_SSP_100; > + } else if (phydev->speed == SPEED_10) { > + val &= ~ENETC_PM_IFM_SSP_MASK; > + val |= ENETC_PM_IFM_SSP_10; > + } > + > + if (phydev->duplex == DUPLEX_FULL) > + val |= ENETC_PM_IFM_FULL_DPX; > + else > + val &= ~ENETC_PM_IFM_FULL_DPX; > + > + if (val == old_val) > + return; > + > + enetc_write_port(priv, ENETC_PM_IF_MODE, val); > } > > /* set up MAC configuration for the given interface type */ > -static void enetc_setup_mac_iface(struct udevice *dev) > +static void enetc_setup_mac_iface(struct udevice *dev, > + struct phy_device *phydev) > { > struct enetc_priv *priv = dev_get_priv(dev); > u32 if_mode; > @@ -202,7 +224,7 @@ static void enetc_setup_mac_iface(struct udevice *dev) > case PHY_INTERFACE_MODE_RGMII_ID: > case PHY_INTERFACE_MODE_RGMII_RXID: > case PHY_INTERFACE_MODE_RGMII_TXID: > - enetc_init_rgmii(dev); > + enetc_init_rgmii(dev, phydev); > break; > case PHY_INTERFACE_MODE_XGMII: > case PHY_INTERFACE_MODE_USXGMII: > @@ -546,10 +568,10 @@ static int enetc_start(struct udevice *dev) > enetc_setup_tx_bdr(dev); > enetc_setup_rx_bdr(dev); > > - enetc_setup_mac_iface(dev); > - > phy_startup(priv->phy); > > + enetc_setup_mac_iface(dev, priv->phy); > + > return 0; > } > > diff --git a/drivers/net/fsl_enetc.h b/drivers/net/fsl_enetc.h > index 110c1d78fbc6..a4409505e043 100644 > --- a/drivers/net/fsl_enetc.h > +++ b/drivers/net/fsl_enetc.h > @@ -77,6 +77,11 @@ enum enetc_bdr_type {TX, RX}; > #define ENETC_PM_IF_MODE 0x8300 > #define ENETC_PM_IF_MODE_RG BIT(2) > #define ENETC_PM_IF_MODE_AN_ENA BIT(15) > +#define ENETC_PM_IFM_SSP_MASK GENMASK(14, 13) > +#define ENETC_PM_IFM_SSP_1000 (2 << 13) > +#define ENETC_PM_IFM_SSP_100 (0 << 13) > +#define ENETC_PM_IFM_SSP_10 (1 << 13) > +#define ENETC_PM_IFM_FULL_DPX BIT(12) > #define ENETC_PM_IF_IFMODE_MASK GENMASK(1, 0) > > /* buffer descriptors count must be multiple of 8 and aligned to 128 bytes */ > -- > 2.25.1 > Reviewed-by: Ramon Fried