From patchwork Wed May 10 23:00:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 92325 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3983605vqo; Wed, 10 May 2023 16:19:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Kp+/6eksDRo9b3C3yD3V++blhVIULUhp1slCpA+++ak/hjc7qW2HWRoBaX0ytvIxbd4R3 X-Received: by 2002:a17:902:b946:b0:1a9:9a18:3458 with SMTP id h6-20020a170902b94600b001a99a183458mr19576124pls.31.1683760757418; Wed, 10 May 2023 16:19:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683760757; cv=none; d=google.com; s=arc-20160816; b=v2VL+QhrsIRoELyyRcNvRL3boiELLf36+5iRRfpDUZtxYVdWVQbrzeUtg75mrGIu7G fkFzgGaoWxDcomquZ6QwmPbtulfaUgXkx4QipuF5O5Z4h0eIxYzdeiZIwQ+P+evfLCbT ZA+H5bvLHcII80ziKCqEv3v8COwqetwtm2q5CwcdvUnLM9VCz1n+5JPkPjLrPqDgoGU0 9bu5wDNmHfb0vhuFGknurELQQD8vRdFrjxW7z7LUM4oz3m71sNFqSI3Mei2TWxAopBYo fo6yLDaMbIqLC9CQupqPtIu8nG/IRG/4d9Y762a0h1TbNVBQS9qRfIDkrb9D5l3V9RPP MuLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date; bh=7gkjpn6qo8GKo/OFPTXVmWj0Oe/mJ+FnTJe60gvg7hU=; b=sxS3ubq+jwovt4PEzEhbtwmHd2G2m8OiOWegtLgTntzWPFTscW7Bltxb5NnUGdv+h4 OnsH4qlLnoR8f0X18AvFdSwK5ZsgivQDQDs7O9OLSOnHJy6XMSi3fvaEIF0LjrPkDzPc 2NEwdagY512J0a9wGvFtFts8tdRIpqgqEqyVH4MKGfZnD70zd9vARhdbJT+vc0dCEjQE TTtgIG+BVQx8vKmqLPm7fSXjj/pVCCP3Hfwr1kbqV5xh3uX+EHGLM5H4et8ncOA9wSop 2O0SpdDLRQUAbcU+LJoyuXMytdsiSOawxyJQzsFsFz3tyew33oR4uE+gNuGsp/xisWg1 8Cdg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f16-20020a63f110000000b0050f66d4e070si5302180pgi.417.2023.05.10.16.19.03; Wed, 10 May 2023 16:19:17 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236774AbjEJXC3 (ORCPT + 99 others); Wed, 10 May 2023 19:02:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236497AbjEJXC2 (ORCPT ); Wed, 10 May 2023 19:02:28 -0400 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D06305249; Wed, 10 May 2023 16:02:26 -0700 (PDT) Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1pwspE-0004Wg-2T; Wed, 10 May 2023 23:02:25 +0000 Date: Thu, 11 May 2023 01:00:21 +0200 From: Daniel Golle To: netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , AngeloGioacchino Del Regno Subject: [PATCH net-next 8/8] net: phy: realtek: setup ALDPS on RTL8221B Message-ID: <701034ea45c08db557af926a5a44113e4e45c634.1683756691.git.daniel@makrotopia.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765551120168019056?= X-GMAIL-MSGID: =?utf-8?q?1765551120168019056?= Setup Link Down Power Saving Mode according the DTS property just like for RTL821x 1GE PHYs. Signed-off-by: Daniel Golle --- drivers/net/phy/realtek.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index 29168f98f451..b5d7208004d8 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -62,6 +62,10 @@ #define RTL8221B_SERDES_OPTION_MODE_2500BASEX 2 #define RTL8221B_SERDES_OPTION_MODE_HISGMII 3 +#define RTL8221B_PHYCR1 0xa430 +#define RTL8221B_PHYCR1_ALDPS_EN BIT(2) +#define RTL8221B_PHYCR1_ALDPS_XTAL_OFF_EN BIT(12) + #define RTL8366RB_POWER_SAVE 0x15 #define RTL8366RB_POWER_SAVE_ON BIT(12) @@ -757,6 +761,25 @@ static int rtl8226_match_phy_device(struct phy_device *phydev) rtlgen_supports_2_5gbps(phydev); } +static int rtl822x_probe(struct phy_device *phydev) +{ + struct device *dev = &phydev->mdio.dev; + int val; + + val = phy_read_mmd(phydev, RTL8221B_MMD_SERDES_CTRL, RTL8221B_PHYCR1); + if (val < 0) + return val; + + if (of_property_read_bool(dev->of_node, "realtek,aldps-enable")) + val |= RTL8221B_PHYCR1_ALDPS_EN | RTL8221B_PHYCR1_ALDPS_XTAL_OFF_EN; + else + val &= ~(RTL8221B_PHYCR1_ALDPS_EN | RTL8221B_PHYCR1_ALDPS_XTAL_OFF_EN); + + phy_write_mmd(phydev, RTL8221B_MMD_SERDES_CTRL, RTL8221B_PHYCR1, val); + + return 0; +} + static int rtlgen_resume(struct phy_device *phydev) { int ret = genphy_resume(phydev); @@ -1034,6 +1057,7 @@ static struct phy_driver realtek_drvs[] = { .match_phy_device = rtl8226_match_phy_device, .get_features = rtl822x_get_features, .config_aneg = rtl822x_config_aneg, + .probe = rtl822x_probe, .read_status = rtl822x_read_status, .suspend = genphy_suspend, .resume = rtlgen_resume, @@ -1048,6 +1072,7 @@ static struct phy_driver realtek_drvs[] = { .get_features = rtl822x_get_features, .config_aneg = rtl822x_config_aneg, .config_init = rtl8221b_config_init, + .probe = rtl822x_probe, .read_status = rtl822x_read_status, .suspend = genphy_suspend, .resume = rtlgen_resume, @@ -1061,6 +1086,7 @@ static struct phy_driver realtek_drvs[] = { .name = "RTL8226-CG 2.5Gbps PHY", .get_features = rtl822x_get_features, .config_aneg = rtl822x_config_aneg, + .probe = rtl822x_probe, .read_status = rtl822x_read_status, .suspend = genphy_suspend, .resume = rtlgen_resume, @@ -1073,6 +1099,7 @@ static struct phy_driver realtek_drvs[] = { .get_features = rtl822x_get_features, .config_aneg = rtl822x_config_aneg, .config_init = rtl8221b_config_init, + .probe = rtl822x_probe, .read_status = rtl822x_read_status, .suspend = genphy_suspend, .resume = rtlgen_resume, @@ -1085,6 +1112,7 @@ static struct phy_driver realtek_drvs[] = { .get_features = rtl822x_get_features, .config_aneg = rtl822x_config_aneg, .config_init = rtl8221b_config_init, + .probe = rtl822x_probe, .read_status = rtl822x_read_status, .suspend = genphy_suspend, .resume = rtlgen_resume, @@ -1097,6 +1125,7 @@ static struct phy_driver realtek_drvs[] = { .get_features = rtl822x_get_features, .config_aneg = rtl822x_config_aneg, .config_init = rtl8221b_config_init, + .probe = rtl822x_probe, .read_status = rtl822x_read_status, .suspend = genphy_suspend, .resume = rtlgen_resume,