All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/2] Add motorcomm phy pad-driver-strength-cfg support
@ 2023-07-14 10:14 Samin Guo
  2023-07-14 10:14 ` [PATCH v4 1/2] dt-bindings: net: motorcomm: Add pad driver strength cfg Samin Guo
  2023-07-14 10:14 ` [PATCH v4 2/2] net: phy: motorcomm: Add pad drive strength cfg support Samin Guo
  0 siblings, 2 replies; 9+ messages in thread
From: Samin Guo @ 2023-07-14 10:14 UTC (permalink / raw)
  To: linux-kernel, devicetree, netdev, Peter Geis, Frank
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Rob Herring, Conor Dooley, Krzysztof Kozlowski, Andrew Lunn,
	Heiner Kallweit, Russell King, Samin Guo, Yanhong Wang

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
-- 
2.17.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v4 1/2] dt-bindings: net: motorcomm: Add pad driver strength cfg
  2023-07-14 10:14 [PATCH v4 0/2] Add motorcomm phy pad-driver-strength-cfg support Samin Guo
@ 2023-07-14 10:14 ` Samin Guo
  2023-07-14 18:54   ` Andrew Lunn
  2023-07-15  2:47   ` Rob Herring
  2023-07-14 10:14 ` [PATCH v4 2/2] net: phy: motorcomm: Add pad drive strength cfg support Samin Guo
  1 sibling, 2 replies; 9+ messages in thread
From: Samin Guo @ 2023-07-14 10:14 UTC (permalink / raw)
  To: linux-kernel, devicetree, netdev, Peter Geis, Frank
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Rob Herring, Conor Dooley, Krzysztof Kozlowski, Andrew Lunn,
	Heiner Kallweit, Russell King, Samin Guo, Yanhong Wang

The motorcomm phy (YT8531) supports the ability to adjust the drive
strength of the rx_clk/rx_data.

The YT8531 RGMII LDO voltage supports 1.8V/3.3V, and the
LDO voltage can be configured with hardware pull-up resistors to match
the SOC voltage (usually 1.8V). The software can read the registers
0xA001 obtain the current LDO voltage value.

When we configure the drive strength, we need to read the current LDO
voltage value to ensure that it is a legal value at that LDO voltage.

Reviewed-by: Hal Feng <hal.feng@starfivetech.com>
Signed-off-by: Samin Guo <samin.guo@starfivetech.com>
---
 .../bindings/net/motorcomm,yt8xxx.yaml        | 46 +++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml b/Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml
index 157e3bbcaf6f..097bf143af35 100644
--- a/Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml
+++ b/Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml
@@ -52,6 +52,52 @@ properties:
       for a timer.
     type: boolean
 
