* [net-next v2 1/4] dt-bindings: net: ftgmac100: Restrict phy-mode and delay properties for AST2600
2025-08-13 6:32 [net-next v2 0/4] Add AST2600 RGMII delay into ftgmac100 Jacky Chou
@ 2025-08-13 6:32 ` Jacky Chou
2025-08-15 18:12 ` Andrew Lunn
2025-08-13 6:32 ` [net-next v2 2/4] ARM: dts: aspeed-g6: Add ethernet alise and update MAC compatible Jacky Chou
` (4 subsequent siblings)
5 siblings, 1 reply; 15+ messages in thread
From: Jacky Chou @ 2025-08-13 6:32 UTC (permalink / raw)
To: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Joel Stanley, Andrew Jeffery
Cc: Simon Horman, Heiner Kallweit, Uwe Kleine-König,
Po-Yu Chuang, netdev, devicetree, linux-kernel, linux-arm-kernel,
linux-aspeed, taoren, bmc-sw2
Create the new compatibles to identify AST2600 MAC0/1 and MAC3/4.
Add conditional schema constraints for Aspeed AST2600 MAC controllers:
- For "aspeed,ast2600-mac01", restrict phy-mode to "rgmii-id" and
"rgmii-rxid", and require rx/tx-internal-delay-ps properties with 45ps
step.
- For "aspeed,ast2600-mac23", require rx/tx-internal-delay-ps properties
with 250ps step.
- Both require the "scu" property.
Other compatible values remain unrestricted.
Because the RGMII delay on AST2600 MAC0/1 is 45ps and its total delay
step is 32, cannot cover 2ns delay for RGMII to meet center. We need
the PHY side enables RX internal delay and the phy_mode must be
"rgmii-id" or "rgmii-rxid".
Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
---
.../bindings/net/faraday,ftgmac100.yaml | 50 +++++++++++++++++--
1 file changed, 47 insertions(+), 3 deletions(-)
diff --git a/Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml b/Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml
index 55d6a8379025..82c7c81eab10 100644
--- a/Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml
+++ b/Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml
@@ -6,9 +6,6 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Faraday Technology FTGMAC100 gigabit ethernet controller
-allOf:
- - $ref: ethernet-controller.yaml#
-
maintainers:
- Po-Yu Chuang <ratbert@faraday-tech.com>
@@ -21,6 +18,8 @@ properties:
- aspeed,ast2400-mac
- aspeed,ast2500-mac
- aspeed,ast2600-mac
+ - aspeed,ast2600-mac01
+ - aspeed,ast2600-mac23
- const: faraday,ftgmac100
reg:
@@ -69,6 +68,12 @@ properties:
mdio:
$ref: /schemas/net/mdio.yaml#
+ scu:
+ $ref: /schemas/types.yaml#/definitions/phandle
+ description:
+ Phandle to the SCU (System Control Unit) syscon node for Aspeed platform.
+ This reference is used by the MAC controller to configure the RGMII delays.
+
required:
- compatible
- reg
@@ -76,6 +81,45 @@ required:
unevaluatedProperties: false
+allOf:
+ - $ref: ethernet-controller.yaml#
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: aspeed,ast2600-mac01
+ then:
+ properties:
+ phy-mode:
+ enum: [rgmii-id, rgmii-rxid]
+ rx-internal-delay-ps:
+ minimum: 0
+ maximum: 1395
+ multipleOf: 45
+ tx-internal-delay-ps:
+ minimum: 0
+ maximum: 1395
+ multipleOf: 45
+ required:
+ - scu
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: aspeed,ast2600-mac23
+ then:
+ properties:
+ rx-internal-delay-ps:
+ minimum: 0
+ maximum: 7750
+ multipleOf: 250
+ tx-internal-delay-ps:
+ minimum: 0
+ maximum: 7750
+ multipleOf: 250
+ required:
+ - scu
+
examples:
- |
ethernet@1e660000 {
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [net-next v2 1/4] dt-bindings: net: ftgmac100: Restrict phy-mode and delay properties for AST2600
2025-08-13 6:32 ` [net-next v2 1/4] dt-bindings: net: ftgmac100: Restrict phy-mode and delay properties for AST2600 Jacky Chou
@ 2025-08-15 18:12 ` Andrew Lunn
0 siblings, 0 replies; 15+ messages in thread
From: Andrew Lunn @ 2025-08-15 18:12 UTC (permalink / raw)
To: Jacky Chou
Cc: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Joel Stanley, Andrew Jeffery, Simon Horman, Heiner Kallweit,
Uwe Kleine-König, Po-Yu Chuang, netdev, devicetree,
linux-kernel, linux-arm-kernel, linux-aspeed, taoren, bmc-sw2
> +allOf:
> + - $ref: ethernet-controller.yaml#
> + - if:
> + properties:
> + compatible:
> + contains:
> + const: aspeed,ast2600-mac01
> + then:
> + properties:
> + phy-mode:
> + enum: [rgmii-id, rgmii-rxid]
Why not rgmii-txid? Also, why not rgmii?
On the MAC, tx/rx-internal-delay-ps is meant to be used to perform
small fine tuning. There is no reason why you cannot use this with a
PCB which implements a delay.
Andrew
^ permalink raw reply [flat|nested] 15+ messages in thread
* [net-next v2 2/4] ARM: dts: aspeed-g6: Add ethernet alise and update MAC compatible
2025-08-13 6:32 [net-next v2 0/4] Add AST2600 RGMII delay into ftgmac100 Jacky Chou
2025-08-13 6:32 ` [net-next v2 1/4] dt-bindings: net: ftgmac100: Restrict phy-mode and delay properties for AST2600 Jacky Chou
@ 2025-08-13 6:32 ` Jacky Chou
2025-08-13 6:33 ` [net-next v2 3/4] ARM: dts: aspeed: ast2600evb: Add delay setting for MAC Jacky Chou
` (3 subsequent siblings)
5 siblings, 0 replies; 15+ messages in thread
From: Jacky Chou @ 2025-08-13 6:32 UTC (permalink / raw)
To: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Joel Stanley, Andrew Jeffery
Cc: Simon Horman, Heiner Kallweit, Uwe Kleine-König,
Po-Yu Chuang, netdev, devicetree, linux-kernel, linux-arm-kernel,
linux-aspeed, taoren, bmc-sw2
For RGMII delay setting, the MAC0 and MAC1 use the SCU0x340 to configure
the RGMII delay. We use the ethernet alise to identify the index of MAC.
And add the new compatible for MAC0/1 and MAC2/3 to calculate the
RGMII delay with different delay unit.
Finally, the RGMII delay of AST2600 is configured in SCU region and add
the scu phandle for configuration.
Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
---
arch/arm/boot/dts/aspeed/aspeed-g6.dtsi | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/arch/arm/boot/dts/aspeed/aspeed-g6.dtsi b/arch/arm/boot/dts/aspeed/aspeed-g6.dtsi
index 8ed715bd53aa..6be17b18da46 100644
--- a/arch/arm/boot/dts/aspeed/aspeed-g6.dtsi
+++ b/arch/arm/boot/dts/aspeed/aspeed-g6.dtsi
@@ -40,6 +40,10 @@ aliases {
mdio1 = &mdio1;
mdio2 = &mdio2;
mdio3 = &mdio3;
+ ethernet0 = &mac0;
+ ethernet1 = &mac1;
+ ethernet2 = &mac2;
+ ethernet3 = &mac3;
};
@@ -232,34 +236,46 @@ mdio3: mdio@1e650018 {
};
mac0: ethernet@1e660000 {
- compatible = "aspeed,ast2600-mac", "faraday,ftgmac100";
+ compatible = "aspeed,ast2600-mac01",
+ "aspeed,ast2600-mac",
+ "faraday,ftgmac100";
reg = <0x1e660000 0x180>;
interrupts = <GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&syscon ASPEED_CLK_GATE_MAC1CLK>;
+ scu = <&syscon>;
status = "disabled";
};
mac1: ethernet@1e680000 {
- compatible = "aspeed,ast2600-mac", "faraday,ftgmac100";
+ compatible = "aspeed,ast2600-mac01",
+ "aspeed,ast2600-mac",
+ "faraday,ftgmac100";
reg = <0x1e680000 0x180>;
interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&syscon ASPEED_CLK_GATE_MAC2CLK>;
+ scu = <&syscon>;
status = "disabled";
};
mac2: ethernet@1e670000 {
- compatible = "aspeed,ast2600-mac", "faraday,ftgmac100";
+ compatible = "aspeed,ast2600-mac23",
+ "aspeed,ast2600-mac",
+ "faraday,ftgmac100";
reg = <0x1e670000 0x180>;
interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&syscon ASPEED_CLK_GATE_MAC3CLK>;
+ scu = <&syscon>;
status = "disabled";
};
mac3: ethernet@1e690000 {
- compatible = "aspeed,ast2600-mac", "faraday,ftgmac100";
+ compatible = "aspeed,ast2600-mac23",
+ "aspeed,ast2600-mac",
+ "faraday,ftgmac100";
reg = <0x1e690000 0x180>;
interrupts = <GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&syscon ASPEED_CLK_GATE_MAC4CLK>;
+ scu = <&syscon>;
status = "disabled";
};
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [net-next v2 3/4] ARM: dts: aspeed: ast2600evb: Add delay setting for MAC
2025-08-13 6:32 [net-next v2 0/4] Add AST2600 RGMII delay into ftgmac100 Jacky Chou
2025-08-13 6:32 ` [net-next v2 1/4] dt-bindings: net: ftgmac100: Restrict phy-mode and delay properties for AST2600 Jacky Chou
2025-08-13 6:32 ` [net-next v2 2/4] ARM: dts: aspeed-g6: Add ethernet alise and update MAC compatible Jacky Chou
@ 2025-08-13 6:33 ` Jacky Chou
2025-08-15 18:17 ` Andrew Lunn
2025-08-13 6:33 ` [net-next v2 4/4] net: ftgmac100: Add RGMII delay configuration for AST2600 Jacky Chou
` (2 subsequent siblings)
5 siblings, 1 reply; 15+ messages in thread
From: Jacky Chou @ 2025-08-13 6:33 UTC (permalink / raw)
To: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Joel Stanley, Andrew Jeffery
Cc: Simon Horman, Heiner Kallweit, Uwe Kleine-König,
Po-Yu Chuang, netdev, devicetree, linux-kernel, linux-arm-kernel,
linux-aspeed, taoren, bmc-sw2
We use the rx-internal-delay-ps and the tx-internal-delay-ps to
configure the RGMII delay. And change the phy_mode of MAC0 and MAC1 to
"rgmii-id" to enable the TX/RX internal delay on PHY side. MAC0 and
MAC1 configure on the edge delay.
Keep the phy_mode of MAC2 and MAC3 to "rgmii". The RGMII delay of MAC2
and MAC3 can generate the delay to meet clock center, so we just add the
delay property to let driver to configure 2ns delay.
Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
---
arch/arm/boot/dts/aspeed/aspeed-ast2600-evb.dts | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/arch/arm/boot/dts/aspeed/aspeed-ast2600-evb.dts b/arch/arm/boot/dts/aspeed/aspeed-ast2600-evb.dts
index de83c0eb1d6e..dc4d437a39ed 100644
--- a/arch/arm/boot/dts/aspeed/aspeed-ast2600-evb.dts
+++ b/arch/arm/boot/dts/aspeed/aspeed-ast2600-evb.dts
@@ -123,22 +123,28 @@ ethphy3: ethernet-phy@0 {
&mac0 {
status = "okay";
- phy-mode = "rgmii-rxid";
+ phy-mode = "rgmii-id";
phy-handle = <ðphy0>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_rgmii1_default>;
+
+ rx-internal-delay-ps = <0>;
+ tx-internal-delay-ps = <0>;
};
&mac1 {
status = "okay";
- phy-mode = "rgmii-rxid";
+ phy-mode = "rgmii-id";
phy-handle = <ðphy1>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_rgmii2_default>;
+
+ rx-internal-delay-ps = <0>;
+ tx-internal-delay-ps = <0>;
};
&mac2 {
@@ -149,6 +155,9 @@ &mac2 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_rgmii3_default>;
+
+ rx-internal-delay-ps = <2000>;
+ tx-internal-delay-ps = <2000>;
};
&mac3 {
@@ -159,6 +168,9 @@ &mac3 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_rgmii4_default>;
+
+ rx-internal-delay-ps = <2000>;
+ tx-internal-delay-ps = <2000>;
};
&emmc_controller {
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [net-next v2 3/4] ARM: dts: aspeed: ast2600evb: Add delay setting for MAC
2025-08-13 6:33 ` [net-next v2 3/4] ARM: dts: aspeed: ast2600evb: Add delay setting for MAC Jacky Chou
@ 2025-08-15 18:17 ` Andrew Lunn
0 siblings, 0 replies; 15+ messages in thread
From: Andrew Lunn @ 2025-08-15 18:17 UTC (permalink / raw)
To: Jacky Chou
Cc: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Joel Stanley, Andrew Jeffery, Simon Horman, Heiner Kallweit,
Uwe Kleine-König, Po-Yu Chuang, netdev, devicetree,
linux-kernel, linux-arm-kernel, linux-aspeed, taoren, bmc-sw2
> @@ -149,6 +155,9 @@ &mac2 {
>
> pinctrl-names = "default";
> pinctrl-0 = <&pinctrl_rgmii3_default>;
> +
> + rx-internal-delay-ps = <2000>;
> + tx-internal-delay-ps = <2000>;
> };
>
> &mac3 {
> @@ -159,6 +168,9 @@ &mac3 {
>
> pinctrl-names = "default";
> pinctrl-0 = <&pinctrl_rgmii4_default>;
> +
> + rx-internal-delay-ps = <2000>;
> + tx-internal-delay-ps = <2000>;
> };
Documentation/devicetree/bindings/net/ethernet-controller.yaml
# Sometimes there is a need to fine tune the delays. Often the MAC or
# PHY can perform this fine tuning. In the MAC node, the Device Tree
# properties 'rx-internal-delay-ps' and 'tx-internal-delay-ps' should
# be used to indicate fine tuning performed by the MAC. The values
# expected here are small. A value of 2000ps, i.e 2ns, and a phy-mode
# of 'rgmii' will not be accepted by Reviewers.
Andrew
---
pw-bot: cr
^ permalink raw reply [flat|nested] 15+ messages in thread
* [net-next v2 4/4] net: ftgmac100: Add RGMII delay configuration for AST2600
2025-08-13 6:32 [net-next v2 0/4] Add AST2600 RGMII delay into ftgmac100 Jacky Chou
` (2 preceding siblings ...)
2025-08-13 6:33 ` [net-next v2 3/4] ARM: dts: aspeed: ast2600evb: Add delay setting for MAC Jacky Chou
@ 2025-08-13 6:33 ` Jacky Chou
2025-08-15 18:23 ` Andrew Lunn
2025-08-15 0:44 ` [net-next v2 0/4] Add AST2600 RGMII delay into ftgmac100 Jakub Kicinski
2025-08-15 18:42 ` Andrew Lunn
5 siblings, 1 reply; 15+ messages in thread
From: Jacky Chou @ 2025-08-13 6:33 UTC (permalink / raw)
To: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Joel Stanley, Andrew Jeffery
Cc: Simon Horman, Heiner Kallweit, Uwe Kleine-König,
Po-Yu Chuang, netdev, devicetree, linux-kernel, linux-arm-kernel,
linux-aspeed, taoren, bmc-sw2
In AST2600, the RGMII delay is configured in SCU register.
The MAC0/1 and the MAC2/3 on AST2600 have different delay unit with
their delay chain.
These MACs all have the 32 stage to configure delay chain.
|Delay Unit|Delay Stage|TX Edge Stage|RX Edge Stage|
------+----------+-----------+-------------+-------------+
MAC0/1| 45 ps| 32 | 0 | 0 |
------+----------+-----------+-------------+-------------+
MAC2/3| 250 ps| 32 | 0 | 26 |
------+----------+-----------+-------------+-------------+
The RX edge stage of MAC2 and MAC3 are strating from 26.
We calculate the delay stage from the rx-internal-delay-ps of MAC2/3 to
add 26. If the stage is equel to or bigger than 32, the delay stage will
be mask 0x1f to get the correct setting. The delay chain is like a ring
for configuration.
So, the rx-internal-delay-ps of MAC2/3 is 2000 ps, we will get the delay
stage is 2.
Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
---
drivers/net/ethernet/faraday/ftgmac100.c | 86 ++++++++++++++++++++++++
drivers/net/ethernet/faraday/ftgmac100.h | 12 ++++
2 files changed, 98 insertions(+)
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index a98d5af3f9e3..02f49558bed8 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -25,6 +25,9 @@
#include <linux/if_vlan.h>
#include <linux/of_net.h>
#include <linux/phy_fixed.h>
+#include <linux/mfd/syscon.h>
+#include <linux/regmap.h>
+#include <linux/bitfield.h>
#include <net/ip.h>
#include <net/ncsi.h>
@@ -1812,6 +1815,86 @@ static bool ftgmac100_has_child_node(struct device_node *np, const char *name)
return ret;
}
+static void ftgmac100_set_internal_delay(struct platform_device *pdev)
+{
+ struct device_node *np = pdev->dev.of_node;
+ struct regmap *scu;
+ u32 rgmii_tx_delay;
+ u32 rgmii_rx_delay;
+ int dly_mask;
+ int dly_reg;
+ int id;
+
+ if (!(of_device_is_compatible(np, "aspeed,ast2600-mac01") ||
+ of_device_is_compatible(np, "aspeed,ast2600-mac23")))
+ return;
+
+ /* If lack one of them, do not configure anything */
+ if (of_property_read_u32(np, "tx-internal-delay-ps", &rgmii_tx_delay)) {
+ dev_warn(&pdev->dev, "failed to get tx-internal-delay-ps\n");
+ return;
+ }
+ if (of_property_read_u32(np, "rx-internal-delay-ps", &rgmii_rx_delay)) {
+ dev_warn(&pdev->dev, "failed to get tx-internal-delay-ps\n");
+ return;
+ }
+ id = of_alias_get_id(np, "ethernet");
+ if (id < 0 || id > 3) {
+ /* If lack alias or out of range, do not configure anything */
+ dev_warn(&pdev->dev, "get wrong alise id %d\n", id);
+ return;
+ }
+
+ if (of_device_is_compatible(np, "aspeed,ast2600-mac01")) {
+ dly_reg = AST2600_MAC01_CLK_DLY;
+ if (rgmii_tx_delay > AST2600_MAC01_CLK_DLY_MAX) {
+ dev_warn(&pdev->dev, "tx-internal-delay-ps %u is out of range\n",
+ rgmii_tx_delay);
+ return;
+ }
+ if (rgmii_rx_delay > AST2600_MAC01_CLK_DLY_MAX) {
+ dev_warn(&pdev->dev, "rx-internal-delay-ps %u is out of range\n",
+ rgmii_rx_delay);
+ return;
+ }
+ rgmii_tx_delay /= AST2600_MAC01_CLK_DLY_UNIT;
+ rgmii_rx_delay /= AST2600_MAC01_CLK_DLY_UNIT;
+ } else if (of_device_is_compatible(np, "aspeed,ast2600-mac23")) {
+ dly_reg = AST2600_MAC23_CLK_DLY;
+ if (rgmii_tx_delay > AST2600_MAC23_CLK_DLY_MAX) {
+ dev_warn(&pdev->dev, "tx-internal-delay-ps %u is out of range\n",
+ rgmii_tx_delay);
+ return;
+ }
+ if (rgmii_rx_delay > AST2600_MAC23_CLK_DLY_MAX) {
+ dev_warn(&pdev->dev, "rx-internal-delay-ps %u is out of range\n",
+ rgmii_rx_delay);
+ return;
+ }
+ rgmii_tx_delay /= AST2600_MAC23_CLK_DLY_UNIT;
+ /* The index of rx edge delay is started from 0x1a */
+ rgmii_rx_delay = (0x1a + (rgmii_rx_delay / AST2600_MAC23_CLK_DLY_UNIT)) & 0x1f;
+ }
+
+ if (id == 0 || id == 2) {
+ dly_mask = ASPEED_MAC0_2_TX_DLY | ASPEED_MAC0_2_RX_DLY;
+ rgmii_tx_delay = FIELD_PREP(ASPEED_MAC0_2_TX_DLY, rgmii_tx_delay);
+ rgmii_rx_delay = FIELD_PREP(ASPEED_MAC0_2_RX_DLY, rgmii_rx_delay);
+ } else {
+ dly_mask = ASPEED_MAC1_3_TX_DLY | ASPEED_MAC1_3_RX_DLY;
+ rgmii_tx_delay = FIELD_PREP(ASPEED_MAC1_3_TX_DLY, rgmii_tx_delay);
+ rgmii_rx_delay = FIELD_PREP(ASPEED_MAC1_3_RX_DLY, rgmii_rx_delay);
+ }
+
+ scu = syscon_regmap_lookup_by_phandle(np, "scu");
+ if (IS_ERR(scu)) {
+ dev_warn(&pdev->dev, "failed to map scu base");
+ return;
+ }
+
+ regmap_update_bits(scu, dly_reg, dly_mask, rgmii_tx_delay | rgmii_rx_delay);
+}
+
static int ftgmac100_probe(struct platform_device *pdev)
{
struct resource *res;
@@ -1977,6 +2060,9 @@ static int ftgmac100_probe(struct platform_device *pdev)
if (of_device_is_compatible(np, "aspeed,ast2600-mac"))
iowrite32(FTGMAC100_TM_DEFAULT,
priv->base + FTGMAC100_OFFSET_TM);
+
+ /* Configure RGMII delay if there are the corresponding compatibles */
+ ftgmac100_set_internal_delay(pdev);
}
/* Default ring sizes */
diff --git a/drivers/net/ethernet/faraday/ftgmac100.h b/drivers/net/ethernet/faraday/ftgmac100.h
index 4968f6f0bdbc..a9f0f00ac784 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.h
+++ b/drivers/net/ethernet/faraday/ftgmac100.h
@@ -271,4 +271,16 @@ struct ftgmac100_rxdes {
#define FTGMAC100_RXDES1_UDP_CHKSUM_ERR (1 << 26)
#define FTGMAC100_RXDES1_IP_CHKSUM_ERR (1 << 27)
+/* Aspeed SCU */
+#define AST2600_MAC01_CLK_DLY 0x340
+#define AST2600_MAC23_CLK_DLY 0x350
+#define AST2600_MAC01_CLK_DLY_MAX 1395 /* ps */
+#define AST2600_MAC01_CLK_DLY_UNIT 45 /* ps */
+#define AST2600_MAC23_CLK_DLY_MAX 7750 /* ps */
+#define AST2600_MAC23_CLK_DLY_UNIT 250 /* ps */
+#define ASPEED_MAC0_2_TX_DLY GENMASK(5, 0)
+#define ASPEED_MAC0_2_RX_DLY GENMASK(17, 12)
+#define ASPEED_MAC1_3_TX_DLY GENMASK(11, 6)
+#define ASPEED_MAC1_3_RX_DLY GENMASK(23, 18)
+
#endif /* __FTGMAC100_H */
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [net-next v2 4/4] net: ftgmac100: Add RGMII delay configuration for AST2600
2025-08-13 6:33 ` [net-next v2 4/4] net: ftgmac100: Add RGMII delay configuration for AST2600 Jacky Chou
@ 2025-08-15 18:23 ` Andrew Lunn
0 siblings, 0 replies; 15+ messages in thread
From: Andrew Lunn @ 2025-08-15 18:23 UTC (permalink / raw)
To: Jacky Chou
Cc: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Joel Stanley, Andrew Jeffery, Simon Horman, Heiner Kallweit,
Uwe Kleine-König, Po-Yu Chuang, netdev, devicetree,
linux-kernel, linux-arm-kernel, linux-aspeed, taoren, bmc-sw2
On Wed, Aug 13, 2025 at 02:33:01PM +0800, Jacky Chou wrote:
> In AST2600, the RGMII delay is configured in SCU register.
> The MAC0/1 and the MAC2/3 on AST2600 have different delay unit with
> their delay chain.
> These MACs all have the 32 stage to configure delay chain.
> |Delay Unit|Delay Stage|TX Edge Stage|RX Edge Stage|
> ------+----------+-----------+-------------+-------------+
> MAC0/1| 45 ps| 32 | 0 | 0 |
> ------+----------+-----------+-------------+-------------+
> MAC2/3| 250 ps| 32 | 0 | 26 |
> ------+----------+-----------+-------------+-------------+
> The RX edge stage of MAC2 and MAC3 are strating from 26.
strating?
> +static void ftgmac100_set_internal_delay(struct platform_device *pdev)
> +{
> + struct device_node *np = pdev->dev.of_node;
> + struct regmap *scu;
> + u32 rgmii_tx_delay;
> + u32 rgmii_rx_delay;
> + int dly_mask;
> + int dly_reg;
> + int id;
> +
> + if (!(of_device_is_compatible(np, "aspeed,ast2600-mac01") ||
> + of_device_is_compatible(np, "aspeed,ast2600-mac23")))
> + return;
> +
> + /* If lack one of them, do not configure anything */
> + if (of_property_read_u32(np, "tx-internal-delay-ps", &rgmii_tx_delay)) {
> + dev_warn(&pdev->dev, "failed to get tx-internal-delay-ps\n");
> + return;
> + }
> + if (of_property_read_u32(np, "rx-internal-delay-ps", &rgmii_rx_delay)) {
> + dev_warn(&pdev->dev, "failed to get tx-internal-delay-ps\n");
> + return;
> + }
If these properties are required, but are missing, the DT blob is
broken. Please return -EINVAL, and fail the probe.
Please make all errors in this function due to a bad DT blob fatal.
Andrew
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [net-next v2 0/4] Add AST2600 RGMII delay into ftgmac100
2025-08-13 6:32 [net-next v2 0/4] Add AST2600 RGMII delay into ftgmac100 Jacky Chou
` (3 preceding siblings ...)
2025-08-13 6:33 ` [net-next v2 4/4] net: ftgmac100: Add RGMII delay configuration for AST2600 Jacky Chou
@ 2025-08-15 0:44 ` Jakub Kicinski
2025-08-15 18:42 ` Andrew Lunn
5 siblings, 0 replies; 15+ messages in thread
From: Jakub Kicinski @ 2025-08-15 0:44 UTC (permalink / raw)
To: Jacky Chou
Cc: Andrew Lunn, David S . Miller, Eric Dumazet, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Joel Stanley,
Andrew Jeffery, Simon Horman, Heiner Kallweit,
Uwe Kleine-König, Po-Yu Chuang, netdev, devicetree,
linux-kernel, linux-arm-kernel, linux-aspeed, taoren, bmc-sw2
On Wed, 13 Aug 2025 14:32:57 +0800 Jacky Chou wrote:
> This patch series adds support for configuring RGMII internal delays for the
> Aspeed AST2600 FTGMAC100 Ethernet MACs. It introduces new compatible strings to
> distinguish between MAC0/1 and MAC2/3, as their delay chains and configuration
> units differ.
> The device tree bindings are updated to restrict the allowed phy-mode and delay
> properties for each MAC type. Corresponding changes are made to the device tree
> source files and the FTGMAC100 driver to support the new delay configuration.
First patch doesn't apply cleanly, please respin.
--
pw-bot: cr
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [net-next v2 0/4] Add AST2600 RGMII delay into ftgmac100
2025-08-13 6:32 [net-next v2 0/4] Add AST2600 RGMII delay into ftgmac100 Jacky Chou
` (4 preceding siblings ...)
2025-08-15 0:44 ` [net-next v2 0/4] Add AST2600 RGMII delay into ftgmac100 Jakub Kicinski
@ 2025-08-15 18:42 ` Andrew Lunn
2025-08-20 0:40 ` 回覆: " Jacky Chou
5 siblings, 1 reply; 15+ messages in thread
From: Andrew Lunn @ 2025-08-15 18:42 UTC (permalink / raw)
To: Jacky Chou
Cc: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Joel Stanley, Andrew Jeffery, Simon Horman, Heiner Kallweit,
Uwe Kleine-König, Po-Yu Chuang, netdev, devicetree,
linux-kernel, linux-arm-kernel, linux-aspeed, taoren, bmc-sw2
On Wed, Aug 13, 2025 at 02:32:57PM +0800, Jacky Chou wrote:
> This patch series adds support for configuring RGMII internal delays for the
> Aspeed AST2600 FTGMAC100 Ethernet MACs.
So i think you are doing things in the wrong order. You first need to
sort out the mess of most, if not all, AST2600 have the wrong
phy-mode, because the RGMII delay configuration is hidden, and set
wrongly.
Please fix that first.
Then consider how you can add fine tuning of the delays. Maybe that
needs to wait for AST2700.
Andrew
^ permalink raw reply [flat|nested] 15+ messages in thread
* 回覆: [net-next v2 0/4] Add AST2600 RGMII delay into ftgmac100
2025-08-15 18:42 ` Andrew Lunn
@ 2025-08-20 0:40 ` Jacky Chou
2025-08-20 2:43 ` Andrew Lunn
0 siblings, 1 reply; 15+ messages in thread
From: Jacky Chou @ 2025-08-20 0:40 UTC (permalink / raw)
To: Andrew Lunn
Cc: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Joel Stanley, Andrew Jeffery, Simon Horman, Heiner Kallweit,
Uwe Kleine-König, Po-Yu Chuang, netdev@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-aspeed@lists.ozlabs.org, taoren@meta.com
Hi Andrew,
Thank you for your reply.
> > This patch series adds support for configuring RGMII internal delays
> > for the Aspeed AST2600 FTGMAC100 Ethernet MACs.
>
> So i think you are doing things in the wrong order. You first need to sort out the
> mess of most, if not all, AST2600 have the wrong phy-mode, because the
> RGMII delay configuration is hidden, and set wrongly.
>
> Please fix that first.
>
The RGMII delay is configured in U-boot stage, and it is not changed when booting to
Linux. I want to know whether the first thing to correct here is whether the phy-mode
in aspeed-ast2600-evb.dts is rgmii-id. Our AST2600 EVB, there is no delay on board,
so, I need to change the phy-mode to "rgmii-id" to meet the RGMII usage first?
> Then consider how you can add fine tuning of the delays. Maybe that needs to
> wait for AST2700.
Currently, on AST2700, we use the "rgmii-id" in our SDK/git as per your suggestion.
And we will add the tx/rx-internal-delay-ps properties in the ftgmac100 driver to
support fine tuning of these delays.
Thanks,
Jacky
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: 回覆: [net-next v2 0/4] Add AST2600 RGMII delay into ftgmac100
2025-08-20 0:40 ` 回覆: " Jacky Chou
@ 2025-08-20 2:43 ` Andrew Lunn
2025-08-20 6:09 ` 回覆: " Jacky Chou
2025-08-26 1:41 ` Jacky Chou
0 siblings, 2 replies; 15+ messages in thread
From: Andrew Lunn @ 2025-08-20 2:43 UTC (permalink / raw)
To: Jacky Chou
Cc: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Joel Stanley, Andrew Jeffery, Simon Horman, Heiner Kallweit,
Uwe Kleine-König, Po-Yu Chuang, netdev@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-aspeed@lists.ozlabs.org, taoren@meta.com
On Wed, Aug 20, 2025 at 12:40:02AM +0000, Jacky Chou wrote:
> Hi Andrew,
>
> Thank you for your reply.
>
> > > This patch series adds support for configuring RGMII internal delays
> > > for the Aspeed AST2600 FTGMAC100 Ethernet MACs.
> >
> > So i think you are doing things in the wrong order. You first need to sort out the
> > mess of most, if not all, AST2600 have the wrong phy-mode, because the
> > RGMII delay configuration is hidden, and set wrongly.
> >
> > Please fix that first.
> >
>
> The RGMII delay is configured in U-boot stage, and it is not changed when booting to
> Linux. I want to know whether the first thing to correct here is whether the phy-mode
> in aspeed-ast2600-evb.dts is rgmii-id. Our AST2600 EVB, there is no delay on board,
> so, I need to change the phy-mode to "rgmii-id" to meet the RGMII usage first?
If there is no delay on the PCB, then phy-mode is "rgmii-id".
Andrew
^ permalink raw reply [flat|nested] 15+ messages in thread
* 回覆: 回覆: [net-next v2 0/4] Add AST2600 RGMII delay into ftgmac100
2025-08-20 2:43 ` Andrew Lunn
@ 2025-08-20 6:09 ` Jacky Chou
2025-08-26 1:41 ` Jacky Chou
1 sibling, 0 replies; 15+ messages in thread
From: Jacky Chou @ 2025-08-20 6:09 UTC (permalink / raw)
To: Andrew Lunn
Cc: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Joel Stanley, Andrew Jeffery, Simon Horman, Heiner Kallweit,
Uwe Kleine-König, Po-Yu Chuang, netdev@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-aspeed@lists.ozlabs.org, taoren@meta.com
> > > > This patch series adds support for configuring RGMII internal
> > > > delays for the Aspeed AST2600 FTGMAC100 Ethernet MACs.
> > >
> > > So i think you are doing things in the wrong order. You first need
> > > to sort out the mess of most, if not all, AST2600 have the wrong
> > > phy-mode, because the RGMII delay configuration is hidden, and set
> wrongly.
> > >
> > > Please fix that first.
> > >
> >
> > The RGMII delay is configured in U-boot stage, and it is not changed
> > when booting to Linux. I want to know whether the first thing to
> > correct here is whether the phy-mode in aspeed-ast2600-evb.dts is
> > rgmii-id. Our AST2600 EVB, there is no delay on board, so, I need to change
> > the phy-mode to "rgmii-id" to meet the RGMII usage first?
>
> If there is no delay on the PCB, then phy-mode is "rgmii-id".
>
I will submit a single patch to correct the phy-mode to "rgmii-id" in our EVB dts,
aspeed-ast2600-evb.dts.
Thanks,
Jacky
^ permalink raw reply [flat|nested] 15+ messages in thread
* [net-next v2 0/4] Add AST2600 RGMII delay into ftgmac100
2025-08-20 2:43 ` Andrew Lunn
2025-08-20 6:09 ` 回覆: " Jacky Chou
@ 2025-08-26 1:41 ` Jacky Chou
2025-08-26 3:17 ` Andrew Lunn
1 sibling, 1 reply; 15+ messages in thread
From: Jacky Chou @ 2025-08-26 1:41 UTC (permalink / raw)
To: Andrew Lunn
Cc: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Joel Stanley, Andrew Jeffery, Simon Horman, Heiner Kallweit,
Uwe Kleine-König, Po-Yu Chuang, netdev@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-aspeed@lists.ozlabs.org, taoren@meta.com
Hi Andrew,
> > > > This patch series adds support for configuring RGMII internal
> > > > delays for the Aspeed AST2600 FTGMAC100 Ethernet MACs.
> > >
> > > So i think you are doing things in the wrong order. You first need
> > > to sort out the mess of most, if not all, AST2600 have the wrong
> > > phy-mode, because the RGMII delay configuration is hidden, and set
> wrongly.
> > >
> > > Please fix that first.
> > >
> >
> > The RGMII delay is configured in U-boot stage, and it is not changed
> > when booting to Linux. I want to know whether the first thing to
> > correct here is whether the phy-mode in aspeed-ast2600-evb.dts is
> > rgmii-id. Our AST2600 EVB, there is no delay on board, so, I need to change
> the phy-mode to "rgmii-id" to meet the RGMII usage first?
>
> If there is no delay on the PCB, then phy-mode is "rgmii-id".
I would like to discuss with you how we fix the RGMII of AST2600 in this thread.
And thank you for your patience in reviewing our code.
Currently, the RGMII delay in AST2600 is configured in U-boot stage, not in Linux.
The ftgmac driver will not use the phy-mode to configure the RGMII delay on MAC side.
I list the parts that I think need to be modified.
1. Change the phy-mode to "rgmii-id" in aspeed-ast2600-evb.dts.
2. Add the tx/rx-internal-delay-ps in dts.
3. Add RGMII delay configuration in ftgmac driver. If the tx/rx-internal-delay-ps has not existed,
according to the phy-mode to configure default value.
These are the fix items I can think of.
Could you point out what I miss or a clear direction to correct the RGMII mode on AST2600?
Thanks,
Jacky
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [net-next v2 0/4] Add AST2600 RGMII delay into ftgmac100
2025-08-26 1:41 ` Jacky Chou
@ 2025-08-26 3:17 ` Andrew Lunn
0 siblings, 0 replies; 15+ messages in thread
From: Andrew Lunn @ 2025-08-26 3:17 UTC (permalink / raw)
To: Jacky Chou
Cc: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Joel Stanley, Andrew Jeffery, Simon Horman, Heiner Kallweit,
Uwe Kleine-König, Po-Yu Chuang, netdev@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-aspeed@lists.ozlabs.org, taoren@meta.com
> I would like to discuss with you how we fix the RGMII of AST2600 in this thread.
> And thank you for your patience in reviewing our code.
>
> Currently, the RGMII delay in AST2600 is configured in U-boot stage, not in Linux.
> The ftgmac driver will not use the phy-mode to configure the RGMII delay on MAC side.
>
> I list the parts that I think need to be modified.
> 1. Change the phy-mode to "rgmii-id" in aspeed-ast2600-evb.dts.
> 2. Add the tx/rx-internal-delay-ps in dts.
> 3. Add RGMII delay configuration in ftgmac driver. If the tx/rx-internal-delay-ps has not existed,
> according to the phy-mode to configure default value.
>
> These are the fix items I can think of.
> Could you point out what I miss or a clear direction to correct the RGMII mode on AST2600?
We have to be careful with the assumption u-boot is configuring
delays. I've seen DT blobs which use 'rgmii-id', which suggests
something is disabling the MAC delays, maybe because they are using a
different version of u-boot, or barebox etc.
You should be able to read what the MAC is doing with delays. You can
compare this with what the phy-mode is.
* If the MAC is adding delays, and the phy-mode is rgmii-id, disable
the MAC delays, pass rgmii-id to the PHY.
* If the MAC is adding delays, and the phy-mode is rgmii, issue a
warning the DT blob is out of date, disable the MAC delays, and pass
rgmii-id to the PHY.
* If the MAC is not adding delays, and the phy-mode is rgmii-id, pass
rmgii-id to the PHY.
* If the MAC is not adding delays, and the phy-mode is rgmii, that
suggests the PCB has extra long clock lines, and the board is using
a U-boot which has been modified to not enable MAC delays. Pass
rgmii to the PHY.
I would also suggest you review all DT blobs in mainline and see if
any are using rgmii-rxid or rgmii-txid. If not, i would go with KISS
and return -EINVAL for these, with a comment. Support for these can be
added when somebody actually needs them.
Most boards today will be the second bullet point. With time, they can
transition to the first. New boards should hopefully be directly the
first bullet point.
Backwards compatibility is however an issue. Anybody with a new DT
blob won't have working Ethernet with an old kernel if they are using
the first bullet point. So we should not edit every DT blob in
mainline and change rgmii to rgmii-id. We want to leave it to the
board owner to decide it is time to make the warning go away.
tx/rx-internal-delay-ps are optional. I would not add them yet,
because it makes the logic more complex. As far as i understand, no
board has required them so far, so there does not appear to be a need
for them.
You need good commit messages with these changes. Make it clear there
could be backwards compatibility issues, but that is the cost of
fixing up a broken implementation.
Andrew
^ permalink raw reply [flat|nested] 15+ messages in thread