Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp602703pxb; Fri, 13 Aug 2021 02:06:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwB+X3y0qbFoGqQXUTl+VCkfa0naDrh7MSPvoftFseYzRSB1oR5KWNuodWJBEiZHESsHKxp X-Received: by 2002:a17:906:d1d6:: with SMTP id bs22mr1413098ejb.554.1628845600368; Fri, 13 Aug 2021 02:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628845600; cv=none; d=google.com; s=arc-20160816; b=zsUMbV7YKaIV95I2rv/m1aysdqqMYC4vey90czYMcxjC5Aq9fVfJJXZBpjz/vT927q hTS+sLWv7d1P9EXxY+YnHKfRTikdBOkNDTMHZw4HxVB4oDm9vR6vB+1JabXoGzBGwYR8 h1YQ9YVqqiHUFQ6PW2kO/sgAB8BFjPyx2sXRg1OU06TQoBJ8yOfVAkAsGenfL52uyqFu dSdHeBQOlZ8vBy6zyCaeAQUdBAi0aA4fWomRby/KpxdKM3MEI8CB/H30LAM57+7orMks TZlzCQucG4zoOGaIzDwoyXY+fsQoHMUcTMSxpgbib8CQoXnXKh48b2f7CibcqzbLFUVr 65vA== 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=4JkVdJqO6rNbDhv8Wpt2BDqSVMCYPtK4M4U6ln/6sfo=; b=t6B6EMpGoz9GPbiWxWvn14WuOMvZpEcpB66mLtUvkG+Yn2nZpFnvlzsjpKHluhQckU miHjH6kstST3Rxq/41RcaJRMCIXABRZEERsQzCTHWlt8cCMWu+2XwWow+70G9q5NaPt+ e3rKalf5vW1zTq93v4uR0jfwRsK6iEgaOO1QeVGoNlmSdMeBhUWDiakVNwEgcCKF45lw QWkfOmHrpLZHVgbPw5EGntagqQ1MtQHj7le6lGyKYZoCMsIS/B6Xy/vgy1CAZMMz+crh sbOHCSaLTBDFUEgwIQS9qibAysiCUE1coGKSwpL2RYNJ58JK82TxAHGTjayk5j62lRTd Owtg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ee53si1180353edb.395.2021.08.13.02.06.16; Fri, 13 Aug 2021 02:06:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239844AbhHMIwc (ORCPT + 99 others); Fri, 13 Aug 2021 04:52:32 -0400 Received: from mga02.intel.com ([134.134.136.20]:46852 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239327AbhHMIwb (ORCPT ); Fri, 13 Aug 2021 04:52:31 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10074"; a="202720766" X-IronPort-AV: E=Sophos;i="5.84,318,1620716400"; d="scan'208";a="202720766" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2021 01:52:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,318,1620716400"; d="scan'208";a="422174640" Received: from siang-ilbpg0.png.intel.com ([10.88.227.28]) by orsmga006.jf.intel.com with ESMTP; 13 Aug 2021 01:52:02 -0700 From: Song Yoong Siang To: Andrew Lunn , Heiner Kallweit , Russell King , "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Song Yoong Siang Subject: [PATCH net-next 1/1] net: phy: marvell: Add WAKE_PHY support to WOL event Date: Fri, 13 Aug 2021 16:45:08 +0800 Message-Id: <20210813084508.182333-1-yoong.siang.song@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add Wake-on-PHY feature support by enabling the Link Up Event. Signed-off-by: Song Yoong Siang --- drivers/net/phy/marvell.c | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index 3de93c9f2744..415e2a01c151 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -155,6 +155,7 @@ #define MII_88E1318S_PHY_WOL_CTRL 0x10 #define MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS BIT(12) +#define MII_88E1318S_PHY_WOL_CTRL_LINK_UP_ENABLE BIT(13) #define MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE BIT(14) #define MII_PHY_LED_CTRL 16 @@ -1746,13 +1747,19 @@ static void m88e1318_get_wol(struct phy_device *phydev, { int ret; - wol->supported = WAKE_MAGIC; + wol->supported = WAKE_MAGIC | WAKE_PHY; wol->wolopts = 0; ret = phy_read_paged(phydev, MII_MARVELL_WOL_PAGE, MII_88E1318S_PHY_WOL_CTRL); - if (ret >= 0 && ret & MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE) + if (ret < 0) + return; + + if (ret & MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE) wol->wolopts |= WAKE_MAGIC; + + if (ret & MII_88E1318S_PHY_WOL_CTRL_LINK_UP_ENABLE) + wol->wolopts |= WAKE_PHY; } static int m88e1318_set_wol(struct phy_device *phydev, @@ -1764,7 +1771,7 @@ static int m88e1318_set_wol(struct phy_device *phydev, if (oldpage < 0) goto error; - if (wol->wolopts & WAKE_MAGIC) { + if (wol->wolopts & (WAKE_MAGIC | WAKE_PHY)) { /* Explicitly switch to page 0x00, just to be sure */ err = marvell_write_page(phydev, MII_MARVELL_COPPER_PAGE); if (err < 0) @@ -1796,7 +1803,9 @@ static int m88e1318_set_wol(struct phy_device *phydev, MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW); if (err < 0) goto error; + } + if (wol->wolopts & WAKE_MAGIC) { err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE); if (err < 0) goto error; @@ -1837,6 +1846,30 @@ static int m88e1318_set_wol(struct phy_device *phydev, goto error; } + if (wol->wolopts & WAKE_PHY) { + err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE); + if (err < 0) + goto error; + + /* Clear WOL status and enable link up event */ + err = __phy_modify(phydev, MII_88E1318S_PHY_WOL_CTRL, 0, + MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS | + MII_88E1318S_PHY_WOL_CTRL_LINK_UP_ENABLE); + if (err < 0) + goto error; + } else { + err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE); + if (err < 0) + goto error; + + /* Clear WOL status and disable link up event */ + err = __phy_modify(phydev, MII_88E1318S_PHY_WOL_CTRL, + MII_88E1318S_PHY_WOL_CTRL_LINK_UP_ENABLE, + MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS); + if (err < 0) + goto error; + } + error: return phy_restore_page(phydev, oldpage, err); } -- 2.25.1