From nobody Mon Sep 15 00:05:49 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 059D6C004D4 for ; Thu, 19 Jan 2023 10:02:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229606AbjASKCx (ORCPT ); Thu, 19 Jan 2023 05:02:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230269AbjASKCb (ORCPT ); Thu, 19 Jan 2023 05:02:31 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2477D6CCC7; Thu, 19 Jan 2023 02:02: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=1674122541; x=1705658541; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BTaC+eTDiqpxNaBodV9SnvUdwz1kIcjygsdvDJtO7y0=; b=ZgAS2VtMnrx4PBwaITSkU79qF32+HWwysjWO/UIJLN8QwYLb8WkTI3G0 smBKQ8NXvyoaBTW9rfSLOeOQGYohpeiVgZrKjLAornZ2pXsUxuwL/9k9L VC54VXWYO0RJ4VmymSKqL71Uihx/nfOp3OFh+kkqstROp5eRP9NfTNkMh 6fvj/6R/WD7MQMNY/aY9rHq6MebrANTUCopTL7yAq4fZoj9Cb5PlDWnXn V3DA0fS+A78jyjhOedmXZazSTT052yecXIpBmfnmSBSgeW8XhXc+oz/ka 6uv8Vdlu+EMoKkNeHoC7PxP4UtrJsr+4mnroIBhre+HVB4XXKAEVq4pIj w==; X-IronPort-AV: E=Sophos;i="5.97,228,1669100400"; d="scan'208";a="197274452" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 19 Jan 2023 03:02:20 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) 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; Thu, 19 Jan 2023 03:02:20 -0700 Received: from che-dk-unglab44lx.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 19 Jan 2023 03:02:17 -0700 From: Pavithra Sathyanarayanan To: , CC: , , , , , Subject: [PATCH net-next 1/3] net: lan743x: remove unwanted interface select settings Date: Tue, 17 Jan 2023 19:46:12 +0530 Message-ID: <20230117141614.4411-2-Pavithra.Sathyanarayanan@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230117141614.4411-1-Pavithra.Sathyanarayanan@microchip.com> References: <20230117141614.4411-1-Pavithra.Sathyanarayanan@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Remove the MII/RGMII Selection settings in driver as it is preset by the EEPROM and has the required configurations before the driver loads for LAN743x. Signed-off-by: Pavithra Sathyanarayanan --- drivers/net/ethernet/microchip/lan743x_main.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/et= hernet/microchip/lan743x_main.c index e205edf477de..c4d16f4654b5 100644 --- a/drivers/net/ethernet/microchip/lan743x_main.c +++ b/drivers/net/ethernet/microchip/lan743x_main.c @@ -1418,14 +1418,6 @@ static void lan743x_phy_link_status_change(struct ne= t_device *netdev) =20 data =3D lan743x_csr_read(adapter, MAC_CR); =20 - /* set interface mode */ - if (phy_interface_is_rgmii(phydev)) - /* RGMII */ - data &=3D ~MAC_CR_MII_EN_; - else - /* GMII */ - data |=3D MAC_CR_MII_EN_; - /* set duplex mode */ if (phydev->duplex) data |=3D MAC_CR_DPX_; --=20 2.25.1 From nobody Mon Sep 15 00:05:49 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 BCF1CC38142 for ; Thu, 19 Jan 2023 10:03:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230305AbjASKDZ (ORCPT ); Thu, 19 Jan 2023 05:03:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230291AbjASKCg (ORCPT ); Thu, 19 Jan 2023 05:02:36 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62B9A53E41; Thu, 19 Jan 2023 02:02:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1674122548; x=1705658548; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QjW6uTTrCngsKFsBw4FCaTlM6YMMp5h8Uj4gd/whf9E=; b=UVzXsZOEZYEiJy1Kq1giAw5fN35pfhIMBYj4t0KztkGwkse47HJSGxLo qhtI6OhVWagaLHfANci6nMBDxlHFxO/UOUggRNBR/MsCW5kJrnxmq95kd 3EfZOTAXMbNBWoGUMQDQB6cMLoIEisbpg7DLdyGcBHKlV5flaKn+rSRIf spxQmqXWoCJua02SEyBZA35rNCUA3GHXXJtraJme/0NOKEh0OljUHDOCm sGdGn/vGVfTxarewHnyGv4BsnaTuSkREza6YtMcsdViHz9dsQWDAFZTtC m4ncpxkHhteW56szIp87zKgV6ijfWC0FtWkS28LrH0Ri2I147xms7Ui6n g==; X-IronPort-AV: E=Sophos;i="5.97,228,1669100400"; d="scan'208";a="133088671" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 19 Jan 2023 03:02:26 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) 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; Thu, 19 Jan 2023 03:02:25 -0700 Received: from che-dk-unglab44lx.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 19 Jan 2023 03:02:22 -0700 From: Pavithra Sathyanarayanan To: , CC: , , , , , Subject: [PATCH net-next 2/3] net: lan743x: add generic implementation for phy interface selection Date: Tue, 17 Jan 2023 19:46:13 +0530 Message-ID: <20230117141614.4411-3-Pavithra.Sathyanarayanan@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230117141614.4411-1-Pavithra.Sathyanarayanan@microchip.com> References: <20230117141614.4411-1-Pavithra.Sathyanarayanan@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add logic to read the Phy interface from MAC_CR register for LAN743x driver. Checks for the LAN7430/31 or pci11x1x devices and the adapter interface is updated accordingly. For LAN7431, adapter interface is set based on Bit 19 of MAC_CR register as MII or RGMII which removes the forced RGMII/GMII configurations in lan743x_phy_open(). Signed-off-by: Pavithra Sathyanarayanan --- drivers/net/ethernet/microchip/lan743x_main.c | 31 ++++++++++++++----- drivers/net/ethernet/microchip/lan743x_main.h | 1 + 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/et= hernet/microchip/lan743x_main.c index c4d16f4654b5..fe3026ed6f03 100644 --- a/drivers/net/ethernet/microchip/lan743x_main.c +++ b/drivers/net/ethernet/microchip/lan743x_main.c @@ -1469,6 +1469,24 @@ static void lan743x_phy_close(struct lan743x_adapter= *adapter) netdev->phydev =3D NULL; } =20 +static void lan743x_phy_interface_select(struct lan743x_adapter *adapter) +{ + u32 id_rev; + u32 data; + + data =3D lan743x_csr_read(adapter, MAC_CR); + id_rev =3D adapter->csr.id_rev & ID_REV_ID_MASK_; + + if (adapter->is_pci11x1x && adapter->is_sgmii_en) + adapter->phy_interface =3D PHY_INTERFACE_MODE_SGMII; + else if (id_rev =3D=3D ID_REV_ID_LAN7430_) + adapter->phy_interface =3D PHY_INTERFACE_MODE_GMII; + else if ((id_rev =3D=3D ID_REV_ID_LAN7431_) && (data & MAC_CR_MII_EN_)) + adapter->phy_interface =3D PHY_INTERFACE_MODE_MII; + else + adapter->phy_interface =3D PHY_INTERFACE_MODE_RGMII; +} + static int lan743x_phy_open(struct lan743x_adapter *adapter) { struct net_device *netdev =3D adapter->netdev; @@ -1486,14 +1504,11 @@ static int lan743x_phy_open(struct lan743x_adapter = *adapter) if (!phydev) goto return_error; =20 - if (adapter->is_pci11x1x) - ret =3D phy_connect_direct(netdev, phydev, - lan743x_phy_link_status_change, - PHY_INTERFACE_MODE_RGMII); - else - ret =3D phy_connect_direct(netdev, phydev, - lan743x_phy_link_status_change, - PHY_INTERFACE_MODE_GMII); + lan743x_phy_interface_select(adapter); + + ret =3D phy_connect_direct(netdev, phydev, + lan743x_phy_link_status_change, + adapter->phy_interface); if (ret) goto return_error; } diff --git a/drivers/net/ethernet/microchip/lan743x_main.h b/drivers/net/et= hernet/microchip/lan743x_main.h index 8438c3dbcf36..52609fc13ad9 100644 --- a/drivers/net/ethernet/microchip/lan743x_main.h +++ b/drivers/net/ethernet/microchip/lan743x_main.h @@ -1042,6 +1042,7 @@ struct lan743x_adapter { #define LAN743X_ADAPTER_FLAG_OTP BIT(0) u32 flags; u32 hw_cfg; + phy_interface_t phy_interface; }; =20 #define LAN743X_COMPONENT_FLAG_RX(channel) BIT(20 + (channel)) --=20 2.25.1 From nobody Mon Sep 15 00:05:49 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 4404BC004D4 for ; Thu, 19 Jan 2023 10:03:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229987AbjASKDW (ORCPT ); Thu, 19 Jan 2023 05:03:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230295AbjASKCi (ORCPT ); Thu, 19 Jan 2023 05:02:38 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB58467796; Thu, 19 Jan 2023 02:02:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1674122551; x=1705658551; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=t2d822SisjWrAgMVP+CU+3S3ocEmxglFWNbEHNbMl9M=; b=RiUTPqaylPW6iZzKPgU8X3OlfsK7bcbmpcDzb1RkHj/FQ5Pk1q6nKlGZ RIZb9jiCwIUG2ch4M0R9i3fappUio9C9dypTBk18g33Q0+cCtYmoiitF+ IQIuVzsUU4Py0rMq3XVba6mH8+KSG0D8ECJpq9uypB//pFvCJwN7MVIzv guteerVL/F5SknlkPN5zd8FdUGhhPrBLzd1qZsC6CqJObxS2EEOj/CPjn O+2JyUv4LAW2NQu+0Gpq6TBLG1QghvenK2FdtokJkyodKDwVSkuvilQd5 0cOvYPrfDFnPpJ2XU1hMPKbf5y2I6Zqo22bRgYRcsFhE0rLmivNmgHCLU A==; X-IronPort-AV: E=Sophos;i="5.97,228,1669100400"; d="scan'208";a="133088692" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 19 Jan 2023 03:02:30 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) 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; Thu, 19 Jan 2023 03:02:29 -0700 Received: from che-dk-unglab44lx.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 19 Jan 2023 03:02:26 -0700 From: Pavithra Sathyanarayanan To: , CC: , , , , , Subject: [PATCH net-next 3/3] net: lan743x: add fixed phy support for LAN7431 device Date: Tue, 17 Jan 2023 19:46:14 +0530 Message-ID: <20230117141614.4411-4-Pavithra.Sathyanarayanan@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230117141614.4411-1-Pavithra.Sathyanarayanan@microchip.com> References: <20230117141614.4411-1-Pavithra.Sathyanarayanan@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add fixed_phy support at 1Gbps full duplex for the lan7431 device if a phy not found over MDIO. Tested with a MAC to MAC connection from LAN7431 to a KSZ9893 switch. This avoids the Driver open error in LAN743x. TX delay and internal CLK125 generation is already enabled in EEPROM. Signed-off-by: Pavithra Sathyanarayanan --- drivers/net/ethernet/microchip/lan743x_main.c | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/et= hernet/microchip/lan743x_main.c index fe3026ed6f03..b5add1c5fa06 100644 --- a/drivers/net/ethernet/microchip/lan743x_main.c +++ b/drivers/net/ethernet/microchip/lan743x_main.c @@ -1491,6 +1491,11 @@ static int lan743x_phy_open(struct lan743x_adapter *= adapter) { struct net_device *netdev =3D adapter->netdev; struct lan743x_phy *phy =3D &adapter->phy; + struct fixed_phy_status fphy_status =3D { + .link =3D 1, + .speed =3D SPEED_1000, + .duplex =3D DUPLEX_FULL, + }; struct phy_device *phydev; int ret =3D -EIO; =20 @@ -1501,8 +1506,19 @@ static int lan743x_phy_open(struct lan743x_adapter *= adapter) if (!phydev) { /* try internal phy */ phydev =3D phy_find_first(adapter->mdiobus); - if (!phydev) - goto return_error; + if (!phydev) { + if ((adapter->csr.id_rev & ID_REV_ID_MASK_) =3D=3D + ID_REV_ID_LAN7431_) { + phydev =3D fixed_phy_register(PHY_POLL, + &fphy_status, NULL); + if (IS_ERR(phydev)) { + netdev_err(netdev, "No PHY/fixed_PHY found\n"); + return -EIO; + } + } else { + goto return_error; + } + } =20 lan743x_phy_interface_select(adapter); =20 --=20 2.25.1