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, From patchwork Thu Dec 14 00:44:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 178388 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8220919dys; Wed, 13 Dec 2023 16:46:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IF3RqRCkEkJ6k/OBfwD062Uk7a7ANzkcx8J7hvVDNzr+h1r98nXZyx02//xsH7jIHG0IkZZ X-Received: by 2002:a05:6871:890:b0:203:47c3:859d with SMTP id r16-20020a056871089000b0020347c3859dmr297356oaq.0.1702514771312; Wed, 13 Dec 2023 16:46:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702514771; cv=none; d=google.com; s=arc-20160816; b=BB/FBiE+SYQ+J2ywIZ7mXIMNTAYRCa5AZdWzHcp0yGwnxXFqNq/u2kXE6gDKtVaa3I kYJg0s7rfjKDSRrDBXTfTV69+rtQvKZwqOjCDHJxaL/XczLJ2sXQ7RpcUmZsvQ++dzx7 E/aKThhiaWh5CU3yJBVuT2xJx0fW02xKWBvtvEhz+tZSQiH+lxxZinYU3dBY8+GQMhW7 v5z1TsOMQg05+YutVxbLphDxNMZTCgh/a9iY/y/7VyKp/GEZcNV6ujE/21RYDUBJpjE6 J0WWPhr0T3Pw7GBTI9Nuj2/Y1BaehhYvKJ7tvtSFLV6Z7Svt4JT2Z7/cN0fL58mQxVBr euzw== 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=HOR5ojDqgOZh8TgFAYUGsLmhZvWja5pYQDWlBF86PYQ=; fh=utmrxdkgikAlLxVfQI1kldUG+rNjhrLN+3fAlOYj01s=; b=nDtfj4tAaManCy3+PSNoFWbqHx85Ug4illLM4gC2e+zR1ogd6H6+o+sNIeUgZuFmBV D18qtZ4aWy5P08aLhkqgadLTBEiC8M0JKJBj/ERlyps4MFF6uWH/IezeCWcozE4uGWZi 6BrtQoqjj4LPPVV/cNZlB1gtM09MMRPTKzXZUZg2zxemw7GoqU739iVlFgV9iLk9Dzhd 6B7lWvOxmTuXMhJGHacMq8kklrrCBWfReAhQ1uc2FkWz+cGqz71d97RMJTOaWBED9GiV y4j9IwNFDz3X3VllbdFUH6T28aDsC/WtXPwHBEXC13XpPw5VXE85iaJRhK1rsuzL10ee ro7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=m0wABbGf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id j4-20020a654304000000b005c66a3f3f5bsi9962329pgq.745.2023.12.13.16.46.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 16:46:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=m0wABbGf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id D949180A774C; Wed, 13 Dec 2023 16:46:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442912AbjLNApm (ORCPT + 99 others); Wed, 13 Dec 2023 19:45:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442898AbjLNApg (ORCPT ); Wed, 13 Dec 2023 19:45:36 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5514DD; Wed, 13 Dec 2023 16:45:42 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-336471815c4so89450f8f.1; Wed, 13 Dec 2023 16:45:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702514741; x=1703119541; 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=HOR5ojDqgOZh8TgFAYUGsLmhZvWja5pYQDWlBF86PYQ=; b=m0wABbGfB7NF7pB2ZGMnu5G7+8FPshKQJwZEWEFhfjJL85q7RBD3EeklsvqAQFGHTP J7vA/y9hgObZE1Pr151r5BvwX0aVfU2SweQNGHX14us7SOsRB4GIUjU/do5Rx3K1jQs4 kLoeHa1V2dpzFQpuVfuKurtk7TfXXFJmImkro9QLO2KknsL8fJ+JjwrJ+IgDm5WBFR5F NxPZLs+n3tEezvsKflSWjYqDFrCpxF1S1Qwq424vivwfm0I+D+Ad0+3jEJc+QF6GSyhS hkkqZVbf2G3CH5jy0huNHHKBzcQ537CY4Dm5oJMZJWUEjqI4W/SQEbENiRdA+qpoq8Eg g3eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702514741; x=1703119541; 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=HOR5ojDqgOZh8TgFAYUGsLmhZvWja5pYQDWlBF86PYQ=; b=TDh5qDS7MeoaVDGn5SJTQJJvyiFbGPLbepsI2HuHiK3CLri6PQ0HY2B3jloysGWwUN bb+q/FwN3ExsHkuxhZ0rBK66cAy/3biau16XrbKWZl+HQml/+c9jp92mFnVBWNzOFVmr pVbU7H/tmSM7svJaV6MvcyEdanTmVuzJCjnAFaL4YSiIr3eAclj+q5pr3cLCoeZ7ZuVB TL3CaXgiqwSJ7TThDadUtyriADgSXpxUhy+PAXAf3daeiPqoo/gvYVi3RYeWUAE0TTkC Z3prHXiZozTt/IGri54/J4Js7crGAIQw5Mgh+tMRTQATqBaeAzH0STv0FTPxheNJ4tnF wTYg== X-Gm-Message-State: AOJu0Yxc37fDNLqEE9xibndVpQ0CSIfJXE/GwGRhT0jnTzp1AoxGwAS2 ZfQrf92BtD/mNFcQRNxY6ZU= X-Received: by 2002:a5d:4342:0:b0:333:591c:6507 with SMTP id u2-20020a5d4342000000b00333591c6507mr2365594wrr.248.1702514741066; Wed, 13 Dec 2023 16:45:41 -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.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 16:45:40 -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 2/2] net: phy: at803x: make read specific status function more generic Date: Thu, 14 Dec 2023 01:44:32 +0100 Message-Id: <20231214004432.16702-3-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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Wed, 13 Dec 2023 16:46:09 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785216128846971031 X-GMAIL-MSGID: 1785216128846971031 Rework read specific status function to be more generic. The function apply different speed mask based on the PHY ID. Make it more generic by adding an additional arg to pass the specific speed (ss) mask and use the provided mask to parse the speed value. This is needed to permit an easier deatch of qca808x code from the at803x driver. Signed-off-by: Christian Marangi --- drivers/net/phy/at803x.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 03f945cc7626..a7d28848ee93 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -301,6 +301,11 @@ static struct at803x_hw_stat qca83xx_hw_stats[] = { { "eee_wake_errors", 0x16, GENMASK(15, 0), MMD}, }; +struct at803x_ss_mask { + u16 speed_mask; + u8 speed_shift; +}; + struct at803x_priv { int flags; u16 clk_25m_reg; @@ -921,7 +926,8 @@ static void at803x_link_change_notify(struct phy_device *phydev) } } -static int at803x_read_specific_status(struct phy_device *phydev) +static int at803x_read_specific_status(struct phy_device *phydev, + struct at803x_ss_mask ss_mask) { int ss; @@ -940,11 +946,8 @@ static int at803x_read_specific_status(struct phy_device *phydev) if (sfc < 0) return sfc; - /* qca8081 takes the different bits for speed value from at803x */ - if (phydev->drv->phy_id == QCA8081_PHY_ID) - speed = FIELD_GET(QCA808X_SS_SPEED_MASK, ss); - else - speed = FIELD_GET(AT803X_SS_SPEED_MASK, ss); + speed = ss & ss_mask.speed_mask; + speed >>= ss_mask.speed_shift; switch (speed) { case AT803X_SS_SPEED_10: @@ -989,6 +992,7 @@ static int at803x_read_specific_status(struct phy_device *phydev) static int at803x_read_status(struct phy_device *phydev) { struct at803x_priv *priv = phydev->priv; + struct at803x_ss_mask ss_mask = { 0 }; int err, old_link = phydev->link; if (priv->is_1000basex) @@ -1012,7 +1016,9 @@ static int at803x_read_status(struct phy_device *phydev) if (err < 0) return err; - err = at803x_read_specific_status(phydev); + ss_mask.speed_mask = AT803X_SS_SPEED_MASK; + ss_mask.speed_shift = __bf_shf(AT803X_SS_SPEED_MASK); + err = at803x_read_specific_status(phydev, ss_mask); if (err < 0) return err; @@ -1869,6 +1875,7 @@ static int qca808x_config_init(struct phy_device *phydev) static int qca808x_read_status(struct phy_device *phydev) { + struct at803x_ss_mask ss_mask = { 0 }; int ret; ret = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_STAT); @@ -1882,7 +1889,10 @@ static int qca808x_read_status(struct phy_device *phydev) if (ret) return ret; - ret = at803x_read_specific_status(phydev); + /* qca8081 takes the different bits for speed value from at803x */ + ss_mask.speed_mask = QCA808X_SS_SPEED_MASK; + ss_mask.speed_shift = __bf_shf(QCA808X_SS_SPEED_MASK); + ret = at803x_read_specific_status(phydev, ss_mask); if (ret < 0) return ret;