Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1683344rwr; Fri, 5 May 2023 19:24:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Qbo1cSF4Sr3d/vd5kk6gSR52EjqWTdY4u5T6qdNljWkmZwEadrkEMQKLxLyhx/qJ6LBXS X-Received: by 2002:a17:902:dac8:b0:1ac:4d01:dfc6 with SMTP id q8-20020a170902dac800b001ac4d01dfc6mr2143215plx.39.1683339889527; Fri, 05 May 2023 19:24:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683339889; cv=none; d=google.com; s=arc-20160816; b=nUbU3jXC7f4ksHVEZGCpn/5ikJW9G5bhHVPccn+xJYnbKfzzgCwZKPgTp/s1XIkmYp b5JfFg2bZZ+37XyW6KnoepS1mZFE3W61+MqiKGJ+AmPzOEiUnoZN97ztDkpYKE1oGcVE FfReqLb50sJRAu+TWK8pX1KcktUv6Vexlw0oeR/yfOfl+DosWGZkK2LhzC317c8MZ0qU K2NUR3N8pDGSb6sfdyHOoQpm9Z2w+3jJp6kHHlPUzXcNXb5G88xfcH/B7Wnm559o1EDr /WEqwX+mBBkccL3+5wFKinqBf5jxeNZMnBhWHeIwd9cc//M5IOTzwLP6HudDsbCCoHr5 52NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=H4NP8dmB7JnF+UKxp99eHphYby9wE/Yh0iDvFxhaOIU=; b=JzTTSM90pofcAlgPGTf2RSzVzYR5GJEnJ4wIgwyRWlfMZ44xlLNcJigrNKh+IoUftD 0KSmRSszNjGmlK1EGio/CRhgvkh/n5g3pQ+ekbEUrESOqGLBjFxudJcVNhl5cpSadVNZ VvdpVewkY4sqzFgueb0jWfWyn2u7La8qTR2Arks+3GmeM0N+zRX6ay6sf3aUEmoXX7Rm gD23uNAlBhNH0d8yAv5TPnoofviYXs52H7Of91ER6LzKgiGJc42p1B8EqDWsQFSbjiSa +JjcZZAAdYqeIjMYOiYUSTEcBX2uYMk8AS+VS3iI3hSkUj5Nn/Kxi8eLkPTsvkqmd+Wq 5Y1Q== 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 l15-20020a170903244f00b001a9930c626dsi3346101pls.273.2023.05.05.19.24.33; Fri, 05 May 2023 19:24:49 -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 S232536AbjEFBxB convert rfc822-to-8bit (ORCPT + 99 others); Fri, 5 May 2023 21:53:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229739AbjEFBw7 (ORCPT ); Fri, 5 May 2023 21:52:59 -0400 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1605A4C01; Fri, 5 May 2023 18:52:58 -0700 (PDT) Received: from EXMBX166.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX166", Issuer "EXMBX166" (not verified)) by fd01.gateway.ufhost.com (Postfix) with ESMTP id 97AB324DEBC; Sat, 6 May 2023 09:52:55 +0800 (CST) Received: from EXMBX062.cuchost.com (172.16.6.62) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Sat, 6 May 2023 09:52:55 +0800 Received: from [192.168.120.40] (171.223.208.138) by EXMBX062.cuchost.com (172.16.6.62) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Sat, 6 May 2023 09:52:54 +0800 Message-ID: Date: Sat, 6 May 2023 09:52:52 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v2 2/2] net: phy: motorcomm: Add pad drive strength cfg support Content-Language: en-US To: Frank Sae , , , , Peter Geis CC: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Andrew Lunn , "Heiner Kallweit" , Russell King , Yanhong Wang References: <20230505090558.2355-1-samin.guo@starfivetech.com> <20230505090558.2355-3-samin.guo@starfivetech.com> From: Guo Samin In-Reply-To: Content-Type: text/plain; charset="UTF-8" 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 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, 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 data: Re: [PATCH v2 2/2] net: phy: motorcomm: Add pad drive strength cfg support From: Frank Sae to: Samin Guo , , , , Peter Geis data: 2023/5/6 > > > On 2023/5/5 17:05, Samin Guo wrote: >> 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 */ > > > YT8531_RGMII_xxx is bit define for YTPHY_PAD_DRIVE_STRENGTH_REG, so it is better to put it under the define of YTPHY_PAD_DRIVE_STRENGTH_REG. > > YT8531_RGMII_xxx bit define as reverse order: > #define YTPHY_PAD_DRIVE_STRENGTH_REG 0xA010 > #define YT8531_RGMII_RXC_DS GENMASK(15, 13) > #define YT8531_RGMII_RXD_DS_HI BIT(12) /* Bit 2 of rxd_ds */ <------- > #define YT8531_RGMII_RXD_DS_LOW GENMASK(5, 4) /* Bit 1/0 of rxd_ds */ > ... > Hi Frank, Ok, will fix it next version. btw, do you have any information you can provide about Andrew's mention of using real unit uA/mA instead of magic numbers? (I couldn't find any information about current in the YT8531's datasheet other than the magic numbers.) Below is all the relevant information I found: Pad Drive Strength Cfg (EXT_0xA010) Bit | Symbol | Access | Default | Description 15:13 | Rgmii_sw_dr_rx | RW | 0x3 | Drive strenght of rx_clk pad. | 3'b111: strongest; 3'b000: weakest. 12 | Rgmii_sw_dr[2] | RW | 0x0 | Bit 2 of Rgmii_sw_dr[2:0], refer to ext A010[5:4] 5:4 | Rgmii_sw_dr[1:0] | RW | 0x3 | Bit 1 and 0 of Rgmii_sw_dr, Drive strenght of rxd/rx_ctl rgmii pad. | 3'b111: strongest; 3'b000: weakest Best regards, Samin >> + >> /* 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; >> } >>