From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71858C282C0 for ; Wed, 23 Jan 2019 19:39:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3914721855 for ; Wed, 23 Jan 2019 19:39:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Rt6Ki/kd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726213AbfAWTjU (ORCPT ); Wed, 23 Jan 2019 14:39:20 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:34146 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725896AbfAWTjT (ORCPT ); Wed, 23 Jan 2019 14:39:19 -0500 Received: by mail-wm1-f66.google.com with SMTP id y185so651873wmd.1 for ; Wed, 23 Jan 2019 11:39:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=ldtVE1XTXCFV/1G6HhhjsfXPLx+fZha+ys3Bkyh1ynI=; b=Rt6Ki/kdOaYw65pilu+17E+wBJtmzvn49RW+xyIWEIdKKQALBZUG0qMLVAsYLx5UY2 /9neDh3NnUseS8U8a4hrcLVh9LGvPzP5a/rMNN1SDB0dqhAgkWvBoAoUwzK3GcHZIhE1 O2tKP7jtStBa33EPIlgT3Dgrgytzs1l7fo+rkY9f3qFQRc82mjzNHYXC0ScrP7Q24rTH bBcSfiKysFFZBt3KrwzBSdvDPdmdhhJ0ww2iWvfuaQFMCKtD0c2gx0WPPI91i+qr5Ydb 71daHOqS3KfLGI+ARa6K7W9DwCw+qx+ZzNyS4AX5t4Uk8BUKeJg2Lff95BWq7uY0LZBn Uxmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=ldtVE1XTXCFV/1G6HhhjsfXPLx+fZha+ys3Bkyh1ynI=; b=lR61TKAf0Fx1ZO9/AxWzbPZpulSUiuLZ1J/fc4KxJM73EXHLWBDfwPEEhtvY3/BMPb RVh0nZb1DEbgVjjTE+cYtLA0eAnyvBwcU6cjsCemqL5X/GQ8SuXveiaie9kG7VKvNd5l 6/FSupG/LWfsWWX+xMOU8Vb+1/WuzNh2zYbQCA6wZeZqSQQXRSCfPf80t1/OtwcoUXoG v9t59Lxj6et+4X0N/1Vv3I3p6sfMFfwl4PGgw2CM7iY5/McWglNfEhR/SKYLEwExmz5K g/KUFhndB9WGpVJrSbrtmK2BYjPiHY9ZmodDp/KTb+JLa+UphxKc3M2WybMBExKI4KRG aZXw== X-Gm-Message-State: AJcUukeRZclrhVJSuBMxTnbepmTmOWGwmilRsEUUJ5Uth3e+kf4jZ8Fi ljs8+8WKVjHmhXIHGDRMCEL35Xuu X-Google-Smtp-Source: ALg8bN55FRIf4Dx/XeWAdmhRijx4Om2MxPxwi8iKpzRtAs3RDAexvZcFq/7sisjhZD8HJ0vNlEsKFQ== X-Received: by 2002:a1c:c64e:: with SMTP id w75mr4137845wmf.46.1548272357464; Wed, 23 Jan 2019 11:39:17 -0800 (PST) Received: from ?IPv6:2003:ea:8bf1:e200:4d69:8b83:be4c:d941? (p200300EA8BF1E2004D698B83BE4CD941.dip0.t-ipconnect.de. [2003:ea:8bf1:e200:4d69:8b83:be4c:d941]) by smtp.googlemail.com with ESMTPSA id j8sm150237841wmd.0.2019.01.23.11.39.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jan 2019 11:39:16 -0800 (PST) To: Realtek linux nic maintainers , David Miller Cc: "netdev@vger.kernel.org" From: Heiner Kallweit Subject: [PATCH net-next] r8169: factor out disabling ALDPS Message-ID: <53a6b46d-e58c-9b22-9324-dbe73e7a9f08@gmail.com> Date: Wed, 23 Jan 2019 20:39:09 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Chip versions from RTL8168g onward use the same sequence to disable ALDPS (Advanced Link-Down Power Saving). So let's factor this out. Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169.c | 31 ++++++++++------------------ 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index f574b6b55..8666ec095 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -3366,6 +3366,12 @@ static void rtl8411_hw_phy_config(struct rtl8169_private *tp) rtl_writephy(tp, 0x1f, 0x0000); } +static void rtl8168g_disable_aldps(struct rtl8169_private *tp) +{ + phy_write(tp->phydev, 0x1f, 0x0a43); + phy_clear_bits(tp->phydev, 0x10, BIT(2)); +} + static void rtl8168g_1_hw_phy_config(struct rtl8169_private *tp) { rtl_apply_firmware(tp); @@ -3424,10 +3430,7 @@ static void rtl8168g_1_hw_phy_config(struct rtl8169_private *tp) rtl_writephy(tp, 0x14, 0x9065); rtl_writephy(tp, 0x14, 0x1065); - /* Check ALDPS bit, disable it if enabled */ - rtl_writephy(tp, 0x1f, 0x0a43); - if (rtl_readphy(tp, 0x10) & 0x0004) - rtl_w0w1_phy(tp, 0x10, 0x0000, 0x0004); + rtl8168g_disable_aldps(tp); rtl_writephy(tp, 0x1f, 0x0000); } @@ -3539,10 +3542,7 @@ static void rtl8168h_1_hw_phy_config(struct rtl8169_private *tp) rtl_w0w1_phy(tp, 0x11, 0x0000, 0x0080); rtl_writephy(tp, 0x1f, 0x0000); - /* Check ALDPS bit, disable it if enabled */ - rtl_writephy(tp, 0x1f, 0x0a43); - if (rtl_readphy(tp, 0x10) & 0x0004) - rtl_w0w1_phy(tp, 0x10, 0x0000, 0x0004); + rtl8168g_disable_aldps(tp); rtl_writephy(tp, 0x1f, 0x0000); } @@ -3612,10 +3612,7 @@ static void rtl8168h_2_hw_phy_config(struct rtl8169_private *tp) rtl_w0w1_phy(tp, 0x11, 0x0000, 0x0080); rtl_writephy(tp, 0x1f, 0x0000); - /* Check ALDPS bit, disable it if enabled */ - rtl_writephy(tp, 0x1f, 0x0a43); - if (rtl_readphy(tp, 0x10) & 0x0004) - rtl_w0w1_phy(tp, 0x10, 0x0000, 0x0004); + rtl8168g_disable_aldps(tp); rtl_writephy(tp, 0x1f, 0x0000); } @@ -3654,10 +3651,7 @@ static void rtl8168ep_1_hw_phy_config(struct rtl8169_private *tp) rtl_w0w1_phy(tp, 0x11, 0x4000, 0x2000); rtl_writephy(tp, 0x1f, 0x0000); - /* Check ALDPS bit, disable it if enabled */ - rtl_writephy(tp, 0x1f, 0x0a43); - if (rtl_readphy(tp, 0x10) & 0x0004) - rtl_w0w1_phy(tp, 0x10, 0x0000, 0x0004); + rtl8168g_disable_aldps(tp); rtl_writephy(tp, 0x1f, 0x0000); } @@ -3745,10 +3739,7 @@ static void rtl8168ep_2_hw_phy_config(struct rtl8169_private *tp) rtl_writephy(tp, 0x14, 0x1065); rtl_writephy(tp, 0x1f, 0x0000); - /* Check ALDPS bit, disable it if enabled */ - rtl_writephy(tp, 0x1f, 0x0a43); - if (rtl_readphy(tp, 0x10) & 0x0004) - rtl_w0w1_phy(tp, 0x10, 0x0000, 0x0004); + rtl8168g_disable_aldps(tp); rtl_writephy(tp, 0x1f, 0x0000); } -- 2.20.1