+  motorcomm,rx-clk-driver-strength:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: |
+      drive strength of rx_clk rgmii pad.
+      |----------------------------------|
+      |        rx_clk ds map table       |
+      |----------------------------------|
+      | DS(3b) |  wol@1.8v  |  wol@3.3v  |
+      |________|_________________________|
+      |        | current(uA)| current(uA)|
+      |   000  |     1200   |    3070    |
+      |   001  |     2100   |    4080    |
+      |   010  |     2700   |    4370    |
+      |   011  |     2910   |    4680    |
+      |   100  |     3110   |    5020    |
+      |   101  |     3600   |    5450    |
+      |   110  |     3970   |    5740    |
+      |   111  |     4350   |    6140    |
+      |--------|------------|------------|
+    enum: [ 1200, 2100, 2700, 2910, 3070, 3110, 3600, 3970,
+            4080, 4350, 4370, 4680, 5020, 5450, 5740, 6140 ]
+    default: 2910
+
+  motorcomm,rx-data-driver-strength:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: |
+      drive strength of rx_data/rx_ctl rgmii pad.
+      |----------------------------------|
+      |        rx_data ds map table      |
+      |----------------------------------|
+      | DS(3b) |  wol@1.8v  |  wol@3.3v  |
+      |________|_________________________|
+      |        | current(uA)| current(uA)|
+      |   000  |     1200   |    3070    |
+      |   001  |     2100   |    4080    |
+      |   010  |     2700   |    4370    |
+      |   011  |     2910   |    4680    |
+      |   100  |     3110   |    5020    |
+      |   101  |     3600   |    5450    |
+      |   110  |     3970   |    5740    |
+      |   111  |     4350   |    6140    |
+      |--------|------------|------------|
+    enum: [ 1200, 2100, 2700, 2910, 3070, 3110, 3600, 3970,
+            4080, 4350, 4370, 4680, 5020, 5450, 5740, 6140 ]
+    default: 2910
+
   motorcomm,tx-clk-adj-enabled:
     description: |
       This configuration is mainly to adapt to VF2 with JH7110 SoC.
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v4 2/2] net: phy: motorcomm: Add pad drive strength cfg support
  2023-07-14 10:14 [PATCH v4 0/2] Add motorcomm phy pad-driver-strength-cfg support Samin Guo
  2023-07-14 10:14 ` [PATCH v4 1/2] dt-bindings: net: motorcomm: Add pad driver strength cfg Samin Guo
@ 2023-07-14 10:14 ` Samin Guo
  2023-07-14 18:49   ` Andrew Lunn
  1 sibling, 1 reply; 9+ messages in thread
From: Samin Guo @ 2023-07-14 10:14 UTC (permalink / raw)
  To: linux-kernel, devicetree, netdev, Peter Geis, Frank
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Rob Herring, Conor Dooley, Krzysztof Kozlowski, Andrew Lunn,
	Heiner Kallweit, Russell King, Samin Guo, Yanhong Wang

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)

When we configure the drive strength, we need to read the current
LDO voltage value to ensure that it is a legal value at that LDO
voltage.

Reviewed-by: Hal Feng <hal.feng@starfivetech.com>
Signed-off-by: Samin Guo <samin.guo@starfivetech.com>
---
 drivers/net/phy/motorcomm.c | 114 ++++++++++++++++++++++++++++++++++++
 1 file changed, 114 insertions(+)

diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c
index 2fa5a90e073b..857a451fa35e 100644
--- a/drivers/net/phy/motorcomm.c
+++ b/drivers/net/phy/motorcomm.c
@@ -163,6 +163,10 @@
 
 #define YT8521_CHIP_CONFIG_REG			0xA001
 #define YT8521_CCR_SW_RST			BIT(15)
+#define YT8531_RGMII_LDO_VOL_MASK		GENMASK(5, 4)
+#define YT8531_LDO_VOL_3V3			0x0
+#define YT8531_LDO_VOL_1V8			0x2
+
 /* 1b0 disable 1.9ns rxc clock delay  *default*
  * 1b1 enable 1.9ns rxc clock delay
  */
@@ -236,6 +240,12 @@
  */
 #define YTPHY_WCR_TYPE_PULSE			BIT(0)
 
+#define YTPHY_PAD_DRIVE_STRENGTH_REG		0xA010
+#define YT8531_RGMII_RXC_DS_MASK		GENMASK(15, 13)
+#define YT8531_RGMII_RXD_DS_HI_MASK		BIT(12)		/* Bit 2 of rxd_ds */
+#define YT8531_RGMII_RXD_DS_LOW_MASK		GENMASK(5, 4)	/* Bit 1/0 of rxd_ds */
+#define YT8531_RGMII_RX_DS_DEFAULT		0x3
+
 #define YTPHY_SYNCE_CFG_REG			0xA012
 #define YT8521_SCR_SYNCE_ENABLE			BIT(5)
 /* 1b0 output 25m clock
@@ -834,6 +844,106 @@ static int ytphy_rgmii_clk_delay_config_with_lock(struct phy_device *phydev)
 	return ret;
 }
 
+/**
+ * struct ytphy_ldo_vol_map - map a current value to a register value
+ * @vol: ldo voltage
+ * @ds:  value in the register
+ * @cur: value in device configuration
+ */
+struct ytphy_ldo_vol_map {
+	u32 vol;
+	u32 ds;
+	u32 cur;
+};
+
+static const struct ytphy_ldo_vol_map yt8531_ldo_vol[] = {
+	{.vol = YT8531_LDO_VOL_1V8, .ds = 0, .cur = 1200},
+	{.vol = YT8531_LDO_VOL_1V8, .ds = 1, .cur = 2100},
+	{.vol = YT8531_LDO_VOL_1V8, .ds = 2, .cur = 2700},
+	{.vol = YT8531_LDO_VOL_1V8, .ds = 3, .cur = 2910},
+	{.vol = YT8531_LDO_VOL_1V8, .ds = 4, .cur = 3110},
+	{.vol = YT8531_LDO_VOL_1V8, .ds = 5, .cur = 3600},
+	{.vol = YT8531_LDO_VOL_1V8, .ds = 6, .cur = 3970},
+	{.vol = YT8531_LDO_VOL_1V8, .ds = 7, .cur = 4350},
+	{.vol = YT8531_LDO_VOL_3V3, .ds = 0, .cur = 3070},
+	{.vol = YT8531_LDO_VOL_3V3, .ds = 1, .cur = 4080},
+	{.vol = YT8531_LDO_VOL_3V3, .ds = 2, .cur = 4370},
+	{.vol = YT8531_LDO_VOL_3V3, .ds = 3, .cur = 4680},
+	{.vol = YT8531_LDO_VOL_3V3, .ds = 4, .cur = 5020},
+	{.vol = YT8531_LDO_VOL_3V3, .ds = 5, .cur = 5450},
+	{.vol = YT8531_LDO_VOL_3V3, .ds = 6, .cur = 5740},
+	{.vol = YT8531_LDO_VOL_3V3, .ds = 7, .cur = 6140},
+};
+
+static u32 yt8531_get_ldo_vol(struct phy_device *phydev)
+{
+	u32 val;
+
+	val = ytphy_read_ext_with_lock(phydev, YT8521_CHIP_CONFIG_REG);
+	val = FIELD_GET(YT8531_RGMII_LDO_VOL_MASK, val);
+
+	return val <= YT8531_LDO_VOL_1V8 ? val : YT8531_LDO_VOL_1V8;
+}
+
+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;
+}
+
+static int yt8531_set_ds(struct phy_device *phydev)
+{
+	struct device_node *node = phydev->mdio.dev.of_node;
+	u32 ds_field_low, ds_field_hi;
+	u32 ds, val;
+	int ret;
+
+	/* set rgmii rx clk driver strength */
+	if (!of_property_read_u32(node, "motorcomm,rx-clk-driver-strength", &val))
+		ds = yt8531_get_ds_map(phydev, val);
+	else
+		ds = YT8531_RGMII_RX_DS_DEFAULT;
+
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YTPHY_PAD_DRIVE_STRENGTH_REG,
+					 YT8531_RGMII_RXC_DS_MASK,
+					 FIELD_PREP(YT8531_RGMII_RXC_DS_MASK, ds));
+	if (ret < 0)
+		return ret;
+
+	/* set rgmii rx data driver strength */
+	if (!of_property_read_u32(node, "motorcomm,rx-data-driver-strength", &val))
+		ds = yt8531_get_ds_map(phydev, val);
+	else
+		ds = YT8531_RGMII_RX_DS_DEFAULT;
+
+	ds_field_hi = FIELD_GET(BIT(2), ds);
+	ds_field_hi = FIELD_PREP(YT8531_RGMII_RXD_DS_HI_MASK, ds_field_hi);
+
+	ds_field_low = FIELD_GET(GENMASK(1, 0), ds);
+	ds_field_low = FIELD_PREP(YT8531_RGMII_RXD_DS_LOW_MASK, ds_field_low);
+
+	ret = ytphy_modify_ext_with_lock(phydev,
+					 YTPHY_PAD_DRIVE_STRENGTH_REG,
+					 YT8531_RGMII_RXD_DS_LOW_MASK | YT8531_RGMII_RXD_DS_HI_MASK,
+					 ds_field_low | ds_field_hi);
+	if (ret < 0)
+		return ret;
+
+	return 0;
+}
+
 /**
  * yt8521_probe() - read chip config then set suitable polling_mode
  * @phydev: a pointer to a &struct phy_device
@@ -1518,6 +1628,10 @@ static int yt8531_config_init(struct phy_device *phydev)
 			return ret;
 	}
 
+	ret = yt8531_set_ds(phydev);
+	if (ret < 0)
+		return ret;
+
 	return 0;
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v4 2/2] net: phy: motorcomm: Add pad drive strength cfg support
  2023-07-14 10:14 ` [PATCH v4 2/2] net: phy: motorcomm: Add pad drive strength cfg support Samin Guo
