mbox series

[v4,0/2] Add motorcomm phy pad-driver-strength-cfg support

Message ID 20230714101406.17686-1-samin.guo@starfivetech.com
Headers show
Series Add motorcomm phy pad-driver-strength-cfg support | expand

Message

Guo Samin July 14, 2023, 10:14 a.m. UTC
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)

The first patch adds a description of dt-bingding, and the second patch adds
YT8531's parsing and settings for pad-driver-strength-cfg.

Changes since v3:
Patch 1:
- Used current values instead of register values
- Added units and numerical descriptions of driver-strength
Patch 2:
- Added a lookup table to listing the valid values in the schema (by Andrew Lunn)


Changes since v2:
Patch 2:
- Readjusted the order of YT8531_RGMII_xxx to below YTPHY_PAD_DRIVE_STRENGTH_REG (by Frank Sae)
- Reversed Christmas tree, sort these longest first, shortest last (by Andrew Lunn)
- Rebased on tag v6.4

Changes since v1:
Patch 1:
- Renamed "rx-xxx-driver-strength" to "motorcomm,rx-xxx-driver-strength" (by Frank Sae)
Patch 2:
- Added default values for rxc/rxd driver strength (by Frank Sea/Andrew Lunn)
- Added range checking when val is in DT (by Frank Sea/Andrew Lunn)

Previous versions:
v1 - https://patchwork.kernel.org/project/netdevbpf/cover/20230426063541.15378-1-samin.guo@starfivetech.com
v2 - https://patchwork.kernel.org/project/netdevbpf/cover/20230505090558.2355-1-samin.guo@starfivetech.com
v3 - https://patchwork.kernel.org/project/netdevbpf/cover/20230526090502.29835-1-samin.guo@starfivetech.com

Samin Guo (2):
  dt-bindings: net: motorcomm: Add pad driver strength cfg
  net: phy: motorcomm: Add pad drive strength cfg support

 .../bindings/net/motorcomm,yt8xxx.yaml        |  46 +++++++
 drivers/net/phy/motorcomm.c                   | 114 ++++++++++++++++++
 2 files changed, 160 insertions(+)


base-commit: 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5

Comments

Andrew Lunn July 14, 2023, 6:49 p.m. UTC | #1
> +static u32 yt8531_get_ds_map(struct phy_device *phydev, u32 cur)
> +{
> +	u32 vol;
> +	int i;
> +
> +	vol = yt8531_get_ldo_vol(phydev);
> +	for (i = 0; i < ARRAY_SIZE(yt8531_ldo_vol); i++) {
> +		if (yt8531_ldo_vol[i].vol == vol && yt8531_ldo_vol[i].cur == cur)
> +			return yt8531_ldo_vol[i].ds;
> +	}
> +
> +	phydev_warn(phydev,
> +		    "No matching current value was found %d, Use default value.\n", cur);
> +
> +	return YT8531_RGMII_RX_DS_DEFAULT;

If there is a value in DT and it is invalid, return -EINVAL and fail
the probe. Only use the default if there is no value in DT.

    Andrew
Guo Samin July 17, 2023, 8:40 a.m. UTC | #2
-------- 原始信息 --------
主题: Re: [PATCH v4 2/2] net: phy: motorcomm: Add pad drive strength cfg support
From: Andrew Lunn <andrew@lunn.ch>
收件人: Samin Guo <samin.guo@starfivetech.com>
日期: 2023/7/15

>> +static u32 yt8531_get_ds_map(struct phy_device *phydev, u32 cur)
>> +{
>> +	u32 vol;
>> +	int i;
>> +
>> +	vol = yt8531_get_ldo_vol(phydev);
>> +	for (i = 0; i < ARRAY_SIZE(yt8531_ldo_vol); i++) {
>> +		if (yt8531_ldo_vol[i].vol == vol && yt8531_ldo_vol[i].cur == cur)
>> +			return yt8531_ldo_vol[i].ds;
>> +	}
>> +
>> +	phydev_warn(phydev,
>> +		    "No matching current value was found %d, Use default value.\n", cur);
>> +
>> +	return YT8531_RGMII_RX_DS_DEFAULT;
> 
> If there is a value in DT and it is invalid, return -EINVAL and fail
> the probe. Only use the default if there is no value in DT.
> 
>     Andrew

Will be fixed in the next version.

Thanks for taking the time to review the code.

Best regards,
Samin