Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3039353rdg; Tue, 17 Oct 2023 02:44:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAQk6sDVTFMLlP4coXhZDqGvzVd9pbbmahpZuAFzJi20O/I5TWlSL85OFPt0xRDKjzPfTC X-Received: by 2002:a05:6a21:66cb:b0:16b:ff2c:c42c with SMTP id ze11-20020a056a2166cb00b0016bff2cc42cmr1374894pzb.62.1697535845235; Tue, 17 Oct 2023 02:44:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697535845; cv=none; d=google.com; s=arc-20160816; b=0GuSHuxMF3HeTL12rZkEs12fqgb99UMyofe8CKrJh/k4z5MRbDJs1JFNN7SKAc65MC hNdwTUfI+RVomM39gGsalwJfffwLJl0dZ7hvxdbZoosW7mToh9frkrN2eJ9A0mRaInvM bCau+bXB1ABqRJv5jR4i93leawBPrNcQWKOvcjqquOK9PHo7a22ciECM0bgMrSw2fSmn cO0Bso46XIEUfcpHXbNpE908M0sooc84oOt7wHaqJmHALBZAqj1nF1dzI/ngxRaCWm+q 5qISYv0BgfdpTxr+6t06sR+N2Eecsnz10cFo+HZ6Gdfq8bF7eFaj+bhfnw38mA2hkplc 3S3Q== 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=HShBaWrADB+UFZ7lm3/Kehl8u3bYcBI9YZFO/OrBuLM=; fh=NUruLdE3T8LF2YnhPWpSubmHudXYXdyNyvNA3I6YSYE=; b=Rmkvg5FcRFuntg6n+FnP0kPsbQK69or9dw7Dd7i/nji2HHvEtU/GD2dz+dS43m9jWR WdhFOL29ImMnyaWMtqsWNCigjBhMgmhMe7hWqPN5vJFs/+wl6n6k4w9zUxwYudvWkZvb 7+o9/52qFCxuoWNehmCdve0oCyPlHTUuM1hNQ5wSV3v9wLNXPEqu4msV4AUzgDcA0uIk BxIxYxrOcR2d0mpgzBSTejxSiupPplMCBtLJud0h9hDTFDvOLC5nOeXZefKPLF+58em0 +spGC4HfWRfCObQLQvnbQUMiV62obvRASUYWOQOjKQsXdnGHoSmBfyyK7YHiRn6/AfF4 XYpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b="HA/lxa3y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id bo13-20020a17090b090d00b0026c198d8182si8294156pjb.105.2023.10.17.02.44.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 02:44:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b="HA/lxa3y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id E0AB280BEB31; Tue, 17 Oct 2023 02:44:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234920AbjJQJnh (ORCPT + 99 others); Tue, 17 Oct 2023 05:43:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234788AbjJQJne (ORCPT ); Tue, 17 Oct 2023 05:43:34 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77A638E; Tue, 17 Oct 2023 02:43:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1697535813; x=1729071813; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+X2kCoRy+dl1KBYTHqUJu0TAPbBI+uMaaA3lR14/a70=; b=HA/lxa3y5oHvZM7oyJ8+h0C9PBPgOOvhq6eK2K5VuueaAdNveBW8Y4yR QM72vEIcII2zUMyvj8gOyQaROF1aBJOZEk9n3dNJoMJZwF/UsDIybrM3i 4Roe5Baa1onHzoAC47BI2UcwNVLkMJVweeST6itDhNhlL70PXj2FJVbmU Y3HKX2YuUOW3vPhXZCvFk8ilnQ+NTvd3OKYkhwlMO73bLZt6Qq02591Yt pnvOd3I0UD5OhiAjg9Jvspd3C8VaL6As03JV3osvVUFADWuDEh8tYZiQ4 pP6RHr916Do9oxXfRh0sCmVMEdMuR5P412+lHlT2ipuL+DOToO6LHSsfL Q==; X-CSE-ConnectionGUID: Ak13SLc/QnG3Q9MHCoEDCQ== X-CSE-MsgGUID: OSvluaMUQGCwa+04zUm8bw== X-ThreatScanner-Verdict: Negative X-IronPort-AV: E=Sophos;i="6.03,231,1694761200"; d="scan'208";a="10624543" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 17 Oct 2023 02:43:32 -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.21; Tue, 17 Oct 2023 02:43:22 -0700 Received: from HYD-DK-UNGSW21.microchip.com (10.10.85.11) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Tue, 17 Oct 2023 02:43:19 -0700 From: Raju Lakkaraju To: CC: , , , , , , Subject: [PATCH net-next V1 1/7] net: lan743x: Create separate PCS power reset function Date: Tue, 17 Oct 2023 15:12:02 +0530 Message-ID: <20231017094208.4956-2-Raju.Lakkaraju@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017094208.4956-1-Raju.Lakkaraju@microchip.com> References: <20231017094208.4956-1-Raju.Lakkaraju@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 17 Oct 2023 02:44:03 -0700 (PDT) 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 | 55 ++++++++++--------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c index f940895b14e8..1432032b795b 100644 --- a/drivers/net/ethernet/microchip/lan743x_main.c +++ b/drivers/net/ethernet/microchip/lan743x_main.c @@ -1145,12 +1145,39 @@ 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; struct phy_device *phydev = netdev->phydev; enum lan743x_sgmii_lsd lsd = POWER_DOWN; - int mii_ctl; bool status; int ret; @@ -1207,31 +1234,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, -- 2.34.1