@ 2023-07-14 18:49   ` Andrew Lunn
  2023-07-17  8:40     ` Guo Samin
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Lunn @ 2023-07-14 18:49 UTC (permalink / raw)
  To: Samin Guo
  Cc: linux-kernel, devicetree, netdev, Peter Geis, Frank,
	David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Rob Herring, Conor Dooley, Krzysztof Kozlowski, Heiner Kallweit,
	Russell King, Yanhong Wang

> +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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v4 1/2] dt-bindings: net: motorcomm: Add pad driver strength cfg
  2023-07-14 10:14 ` [PATCH v4 1/2] dt-bindings: net: motorcomm: Add pad driver strength cfg Samin Guo
@ 2023-07-14 18:54   ` Andrew Lunn
  2023-07-17  8:28     ` Guo Samin
  2023-07-15  2:47   ` Rob Herring
  1 sibling, 1 reply; 9+ messages in thread
From: Andrew Lunn @ 2023-07-14 18:54 UTC (permalink / raw)
  To: Samin Guo
  Cc: linux-kernel, devicetree, netdev, Peter Geis, Frank,
	David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Rob Herring, Conor Dooley, Krzysztof Kozlowski, Heiner Kallweit,
	Russell King, Yanhong Wang

> +  motorcomm,rx-clk-driver-strength:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: |
> +      drive strength of rx_clk rgmii pad.
> +      |----------------------------------|
> +      |        rx_clk ds map table       |
> +      |----------------------------------|
> +      | DS(3b) |  wol@1.8v  |  wol@3.3v  |
> +      |________|_________________________|
> +      |        | current(uA)| current(uA)|
> +      |   000  |     1200   |    3070    |
> +      |   001  |     2100   |    4080    |
> +      |   010  |     2700   |    4370    |
> +      |   011  |     2910   |    4680    |
> +      |   100  |     3110   |    5020    |
> +      |   101  |     3600   |    5450    |
> +      |   110  |     3970   |    5740    |
> +      |   111  |     4350   |    6140    |
> +      |--------|------------|------------|
> +    enum: [ 1200, 2100, 2700, 2910, 3070, 3110, 3600, 3970,
> +            4080, 4350, 4370, 4680, 5020, 5450, 5740, 6140 ]
> +    default: 2910

