From patchwork Wed Nov 29 02:12:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 171032 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp68510vqn; Tue, 28 Nov 2023 18:13:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IHRig6v7RMRPufFvpy9KnM4mABtq1/cP86/pdBpbMOiaDND7vPFvKd+onOEG86MhwAaddGF X-Received: by 2002:a05:6a21:78a3:b0:18c:3ea9:b85d with SMTP id bf35-20020a056a2178a300b0018c3ea9b85dmr18013071pzc.11.1701224003165; Tue, 28 Nov 2023 18:13:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701224003; cv=none; d=google.com; s=arc-20160816; b=m8K7IgMJPMWpQHPcFCcDa326x2cwfpgzhLYTUKo0ijUPo4caCvwW1kpGO56gdZ6sF9 cgfhIl+aqF1B16JlHUpaGcBpd5Hre79AoNLKah4dRAMRcTyaCoWoytgV/dCNhQ2TZvhn owOy6X1nMDOo0ep0fttPepyQG6h9gXxd0m0Icva6KJYrlG/6yYpCLKREhvAYWFWtYc3g rlcyDPYEIzOm0EslirD0ElmbeHzZSbI/1PjomfCG3QJZY9j37lNkUkIOUbP0f+Ylwbbb zVFm3dcXjGR+XmAEEkoiPJIU37fMDM0MZU7Aw1iA7f4iYxTUsFj3nFf76K9Qmef+tqEX OmzQ== 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=6qRqs6v8lxOTVA+x1bbD/Lx0mTC/Dnzw05WwqzyQgc4=; fh=M/Mg9TtngevyqXgZJCTwFV5p5//1sl9LEorA0JOhC3o=; b=aALbywXqvv4hKJxgrou2YBWX9yJcvJ6FLQBycvEl/AYWn4UMStNjftWXweGONHV/ri 3KIhMY2mjxWLVB79LFDU8wUFUz/3sSq7T7nhzNtWLmrqj3lDKYn1B60Dd7eZI9GVsKgv KCfI65gVb/RBQ2knriXAVOFIERe/C3o4vuJ6o8ToZk+7bwRSbQQj0oz8bJEMgK3Cb24f STetPCtHLqv/cil2LJfkcudUU35xagNyTFmd//b/0+I8Y2CPIJ5GnFAG4YJZBlScHbh1 mAoXfDz4XkuihmynCvljElV3L5mdc89/q7LqHCqNZLR13PonjhyIkme0n4FDyc+hfMQe xtpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=B0CdoN8N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id a6-20020a654186000000b005ad5178d053si12849549pgq.347.2023.11.28.18.13.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 18:13:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=B0CdoN8N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id 8AA5F81C98D0; Tue, 28 Nov 2023 18:13:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376791AbjK2CM7 (ORCPT + 99 others); Tue, 28 Nov 2023 21:12:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234885AbjK2CMj (ORCPT ); Tue, 28 Nov 2023 21:12:39 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4CAF1BC8; Tue, 28 Nov 2023 18:12:39 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-40b34563987so2222865e9.1; Tue, 28 Nov 2023 18:12:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701223958; x=1701828758; 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=6qRqs6v8lxOTVA+x1bbD/Lx0mTC/Dnzw05WwqzyQgc4=; b=B0CdoN8NSeIa7WCPwPPd3RDfXLFNmXeAL7On/XMQgnwNLHIb/VLND/5t4cPQ4z9xGZ yXBWApkouvxT7nSf7Q4wsXSRL6lgb6+YzrUpijsZ9KsbWFk6DpucW2NO9JFYGgn4iRlC CVBdZv2SVvbahPTTvWkVlG0QBKyUmAYQPq7pwO/XtFNOm61G0sTglxmGwJ/ANkH42c+4 QnULhY5AfQitqnLBAzPZShM8+qFtbmSlPonRC92GHuniPVvPmxkLpVE3ehlVEQsEhcVf 46prRbapGquJZPbM144+9xiytFs3KE1+woW+lLbP7xTH5jVKa40c3UpPR1e2Qs965rYe FL9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701223958; x=1701828758; 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=6qRqs6v8lxOTVA+x1bbD/Lx0mTC/Dnzw05WwqzyQgc4=; b=ulF+6rA7HBJr7b5vnvIcf2impfo3+oYt4y/FkXlASxCYW1k2FwfGACGuCiBEBeQ+PN OM83HVrWQHUDfvnKwVfS37Z9IXWtGk/mvOPp/vMrykSK6FXGbkdsXcMnJMVXfwbJxcro 8i8y//oRdd/1zmVdGG7hKCpvZTAakB9UdGqsYp32qxZtycbFVKpvujcyHdteMESPZBew ZPw/EL/HJnMpObfPi2liotF+lfnmD6KWVIV3kcEZwubYM6LZdcB2Uurd3Ihd39mIrid2 6ySMuN/E/O8+K4sHq0u+7wnUDY+pnpR8edhkFzD4drzif/fbRU/BzO90XaNPl6OqKm8m LSHw== X-Gm-Message-State: AOJu0YykueOeGXuDx7iNiWDhEUyZKQdJASkqBpmPx9XLG+PLwS+F1Icx sqH9f+1NtEmgvKloy866W+I= X-Received: by 2002:a05:600c:45c8:b0:40b:45e2:1f4b with SMTP id s8-20020a05600c45c800b0040b45e21f4bmr7411183wmo.6.1701223958024; Tue, 28 Nov 2023 18:12:38 -0800 (PST) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id b19-20020a05600c4e1300b0040648217f4fsm321406wmq.39.2023.11.28.18.12.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 18:12:37 -0800 (PST) From: Christian Marangi To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andy Gross , Bjorn Andersson , Konrad Dybcio , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org Cc: Christian Marangi Subject: [net-next PATCH 09/14] net: phy: at803x: remove specific qca808x check from at803x functions Date: Wed, 29 Nov 2023 03:12:14 +0100 Message-Id: <20231129021219.20914-10-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231129021219.20914-1-ansuelsmth@gmail.com> References: <20231129021219.20914-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 pete.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 (pete.vger.email [0.0.0.0]); Tue, 28 Nov 2023 18:13:18 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783862660257167916 X-GMAIL-MSGID: 1783862660257167916 Remove specific qca808x check from at803x generic functions. While this cause a bit of code duplication, this is needed in preparation for splitting the driver per PHY family and detaching qca808x specific bits from the at803x driver. Signed-off-by: Christian Marangi --- drivers/net/phy/at803x.c | 107 ++++++++++++++++++++++++++------------- 1 file changed, 71 insertions(+), 36 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 8f5878ccb1a8..475b96165f45 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -1043,24 +1043,6 @@ static int at803x_config_aneg(struct phy_device *phydev) */ ret = 0; - if (phydev->drv->phy_id == QCA8081_PHY_ID) { - int phy_ctrl = 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); - - 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); } @@ -1197,14 +1179,8 @@ static int at803x_cdt_start(struct phy_device *phydev, int pair) { u16 cdt; - /* qca8081 takes the different bit 15 to enable CDT test */ - if (phydev->drv->phy_id == QCA8081_PHY_ID) - cdt = QCA808X_CDT_ENABLE_TEST | - QCA808X_CDT_LENGTH_UNIT | - QCA808X_CDT_INTER_CHECK_DIS; - else - cdt = FIELD_PREP(AT803X_CDT_MDI_PAIR_MASK, pair) | - AT803X_CDT_ENABLE_TEST; + cdt = FIELD_PREP(AT803X_CDT_MDI_PAIR_MASK, pair) | + AT803X_CDT_ENABLE_TEST; return phy_write(phydev, AT803X_CDT, cdt); } @@ -1212,16 +1188,10 @@ static int at803x_cdt_start(struct phy_device *phydev, int pair) static int at803x_cdt_wait_for_completion(struct phy_device *phydev) { int val, ret; - u16 cdt_en; - - if (phydev->drv->phy_id == QCA8081_PHY_ID) - cdt_en = QCA808X_CDT_ENABLE_TEST; - else - cdt_en = AT803X_CDT_ENABLE_TEST; /* One test run takes about 25ms */ ret = phy_read_poll_timeout(phydev, AT803X_CDT, val, - !(val & cdt_en), + !(val & AT803X_CDT_ENABLE_TEST), 30000, 100000, true); return ret < 0 ? ret : 0; @@ -1845,6 +1815,47 @@ static int qca8327_suspend(struct phy_device *phydev) return qca83xx_suspend(phydev); } +static int qca808x_config_aneg(struct phy_device *phydev) +{ + int phy_ctrl = 0; + int ret; + + ret = at803x_config_mdix(phydev, phydev->mdix_ctrl); + if (ret < 0) + return ret; + + /* Changes of the midx bits are disruptive to the normal operation; + * therefore any changes to these registers must be followed by a + * software reset to take effect. + */ + if (ret == 1) { + ret = genphy_soft_reset(phydev); + if (ret < 0) + return ret; + } + + /* Do not restart auto-negotiation by setting ret to 0 defautly, + * when calling __genphy_config_aneg later. + */ + ret = 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); + + 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 int qca808x_phy_fast_retrain_config(struct phy_device *phydev) { int ret; @@ -2104,6 +2115,30 @@ static int qca808x_cable_test_start(struct phy_device *phydev) return 0; } +static int qca808x_cdt_start(struct phy_device *phydev) +{ + u16 cdt; + + /* qca8081 takes the different bit 15 to enable CDT test */ + cdt = QCA808X_CDT_ENABLE_TEST | + QCA808X_CDT_LENGTH_UNIT | + QCA808X_CDT_INTER_CHECK_DIS; + + return phy_write(phydev, AT803X_CDT, cdt); +} + +static int qca808x_cdt_wait_for_completition(struct phy_device *phydev) +{ + int val, ret; + + /* One test run takes about 25ms */ + ret = phy_read_poll_timeout(phydev, AT803X_CDT, val, + !(val & QCA808X_CDT_ENABLE_TEST), + 30000, 100000, true); + + return ret < 0 ? ret : 0; +} + static int qca808x_cable_test_get_status(struct phy_device *phydev, bool *finished) { int ret, val; @@ -2111,11 +2146,11 @@ static int qca808x_cable_test_get_status(struct phy_device *phydev, bool *finish *finished = false; - ret = at803x_cdt_start(phydev, 0); + ret = qca808x_cdt_start(phydev); if (ret) return ret; - ret = at803x_cdt_wait_for_completion(phydev); + ret = qca808x_cdt_wait_for_completition(phydev); if (ret) return ret; @@ -2360,7 +2395,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,