Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp164405lqh; Thu, 30 May 2024 18:38:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVfOqrhDkdEeJZW10V20E81UpHvGnz4CoRDp3avrSvZsz719NQmA9Gqmu6BHdgBQ+K0JUVyxYalzhg7EPdgkt5I4dJ0AhAnuBO2WwUGSg== X-Google-Smtp-Source: AGHT+IG81/he5XoYZM17WAVWj8bANQ0AV2/LCdTsrLu4JgAp5d3VV40UlTXRPDt0enptG14ozPcD X-Received: by 2002:a05:600c:198b:b0:41f:ed4c:b8b6 with SMTP id 5b1f17b1804b1-4212e0c2dd6mr4068505e9.38.1717119520382; Thu, 30 May 2024 18:38:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717119520; cv=pass; d=google.com; s=arc-20160816; b=Uh/6cQg06nhVfLzgKIKPuld7GFWtL/7TGF038okjJA1u3cypQ9/8WNpi/1Y4wh5mJK K2xtGVeM09LGxopYdO9qRiiFiDo6qxKDbRT9fpE2UFvCO2EMKQdI3BQ1HsjbFbm3NYGy iUA26S2MTRVMdA0AoQhEC1KdKNqC0s9ua6SFZP0SbrcwOVnLIR3nlta35Go9el6LTplz S3DOP36opak7Eb+xc62e0LPQktZpzE6L/fHK/Wr9RIqvY2z6XCsDwOsIc7BnipWZbjK8 Gfnowgkf3kB6pg9neDzvNsxyc7cH4ivbuZ15tp28rfQEUhACSlWJqjd35Imfd7NU5PKJ HVGA== 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=pu4tS1RKdiruQDYLtzX3OYhIq6uClSaUNVI9buJl9us=; fh=EeHyGofIPIl2Xe+EV2/Db+nCcBad2jLaZhXSjEKIM7s=; b=PT4iFvrNufPMLt1bIugS6OhQAeaIRVkjXMfaKtloR30FIIcJqgTQTC3UprdrJyn1ed HVNFHVFfCoQQrtqU1vLkaLW1pg8ggwl9cZzLPnzhOtWC7TC9s1ejn183QF98SnnVJqny ItBdpvt7jekxBpbpp0NhGt3GSI+SUqU1CHsXo6NGywxgfZCkrAqjoAdTR4qlsadUsYNU SsSEvdQ1jIRu/VEIBfIZrurkQ5Sedf7n8tQ5ZO3CaDmH3qqryJ9vINl9qX2wKoHANTJP VBfPM7fm0fE0kKmwyDuJXMFMSMTFmR0V4dPrVitVsjNmAqihM6Uau/lWLIyQi7JhFl3N Y60A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=lSo6f6vn; 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-196159-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196159-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microchip.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31ba7a5bsi402812a12.179.2024.05.30.18.38.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 18:38:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-196159-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=lSo6f6vn; 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-196159-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196159-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 6CC211F21CB5 for ; Fri, 31 May 2024 01:38:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 66F05F9E4; Fri, 31 May 2024 01:35:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="lSo6f6vn" 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 EB2AE5C89; Fri, 31 May 2024 01:35:10 +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=1717119312; cv=none; b=rbt4aYcpR4n3VHdFKk/hFL0WZ5u/aN+xdTym48wqyYF6OH+UtK4ci8G5VjUN24tw62lFpYw7wjDnYIuDi50gpRLQ2sWGZ/tnSJz5ZL7pk32DUN6uvT9IVRcf9ymzB8xXaVJ3HNAfElDqyplZ0cZKgHGA3w4wnL8QbyCnNxnkTSA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717119312; c=relaxed/simple; bh=TKphNDbRBuukut1Ep2302cA61A0z6FOESwmZlyo0rOw=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=AA/WhMzg7vSpEwIL1gI6EDEMGLV9vMFicQ5Y5eGdwVHRJgg3bddDHV+aMmEDyfwVtVHH59T6mX9iQsKcXBqYrfApBkiHfV1uXt1gRGqA92OmAFqhcjhI+jHkFb8UtFLHyZ+Rev3VS8N0Hs1QC9pHlc3/PLeOiB6OZ4/TpYk4B+8= 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=lSo6f6vn; 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=1717119311; x=1748655311; h=from:to:cc:subject:date:message-id:mime-version; bh=TKphNDbRBuukut1Ep2302cA61A0z6FOESwmZlyo0rOw=; b=lSo6f6vnqE6pRgZ1ccpAN/06ZVeTjMsdkgRlKEIoohoLt6Jzr0tqK1WY VxxGJ9KxyacPsj6rcSH7rON8tX+W1aPp2ikCOvDEXcDbpFZOrjZ9qnmZ4 d3ZD1RU+Yc7WnkV2LcFWL+M/C7rcJX1x5U6HV/1LxcEoFUS67MWM5bkOk glsxmA48RWUsWnlUwpH3X1FABolprzvMoRnmQoTua07bEH+sizb6aD2C8 CTLZ9hwWIMQGyKXmInv78VKPruwNEvG7gD1Wh/fgfYV74WeICs6WFIV4b e3FTG/mz6hgIh7OVRJeux+Rt2oBRJ1q1ql1wJ6FmPl3uAdkwPORdPODdd g==; X-CSE-ConnectionGUID: /B7No0VXTMuuzRK/V9lgdw== X-CSE-MsgGUID: 01GfK7jXSBOKQb7FeaLGVA== X-IronPort-AV: E=Sophos;i="6.08,202,1712646000"; d="scan'208";a="26781072" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 30 May 2024 18:35:09 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.87.72) by chn-vm-ex02.mchp-main.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 30 May 2024 18:34:39 -0700 Received: from hat-linux.microchip.com (10.10.85.11) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Thu, 30 May 2024 18:34:38 -0700 From: To: Andrew Lunn , Heiner Kallweit , Russell King CC: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , , , , Tristram Ha Subject: [PATCH v1 net] net: phy: Micrel KSZ8061: fix errata solution not taking effect problem Date: Thu, 30 May 2024 18:38:01 -0700 Message-ID: <1717119481-3353-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 5.0 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 --- v1 - Correct the kernel version to 5.0 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