From: Guo Samin <samin.guo@starfivetech.com>
To: Frank Sae <Frank.Sae@motor-comm.com>,
<linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>,
<netdev@vger.kernel.org>, Peter Geis <pgwipeout@gmail.com>
Cc: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Andrew Lunn <andrew@lunn.ch>,
"Heiner Kallweit" <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
Yanhong Wang <yanhong.wang@starfivetech.com>
Subject: Re: [PATCH v2 2/2] net: phy: motorcomm: Add pad drive strength cfg support
Date: Sat, 6 May 2023 09:52:52 +0800 [thread overview]
Message-ID: <cda098be-eb4a-75dc-ea12-977766e9e843@starfivetech.com> (raw)
In-Reply-To: <ba94f81c-3fc0-303c-f0f9-8fd0ab7d33fe@motor-comm.com>
data: Re: [PATCH v2 2/2] net: phy: motorcomm: Add pad drive strength cfg support
From: Frank Sae <Frank.Sae@motor-comm.com>
to: Samin Guo <samin.guo@starfivetech.com>, <linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>, <netdev@vger.kernel.org>, Peter Geis <pgwipeout@gmail.com>
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 <samin.guo@starfivetech.com>
>> ---
>> 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;
>> }
>>
prev parent reply other threads:[~2023-05-06 1:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-05 9:05 [PATCH v2 0/2] Add motorcomm phy pad-driver-strength-cfg support Samin Guo
2023-05-05 9:05 ` [PATCH v2 1/2] dt-bindings: net: motorcomm: Add pad driver strength cfg Samin Guo
2023-05-05 17:52 ` Krzysztof Kozlowski
2023-05-05 9:05 ` [PATCH v2 2/2] net: phy: motorcomm: Add pad drive strength cfg support Samin Guo
2023-05-05 13:18 ` Andrew Lunn
2023-05-06 7:13 ` Guo Samin
2023-05-18 8:29 ` Guo Samin
2023-05-06 1:29 ` Frank Sae
2023-05-06 1:52 ` Guo Samin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cda098be-eb4a-75dc-ea12-977766e9e843@starfivetech.com \
--to=samin.guo@starfivetech.com \
--cc=Frank.Sae@motor-comm.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pgwipeout@gmail.com \
--cc=robh+dt@kernel.org \
--cc=yanhong.wang@starfivetech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).