Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2145419rwd; Fri, 26 May 2023 02:20:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6OpPYzdUMCJcdAhTEimG5wRGe0sZD7rUGCJttvyOk0ezZlDTOlG5s+4zZcuHzGMsyUWVXA X-Received: by 2002:a05:6a20:748b:b0:109:c161:a679 with SMTP id p11-20020a056a20748b00b00109c161a679mr1649877pzd.19.1685092827622; Fri, 26 May 2023 02:20:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685092827; cv=none; d=google.com; s=arc-20160816; b=Y5U+z1FkbxsQsF9XE0PUKHLzWew4KNgtrs08DjGAJlOIcgX5xCGXmayCE3M6x0adgw 8MnHsvSbEHlTkF50+gFmfxtSBPtsKlh2b0qzweRUvbBoWMtWBuTsggzaCxr3PYttsath JV+/EVPWosUUEI34DI7OOiwQyjSnqQ5OfzEABLt2/dKpa/57oeg2VUkMoACRMUDa6vij lZk9/hfPcS56zNGauhQu9jyPtdyd2sTO7/wZT6pNqn4gz/V9DTBRbBBFz6uEfpFP5NQo /k/VbFY5wsdQXUbjYRliS+bHRhsyjR+38z7dCAJZmvaTmTXvkeSyTEOPfLL2wwIeE4g5 qsOA== 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=LzdGMwd6UagH12Ta3Y4NT1Eb81ve7m7D2daFA1kNcdg=; b=GOVjbiFpbp8GuCgy2OtUGnjbi/KoheHuDMKHx4be6CvtQF5HGQDBC0sTA/eJov1Utx Z7fcWcv4pqe8T/S+tr1wSiXkf5JsRp52HyAB7fQeWOoRRdeDgbXnel0F1vp839s83/ZI nyN5VTwDdZq+H4UyGhxAXs41v8wqaF5HkrTKGwpO3bZ2feEPl+BNcJMSzmE28qtVSYEG rEBj4YQfMr8IhafDl1aT6WtepNXbjAgARamDrFZ336sjvs2Z3Uw9IrKCbcZ3j3NJKOw2 pgHKzcBo0Xf0V6mFSB8wG1/l5T4s4w2J0Jx1vR7iObtOnSQOo9VTA1BFsBQ66rif/Qo0 9SrA== 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 v202-20020a6361d3000000b005138de75d17si3239817pgb.116.2023.05.26.02.20.13; Fri, 26 May 2023 02:20:27 -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 S242919AbjEZJFP (ORCPT + 99 others); Fri, 26 May 2023 05:05:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242573AbjEZJFK (ORCPT ); Fri, 26 May 2023 05:05:10 -0400 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8417912F; Fri, 26 May 2023 02:05:07 -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 50A667FEF; Fri, 26 May 2023 17:05:06 +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, 26 May 2023 17:05:06 +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, 26 May 2023 17:05:05 +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 v3 2/2] net: phy: motorcomm: Add pad drive strength cfg support Date: Fri, 26 May 2023 17:05:02 +0800 Message-ID: <20230526090502.29835-3-samin.guo@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230526090502.29835-1-samin.guo@starfivetech.com> References: <20230526090502.29835-1-samin.guo@starfivetech.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [171.223.208.138] X-ClientProxiedBy: EXCAS061.cuchost.com (172.16.6.21) 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..e5d6b491046e 100644 --- a/drivers/net/phy/motorcomm.c +++ b/drivers/net/phy/motorcomm.c @@ -236,6 +236,15 @@ */ #define YTPHY_WCR_TYPE_PULSE BIT(0) +#define YTPHY_PAD_DRIVE_STRENGTH_REG 0xA010 +#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 */ + #define YTPHY_SYNCE_CFG_REG 0xA012 #define YT8521_SCR_SYNCE_ENABLE BIT(5) /* 1b0 output 25m clock @@ -1494,6 +1503,7 @@ static int yt8521_config_init(struct phy_device *phydev) static int yt8531_config_init(struct phy_device *phydev) { struct device_node *node = phydev->mdio.dev.of_node; + u32 ds, val; int ret; ret = ytphy_rgmii_clk_delay_config_with_lock(phydev); @@ -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