Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp348897pxj; Fri, 11 Jun 2021 00:18:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzK85SUjKyOnRxagVoxrU2kGo16UMK5iaaxrOfNuztSieS+9brf12SNUuY+l0zXpgoK4G1v X-Received: by 2002:a17:906:acd:: with SMTP id z13mr241315ejf.437.1623395882375; Fri, 11 Jun 2021 00:18:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623395882; cv=none; d=google.com; s=arc-20160816; b=SSMBLmtCHWtj76PNlbNVRoee/WnwyhQwNg7sIh1q3RJA9x6E4qObNk+ctCDLYkhaml nN30PiCTUDkjtoTNytg4GeSed7M/b0TvBgjalMLo4wac+UAFsL3j2SyxnFMF2zmon+ir ofS2NiFxracZeSsaEl3B/qE3AZIEzrpDtCYkGFuYFarAUPUZ9GdVMHEMHkrUF5bJb1r/ hETNZFrPwBtNbzgKfr6eJkdYh6nop9r50lPFpWo0tpvLaFfh6UI0pir+/svCCKxHFLxe A33uQnN/R2raamSaDtkJLg9dtIp8gqpmGWx/bXOuZu0JXg2K8dfhuFU4Qcx25hIhqZ7f ETRw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Wc1VZC12H3LjVEpYsIsv6qXwP18l0qaJ7wKctiyBEB0=; b=YVE3xX+RU5vmDg4jK1B5dWoThIE0+0pVOAwOKlYdEEzK3shVffbqcR7YnBIxVz0Fnu R1aHKdR+GJGoxCpus8U2goxDc5XO6LovzU7DpAHW00SrwXT9CmXDXuzL79997fv6NVES 2s3r1eWPrxbByLtdqOIM7DDTnLLFD9izzHF7U63j/TczPXVcpio+g91NSVM1nTfEYELP JbKRp/j2dfAlL5rc2Y6KafxF1KsYQS1IxnmkdxJObhZGV9pk0QoFBXQzuhWDa+BtspfX VDVq8aCdj7lau5zF8H+bgTVAUG5cyx4ysF1w5YvXvVgPi9zK9KAATOACyLccjpN8Yhn5 106g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o26si4313464edv.354.2021.06.11.00.17.39; Fri, 11 Jun 2021 00:18:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231445AbhFKHRt (ORCPT + 99 others); Fri, 11 Jun 2021 03:17:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231272AbhFKHRj (ORCPT ); Fri, 11 Jun 2021 03:17:39 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C080AC06121D for ; Fri, 11 Jun 2021 00:15:40 -0700 (PDT) Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lrbO7-0000vK-8L; Fri, 11 Jun 2021 09:15:31 +0200 Received: from ore by dude.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1lrbO5-0002U3-I0; Fri, 11 Jun 2021 09:15:29 +0200 From: Oleksij Rempel To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean , "David S. Miller" , Jakub Kicinski Cc: Oleksij Rempel , kernel@pengutronix.de, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Russell King , Michael Grzeschik Subject: [PATCH net-next v4 4/9] net: phy: micrel: apply resume errata workaround for ksz8873 and ksz8863 Date: Fri, 11 Jun 2021 09:15:22 +0200 Message-Id: <20210611071527.9333-5-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210611071527.9333-1-o.rempel@pengutronix.de> References: <20210611071527.9333-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ksz8873 and ksz8863 switches are affected by following errata: | "Receiver error in 100BASE-TX mode following Soft Power Down" | | Some KSZ8873 devices may exhibit receiver errors after transitioning | from Soft Power Down mode to Normal mode, as controlled by register 195 | (0xC3) bits [1:0]. When exiting Soft Power Down mode, the receiver | blocks may not start up properly, causing the PHY to miss data and | exhibit erratic behavior. The problem may appear on either port 1 or | port 2, or both ports. The problem occurs only for 100BASE-TX, not | 10BASE-T. | | END USER IMPLICATIONS | When the failure occurs, the following symptoms are seen on the affected | port(s): | - The port is able to link | - LED0 blinks, even when there is no traffic | - The MIB counters indicate receive errors (Rx Fragments, Rx Symbol | Errors, Rx CRC Errors, Rx Alignment Errors) | - Only a small fraction of packets is correctly received and forwarded | through the switch. Most packets are dropped due to receive errors. | | The failing condition cannot be corrected by the following: | - Removing and reconnecting the cable | - Hardware reset | - Software Reset and PCS Reset bits in register 67 (0x43) | | Work around: | The problem can be corrected by setting and then clearing the Port Power | Down bits (registers 29 (0x1D) and 45 (0x2D), bit 3). This must be done | separately for each affected port after returning from Soft Power Down | Mode to Normal Mode. The following procedure will ensure no further | issues due to this erratum. To enter Soft Power Down Mode, set register | 195 (0xC3), bits [1:0] = 10. | | To exit Soft Power Down Mode, follow these steps: | 1. Set register 195 (0xC3), bits [1:0] = 00 // Exit soft power down mode | 2. Wait 1ms minimum | 3. Set register 29 (0x1D), bit [3] = 1 // Enter PHY port 1 power down mode | 4. Set register 29 (0x1D), bit [3] = 0 // Exit PHY port 1 power down mode | 5. Set register 45 (0x2D), bit [3] = 1 // Enter PHY port 2 power down mode | 6. Set register 45 (0x2D), bit [3] = 0 // Exit PHY port 2 power down mode This patch implements steps 2...6 of the suggested workaround. During (initial) switch power up, step 1 is executed by the dsa/ksz8795 driver's probe function. Note: In this workaround we toggle the MII_BMCR register's BMCR_PDOWN bit, this is translated to the actual register and bit (as mentioned in the arratum) by the ksz8_r_phy()/ksz8_w_phy() functions. Signed-off-by: Oleksij Rempel --- drivers/net/phy/micrel.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 77640b990977..e462e718d68e 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -1048,6 +1048,26 @@ static int ksz8873mll_config_aneg(struct phy_device *phydev) return 0; } +static int ksz886x_resume(struct phy_device *phydev) +{ + int ret; + + /* Apply errata workaround for KSZ8863 and KSZ8873: + * Receiver error in 100BASE-TX mode following Soft Power Down + * + * When exiting Soft Power Down mode, the receiver blocks may not start + * up properly, causing the PHY to miss data and exhibit erratic + * behavior. + */ + usleep_range(1000, 2000); + + ret = phy_set_bits(phydev, MII_BMCR, BMCR_PDOWN); + if (ret) + return ret; + + return phy_clear_bits(phydev, MII_BMCR, BMCR_PDOWN); +} + static int kszphy_get_sset_count(struct phy_device *phydev) { return ARRAY_SIZE(kszphy_hw_stats); @@ -1401,7 +1421,7 @@ static struct phy_driver ksphy_driver[] = { /* PHY_BASIC_FEATURES */ .config_init = kszphy_config_init, .suspend = genphy_suspend, - .resume = genphy_resume, + .resume = ksz886x_resume, }, { .name = "Micrel KSZ87XX Switch", /* PHY_BASIC_FEATURES */ -- 2.29.2