From patchwork Fri Jul 21 06:00:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raju Lakkaraju X-Patchwork-Id: 123571 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp3586818vqt; Thu, 20 Jul 2023 23:06:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlHS0wEfZW9FLFpAaqpQNUZZXlY7n+9o1QjbwNBXke58Np3jcOw1asJ47HeGzfG2N5pwLhlB X-Received: by 2002:a05:6870:7022:b0:1ba:2c39:18e8 with SMTP id u34-20020a056870702200b001ba2c3918e8mr1214097oae.46.1689919592959; Thu, 20 Jul 2023 23:06:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689919592; cv=none; d=google.com; s=arc-20160816; b=xmL8lAs4/yt6AIBNlrCWKVm07QkFOAs0GAISYaShJ9OKdI9L9j9NYdFojJgOdg8cY5 ayg8qg1Wk3qNRvaNZOXDunVpo97LWYj/Try5hYbqOp+VHC3f46WNjJ4c2Ml9eSUk1U82 BcLulA2Xi5R8jdh0GZohcFfGrevKOYTOo/oHpeDKQHGZo3qYKs4Av9B/6HVLiwvhnsdf LowAape+Op2wB6LUJWtz+h7oYM22E26uCrAh8qc9n4d5gh+xb9ruH+dC2la4/NHcE2Dk Fm7OmtufAqo/h7eX3iAm0tK4Ywt1yX4VVrbvsovsbrZhbFIzJhH+FFxIvknYRyjAB+Rn a80g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3hcFiO/3u4pbr6phQhQFTfsQZLoF9oplNsotsZLcddY=; fh=qv6R2IaILI1S1xEIxOZzAcF4rN0hGtVsF9kjKc0mAD0=; b=pIX1xkj97dmDX9deY00tyAPKfQzsUiavXC2RLORWjI8pH6xDGIKS6wNqOWAqVrxZKH W/Yp2Pijh5BmPMmfoZGrRss/oqHbx6erJv+LMnQjx8w13bM4pVYDBUstGKhfurJQqX3X KPAK+jDI/b4FaSo7HVXrNqvqoD8RkfZVUd2AvAnGVuHCuw4ZV9y7eA38iiCrC/n4m1hP w2RyOggeDbMSuVaDp6gKwgQ+rkl0GIKJNlYjpje27DwZauZk7dksNG7MXTwKvlA9NCqv Ng4fteg604ai0dn81r1D0F94st8gN++zNOME4VIju0qDRejb8NudnCL6QaHj6CtCrG9G n0Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=kBqdkSsG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p15-20020a63f44f000000b00557673fdd1asi2163583pgk.313.2023.07.20.23.06.18; Thu, 20 Jul 2023 23:06:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=kBqdkSsG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229815AbjGUGAp (ORCPT + 99 others); Fri, 21 Jul 2023 02:00:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229779AbjGUGAm (ORCPT ); Fri, 21 Jul 2023 02:00:42 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38CDDE62; Thu, 20 Jul 2023 23:00:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1689919241; x=1721455241; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1ypgipcrK/g6JVBXnq3hemafU0QzkXU5hISGsnvZ/lw=; b=kBqdkSsGFIuj8nV2OOKS3jvpNZmUjOGuDTyunLF83Sp8rjWKsaGrCkLb ODFCyz7zNUYZHGCN43BoNcxhixLKpAJSLg2zlI63pzhiPybzk2IBhBz6h VyGWh6GvDY8MC8VwbJOJK3BJffcylVnkmdllC/ZT4agTzhmXMcabt4xKQ o6kWdV6J3sS6cg+xMmgUnrOr9yPx4RmcvvEVMZl/R+4lidgIoboHcgLHi fL7Bq7PCgl/5GaK9YD/ASzYXXVIvKxRBYc6vAG4nllrSMItsT35x/RTe4 54V8GeVixXVmFC/J0WMsXTz5s+VMt7XZaFGOm6jeo8au0AzdYv9M5Z1xb w==; X-IronPort-AV: E=Sophos;i="6.01,220,1684825200"; d="scan'208";a="225102694" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 20 Jul 2023 23:00:39 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) 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.21; Thu, 20 Jul 2023 23:00:37 -0700 Received: from localhost.localdomain (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Thu, 20 Jul 2023 23:00:34 -0700 From: Raju Lakkaraju To: CC: , , , , , , Subject: [PATCH net-next 1/7] net: lan743x: Create separate PCS power reset function Date: Fri, 21 Jul 2023 11:30:13 +0530 Message-ID: <20230721060019.2737-2-Raju.Lakkaraju@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230721060019.2737-1-Raju.Lakkaraju@microchip.com> References: <20230721060019.2737-1-Raju.Lakkaraju@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772009127100341802 X-GMAIL-MSGID: 1772009127100341802 Create separate PCS power reset function from lan743x_sgmii_config () to use as subroutine. Signed-off-by: Raju Lakkaraju --- drivers/net/ethernet/microchip/lan743x_main.c | 54 ++++++++++--------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c index a36f6369f132..dba5576a933b 100644 --- a/drivers/net/ethernet/microchip/lan743x_main.c +++ b/drivers/net/ethernet/microchip/lan743x_main.c @@ -1145,6 +1145,34 @@ static int lan743x_pcs_seq_state(struct lan743x_adapter *adapter, u8 state) return 0; } +static int lan743x_pcs_power_reset(struct lan743x_adapter *adapter) +{ + int mii_ctl; + int ret; + + /* SGMII/1000/2500BASE-X PCS power down */ + mii_ctl = lan743x_sgmii_read(adapter, MDIO_MMD_VEND2, MII_BMCR); + if (mii_ctl < 0) + return mii_ctl; + + mii_ctl |= BMCR_PDOWN; + ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, MII_BMCR, mii_ctl); + if (ret < 0) + return ret; + + ret = lan743x_pcs_seq_state(adapter, PCS_POWER_STATE_DOWN); + if (ret < 0) + return ret; + + /* SGMII/1000/2500BASE-X PCS power up */ + mii_ctl &= ~BMCR_PDOWN; + ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, MII_BMCR, mii_ctl); + if (ret < 0) + return ret; + + return lan743x_pcs_seq_state(adapter, PCS_POWER_STATE_UP); +} + static int lan743x_sgmii_config(struct lan743x_adapter *adapter) { struct net_device *netdev = adapter->netdev; @@ -1207,31 +1235,7 @@ static int lan743x_sgmii_config(struct lan743x_adapter *adapter) netif_dbg(adapter, drv, adapter->netdev, "SGMII 1G mode enable\n"); - /* SGMII/1000/2500BASE-X PCS power down */ - mii_ctl = lan743x_sgmii_read(adapter, MDIO_MMD_VEND2, MII_BMCR); - if (mii_ctl < 0) - return mii_ctl; - - mii_ctl |= BMCR_PDOWN; - ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, MII_BMCR, mii_ctl); - if (ret < 0) - return ret; - - ret = lan743x_pcs_seq_state(adapter, PCS_POWER_STATE_DOWN); - if (ret < 0) - return ret; - - /* SGMII/1000/2500BASE-X PCS power up */ - mii_ctl &= ~BMCR_PDOWN; - ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, MII_BMCR, mii_ctl); - if (ret < 0) - return ret; - - ret = lan743x_pcs_seq_state(adapter, PCS_POWER_STATE_UP); - if (ret < 0) - return ret; - - return 0; + return lan743x_pcs_power_reset(adapter); } static void lan743x_mac_set_address(struct lan743x_adapter *adapter,