The DS(3b) value is not relevant to the binding. It is a driver
detail. So i would not bother listing it.

Please add a comment explaining what wol is. 

       Andrew

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v4 1/2] dt-bindings: net: motorcomm: Add pad driver strength cfg
  2023-07-14 10:14 ` [PATCH v4 1/2] dt-bindings: net: motorcomm: Add pad driver strength cfg Samin Guo
  2023-07-14 18:54   ` Andrew Lunn
@ 2023-07-15  2:47   ` Rob Herring
  2023-07-17  8:35     ` Guo Samin
  1 sibling, 1 reply; 9+ messages in thread
From: Rob Herring @ 2023-07-15  2:47 UTC (permalink / raw)
  To: Samin Guo
  Cc: linux-kernel, devicetree, netdev, Peter Geis, Frank,
	David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Conor Dooley, Krzysztof Kozlowski, Andrew Lunn, Heiner Kallweit,
	Russell King, Yanhong Wang

On Fri, Jul 14, 2023 at 06:14:05PM +0800, Samin Guo wrote:
> The motorcomm phy (YT8531) supports the ability to adjust the drive
> strength of the rx_clk/rx_data.
> 
> The YT8531 RGMII LDO voltage supports 1.8V/3.3V, and the
> LDO voltage can be configured with hardware pull-up resistors to match
> the SOC voltage (usually 1.8V). The software can read the registers
> 0xA001 obtain the current LDO voltage value.
> 
> When we configure the drive strength, we need to read the current LDO
> voltage value to ensure that it is a legal value at that LDO voltage.
> 
> Reviewed-by: Hal Feng <hal.feng@starfivetech.com>
> Signed-off-by: Samin Guo <samin.guo@starfivetech.com>
> ---
>  .../bindings/net/motorcomm,yt8xxx.yaml        | 46 +++++++++++++++++++
>  1 file changed, 46 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml b/Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml
> index 157e3bbcaf6f..097bf143af35 100644
> --- a/Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml
> +++ b/Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml
> @@ -52,6 +52,52 @@ properties:
>        for a timer.
>      type: boolean
>  
> +  motorcomm,rx-clk-driver-strength:
> +    $ref: /schemas/types.yaml#/definitions/uint32

