From patchwork Fri Jul 21 06:00:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raju Lakkaraju X-Patchwork-Id: 123572 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp3586939vqt; Thu, 20 Jul 2023 23:06:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlGy3HVByEzANuPB44NZ2W0aPTg9AejP9yI9rpAhkBmFXw5iHIOFCs3hJtIQ1jOawy4+TX39 X-Received: by 2002:a17:903:2305:b0:1b3:a928:18e7 with SMTP id d5-20020a170903230500b001b3a92818e7mr965258plh.59.1689919610144; Thu, 20 Jul 2023 23:06:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689919610; cv=none; d=google.com; s=arc-20160816; b=v7Cpat2bbSCfYDmdydmZhaHv2CRREHTvFKASP/uVCI1RsYZ20xsiJ9LA6KBuf3PAOL 6xwq2IHt20KHXks3xDR7oR4+Gb1vzKCDXEFBipugxfkaIJOkKrOtGUImFSO9KYT65ROc Lz/GSOCzXUy5uO2XgDvk1mtRNcj6tnEOmE3y4HVpJYC0xH6fSgUG2KmudkyUYN3kA3Xy ewru4C/1oqBDaAbqUNhhqeh0hYBn6123P/Z7ZdN3XtHgGPs6o7vIcbGuDjPTeCmPBvpp jhGHrI8GKWLgJeBY3HcGefAxpciHE+QmiiHAQIT16932c6/HscM0ZFmXesF2/jYrXG+p CTnQ== 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=44qbC76F4wVSaDbyUyav5Hg0S2jKVo3vaUOaNzWEGrQ=; fh=qv6R2IaILI1S1xEIxOZzAcF4rN0hGtVsF9kjKc0mAD0=; b=gen7GiBWr/tOliZvtNs+AzSwWWmSCE/d71crbpzrgAFgvbrI+00hRbDzLZI7MxoGw7 JNCCkgChvODKUwhcKIyPntTCggTXT0YiO6H/X4qxAJNMrGyIQzp7Qi3ObTxXx2ZAzRfU lvoINd+hjAHQ8T5dl41zQS2HThErs5V11m3cOyCMxd6xB5BH/Xml9R1vfzApINWYEgwJ Kcl0RwkfrNwqeNZ+6F0/65tg3oOdvI9QM4jEn7qn484pUjOHqjo1ooj48DZdtDye/yAS dGF+Wk/t1Xar7iua8GtP6C3j1MOa6p6L60J3buNHCM3Bw77qsKHBpgCpNCn/Xbdnb8KX vx1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=BSgYonXn; 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 f14-20020a170902684e00b001b8a5d9806bsi2332404pln.21.2023.07.20.23.06.36; Thu, 20 Jul 2023 23:06:50 -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=BSgYonXn; 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 S229823AbjGUGAr (ORCPT + 99 others); Fri, 21 Jul 2023 02:00:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229757AbjGUGAm (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 527B0E65; 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=VxSnmdIkmVO33/iPhlNVZCik+lh1SAAiutDaFIxRxR8=; b=BSgYonXnd2wjiJ5u2gSyIqT6SCxm+ZZ0G+/g1bHwKuoXuOl/YFFDFGOa I9CssQUmc3bCu7/Llhp/57g1CxvT9dn9CHIuixN2l1VN2r3GQnXEqUa1T vt4aXDjFjAJ3V9I+oSKiYJJ5pGMIYiioDXcPXEbMd/PON+anbyOluVFm2 z/fOGPLfU9JFzla4rkhdmuxdB0Kq9inGdxggoBystQY5GRjaznf8lcEtG 5SMpPZQyW9lRM6GBQ6Fpl7ErQb+L2HfNbXrp1Ved+9alisBmQaIYVMkmd SA4eBlRRHfq6KfefNwf4MVv6ecDiOMetEQjl+6WIAIIPpwSGesNYjGK/4 Q==; X-IronPort-AV: E=Sophos;i="6.01,220,1684825200"; d="scan'208";a="225102709" 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:41 -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:40 -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:37 -0700 From: Raju Lakkaraju To: CC: , , , , , , Subject: [PATCH net-next 2/7] net: lan743x: Create separate Link Speed Duplex state function Date: Fri, 21 Jul 2023 11:30:14 +0530 Message-ID: <20230721060019.2737-3-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: 1772009144965451843 X-GMAIL-MSGID: 1772009144965451843 Create separate Link Speed Duplex (LSD) update state function from lan743x_sgmii_config () to use as subroutine. Signed-off-by: Raju Lakkaraju --- drivers/net/ethernet/microchip/lan743x_main.c | 76 +++++++++++-------- drivers/net/ethernet/microchip/lan743x_main.h | 1 + 2 files changed, 46 insertions(+), 31 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c index dba5576a933b..e8dd272a591a 100644 --- a/drivers/net/ethernet/microchip/lan743x_main.c +++ b/drivers/net/ethernet/microchip/lan743x_main.c @@ -990,6 +990,42 @@ static int lan743x_sgmii_write(struct lan743x_adapter *adapter, return ret; } +int lan743x_lsd_update(int speed, int duplex, u8 mss) +{ + enum lan743x_sgmii_lsd lsd = POWER_DOWN; + + switch (speed) { + case SPEED_2500: + if (mss == MASTER_SLAVE_STATE_SLAVE) + lsd = LINK_2500_SLAVE; + else + lsd = LINK_2500_MASTER; + break; + case SPEED_1000: + if (mss == MASTER_SLAVE_STATE_SLAVE) + lsd = LINK_1000_SLAVE; + else + lsd = LINK_1000_MASTER; + break; + case SPEED_100: + if (duplex == DUPLEX_FULL) + lsd = LINK_100FD; + else + lsd = LINK_100HD; + break; + case SPEED_10: + if (duplex == DUPLEX_FULL) + lsd = LINK_10FD; + else + lsd = LINK_10HD; + break; + default: + return -EINVAL; + } + + return lsd; +} + static int lan743x_sgmii_mpll_set(struct lan743x_adapter *adapter, u16 baud) { @@ -1177,43 +1213,21 @@ 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; - switch (phydev->speed) { - case SPEED_2500: - if (phydev->master_slave_state == MASTER_SLAVE_STATE_MASTER) - lsd = LINK_2500_MASTER; - else - lsd = LINK_2500_SLAVE; - break; - case SPEED_1000: - if (phydev->master_slave_state == MASTER_SLAVE_STATE_MASTER) - lsd = LINK_1000_MASTER; - else - lsd = LINK_1000_SLAVE; - break; - case SPEED_100: - if (phydev->duplex) - lsd = LINK_100FD; - else - lsd = LINK_100HD; - break; - case SPEED_10: - if (phydev->duplex) - lsd = LINK_10FD; - else - lsd = LINK_10HD; - break; - default: + ret = lan743x_lsd_update(phydev->speed, phydev->duplex, + phydev->master_slave_state); + if (ret < 0) { netif_err(adapter, drv, adapter->netdev, - "Invalid speed %d\n", phydev->speed); - return -EINVAL; + "error %d link-speed-duplex(LSD) invalid\n", ret); + return ret; } - adapter->sgmii_lsd = lsd; + adapter->sgmii_lsd = ret; + netif_dbg(adapter, drv, adapter->netdev, + "Link Speed Duplex (lsd) : 0x%X\n", adapter->sgmii_lsd); + ret = lan743x_sgmii_aneg_update(adapter); if (ret < 0) { netif_err(adapter, drv, adapter->netdev, diff --git a/drivers/net/ethernet/microchip/lan743x_main.h b/drivers/net/ethernet/microchip/lan743x_main.h index 52609fc13ad9..0cd3fe71dfad 100644 --- a/drivers/net/ethernet/microchip/lan743x_main.h +++ b/drivers/net/ethernet/microchip/lan743x_main.h @@ -1163,5 +1163,6 @@ void lan743x_hs_syslock_release(struct lan743x_adapter *adapter); void lan743x_mac_flow_ctrl_set_enables(struct lan743x_adapter *adapter, bool tx_enable, bool rx_enable); int lan743x_sgmii_read(struct lan743x_adapter *adapter, u8 mmd, u16 addr); +int lan743x_lsd_update(int speed, int duplex, u8 mss); #endif /* _LAN743X_H */