From nobody Sun May 19 13:07:53 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93E62C00A5A for ; Tue, 17 Jan 2023 23:32:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229482AbjAQXcx (ORCPT ); Tue, 17 Jan 2023 18:32:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230029AbjAQXbd (ORCPT ); Tue, 17 Jan 2023 18:31:33 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF04D8C92E; Tue, 17 Jan 2023 12:57:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673989036; x=1705525036; h=from:to:subject:date:message-id:in-reply-to:references: mime-version; bh=4MVjklp+WInBd0klfJLhEVo/AmyM+BveJwsJuTHar2g=; b=yXCbJKHNl0Q//BJshBsSc1Ah0dxISwVTKIh2sW94fIwOw5y5KN0QkLTI 3iVdgtd8z3hWrIQqLeHJcIwwiyxX9BKYmtQqlh5v8bXXbInny+dFIXOxD nEI9y9kEdSTbYXFMKsHLMvaCPLUWRdIrmtxJ+CODhgUIUgbnDk4Wwm7Pb tVev4QGvxT3UnnGaTPKVcDT9OJ01YGYv6l/i3/fsQHxoBZG4DWrNGD+bt R6yXNewM7+EDSOhbthR0dTBn2JHAAyIeTJmyvmjdIpKQSfjjmXeVT9QHJ aVmzXX6TDnD9dm4z6rkojihztE4cYP16xl9bekn/djE7uIA2cEQApARTm Q==; X-IronPort-AV: E=Sophos;i="5.97,224,1669100400"; d="scan'208";a="208210722" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Jan 2023 13:57:08 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 17 Jan 2023 13:57:08 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Tue, 17 Jan 2023 13:57:06 -0700 From: Jerry Ray To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , Russell King , , , , Jerry Ray Subject: [net-next: PATCH v7 1/7] dsa: lan9303: align dsa_switch_ops members Date: Tue, 17 Jan 2023 14:56:57 -0600 Message-ID: <20230117205703.25960-2-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230117205703.25960-1-jerry.ray@microchip.com> References: <20230117205703.25960-1-jerry.ray@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Whitespace preparatory patch, making the dsa_switch_ops table consistent. No code is added or removed. Signed-off-by: Jerry Ray --- drivers/net/dsa/lan9303-core.c | 38 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index 2e270b479143..f8f6f79052e3 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -1282,25 +1282,25 @@ static int lan9303_port_mdb_del(struct dsa_switch *= ds, int port, } =20 static const struct dsa_switch_ops lan9303_switch_ops =3D { - .get_tag_protocol =3D lan9303_get_tag_protocol, - .setup =3D lan9303_setup, - .get_strings =3D lan9303_get_strings, - .phy_read =3D lan9303_phy_read, - .phy_write =3D lan9303_phy_write, - .adjust_link =3D lan9303_adjust_link, - .get_ethtool_stats =3D lan9303_get_ethtool_stats, - .get_sset_count =3D lan9303_get_sset_count, - .port_enable =3D lan9303_port_enable, - .port_disable =3D lan9303_port_disable, - .port_bridge_join =3D lan9303_port_bridge_join, - .port_bridge_leave =3D lan9303_port_bridge_leave, - .port_stp_state_set =3D lan9303_port_stp_state_set, - .port_fast_age =3D lan9303_port_fast_age, - .port_fdb_add =3D lan9303_port_fdb_add, - .port_fdb_del =3D lan9303_port_fdb_del, - .port_fdb_dump =3D lan9303_port_fdb_dump, - .port_mdb_add =3D lan9303_port_mdb_add, - .port_mdb_del =3D lan9303_port_mdb_del, + .get_tag_protocol =3D lan9303_get_tag_protocol, + .setup =3D lan9303_setup, + .get_strings =3D lan9303_get_strings, + .phy_read =3D lan9303_phy_read, + .phy_write =3D lan9303_phy_write, + .adjust_link =3D lan9303_adjust_link, + .get_ethtool_stats =3D lan9303_get_ethtool_stats, + .get_sset_count =3D lan9303_get_sset_count, + .port_enable =3D lan9303_port_enable, + .port_disable =3D lan9303_port_disable, + .port_bridge_join =3D lan9303_port_bridge_join, + .port_bridge_leave =3D lan9303_port_bridge_leave, + .port_stp_state_set =3D lan9303_port_stp_state_set, + .port_fast_age =3D lan9303_port_fast_age, + .port_fdb_add =3D lan9303_port_fdb_add, + .port_fdb_del =3D lan9303_port_fdb_del, + .port_fdb_dump =3D lan9303_port_fdb_dump, + .port_mdb_add =3D lan9303_port_mdb_add, + .port_mdb_del =3D lan9303_port_mdb_del, }; =20 static int lan9303_register_switch(struct lan9303 *chip) --=20 2.17.1 From nobody Sun May 19 13:07:53 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4D37C00A5A for ; Tue, 17 Jan 2023 23:15:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229483AbjAQXPU (ORCPT ); Tue, 17 Jan 2023 18:15:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229662AbjAQXNc (ORCPT ); Tue, 17 Jan 2023 18:13:32 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8FF38CE72; Tue, 17 Jan 2023 12:57:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673989040; x=1705525040; h=from:to:subject:date:message-id:in-reply-to:references: mime-version; bh=l//9fOjFa2fPgl+Ydqe3nVGAlwfQjBnfvOtLXzxETz0=; b=ExtUB0+u2vyBYtLzZaRYG+kOq2ANdc1Bxhlwnr025aQioMHQgkMNV7Oo 1w4kyw/Db5q2CzC8Htpecw74vHjofb7NWR4FyNHSSuD4zol3wRw1LqQ3j 214kQ/s+KojdVL0j7zRcC8hZgKuv5K4kg487nJO609PSbAvQWfZ31MmKx 1fuMn3/l8knVDQa+d1t/wll0UyffO/UUk3Td7e/WMX7ViTetfvhw5efGo Hkmwv+AM+1i5MKlyorFay8uTArAiraVljv/cdzP2YU5ctK0IylvBEy88c m2YiNCh67iBltKUYWXz6iyP42ZSL26Vplz8XN7wHLqfgUPlz90xJsMOWf A==; X-IronPort-AV: E=Sophos;i="5.97,224,1669100400"; d="scan'208";a="197058703" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Jan 2023 13:57:11 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 17 Jan 2023 13:57:10 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Tue, 17 Jan 2023 13:57:08 -0700 From: Jerry Ray To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , Russell King , , , , Jerry Ray Subject: [net-next: PATCH v7 2/7] dsa: lan9303: move Turbo Mode bit init Date: Tue, 17 Jan 2023 14:56:58 -0600 Message-ID: <20230117205703.25960-3-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230117205703.25960-1-jerry.ray@microchip.com> References: <20230117205703.25960-1-jerry.ray@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In preparing to remove the .adjust_link api, I am moving the one-time initialization of the device's Turbo Mode bit into a different execution path. This code clears (disables) the Turbo Mode bit which is never used by this driver. Turbo Mode is a non-standard mode that would allow the 100Mbps RMII interface to run at 200Mbps. Signed-off-by: Jerry Ray --- drivers/net/dsa/lan9303-core.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index f8f6f79052e3..63f5c1ef65e2 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -902,6 +902,7 @@ static int lan9303_setup(struct dsa_switch *ds) { struct lan9303 *chip =3D ds->priv; int ret; + u32 reg; =20 /* Make sure that port 0 is the cpu port */ if (!dsa_is_cpu_port(ds, 0)) { @@ -909,6 +910,12 @@ static int lan9303_setup(struct dsa_switch *ds) return -EINVAL; } =20 + /* Virtual Phy: Remove Turbo 200Mbit mode */ + lan9303_read(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, ®); + + reg &=3D ~LAN9303_VIRT_SPECIAL_TURBO; + regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, reg); + ret =3D lan9303_setup_tagging(chip); if (ret) dev_err(chip->dev, "failed to setup port tagging %d\n", ret); @@ -1052,7 +1059,6 @@ static int lan9303_phy_write(struct dsa_switch *ds, i= nt phy, int regnum, static void lan9303_adjust_link(struct dsa_switch *ds, int port, struct phy_device *phydev) { - struct lan9303 *chip =3D ds->priv; int ctl; =20 if (!phy_is_pseudo_fixed_link(phydev)) @@ -1075,14 +1081,6 @@ static void lan9303_adjust_link(struct dsa_switch *d= s, int port, ctl &=3D ~BMCR_FULLDPLX; =20 lan9303_phy_write(ds, port, MII_BMCR, ctl); - - if (port =3D=3D chip->phy_addr_base) { - /* Virtual Phy: Remove Turbo 200Mbit mode */ - lan9303_read(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, &ctl); - - ctl &=3D ~LAN9303_VIRT_SPECIAL_TURBO; - regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, ctl); - } } =20 static int lan9303_port_enable(struct dsa_switch *ds, int port, --=20 2.17.1 From nobody Sun May 19 13:07:53 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DE3FC38147 for ; Tue, 17 Jan 2023 23:14:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229748AbjAQXON (ORCPT ); Tue, 17 Jan 2023 18:14:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229934AbjAQXNQ (ORCPT ); Tue, 17 Jan 2023 18:13:16 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 681D78CE48; Tue, 17 Jan 2023 12:57:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673989037; x=1705525037; h=from:to:subject:date:message-id:in-reply-to:references: mime-version; bh=7EEKO+T/AsKAYllVpBR1IF6jmvpXWkUA9M7SqcfZgMk=; b=j3Z9lxUt3D5xAl2yOg+W+QgzMrNkZQkUXPKpx7ZGvkdIbxsxKx9W2lsz mY30T89yRWtvSC504RE2eORO8KI09le9wTVeQNeeyINWL2URVL1+P134F Fzu2E6dj7YJaoBRp/+9NWXq75zGjWA0KN7BS+E2aj4IDCKjTskFT53O22 W1S2qTGn9pEyp9aYGUN4rDNTgKc0423+PNtYK4v9WQ/Tlu4+ygCejsnvi P8e1nqEHkIo4M7wVEBoAnLi4tDSFOErXUKVz7DL04yL4s/Q2a9ZT/iS96 zZIQggoNjo30QipykZS9tKVd1ipk6ElMY4WDhFcvDr/DM7B7ny99Bcdft A==; X-IronPort-AV: E=Sophos;i="5.97,224,1669100400"; d="scan'208";a="197211172" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Jan 2023 13:57:14 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 17 Jan 2023 13:57:13 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Tue, 17 Jan 2023 13:57:11 -0700 From: Jerry Ray To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , Russell King , , , , Jerry Ray Subject: [net-next: PATCH v7 3/7] dsa: lan9303: Add exception logic for read failure Date: Tue, 17 Jan 2023 14:56:59 -0600 Message-ID: <20230117205703.25960-4-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230117205703.25960-1-jerry.ray@microchip.com> References: <20230117205703.25960-1-jerry.ray@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" While it is highly unlikely a read will ever fail, This code fragment is now in a function that allows us to return an error code. A read failure here will cause the lan9303_probe to fail. Signed-off-by: Jerry Ray --- drivers/net/dsa/lan9303-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index 63f5c1ef65e2..66466d50d015 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -911,7 +911,9 @@ static int lan9303_setup(struct dsa_switch *ds) } =20 /* Virtual Phy: Remove Turbo 200Mbit mode */ - lan9303_read(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, ®); + ret =3D lan9303_read(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, ®); + if (ret) + return (ret); =20 reg &=3D ~LAN9303_VIRT_SPECIAL_TURBO; regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, reg); --=20 2.17.1 From nobody Sun May 19 13:07:53 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37EE5C38142 for ; Tue, 17 Jan 2023 23:32:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229536AbjAQXc0 (ORCPT ); Tue, 17 Jan 2023 18:32:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230039AbjAQXbf (ORCPT ); Tue, 17 Jan 2023 18:31:35 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E94FF8CE79; Tue, 17 Jan 2023 12:57:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673989040; x=1705525040; h=from:to:subject:date:message-id:in-reply-to:references: mime-version; bh=zwa4GW5jWlP5YXzoa6EZS1ONEyHsZM9zF0qwfkL82oY=; b=u/cPn3TBeaR7EUtcKm9aOx3pra/8vg/XJL8x7k6vollR0PPHlZabuPmD VUDMITc39AlgMjmA6KUcI3SPEuHrQeIKdmAtCwtC4JkAXAr7bdk+1YzHi wLm2+RExXuGDcIls924eXxfHlg/oVwaIEDdF/2Y6SpD4yHkAcowdxEIuq Vsk6B1AdrHaDAd3GqYeJx1rKTeZVjHkvI3bb5OVZUgEQKnZT3n2hKEBAO EESgYc+pnOdQTWKYstzYSZhB5y2guR8D9UTXP/nAvWEq0e5SkkxgXvVbQ 5bIFgbRFSkTL0HV69rlSgmn7cCGb5NyMwwCsYTYTKeuaJxFr4QzOlELzR w==; X-IronPort-AV: E=Sophos;i="5.97,224,1669100400"; d="scan'208";a="132797655" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Jan 2023 13:57:15 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 17 Jan 2023 13:57:15 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Tue, 17 Jan 2023 13:57:13 -0700 From: Jerry Ray To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , Russell King , , , , Jerry Ray Subject: [net-next: PATCH v7 4/7] dsa: lan9303: write reg only if necessary Date: Tue, 17 Jan 2023 14:57:00 -0600 Message-ID: <20230117205703.25960-5-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230117205703.25960-1-jerry.ray@microchip.com> References: <20230117205703.25960-1-jerry.ray@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" As the regmap_write() is over a slow bus that will sleep, we can speed up the boot-up time a bit by not bothering to clear a bit that is already clear. Signed-off-by: Jerry Ray --- drivers/net/dsa/lan9303-core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index 66466d50d015..a4decf42a002 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -915,8 +915,11 @@ static int lan9303_setup(struct dsa_switch *ds) if (ret) return (ret); =20 - reg &=3D ~LAN9303_VIRT_SPECIAL_TURBO; - regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, reg); + /* Clear the TURBO Mode bit if it was set. */ + if (reg & LAN9303_VIRT_SPECIAL_TURBO) { + reg &=3D ~LAN9303_VIRT_SPECIAL_TURBO; + regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, reg); + } =20 ret =3D lan9303_setup_tagging(chip); if (ret) --=20 2.17.1 From nobody Sun May 19 13:07:53 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46553C00A5A for ; Tue, 17 Jan 2023 23:14:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229853AbjAQXOZ (ORCPT ); Tue, 17 Jan 2023 18:14:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229936AbjAQXNQ (ORCPT ); Tue, 17 Jan 2023 18:13:16 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9FD58C929; Tue, 17 Jan 2023 12:57:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673989041; x=1705525041; h=from:to:subject:date:message-id:in-reply-to:references: mime-version; bh=1dySa7UmdtWanwrXlbKGP1PlLBaLqOsIW6dN4IkvW+c=; b=ZeHAp0yG1xcZoVuel4+QlpbmX3Ke80Y53snRSSKx0XWCHhRslUIyHjg1 pGvQl4jSdBEGsk1m/i9//agYLLCmImQxuD3h+iKQKcfLFLao18vTjez+e W8Sx6GvtINHMMp/sAgdExVI+PLoSb+JaBMoauvAcYhH93hwkpqJPcHIKf VvnaEQ8BpTzhqNqIJXBzolm7oYoBCgniZ6bGQBZ7KKiEDzr1eguCwacOx XJGBkByS68yDKRgcujB8TLOi9/Oi2Nonrz5UpBOgJLfNpqEEElNLr0a4F wC/+/RPxWdBgjtMqmi52ef07wMn1LNuCqn4Em4eMtHrZMR7K6iT7nNbjx w==; X-IronPort-AV: E=Sophos;i="5.97,224,1669100400"; d="scan'208";a="132797669" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Jan 2023 13:57:18 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 17 Jan 2023 13:57:17 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Tue, 17 Jan 2023 13:57:15 -0700 From: Jerry Ray To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , Russell King , , , , Jerry Ray Subject: [net-next: PATCH v7 5/7] dsa: lan9303: Port 0 is xMII port Date: Tue, 17 Jan 2023 14:57:01 -0600 Message-ID: <20230117205703.25960-6-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230117205703.25960-1-jerry.ray@microchip.com> References: <20230117205703.25960-1-jerry.ray@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In preparing to move the adjust_link logic into the phylink_mac_link_up api, change the macro used to check for the cpu port. In phylink_mac_link_up, the phydev pointer passed in for the CPU port is NULL, so we can't keep using phy_is_pseudo_fixed_link(phydev). Signed-off-by: Jerry Ray --- drivers/net/dsa/lan9303-core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index a4decf42a002..a4cc76423d4b 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -15,6 +15,9 @@ =20 #include "lan9303.h" =20 +/* For the LAN9303 and LAN9354, only port 0 is an XMII port. */ +#define IS_PORT_XMII(port) ((port) =3D=3D 0) + #define LAN9303_NUM_PORTS 3 =20 /* 13.2 System Control and Status Registers @@ -1066,7 +1069,11 @@ static void lan9303_adjust_link(struct dsa_switch *d= s, int port, { int ctl; =20 - if (!phy_is_pseudo_fixed_link(phydev)) + /* On this device, we are only interested in doing something here if + * this is an xMII port. All other ports are 10/100 phys using MDIO + * to control there link settings. + */ + if (!IS_PORT_XMII(port)) return; =20 ctl =3D lan9303_phy_read(ds, port, MII_BMCR); --=20 2.17.1 From nobody Sun May 19 13:07:53 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEC5EC00A5A for ; Tue, 17 Jan 2023 23:32:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230038AbjAQXco (ORCPT ); Tue, 17 Jan 2023 18:32:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230040AbjAQXbg (ORCPT ); Tue, 17 Jan 2023 18:31:36 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE7718CE7F; Tue, 17 Jan 2023 12:57:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673989041; x=1705525041; h=from:to:subject:date:message-id:in-reply-to:references: mime-version; bh=IW/243XeP8m7HEGadBjno8Oc4TYmpSpNcrwQQRkLL+o=; b=1UdTBsHmE6YxLjEAbwqIKbGT73DHeS1d8HRF1RQcpxK/bbXmOXe+zT9e xsEN9GhRFj2FzhdjPU3YSBGIZE/kYPX0+Hx/VSAdyPs0pXSFCjt5HUA5F uZNgaQUEit4gvAVSTH6BC+nGwZpqOFVYfLnXbiKvgNbK9dLwKHjcGlOQw 0+5Uqju+I8FbQlorSDUHFBDLHT57PRaBDiBwfiVOAz8AdRmiC1GsrSaY4 jQE+yUzJ/hVNKYC/M+b94YJwLwJ9aJonyntxW8OPGcuUN4xvEZ57Wha6s lX5gcQXXT+nTED4pixa1VXBCdfZNkKTN+GaWFXbc+ddD3pLslMXWle4WG w==; X-IronPort-AV: E=Sophos;i="5.97,224,1669100400"; d="scan'208";a="196226785" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Jan 2023 13:57:21 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 17 Jan 2023 13:57:19 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Tue, 17 Jan 2023 13:57:17 -0700 From: Jerry Ray To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , Russell King , , , , Jerry Ray Subject: [net-next: PATCH v7 6/7] dsa: lan9303: Migrate to PHYLINK Date: Tue, 17 Jan 2023 14:57:02 -0600 Message-ID: <20230117205703.25960-7-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230117205703.25960-1-jerry.ray@microchip.com> References: <20230117205703.25960-1-jerry.ray@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This patch replaces the adjust_link api with the phylink apis that provide equivalent functionality. The remaining functionality from the adjust_link is now covered in the phylink_mac_link_up api. Removes: .adjust_link Adds: .phylink_get_caps .phylink_mac_link_up Signed-off-by: Jerry Ray --- drivers/net/dsa/lan9303-core.c | 101 ++++++++++++++++++++++----------- 1 file changed, 69 insertions(+), 32 deletions(-) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index a4cc76423d4b..93ece212cac8 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -1064,37 +1064,6 @@ static int lan9303_phy_write(struct dsa_switch *ds, = int phy, int regnum, return chip->ops->phy_write(chip, phy, regnum, val); } =20 -static void lan9303_adjust_link(struct dsa_switch *ds, int port, - struct phy_device *phydev) -{ - int ctl; - - /* On this device, we are only interested in doing something here if - * this is an xMII port. All other ports are 10/100 phys using MDIO - * to control there link settings. - */ - if (!IS_PORT_XMII(port)) - return; - - ctl =3D lan9303_phy_read(ds, port, MII_BMCR); - - ctl &=3D ~BMCR_ANENABLE; - - if (phydev->speed =3D=3D SPEED_100) - ctl |=3D BMCR_SPEED100; - else if (phydev->speed =3D=3D SPEED_10) - ctl &=3D ~BMCR_SPEED100; - else - dev_err(ds->dev, "unsupported speed: %d\n", phydev->speed); - - if (phydev->duplex =3D=3D DUPLEX_FULL) - ctl |=3D BMCR_FULLDPLX; - else - ctl &=3D ~BMCR_FULLDPLX; - - lan9303_phy_write(ds, port, MII_BMCR, ctl); -} - static int lan9303_port_enable(struct dsa_switch *ds, int port, struct phy_device *phy) { @@ -1291,13 +1260,81 @@ static int lan9303_port_mdb_del(struct dsa_switch *= ds, int port, return 0; } =20 +static void lan9303_phylink_get_caps(struct dsa_switch *ds, int port, + struct phylink_config *config) +{ + struct lan9303 *chip =3D ds->priv; + + dev_dbg(chip->dev, "%s(%d) entered.", __func__, port); + + config->mac_capabilities =3D MAC_10 | MAC_100 | MAC_ASYM_PAUSE | + MAC_SYM_PAUSE; + + if (port =3D=3D 0) { + __set_bit(PHY_INTERFACE_MODE_RMII, + config->supported_interfaces); + __set_bit(PHY_INTERFACE_MODE_MII, + config->supported_interfaces); + } else { + __set_bit(PHY_INTERFACE_MODE_INTERNAL, + config->supported_interfaces); + /* Compatibility for phylib's default interface type when the + * phy-mode property is absent + */ + __set_bit(PHY_INTERFACE_MODE_GMII, + config->supported_interfaces); + } + + /* This driver does not make use of the speed, duplex, pause or the + * advertisement in its mac_config, so it is safe to mark this driver + * as non-legacy. + */ + config->legacy_pre_march2020 =3D false; +} + +static void lan9303_phylink_mac_link_up(struct dsa_switch *ds, int port, + unsigned int mode, + phy_interface_t interface, + struct phy_device *phydev, int speed, + int duplex, bool tx_pause, + bool rx_pause) +{ + u32 ctl; + + /* On this device, we are only interested in doing something here if + * this is the xMII port. All other ports are 10/100 phys using MDIO + * to control there link settings. + */ + if (!IS_PORT_XMII(port)) + return; + + ctl =3D lan9303_phy_read(ds, port, MII_BMCR); + + ctl &=3D ~BMCR_ANENABLE; + + if (speed =3D=3D SPEED_100) + ctl |=3D BMCR_SPEED100; + else if (speed =3D=3D SPEED_10) + ctl &=3D ~BMCR_SPEED100; + else + dev_err(ds->dev, "unsupported speed: %d\n", speed); + + if (duplex =3D=3D DUPLEX_FULL) + ctl |=3D BMCR_FULLDPLX; + else + ctl &=3D ~BMCR_FULLDPLX; + + lan9303_phy_write(ds, port, MII_BMCR, ctl); +} + static const struct dsa_switch_ops lan9303_switch_ops =3D { .get_tag_protocol =3D lan9303_get_tag_protocol, .setup =3D lan9303_setup, .get_strings =3D lan9303_get_strings, .phy_read =3D lan9303_phy_read, .phy_write =3D lan9303_phy_write, - .adjust_link =3D lan9303_adjust_link, + .phylink_get_caps =3D lan9303_phylink_get_caps, + .phylink_mac_link_up =3D lan9303_phylink_mac_link_up, .get_ethtool_stats =3D lan9303_get_ethtool_stats, .get_sset_count =3D lan9303_get_sset_count, .port_enable =3D lan9303_port_enable, --=20 2.17.1 From nobody Sun May 19 13:07:53 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A302AC00A5A for ; Tue, 17 Jan 2023 23:15:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229493AbjAQXP1 (ORCPT ); Tue, 17 Jan 2023 18:15:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229635AbjAQXNc (ORCPT ); Tue, 17 Jan 2023 18:13:32 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBD239AA8B; Tue, 17 Jan 2023 12:57:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673989044; x=1705525044; h=from:to:subject:date:message-id:in-reply-to:references: mime-version; bh=C5fCOlZ75pNlYBnCtI5JbqlChvo+KMflLyhKJDLKe4o=; b=v/LjfrMxThpW+NkUmEcSMLl1bpKgxyFav9UPZ2xWIaDTAlY0DFTlaKhd EfTi5eMqhNjCDfOj+QOTaLx5debiYqVs7MLKXZ5sin+df6hl+mgcIvqxH R7oP5wQzJ6EoZFWKh8YYdRZI7j3xwX1iP7iaqLQybrLZ4kwKeDftTBPxG KU4/8BkWoQ1SrUhCENFGoCMNIiEgO4ydgeX62Ytgi0OIfGVJ/fKVzXrtI 7e+8oMbIpc/F51JXKOzuHZ6mIk4Ka/UfeyiphCrPlueYLJBND+kJrJOuv qKdHJ+Kh1/0dsXIhS/oWxLrqgXN16CsVgAEIf0kiIarXrgIjMFT2yVYsB g==; X-IronPort-AV: E=Sophos;i="5.97,224,1669100400"; d="scan'208";a="196226791" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Jan 2023 13:57:23 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 17 Jan 2023 13:57:21 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Tue, 17 Jan 2023 13:57:19 -0700 From: Jerry Ray To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , Russell King , , , , Jerry Ray Subject: [net-next: PATCH v7 7/7] dsa: lan9303: Add flow ctrl in link_up Date: Tue, 17 Jan 2023 14:57:03 -0600 Message-ID: <20230117205703.25960-8-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230117205703.25960-1-jerry.ray@microchip.com> References: <20230117205703.25960-1-jerry.ray@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" While the prior patch moved the adjust_link code into the phylink_mac_link_up api, this patch cleans it up and adds the setting the port's flow control based on the phylink_mac_link_up input parameters. Signed-off-by: Jerry Ray --- drivers/net/dsa/lan9303-core.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index 93ece212cac8..fe8bf0faf6b7 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -53,6 +53,9 @@ #define LAN9303_MANUAL_FC_1 0x68 #define LAN9303_MANUAL_FC_2 0x69 #define LAN9303_MANUAL_FC_0 0x6a +# define LAN9303_BP_EN BIT(6) +# define LAN9303_RX_FC_EN BIT(2) +# define LAN9303_TX_FC_EN BIT(1) #define LAN9303_SWITCH_CSR_DATA 0x6b #define LAN9303_SWITCH_CSR_CMD 0x6c #define LAN9303_SWITCH_CSR_CMD_BUSY BIT(31) @@ -228,6 +231,13 @@ const struct regmap_access_table lan9303_register_set = =3D { }; EXPORT_SYMBOL(lan9303_register_set); =20 +/* Flow Control registers indexed by port number */ +static unsigned int flow_ctl_reg[] =3D { + LAN9303_MANUAL_FC_0, + LAN9303_MANUAL_FC_1, + LAN9303_MANUAL_FC_2 +}; + static int lan9303_read(struct regmap *regmap, unsigned int offset, u32 *r= eg) { int ret, i; @@ -1299,7 +1309,9 @@ static void lan9303_phylink_mac_link_up(struct dsa_sw= itch *ds, int port, int duplex, bool tx_pause, bool rx_pause) { + struct lan9303 *chip =3D ds->priv; u32 ctl; + u32 reg; =20 /* On this device, we are only interested in doing something here if * this is the xMII port. All other ports are 10/100 phys using MDIO @@ -1308,23 +1320,23 @@ static void lan9303_phylink_mac_link_up(struct dsa_= switch *ds, int port, if (!IS_PORT_XMII(port)) return; =20 + /* Disable auto-negotiation and force the speed/duplex settings. */ ctl =3D lan9303_phy_read(ds, port, MII_BMCR); - - ctl &=3D ~BMCR_ANENABLE; - + ctl &=3D ~(BMCR_ANENABLE | BMCR_SPEED100 | BMCR_FULLDPLX); if (speed =3D=3D SPEED_100) ctl |=3D BMCR_SPEED100; - else if (speed =3D=3D SPEED_10) - ctl &=3D ~BMCR_SPEED100; - else - dev_err(ds->dev, "unsupported speed: %d\n", speed); - if (duplex =3D=3D DUPLEX_FULL) ctl |=3D BMCR_FULLDPLX; - else - ctl &=3D ~BMCR_FULLDPLX; - lan9303_phy_write(ds, port, MII_BMCR, ctl); + + /* Force the flow control settings. */ + lan9303_read(chip->regmap, flow_ctl_reg[port], ®); + reg &=3D ~(LAN9303_BP_EN | LAN9303_RX_FC_EN | LAN9303_TX_FC_EN); + if (rx_pause) + reg |=3D (LAN9303_RX_FC_EN | LAN9303_BP_EN); + if (tx_pause) + reg |=3D LAN9303_TX_FC_EN; + regmap_write(chip->regmap, flow_ctl_reg[port], reg); } =20 static const struct dsa_switch_ops lan9303_switch_ops =3D { --=20 2.17.1