* [PATCH v4 1/3] dt-bindings: net: sophgo,sg2044-dwmac: add phy mode restriction
2025-10-28 0:38 [PATCH v4 0/3] net: stmmac: dwmac-sophgo: Add phy interface filter Inochi Amaoto
@ 2025-10-28 0:38 ` Inochi Amaoto
2025-10-28 19:22 ` Conor Dooley
2025-10-28 0:38 ` [PATCH v4 2/3] net: phy: Add helper for fixing RGMII PHY mode based on internal mac delay Inochi Amaoto
2025-10-28 0:38 ` [PATCH v4 3/3] net: stmmac: dwmac-sophgo: Add phy interface filter Inochi Amaoto
2 siblings, 1 reply; 11+ messages in thread
From: Inochi Amaoto @ 2025-10-28 0:38 UTC (permalink / raw)
To: Han Gao, Icenowy Zheng, Vivian Wang, Yao Zi, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen Wang,
Inochi Amaoto, Maxime Coquelin, Alexandre Torgue, Heiner Kallweit,
Russell King, Russell King (Oracle)
Cc: netdev, devicetree, sophgo, linux-kernel, linux-stm32,
linux-arm-kernel, Yixun Lan, Longbin Li
As the ethernet controller of SG2044 and SG2042 only supports
RGMII phy. Add phy-mode property to restrict the value.
Also, since SG2042 has internal rx delay in its mac, make
only "rgmii-txid" and "rgmii-id" valid for phy-mode.
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
---
.../bindings/net/sophgo,sg2044-dwmac.yaml | 20 +++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml b/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml
index ce21979a2d9a..916ef8f4838a 100644
--- a/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml
+++ b/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml
@@ -70,6 +70,26 @@ required:
allOf:
- $ref: snps,dwmac.yaml#
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: sophgo,sg2042-dwmac
+ then:
+ properties:
+ phy-mode:
+ enum:
+ - rgmii-txid
+ - rgmii-id
+ else:
+ properties:
+ phy-mode:
+ enum:
+ - rgmii
+ - rgmii-rxid
+ - rgmii-txid
+ - rgmii-id
+
unevaluatedProperties: false
--
2.51.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v4 1/3] dt-bindings: net: sophgo,sg2044-dwmac: add phy mode restriction
2025-10-28 0:38 ` [PATCH v4 1/3] dt-bindings: net: sophgo,sg2044-dwmac: add phy mode restriction Inochi Amaoto
@ 2025-10-28 19:22 ` Conor Dooley
2025-10-29 0:56 ` Inochi Amaoto
0 siblings, 1 reply; 11+ messages in thread
From: Conor Dooley @ 2025-10-28 19:22 UTC (permalink / raw)
To: Inochi Amaoto
Cc: Han Gao, Icenowy Zheng, Vivian Wang, Yao Zi, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen Wang,
Maxime Coquelin, Alexandre Torgue, Heiner Kallweit, Russell King,
Russell King (Oracle), netdev, devicetree, sophgo, linux-kernel,
linux-stm32, linux-arm-kernel, Yixun Lan, Longbin Li
[-- Attachment #1: Type: text/plain, Size: 1503 bytes --]
On Tue, Oct 28, 2025 at 08:38:56AM +0800, Inochi Amaoto wrote:
> As the ethernet controller of SG2044 and SG2042 only supports
> RGMII phy. Add phy-mode property to restrict the value.
>
> Also, since SG2042 has internal rx delay in its mac, make
> only "rgmii-txid" and "rgmii-id" valid for phy-mode.
Should this have a fixes tag?
Acked-by: Conor Dooley <conor.dooley@microchip.com>
>
> Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
> ---
> .../bindings/net/sophgo,sg2044-dwmac.yaml | 20 +++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml b/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml
> index ce21979a2d9a..916ef8f4838a 100644
> --- a/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml
> +++ b/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml
> @@ -70,6 +70,26 @@ required:
>
> allOf:
> - $ref: snps,dwmac.yaml#
> + - if:
> + properties:
> + compatible:
> + contains:
> + const: sophgo,sg2042-dwmac
> + then:
> + properties:
> + phy-mode:
> + enum:
> + - rgmii-txid
> + - rgmii-id
> + else:
> + properties:
> + phy-mode:
> + enum:
> + - rgmii
> + - rgmii-rxid
> + - rgmii-txid
> + - rgmii-id
> +
>
> unevaluatedProperties: false
>
> --
> 2.51.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 1/3] dt-bindings: net: sophgo,sg2044-dwmac: add phy mode restriction
2025-10-28 19:22 ` Conor Dooley
@ 2025-10-29 0:56 ` Inochi Amaoto
2025-10-29 17:54 ` Conor Dooley
0 siblings, 1 reply; 11+ messages in thread
From: Inochi Amaoto @ 2025-10-29 0:56 UTC (permalink / raw)
To: Conor Dooley, Inochi Amaoto
Cc: Han Gao, Icenowy Zheng, Vivian Wang, Yao Zi, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen Wang,
Maxime Coquelin, Alexandre Torgue, Heiner Kallweit, Russell King,
Russell King (Oracle), netdev, devicetree, sophgo, linux-kernel,
linux-stm32, linux-arm-kernel, Yixun Lan, Longbin Li
On Tue, Oct 28, 2025 at 07:22:37PM +0000, Conor Dooley wrote:
> On Tue, Oct 28, 2025 at 08:38:56AM +0800, Inochi Amaoto wrote:
> > As the ethernet controller of SG2044 and SG2042 only supports
> > RGMII phy. Add phy-mode property to restrict the value.
> >
> > Also, since SG2042 has internal rx delay in its mac, make
> > only "rgmii-txid" and "rgmii-id" valid for phy-mode.
>
> Should this have a fixes tag?
> Acked-by: Conor Dooley <conor.dooley@microchip.com>
>
Although I add a fixes tag to the driver, I am not sure whether the
binding requires it. But if it is required, I think it should be
Fixes: e281c48a7336 ("dt-bindings: net: sophgo,sg2044-dwmac: Add support for Sophgo SG2042 dwmac")
> >
> > Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
> > ---
> > .../bindings/net/sophgo,sg2044-dwmac.yaml | 20 +++++++++++++++++++
> > 1 file changed, 20 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml b/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml
> > index ce21979a2d9a..916ef8f4838a 100644
> > --- a/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml
> > +++ b/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml
> > @@ -70,6 +70,26 @@ required:
> >
> > allOf:
> > - $ref: snps,dwmac.yaml#
> > + - if:
> > + properties:
> > + compatible:
> > + contains:
> > + const: sophgo,sg2042-dwmac
> > + then:
> > + properties:
> > + phy-mode:
> > + enum:
> > + - rgmii-txid
> > + - rgmii-id
> > + else:
> > + properties:
> > + phy-mode:
> > + enum:
> > + - rgmii
> > + - rgmii-rxid
> > + - rgmii-txid
> > + - rgmii-id
> > +
> >
> > unevaluatedProperties: false
> >
> > --
> > 2.51.1
> >
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH v4 1/3] dt-bindings: net: sophgo,sg2044-dwmac: add phy mode restriction
2025-10-29 0:56 ` Inochi Amaoto
@ 2025-10-29 17:54 ` Conor Dooley
2025-10-30 2:17 ` Inochi Amaoto
0 siblings, 1 reply; 11+ messages in thread
From: Conor Dooley @ 2025-10-29 17:54 UTC (permalink / raw)
To: Inochi Amaoto
Cc: Han Gao, Icenowy Zheng, Vivian Wang, Yao Zi, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen Wang,
Maxime Coquelin, Alexandre Torgue, Heiner Kallweit, Russell King,
Russell King (Oracle), netdev, devicetree, sophgo, linux-kernel,
linux-stm32, linux-arm-kernel, Yixun Lan, Longbin Li
[-- Attachment #1: Type: text/plain, Size: 2478 bytes --]
On Wed, Oct 29, 2025 at 08:56:09AM +0800, Inochi Amaoto wrote:
> On Tue, Oct 28, 2025 at 07:22:37PM +0000, Conor Dooley wrote:
> > On Tue, Oct 28, 2025 at 08:38:56AM +0800, Inochi Amaoto wrote:
> > > As the ethernet controller of SG2044 and SG2042 only supports
> > > RGMII phy. Add phy-mode property to restrict the value.
> > >
> > > Also, since SG2042 has internal rx delay in its mac, make
> > > only "rgmii-txid" and "rgmii-id" valid for phy-mode.
> >
> > Should this have a fixes tag?
> > Acked-by: Conor Dooley <conor.dooley@microchip.com>
> >
>
> Although I add a fixes tag to the driver, I am not sure whether the
> binding requires it. But if it is required, I think it should be
Kinda depends for bindings, amending a binding for completeness probably
doesn't need one but amending it to actually permit a functional
configuration does. This is somewhere in-between I suppose. If a driver
change is coming along with it which is likely to be backported, that'd
be a vote in favour of a fixes tag here too, so that the binding and
driver match in stable.
>
> Fixes: e281c48a7336 ("dt-bindings: net: sophgo,sg2044-dwmac: Add support for Sophgo SG2042 dwmac")
>
> > >
> > > Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
> > > ---
> > > .../bindings/net/sophgo,sg2044-dwmac.yaml | 20 +++++++++++++++++++
> > > 1 file changed, 20 insertions(+)
> > >
> > > diff --git a/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml b/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml
> > > index ce21979a2d9a..916ef8f4838a 100644
> > > --- a/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml
> > > +++ b/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml
> > > @@ -70,6 +70,26 @@ required:
> > >
> > > allOf:
> > > - $ref: snps,dwmac.yaml#
> > > + - if:
> > > + properties:
> > > + compatible:
> > > + contains:
> > > + const: sophgo,sg2042-dwmac
> > > + then:
> > > + properties:
> > > + phy-mode:
> > > + enum:
> > > + - rgmii-txid
> > > + - rgmii-id
> > > + else:
> > > + properties:
> > > + phy-mode:
> > > + enum:
> > > + - rgmii
> > > + - rgmii-rxid
> > > + - rgmii-txid
> > > + - rgmii-id
> > > +
> > >
> > > unevaluatedProperties: false
> > >
> > > --
> > > 2.51.1
> > >
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH v4 1/3] dt-bindings: net: sophgo,sg2044-dwmac: add phy mode restriction
2025-10-29 17:54 ` Conor Dooley
@ 2025-10-30 2:17 ` Inochi Amaoto
0 siblings, 0 replies; 11+ messages in thread
From: Inochi Amaoto @ 2025-10-30 2:17 UTC (permalink / raw)
To: Conor Dooley, Inochi Amaoto
Cc: Han Gao, Icenowy Zheng, Vivian Wang, Yao Zi, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen Wang,
Maxime Coquelin, Alexandre Torgue, Heiner Kallweit, Russell King,
Russell King (Oracle), netdev, devicetree, sophgo, linux-kernel,
linux-stm32, linux-arm-kernel, Yixun Lan, Longbin Li
On Wed, Oct 29, 2025 at 05:54:49PM +0000, Conor Dooley wrote:
> On Wed, Oct 29, 2025 at 08:56:09AM +0800, Inochi Amaoto wrote:
> > On Tue, Oct 28, 2025 at 07:22:37PM +0000, Conor Dooley wrote:
> > > On Tue, Oct 28, 2025 at 08:38:56AM +0800, Inochi Amaoto wrote:
> > > > As the ethernet controller of SG2044 and SG2042 only supports
> > > > RGMII phy. Add phy-mode property to restrict the value.
> > > >
> > > > Also, since SG2042 has internal rx delay in its mac, make
> > > > only "rgmii-txid" and "rgmii-id" valid for phy-mode.
> > >
> > > Should this have a fixes tag?
> > > Acked-by: Conor Dooley <conor.dooley@microchip.com>
> > >
> >
> > Although I add a fixes tag to the driver, I am not sure whether the
> > binding requires it. But if it is required, I think it should be
>
> Kinda depends for bindings, amending a binding for completeness probably
> doesn't need one but amending it to actually permit a functional
> configuration does. This is somewhere in-between I suppose. If a driver
> change is coming along with it which is likely to be backported, that'd
> be a vote in favour of a fixes tag here too, so that the binding and
> driver match in stable.
>
Thank you. It is helpful for me. And in this case, it is suitable
to add this fixes tag.
Regards,
Inochi
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v4 2/3] net: phy: Add helper for fixing RGMII PHY mode based on internal mac delay
2025-10-28 0:38 [PATCH v4 0/3] net: stmmac: dwmac-sophgo: Add phy interface filter Inochi Amaoto
2025-10-28 0:38 ` [PATCH v4 1/3] dt-bindings: net: sophgo,sg2044-dwmac: add phy mode restriction Inochi Amaoto
@ 2025-10-28 0:38 ` Inochi Amaoto
2025-10-29 19:28 ` Maxime Chevallier
2025-10-28 0:38 ` [PATCH v4 3/3] net: stmmac: dwmac-sophgo: Add phy interface filter Inochi Amaoto
2 siblings, 1 reply; 11+ messages in thread
From: Inochi Amaoto @ 2025-10-28 0:38 UTC (permalink / raw)
To: Han Gao, Icenowy Zheng, Vivian Wang, Yao Zi, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen Wang,
Inochi Amaoto, Maxime Coquelin, Alexandre Torgue, Heiner Kallweit,
Russell King, Russell King (Oracle)
Cc: netdev, devicetree, sophgo, linux-kernel, linux-stm32,
linux-arm-kernel, Yixun Lan, Longbin Li
The "phy-mode" property of devicetree indicates whether the PCB has
delay now, which means the mac needs to modify the PHY mode based
on whether there is an internal delay in the mac.
This modification is similar for many ethernet drivers. To simplify
code, define the helper phy_fix_phy_mode_for_mac_delays(speed, mac_txid,
mac_rxid) to fix PHY mode based on whether mac adds internal delay.
Suggested-by: Russell King (Oracle) <linux@armlinux.org.uk>
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
---
drivers/net/phy/phy-core.c | 43 ++++++++++++++++++++++++++++++++++++++
include/linux/phy.h | 3 +++
2 files changed, 46 insertions(+)
diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c
index 605ca20ae192..4f258fb409da 100644
--- a/drivers/net/phy/phy-core.c
+++ b/drivers/net/phy/phy-core.c
@@ -101,6 +101,49 @@ const char *phy_rate_matching_to_str(int rate_matching)
}
EXPORT_SYMBOL_GPL(phy_rate_matching_to_str);
+/**
+ * phy_fix_phy_mode_for_mac_delays - Convenience function for fixing PHY
+ * mode based on whether mac adds internal delay
+ *
+ * @interface: The current interface mode of the port
+ * @mac_txid: True if the mac adds internal tx delay
+ * @mac_rxid: True if the mac adds internal rx delay
+ *
+ * Return fixed PHY mode, or PHY_INTERFACE_MODE_NA if the interface can
+ * not apply the internal delay
+ */
+phy_interface_t phy_fix_phy_mode_for_mac_delays(phy_interface_t interface,
+ bool mac_txid, bool mac_rxid)
+{
+ if (!phy_interface_mode_is_rgmii(interface))
+ return interface;
+
+ if (mac_txid && mac_rxid) {
+ if (interface == PHY_INTERFACE_MODE_RGMII_ID)
+ return PHY_INTERFACE_MODE_RGMII;
+ return PHY_INTERFACE_MODE_NA;
+ }
+
+ if (mac_txid) {
+ if (interface == PHY_INTERFACE_MODE_RGMII_ID)
+ return PHY_INTERFACE_MODE_RGMII_RXID;
+ if (interface == PHY_INTERFACE_MODE_RGMII_TXID)
+ return PHY_INTERFACE_MODE_RGMII;
+ return PHY_INTERFACE_MODE_NA;
+ }
+
+ if (mac_rxid) {
+ if (interface == PHY_INTERFACE_MODE_RGMII_ID)
+ return PHY_INTERFACE_MODE_RGMII_TXID;
+ if (interface == PHY_INTERFACE_MODE_RGMII_RXID)
+ return PHY_INTERFACE_MODE_RGMII;
+ return PHY_INTERFACE_MODE_NA;
+ }
+
+ return interface;
+}
+EXPORT_SYMBOL_GPL(phy_fix_phy_mode_for_mac_delays);
+
/**
* phy_interface_num_ports - Return the number of links that can be carried by
* a given MAC-PHY physical link. Returns 0 if this is
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 3c7634482356..0bc00a4cceb2 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1813,6 +1813,9 @@ static inline bool phy_is_pseudo_fixed_link(struct phy_device *phydev)
return phydev->is_pseudo_fixed_link;
}
+phy_interface_t phy_fix_phy_mode_for_mac_delays(phy_interface_t interface,
+ bool mac_txid, bool mac_rxid);
+
int phy_save_page(struct phy_device *phydev);
int phy_select_page(struct phy_device *phydev, int page);
int phy_restore_page(struct phy_device *phydev, int oldpage, int ret);
--
2.51.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH v4 2/3] net: phy: Add helper for fixing RGMII PHY mode based on internal mac delay
2025-10-28 0:38 ` [PATCH v4 2/3] net: phy: Add helper for fixing RGMII PHY mode based on internal mac delay Inochi Amaoto
@ 2025-10-29 19:28 ` Maxime Chevallier
0 siblings, 0 replies; 11+ messages in thread
From: Maxime Chevallier @ 2025-10-29 19:28 UTC (permalink / raw)
To: Inochi Amaoto, Han Gao, Icenowy Zheng, Vivian Wang, Yao Zi,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chen Wang, Maxime Coquelin, Alexandre Torgue, Heiner Kallweit,
Russell King, Russell King (Oracle)
Cc: netdev, devicetree, sophgo, linux-kernel, linux-stm32,
linux-arm-kernel, Yixun Lan, Longbin Li
Hi,
On 28/10/2025 01:38, Inochi Amaoto wrote:
> The "phy-mode" property of devicetree indicates whether the PCB has
> delay now, which means the mac needs to modify the PHY mode based
> on whether there is an internal delay in the mac.
>
> This modification is similar for many ethernet drivers. To simplify
> code, define the helper phy_fix_phy_mode_for_mac_delays(speed, mac_txid,
> mac_rxid) to fix PHY mode based on whether mac adds internal delay.
>
> Suggested-by: Russell King (Oracle) <linux@armlinux.org.uk>
> Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Name may be a bit long, but I'm not the best at naming stuff :)
I agree with the logic of that helper,
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Maxime
> ---
> drivers/net/phy/phy-core.c | 43 ++++++++++++++++++++++++++++++++++++++
> include/linux/phy.h | 3 +++
> 2 files changed, 46 insertions(+)
>
> diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c
> index 605ca20ae192..4f258fb409da 100644
> --- a/drivers/net/phy/phy-core.c
> +++ b/drivers/net/phy/phy-core.c
> @@ -101,6 +101,49 @@ const char *phy_rate_matching_to_str(int rate_matching)
> }
> EXPORT_SYMBOL_GPL(phy_rate_matching_to_str);
>
> +/**
> + * phy_fix_phy_mode_for_mac_delays - Convenience function for fixing PHY
> + * mode based on whether mac adds internal delay
> + *
> + * @interface: The current interface mode of the port
> + * @mac_txid: True if the mac adds internal tx delay
> + * @mac_rxid: True if the mac adds internal rx delay
> + *
> + * Return fixed PHY mode, or PHY_INTERFACE_MODE_NA if the interface can
> + * not apply the internal delay
> + */
> +phy_interface_t phy_fix_phy_mode_for_mac_delays(phy_interface_t interface,
> + bool mac_txid, bool mac_rxid)
> +{
> + if (!phy_interface_mode_is_rgmii(interface))
> + return interface;
> +
> + if (mac_txid && mac_rxid) {
> + if (interface == PHY_INTERFACE_MODE_RGMII_ID)
> + return PHY_INTERFACE_MODE_RGMII;
> + return PHY_INTERFACE_MODE_NA;
> + }
> +
> + if (mac_txid) {
> + if (interface == PHY_INTERFACE_MODE_RGMII_ID)
> + return PHY_INTERFACE_MODE_RGMII_RXID;
> + if (interface == PHY_INTERFACE_MODE_RGMII_TXID)
> + return PHY_INTERFACE_MODE_RGMII;
> + return PHY_INTERFACE_MODE_NA;
> + }
> +
> + if (mac_rxid) {
> + if (interface == PHY_INTERFACE_MODE_RGMII_ID)
> + return PHY_INTERFACE_MODE_RGMII_TXID;
> + if (interface == PHY_INTERFACE_MODE_RGMII_RXID)
> + return PHY_INTERFACE_MODE_RGMII;
> + return PHY_INTERFACE_MODE_NA;
> + }
> +
> + return interface;
> +}
> +EXPORT_SYMBOL_GPL(phy_fix_phy_mode_for_mac_delays);
> +
> /**
> * phy_interface_num_ports - Return the number of links that can be carried by
> * a given MAC-PHY physical link. Returns 0 if this is
> diff --git a/include/linux/phy.h b/include/linux/phy.h
> index 3c7634482356..0bc00a4cceb2 100644
> --- a/include/linux/phy.h
> +++ b/include/linux/phy.h
> @@ -1813,6 +1813,9 @@ static inline bool phy_is_pseudo_fixed_link(struct phy_device *phydev)
> return phydev->is_pseudo_fixed_link;
> }
>
> +phy_interface_t phy_fix_phy_mode_for_mac_delays(phy_interface_t interface,
> + bool mac_txid, bool mac_rxid);
> +
> int phy_save_page(struct phy_device *phydev);
> int phy_select_page(struct phy_device *phydev, int page);
> int phy_restore_page(struct phy_device *phydev, int oldpage, int ret);
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v4 3/3] net: stmmac: dwmac-sophgo: Add phy interface filter
2025-10-28 0:38 [PATCH v4 0/3] net: stmmac: dwmac-sophgo: Add phy interface filter Inochi Amaoto
2025-10-28 0:38 ` [PATCH v4 1/3] dt-bindings: net: sophgo,sg2044-dwmac: add phy mode restriction Inochi Amaoto
2025-10-28 0:38 ` [PATCH v4 2/3] net: phy: Add helper for fixing RGMII PHY mode based on internal mac delay Inochi Amaoto
@ 2025-10-28 0:38 ` Inochi Amaoto
2025-10-30 0:49 ` Yixun Lan
2 siblings, 1 reply; 11+ messages in thread
From: Inochi Amaoto @ 2025-10-28 0:38 UTC (permalink / raw)
To: Han Gao, Icenowy Zheng, Vivian Wang, Yao Zi, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen Wang,
Inochi Amaoto, Maxime Coquelin, Alexandre Torgue, Heiner Kallweit,
Russell King, Russell King (Oracle)
Cc: netdev, devicetree, sophgo, linux-kernel, linux-stm32,
linux-arm-kernel, Yixun Lan, Longbin Li
As the SG2042 has an internal rx delay, the delay should be removed
when initializing the mac, otherwise the phy will be misconfigurated.
Fixes: 543009e2d4cd ("net: stmmac: dwmac-sophgo: Add support for Sophgo SG2042 SoC")
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Tested-by: Han Gao <rabenda.cn@gmail.com>
---
.../ethernet/stmicro/stmmac/dwmac-sophgo.c | 20 ++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
index 3b7947a7a7ba..7f0ca4249a13 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
@@ -7,11 +7,16 @@
#include <linux/clk.h>
#include <linux/module.h>
+#include <linux/property.h>
#include <linux/mod_devicetable.h>
#include <linux/platform_device.h>
#include "stmmac_platform.h"
+struct sophgo_dwmac_data {
+ bool has_internal_rx_delay;
+};
+
static int sophgo_sg2044_dwmac_init(struct platform_device *pdev,
struct plat_stmmacenet_data *plat_dat,
struct stmmac_resources *stmmac_res)
@@ -32,6 +37,7 @@ static int sophgo_sg2044_dwmac_init(struct platform_device *pdev,
static int sophgo_dwmac_probe(struct platform_device *pdev)
{
struct plat_stmmacenet_data *plat_dat;
+ const struct sophgo_dwmac_data *data;
struct stmmac_resources stmmac_res;
struct device *dev = &pdev->dev;
int ret;
@@ -50,11 +56,23 @@ static int sophgo_dwmac_probe(struct platform_device *pdev)
if (ret)
return ret;
+ data = device_get_match_data(&pdev->dev);
+ if (data && data->has_internal_rx_delay) {
+ plat_dat->phy_interface = phy_fix_phy_mode_for_mac_delays(plat_dat->phy_interface,
+ false, true);
+ if (plat_dat->phy_interface == PHY_INTERFACE_MODE_NA)
+ return -EINVAL;
+ }
+
return stmmac_dvr_probe(dev, plat_dat, &stmmac_res);
}
+static struct sophgo_dwmac_data sg2042_dwmac_data = {
+ .has_internal_rx_delay = true,
+};
+
static const struct of_device_id sophgo_dwmac_match[] = {
- { .compatible = "sophgo,sg2042-dwmac" },
+ { .compatible = "sophgo,sg2042-dwmac", .data = &sg2042_dwmac_data },
{ .compatible = "sophgo,sg2044-dwmac" },
{ /* sentinel */ }
};
--
2.51.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH v4 3/3] net: stmmac: dwmac-sophgo: Add phy interface filter
2025-10-28 0:38 ` [PATCH v4 3/3] net: stmmac: dwmac-sophgo: Add phy interface filter Inochi Amaoto
@ 2025-10-30 0:49 ` Yixun Lan
2025-10-30 2:16 ` Inochi Amaoto
0 siblings, 1 reply; 11+ messages in thread
From: Yixun Lan @ 2025-10-30 0:49 UTC (permalink / raw)
To: Inochi Amaoto
Cc: Han Gao, Icenowy Zheng, Vivian Wang, Yao Zi, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen Wang,
Maxime Coquelin, Alexandre Torgue, Heiner Kallweit, Russell King,
Russell King (Oracle), netdev, devicetree, sophgo, linux-kernel,
linux-stm32, linux-arm-kernel, Longbin Li
Hi Inochi,
On 08:38 Tue 28 Oct , Inochi Amaoto wrote:
> As the SG2042 has an internal rx delay, the delay should be removed
> when initializing the mac, otherwise the phy will be misconfigurated.
>
> Fixes: 543009e2d4cd ("net: stmmac: dwmac-sophgo: Add support for Sophgo SG2042 SoC")
> Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
> Tested-by: Han Gao <rabenda.cn@gmail.com>
> ---
...
> +static struct sophgo_dwmac_data sg2042_dwmac_data = {
> + .has_internal_rx_delay = true,
> +};
> +
you forget to address in this version? see
https://lore.kernel.org/all/ljyivijlhvrendlslvpo4b7rycclt5pheipegx3fwz3fksn4cn@fgpzyhr2j4gi/
--
Yixun Lan (dlan)
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH v4 3/3] net: stmmac: dwmac-sophgo: Add phy interface filter
2025-10-30 0:49 ` Yixun Lan
@ 2025-10-30 2:16 ` Inochi Amaoto
0 siblings, 0 replies; 11+ messages in thread
From: Inochi Amaoto @ 2025-10-30 2:16 UTC (permalink / raw)
To: Yixun Lan, Inochi Amaoto
Cc: Han Gao, Icenowy Zheng, Vivian Wang, Yao Zi, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen Wang,
Maxime Coquelin, Alexandre Torgue, Heiner Kallweit, Russell King,
Russell King (Oracle), netdev, devicetree, sophgo, linux-kernel,
linux-stm32, linux-arm-kernel, Longbin Li
On Thu, Oct 30, 2025 at 08:49:48AM +0800, Yixun Lan wrote:
> Hi Inochi,
>
> On 08:38 Tue 28 Oct , Inochi Amaoto wrote:
> > As the SG2042 has an internal rx delay, the delay should be removed
> > when initializing the mac, otherwise the phy will be misconfigurated.
> >
> > Fixes: 543009e2d4cd ("net: stmmac: dwmac-sophgo: Add support for Sophgo SG2042 SoC")
> > Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
> > Tested-by: Han Gao <rabenda.cn@gmail.com>
> > ---
> ...
> > +static struct sophgo_dwmac_data sg2042_dwmac_data = {
> > + .has_internal_rx_delay = true,
> > +};
> > +
> you forget to address in this version? see
> https://lore.kernel.org/all/ljyivijlhvrendlslvpo4b7rycclt5pheipegx3fwz3fksn4cn@fgpzyhr2j4gi/
>
Yeah, that's right, it seems like I have forgot too much things.....
Regards,
Inochi
^ permalink raw reply [flat|nested] 11+ messages in thread