As the units are uA, drop the type and add '-microamp' suffix. 
'motorcomm,rx-clk-drv-microamp' is probably sufficient.

> +    description: |
> +      drive strength of rx_clk rgmii pad.
> +      |----------------------------------|
> +      |        rx_clk ds map table       |
> +      |----------------------------------|
> +      | DS(3b) |  wol@1.8v  |  wol@3.3v  |
> +      |________|_________________________|
> +      |        | current(uA)| current(uA)|
> +      |   000  |     1200   |    3070    |
> +      |   001  |     2100   |    4080    |
> +      |   010  |     2700   |    4370    |
> +      |   011  |     2910   |    4680    |
> +      |   100  |     3110   |    5020    |
> +      |   101  |     3600   |    5450    |
> +      |   110  |     3970   |    5740    |
> +      |   111  |     4350   |    6140    |
> +      |--------|------------|------------|
> +    enum: [ 1200, 2100, 2700, 2910, 3070, 3110, 3600, 3970,
> +            4080, 4350, 4370, 4680, 5020, 5450, 5740, 6140 ]
> +    default: 2910
> +
> +  motorcomm,rx-data-driver-strength:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: |
> +      drive strength of rx_data/rx_ctl rgmii pad.
> +      |----------------------------------|
> +      |        rx_data ds map table      |
> +      |----------------------------------|
> +      | DS(3b) |  wol@1.8v  |  wol@3.3v  |
> +      |________|_________________________|
> +      |        | current(uA)| current(uA)|
> +      |   000  |     1200   |    3070    |
> +      |   001  |     2100   |    4080    |
> +      |   010  |     2700   |    4370    |
> +      |   011  |     2910   |    4680    |
> +      |   100  |     3110   |    5020    |
> +      |   101  |     3600   |    5450    |
> +      |   110  |     3970   |    5740    |
> +      |   111  |     4350   |    6140    |
> +      |--------|------------|------------|
> +    enum: [ 1200, 2100, 2700, 2910, 3070, 3110, 3600, 3970,
> +            4080, 4350, 4370, 4680, 5020, 5450, 5740, 6140 ]
> +    default: 2910
> +
>    motorcomm,tx-clk-adj-enabled:
>      description: |
>        This configuration is mainly to adapt to VF2 with JH7110 SoC.
> -- 
> 2.17.1
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v4 1/2] dt-bindings: net: motorcomm: Add pad driver strength cfg
  2023-07-14 18:54   ` Andrew Lunn
@ 2023-07-17  8:28     ` Guo Samin
  0 siblings, 0 replies; 9+ messages in thread
