Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp616716rwr; Fri, 5 May 2023 02:16:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7d/rvxRoVhuoIzemYbCNyywyOQoSka7A+AzgusKh4MLcC9t4toPREsunRFocFgXQhioZFX X-Received: by 2002:a17:903:24c:b0:1aa:fea6:f85b with SMTP id j12-20020a170903024c00b001aafea6f85bmr866078plh.12.1683278198810; Fri, 05 May 2023 02:16:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683278198; cv=none; d=google.com; s=arc-20160816; b=ZDDMlqzk9Y9u31JXGmlXtJb1iMOAxGzVJBOvJxjnU4D78bQJbw3FWrVtTU6++30XCT Hqg2E/TljSKSHmX+t7nChX2rH1zpr5rcdEO9XHShtp6T34QrwstGIUFmhXuDyd3Ku2Ul tDlHt/XTwI1vkSHILUSRLV//zl6oVTwJcEieKqKrqIPySuOjcMfKM6JYL1fVh8YHuHpl C+Yz4gmggb2VRld3/ON6h/go2/ijzhJYJWh0lekbe61jj6BYFNEajny8Ay8Cq9/bf6Hu DzB0N+CKEWrdsPj4s9VFzyrnxj+imFgekL45s+hCwrpBymLO2LZxKB8IeKYM/vWjT0Yv jmdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=wWwMfxYVS+EARoO1IYBixb9xUVDpC9dmt+m5y5MMUrc=; b=ysxhgEb2Uam/OXiyyaT2UuJB+XZbYKgVFEHnBbM5edXQWQnjTLUQlCedJs5Xbhnzxt ATqE5Bz+30Ja1jnKqB9k0STLVCNHK8cUoLBjUf6UW44uHggqvb73dNa8bzAN0JYUyvts G58vUm8kil7Y/beHExtefLfZmgLNaXHVtlHlhBG8TkhNfwcMvltVDWpQWBGpRwpNpknV b+KFMtYbENUr9Fj2cB29PW9uhoNMJIB1dCV0K0551dpBbcGqZZzej/RTfWo3fb5VrofN 4Ecr702cYhtcs/Hvjn8zAb2TH2K2ayF2UJVyF5RhUi5+BLexvU2vszyMCqs43PhyQTdP fNVA== 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 x8-20020a170902ec8800b001a5abc9d9bcsi1266665plg.583.2023.05.05.02.16.24; Fri, 05 May 2023 02:16:38 -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 S231563AbjEEJGP (ORCPT + 99 others); Fri, 5 May 2023 05:06:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231551AbjEEJGK (ORCPT ); Fri, 5 May 2023 05:06:10 -0400 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFD5918FFA; Fri, 5 May 2023 02:06:08 -0700 (PDT) Received: from EXMBX165.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX165", Issuer "EXMBX165" (not verified)) by fd01.gateway.ufhost.com (Postfix) with ESMTP id 53F0C24E2E7; Fri, 5 May 2023 17:06:01 +0800 (CST) Received: from EXMBX062.cuchost.com (172.16.6.62) by EXMBX165.cuchost.com (172.16.6.75) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 5 May 2023 17:06:01 +0800 Received: from starfive-sdk.starfivetech.com (171.223.208.138) by EXMBX062.cuchost.com (172.16.6.62) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 5 May 2023 17:06:00 +0800 From: Samin Guo To: , , , Peter Geis , Frank CC: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Andrew Lunn , "Heiner Kallweit" , Russell King , "Samin Guo" , Yanhong Wang Subject: [PATCH v2 2/2] net: phy: motorcomm: Add pad drive strength cfg support Date: Fri, 5 May 2023 17:05:58 +0800 Message-ID: <20230505090558.2355-3-samin.guo@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230505090558.2355-1-samin.guo@starfivetech.com> References: <20230505090558.2355-1-samin.guo@starfivetech.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [171.223.208.138] X-ClientProxiedBy: EXCAS064.cuchost.com (172.16.6.24) To EXMBX062.cuchost.com (172.16.6.62) X-YovoleRuleAgent: yovoleflag X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, 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 The motorcomm phy (YT8531) supports the ability to adjust the drive strength of the rx_clk/rx_data, and the default strength may not be suitable for all boards. So add configurable options to better match the boards.(e.g. StarFive VisionFive 2) Signed-off-by: Samin Guo --- drivers/net/phy/motorcomm.c | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c index 2fa5a90e073b..191650bb1454 100644 --- a/drivers/net/phy/motorcomm.c +++ b/drivers/net/phy/motorcomm.c @@ -236,6 +236,7 @@ */ #define YTPHY_WCR_TYPE_PULSE BIT(0) +#define YTPHY_PAD_DRIVE_STRENGTH_REG 0xA010 #define YTPHY_SYNCE_CFG_REG 0xA012 #define YT8521_SCR_SYNCE_ENABLE BIT(5) /* 1b0 output 25m clock @@ -260,6 +261,14 @@ #define YT8531_SCR_CLK_SRC_REF_25M 4 #define YT8531_SCR_CLK_SRC_SSC_25M 5 +#define YT8531_RGMII_RXC_DS_DEFAULT 0x3 +#define YT8531_RGMII_RXC_DS_MAX 0x7 +#define YT8531_RGMII_RXC_DS GENMASK(15, 13) +#define YT8531_RGMII_RXD_DS_DEFAULT 0x3 +#define YT8531_RGMII_RXD_DS_MAX 0x7 +#define YT8531_RGMII_RXD_DS_LOW GENMASK(5, 4) /* Bit 1/0 of rxd_ds */ +#define YT8531_RGMII_RXD_DS_HI BIT(12) /* Bit 2 of rxd_ds */ + /* Extended Register end */ #define YTPHY_DTS_OUTPUT_CLK_DIS 0 @@ -1495,6 +1504,7 @@ static int yt8531_config_init(struct phy_device *phydev) { struct device_node *node = phydev->mdio.dev.of_node; int ret; + u32 ds, val; ret = ytphy_rgmii_clk_delay_config_with_lock(phydev); if (ret < 0) @@ -1518,6 +1528,42 @@ static int yt8531_config_init(struct phy_device *phydev) return ret; } + ds = YT8531_RGMII_RXC_DS_DEFAULT; + if (!of_property_read_u32(node, "motorcomm,rx-clk-driver-strength", &val)) { + if (val > YT8531_RGMII_RXC_DS_MAX) + return -EINVAL; + + ds = val; + } + + ret = ytphy_modify_ext_with_lock(phydev, + YTPHY_PAD_DRIVE_STRENGTH_REG, + YT8531_RGMII_RXC_DS, + FIELD_PREP(YT8531_RGMII_RXC_DS, ds)); + if (ret < 0) + return ret; + + ds = FIELD_PREP(YT8531_RGMII_RXD_DS_LOW, YT8531_RGMII_RXD_DS_DEFAULT); + if (!of_property_read_u32(node, "motorcomm,rx-data-driver-strength", &val)) { + if (val > YT8531_RGMII_RXD_DS_MAX) + return -EINVAL; + + if (val > FIELD_MAX(YT8531_RGMII_RXD_DS_LOW)) { + ds = val & FIELD_MAX(YT8531_RGMII_RXD_DS_LOW); + ds = FIELD_PREP(YT8531_RGMII_RXD_DS_LOW, ds); + ds |= YT8531_RGMII_RXD_DS_HI; + } else { + ds = FIELD_PREP(YT8531_RGMII_RXD_DS_LOW, val); + } + } + + ret = ytphy_modify_ext_with_lock(phydev, + YTPHY_PAD_DRIVE_STRENGTH_REG, + YT8531_RGMII_RXD_DS_LOW | YT8531_RGMII_RXD_DS_HI, + ds); + if (ret < 0) + return ret; + return 0; } -- 2.17.1