Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5807362rwd; Mon, 5 Jun 2023 08:49:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7OWFXAK4Ajns8XPE+NwSGkK9ax75y3HhsXPzTiVJwolsPQ+h6DNchArIf/WFoeJltW0Fun X-Received: by 2002:a05:6a00:21cb:b0:65f:1772:e253 with SMTP id t11-20020a056a0021cb00b0065f1772e253mr140652pfj.2.1685980193910; Mon, 05 Jun 2023 08:49:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685980193; cv=none; d=google.com; s=arc-20160816; b=pbx36El9/QOgJafFLIFL8slCbGpVJKXcWGtgeydGmVDi4ChJuu7Dt+NvdcOFW9OCZJ avIIBpExqvaqoKbph/muB1RAB/X1QQ41am9ZZWRN0QiYWRc73sroq6HoZpsIgjXOszeU 9auhhdbkGwbmTbY00YhRyf/GxKnz+36UrteIRKVWpyIJMVIManrCDdRQVnct3n1cvb4X TCTU8NWmf1Hm/Dwt3etsgZTD8jkPqOr3MPu4pwakQIBFti5+UsHFev9bnMHIfikd6lzB sm+TgjsvVbUmYS168piao+R1ViuTo4Ix/NIsQfjCQMxV0E1HBH9LwjjjgVjoZEvV3alg PRPA== 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=1BPx4RFa8Xe297M49f5Gqu1U0/GMT39bRHr7LV6AlIU=; b=hqarrlATvTrAz2GZMAxoJVpVdfLdX2lduVnbgkqHsxOajjWzw2OOQWtldX9neZee/M uwqhHT2cRQ6o3+Xj12Y3kD10J17/GZMKdanUG4ufi44LDFfwTM6MYXhqISI5rYjaIArf /A1LMBnpixqv6Uvd9Bi/FrwXDKhRs5yhXn1yRCHTKt2ZTHk/CVvFxBnqShFSXPJ2P9cI YB46/ssZ5VYeROBVO8fX2qhv0qwJ+GFM414BNN0PFAtZ38pIltIRm++eAU6kdi5PfrBl Tb2p1DJthgrBDsplS/CQgzuPVnB4IDcztsQEDEGTuEY7bFL+Vr5iZm3H1OAzf1rqmTjV +xUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=V1OzFLkh; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j24-20020a63cf18000000b0053f19be2174si5629792pgg.791.2023.06.05.08.49.40; Mon, 05 Jun 2023 08:49:53 -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; dkim=pass header.i=@collabora.com header.s=mail header.b=V1OzFLkh; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233688AbjFEPko (ORCPT + 99 others); Mon, 5 Jun 2023 11:40:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234926AbjFEPk2 (ORCPT ); Mon, 5 Jun 2023 11:40:28 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DE4AE4B; Mon, 5 Jun 2023 08:40:20 -0700 (PDT) Received: from arisu.mtl.collabora.ca (mtl.collabora.ca [66.171.169.34]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: detlev) by madras.collabora.co.uk (Postfix) with ESMTPSA id DE055660036A; Mon, 5 Jun 2023 16:40:17 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1685979619; bh=pTp6/xk/Wg5wGQWw/vjAgqilJMAtoUJefEJPkScDWl4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V1OzFLkh72ZNfGgey0ZL3otcPLcUv/LkTVp4ChTBsreaddqesNNasKhY8YiqvZ1yp vrd/u6f53c06Hr/BAAgyWFj2qkH6q/5xkiSkMdPNDxG8DU/DhlbMSAKgurRqAe+7LH 19FveSBeXeiGBz1LB7ZT9yQ2AivStSzOFgvHvIPuzDGCEA+KGcg/Ea77qsxxSDFrLk XIYtAgu8unZcVqLdRp4dIu+WLSobvCgnf/52qBNVL682PaYh9j5D9nfhOq6cPCYx/z DDuMAteufcIUIYAgTtyjYnJAl5CodOT6CTnRLdCJrUrzHkCGLHRA7a/HArc5GpPwa6 FUAY8b75bqbLg== From: Detlev Casanova To: linux-kernel@vger.kernel.org Cc: Andrew Lunn , Heiner Kallweit , Russell King , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , netdev@vger.kernel.org, devicetree@vger.kernel.org, Detlev Casanova , Florian Fainelli Subject: [PATCH v4 3/3] net: phy: realtek: Disable clock on suspend Date: Mon, 5 Jun 2023 11:40:10 -0400 Message-Id: <20230605154010.49611-4-detlev.casanova@collabora.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230605154010.49611-1-detlev.casanova@collabora.com> References: <20230605154010.49611-1-detlev.casanova@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 For PHYs that call rtl821x_probe() where an external clock can be configured, make sure that the clock is disabled when ->suspend() is called and enabled on resume. The PHY_ALWAYS_CALL_SUSPEND is added to ensure that the suspend function is actually always called. Reviewed-by: Florian Fainelli Signed-off-by: Detlev Casanova --- drivers/net/phy/realtek.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index b13dd0b3c99e..894172a3e15f 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -426,10 +426,31 @@ static int rtl8211f_config_init(struct phy_device *phydev) return genphy_soft_reset(phydev); } +static int rtl821x_suspend(struct phy_device *phydev) +{ + struct rtl821x_priv *priv = phydev->priv; + int ret = 0; + + if (!phydev->wol_enabled) { + ret = genphy_suspend(phydev); + + if (ret) + return ret; + + clk_disable_unprepare(priv->clk); + } + + return ret; +} + static int rtl821x_resume(struct phy_device *phydev) { + struct rtl821x_priv *priv = phydev->priv; int ret; + if (!phydev->wol_enabled) + clk_prepare_enable(priv->clk); + ret = genphy_resume(phydev); if (ret < 0) return ret; @@ -934,10 +955,11 @@ static struct phy_driver realtek_drvs[] = { .read_status = rtlgen_read_status, .config_intr = &rtl8211f_config_intr, .handle_interrupt = rtl8211f_handle_interrupt, - .suspend = genphy_suspend, + .suspend = rtl821x_suspend, .resume = rtl821x_resume, .read_page = rtl821x_read_page, .write_page = rtl821x_write_page, + .flags = PHY_ALWAYS_CALL_SUSPEND, }, { PHY_ID_MATCH_EXACT(RTL_8211FVD_PHYID), .name = "RTL8211F-VD Gigabit Ethernet", @@ -946,10 +968,11 @@ static struct phy_driver realtek_drvs[] = { .read_status = rtlgen_read_status, .config_intr = &rtl8211f_config_intr, .handle_interrupt = rtl8211f_handle_interrupt, - .suspend = genphy_suspend, + .suspend = rtl821x_suspend, .resume = rtl821x_resume, .read_page = rtl821x_read_page, .write_page = rtl821x_write_page, + .flags = PHY_ALWAYS_CALL_SUSPEND, }, { .name = "Generic FE-GE Realtek PHY", .match_phy_device = rtlgen_match_phy_device, -- 2.39.3