From: Guo Samin @ 2023-07-17  8:28 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: linux-kernel, devicetree, netdev, Peter Geis, Frank,
	David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Rob Herring, Conor Dooley, Krzysztof Kozlowski, Heiner Kallweit,
	Russell King, Yanhong Wang



-------- 原始信息 --------
主题: Re: [PATCH v4 1/2] dt-bindings: net: motorcomm: Add pad driver strength cfg
From: Andrew Lunn <andrew@lunn.ch>
收件人: Samin Guo <samin.guo@starfivetech.com>
日期: 2023/7/15

>> +  motorcomm,rx-clk-driver-strength:
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    description: |
>> +      drive strength of rx_clk rgmii pad.
>> +      |----------------------------------|
>> +      |        rx_clk ds map table       |
>> +      |----------------------------------|
>> +      | DS(3b) |  wol@1.8v  |  wol@3.3v  |
>> +      |________|_________________________|
>> +      |        | current(uA)| current(uA)|
>> +      |   000  |     1200   |    3070    |
>> +      |   001  |     2100   |    4080    |
>> +      |   010  |     2700   |    4370    |
>> +      |   011  |     2910   |    4680    |
>> +      |   100  |     3110   |    5020    |
>> +      |   101  |     3600   |    5450    |
>> +      |   110  |     3970   |    5740    |
>> +      |   111  |     4350   |    6140    |
>> +      |--------|------------|------------|
>> +    enum: [ 1200, 2100, 2700, 2910, 3070, 3110, 3600, 3970,
>> +            4080, 4350, 4370, 4680, 5020, 5450, 5740, 6140 ]
>> +    default: 2910
> 
> The DS(3b) value is not relevant to the binding. It is a driver
> detail. So i would not bother listing it.
> 
ok, will remove it.

> Please add a comment explaining what wol is. 
> 
>        Andrew

Sorry,it should be vol (voltage), not wol.

 
Best regards,
Samin

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v4 1/2] dt-bindings: net: motorcomm: Add pad driver strength cfg
  2023-07-15  2:47   ` Rob Herring
@ 2023-07-17  8:35     ` Guo Samin
  0 siblings, 0 replies; 9+ messages in thread
From: Guo Samin @ 2023-07-17  8:35 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-kernel, devicetree, netdev, Peter Geis, Frank,
	David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Conor Dooley, Krzysztof Kozlowski, Andrew Lunn, Heiner Kallweit,
	Russell King, Yanhong Wang

-------- 原始信息 --------
主题: Re: [PATCH v4 1/2] dt-bindings: net: motorcomm: Add pad driver strength cfg
From: Rob Herring <robh@kernel.org>
收件人: Samin Guo <samin.guo@starfivetech.com>
日期: 2023/7/15

> On Fri, Jul 14, 2023 at 06:14:05PM +0800, Samin Guo wrote:
>> The motorcomm phy (YT8531) supports the ability to adjust the drive
>> strength of the rx_clk/rx_data.
>>
>> The YT8531 RGMII LDO voltage supports 1.8V/3.3V, and the
>> LDO voltage can be configured with hardware pull-up resistors to match
>> the SOC voltage (usually 1.8V). The software can read the registers
>> 0xA001 obtain the current LDO voltage value.
>>
>> When we configure the drive strength, we need to read the current LDO
>> voltage value to ensure that it is a legal value at that LDO voltage.
>>
>> Reviewed-by: Hal Feng <hal.feng@starfivetech.com>
>> Signed-off-by: Samin Guo <samin.guo@starfivetech.com>
>> ---
>>  .../bindings/net/motorcomm,yt8xxx.yaml        | 46 +++++++++++++++++++
>>  1 file changed, 46 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml b/Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml
>> index 157e3bbcaf6f..097bf143af35 100644
>> --- a/Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml
>> +++ b/Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml
>> @@ -52,6 +52,52 @@ properties:
>>        for a timer.
>>      type: boolean
>>  
>> +  motorcomm,rx-clk-driver-strength:
>> +    $ref: /schemas/types.yaml#/definitions/uint32
> 
> As the units are uA, drop the type and add '-microamp' suffix. 
> 'motorcomm,rx-clk-drv-microamp' is probably sufficient.
>
Thanks for the guidance, will be improved in the next version.
 
