From patchwork Fri Sep 6 10:35:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raju Lakkaraju - I30499 X-Patchwork-Id: 13793906 X-Patchwork-Delegate: kuba@kernel.org Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C1761C7B7B; Fri, 6 Sep 2024 10:39:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.153.233 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725619169; cv=none; b=TNghgOqSM+iiz61MuvYpaYvYALdB0ImswRJD7iwU0d/siK7IF4ADeyo7kDIXLOtrtCoBedoHCujSprEiKuCZBsjJRgxDbEbo4JFESydVx9rrFraS6me2Vo6O6Lsaf8+c/5kCtdCTQwgV6jJBak5rOPjznqS0WP4kDCIDhyTGTX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725619169; c=relaxed/simple; bh=RPS11cwJgmKMAE/dTEv9V1F0ccEbMjx3kYVQrayyzAg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=j+ctuovhCwACxfGWtu16vHh8Zbu8CeJRAHNp7bqTAEMPsb1VdNXfbNnx/0/+g1ePWaoY0fkD52rrtOplsN9rsW8Iof86ft3OWOJewqrYflz7skA7awaMZTBqhttmQKTropB1zyvtJlEfjczqssAaGB4ffmUYI/OxMB66Pi3Y+R0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=cUx6U2b/; arc=none smtp.client-ip=68.232.153.233 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="cUx6U2b/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1725619166; x=1757155166; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RPS11cwJgmKMAE/dTEv9V1F0ccEbMjx3kYVQrayyzAg=; b=cUx6U2b//1Y1YOGvr0z0zMZspCFmnwAsM5Jd0SO/F4JuM85Pw6vK/XDe NzeXz0NoJ2ZJZ3fh8jDXs7NYveKao15rp87Yn1iiyb5n3+EE1kstx1rNS BIBVp77UF5gxtmoFkKAMWKrahBnQgKpD7SkSy8vdXIflssUFRIN1C0Cvj LxVDJccJzI176IcUhYXRZLs9EALfpVe2/tT3PbnHyeceh95QP03eENrcB bX9hTjoODwxddrn5CFfHi4HDBOfh/QgGAZR9GVlmuwRDbbpRd9LZP3GHM Shf4TxE78yyFw51wDLOzAZI2jflbl0HWA10tg9K0EakOYBYIxmglJQKXB A==; X-CSE-ConnectionGUID: ARynwNKwTMmFStNWNTzFxw== X-CSE-MsgGUID: 4CZJyXTFRVecyge7FMxCuw== X-IronPort-AV: E=Sophos;i="6.10,207,1719903600"; d="scan'208";a="34530671" 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; 06 Sep 2024 03:39:24 -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.35; Fri, 6 Sep 2024 03:39:13 -0700 Received: from HYD-DK-UNGSW21.microchip.com (10.10.85.11) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Fri, 6 Sep 2024 03:39:09 -0700 From: Raju Lakkaraju To: CC: , , , , , , , , , , , , , Subject: [PATCH net-next V6 2/5] net: lan743x: Create separate PCS power reset function Date: Fri, 6 Sep 2024 16:05:08 +0530 Message-ID: <20240906103511.28416-3-Raju.Lakkaraju@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240906103511.28416-1-Raju.Lakkaraju@microchip.com> References: <20240906103511.28416-1-Raju.Lakkaraju@microchip.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Create separate PCS power reset function from lan743x_sgmii_config () to use as subroutine. Reviewed-by: Andrew Lunn Signed-off-by: Raju Lakkaraju --- Change List: ============ V5 -> V6: - No change V4 -> V5: - No change V3 -> V4: - No change V2 -> V3: - No change V1 -> V2: - No change 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 e418539565b1..ce1e104adc20 100644 --- a/drivers/net/ethernet/microchip/lan743x_main.c +++ b/drivers/net/ethernet/microchip/lan743x_main.c @@ -1147,12 +1147,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; @@ -1209,31 +1236,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,