[net-next,v2,08/12] net: phy: at803x: move specific at8031 WOL bits to dedicated function
Message ID | 20231201001423.20989-9-ansuelsmth@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp776528vqy; Thu, 30 Nov 2023 16:16:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IGjz2DbMlTh2P6vJMJIG4TrxddcVeJsgxvPmwXMRjeqWP5DrlB44yXTaX1QMrejL++ItIDc X-Received: by 2002:a05:6a20:3c9f:b0:187:e3a5:b35d with SMTP id b31-20020a056a203c9f00b00187e3a5b35dmr30249918pzj.13.1701389777326; Thu, 30 Nov 2023 16:16:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701389777; cv=none; d=google.com; s=arc-20160816; b=siTcCKH+z32lTGpl08Ve915u68IW3SAXuZkG5ESFmWqu5VjiSIbUiNAkHe/DCLkrHk GLs/KYYmggGJnZU3mrjLion8rvXe3+j9XPbPqsp6diRHSm6qZbsxPtU+bOy91Oi25zNb R4w68DCoXdHPI0bcpik/rWKtC/thM/PcIdLxtFZsjTdH5jGGwuiGbrT+Lv4x1jjd3+wg bKWk2hJxprvp25UUA05gmeZCVhNqjDzgfg75GFEpAtANLry9y7cGoJz6ZknaUIw3N9mW MOzfLS5t0lPrLZLFloqteUybIU2UjZcLGGkjDMfuqCprE37kteaCJwLOwSzxqpiTj2gl 3IeQ== 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=Lg7qa9kgNv3JPVirMlKzkE9ZBdZKAWAeOTAv7Yn8WPU=; fh=utmrxdkgikAlLxVfQI1kldUG+rNjhrLN+3fAlOYj01s=; b=Pzfe/KMAv9Y7t5s3wWNixWy1/EaRQiLJFlbKHwsePMWRxqY98OywqP85A74eRut55o 3wtSCQH8b5iOgA73G9eWQ1hHcp/I+/i8sMg92WOEddOIze85D+HShc4oWMftmTWy+VHn /L3WOEPh4ypGR1CuvkttodOoLHs6V48hA7SPQ3gIDDozE0UrSSpibGlu1TMPxbxgs8XR dCh6+tXQyKOCNsgybMoMAj0H9li3g0RVsVVc+plGc10uGVh05RR54QtCHz18zpDgCowP a868A4P53WaRW6E0wNfiYEBAFVIlHoH6bpTYzewzfI6Gqnd2bBSjO451+/qnaRAe5wSr q9BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GovzP+pz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id s38-20020a056a0017a600b006cd8cabde34si2325998pfg.71.2023.11.30.16.16.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 16:16:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GovzP+pz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 29B7880F6D16; Thu, 30 Nov 2023 16:16:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377411AbjLAAPO (ORCPT <rfc822;ruipengqi7@gmail.com> + 99 others); Thu, 30 Nov 2023 19:15:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377416AbjLAAPC (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 30 Nov 2023 19:15:02 -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 8FFCE1713; Thu, 30 Nov 2023 16:14:58 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40b474c925bso11565075e9.3; Thu, 30 Nov 2023 16:14:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701389697; x=1701994497; 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=Lg7qa9kgNv3JPVirMlKzkE9ZBdZKAWAeOTAv7Yn8WPU=; b=GovzP+pz0W2rx7ANrQQ4VMX3XgKrw74AF64oBej8McdvMoNfjfXa8xIXyVZVYZgsm6 98QjPBaLEykVUKjZzgdlgOlTQ+4ut1jttbgxySpbLtuEGc6E32XolJUQoV/B5p4t6zVc lk/J251gNAJgGxSC1j0aSqxWwhur7qzEe4LiZt1iqwwlh2BESzHsxPoQpaNh7YfPSHA4 MGFSoVJLSFIrqvZmz3eTeWjJT7c5F2kvMRwYeUV/I9ZZjhGFmtOfc/Whb2r+vD2XCqWz mVbI1qkCvqVLOjDDbUZ7ltiOakOClAryd8vRxCTBPIaDCccLTpRXtkuE17teFAwaNO9P V/Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701389697; x=1701994497; 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=Lg7qa9kgNv3JPVirMlKzkE9ZBdZKAWAeOTAv7Yn8WPU=; b=vdj+zSUNBvsGOLEuR9bfKwl3mX1T1vmxJa/aMZq18FfvztuGWnwmBQiOKcnPW6/s+j cTuE2oCPwEkxZLoAn9f4jLrGNZjjj29761/kioNu6do5KTwp63rdhmMrCLOM5V8fK1C6 Zr9w9UJK6T5Q+AR4gaKxUeedHPmb+ZwM/qf1kFDk0LzZxFlviYd/O23bPwq7bSzS5gUt a7+5ilmcm0JqNVwfWshgheYArwUa41gDERxqV9NZhj1NxBgGwXOQViDlwpq1EAygH/4h aO9VjtYfR3E//KaJWEVbHcYR8aXpM7hsNL1lxV5l8/Mvo0Q9EpakndB1QspIceN8ZcfV sX2A== X-Gm-Message-State: AOJu0Yw8Y9mctAZ9OB76fWCs1i7AumW+26rfQX5R1cWu2nI0JMuuMQqS NL63z3Rs8H7F6FG/qRLbC4eq8a/t2mQ= X-Received: by 2002:a1c:7c0d:0:b0:40b:5e59:b7c5 with SMTP id x13-20020a1c7c0d000000b0040b5e59b7c5mr129344wmc.162.1701389696941; Thu, 30 Nov 2023 16:14:56 -0800 (PST) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id g16-20020a05600c4ed000b0040b47c53610sm3535457wmq.14.2023.11.30.16.14.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 16:14:56 -0800 (PST) From: Christian Marangi <ansuelsmth@gmail.com> To: Andrew Lunn <andrew@lunn.ch>, Heiner Kallweit <hkallweit1@gmail.com>, Russell King <linux@armlinux.org.uk>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christian Marangi <ansuelsmth@gmail.com> Subject: [net-next PATCH v2 08/12] net: phy: at803x: move specific at8031 WOL bits to dedicated function Date: Fri, 1 Dec 2023 01:14:18 +0100 Message-Id: <20231201001423.20989-9-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231201001423.20989-1-ansuelsmth@gmail.com> References: <20231201001423.20989-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 fry.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 30 Nov 2023 16:16:08 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784036486926115767 X-GMAIL-MSGID: 1784036486926115767 |
Series |
net: phy: at803x: cleanup
|
|
Commit Message
Christian Marangi
Dec. 1, 2023, 12:14 a.m. UTC
Move specific at8031 WOL enable/disable to dedicated function to make
at803x_set_wol more generic.
This is needed in preparation for PHY driver split as qca8081 share the
same function to toggle WOL settings.
In this new implementation WOL module in at8031 is enabled after the
generic interrupt is setup. This should not cause any problem as the
WOL_INT has a separate implementation and only relay on MAC bits.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
drivers/net/phy/at803x.c | 42 ++++++++++++++++++++++++----------------
1 file changed, 25 insertions(+), 17 deletions(-)
Comments
On Fri, 2023-12-01 at 01:14 +0100, Christian Marangi wrote: > Move specific at8031 WOL enable/disable to dedicated function to make > at803x_set_wol more generic. > > This is needed in preparation for PHY driver split as qca8081 share the > same function to toggle WOL settings. > > In this new implementation WOL module in at8031 is enabled after the > generic interrupt is setup. This should not cause any problem as the > WOL_INT has a separate implementation and only relay on MAC bits. > > Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> > --- > drivers/net/phy/at803x.c | 42 ++++++++++++++++++++++++---------------- > 1 file changed, 25 insertions(+), 17 deletions(-) > > diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c > index 02ac71f98466..2de7a59c0faa 100644 > --- a/drivers/net/phy/at803x.c > +++ b/drivers/net/phy/at803x.c > @@ -466,27 +466,11 @@ 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 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 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) > @@ -1611,6 +1595,30 @@ static int at8031_config_init(struct phy_device *phydev) > return at803x_config_init(phydev); > } > > +static int at8031_set_wol(struct phy_device *phydev, > + struct ethtool_wolinfo *wol) > +{ > + int ret; > + > + /* First setup MAC address and enable WOL interrupt */ > + ret = at803x_set_wol(phydev, wol); > + if (ret) > + return ret; > + > + if (wol->wolopts & WAKE_MAGIC) > + /* Enable WOL function for 1588 */ > + ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, > + AT803X_PHY_MMD3_WOL_CTRL, > + 0, AT803X_WOL_EN); > + else > + /* Disable WoL function for 1588 */ > + ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, > + AT803X_PHY_MMD3_WOL_CTRL, > + AT803X_WOL_EN, 0); > + > + return ret; If I read correctly, the above changes the order of some WoL initialization steps: now WOL_CTRL is touched after AT803X_INTR_ENABLE_WOL. Is that correct? Thanks, Paolo
On Tue, Dec 05, 2023 at 10:32:55AM +0100, Paolo Abeni wrote: > On Fri, 2023-12-01 at 01:14 +0100, Christian Marangi wrote: > > Move specific at8031 WOL enable/disable to dedicated function to make > > at803x_set_wol more generic. > > > > This is needed in preparation for PHY driver split as qca8081 share the > > same function to toggle WOL settings. > > > > In this new implementation WOL module in at8031 is enabled after the > > generic interrupt is setup. This should not cause any problem as the > > WOL_INT has a separate implementation and only relay on MAC bits. > > > > Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> > > --- > > drivers/net/phy/at803x.c | 42 ++++++++++++++++++++++++---------------- > > 1 file changed, 25 insertions(+), 17 deletions(-) > > > > diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c > > index 02ac71f98466..2de7a59c0faa 100644 > > --- a/drivers/net/phy/at803x.c > > +++ b/drivers/net/phy/at803x.c > > @@ -466,27 +466,11 @@ 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 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 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) > > @@ -1611,6 +1595,30 @@ static int at8031_config_init(struct phy_device *phydev) > > return at803x_config_init(phydev); > > } > > > > +static int at8031_set_wol(struct phy_device *phydev, > > + struct ethtool_wolinfo *wol) > > +{ > > + int ret; > > + > > + /* First setup MAC address and enable WOL interrupt */ > > + ret = at803x_set_wol(phydev, wol); > > + if (ret) > > + return ret; > > + > > + if (wol->wolopts & WAKE_MAGIC) > > + /* Enable WOL function for 1588 */ > > + ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, > > + AT803X_PHY_MMD3_WOL_CTRL, > > + 0, AT803X_WOL_EN); > > + else > > + /* Disable WoL function for 1588 */ > > + ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, > > + AT803X_PHY_MMD3_WOL_CTRL, > > + AT803X_WOL_EN, 0); > > + > > + return ret; > > If I read correctly, the above changes the order of some WoL > initialization steps: now WOL_CTRL is touched after > AT803X_INTR_ENABLE_WOL. Is that correct? Correct, as it was pointed out, in the previous revision the WOL was enabled before setting the MAC leaving some timeframe where we had interrupt that could be triggered by invalind MAC (and also in case MAC setup was failing the WOL was laved enabled) The current change should be safe enough as the WOL module is enabled at the end of all the required setup preventing any kind of misconfiguration if something fails before.
On Tue, Dec 05, 2023 at 10:32:55AM +0100, Paolo Abeni wrote: > On Fri, 2023-12-01 at 01:14 +0100, Christian Marangi wrote: > > Move specific at8031 WOL enable/disable to dedicated function to make > > at803x_set_wol more generic. > > > > This is needed in preparation for PHY driver split as qca8081 share the > > same function to toggle WOL settings. > > > > In this new implementation WOL module in at8031 is enabled after the > > generic interrupt is setup. This should not cause any problem as the > > WOL_INT has a separate implementation and only relay on MAC bits. > > > > Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> > > --- > > drivers/net/phy/at803x.c | 42 ++++++++++++++++++++++++---------------- > > 1 file changed, 25 insertions(+), 17 deletions(-) > > > > diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c > > index 02ac71f98466..2de7a59c0faa 100644 > > --- a/drivers/net/phy/at803x.c > > +++ b/drivers/net/phy/at803x.c > > @@ -466,27 +466,11 @@ 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 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 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) > > @@ -1611,6 +1595,30 @@ static int at8031_config_init(struct phy_device *phydev) > > return at803x_config_init(phydev); > > } > > > > +static int at8031_set_wol(struct phy_device *phydev, > > + struct ethtool_wolinfo *wol) > > +{ > > + int ret; > > + > > + /* First setup MAC address and enable WOL interrupt */ > > + ret = at803x_set_wol(phydev, wol); > > + if (ret) > > + return ret; > > + > > + if (wol->wolopts & WAKE_MAGIC) > > + /* Enable WOL function for 1588 */ > > + ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, > > + AT803X_PHY_MMD3_WOL_CTRL, > > + 0, AT803X_WOL_EN); > > + else > > + /* Disable WoL function for 1588 */ > > + ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, > > + AT803X_PHY_MMD3_WOL_CTRL, > > + AT803X_WOL_EN, 0); > > + > > + return ret; > > If I read correctly, the above changes the order of some WoL > initialization steps: now WOL_CTRL is touched after > AT803X_INTR_ENABLE_WOL. Is that correct? It is fine. AT803X_INTR_ENABLE_WOL enables or disables whether the INT pin (which is used for any interrupt from the PHY) is used to signal WOL - it's the interrupt enable for the WoL function. The MMD3 WOL_EN bit controls whether the WoL function is enabled, and thus whether the WOL_INT pin will signal WoL. WOL_EN should not be set until we have initialised the WoL function, and thus that needs to happen _after_ the MAC address has been programmed. Clearing WOL_EN afterwards is not a problem because it will already have been setup, or is in its power-on default state.
diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 02ac71f98466..2de7a59c0faa 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -466,27 +466,11 @@ 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 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 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) @@ -1611,6 +1595,30 @@ static int at8031_config_init(struct phy_device *phydev) return at803x_config_init(phydev); } +static int at8031_set_wol(struct phy_device *phydev, + struct ethtool_wolinfo *wol) +{ + int ret; + + /* First setup MAC address and enable WOL interrupt */ + ret = at803x_set_wol(phydev, wol); + if (ret) + return ret; + + if (wol->wolopts & WAKE_MAGIC) + /* Enable WOL function for 1588 */ + ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, + AT803X_PHY_MMD3_WOL_CTRL, + 0, AT803X_WOL_EN); + else + /* Disable WoL function for 1588 */ + ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, + AT803X_PHY_MMD3_WOL_CTRL, + AT803X_WOL_EN, 0); + + return ret; +} + static int qca83xx_config_init(struct phy_device *phydev) { u8 switch_revision; @@ -2123,7 +2131,7 @@ static struct phy_driver at803x_driver[] = { .config_init = at8031_config_init, .config_aneg = at803x_config_aneg, .soft_reset = genphy_soft_reset, - .set_wol = at803x_set_wol, + .set_wol = at8031_set_wol, .get_wol = at803x_get_wol, .suspend = at803x_suspend, .resume = at803x_resume,