>> +    description: |
>> +      drive strength of rx_clk rgmii pad.
>> +      |----------------------------------|
>> +      |        rx_clk ds map table       |
>> +      |----------------------------------|
>> +      | DS(3b) |  wol@1.8v  |  wol@3.3v  |
>> +      |________|_________________________|
>> +      |        | current(uA)| current(uA)|
>> +      |   000  |     1200   |    3070    |
>> +      |   001  |     2100   |    4080    |
>> +      |   010  |     2700   |    4370    |
>> +      |   011  |     2910   |    4680    |
>> +      |   100  |     3110   |    5020    |
>> +      |   101  |     3600   |    5450    |
>> +      |   110  |     3970   |    5740    |
>> +      |   111  |     4350   |    6140    |
>> +      |--------|------------|------------|
>> +    enum: [ 1200, 2100, 2700, 2910, 3070, 3110, 3600, 3970,
>> +            4080, 4350, 4370, 4680, 5020, 5450, 5740, 6140 ]
>> +    default: 2910
>> +
>> +  motorcomm,rx-data-driver-strength:
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    description: |
>> +      drive strength of rx_data/rx_ctl rgmii pad.
>> +      |----------------------------------|
>> +      |        rx_data ds map table      |
>> +      |----------------------------------|
>> +      | DS(3b) |  wol@1.8v  |  wol@3.3v  |
>> +      |________|_________________________|
>> +      |        | current(uA)| current(uA)|
>> +      |   000  |     1200   |    3070    |
>> +      |   001  |     2100   |    4080    |
>> +      |   010  |     2700   |    4370    |
>> +      |   011  |     2910   |    4680    |
>> +      |   100  |     3110   |    5020    |
>> +      |   101  |     3600   |    5450    |
>> +      |   110  |     3970   |    5740    |
>> +      |   111  |     4350   |    6140    |
>> +      |--------|------------|------------|
>> +    enum: [ 1200, 2100, 2700, 2910, 3070, 3110, 3600, 3970,
>> +            4080, 4350, 4370, 4680, 5020, 5450, 5740, 6140 ]
>> +    default: 2910
>> +
>>    motorcomm,tx-clk-adj-enabled:
>>      description: |
>>        This configuration is mainly to adapt to VF2 with JH7110 SoC.
>> -- 
>> 2.17.1
>>

Best regards,
Samin

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v4 2/2] net: phy: motorcomm: Add pad drive strength cfg support
  2023-07-14 18:49   ` Andrew Lunn
@ 2023-07-17  8:40     ` Guo Samin
  0 siblings, 0 replies; 9+ messages in thread
From: Guo Samin @ 2023-07-17  8:40 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: linux-kernel, devicetree, netdev, Peter Geis, Frank,
	David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Rob Herring, Conor Dooley, Krzysztof Kozlowski, Heiner Kallweit,
	Russell King, Yanhong Wang



-------- 原始信息 --------
主题: 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-07-17  8:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-14 10:14 [PATCH v4 0/2] Add motorcomm phy pad-driver-strength-cfg support Samin Guo
2023-07-14 10:14 ` [PATCH v4 1/2] dt-bindings: net: motorcomm: Add pad driver strength cfg Samin Guo
2023-07-14 18:54   ` Andrew Lunn
2023-07-17  8:28     ` Guo Samin
2023-07-15  2:47   ` Rob Herring
2023-07-17  8:35     ` Guo Samin
2023-07-14 10:14 ` [PATCH v4 2/2] net: phy: motorcomm: Add pad drive strength cfg support Samin Guo
2023-07-14 18:49   ` Andrew Lunn
2023-07-17  8:40     ` Guo Samin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.