From patchwork Thu May 30 10:24:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Enguerrand de Ribaucourt X-Patchwork-Id: 13680140 X-Patchwork-Delegate: kuba@kernel.org Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) (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 7ED261761B1 for ; Thu, 30 May 2024 10:31:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=208.88.110.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717065099; cv=none; b=hacRv8JjYIpC/jAyX5AZyRnbW9oYmBpU0S+N7cGfLydUvxaXa9Nn9EAjrQLVAF8RVzJIu6yL4U4GbEo3D7bwYX94stY1vFz6+RwBC85w10NoPZb7VIch8g1f+tMY1G/O1adLReeQfckIwXiiu6e13CyAZ+orM9T4BzhTkW/FrZk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717065099; c=relaxed/simple; bh=rLioc4IXEvqTemHi7lRZSVNRa2Q2nkZVJuSWw3lrp+E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rlAjYcBCGX+kPdvxM+mWZ9qRAv/tZMZVAFvM3PVFkzW+9Xp1MVeiXpUzfLmIbGrnPCOVkRMgWRAhj+VtjJzWdIUAJMGfjyMFszAnIYVhFcqpwdpW9d+l+N5xZq2SVJwo/F2VyKyyu9CjluqGfjJwHFSqZCvyiT5EIiQ5TBe+NqA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=savoirfairelinux.com; spf=pass smtp.mailfrom=savoirfairelinux.com; dkim=pass (2048-bit key) header.d=savoirfairelinux.com header.i=@savoirfairelinux.com header.b=bjtP1dUN; arc=none smtp.client-ip=208.88.110.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=savoirfairelinux.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=savoirfairelinux.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=savoirfairelinux.com header.i=@savoirfairelinux.com header.b="bjtP1dUN" Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id B0BE29C5A25; Thu, 30 May 2024 06:25:09 -0400 (EDT) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10032) with ESMTP id 5G9ZAmsJRaP8; Thu, 30 May 2024 06:25:08 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id A2F859C5A15; Thu, 30 May 2024 06:25:08 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com A2F859C5A15 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1717064708; bh=yve/1q3P+SWraA1Z3gh6daavfsFifTh+55Sw/l4aOCE=; h=From:To:Date:Message-Id:MIME-Version; b=bjtP1dUNIjMX9Z8mUOFKBhoxpH2J/kbCwMo55FbPLrdFM6Pb1RQohK7XhwtlRlPYP qxA/K2hA6fDt4wew8hzI+qZfZgZYNBobzC2zmAbDwfr62bK23+j24LP1HwoqngvvJm MIPDqye06P96DU82s8ltt256UR6BaoeUs6GZFFVLasDcMFAbTHkghpSc0iXHHp22MR r+4/xnRa2UCPOaYu/zu5qjGDgmgIRlv7I08NPRxLzcHpaCDpTlWhH09RyLECWMYZxB /hh8691AXp/D0Q7Jqq1uubOTcRspZst6xKtc/B6jDIAC1sz0r3z2hXPFe8chYx2XEl n9II1wgXLnjQw== X-Virus-Scanned: amavis at mail.savoirfairelinux.com Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10026) with ESMTP id noKKc1kjr7G5; Thu, 30 May 2024 06:25:08 -0400 (EDT) Received: from sfl-deribaucourt.rennes.sfl (lmontsouris-657-1-69-118.w80-15.abo.wanadoo.fr [80.15.101.118]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id B709B9C5A16; Thu, 30 May 2024 06:25:07 -0400 (EDT) From: Enguerrand de Ribaucourt To: netdev@vger.kernel.org Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, woojung.huh@microchip.com, embedded-discuss@lists.savoirfairelinux.net, Enguerrand de Ribaucourt Subject: [PATCH v3 1/5] net: phy: micrel: add Microchip KSZ 9897 Switch PHY support Date: Thu, 30 May 2024 10:24:32 +0000 Message-Id: <20240530102436.226189-2-enguerrand.de-ribaucourt@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240530102436.226189-1-enguerrand.de-ribaucourt@savoirfairelinux.com> References: <20240530102436.226189-1-enguerrand.de-ribaucourt@savoirfairelinux.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org There is a DSA driver for microchip,ksz9897 which can be controlled through SPI or I2C. This patch adds support for it's CPU ports PHYs to also allow network access to the switch's CPU port. The CPU ports PHYs of the KSZ9897 are not documented in the datasheet. They weirdly use the same PHY ID as the KSZ8081, which is a different PHY and that driver isn't compatible with KSZ9897. Before this patch, the KSZ8081 driver was used for the CPU ports of the KSZ9897 but the link would never come up. A new driver for the KSZ9897 is added, based on the compatible KSZ87XX. I could not test if Gigabit Ethernet works, but the link comes up and can successfully allow packets to be sent and received with DSA tags. To resolve the KSZ8081/KSZ9897 phy_id conflicts, I could not find any stable register to distinguish them. The crude solution is to check if a KSZ9897 DSA switch is present in the devicetree. A discussion to find better alternatives had been opened with the Microchip team, with no response yet. See https://lore.kernel.org/all/20220207174532.362781-1-enguerrand.de-ribaucourt@savoirfairelinux.com/ Signed-off-by: Enguerrand de Ribaucourt --- drivers/net/phy/micrel.c | 46 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 13e30ea7eec5..99322a3c3869 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -16,7 +16,7 @@ * ksz8081, ksz8091, * ksz8061, * Switch : ksz8873, ksz886x - * ksz9477, lan8804 + * ksz9477, ksz9897, lan8804 */ #include @@ -769,6 +769,38 @@ static int ksz8051_match_phy_device(struct phy_device *phydev) return ksz8051_ksz8795_match_phy_device(phydev, true); } +static int ksz8081_ksz9897_match_phy_device(struct phy_device *phydev, + const bool ksz_8081) +{ + /* KSZ8081 and KSZ9897 CPU port share the same exact PHY ID. Despite driver + * differences. None of the PHY registers allow to distinguish them + * accurately. The driver initialization order may also start with the PHY + * matching before the DSA switch node is attached to the CPU port. We fall + * back to looking up if any KSZ9897 is present in the devicetree. + */ + struct device_node *node; + + if (!phy_id_compare(phydev->phy_id, PHY_ID_KSZ8081, MICREL_PHY_ID_MASK)) + return 0; + + node = of_find_compatible_node(NULL, NULL, "microchip,ksz9897"); + + if (ksz_8081) + return node == NULL; + else + return node != NULL; +} + +static int ksz8081_match_phy_device(struct phy_device *phydev) +{ + return ksz8081_ksz9897_match_phy_device(phydev, true); +} + +static int ksz9897_match_phy_device(struct phy_device *phydev) +{ + return ksz8081_ksz9897_match_phy_device(phydev, false); +} + static int ksz8081_config_init(struct phy_device *phydev) { /* KSZPHY_OMSO_FACTORY_TEST is set at de-assertion of the reset line @@ -5300,9 +5332,7 @@ static struct phy_driver ksphy_driver[] = { .suspend = kszphy_suspend, .resume = kszphy_resume, }, { - .phy_id = PHY_ID_KSZ8081, .name = "Micrel KSZ8081 or KSZ8091", - .phy_id_mask = MICREL_PHY_ID_MASK, .flags = PHY_POLL_CABLE_TEST, /* PHY_BASIC_FEATURES */ .driver_data = &ksz8081_type, @@ -5316,6 +5346,7 @@ static struct phy_driver ksphy_driver[] = { .get_sset_count = kszphy_get_sset_count, .get_strings = kszphy_get_strings, .get_stats = kszphy_get_stats, + .match_phy_device = ksz8081_match_phy_device, .suspend = kszphy_suspend, .resume = kszphy_resume, .cable_test_start = ksz886x_cable_test_start, @@ -5486,6 +5517,15 @@ static struct phy_driver ksphy_driver[] = { .suspend = genphy_suspend, .resume = genphy_resume, .get_features = ksz9477_get_features, +}, { + .name = "Microchip KSZ9897 Switch", + /* PHY_BASIC_FEATURES */ + .config_init = kszphy_config_init, + .config_aneg = ksz8873mll_config_aneg, + .read_status = ksz8873mll_read_status, + .match_phy_device = ksz9897_match_phy_device, + .suspend = genphy_suspend, + .resume = genphy_resume, } }; module_phy_driver(ksphy_driver); From patchwork Thu May 30 10:24:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Enguerrand de Ribaucourt X-Patchwork-Id: 13680139 X-Patchwork-Delegate: kuba@kernel.org Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) (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 7EDB1176AC7 for ; Thu, 30 May 2024 10:31:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=208.88.110.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717065099; cv=none; b=FsN1g70a/hrKUPG1VkY6T2PmbQpEoBF3XhYxHAOU8CG7izsIYKhMU+mfgEgOO/knGTE1N7b4sM7UvXZbLHZenlwqcMFIq/5waLpWO0VBQ/i2+LnF+s/kd1Ln2ZbvsDYcrLBCSGh7F4cJNYmooygh9Sq9jPSrPpxMu0MNMkLf/AU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717065099; c=relaxed/simple; bh=GFA91Mr3rynjqsgM4fHjz0cSVPUVhfgs+tM8NqaFOhk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RR9arj4KJ7pjEAJqMUCmx6OkhmxEqVNOa9UxAarhHFAqJUw5IKT/g7cudfkmf0ecueyQOW9TyrDkuXtABvyMwV7g7qaSsbVMQ5eIPLNrrjiqtHIKTefy7vLvIbl+SCKesIcCxB3wVRK+cC+mC1SUfYiCmfrdWq9QvtTrK7vxlUE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=savoirfairelinux.com; spf=pass smtp.mailfrom=savoirfairelinux.com; dkim=pass (2048-bit key) header.d=savoirfairelinux.com header.i=@savoirfairelinux.com header.b=UcLBeg4E; arc=none smtp.client-ip=208.88.110.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=savoirfairelinux.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=savoirfairelinux.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=savoirfairelinux.com header.i=@savoirfairelinux.com header.b="UcLBeg4E" Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 532F09C5A17; Thu, 30 May 2024 06:25:10 -0400 (EDT) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10032) with ESMTP id fhSMu1Vn-zR9; Thu, 30 May 2024 06:25:09 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id AB5A19C53C1; Thu, 30 May 2024 06:25:09 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com AB5A19C53C1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1717064709; bh=0FUsDMqKI4DbapXjdymOIRvqnPI51tJuF/s9XLEpmEk=; h=From:To:Date:Message-Id:MIME-Version; b=UcLBeg4ECFTsCwnzpZP/Y2fdwRfOp98N/DXu+8g/spAkWaRJ4bzwTjqdAGCSO331v MYp962GMwKrlKFs7qaGR5hDfctEfuaY+ArndBvAwDd1Mlw9D4sNe+zmTL4y7IaXgPu /yAlSvDZTO5T6tkVPvOCMJm5beyQ41lqtEJPvNeoz43tLOHFWoiQ5ORfRarloQXrl2 IUOF2YQ7Eo5ss2DEOsVWmdFHsjkcCDdlczIBcpBEN2jKO61by2Gey60cSroreg/zqe MrSMkyrfXz3crZfYx6JlJ9e6WMJE3ncbhQfVNBKmzz0dUatyVw3eqj2Jjuj2CtuGUA rrEsOoPd3qMKQ== X-Virus-Scanned: amavis at mail.savoirfairelinux.com Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10026) with ESMTP id ry9hHGqKBgVH; Thu, 30 May 2024 06:25:09 -0400 (EDT) Received: from sfl-deribaucourt.rennes.sfl (lmontsouris-657-1-69-118.w80-15.abo.wanadoo.fr [80.15.101.118]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id BF0D29C32FC; Thu, 30 May 2024 06:25:08 -0400 (EDT) From: Enguerrand de Ribaucourt To: netdev@vger.kernel.org Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, woojung.huh@microchip.com, embedded-discuss@lists.savoirfairelinux.net, Enguerrand de Ribaucourt Subject: [PATCH v3 2/5] net: phy: micrel: disable suspend/resume callbacks following errata Date: Thu, 30 May 2024 10:24:33 +0000 Message-Id: <20240530102436.226189-3-enguerrand.de-ribaucourt@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240530102436.226189-1-enguerrand.de-ribaucourt@savoirfairelinux.com> References: <20240530102436.226189-1-enguerrand.de-ribaucourt@savoirfairelinux.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Microchip's erratas state that powering down a PHY may cause errors on the adjacent PHYs due to the power supply noise. The suggested workaround is to avoid toggling the powerdown bit dynamically while traffic may be present. Signed-off-by: Enguerrand de Ribaucourt --- drivers/net/phy/micrel.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 99322a3c3869..78f2040c3cd1 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -5514,8 +5514,9 @@ static struct phy_driver ksphy_driver[] = { .config_init = ksz9477_config_init, .config_intr = kszphy_config_intr, .handle_interrupt = kszphy_handle_interrupt, - .suspend = genphy_suspend, - .resume = genphy_resume, + /* No suspend/resume callbacks because of errata DS80000758: + * Toggling PHY Powerdown can cause errors or link failures in adjacent PHYs + */ .get_features = ksz9477_get_features, }, { .name = "Microchip KSZ9897 Switch", @@ -5524,8 +5525,9 @@ static struct phy_driver ksphy_driver[] = { .config_aneg = ksz8873mll_config_aneg, .read_status = ksz8873mll_read_status, .match_phy_device = ksz9897_match_phy_device, - .suspend = genphy_suspend, - .resume = genphy_resume, + /* No suspend/resume callbacks because of errata DS00002330D: + * Toggling PHY Powerdown can cause errors or link failures in adjacent PHYs + */ } }; module_phy_driver(ksphy_driver); From patchwork Thu May 30 10:24:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Enguerrand de Ribaucourt X-Patchwork-Id: 13680137 X-Patchwork-Delegate: kuba@kernel.org Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) (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 7ED6B176AA1 for ; Thu, 30 May 2024 10:31:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=208.88.110.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717065098; cv=none; b=DpJJDbUOXNHdo57GFdzZ3fQPb2flFUoQq02EJsv19Wsy0ec4EJ6dP3rW6d7wK1Bbgrx89x2HWM8F7FVqkKPXuU2PrWECTpblKh8pndgTRmLzYAl++vd8U/mtpkwYoG64s169uqbIRLTgiNRIR0s75Q008uMAvnBphSJK+XxiHvA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717065098; c=relaxed/simple; bh=63f+O1opezTLfsJXw5dCgIt/b+Nl3TJNtrddmzzT4ig=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ReiYWZtTW/pBpvH4pZC/YU687J4aik90daOGWvvDRIGUVa+5dGa+tQAc9jif8/Eyb/gxjwQ1x769qUeJnmLwj1vLj5gwSwpN8+MEqCh3JLzmD0bFI0sQY97xLoZXtluqlkJ+0UZhKKK1paY3Q3mwe0smLWiEdn5kbpAPS91v+xo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=savoirfairelinux.com; spf=pass smtp.mailfrom=savoirfairelinux.com; dkim=pass (2048-bit key) header.d=savoirfairelinux.com header.i=@savoirfairelinux.com header.b=Fr3vU/aj; arc=none smtp.client-ip=208.88.110.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=savoirfairelinux.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=savoirfairelinux.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=savoirfairelinux.com header.i=@savoirfairelinux.com header.b="Fr3vU/aj" Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 3C8DD9C5A29; Thu, 30 May 2024 06:25:11 -0400 (EDT) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10032) with ESMTP id fxuGAiE4UcPP; Thu, 30 May 2024 06:25:10 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id C0B8F9C53C1; Thu, 30 May 2024 06:25:10 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com C0B8F9C53C1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1717064710; bh=SC1lrSWdAcyOqTblFjk1GR2AXzdOlyFvvtUN/tnZ2CE=; h=From:To:Date:Message-Id:MIME-Version; b=Fr3vU/ajV2aiR5QXZLPamwL2OEUy0+OgqYb5DNOehGUPpryYEmwvEkRaNxWFouTWy I7Giu+okoPntWbKMkwyhg+qvOuXP716o9qWGe8Gz/qnl8DN20gl9T0jvOHoH+BoYP6 aEf5juor5M647z6syOB/hZYkENid41rBRFXkciUYrPI1BJv0SlROT2kFtDyhwVNezi zgJJQnKI178B8qQeHUixbO0CvY4+CI4OHJsgNL0mPoER9O1KzL64bdL0Lv95AC7M0O u8VTGSVZB+TiUKMXclv00uTnBkxLveHARFKoRVqMqu9MAD1MHGPLMnI1ymvcu6opT+ +iraUyc4CItiw== X-Virus-Scanned: amavis at mail.savoirfairelinux.com Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10026) with ESMTP id fGvPwIdHArBH; Thu, 30 May 2024 06:25:10 -0400 (EDT) Received: from sfl-deribaucourt.rennes.sfl (lmontsouris-657-1-69-118.w80-15.abo.wanadoo.fr [80.15.101.118]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id CA9349C32FC; Thu, 30 May 2024 06:25:09 -0400 (EDT) From: Enguerrand de Ribaucourt To: netdev@vger.kernel.org Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, woojung.huh@microchip.com, embedded-discuss@lists.savoirfairelinux.net, Enguerrand de Ribaucourt Subject: [PATCH v3 3/5] net: phy: micrel: add Microchip KSZ 9477 to the device table Date: Thu, 30 May 2024 10:24:34 +0000 Message-Id: <20240530102436.226189-4-enguerrand.de-ribaucourt@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240530102436.226189-1-enguerrand.de-ribaucourt@savoirfairelinux.com> References: <20240530102436.226189-1-enguerrand.de-ribaucourt@savoirfairelinux.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org PHY_ID_KSZ9477 was supported but not added to the device table passed to MODULE_DEVICE_TABLE. Signed-off-by: Enguerrand de Ribaucourt --- drivers/net/phy/micrel.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 78f2040c3cd1..5930ac9fa661 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -5550,6 +5550,7 @@ static struct mdio_device_id __maybe_unused micrel_tbl[] = { { PHY_ID_KSZ8081, MICREL_PHY_ID_MASK }, { PHY_ID_KSZ8873MLL, MICREL_PHY_ID_MASK }, { PHY_ID_KSZ886X, MICREL_PHY_ID_MASK }, + { PHY_ID_KSZ9477, MICREL_PHY_ID_MASK }, { PHY_ID_LAN8814, MICREL_PHY_ID_MASK }, { PHY_ID_LAN8804, MICREL_PHY_ID_MASK }, { PHY_ID_LAN8841, MICREL_PHY_ID_MASK }, From patchwork Thu May 30 10:24:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Enguerrand de Ribaucourt X-Patchwork-Id: 13680138 X-Patchwork-Delegate: kuba@kernel.org Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) (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 7ECE318398B for ; Thu, 30 May 2024 10:31:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=208.88.110.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717065099; cv=none; b=lBq1oer/1H67SJFmlW+/+D1Oc0A7R3J5rgdYkG4+zHqi/EMxacMIKLYXYByppReBATfOAQzhACILxGERBOQ9Y94CY4iHY0qHqQiZSyfnNSKeOqtCt5gauHnR3u+3aziLTGXMhrSIPMEFjmXrQQjYIc9Nkcg9GFWAdVpVCDe8WIM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717065099; c=relaxed/simple; bh=lzzefgjDdWw4etASbP9OphGOeeKdJ/U8erhVlzJyjEs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QQe+2SGZiySVCEWe1NS/NtPWekwIIGecdT0/5bRqcnpFMdMmkYFyOiWeUl9PaFpmB/GGtKow6V9J+D9dtApY4am/pK3c6AQWnqaKk7oNYxK9Mw5847TbdSO/PZugOvbh36ERgyfMV8mAGxqJBH4b/Ps8oIq/kct1v6IYt7Qkxlk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=savoirfairelinux.com; spf=pass smtp.mailfrom=savoirfairelinux.com; dkim=pass (2048-bit key) header.d=savoirfairelinux.com header.i=@savoirfairelinux.com header.b=v/ggTrPu; arc=none smtp.client-ip=208.88.110.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=savoirfairelinux.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=savoirfairelinux.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=savoirfairelinux.com header.i=@savoirfairelinux.com header.b="v/ggTrPu" Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 55D239C5882; Thu, 30 May 2024 06:25:12 -0400 (EDT) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10032) with ESMTP id 50yjBMYNa1EG; Thu, 30 May 2024 06:25:11 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id CD7C19C56BD; Thu, 30 May 2024 06:25:11 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com CD7C19C56BD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1717064711; bh=EZMrywvIahsm1TnQTRaY8UsYDNJshfm0cOM+dvJRsZ4=; h=From:To:Date:Message-Id:MIME-Version; b=v/ggTrPuEOhrCyZVNRZ91hf8bjEw4pWg6RrYsJFDtu21n6rzI4L5mW6SltsyyuB80 FCiNBip/YCHiTYk1EF5sNjaU+XsvxcBe+Q1AWT8tDdgySk6lm/yy8Q3chyupte4DCa kMVNzo+wHz/+/kIrGeMKz1tnPTvkVHNgnLIsCY1hkqNhrE42c4HXoo6J3ajsPcpKS9 g3VTYmDjFish6g8asOl/wi7c8CFzY5jNUMux7DVnZb8DUfhsq0EcKgTeyQtaIhXm/s +NRLFbRMXWuBlBLbuRCmAnyHh6QFcm+Yvq4a6I3OjOABZcYRjvXgx/YKmtpb1D3d2x 8LU4ite7iHC6g== X-Virus-Scanned: amavis at mail.savoirfairelinux.com Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10026) with ESMTP id YhHjEoTZdHym; Thu, 30 May 2024 06:25:11 -0400 (EDT) Received: from sfl-deribaucourt.rennes.sfl (lmontsouris-657-1-69-118.w80-15.abo.wanadoo.fr [80.15.101.118]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id DF3BE9C32FC; Thu, 30 May 2024 06:25:10 -0400 (EDT) From: Enguerrand de Ribaucourt To: netdev@vger.kernel.org Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, woojung.huh@microchip.com, embedded-discuss@lists.savoirfairelinux.net, Enguerrand de Ribaucourt Subject: [PATCH v3 4/5] net: dsa: microchip: use collision based back pressure mode Date: Thu, 30 May 2024 10:24:35 +0000 Message-Id: <20240530102436.226189-5-enguerrand.de-ribaucourt@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240530102436.226189-1-enguerrand.de-ribaucourt@savoirfairelinux.com> References: <20240530102436.226189-1-enguerrand.de-ribaucourt@savoirfairelinux.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Errata DS80000758 states that carrier sense back pressure mode can cause link down issues in 100BASE-TX half duplex mode. The datasheet also recommends to always use the collision based back pressure mode. Signed-off-by: Enguerrand de Ribaucourt --- drivers/net/dsa/microchip/ksz9477.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c index f8ad7833f5d9..343b9d7538e9 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -1299,6 +1299,9 @@ int ksz9477_setup(struct dsa_switch *ds) /* Enable REG_SW_MTU__2 reg by setting SW_JUMBO_PACKET */ ksz_cfg(dev, REG_SW_MAC_CTRL_1, SW_JUMBO_PACKET, true); + /* Use collision based back pressure mode. */ + ksz_cfg(dev, REG_SW_MAC_CTRL_1, SW_BACK_PRESSURE, false); + /* Now we can configure default MTU value */ ret = regmap_update_bits(ksz_regmap_16(dev), REG_SW_MTU__2, REG_SW_MTU_MASK, VLAN_ETH_FRAME_LEN + ETH_FCS_LEN); From patchwork Thu May 30 10:24:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Enguerrand de Ribaucourt X-Patchwork-Id: 13680133 X-Patchwork-Delegate: kuba@kernel.org Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) (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 EE6C9176AAE for ; Thu, 30 May 2024 10:25:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=208.88.110.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717064719; cv=none; b=MC3/xKxWGS49nk7U6gjYkUotBtdLoP54tuDlMpICEyzpkZAMptbfT99KrNGgZjtr2EB6AouW19HDuMK+kdQgdG9+gKreJ601yaC2WAdUCm9xTpkeHsXa1krxOc+2VDJhPDo48kRutjixZQYe+f1cNr2cV9CkyVKE8adKPZVVxY4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717064719; c=relaxed/simple; bh=T+XWsFi7Zp00QuXleTyFDfLRSGyq5aoe0Ao7ucW+MvM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nKHbosl7xcJHNLTPT9SVIQopuyEECjVh5bA9UtbjQceQn+3dLFkssWO6+kX5a/swL8xI8hcoH7SaEFd0afWy8YHxoNmxLIGaPJsqX4q3PN39j5ZnPnl9nosScaZtBoY+QUTiXrOURdGm/XiJu3DGvOCHRoGZQw0ORORe3CkAwSU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=savoirfairelinux.com; spf=pass smtp.mailfrom=savoirfairelinux.com; dkim=pass (2048-bit key) header.d=savoirfairelinux.com header.i=@savoirfairelinux.com header.b=EVWhdLlD; arc=none smtp.client-ip=208.88.110.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=savoirfairelinux.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=savoirfairelinux.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=savoirfairelinux.com header.i=@savoirfairelinux.com header.b="EVWhdLlD" Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 3206F9C32FC; Thu, 30 May 2024 06:25:14 -0400 (EDT) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10032) with ESMTP id 0IWIx_esQcaR; Thu, 30 May 2024 06:25:12 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id D61139C5847; Thu, 30 May 2024 06:25:12 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com D61139C5847 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1717064712; bh=tfhRbGUxBvcpFrVufTpKrccUBh0CLoH/U4j9Wubt0+k=; h=From:To:Date:Message-Id:MIME-Version; b=EVWhdLlD7OLpqBh6cWZLQoq9ejub6lktdhSYQzwvC0hxfFgEDrN8o6cprtXDseHSJ dFHgY8o4meYlapeeB4YxCRICYtejr91kJ6mWLGaS2Wfs/rJw1cfWkTi17qhV66uw0k PWXgcwkh6jaXglSdbMSqlCciVbj9wMooPV3NxJFL9GJy3+HRj/fLFzBr/l3Xh54tXl 22eoC24A8sliJ3vWH8Z7dZVMyIMm0lkfWLTRIG561G7pfqbfI8RkcELyFKvUae4Meo aKdNQid7PX2tiIVntogNBRZ1V32WeE38rwTizMYX3lBH4OUiAVpv1ukWDoA0NULEqz aqZ3XnCA0CHxA== X-Virus-Scanned: amavis at mail.savoirfairelinux.com Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10026) with ESMTP id ACq2z9obPSgR; Thu, 30 May 2024 06:25:12 -0400 (EDT) Received: from sfl-deribaucourt.rennes.sfl (lmontsouris-657-1-69-118.w80-15.abo.wanadoo.fr [80.15.101.118]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id EAC4E9C32FC; Thu, 30 May 2024 06:25:11 -0400 (EDT) From: Enguerrand de Ribaucourt To: netdev@vger.kernel.org Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, woojung.huh@microchip.com, embedded-discuss@lists.savoirfairelinux.net, Enguerrand de Ribaucourt Subject: [PATCH v3 5/5] net: dsa: microchip: monitor potential faults in half-duplex mode Date: Thu, 30 May 2024 10:24:36 +0000 Message-Id: <20240530102436.226189-6-enguerrand.de-ribaucourt@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240530102436.226189-1-enguerrand.de-ribaucourt@savoirfairelinux.com> References: <20240530102436.226189-1-enguerrand.de-ribaucourt@savoirfairelinux.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The errata DS80000754 recommends monitoring potential faults in half-duplex mode for the KSZ9477 familly. half-duplex is not very common so I just added a critical message when the fault conditions are detected. The switch can be expected to be unable to communicate anymore in these states and a software reset of the switch would be required which I did not implement. Signed-off-by: Enguerrand de Ribaucourt --- drivers/net/dsa/microchip/ksz9477.c | 34 +++++++++++++++++++++++++ drivers/net/dsa/microchip/ksz9477.h | 2 ++ drivers/net/dsa/microchip/ksz9477_reg.h | 8 ++++-- drivers/net/dsa/microchip/ksz_common.c | 7 +++++ drivers/net/dsa/microchip/ksz_common.h | 1 + 5 files changed, 50 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c index 343b9d7538e9..ea1c12304f7f 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -429,6 +429,40 @@ void ksz9477_freeze_mib(struct ksz_device *dev, int port, bool freeze) mutex_unlock(&p->mib.cnt_mutex); } +void ksz9477_errata_monitor(struct ksz_device *dev, int port, + u64 tx_late_col) +{ + u8 status; + u16 pqm; + u32 pmavbc; + + ksz_pread8(dev, port, REG_PORT_STATUS_0, &status); + if (!((status & PORT_INTF_SPEED_MASK) == PORT_INTF_SPEED_MASK) && + !(status & PORT_INTF_FULL_DUPLEX)) { + dev_warn_once(dev->dev, + "Half-duplex detected on port %d, transmission halt may occur\n", + port); + /* Errata DS80000754 recommends monitoring potential faults in + * half-duplex mode. The switch might not be able to communicate anymore + * in these states. + */ + if (tx_late_col != 0) { + /* Transmission halt with late collisions */ + dev_crit_ratelimited(dev->dev, + "TX late collisions detected, transmission may be halted on port %d\n", + port); + } + ksz_pread16(dev, port, REG_PORT_QM_TX_CNT_0__4, &pqm); + ksz_read32(dev, REG_PMAVBC, &pmavbc); + if (((pmavbc & PMAVBC_MASK) >> PMAVBC_SHIFT <= 0x580) || + ((pqm & PORT_QM_TX_CNT_M) >= 0x200)) { + /* Transmission halt with Half-Duplex and VLAN */ + dev_crit_ratelimited(dev->dev, + "resources out of limits, transmission may be halted\n"); + } + } +} + void ksz9477_port_init_cnt(struct ksz_device *dev, int port) { struct ksz_port_mib *mib = &dev->ports[port].mib; diff --git a/drivers/net/dsa/microchip/ksz9477.h b/drivers/net/dsa/microchip/ksz9477.h index ce1e656b800b..3312ef28e99c 100644 --- a/drivers/net/dsa/microchip/ksz9477.h +++ b/drivers/net/dsa/microchip/ksz9477.h @@ -36,6 +36,8 @@ int ksz9477_port_mirror_add(struct ksz_device *dev, int port, bool ingress, struct netlink_ext_ack *extack); void ksz9477_port_mirror_del(struct ksz_device *dev, int port, struct dsa_mall_mirror_tc_entry *mirror); +void ksz9477_errata_monitor(struct ksz_device *dev, int port, + u64 tx_late_col); void ksz9477_get_caps(struct ksz_device *dev, int port, struct phylink_config *config); int ksz9477_fdb_dump(struct ksz_device *dev, int port, diff --git a/drivers/net/dsa/microchip/ksz9477_reg.h b/drivers/net/dsa/microchip/ksz9477_reg.h index f3a205ee483f..3238b9748d0f 100644 --- a/drivers/net/dsa/microchip/ksz9477_reg.h +++ b/drivers/net/dsa/microchip/ksz9477_reg.h @@ -842,8 +842,7 @@ #define REG_PORT_STATUS_0 0x0030 -#define PORT_INTF_SPEED_M 0x3 -#define PORT_INTF_SPEED_S 3 +#define PORT_INTF_SPEED_MASK 0x0018 #define PORT_INTF_FULL_DUPLEX BIT(2) #define PORT_TX_FLOW_CTRL BIT(1) #define PORT_RX_FLOW_CTRL BIT(0) @@ -1167,6 +1166,11 @@ #define PORT_RMII_CLK_SEL BIT(7) #define PORT_MII_SEL_EDGE BIT(5) +#define REG_PMAVBC 0x03AC + +#define PMAVBC_MASK 0x7ff0000 +#define PMAVBC_SHIFT 16 + /* 4 - MAC */ #define REG_PORT_MAC_CTRL_0 0x0400 diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 1e0085cd9a9a..26e2fcd74ba8 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -1382,6 +1382,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .tc_cbs_supported = true, .ops = &ksz9477_dev_ops, .phylink_mac_ops = &ksz9477_phylink_mac_ops, + .phy_errata_9477 = true, .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, @@ -1416,6 +1417,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .num_ipms = 8, .ops = &ksz9477_dev_ops, .phylink_mac_ops = &ksz9477_phylink_mac_ops, + .phy_errata_9477 = true, .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, @@ -1450,6 +1452,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .num_ipms = 8, .ops = &ksz9477_dev_ops, .phylink_mac_ops = &ksz9477_phylink_mac_ops, + .phy_errata_9477 = true, .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, @@ -1540,6 +1543,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .tc_cbs_supported = true, .ops = &ksz9477_dev_ops, .phylink_mac_ops = &ksz9477_phylink_mac_ops, + .phy_errata_9477 = true, .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, @@ -1861,6 +1865,9 @@ void ksz_r_mib_stats64(struct ksz_device *dev, int port) pstats->rx_pause_frames = raw->rx_pause; spin_unlock(&mib->stats64_lock); + + if (dev->info->phy_errata_9477) + ksz9477_errata_monitor(dev, port, raw->tx_late_col); } void ksz88xx_r_mib_stats64(struct ksz_device *dev, int port) diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index c784fd23a993..ee7db46e469d 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -66,6 +66,7 @@ struct ksz_chip_data { bool tc_cbs_supported; const struct ksz_dev_ops *ops; const struct phylink_mac_ops *phylink_mac_ops; + bool phy_errata_9477; bool ksz87xx_eee_link_erratum; const struct ksz_mib_names *mib_names; int mib_cnt;