Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp347310pxb; Fri, 15 Oct 2021 06:45:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydEjXSNJtr5BHLMYBCC0GvLj/kcdYjto+FkoKnk7D0HFrDwe0IKwGRBvE73qNUIVnHfniB X-Received: by 2002:a63:9508:: with SMTP id p8mr9036124pgd.413.1634305505453; Fri, 15 Oct 2021 06:45:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634305505; cv=none; d=google.com; s=arc-20160816; b=0gWXX1lt4ZIlV07wnM5rT+wHBmH0iv3RMVNV/fRQCDuLgi6qcZqEAB58Geb7u+wy+m WMNri4hrC52Rdo3bXaNUwFPX6pp4cw+Z890zOvmabMtIE2l9QQSeriWu+ExmVg/krOYA AsGp55nbN+KBmhYXdVcal6jgXa7moMuRpKAwsiKfAy/Ea9NrHSemyVW75FEvDbciKhGx vkONalsbfDiK9ZNbMW0wBfoKi+Idvj2Jq5eNdL45HOwOZaW2z/hM84HTzX8u5UG6sGNN g7NvDsju2a/+063T22UAtXOrIgVJ6H0zDHX3MyiLhviAyfIpPe70OCsdj14p5J6EjmLL +/CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dmarc-filter:sender:dkim-signature; bh=Lo3W/Te7SVFoiKgMizE9XcNF5nGE8jBoH5W/RjHiz0M=; b=EtrWEe6I4FlyB5IFahqj7cbvrkjuHQmRXfg6kiLDvDwTKI1K5yvlMuyCrB1kTG5Fgb +YB+LdhoybQ+Ljmwja4x3+iMCihgLb67Fok7iKR9ugscRJUTQFD1bHEIhkMHv0zXU+8H A6pL3WSYtPxae5jJuOP50n2J+mCNG0nmmr5nvGxQbLPcihPGe9CoOjfr7g2f0BDGKUgC s2C1TRHMrzH5pEU7D5aRmUtNWfEC1yINDZhJtiQZY+iBYRgbx7/FKIcmfDPZo+xEpAQm ObEKecN18lgTXQ/vhU4q/dYwaPPQ6w963RLuZewiTQqIShbW56dQ0I8hZvmdSVlaEBgk lTMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=NulRkhbe; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 30si8036883pgr.183.2021.10.15.06.44.30; Fri, 15 Oct 2021 06:45:05 -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; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=NulRkhbe; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236157AbhJOHhn (ORCPT + 99 others); Fri, 15 Oct 2021 03:37:43 -0400 Received: from so254-9.mailgun.net ([198.61.254.9]:34544 "EHLO so254-9.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236127AbhJOHhm (ORCPT ); Fri, 15 Oct 2021 03:37:42 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1634283336; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=Lo3W/Te7SVFoiKgMizE9XcNF5nGE8jBoH5W/RjHiz0M=; b=NulRkhbeFVNGXnAZmqvFwVpvnEyZHCFVjEeIu6EeipxIbfJI+vTASwa6x9xpTPOc2BSZBJbc M4qiboPKt717RfghInbTOyhH7mugKBuViUxJZK8UgNkpI4cfIEQphTC9FGmpQkT4O1YIxEgC KJn1bJkfWAZ5l6B+bW21LGZ7E7Y= X-Mailgun-Sending-Ip: 198.61.254.9 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n01.prod.us-west-2.postgun.com with SMTP id 61692f4030ce13d2b487b506 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Fri, 15 Oct 2021 07:35:28 GMT Sender: luoj=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 7581FC43460; Fri, 15 Oct 2021 07:35:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from akronite-sh-dev02.qualcomm.com (unknown [180.166.53.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luoj) by smtp.codeaurora.org (Postfix) with ESMTPSA id 40441C4338F; Fri, 15 Oct 2021 07:35:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.codeaurora.org 40441C4338F Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=codeaurora.org From: Luo Jie To: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, sricharan@codeaurora.org, Luo Jie Subject: [PATCH v2 03/13] net: phy: at803x: improve the WOL feature Date: Fri, 15 Oct 2021 15:34:55 +0800 Message-Id: <20211015073505.1893-4-luoj@codeaurora.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211015073505.1893-1-luoj@codeaurora.org> References: <20211015073505.1893-1-luoj@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The wol feature is controlled by the MMD3.8012 bit5, need to set this bit when the wol function is enabled. The reg18 bit0 is for enabling WOL interrupt, when wol occurs, the wol interrupt status reg19 bit0 is set to 1. Signed-off-by: Luo Jie --- drivers/net/phy/at803x.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index c5e145ff5ec8..2f7d96bd1be8 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -70,6 +70,8 @@ #define AT803X_CDT_STATUS_DELTA_TIME_MASK GENMASK(7, 0) #define AT803X_LED_CONTROL 0x18 +#define AT803X_PHY_MMD3_WOL_CTRL 0x8012 +#define AT803X_WOL_EN BIT(5) #define AT803X_LOC_MAC_ADDR_0_15_OFFSET 0x804C #define AT803X_LOC_MAC_ADDR_16_31_OFFSET 0x804B #define AT803X_LOC_MAC_ADDR_32_47_OFFSET 0x804A @@ -327,7 +329,6 @@ static int at803x_set_wol(struct phy_device *phydev, struct net_device *ndev = phydev->attached_dev; const u8 *mac; int ret; - u32 value; unsigned int i; const unsigned int offsets[] = { AT803X_LOC_MAC_ADDR_32_47_OFFSET, @@ -348,18 +349,29 @@ 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 interrupt */ ret = phy_modify(phydev, AT803X_INTR_ENABLE, 0, AT803X_INTR_ENABLE_WOL); if (ret) return ret; - value = phy_read(phydev, AT803X_INTR_STATUS); } 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 interrupt */ ret = phy_modify(phydev, AT803X_INTR_ENABLE, AT803X_INTR_ENABLE_WOL, 0); if (ret) return ret; - value = phy_read(phydev, AT803X_INTR_STATUS); } - return ret; + /* Clear WOL status */ + return phy_read(phydev, AT803X_INTR_STATUS); } static void at803x_get_wol(struct phy_device *phydev, @@ -370,8 +382,11 @@ static void at803x_get_wol(struct phy_device *phydev, wol->supported = WAKE_MAGIC; wol->wolopts = 0; - value = phy_read(phydev, AT803X_INTR_ENABLE); - if (value & AT803X_INTR_ENABLE_WOL) + value = phy_read_mmd(phydev, MDIO_MMD_PCS, AT803X_PHY_MMD3_WOL_CTRL); + if (value < 0) + return; + + if (value & AT803X_WOL_EN) wol->wolopts |= WAKE_MAGIC; } -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project