From patchwork Sat Apr 22 11:49:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 86595 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1660639vqo; Sat, 22 Apr 2023 05:08:47 -0700 (PDT) X-Google-Smtp-Source: AKy350Y8h96stZsscfgwS2TB9HqAtv0pPeybD1su11jTPwCaRd4D1kGdsAvZU93wtjFZOT+yMNUS X-Received: by 2002:a17:902:f681:b0:1a9:68d2:e4ae with SMTP id l1-20020a170902f68100b001a968d2e4aemr9143plg.2.1682165326760; Sat, 22 Apr 2023 05:08:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682165326; cv=none; d=google.com; s=arc-20160816; b=xJ6Va5xOmhL0Z4VfeGP65N1f2FcCKYwNaz0qY1stmAbz3iB8HOy8y1VPU1BBZmodjP gxEIDCB7uXYlJzalRE9OC0o9l7h/3U6g1ghTUQq4GjsbbaR862X4X6lyggedTwMFB3N0 HvQ5T6YBAp7340Zyqdl9K0m3Z8UEPVj/hYmi48g4GRMVpY8ZWiZNfOvXQ7DQ5JLR9UbU xAbZ3zm4cQttZP3fF4cap2xi/hr69x61207Qba2HHXaDCbMNoYJSUeIafpAInNQqV/tB 61vjrm0RwBKfqYBSUnY55m7o70adf8JJlGFS7ykRJUM64taMNAyIwmB13/LgDGSU9T7s 2b5g== 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:cc:to:from:date; bh=s5cTS7Ce8l5DgFaa7rd/10tljuIKq8+9W+5kxxfCjzM=; b=PzpiWtzMYh6DhuYPLd+EJOqrFiH9GoOWl9U/oBwIrhse99nhAXiVulvtZlFj7FLXxC vYIVhT3mfWEB3Jgz2CZK8CpZgj7Tnxbv28zzF4k5CgoD7KOUzY/fZwQLfzriabV4iDaA +0hV9saDJFbXC+FihgUUz70q7p5nCi4CfVu+kop7s3v12HkpuqHXUO1OClgNHgar2TEG 1zMtZf2MifagniPR0Joo6IlnqcYxvw45zxR81SrxU3wv6/u+2RizeojAqQ93qnYtn6Y+ 8Su7K25XXt8pTUyD/0U/OeFluBTukTLnTRHOTqwIS61LpJc+0VYHBS3AoBVLP9p1gzRR HLAw== 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 kw8-20020a170902f90800b001a1defc30cbsi6147657plb.479.2023.04.22.05.08.32; Sat, 22 Apr 2023 05:08:46 -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 S229790AbjDVLuX (ORCPT + 99 others); Sat, 22 Apr 2023 07:50:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229689AbjDVLuU (ORCPT ); Sat, 22 Apr 2023 07:50:20 -0400 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA2262139; Sat, 22 Apr 2023 04:49:54 -0700 (PDT) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1pqBkT-00086z-1p; Sat, 22 Apr 2023 13:49:49 +0200 Date: Sat, 22 Apr 2023 12:49:45 +0100 From: Daniel Golle To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Chen Minqiang , Chukun Pan , Yevhen Kolomeiko , Alexander Couzens Subject: [RFC PATCH net-next 8/8] net: phy: realtek: setup ALDPS on RTL822x Message-ID: <19f9db255a1ca4afaab5701a6a829697c48ef0e1.1682163424.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?1763878189740413126?= X-GMAIL-MSGID: =?utf-8?q?1763878189740413126?= 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 de73049037891..a2324918c42db 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) @@ -744,6 +748,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); @@ -1029,6 +1052,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, @@ -1042,6 +1066,7 @@ static struct phy_driver realtek_drvs[] = { .name = "RTL8226B_RTL8221B 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, @@ -1055,6 +1080,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, @@ -1066,6 +1092,7 @@ static struct phy_driver realtek_drvs[] = { .name = "RTL8226B-CG_RTL8221B-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, @@ -1078,6 +1105,7 @@ static struct phy_driver realtek_drvs[] = { .get_features = rtl822x_get_features, .config_init = rtl8221b_config_init, .config_aneg = rtl822x_config_aneg, + .probe = rtl822x_probe, .read_status = rtl822x_read_status, .suspend = genphy_suspend, .resume = rtlgen_resume, @@ -1090,6 +1118,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,