From patchwork Tue Feb 21 22:40:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Yang X-Patchwork-Id: 60283 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp259661wrd; Tue, 21 Feb 2023 14:42:22 -0800 (PST) X-Google-Smtp-Source: AK7set+BGgAZ4Tnluxrl9R4Im1Rzuv13J3TPtRXxmCVPus7NCxrCAC/bJaCvDw8NgyAFnI57lfHy X-Received: by 2002:a17:906:868b:b0:8af:2fa1:2226 with SMTP id g11-20020a170906868b00b008af2fa12226mr11733986ejx.6.1677019342540; Tue, 21 Feb 2023 14:42:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677019342; cv=none; d=google.com; s=arc-20160816; b=wxq4R6VrpNMPFPyEYYLEqx8zEFnh4iuHtWL06obuIJJQcok06Lg+eM94jH1NYd2ymC IGa7RIyVU4EdzrOOouhcxLyT3bc39QFeGqEyAVyj209khSFp23LtrNGERinLJf0OboA0 MyzeNIzic2k7SwUmyQmFP8e1lJAGDZEzxDBH5Yz0HctBKtzFAfGGYrELq6btekc2ZZYC o6t1kXwLg0DauogRvOEPg2KlfI8Nwk5j6BIhg+Hz6ZhRoPLvlMPCKxIGfLlFYox+2fhA JCsn2/zJcCrg4NHVh/HNmHfa0CJu6htdeDynzuuHHfl8+ZMwIyjg3AOKNpeUv02CxoaJ 9WOg== 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 :message-id:date:subject:cc:to:from; bh=Ph8bOdCBT6nmZMFjDJOf5Qs7U61gyfsOeE8KRmUAXNQ=; b=iiKGCnIGilh1JPFuLgew497LyQ1zRn13xu5REQsV5xYsy/ptWY3/OBueYZJnfVC/Jf HQECAdTawHqnK91wlNe2R+EDWdDr8JbHNyDJAhzdFsRb6gohXVCpn9j8jHs8ynhW9j2k BrqtyBEIb1xW2w0ebvO5EWemJYTsaxs2LMZVaWdxH7S2FpbGVOhxR4G0bj9QaNyFdYff 0lfj1l5cQgmMXni0KeE0ilS1nnv2VTwplBgL0BZnCghCP+427eswDRcjI0WYhy1Kr4Kf mWPq8grezL4TQ84vrUSl18OPQ5GJScYOKN/8yOkhHVgNY5oJNapxdHzkUAWhy4LJjb73 jezw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wi14-20020a170906fd4e00b008e496c408aesi1361458ejb.709.2023.02.21.14.41.58; Tue, 21 Feb 2023 14:42:22 -0800 (PST) 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 S230281AbjBUWlK (ORCPT + 99 others); Tue, 21 Feb 2023 17:41:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229874AbjBUWlI (ORCPT ); Tue, 21 Feb 2023 17:41:08 -0500 Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD40810FD; Tue, 21 Feb 2023 14:41:03 -0800 (PST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 377B62004C7; Tue, 21 Feb 2023 23:41:02 +0100 (CET) Received: from smtp.na-rdc02.nxp.com (usphx01srsp001v.us-phx01.nxp.com [134.27.49.11]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id C09BC2001FF; Tue, 21 Feb 2023 23:41:01 +0100 (CET) Received: from right.am.freescale.net (right.am.freescale.net [10.81.116.134]) by usphx01srsp001v.us-phx01.nxp.com (Postfix) with ESMTP id 5501F4023B; Tue, 21 Feb 2023 15:41:00 -0700 (MST) From: Li Yang To: Andrew Lunn , Heiner Kallweit , Russell King , "David S . Miller" , Jakub Kicinski , Luo Jie Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Li Yang , Viorel Suman , Wei Fang Subject: [PATCH] net: phy: at803x: fix the wol setting functions Date: Tue, 21 Feb 2023 16:40:31 -0600 Message-Id: <20230221224031.7244-1-leoyang.li@nxp.com> X-Mailer: git-send-email 2.25.1.377.g2d2118b MIME-Version: 1.0 X-Virus-Scanned: ClamAV using ClamSMTP X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758482234375549915?= X-GMAIL-MSGID: =?utf-8?q?1758482234375549915?= In 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 d7cd5e06c9dd ("net: phy: at803x: disable WOL at probe") is no longer needed. So it is removed. Also remove the set_wol()/get_wol() callbacks from AR8032 which doesn't support WoL. Fixes: 7beecaf7d507b ("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 | 42 +++++++++++++++------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 22f4458274aa..ac47a1d681b2 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -461,21 +461,25 @@ 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) @@ -510,11 +514,8 @@ 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); - if (value < 0) - return; - - if (value & AT803X_WOL_EN) + value = phy_read(phydev, AT803X_INTR_ENABLE); + if (value & AT803X_INTR_ENABLE_WOL) wol->wolopts |= WAKE_MAGIC; } @@ -866,9 +867,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) { ret = ccr; @@ -887,12 +885,6 @@ static int at803x_probe(struct phy_device *phydev) 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); - goto err; - } } return 0; @@ -2087,8 +2079,6 @@ static struct phy_driver at803x_driver[] = { .flags = PHY_POLL_CABLE_TEST, .config_init = at803x_config_init, .link_change_notify = at803x_link_change_notify, - .set_wol = at803x_set_wol, - .get_wol = at803x_get_wol, .suspend = at803x_suspend, .resume = at803x_resume, /* PHY_BASIC_FEATURES */