Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp8034062rwr; Wed, 10 May 2023 16:58:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7IUXmxJdeeosJXIO+sVGM/a+qOCrsTFQyPI76gshmCSv77Noa0+Jz5ZaqVf22OLrDRSmns X-Received: by 2002:a05:6a20:7f92:b0:100:b126:dd27 with SMTP id d18-20020a056a207f9200b00100b126dd27mr14002609pzj.15.1683763105027; Wed, 10 May 2023 16:58:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683763105; cv=none; d=google.com; s=arc-20160816; b=cSPXVnH8aHlU96pN1rCdcPGMkIQJwNhOkMOqx6cuZpahNLnzZY4JQ/gWP5DnOhiEA3 2qhQorfvu346svjdsUgsy6/XA9cvN6s6tHQymwZN7ITKX8CbGIDEt6MPUl2pA4zFjIt2 5CzJ3n25l2rJ5PvqIFf1x9C+zmxLyLuhlaQlyAwyfZQsrAQbGveT/f+D4NMosyMhv1uO /uX3yGpjbnCuoscM8HFTVNQ8orE4UsTurb413S6WBwFyEN9N5qQeK2Gf5hixc3Qr1eLv /y1z/Cn6/n2QnuIFfeBb+NJ3jUoHexbzRCHnEztY3GafbI9KVueSVpMqrhlobaUAxY4l aEsg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s4-20020a63b404000000b005287bffc5c0si5142318pgf.711.2023.05.10.16.58.10; Wed, 10 May 2023 16:58:25 -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 S236758AbjEJXC3 (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-Type: text/plain; charset=us-ascii 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 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, -- 2.40.0