Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1851566rwb; Fri, 28 Jul 2023 16:33:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlHFVh8ZokY/qq15lAwh9y6hzcdoBjDGo1IxyMJ5GtjNjIS6wgoLUXe+H9wQU9jn8AOR+AmY X-Received: by 2002:a17:90b:16ce:b0:268:18d6:101a with SMTP id iy14-20020a17090b16ce00b0026818d6101amr2995700pjb.14.1690587223940; Fri, 28 Jul 2023 16:33:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690587223; cv=none; d=google.com; s=arc-20160816; b=RCqjL0++Lb3VbjH7irnyfrj4zilO3MtuiGZ8fWnNTTo4daz9BrhiagpXjAbgd6nVcN 7kPm6Oqz3ne7QIs7Q+BJXjE5hDdelMboRA841A8mYCOIfI+Rkw298f4Y1JQCuEp4nFCb BwQfpIfptMACj/qi1vulZTcd9vgpuvtFGJd0F0q88eNOu4CIC9OgtjP1pbxlnWwuNlLG TKjauANUskqc/FKteaTsIIleEXyu8jn8tr1NLI92RJUirlFUNBKZ3QxaBaWOzz4pnB9R 83JeHWfr2heywCbIIPBsvLx53fT2A/rh44T8k9HwbJuesg5b4VRbDRr9/UaAxq1i7tt2 kMyA== 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; bh=7hZtUbGv32OIWHGKdlpu4n0zm8H+tC7MoQOoyAFT05o=; fh=6wQ8A3cuGJr8eY6k+/6q/5O1FDi6YEtB8qDQlwYXszE=; b=hDTc672Z2aPbT8qdmA/UNtOPSFs25ETHkJmtNzj5/TfkrRaFTwiLt/QVme9F1iLcer 3t9hxHLBk8sjsyN54WKG8xvQStEEs0Mgd2X+wISDg54cgvmCjbsV6IV+ZRZnA+NChB2r FsgrZQ2EQQQhKKsFPcg2lmTrpqtOtQ0DrSyJNDAzkOUriF0lBUWiwVz1lncpwOJSUQuw A0Isr8j5v3p2tP5VkNtuW6aLxaTOuhPcmfy8zTHXpYk/Xa3vug8xb1mRdqNeRZMnG4OB pRHSMiFdtiKc9MGQyf8H83IJixFgKcHpN+6Anaz41nGf0c7IlyZ2ih3a59uTxfZdF1Sm oFiw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lb3-20020a17090b4a4300b0026805ee16e0si4029036pjb.130.2023.07.28.16.33.32; Fri, 28 Jul 2023 16:33:43 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235145AbjG1WCi (ORCPT + 99 others); Fri, 28 Jul 2023 18:02:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231146AbjG1WCg (ORCPT ); Fri, 28 Jul 2023 18:02:36 -0400 Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BFD32D61; Fri, 28 Jul 2023 15:02:15 -0700 (PDT) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id D554B1A00F3; Fri, 28 Jul 2023 23:53:34 +0200 (CEST) Received: from smtp.na-rdc02.nxp.com (usphx01srsp001v.us-phx01.nxp.com [134.27.49.11]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 7660F1A0086; Fri, 28 Jul 2023 23:53:34 +0200 (CEST) Received: from right.am.freescale.net (right.am.freescale.net [10.81.116.134]) by usphx01srsp001v.us-phx01.nxp.com (Postfix) with ESMTP id 11D214058C; Fri, 28 Jul 2023 14:53:33 -0700 (MST) From: Li Yang To: Andrew Lunn , Heiner Kallweit , Russell King , "David S . Miller" , Jakub Kicinski , David Bauer Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Li Yang , Viorel Suman , Wei Fang Subject: [PATCH v3 1/2] net: phy: at803x: fix the wol setting functions Date: Fri, 28 Jul 2023 16:53:19 -0500 Message-Id: <20230728215320.31801-2-leoyang.li@nxp.com> X-Mailer: git-send-email 2.25.1.377.g2d2118b In-Reply-To: <20230728215320.31801-1-leoyang.li@nxp.com> References: <20230728215320.31801-1-leoyang.li@nxp.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV using ClamSMTP X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 In commit 7beecaf7d507 ("net: phy: at803x: improve the WOL feature"), it seems not correct to use a wol_en bit in a 1588 Control Register which is only available on AR8031/AR8033(share the same phy_id) to determine if WoL is enabled. Change it back to use AT803X_INTR_ENABLE_WOL for determining the WoL status which is applicable on all chips supporting wol. Also update the at803x_set_wol() function to only update the 1588 register on chips having it. After this change, disabling wol at probe from commit d7cd5e06c9dd ("net: phy: at803x: disable WOL at probe") is no longer needed. So that part is removed. Fixes: 7beecaf7d507 ("net: phy: at803x: improve the WOL feature") Signed-off-by: Li Yang Reviewed-by: Viorel Suman Reviewed-by: Wei Fang --- drivers/net/phy/at803x.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index c1f307d90518..1d61f7190367 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -459,21 +459,27 @@ static int at803x_set_wol(struct phy_device *phydev, phy_write_mmd(phydev, MDIO_MMD_PCS, offsets[i], mac[(i * 2) + 1] | (mac[(i * 2)] << 8)); - /* Enable WOL function */ - ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_PHY_MMD3_WOL_CTRL, - 0, AT803X_WOL_EN); - if (ret) - return ret; + /* Enable WOL function for 1588 */ + if (phydev->drv->phy_id == ATH8031_PHY_ID) { + ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, + AT803X_PHY_MMD3_WOL_CTRL, + 0, AT803X_WOL_EN); + if (ret) + return ret; + } /* Enable WOL interrupt */ ret = phy_modify(phydev, AT803X_INTR_ENABLE, 0, AT803X_INTR_ENABLE_WOL); if (ret) return ret; } else { - /* Disable WoL function */ - ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_PHY_MMD3_WOL_CTRL, - AT803X_WOL_EN, 0); - if (ret) - return ret; + /* Disable WoL function for 1588 */ + if (phydev->drv->phy_id == ATH8031_PHY_ID) { + ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, + AT803X_PHY_MMD3_WOL_CTRL, + AT803X_WOL_EN, 0); + if (ret) + return ret; + } /* Disable WOL interrupt */ ret = phy_modify(phydev, AT803X_INTR_ENABLE, AT803X_INTR_ENABLE_WOL, 0); if (ret) @@ -508,11 +514,11 @@ static void at803x_get_wol(struct phy_device *phydev, wol->supported = WAKE_MAGIC; wol->wolopts = 0; - value = phy_read_mmd(phydev, MDIO_MMD_PCS, AT803X_PHY_MMD3_WOL_CTRL); + value = phy_read(phydev, AT803X_INTR_ENABLE); if (value < 0) return; - if (value & AT803X_WOL_EN) + if (value & AT803X_INTR_ENABLE_WOL) wol->wolopts |= WAKE_MAGIC; } @@ -858,9 +864,6 @@ static int at803x_probe(struct phy_device *phydev) if (phydev->drv->phy_id == ATH8031_PHY_ID) { int ccr = phy_read(phydev, AT803X_REG_CHIP_CONFIG); int mode_cfg; - struct ethtool_wolinfo wol = { - .wolopts = 0, - }; if (ccr < 0) return ccr; @@ -876,13 +879,6 @@ static int at803x_probe(struct phy_device *phydev) priv->is_fiber = true; break; } - - /* Disable WOL by default */ - ret = at803x_set_wol(phydev, &wol); - if (ret < 0) { - phydev_err(phydev, "failed to disable WOL on probe: %d\n", ret); - return ret; - } } return 0; -- 2.25.1.377.g2d2118b