Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp250262lqb; Tue, 28 May 2024 14:34:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV7Mn6LQ6SIOzdgpq41KDpgfSpDe45WmB+RevwNe/AQG/2vb15W6fGuYPkdKKY+JRnCDXs3mOKmfjjtq2i9jHNaMA/Bc1ZuaUQDrnJeqQ== X-Google-Smtp-Source: AGHT+IHKHsHPsErjoRl0WovSzzeVeMfiKxcuPoGnlYJzgqPXKVutqRueCVuuZxxk72WpTvkhLrk4 X-Received: by 2002:a05:6122:21a8:b0:4d3:362f:f9c1 with SMTP id 71dfb90a1353d-4e4f02e8f06mr13747355e0c.13.1716932074539; Tue, 28 May 2024 14:34:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716932074; cv=pass; d=google.com; s=arc-20160816; b=vRCbmggvNUDRW2BAx8QwtWua0+JeeTS9ZZBgqZZ8o3RXXtqwmImTLTO7aFkRM9Gq4u mvbm6BgjTKVhR2biKqeghinAZKIM7HF1kfMd71XZajmPL6n3lwPWroSPh2N/e4mlbK8M W6TYsoIvdxtREwubwa6k/mcsQfwfbmaz+ZaxKRS8gZXxIr7cDCRwxnFupr7OTqRcC1IO iZsq3Snrd9V+hUYcRusFd6NDpk/ViD0Uvw1zZlhG/sfcI30+yTTfWT41P91ZRS7Znjoz ngsQAWk46pOe392jI7Q62uhttKnSFgq0dctiKn9nH8tCHu9KKzlkf1Aq86/GNGRn7eEF wZfg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:subject:cc:to:from:dkim-signature; bh=W3haQI8CwWF9QAItJF2G5mzASRM6e6aKJ9m1Px2BcQw=; fh=EeHyGofIPIl2Xe+EV2/Db+nCcBad2jLaZhXSjEKIM7s=; b=08X/AZp1ZOgFoUAl/V6hPA/j/veEecwNSKGo+fdFafaubPe6mw393HKzMj/hwRm6Lj 7vrygnGAKbBLJAa04aA+GTL2TJzXQaUTYNbpc/SY3CKJOCq2cFY24mk6DBM8N94hpFMK tTMRFKBqgJfaqdsIaU34h5BbxV157teqjVg2fwi5xmZLgAJ1xsulyTfPvgWjrwPB26Sy Ry5au7kCfMIK1YHFtOuTllmp7W8hztv5Y+gfiuzAhM0Do2JxQkcewct/3l9rW7e1vkOU O1T3+mz6PL8M2oC96nW1bdpp5/ZIDbFk1YXQ9Y77ZQdOQX7z6qlisbuETyQ+kbe17/Pj fFFw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=SroBXdpL; arc=pass (i=1 spf=pass spfdomain=microchip.com dkim=pass dkdomain=microchip.com dmarc=pass fromdomain=microchip.com); spf=pass (google.com: domain of linux-kernel+bounces-193121-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193121-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microchip.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-794abd3d73dsi1218214985a.472.2024.05.28.14.34.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 14:34:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193121-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=SroBXdpL; arc=pass (i=1 spf=pass spfdomain=microchip.com dkim=pass dkdomain=microchip.com dmarc=pass fromdomain=microchip.com); spf=pass (google.com: domain of linux-kernel+bounces-193121-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193121-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microchip.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4566F1C22C7D for ; Tue, 28 May 2024 21:34:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 45CFD17BB1D; Tue, 28 May 2024 21:34:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="SroBXdpL" Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 313BF17E8EB; Tue, 28 May 2024 21:34:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.153.233 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716932065; cv=none; b=kIOUszLm2CsnrV4NTHfm+/P3IEdM6L/K3nITqS/SSo9tsL0SePIZjlwhMCTcvIp+8JNiTYabX75zoG6gE43ue8v7SG0Omi2ZGGGnhtgPn7edCiNYZNAK7oGdfu8m76knYbAtEqKGQXdXPgMNiuD8uHh2B0oQ2xGGGzOMwPSQLqA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716932065; c=relaxed/simple; bh=66jCgIAfVLYODIuS69ZJMzNLkJBlcRvktHQeAOpY69I=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=iTWvjptikYnTVa4KNVZPGOKxxC6e4up3uM+WQWFKAdChaXTTQ5uwOYwW/8omqAJhZwyoMGl/ZolBcI3cgStNgd9wMY9e6FHy+DQUmFcTzgGTIfQKVd8w3YBH+wjLA1VxwhnshxTeiJtsyUWWb8p9s3y/sjIpdJIG5UMMElOBzcg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=SroBXdpL; arc=none smtp.client-ip=68.232.153.233 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1716932064; x=1748468064; h=from:to:cc:subject:date:message-id:mime-version; bh=66jCgIAfVLYODIuS69ZJMzNLkJBlcRvktHQeAOpY69I=; b=SroBXdpLIpi11zC9ZpxyjgfwKFea/lX1mpyepsj6qi45H2kOfji0FKze +QChXWp3h7IXLXGrp6AtOBPk04wy0gGlKxVjPdQLzpZp21Q1u9rkXDZ62 uEQcwf+Pd5cRnCKgpAlIdRpQCWSx5+l8/HUzCwoygzlQyexPYeJzr7426 LfTimYA3Xos8WawSR/sgYpBeM9qAXeUWsz1CPsAfeK9LPXSQRqjisKMAV zE0D6sclxXk5fhTYLCradv2mGB4t0L/T8S+LhXorVOnhlWVDmKoAjI4uj QndOqDPVO77T19AnFXrVthmctnTYjVtM7SA+O0ugR74j3r0qSt8G3SA+V w==; X-CSE-ConnectionGUID: 7btE8S4STMGx7zw2VOaPVA== X-CSE-MsgGUID: RsSuqp3LTHakwHagEdfHUw== X-IronPort-AV: E=Sophos;i="6.08,196,1712646000"; d="scan'208";a="28964721" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 May 2024 14:34:23 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 28 May 2024 14:34:12 -0700 Received: from hat-linux.microchip.com (10.10.85.11) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Tue, 28 May 2024 14:34:12 -0700 From: To: Andrew Lunn , Heiner Kallweit , Russell King CC: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , , , , Tristram Ha Subject: [PATCH net] net: phy: Micrel KSZ8061: fix errata solution not taking effect problem Date: Tue, 28 May 2024 14:37:34 -0700 Message-ID: <1716932254-3703-1-git-send-email-Tristram.Ha@microchip.com> X-Mailer: git-send-email 1.9.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain From: Tristram Ha KSZ8061 needs to write to a MMD register at driver initialization to fix an errata. This worked in 4.14 kernel but not in newer kernels. The issue is the main phylib code no longer resets PHY at the very beginning. Calling phy resuming code later will reset the chip if it is already powered down at the beginning. This wipes out the MMD register write. Solution is to implement a phy resume function for KSZ8061 to take care of this problem. Fixes: 232ba3a51cc2 ("net: phy: Micrel KSZ8061: link failure after cable connect") Signed-off-by: Tristram Ha --- drivers/net/phy/micrel.c | 42 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 2b8f8b7f1517..618e532ee5d7 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -866,6 +866,17 @@ static int ksz8061_config_init(struct phy_device *phydev) { int ret; + /* Chip can be powered down by the bootstrap code. */ + ret = phy_read(phydev, MII_BMCR); + if (ret < 0) + return ret; + if (ret & BMCR_PDOWN) { + ret = phy_write(phydev, MII_BMCR, ret & ~BMCR_PDOWN); + if (ret < 0) + return ret; + usleep_range(1000, 2000); + } + ret = phy_write_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_DEVID1, 0xB61A); if (ret) return ret; @@ -2085,6 +2096,35 @@ static int kszphy_resume(struct phy_device *phydev) return 0; } +static int ksz8061_resume(struct phy_device *phydev) +{ + int ret; + + /* This function can be called twice when the Ethernet device is on. */ + ret = phy_read(phydev, MII_BMCR); + if (ret < 0) + return ret; + if (!(ret & BMCR_PDOWN)) + return 0; + + genphy_resume(phydev); + usleep_range(1000, 2000); + + /* Re-program the value after chip is reset. */ + ret = phy_write_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_DEVID1, 0xB61A); + if (ret) + return ret; + + /* Enable PHY Interrupts */ + if (phy_interrupt_is_valid(phydev)) { + phydev->interrupts = PHY_INTERRUPT_ENABLED; + if (phydev->drv->config_intr) + phydev->drv->config_intr(phydev); + } + + return 0; +} + static int kszphy_probe(struct phy_device *phydev) { const struct kszphy_type *type = phydev->drv->driver_data; @@ -5339,7 +5379,7 @@ static struct phy_driver ksphy_driver[] = { .config_intr = kszphy_config_intr, .handle_interrupt = kszphy_handle_interrupt, .suspend = kszphy_suspend, - .resume = kszphy_resume, + .resume = ksz8061_resume, }, { .phy_id = PHY_ID_KSZ9021, .phy_id_mask = 0x000ffffe, -- 2.34.1