From patchwork Wed Dec 6 23:57:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 174788 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4454604vqy; Wed, 6 Dec 2023 16:01:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IHvDSYYW70FcurdFP4a04IudLyrPTbrF9HWoPmW1PRWOviSL/cGGwtrCwvYt5BhyqNFw2rt X-Received: by 2002:a05:6a20:a123:b0:18f:97c:8a14 with SMTP id q35-20020a056a20a12300b0018f097c8a14mr2108155pzk.63.1701907272737; Wed, 06 Dec 2023 16:01:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701907272; cv=none; d=google.com; s=arc-20160816; b=oKnQmULhn+oIdySyTJ3dtaDSl8cPip/a6mnVvo43mMOOW4BFpLmgxRNeQFwAK/sh70 GHvU112FvdFQdOEKAgi4PPZKVKWNCAZaYK0Mt4cwoPeHM+MuZIxoOYbc2S6kGCtEiDm1 Zxm8apWhaxfrb0Go95YDbQTpyjImTJM6dEUHlQbUNHQXtbbR8JVPAM+EiSTB7+x7S6WH XuV9QnHzCmImsYzDOcvxOaADWWp4Wc46nF7aj/umPPCPBBF8q1XTUe/7P0kgwFf76W7O e8td3zUY2pDXAbaPT/Qd51eLUFKUsWwH7C+m8S86okx3Lg3J/ny1DxYBp1doO7DMEU53 H0Qw== 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=5CMZETdDgYu5hG2aMQ54/zJsbch0uzjPkjbZMzkqZ7k=; fh=utmrxdkgikAlLxVfQI1kldUG+rNjhrLN+3fAlOYj01s=; b=GrQlkVy8C7vaBPc7r4H+lC7OX1KggRAkrKcjpYDZ7vjBoog6yJeqn4Ex+HXpvwgkz5 nvDvF3yICXCMHVbdkg7ROuL2FqzoLpiTM1R+4Uxh7qnha+/bfM0pwOWBHUDojb3L+BQd NoYAyxHuZynDMKctMEo9pTidfZj4u3mPQuO7ftT0xrRMtuD/ht34g+ZJtmOj6ZrOsZJv +3gBJo1djPVmI14RyUHieq70Ng6lHM9D/ddRm6IUwFwHpL3SAch01FwZWGvhXJALOGg0 pelLfGpNhKU+CoNGF4go13HtLoZIUQLLIHgeiK06Aalx5KW4PAnaWiVKonXAdtYjPe9U r44Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=l256Hu76; 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 w67-20020a636246000000b005c66e00ffccsi98423pgb.260.2023.12.06.16.01.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 16:01:12 -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=l256Hu76; 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 BAFA280AE50D; Wed, 6 Dec 2023 16:01:00 -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 S1442958AbjLGAAn (ORCPT + 99 others); Wed, 6 Dec 2023 19:00:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1441896AbjLGAAR (ORCPT ); Wed, 6 Dec 2023 19:00:17 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D03F319E; Wed, 6 Dec 2023 16:00:21 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-40c2308faedso4060085e9.1; Wed, 06 Dec 2023 16:00:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701907220; x=1702512020; 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=5CMZETdDgYu5hG2aMQ54/zJsbch0uzjPkjbZMzkqZ7k=; b=l256Hu769S3aPPSPv7+NabZ/IhJNxgTGjqN9tXHJxghBS/AIFrx9kUzlWfN4iyj1kS DvGlAZdYl9S8vYpAXDQ7bGbVIGK2jgq+NYp5wgIFn5k81cPnUb2vVEprEwdswWECCSBZ AZYxLiSmOPLEBEGdUsW+12ht5LdQYYUsIvfGJDJJ2y0Q4Elw8LKTG1ozY8/tlVIL/Akz iWKcmYLzAy+ialczS1kbcZLVnVNltgsHR2iu+0NaTV7dX89oZGKb/VBg1qGxOQG8cAuO BRJ/s8SYjMLGCMkjjLQQNAXuWgip0o+h/SPgJrJJ+HUWaWcLU7i8qnqBZxKJ/ZfJz3bG QSXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701907220; x=1702512020; 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=5CMZETdDgYu5hG2aMQ54/zJsbch0uzjPkjbZMzkqZ7k=; b=qmlJu9UXuED0IZ/WN/RSTD7T1vc4uBR9YOMV52/SXV1eqCRztprVseyCcASilLwOWP Lio/4j4vqw1sWwqkU7Q+ykA8oHGTBICqoXQ2+j3bZ02+eRVKSC8xWpMMdNgejhz57evX mGzaDo6CN406whHtyzW4jF9NDJxcaTEbXA8MU+SiX00WHbaJ4dVxY6ptYXE7TeDwkJcU NdoFXxkjzjwusrjeVp83BCXWWBfMytnmaqBlLT02MfGm6UQWPhi79tHSfq8YfoBoyG3z o2D2Ykb811Qetau0XUqEsRasOaWalinPgodXKIjw43nD01ld8Xc4jp32mA70MWrihpO5 lKNQ== X-Gm-Message-State: AOJu0Ywm/G2Tl5pXAeoWiFIMuzUpdsiHHOHHtEYbs1W+FX/bA9ftitOj +S8gMNlgHZLS2X7E+ESDntA= X-Received: by 2002:a05:600c:cb:b0:40b:5e59:c58a with SMTP id u11-20020a05600c00cb00b0040b5e59c58amr1017932wmm.180.1701907219993; Wed, 06 Dec 2023 16:00:19 -0800 (PST) Received: from localhost.localdomain (host-79-26-252-6.retail.telecomitalia.it. [79.26.252.6]) by smtp.googlemail.com with ESMTPSA id je16-20020a05600c1f9000b00405442edc69sm50280wmb.14.2023.12.06.16.00.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 16:00:19 -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 v3 04/13] net: phy: at803x: move qca83xx specific check in dedicated functions Date: Thu, 7 Dec 2023 00:57:19 +0100 Message-Id: <20231206235728.6985-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231206235728.6985-1-ansuelsmth@gmail.com> References: <20231206235728.6985-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, 06 Dec 2023 16:01:00 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784579120669435719 X-GMAIL-MSGID: 1784579120669435719 Rework qca83xx specific check to dedicated function to tidy things up and drop useless phy_id check. Also drop an useless link_change_notify for QCA8337 as it did nothing an returned early. Signed-off-by: Christian Marangi Reviewed-by: Andrew Lunn --- drivers/net/phy/at803x.c | 68 ++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index b1ea52ba3f07..779e0835fa5d 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -1625,27 +1625,26 @@ static int qca83xx_config_init(struct phy_device *phydev) break; } + /* Following original QCA sourcecode set port to prefer master */ + phy_set_bits(phydev, MII_CTRL1000, CTL1000_PREFER_MASTER); + + return 0; +} + +static int qca8327_config_init(struct phy_device *phydev) +{ /* QCA8327 require DAC amplitude adjustment for 100m set to +6%. * Disable on init and enable only with 100m speed following * qca original source code. */ - if (phydev->drv->phy_id == QCA8327_A_PHY_ID || - phydev->drv->phy_id == QCA8327_B_PHY_ID) - at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, - QCA8327_DEBUG_MANU_CTRL_EN, 0); + at803x_debug_reg_mask(phydev, AT803X_DEBUG_ANALOG_TEST_CTRL, + QCA8327_DEBUG_MANU_CTRL_EN, 0); - /* Following original QCA sourcecode set port to prefer master */ - phy_set_bits(phydev, MII_CTRL1000, CTL1000_PREFER_MASTER); - - return 0; + return qca83xx_config_init(phydev); } static void qca83xx_link_change_notify(struct phy_device *phydev) { - /* QCA8337 doesn't require DAC Amplitude adjustement */ - if (phydev->drv->phy_id == QCA8337_PHY_ID) - return; - /* Set DAC Amplitude adjustment to +6% for 100m on link running */ if (phydev->state == PHY_RUNNING) { if (phydev->speed == SPEED_100) @@ -1688,19 +1687,6 @@ static int qca83xx_resume(struct phy_device *phydev) static int qca83xx_suspend(struct phy_device *phydev) { - u16 mask = 0; - - /* Only QCA8337 support actual suspend. - * QCA8327 cause port unreliability when phy suspend - * is set. - */ - if (phydev->drv->phy_id == QCA8337_PHY_ID) { - genphy_suspend(phydev); - } else { - mask |= ~(BMCR_SPEED1000 | BMCR_FULLDPLX); - phy_modify(phydev, MII_BMCR, mask, 0); - } - at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_GREEN, AT803X_DEBUG_GATE_CLK_IN1000, 0); @@ -1711,6 +1697,27 @@ static int qca83xx_suspend(struct phy_device *phydev) return 0; } +static int qca8337_suspend(struct phy_device *phydev) +{ + /* Only QCA8337 support actual suspend. */ + genphy_suspend(phydev); + + return qca83xx_suspend(phydev); +} + +static int qca8327_suspend(struct phy_device *phydev) +{ + u16 mask = 0; + + /* QCA8327 cause port unreliability when phy suspend + * is set. + */ + mask |= ~(BMCR_SPEED1000 | BMCR_FULLDPLX); + phy_modify(phydev, MII_BMCR, mask, 0); + + return qca83xx_suspend(phydev); +} + static int qca808x_phy_fast_retrain_config(struct phy_device *phydev) { int ret; @@ -2172,7 +2179,6 @@ static struct phy_driver at803x_driver[] = { .phy_id_mask = QCA8K_PHY_ID_MASK, .name = "Qualcomm Atheros 8337 internal PHY", /* PHY_GBIT_FEATURES */ - .link_change_notify = qca83xx_link_change_notify, .probe = at803x_probe, .flags = PHY_IS_INTERNAL, .config_init = qca83xx_config_init, @@ -2180,7 +2186,7 @@ static struct phy_driver at803x_driver[] = { .get_sset_count = qca83xx_get_sset_count, .get_strings = qca83xx_get_strings, .get_stats = qca83xx_get_stats, - .suspend = qca83xx_suspend, + .suspend = qca8337_suspend, .resume = qca83xx_resume, }, { /* QCA8327-A from switch QCA8327-AL1A */ @@ -2191,12 +2197,12 @@ static struct phy_driver at803x_driver[] = { .link_change_notify = qca83xx_link_change_notify, .probe = at803x_probe, .flags = PHY_IS_INTERNAL, - .config_init = qca83xx_config_init, + .config_init = qca8327_config_init, .soft_reset = genphy_soft_reset, .get_sset_count = qca83xx_get_sset_count, .get_strings = qca83xx_get_strings, .get_stats = qca83xx_get_stats, - .suspend = qca83xx_suspend, + .suspend = qca8327_suspend, .resume = qca83xx_resume, }, { /* QCA8327-B from switch QCA8327-BL1A */ @@ -2207,12 +2213,12 @@ static struct phy_driver at803x_driver[] = { .link_change_notify = qca83xx_link_change_notify, .probe = at803x_probe, .flags = PHY_IS_INTERNAL, - .config_init = qca83xx_config_init, + .config_init = qca8327_config_init, .soft_reset = genphy_soft_reset, .get_sset_count = qca83xx_get_sset_count, .get_strings = qca83xx_get_strings, .get_stats = qca83xx_get_stats, - .suspend = qca83xx_suspend, + .suspend = qca8327_suspend, .resume = qca83xx_resume, }, { /* Qualcomm QCA8081 */