From patchwork Wed Mar 24 09:20:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roese X-Patchwork-Id: 1457811 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=wkvDzg8d; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4F52m85Nzwz9sRN for ; Wed, 24 Mar 2021 20:21:12 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E75AE82887; Wed, 24 Mar 2021 10:20:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (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=1616577648; bh=VxaqeBPrymw/bRgLrrs6MYjOLOH7TGCXDWuuZ95YiV0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=wkvDzg8drwQKjMd86n0soZh3hdmxInIt8c+5jXkwavk6PjjiQmtegMe8VK58fcs6K aQH1VxXEG1CmmG/LYd5jmkP7/SAUcbaNbZM1artI+24TREz+tY/HLbGw7PEuhu063l 7BCqFUDnsXDbPsVKMVwRNhbWiKG/RY/ks0YCQBalE00N+lNcZALn/WPcL+FPuVbNq2 ZedjNK7XKFVG5jLVmUS0k//fRtQ5shPwmiO3XGNrG8aV2CAELtIWxrOYqfrgpod0sq 1qx+OY5mHNlUlkDhymFjheBb4EywD35qnCNkc2esdPtE2mxNEpdkL1GP1F5mCZvCfo 4XyoK6z58M7fA== Received: by phobos.denx.de (Postfix, from userid 109) id F301B825F1; Wed, 24 Mar 2021 10:20:26 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [IPv6:2001:67c:2050:1::465:204]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6DB6A8276D for ; Wed, 24 Mar 2021 10:20:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=sr@denx.de Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4F52l41gDGzQjp6; Wed, 24 Mar 2021 10:20:16 +0100 (CET) Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter06.heinlein-hosting.de (spamfilter06.heinlein-hosting.de [80.241.56.125]) (amavisd-new, port 10030) with ESMTP id Gn8Fj-NaHMkJ; Wed, 24 Mar 2021 10:20:09 +0100 (CET) From: Stefan Roese To: u-boot@lists.denx.de Cc: Kostya Porotchkin , Stefan Chulski , Ramon Fried , Nadav Haklai , Joe Hershberger , Marcin Wojtas , Igal Liberman , Kevin Shi , Simon Glass , Yan Markman Subject: [PATCH v1 1/5] net: phy: marvell: add support for 88E2110 phy Date: Wed, 24 Mar 2021 10:20:04 +0100 Message-Id: <20210324101949.v1.1.Ia608ca440eaea766c26db66de63ec7f6abef3453@changeid> In-Reply-To: <20210324092008.1300548-1-sr@denx.de> References: <20210324092008.1300548-1-sr@denx.de> MIME-Version: 1.0 X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.13 / 15.00 / 15.00 X-Rspamd-Queue-Id: 1BBE91839 X-Rspamd-UID: 01c041 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.102.4 at phobos.denx.de X-Virus-Status: Clean From: Igal Liberman E2110 support 10M/100M/1G/2.5G/5G speed and use C45 register definition. Need to use C45 or C22 r13/r14 indirect method to access Signed-off-by: Kevin Shi Signed-off-by: Igal Liberman Signed-off-by: Stefan Roese --- drivers/net/phy/marvell.c | 205 ++++++++++++++++++++++++++++++++++++++ include/linux/ethtool.h | 3 +- 2 files changed, 207 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index a62c695c5c84..c3f86d98f9e3 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -6,6 +6,7 @@ * author Andy Fleming */ #include +#include #include #include #include @@ -104,6 +105,19 @@ #define MIIM_88E151x_MODE_SGMII 1 #define MIIM_88E151x_RESET_OFFS 15 +/* 88E2110 PHY defines */ +#define MIIM_88E2110_PHY_STATUS 0x8008 +#define MIIM_88E2110_PHYSTAT_SPEED 0xc000 +#define MIIM_88E2110_PHYSTAT_10GBIT 0xc000 +#define MIIM_88E2110_PHYSTAT_GBIT 0x8000 +#define MIIM_88E2110_PHYSTAT_100 0x4000 +#define MIIM_88E2110_PHYSTAT_DUPLEX 0x2000 +#define MIIM_88E2110_PHYSTAT_SPDDONE 0x0800 +#define MIIM_88E2110_PHYSTAT_LINK 0x0400 +#define MIIM_88E2110_PHYSTAT_SPEED_5G 0x000c +#define MIIM_88E2110_PHYSTAT_5GBIT 0x0008 +#define MIIM_88E2110_PHYSTAT_2_5GBIT 0x0004 + static int m88e1xxx_phy_extread(struct phy_device *phydev, int addr, int devaddr, int regnum) { @@ -590,6 +604,185 @@ static int m88e1680_config(struct phy_device *phydev) return 0; } +/* Marvell 88E2110 */ +static int m88e2110_probe(struct phy_device *phydev) +{ + /* + * skip reset since phy has its own initial value. + * resettting leads to weird behavior + */ + phydev->flags |= PHY_FLAG_BROKEN_RESET; + + return 0; +} + +static int m88e2110_config(struct phy_device *phydev) +{ + u16 reg; + + /* Perform lane swap */ + reg = phy_read(phydev, 1, 0xc000); + reg |= 0x1; + phy_write(phydev, 1, 0xc000, reg); + + /* Configure auto-negotiation advertisement */ + if (phydev->interface == PHY_INTERFACE_MODE_SFI) { + /* Disabled 10G advertisement */ + phy_write(phydev, 7, 0x20, 0x1e1); + } else { + if (phydev->interface == PHY_INTERFACE_MODE_SGMII_2500) { + /* Disabled 10G/5G advertisements */ + phy_write(phydev, 7, 0x20, 0xa1); + } else { + /* Disable 10G/5G/2.5G auto-negotiation advertisement */ + phy_write(phydev, 7, 0x20, 0x1); + } + } + + /* Restart auto-negotiation */ + phy_write(phydev, 7, 0, 0x3200); + + return 0; +} + +/* Parse the 88E2110's status register for speed and duplex + * information + */ +static uint m88e2110_parse_status(struct phy_device *phydev) +{ + unsigned int speed; + unsigned int mii_reg; + + mii_reg = phy_read(phydev, 3, MIIM_88E2110_PHY_STATUS); + + if ((mii_reg & MIIM_88E2110_PHYSTAT_LINK) && + !(mii_reg & MIIM_88E2110_PHYSTAT_SPDDONE)) { + int i = 0; + + puts("Waiting for PHY realtime link"); + while (!(mii_reg & MIIM_88E2110_PHYSTAT_SPDDONE)) { + /* Timeout reached ? */ + if (i > PHY_AUTONEGOTIATE_TIMEOUT) { + puts(" TIMEOUT !\n"); + phydev->link = 0; + break; + } + + if ((i++ % 1000) == 0) + putc('.'); + udelay(1000); + mii_reg = phy_read(phydev, 3, MIIM_88E2110_PHY_STATUS); + } + puts(" done\n"); + mdelay(500); /* another 500 ms (results in faster booting) */ + } else { + if (mii_reg & MIIM_88E2110_PHYSTAT_LINK) + phydev->link = 1; + else + phydev->link = 0; + } + + if (mii_reg & MIIM_88E2110_PHYSTAT_DUPLEX) + phydev->duplex = DUPLEX_FULL; + else + phydev->duplex = DUPLEX_HALF; + + speed = mii_reg & MIIM_88E2110_PHYSTAT_SPEED; + + switch (speed) { + case MIIM_88E2110_PHYSTAT_10GBIT: + switch (mii_reg & MIIM_88E2110_PHYSTAT_SPEED_5G) { + case MIIM_88E2110_PHYSTAT_5GBIT: + phydev->speed = SPEED_5000; + break; + case MIIM_88E2110_PHYSTAT_2_5GBIT: + phydev->speed = SPEED_2500; + break; + default: + puts(" Unknown speed detected\n"); + break; + } + case MIIM_88E2110_PHYSTAT_GBIT: + phydev->speed = SPEED_1000; + break; + case MIIM_88E2110_PHYSTAT_100: + phydev->speed = SPEED_100; + break; + default: + phydev->speed = SPEED_10; + break; + } + + return 0; +} + +static int m88e2110_update_link(struct phy_device *phydev) +{ + unsigned int mii_reg; + + /* + * Wait if the link is up, and autonegotiation is in progress + * (ie - we're capable and it's not done) + */ + mii_reg = phy_read(phydev, 7, MII_BMSR); + + /* + * If we already saw the link up, and it hasn't gone down, then + * we don't need to wait for autoneg again + */ + if (phydev->link && mii_reg & BMSR_LSTATUS) + return 0; + + if ((mii_reg & BMSR_ANEGCAPABLE) && !(mii_reg & BMSR_ANEGCOMPLETE)) { + int i = 0; + + debug("%s Waiting for PHY auto negotiation to complete", + phydev->drv->name); + while (!(mii_reg & BMSR_ANEGCOMPLETE)) { + /* + * Timeout reached ? + */ + if (i > PHY_ANEG_TIMEOUT) { + debug(" TIMEOUT !\n"); + phydev->link = 0; + return 0; + } + + if (ctrlc()) { + puts("user interrupt!\n"); + phydev->link = 0; + return -EINTR; + } + + if ((i++ % 500) == 0) + debug("."); + + udelay(1000); /* 1 ms */ + mii_reg = phy_read(phydev, 7, MII_BMSR); + } + debug(" done\n"); + phydev->link = 1; + } else { + /* Read the link a second time to clear the latched state */ + mii_reg = phy_read(phydev, 7, MII_BMSR); + + if (mii_reg & BMSR_LSTATUS) + phydev->link = 1; + else + phydev->link = 0; + } + + return 0; +} + +static int m88e2110_startup(struct phy_device *phydev) +{ + m88e2110_update_link(phydev); + m88e2110_parse_status(phydev); + + return 0; +} + static struct phy_driver M88E1011S_driver = { .name = "Marvell 88E1011S", .uid = 0x1410c60, @@ -692,6 +885,17 @@ static struct phy_driver M88E1680_driver = { .shutdown = &genphy_shutdown, }; +static struct phy_driver M88E2110_driver = { + .name = "Marvell 88E2110", + .uid = 0x2b09b8, + .mask = 0xffffff0, + .features = PHY_GBIT_FEATURES, + .probe = &m88e2110_probe, + .config = &m88e2110_config, + .startup = &m88e2110_startup, + .shutdown = &genphy_shutdown, +}; + int phy_marvell_init(void) { phy_register(&M88E1310_driver); @@ -704,6 +908,7 @@ int phy_marvell_init(void) phy_register(&M88E1011S_driver); phy_register(&M88E151x_driver); phy_register(&M88E1680_driver); + phy_register(&M88E2110_driver); return 0; } diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index f6dbdb096d34..a97bde48df99 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -614,11 +614,12 @@ enum ethtool_sfeatures_retval_bits { * it was foced up into this mode or autonegotiated. */ -/* The forced speed, 10Mb, 100Mb, gigabit, 2.5Gb, 10GbE. */ +/* The forced speed, 10Mb, 100Mb, gigabit, 2.5Gb, 5Gb, 10GbE. */ #define SPEED_10 10 #define SPEED_100 100 #define SPEED_1000 1000 #define SPEED_2500 2500 +#define SPEED_5000 5000 #define SPEED_10000 10000 /* Duplex, half or full. */ From patchwork Wed Mar 24 09:20:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roese X-Patchwork-Id: 1457812 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=g5YBabDd; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4F52mN3wWdz9sRN for ; Wed, 24 Mar 2021 20:21:24 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3409682843; Wed, 24 Mar 2021 10:20:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (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=1616577651; bh=EFWY7/sl52gM+kAwPGm8+QeBPY1siqsuNpCu+x03Z7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=g5YBabDdDLy2xRZ9BWNrtQddqN9zHQv3kdwM6p1FQ0651/nQN4TrQyXnRswBOAqBC MyUKUA8mQkc6OjxOn8fl+l38JKNinIOPBGrdxdSV/rlcYC5Do5L1NUIuYDRJJWwoAb VeuqYZm/bmKlfDgZetaz2Gm/z9ggCSlQNIOgzqQc1NWBPht7LEe7beBukRdvowsic8 teoRbqc2RTmydQfl4Uo1t3ZyJCE93vew+r6FKHtqSQn810njNPf2lr5YmMatD915lp SDnuhfOEkp46VWCEn9CiBMRfmKgyLp5FcmrnSKVyF64EscsYlde/jqhMKSl72kZ/wA ChHiutlQ3YYwQ== Received: by phobos.denx.de (Postfix, from userid 109) id DE65A825F4; Wed, 24 Mar 2021 10:20:25 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [91.198.250.253]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id ACE1E826F5 for ; Wed, 24 Mar 2021 10:20:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=sr@denx.de Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4F52l34D8CzQjp4; Wed, 24 Mar 2021 10:20:15 +0100 (CET) Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter05.heinlein-hosting.de (spamfilter05.heinlein-hosting.de [80.241.56.123]) (amavisd-new, port 10030) with ESMTP id hjffpIJTJk2w; Wed, 24 Mar 2021 10:20:12 +0100 (CET) From: Stefan Roese To: u-boot@lists.denx.de Cc: Kostya Porotchkin , Stefan Chulski , Ramon Fried , Nadav Haklai , Joe Hershberger , Marcin Wojtas , sa_ip-sw-jenkins , Igal Liberman , Simon Glass , Yan Markman Subject: [PATCH v1 2/5] net: phy: marvell: extend 88E2110 to use both 2.5GHz modes Date: Wed, 24 Mar 2021 10:20:05 +0100 Message-Id: <20210324101949.v1.2.I60e61534246755c890f5283d6041f9c8fbcea87b@changeid> In-Reply-To: <20210324092008.1300548-1-sr@denx.de> References: <20210324092008.1300548-1-sr@denx.de> MIME-Version: 1.0 X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.98 / 15.00 / 15.00 X-Rspamd-Queue-Id: 748771876 X-Rspamd-UID: 437d6c 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.102.4 at phobos.denx.de X-Virus-Status: Clean From: Marcin Wojtas Allow 88E2110 to configure advertisements for both SGMII @2.5Ghz and 2500BaseX modes. Signed-off-by: Marcin Wojtas Tested-by: sa_ip-sw-jenkins Reviewed-by: Kostya Porotchkin Reviewed-by: Stefan Chulski Reviewed-by: Nadav Haklai Signed-off-by: Stefan Roese --- drivers/net/phy/marvell.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index c3f86d98f9e3..2e08bf3e2f79 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -630,7 +630,8 @@ static int m88e2110_config(struct phy_device *phydev) /* Disabled 10G advertisement */ phy_write(phydev, 7, 0x20, 0x1e1); } else { - if (phydev->interface == PHY_INTERFACE_MODE_SGMII_2500) { + if (phydev->interface == PHY_INTERFACE_MODE_SGMII_2500 || + phydev->interface == PHY_INTERFACE_MODE_2500BASEX) { /* Disabled 10G/5G advertisements */ phy_write(phydev, 7, 0x20, 0xa1); } else { From patchwork Wed Mar 24 09:20:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roese X-Patchwork-Id: 1457808 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=tuAbrKBe; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4F52lV3d3Fz9sRN for ; Wed, 24 Mar 2021 20:20:38 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 659AD825F1; Wed, 24 Mar 2021 10:20:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (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=1616577633; bh=ejdtJSx9hwcYf9g9Y2x97/Mc+9hDAtNJ/lYNATf+ySw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=tuAbrKBeG1PdmVpV1dSFCo8A5cVA6vyWJVjCpsyDmBPnweCjHneu4h7L1nmAWZKKS Vhu9kARkVcDt27plcoqvBoJHYH1c4sD44Txu9JqTEWtOqYIcJvC/tNl68E72kbCID3 Yku9a0m5BqoRW8zEuo99OHYnGE1YPfsVWNmShUUaa9ZJpy4WW1qEChUeEnPgRmjKeN QiPUatD+2cy4/VODPBt13WZtJZS6uLJTSQUKTuoUHbR9mvmYLSHY7ZU1E7Qpt7QDaq 8tr1CW6Xhm97GE3kfk1VAIOVZqB9ATMCIyh+KJxin2/rS+ZD3mOFERmhBr1UFNjbcg tZKpReZxnk+sA== Received: by phobos.denx.de (Postfix, from userid 109) id B7B42827BC; Wed, 24 Mar 2021 10:20:20 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-u-107.mailbox.org (mout-u-107.mailbox.org [91.198.250.252]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 36EAE825BF for ; Wed, 24 Mar 2021 10:20:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=sr@denx.de Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-107.mailbox.org (Postfix) with ESMTPS id 4F52l213jSzQjhG; Wed, 24 Mar 2021 10:20:14 +0100 (CET) Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.116]) (amavisd-new, port 10030) with ESMTP id 3_MxzowWtNKl; Wed, 24 Mar 2021 10:20:10 +0100 (CET) From: Stefan Roese To: u-boot@lists.denx.de Cc: Kostya Porotchkin , Stefan Chulski , Ramon Fried , Nadav Haklai , Joe Hershberger , Marcin Wojtas , sa_ip-sw-jenkins , Yan Markman , Marcin Wojtas , Igal Liberman , Simon Glass Subject: [PATCH v1 3/5] net: phy: marvell: remove hardcoded PHY 2210 lane swap Date: Wed, 24 Mar 2021 10:20:06 +0100 Message-Id: <20210324101949.v1.3.I0fa0a4adcf6085644f8ec39c6901ddca16d4c273@changeid> In-Reply-To: <20210324092008.1300548-1-sr@denx.de> References: <20210324092008.1300548-1-sr@denx.de> MIME-Version: 1.0 X-MBO-SPAM-Probability: *** X-Rspamd-Score: 4.41 / 15.00 / 15.00 X-Rspamd-Queue-Id: E66361871 X-Rspamd-UID: 99152c 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.102.4 at phobos.denx.de X-Virus-Status: Clean From: Stefan Chulski Lane swapped only if "enet-phy-lane-swap" set in device tree. Signed-off-by: Stefan Chulski Tested-by: sa_ip-sw-jenkins Reviewed-by: Kostya Porotchkin Reviewed-by: Yan Markman Reviewed-by: Marcin Wojtas Signed-off-by: Stefan Roese --- drivers/net/phy/marvell.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index 2e08bf3e2f79..8311b3b4722f 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -619,11 +619,17 @@ static int m88e2110_probe(struct phy_device *phydev) static int m88e2110_config(struct phy_device *phydev) { u16 reg; + ofnode node = phy_get_ofnode(phydev); - /* Perform lane swap */ - reg = phy_read(phydev, 1, 0xc000); - reg |= 0x1; - phy_write(phydev, 1, 0xc000, reg); + if (!ofnode_valid(node)) + return -EINVAL; + + if (ofnode_read_bool(node, "enet-phy-lane-swap")) { + /* Perform lane swap */ + reg = phy_read(phydev, 1, 0xc000); + reg |= 0x1; + phy_write(phydev, 1, 0xc000, reg); + } /* Configure auto-negotiation advertisement */ if (phydev->interface == PHY_INTERFACE_MODE_SFI) { From patchwork Wed Mar 24 09:20:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roese X-Patchwork-Id: 1457810 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=yb/kKhIq; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4F52lw41Dcz9sRN for ; Wed, 24 Mar 2021 20:21:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B8DDD82816; Wed, 24 Mar 2021 10:20:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (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=1616577643; bh=763JOPmiKcyDxjpGOlSc0b24RXH6dUaBpSyYKd0v0aE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=yb/kKhIq/oBjgjQ3K4fsgF4qBxbE9Xl5sf3PX9DAllXUbisubLgEON3Ek5wb91I35 3G7TZ7/vFz6OZJXGCs+lXlKx3lvZSuZWgDtTGMJ91JzWFTt3L+aFR0owOumcfZLGCM aU2u/eDdRRUgXKUsg4jkhGwMrXkT77fCEYlUNqqoqsxZ1lGcuZTJ+gj+MrwVRljITP lTH/zWdAvEtaBLp8acZUchnIZ6wYFtdgvQm3fBFd0aerUI8eGrULVfGfQAobn2dP8e 1vywbc236SqNEcBCCMNW1GwIKlmHS52KCn6UQ09hMP+WHk+YecHPgBMyz/R3NL67XT 5QiR+R3jl3P6Q== Received: by phobos.denx.de (Postfix, from userid 109) id 64D4B8283E; Wed, 24 Mar 2021 10:20:25 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [IPv6:2001:67c:2050:1::465:204]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id EE541825F4 for ; Wed, 24 Mar 2021 10:20:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=sr@denx.de Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4F52l55HcSzQjp3; Wed, 24 Mar 2021 10:20:17 +0100 (CET) Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter06.heinlein-hosting.de (spamfilter06.heinlein-hosting.de [80.241.56.125]) (amavisd-new, port 10030) with ESMTP id GCZ0-Pn2oakQ; Wed, 24 Mar 2021 10:20:11 +0100 (CET) From: Stefan Roese To: u-boot@lists.denx.de Cc: Kostya Porotchkin , Stefan Chulski , Ramon Fried , Nadav Haklai , Joe Hershberger , Marcin Wojtas , sa_ip-sw-jenkins , Yan Markman , Igal Liberman , Simon Glass Subject: [PATCH v1 4/5] net: phy: marvell: Fix PHY 221 2.5G speed detection Date: Wed, 24 Mar 2021 10:20:07 +0100 Message-Id: <20210324101949.v1.4.I3b64b258e0025ba683181e1dfc5fd5ced285b1e0@changeid> In-Reply-To: <20210324092008.1300548-1-sr@denx.de> References: <20210324092008.1300548-1-sr@denx.de> MIME-Version: 1.0 X-MBO-SPAM-Probability: *** X-Rspamd-Score: 4.37 / 15.00 / 15.00 X-Rspamd-Queue-Id: 9848C186B X-Rspamd-UID: bb6795 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.102.4 at phobos.denx.de X-Virus-Status: Clean From: Stefan Chulski Add missed break in speed detection procedure and remove nested switch. Signed-off-by: Stefan Chulski Tested-by: sa_ip-sw-jenkins Reviewed-by: Kostya Porotchkin Reviewed-by: Yan Markman Signed-off-by: Stefan Roese --- drivers/net/phy/marvell.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index 8311b3b4722f..36e678755ae8 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -107,16 +107,14 @@ /* 88E2110 PHY defines */ #define MIIM_88E2110_PHY_STATUS 0x8008 -#define MIIM_88E2110_PHYSTAT_SPEED 0xc000 -#define MIIM_88E2110_PHYSTAT_10GBIT 0xc000 +#define MIIM_88E2110_PHYSTAT_SPEED 0xc00c #define MIIM_88E2110_PHYSTAT_GBIT 0x8000 #define MIIM_88E2110_PHYSTAT_100 0x4000 #define MIIM_88E2110_PHYSTAT_DUPLEX 0x2000 #define MIIM_88E2110_PHYSTAT_SPDDONE 0x0800 #define MIIM_88E2110_PHYSTAT_LINK 0x0400 -#define MIIM_88E2110_PHYSTAT_SPEED_5G 0x000c -#define MIIM_88E2110_PHYSTAT_5GBIT 0x0008 -#define MIIM_88E2110_PHYSTAT_2_5GBIT 0x0004 +#define MIIM_88E2110_PHYSTAT_5GBIT 0xc008 +#define MIIM_88E2110_PHYSTAT_2_5GBIT 0xc004 static int m88e1xxx_phy_extread(struct phy_device *phydev, int addr, int devaddr, int regnum) @@ -657,7 +655,6 @@ static int m88e2110_config(struct phy_device *phydev) */ static uint m88e2110_parse_status(struct phy_device *phydev) { - unsigned int speed; unsigned int mii_reg; mii_reg = phy_read(phydev, 3, MIIM_88E2110_PHY_STATUS); @@ -694,21 +691,13 @@ static uint m88e2110_parse_status(struct phy_device *phydev) else phydev->duplex = DUPLEX_HALF; - speed = mii_reg & MIIM_88E2110_PHYSTAT_SPEED; - - switch (speed) { - case MIIM_88E2110_PHYSTAT_10GBIT: - switch (mii_reg & MIIM_88E2110_PHYSTAT_SPEED_5G) { - case MIIM_88E2110_PHYSTAT_5GBIT: - phydev->speed = SPEED_5000; - break; - case MIIM_88E2110_PHYSTAT_2_5GBIT: - phydev->speed = SPEED_2500; - break; - default: - puts(" Unknown speed detected\n"); - break; - } + switch (mii_reg & MIIM_88E2110_PHYSTAT_SPEED) { + case MIIM_88E2110_PHYSTAT_5GBIT: + phydev->speed = SPEED_5000; + break; + case MIIM_88E2110_PHYSTAT_2_5GBIT: + phydev->speed = SPEED_2500; + break; case MIIM_88E2110_PHYSTAT_GBIT: phydev->speed = SPEED_1000; break; From patchwork Wed Mar 24 09:20:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roese X-Patchwork-Id: 1457809 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=Hfw1aOhp; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4F52lj0PMBz9sRN for ; Wed, 24 Mar 2021 20:20:49 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 67EF88284D; Wed, 24 Mar 2021 10:20:38 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (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=1616577638; bh=wpM1c2ZT7TCUygUORlhHId55fpagN8ijpEDpVj5ZrBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Hfw1aOhpeJYNNRq0qvvGpy2SmobZMZ0Sku+9GIymCmJQ4R8lgJgvLHeo+1AH4aglp 2hw9+f+ssrkbG2BkdTKLvaCVWW/vH1Kw7lzH/08Kshc+jEobJO5RvrwqEYu+ptcwwi icigwTNwQJINhIlrXbrdaDxUfwZmSoYLRVnEs3DnVRUGXq8Q+k1+bCCbVDkBVXljPF 61M8kV65F7S/Sa5o4Z6uJjb8/fOm5P4TlaRRdRIViSEdM+fEFL3XMMdAA6j+RCEhMM pL5miuvBuHGp8TsB3muGXAsYG+kSe6wTUwxkaOs1vFPBf4km9OPPjs/22lOdQIg47Y Emz2R1lkwQTyg== Received: by phobos.denx.de (Postfix, from userid 109) id F3A558282E; Wed, 24 Mar 2021 10:20:22 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [IPv6:2001:67c:2050:1::465:204]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 000BC825F1 for ; Wed, 24 Mar 2021 10:20:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=sr@denx.de Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4F52l34ysvzQjp5; Wed, 24 Mar 2021 10:20:15 +0100 (CET) Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter04.heinlein-hosting.de (spamfilter04.heinlein-hosting.de [80.241.56.122]) (amavisd-new, port 10030) with ESMTP id zu5kk5Gwpa5p; Wed, 24 Mar 2021 10:20:11 +0100 (CET) From: Stefan Roese To: u-boot@lists.denx.de Cc: Kostya Porotchkin , Stefan Chulski , Ramon Fried , Nadav Haklai , Joe Hershberger , Marcin Wojtas , sa_ip-sw-jenkins , Yan Markman , Marcin Wojtas , Igal Liberman , Simon Glass Subject: [PATCH v1 5/5] net: phy: marvell: Fix 2210 link and speed detection resolution Date: Wed, 24 Mar 2021 10:20:08 +0100 Message-Id: <20210324101949.v1.5.I67a56cf3de91b8ac3dde86e7ca49e0ab61b5e18f@changeid> In-Reply-To: <20210324092008.1300548-1-sr@denx.de> References: <20210324092008.1300548-1-sr@denx.de> MIME-Version: 1.0 X-MBO-SPAM-Probability: * X-Rspamd-Score: 1.41 / 15.00 / 15.00 X-Rspamd-Queue-Id: DDFF81893 X-Rspamd-UID: 1975c8 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.102.4 at phobos.denx.de X-Virus-Status: Clean From: Stefan Chulski Patch fix couple of link and speed detection resolution bugs: 1. Waiting for PHY real time link condition. 2. Replace PHYSTAT_SPDDONE with PHYSTAT_LINK in while loop, PHYSTAT_SPDDONE could be enabled before link status changed to enable. 3. Update link status after link resolution loop. Signed-off-by: Stefan Chulski Tested-by: sa_ip-sw-jenkins Reviewed-by: Kostya Porotchkin Reviewed-by: Yan Markman Reviewed-by: Marcin Wojtas Signed-off-by: Stefan Roese --- drivers/net/phy/marvell.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index 36e678755ae8..3bcb0033b391 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -659,12 +659,11 @@ static uint m88e2110_parse_status(struct phy_device *phydev) mii_reg = phy_read(phydev, 3, MIIM_88E2110_PHY_STATUS); - if ((mii_reg & MIIM_88E2110_PHYSTAT_LINK) && - !(mii_reg & MIIM_88E2110_PHYSTAT_SPDDONE)) { + if (!(mii_reg & MIIM_88E2110_PHYSTAT_LINK)) { int i = 0; puts("Waiting for PHY realtime link"); - while (!(mii_reg & MIIM_88E2110_PHYSTAT_SPDDONE)) { + while (!(mii_reg & MIIM_88E2110_PHYSTAT_LINK)) { /* Timeout reached ? */ if (i > PHY_AUTONEGOTIATE_TIMEOUT) { puts(" TIMEOUT !\n"); @@ -679,13 +678,13 @@ static uint m88e2110_parse_status(struct phy_device *phydev) } puts(" done\n"); mdelay(500); /* another 500 ms (results in faster booting) */ - } else { - if (mii_reg & MIIM_88E2110_PHYSTAT_LINK) - phydev->link = 1; - else - phydev->link = 0; } + if (mii_reg & MIIM_88E2110_PHYSTAT_LINK) + phydev->link = 1; + else + phydev->link = 0; + if (mii_reg & MIIM_88E2110_PHYSTAT_DUPLEX) phydev->duplex = DUPLEX_FULL; else