From nobody Mon Sep 15 21:41:12 2025 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 2E70FC54EBE for ; Mon, 9 Jan 2023 21:19:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237908AbjAIVTt (ORCPT ); Mon, 9 Jan 2023 16:19:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237496AbjAIVTU (ORCPT ); Mon, 9 Jan 2023 16:19:20 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1FA4DFD4; Mon, 9 Jan 2023 13:18:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673299136; x=1704835136; h=from:to:subject:date:message-id:in-reply-to:references: mime-version; bh=br/M5WmvwdwxFySfGnmU52+djJ0iOGc1/k2tY+9cOwU=; b=D59hyTiEax65gQWYuc8uameM98iwiTDW6Efm7LGXNhyDmL3IBO7n9nHt 1tqLzgCPtPw7gZP3YtESDvsx/GyrfnKsM5cbVKVHd+cpC3fs0BrWMiNvi Q6ZwShfDNmH0ooOjNrtIBMI8Qmhu/ZgQAUWtrZOYq0AMyYMwIZZgLa5l0 umOiNaSouvxbB4gdq10y6d8dZ3fchEzk4dASRyKbbi5MdZMgoAA0MHP8E cJNMswyyvuDS4D6tyNQNpNNzIKnRAD8/0/r60auR49yNGkgm4YZgH/0jO CGyMVnEpqTknInH89cFa5O3MSiieFcFbyt1jN9YFCbGRCe2BMdpW9WNbg Q==; X-IronPort-AV: E=Sophos;i="5.96,313,1665471600"; d="scan'208";a="131543878" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 09 Jan 2023 14:18:56 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) 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.16; Mon, 9 Jan 2023 14:18:55 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Mon, 9 Jan 2023 14:18:53 -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: [PATCH net-next v6 1/6] dsa: lan9303: align dsa_switch_ops members Date: Mon, 9 Jan 2023 15:18:44 -0600 Message-ID: <20230109211849.32530-2-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230109211849.32530-1-jerry.ray@microchip.com> References: <20230109211849.32530-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 Reviewed-by: Florian Fainelli Reviewed-by: Vladimir Oltean --- v4->v5: changed patch title to be less generic Addressed space-tab issue missed in the initial patch. --- 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 80f07bd20593..5a21fc96d479 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -1280,25 +1280,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 Mon Sep 15 21:41:12 2025 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 872F3C54EBD for ; Mon, 9 Jan 2023 21:19:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237920AbjAIVTy (ORCPT ); Mon, 9 Jan 2023 16:19:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237545AbjAIVTU (ORCPT ); Mon, 9 Jan 2023 16:19:20 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0D2C193; Mon, 9 Jan 2023 13:19:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673299143; x=1704835143; h=from:to:subject:date:message-id:in-reply-to:references: mime-version; bh=qk7EXgI2QvbLbQWUvseiawTbqOJcT8gGauJRmP837Hw=; b=hGefZ7UvoinO80K09A3YGXyk08JxrlsHvtmXbjd1trt4p5j+kGw2+rIE nWZz0HAANcclN4fZbC/XlxM8ZWQ3EOEM6bhMSUY1h72gbjKpPckw2Saj3 FrWAZXFltRs2nf+Huj6WKKto6/l0gXMRdKTrtYTUyod89lXxwVPQYieYN Xd7hI54iiEIXz7I4BwiDqIz4hN22hWzTIbrVIg+phZo9dZGE+wbQ1UgyT 3jrwQPKWzZG3BALOkE628JbplOy1gSWbVWUYe0G4dsio+Gsc/Fyehtmhc 7dNTZQLs+z1ARRBotmHkgEfSkt0+QTICN4tNJ26MajINmp9HfNVO6M/fe g==; X-IronPort-AV: E=Sophos;i="5.96,313,1665471600"; d="scan'208";a="131543894" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 09 Jan 2023 14:19:02 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) 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; Mon, 9 Jan 2023 14:18:58 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Mon, 9 Jan 2023 14:18:56 -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: [PATCH net-next v6 2/6] dsa: lan9303: move Turbo Mode bit init Date: Mon, 9 Jan 2023 15:18:45 -0600 Message-ID: <20230109211849.32530-3-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230109211849.32530-1-jerry.ray@microchip.com> References: <20230109211849.32530-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 | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index 5a21fc96d479..50470fb09cb4 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -886,6 +886,12 @@ static int lan9303_check_device(struct lan9303 *chip) return ret; } =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); + return 0; } =20 @@ -1050,7 +1056,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)) @@ -1073,14 +1078,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 Mon Sep 15 21:41:12 2025 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 3FB4BC54EBD for ; Mon, 9 Jan 2023 21:20:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237929AbjAIVT6 (ORCPT ); Mon, 9 Jan 2023 16:19:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237554AbjAIVTV (ORCPT ); Mon, 9 Jan 2023 16:19:21 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EDCC189; Mon, 9 Jan 2023 13:19:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673299144; x=1704835144; h=from:to:subject:date:message-id:in-reply-to:references: mime-version; bh=VxkEKNZWJ3KcbW8rhbq+3YllhYbn54Q2UHPI5yThc9c=; b=rLjjGqJ9wClvDy/rJaz7WXhSGdZ0W14ay/pj/VXLOU1VCr1ieBLr3Iqi TVhWDIlQqQ0OUu0SGYtaafMVobiIaMZXXuF0Q3fkfAivFZZtY4Xrp5BHU RcjwJC2J4USKjkDyQ9j2q74fC8kdmgkYBI80VVRzOGfLkNU4jiitkfdly 0a+dX8HsfcgefJMJhbYY2/IocicznELetZBmDwHGaoGxifXrX5Iqphmq/ SITqg3j+0sGnOQaP/aEhNbJ+8l2xFjaN2Hji4QBp++dGRoCVdofeGgwzV EGjJv2Gvb8Xpf750jC2zd9g34qZfEi6XyYPm5R8jeaUzqbAwCd5oS40fP w==; X-IronPort-AV: E=Sophos;i="5.96,313,1665471600"; d="scan'208";a="131543896" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 09 Jan 2023 14:19:03 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) 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; Mon, 9 Jan 2023 14:19:01 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Mon, 9 Jan 2023 14:18:59 -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: [PATCH net-next v6 3/6] dsa: lan9303: Add exception logic for read failure Date: Mon, 9 Jan 2023 15:18:46 -0600 Message-ID: <20230109211849.32530-4-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230109211849.32530-1-jerry.ray@microchip.com> References: <20230109211849.32530-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 50470fb09cb4..8eee340f6464 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -887,7 +887,9 @@ static int lan9303_check_device(struct lan9303 *chip) } =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 Mon Sep 15 21:41:12 2025 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 AB873C54EBD for ; Mon, 9 Jan 2023 21:20:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237931AbjAIVUC (ORCPT ); Mon, 9 Jan 2023 16:20:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237557AbjAIVTV (ORCPT ); Mon, 9 Jan 2023 16:19:21 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 692E619D; Mon, 9 Jan 2023 13:19:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673299145; x=1704835145; h=from:to:subject:date:message-id:in-reply-to:references: mime-version; bh=+spUW6W7ItozH7ki1a6AOa72sASOb3/uSrDwr95CuuI=; b=fQKl1gKINI6V7utDwLl94rarT2dR6jCM5YyetMrIBKQeNLrXN28Hnbhe 9eRPlYbkRXdWVNKvKNVGFLzv1ys+W10bLTdGZLNOd2YzmCPyuNvVSCx2j czmcUPmMaoJD93ze6S6s0skaSGCyENVBWv9s1aIxz+mq2THbtoemKl1jO 5XQH6ZbU5YGiEhW8Hjl+qKTECn9C00n9QsnX+DJ0b+K+xbkhB1SAwy9ld qpg25VjSHrgkdm2BLu/+o9Ec9westopqqtNIQoU8ofmtRy5sIIA7LHhbU ldPIvBlU7fQW+LwVfWENUR5bfbQyDiijo985Q6QzUG+lwMYtwbfqdS0f+ g==; X-IronPort-AV: E=Sophos;i="5.96,313,1665471600"; d="scan'208";a="131543910" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 09 Jan 2023 14:19:04 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) 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; Mon, 9 Jan 2023 14:19:04 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Mon, 9 Jan 2023 14:19:01 -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: [PATCH net-next v6 4/6] dsa: lan9303: write reg only if necessary Date: Mon, 9 Jan 2023 15:18:47 -0600 Message-ID: <20230109211849.32530-5-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230109211849.32530-1-jerry.ray@microchip.com> References: <20230109211849.32530-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 8eee340f6464..792ce6a26a6a 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -891,8 +891,11 @@ static int lan9303_check_device(struct lan9303 *chip) 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 return 0; } --=20 2.17.1 From nobody Mon Sep 15 21:41:12 2025 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 B58EAC54EBD for ; Mon, 9 Jan 2023 21:20:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237955AbjAIVUI (ORCPT ); Mon, 9 Jan 2023 16:20:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237699AbjAIVT2 (ORCPT ); Mon, 9 Jan 2023 16:19:28 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E67EF01D; Mon, 9 Jan 2023 13:19:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673299152; x=1704835152; h=from:to:subject:date:message-id:in-reply-to:references: mime-version; bh=J1yPTJ30ftyyvOnC2+2vUGnUMmEFmadFpDvwb82hEIM=; b=ULHb+XzkpAZU1iMyNq8LWdweTltsPOzE8qfHkTQV9VN+AyqN5DdpoeK7 9t0GcIv4G2LDODqvi0ITX2ZN0vMxHU8+6/e39YYVAffbhXYlp0ostjTTK 5TCZXv73oEJHkz7Nb7ASUBZYisvVEORCO4g7e3rBgIkg08/EWM6Ss2cUM LzWM0j+N/0f+1aPaYyMUczRpm5+pIMs2kjsqV9T99C8ol36CM/rpKGB4A IPsW/29hcGtmY82Qf0hgyOo+DQtrxu4B/8XQx9CDWrlWsv+IXIQ6+PVZs 7FizB767DuzqkXmjtOkp2QQ0m//zwl2jdvNth59qRF9P0UyEiNKpAFPB4 A==; X-IronPort-AV: E=Sophos;i="5.96,313,1665471600"; d="scan'208";a="131543916" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 09 Jan 2023 14:19:11 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) 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; Mon, 9 Jan 2023 14:19:07 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Mon, 9 Jan 2023 14:19:04 -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: [PATCH net-next v6 5/6] dsa: lan9303: Port 0 is xMII port Date: Mon, 9 Jan 2023 15:18:48 -0600 Message-ID: <20230109211849.32530-6-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230109211849.32530-1-jerry.ray@microchip.com> References: <20230109211849.32530-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 --- v5->v6: Using port 0 to identify the xMII port on the LAN9303. --- drivers/net/dsa/lan9303-core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index 792ce6a26a6a..7be4c491e5d9 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -1063,7 +1063,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 (port !=3D 0) return; =20 ctl =3D lan9303_phy_read(ds, port, MII_BMCR); --=20 2.17.1 From nobody Mon Sep 15 21:41:12 2025 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 EDA77C54EBD for ; Mon, 9 Jan 2023 21:20:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237765AbjAIVUQ (ORCPT ); Mon, 9 Jan 2023 16:20:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237709AbjAIVT2 (ORCPT ); Mon, 9 Jan 2023 16:19:28 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0BAFEA0; Mon, 9 Jan 2023 13:19:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673299152; x=1704835152; h=from:to:subject:date:message-id:in-reply-to:references: mime-version; bh=bF71XwdfkyXFfdauaOthhsM1+Sz7taE1BuvslIS1rog=; b=N859cFPKWrhNX/gvtgr60t7pb9k5ca1Ue24sqUGDTBac3ExkLZbbk+RT cli7BLymxjeUe5GsrJxcyyvU8j+Yfi4SuQN3I+QCntOGxe0HcNoawGve3 E3oVnjZgMlfvuCLIrMroh98LE0zg/7m15X/JodEyjGD3UnyhcJFIrz1Jb 28+2mFr8vaefihLgjw0c5kk197RWY17f2177SSsNM0re1veKocuNSI1VD 6LEcOyRba749TtDarPWX0kcQbZv70fKqb6Te7DlLaFu14UUA25maSfunb hl55rDjAhKAy3umFrQOqwhREQsnh8PtP8VnHM4NBlZi7spkaw36nOKwyH A==; X-IronPort-AV: E=Sophos;i="5.96,313,1665471600"; d="scan'208";a="196049306" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 09 Jan 2023 14:19:11 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 9 Jan 2023 14:19:09 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Mon, 9 Jan 2023 14:19:07 -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: [PATCH net-next v6 6/6] dsa: lan9303: Migrate to PHYLINK Date: Mon, 9 Jan 2023 15:18:49 -0600 Message-ID: <20230109211849.32530-7-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230109211849.32530-1-jerry.ray@microchip.com> References: <20230109211849.32530-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 --- v5->v6: - Moved to using port number to identify xMII port for the LAN9303. v4->v5: - Added various prep patches to better show the movement of the logic. v3->v4: - Reworked the implementation to preserve the adjust_link functionality by including it in the phylink_mac_link_up api. v2->v3: Added back in disabling Turbo Mode on the CPU MII interface. Removed the unnecessary clearing of the phy supported interfaces. --- 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 7be4c491e5d9..e514fff81af6 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -1058,37 +1058,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 (port !=3D 0) - 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) { @@ -1285,13 +1254,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 (port !=3D 0) + 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