From patchwork Thu Dec 14 00:44:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 178387 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8220772dys; Wed, 13 Dec 2023 16:46:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IHSTnod/M2iHy0Z+y/8Zpx4cHUFCYZDND1rNrzUsw73izh9hEk2yqD4oHNYVKsHdCijrukx X-Received: by 2002:a05:6830:20c3:b0:6d9:f70d:58f with SMTP id z3-20020a05683020c300b006d9f70d058fmr8124617otq.20.1702514762622; Wed, 13 Dec 2023 16:46:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702514762; cv=none; d=google.com; s=arc-20160816; b=dMRE4kZxfrSB07wPIxkoMnYb01AMuK+uXwDfwYWy85dwSrRtnnfdAb6UJ+yh5WysmO jlsT5EuyUPpkCDU+fPQewIQ65ZU+kc4FRktROouCcYLt34bcTOLNVI76aK7h/8ifN3dw 2vKBPEjszoYHaVo19ZKqw8PBzn7/nrnZCYd7tQ6bZYnftwEjdqsf6lTiV6bnOoQWU3vy 0MyOqWppj6mFvJ0OfcDqZIjQXLgi5Si/z2itqZf16WKCUObLlmsZRT13xiduYiIoaSgw 4m4MmDAKIPuqxrpWZCpE0exHi1DhF9top2FhU67gFAngcVGgN4RGpZJhOUTUwTh3hel1 RihQ== 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=U+moSObm6SmTF7EP235eqi6TuZLbs8gEL+3plRa6dpk=; fh=utmrxdkgikAlLxVfQI1kldUG+rNjhrLN+3fAlOYj01s=; b=jCIMAPID1C9mr/ysGUMM8sOUZGnaXK4/SbYT4dIY8YC8XXqO4I1pZiYApKxIYqwlFd Qx+sAW2f2g3imGUEAmxsSeYp6J8z4NclEtCLh0vzO08z1f7iRuf9uoVXj58av8ok8xcf cIDFHH8Uujh6tgtDFv/KS8ufp7KcFVmDL4t2O9INbCXd1e31Ju+UvTcby7LPG1MPOCqs m3yaTU/rAYnEPxyxT2ubzLkdExCf5Idw2X/Toi7b4D58ybzYOc1Ij0lFmUOXIXVwInES DWDq0do2kRy7kkg3lGBdWDoN+CTmTBMfaA2CfzSB2A78DcVmPwwezvEiQwhpqnsb7E9a ykhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WlkbeTlJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id u42-20020a056a0009aa00b006ce6f21565fsi10199164pfg.272.2023.12.13.16.46.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 16:46:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WlkbeTlJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 1029380320DB; Wed, 13 Dec 2023 16:46:00 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442894AbjLNAph (ORCPT + 99 others); Wed, 13 Dec 2023 19:45:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442888AbjLNApf (ORCPT ); Wed, 13 Dec 2023 19:45:35 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFFF4AC; Wed, 13 Dec 2023 16:45:41 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40c46d6784eso36729795e9.3; Wed, 13 Dec 2023 16:45:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702514740; x=1703119540; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=U+moSObm6SmTF7EP235eqi6TuZLbs8gEL+3plRa6dpk=; b=WlkbeTlJIMWtZEKGaBcWDxLg+nrPn+nzalrow44Z+b0maQwznOEoB0Fk3NnrqJ83b4 4Y7TmEXLbRhLpSKbzSaYjFNpzl2lhJHPDGcRS6oIdtaIEGpXviJz7vlnyydaT2gM1/VN f3mfcZhMDFB5XpYiUVQQrUTtYJmM5QKtF0fB9S74sk7ai3TofdfxYiL5y2WEnjEoESjm YgJpsQSLQMHIA6yftYa4a0PDcZV8GYbidrzve87L2bhhQRE3Ike5b2IpmOYbjMUDlGaK dbGs0r4ioGqRMwr0oaoyDYPZREAGLBPkVadCwPWT326rNGZATYXuPJMwxoZtlJe32J46 S4/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702514740; x=1703119540; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U+moSObm6SmTF7EP235eqi6TuZLbs8gEL+3plRa6dpk=; b=LDqaGbCWucJ8vcrKtJEd9zRIrs84P2uX9JcZBiVyTkIowbGfpirxOZpr4aYdYJRq0S zNAW31XaxgQf+1Ic/8SHHTLxJrwnodsFCRvM78A8zR0+xBi/qMa1VZ4DHY1mvMxtpy4r HfamL5dwe7UY75WYlh3F3ddpVKBGK89R+t9R/xKKGstUl5zOY+7IXRuXG7H0KKoL2Yw9 pBGVk/71Wl71cNC2jAD39b7sTbBXuNzSgQbC+AAjKIpU7HBHosUQ7/puLvWX7Z5f37Qx Hzmrx+ZQtUiAKLtwnfERgRNRCU4gatpzBRq07niMn7bJULgD6YlmCc+uuZUAdIa8KKrf J/cw== X-Gm-Message-State: AOJu0Yzz+AmcMF5MDU2xKPpQ+BVqmPxoHVxz/2OZlpqZFBFjIojRe0Rc nQZvWdBQpgjvC7Nc41ls5uY= X-Received: by 2002:a7b:c3d7:0:b0:40c:610e:3c7c with SMTP id t23-20020a7bc3d7000000b0040c610e3c7cmr169512wmj.23.1702514739940; Wed, 13 Dec 2023 16:45:39 -0800 (PST) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id g15-20020adfe40f000000b003364470f30bsm959013wrm.52.2023.12.13.16.45.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 16:45:39 -0800 (PST) From: Christian Marangi To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christian Marangi Subject: [net-next PATCH 1/2] net: phy: at803x: move specific qca808x config_aneg to dedicated function Date: Thu, 14 Dec 2023 01:44:31 +0100 Message-Id: <20231214004432.16702-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231214004432.16702-1-ansuelsmth@gmail.com> References: <20231214004432.16702-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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]); Wed, 13 Dec 2023 16:46:00 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785216119815664107 X-GMAIL-MSGID: 1785216119815664107 Move specific qca808x config_aneg to dedicated function to permit easier split of qca808x portion from at803x driver. Signed-off-by: Christian Marangi --- drivers/net/phy/at803x.c | 66 ++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 26 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index b9d3a26cf6dc..03f945cc7626 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -1045,9 +1045,8 @@ static int at803x_config_mdix(struct phy_device *phydev, u8 ctrl) FIELD_PREP(AT803X_SFC_MDI_CROSSOVER_MODE_M, val)); } -static int at803x_config_aneg(struct phy_device *phydev) +static int at803x_prepare_config_aneg(struct phy_device *phydev) { - struct at803x_priv *priv = phydev->priv; int ret; ret = at803x_config_mdix(phydev, phydev->mdix_ctrl); @@ -1064,33 +1063,22 @@ static int at803x_config_aneg(struct phy_device *phydev) return ret; } - if (priv->is_1000basex) - return genphy_c37_config_aneg(phydev); - - /* Do not restart auto-negotiation by setting ret to 0 defautly, - * when calling __genphy_config_aneg later. - */ - ret = 0; - - if (phydev->drv->phy_id == QCA8081_PHY_ID) { - int phy_ctrl = 0; + return 0; +} - /* The reg MII_BMCR also needs to be configured for force mode, the - * genphy_config_aneg is also needed. - */ - if (phydev->autoneg == AUTONEG_DISABLE) - genphy_c45_pma_setup_forced(phydev); +static int at803x_config_aneg(struct phy_device *phydev) +{ + struct at803x_priv *priv = phydev->priv; + int ret; - if (linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->advertising)) - phy_ctrl = MDIO_AN_10GBT_CTRL_ADV2_5G; + ret = at803x_prepare_config_aneg(phydev); + if (ret) + return ret; - ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL, - MDIO_AN_10GBT_CTRL_ADV2_5G, phy_ctrl); - if (ret < 0) - return ret; - } + if (priv->is_1000basex) + return genphy_c37_config_aneg(phydev); - return __genphy_config_aneg(phydev, ret); + return genphy_config_aneg(phydev); } static int at803x_get_downshift(struct phy_device *phydev, u8 *d) @@ -2118,6 +2106,32 @@ static int qca808x_get_features(struct phy_device *phydev) return 0; } +static int qca808x_config_aneg(struct phy_device *phydev) +{ + int phy_ctrl = 0; + int ret; + + ret = at803x_prepare_config_aneg(phydev); + if (ret) + return ret; + + /* The reg MII_BMCR also needs to be configured for force mode, the + * genphy_config_aneg is also needed. + */ + if (phydev->autoneg == AUTONEG_DISABLE) + genphy_c45_pma_setup_forced(phydev); + + if (linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->advertising)) + phy_ctrl = MDIO_AN_10GBT_CTRL_ADV2_5G; + + ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL, + MDIO_AN_10GBT_CTRL_ADV2_5G, phy_ctrl); + if (ret < 0) + return ret; + + return __genphy_config_aneg(phydev, ret); +} + static void qca808x_link_change_notify(struct phy_device *phydev) { /* Assert interface sgmii fifo on link down, deassert it on link up, @@ -2295,7 +2309,7 @@ static struct phy_driver at803x_driver[] = { .set_wol = at803x_set_wol, .get_wol = at803x_get_wol, .get_features = qca808x_get_features, - .config_aneg = at803x_config_aneg, + .config_aneg = qca808x_config_aneg, .suspend = genphy_suspend, .resume = genphy_resume, .read_status = qca808x_read_status,