* [PATCH 1/5] dt-bindings: net: allwinner,sun8i-a83t-emac: Add Allwinner A733 GMAC210
2026-11-25 13:06 [PATCH 0/5] net: stmmac: dwmac-sun55i: Add Allwinner A733 GMAC210 support Alastair D'Silva
@ 2026-11-25 13:06 ` Alastair D'Silva
2026-11-25 13:06 ` [PATCH 2/5] net: stmmac: dwmac-sun55i: Add per-compatible match data Alastair D'Silva
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Alastair D'Silva @ 2026-11-25 13:06 UTC (permalink / raw)
To: netdev, devicetree, linux-sunxi
Cc: linux-kernel, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
Maxime Chevallier, Maxime Ripard, Alastair D'Silva
The Allwinner A733 SoC integrates a Synopsys DWMAC 5.20 (GMAC210)
controller. Unlike earlier Allwinner SoCs that configure GMAC in a
shared syscon, A733 places the GMAC0 glue registers in a dedicated MMIO
region, so model them as a second reg entry rather than inventing a
syscon node. A733 also omits a power-domain wrapper, adds a second
reset, a PTP reference clock, multi-queue/LPI interrupts, and uses
5-bit MAC delay fields in 180 ps steps (0..5580 ps).
Document allwinner,sun60i-a733-gmac210 with snps,dwmac-5.20 fallback
and its schema constraints so A733 device trees validate cleanly.
Assisted-by: LLM
Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
---
.../net/allwinner,sun8i-a83t-emac.yaml | 136 ++++++++++++++++--
1 file changed, 126 insertions(+), 10 deletions(-)
diff --git a/Documentation/devicetree/bindings/net/allwinner,sun8i-a83t-emac.yaml b/Documentation/devicetree/bindings/net/allwinner,sun8i-a83t-emac.yaml
index 323a669fa982..94af58d369a7 100644
--- a/Documentation/devicetree/bindings/net/allwinner,sun8i-a83t-emac.yaml
+++ b/Documentation/devicetree/bindings/net/allwinner,sun8i-a83t-emac.yaml
@@ -22,6 +22,7 @@ select:
- allwinner,sun8i-v3s-emac
- allwinner,sun50i-a64-emac
- allwinner,sun55i-a523-gmac200
+ - allwinner,sun60i-a733-gmac210
required:
- compatible
@@ -44,25 +45,38 @@ properties:
- items:
- const: allwinner,sun55i-a523-gmac200
- const: snps,dwmac-4.20a
+ - items:
+ - const: allwinner,sun60i-a733-gmac210
+ - const: snps,dwmac-5.20
reg:
- maxItems: 1
+ minItems: 1
+ items:
+ - description: MAC controller registers
+ - description: Glue configuration registers
interrupts:
- maxItems: 1
+ minItems: 1
+ maxItems: 4
interrupt-names:
- const: macirq
+ minItems: 1
+ items:
+ - const: macirq
+ - const: eth_lpi
+ - const: tx-queue-0
+ - const: rx-queue-0
clocks:
minItems: 1
- maxItems: 2
+ maxItems: 3
clock-names:
minItems: 1
items:
- const: stmmaceth
- const: mbus
+ - const: ptp_ref
phy-supply:
description: PHY regulator
@@ -87,7 +101,6 @@ required:
- reset-names
- phy-handle
- phy-mode
- - syscon
allOf:
- $ref: snps,dwmac.yaml#
@@ -215,6 +228,36 @@ allOf:
- mdio-parent-bus
- mdio@1
+ - if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - allwinner,sun8i-a83t-emac
+ - allwinner,sun8i-h3-emac
+ - allwinner,sun8i-r40-gmac
+ - allwinner,sun8i-v3s-emac
+ - allwinner,sun50i-a64-emac
+ then:
+ properties:
+ reg:
+ maxItems: 1
+ interrupts:
+ maxItems: 1
+ interrupt-names:
+ maxItems: 1
+ clocks:
+ maxItems: 1
+ clock-names:
+ maxItems: 1
+ resets:
+ maxItems: 1
+ reset-names:
+ maxItems: 1
+ power-domains: false
+ required:
+ - syscon
+
- if:
properties:
compatible:
@@ -222,32 +265,76 @@ allOf:
const: allwinner,sun55i-a523-gmac200
then:
properties:
+ reg:
+ maxItems: 1
+ interrupts:
+ maxItems: 1
+ interrupt-names:
+ maxItems: 1
clocks:
minItems: 2
+ maxItems: 2
clock-names:
minItems: 2
+ maxItems: 2
+ resets:
+ maxItems: 1
+ reset-names:
+ maxItems: 1
tx-internal-delay-ps:
default: 0
minimum: 0
maximum: 700
multipleOf: 100
description:
- External RGMII PHY TX clock delay chain value in ps.
+ Internal RGMII MAC TX clock delay chain value in ps.
rx-internal-delay-ps:
default: 0
minimum: 0
maximum: 3100
multipleOf: 100
description:
- External RGMII PHY TX clock delay chain value in ps.
+ Internal RGMII MAC RX clock delay chain value in ps.
required:
- power-domains
- else:
+ - syscon
+
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: allwinner,sun60i-a733-gmac210
+ then:
properties:
+ reg:
+ minItems: 2
+ interrupts:
+ minItems: 4
+ interrupt-names:
+ minItems: 4
clocks:
- maxItems: 1
+ minItems: 3
clock-names:
- maxItems: 1
+ minItems: 3
+ resets:
+ minItems: 2
+ reset-names:
+ minItems: 2
+ tx-internal-delay-ps:
+ default: 0
+ minimum: 0
+ maximum: 5580
+ multipleOf: 180
+ description:
+ Internal RGMII MAC TX clock delay chain value in ps.
+ rx-internal-delay-ps:
+ default: 0
+ minimum: 0
+ maximum: 5580
+ multipleOf: 180
+ description:
+ Internal RGMII MAC RX clock delay chain value in ps.
+ syscon: false
power-domains: false
unevaluatedProperties: false
@@ -412,4 +499,33 @@ examples:
};
};
};
+
+ - |
+ ethernet@4500000 {
+ compatible = "allwinner,sun60i-a733-gmac210",
+ "snps,dwmac-5.20";
+ reg = <0x04500000 0x8000>,
+ <0x04508000 0x100>;
+ interrupts = <0 172 4>,
+ <0 178 4>,
+ <0 173 4>,
+ <0 174 4>;
+ interrupt-names = "macirq", "eth_lpi", "tx-queue-0", "rx-queue-0";
+ clocks = <&ccu 229>, <&ccu 92>, <&ccu 227>;
+ clock-names = "stmmaceth", "mbus", "ptp_ref";
+ resets = <&ccu 94>, <&ccu 93>;
+ reset-names = "stmmaceth", "ahb";
+ phy-handle = <&ext_rgmii_phy_a733>;
+ phy-mode = "rgmii-id";
+
+ mdio {
+ compatible = "snps,dwmac-mdio";
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ ext_rgmii_phy_a733: ethernet-phy@1 {
+ reg = <1>;
+ };
+ };
+ };
...
--
2.53.0
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 2/5] net: stmmac: dwmac-sun55i: Add per-compatible match data
2026-11-25 13:06 [PATCH 0/5] net: stmmac: dwmac-sun55i: Add Allwinner A733 GMAC210 support Alastair D'Silva
2026-11-25 13:06 ` [PATCH 1/5] dt-bindings: net: allwinner,sun8i-a83t-emac: Add Allwinner A733 GMAC210 Alastair D'Silva
@ 2026-11-25 13:06 ` Alastair D'Silva
2026-11-25 13:06 ` [PATCH 3/5] net: stmmac: dwmac-sun55i: Add Allwinner A733 GMAC210 support Alastair D'Silva
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Alastair D'Silva @ 2026-11-25 13:06 UTC (permalink / raw)
To: netdev, devicetree, linux-sunxi
Cc: linux-kernel, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
Maxime Chevallier, Maxime Ripard, Alastair D'Silva
dwmac-sun55i currently hardcodes A523 syscon lookups, glue register
offsets, 100 ps delay steps, and stmmac flags, and writes the glue
register only once during probe.
Introduce struct sun55i_gmac_data and struct sun55i_gmac, and move the
glue write into plat_dat->init so settings are restored on resume and
A733 GMAC210 support can be added without duplicating probe logic.
A523 behavior remains unchanged via sun55i_a523_gmac200_data.
Assisted-by: LLM
Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
---
.../ethernet/stmicro/stmmac/dwmac-sun55i.c | 136 +++++++++++++-----
1 file changed, 103 insertions(+), 33 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c
index 862df173d963..e872e241a220 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c
@@ -16,6 +16,7 @@
#include <linux/of.h>
#include <linux/phy.h>
#include <linux/platform_device.h>
+#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/stmmac.h>
@@ -23,8 +24,6 @@
#include "stmmac.h"
#include "stmmac_platform.h"
-#define SYSCON_REG 0x34
-
/* RMII specific bits */
#define SYSCON_RMII_EN BIT(13) /* 1: enable RMII (overrides EPIT) */
/* Generic system control EMAC_CLK bits */
@@ -37,42 +36,78 @@
#define SYSCON_ETCS_EXT_GMII 0x1
#define SYSCON_ETCS_INT_GMII 0x2
-static int sun55i_gmac200_set_syscon(struct device *dev,
- struct plat_stmmacenet_data *plat)
+struct sun55i_gmac;
+
+struct sun55i_gmac_data {
+ int (*init_resources)(struct platform_device *pdev,
+ struct sun55i_gmac *gmac);
+ unsigned int flags;
+ u32 txdly_step_ps;
+ u32 rxdly_step_ps;
+ u32 offset;
+};
+
+struct sun55i_gmac {
+ const struct sun55i_gmac_data *data;
+ struct regmap *regmap;
+ u32 syscon_val;
+};
+
+static int sun55i_gmac200_init_resources(struct platform_device *pdev,
+ struct sun55i_gmac *gmac)
+{
+ gmac->regmap = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
+ "syscon");
+ if (IS_ERR(gmac->regmap))
+ return dev_err_probe(&pdev->dev, PTR_ERR(gmac->regmap),
+ "Unable to map syscon\n");
+
+ return 0;
+}
+
+static int sun55i_gmac200_validate_delay(struct device *dev, const char *dir,
+ u32 *val, u32 step, u32 max)
+{
+ if (*val % step)
+ return dev_err_probe(dev, -EINVAL,
+ "%s-delay must be a multiple of %ups\n",
+ dir, step);
+ max *= step;
+ if (*val > max)
+ return dev_err_probe(dev, -EINVAL,
+ "%s clock delay exceeds maximum (%ups > %ups)\n",
+ dir, *val, max);
+ *val /= step;
+ dev_dbg(dev, "set %s-delay to %x\n", dir, *val);
+
+ return 0;
+}
+
+static int sun55i_gmac200_parse_config(struct device *dev,
+ struct plat_stmmacenet_data *plat,
+ struct sun55i_gmac *gmac)
{
+ const struct sun55i_gmac_data *data = gmac->data;
struct device_node *node = dev->of_node;
- struct regmap *regmap;
u32 val, reg = 0;
int ret;
- regmap = syscon_regmap_lookup_by_phandle(node, "syscon");
- if (IS_ERR(regmap))
- return dev_err_probe(dev, PTR_ERR(regmap), "Unable to map syscon\n");
-
if (!of_property_read_u32(node, "tx-internal-delay-ps", &val)) {
- if (val % 100)
- return dev_err_probe(dev, -EINVAL,
- "tx-delay must be a multiple of 100ps\n");
- val /= 100;
- dev_dbg(dev, "set tx-delay to %x\n", val);
- if (!FIELD_FIT(SYSCON_ETXDC_MASK, val))
- return dev_err_probe(dev, -EINVAL,
- "TX clock delay exceeds maximum (%u00ps > %lu00ps)\n",
- val, FIELD_MAX(SYSCON_ETXDC_MASK));
+ ret = sun55i_gmac200_validate_delay(dev, "tx", &val,
+ data->txdly_step_ps,
+ FIELD_MAX(SYSCON_ETXDC_MASK));
+ if (ret)
+ return ret;
reg |= FIELD_PREP(SYSCON_ETXDC_MASK, val);
}
if (!of_property_read_u32(node, "rx-internal-delay-ps", &val)) {
- if (val % 100)
- return dev_err_probe(dev, -EINVAL,
- "rx-delay must be a multiple of 100ps\n");
- val /= 100;
- dev_dbg(dev, "set rx-delay to %x\n", val);
- if (!FIELD_FIT(SYSCON_ERXDC_MASK, val))
- return dev_err_probe(dev, -EINVAL,
- "RX clock delay exceeds maximum (%u00ps > %lu00ps)\n",
- val, FIELD_MAX(SYSCON_ERXDC_MASK));
+ ret = sun55i_gmac200_validate_delay(dev, "rx", &val,
+ data->rxdly_step_ps,
+ FIELD_MAX(SYSCON_ERXDC_MASK));
+ if (ret)
+ return ret;
reg |= FIELD_PREP(SYSCON_ERXDC_MASK, val);
}
@@ -95,9 +130,20 @@ static int sun55i_gmac200_set_syscon(struct device *dev,
phy_modes(plat->phy_interface));
}
- ret = regmap_write(regmap, SYSCON_REG, reg);
+ gmac->syscon_val = reg;
+
+ return 0;
+}
+
+static int sun55i_gmac200_init(struct device *dev, void *priv)
+{
+ struct sun55i_gmac *gmac = priv;
+ int ret;
+
+ ret = regmap_write(gmac->regmap, gmac->data->offset, gmac->syscon_val);
if (ret < 0)
- return dev_err_probe(dev, ret, "Failed to write to syscon\n");
+ return dev_err_probe(dev, ret,
+ "Failed to write glue configuration\n");
return 0;
}
@@ -107,25 +153,40 @@ static int sun55i_gmac200_probe(struct platform_device *pdev)
struct plat_stmmacenet_data *plat_dat;
struct stmmac_resources stmmac_res;
struct device *dev = &pdev->dev;
+ struct sun55i_gmac *gmac;
struct clk *clk;
int ret;
+ gmac = devm_kzalloc(dev, sizeof(*gmac), GFP_KERNEL);
+ if (!gmac)
+ return -ENOMEM;
+
+ gmac->data = device_get_match_data(dev);
+ if (!gmac->data)
+ return -EINVAL;
+
ret = stmmac_get_platform_resources(pdev, &stmmac_res);
if (ret)
return ret;
+ ret = gmac->data->init_resources(pdev, gmac);
+ if (ret)
+ return ret;
+
plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
if (IS_ERR(plat_dat))
return PTR_ERR(plat_dat);
- /* BSP disables it */
- plat_dat->flags |= STMMAC_FLAG_SPH_DISABLE;
+ plat_dat->flags |= gmac->data->flags;
plat_dat->host_dma_width = 32;
- ret = sun55i_gmac200_set_syscon(dev, plat_dat);
+ ret = sun55i_gmac200_parse_config(dev, plat_dat, gmac);
if (ret)
return ret;
+ plat_dat->bsp_priv = gmac;
+ plat_dat->init = sun55i_gmac200_init;
+
clk = devm_clk_get_enabled(dev, "mbus");
if (IS_ERR(clk))
return dev_err_probe(dev, PTR_ERR(clk),
@@ -138,8 +199,17 @@ static int sun55i_gmac200_probe(struct platform_device *pdev)
return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
}
+static const struct sun55i_gmac_data sun55i_a523_gmac200_data = {
+ .init_resources = sun55i_gmac200_init_resources,
+ .flags = STMMAC_FLAG_SPH_DISABLE,
+ .offset = 0x34,
+ .txdly_step_ps = 100,
+ .rxdly_step_ps = 100,
+};
+
static const struct of_device_id sun55i_gmac200_match[] = {
- { .compatible = "allwinner,sun55i-a523-gmac200" },
+ { .compatible = "allwinner,sun55i-a523-gmac200",
+ .data = &sun55i_a523_gmac200_data },
{ }
};
MODULE_DEVICE_TABLE(of, sun55i_gmac200_match);
--
2.53.0
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 3/5] net: stmmac: dwmac-sun55i: Add Allwinner A733 GMAC210 support
2026-11-25 13:06 [PATCH 0/5] net: stmmac: dwmac-sun55i: Add Allwinner A733 GMAC210 support Alastair D'Silva
2026-11-25 13:06 ` [PATCH 1/5] dt-bindings: net: allwinner,sun8i-a83t-emac: Add Allwinner A733 GMAC210 Alastair D'Silva
2026-11-25 13:06 ` [PATCH 2/5] net: stmmac: dwmac-sun55i: Add per-compatible match data Alastair D'Silva
@ 2026-11-25 13:06 ` Alastair D'Silva
2026-11-25 17:25 ` Andrew Lunn
2026-11-25 13:06 ` [PATCH 4/5] arm64: dts: allwinner: sun60i-a733: Add GMAC0 node Alastair D'Silva
2026-11-25 13:06 ` [PATCH 5/5] arm64: dts: allwinner: sun60i-a733-orangepi-4-pro: Enable GMAC0 Ethernet Alastair D'Silva
4 siblings, 1 reply; 8+ messages in thread
From: Alastair D'Silva @ 2026-11-25 13:06 UTC (permalink / raw)
To: netdev, devicetree, linux-sunxi
Cc: linux-kernel, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
Maxime Chevallier, Maxime Ripard, Alastair D'Silva
The Allwinner A733 GMAC210 controller differs from A523 GMAC200 and
requires SoC-specific glue handling:
- Glue registers reside inside the AHB reset domain, and stmmac calls
plat_dat->init() before deasserting stmmac_ahb_rst, so dwmac-sun55i
deasserts stmmac_ahb_rst prior to devm_stmmac_pltfr_probe() (with a
devm action to re-assert on error or unbind).
- An active-low clock gate at glue offset 0x80 (BIT(0)) must be cleared
in init() and set in exit().
- Hardware splits the 5-bit RGMII TX delay across [17:16] and [12:10]
in 180 ps steps, and uses external GMII TX clocking
(SYSCON_ETCS_EXT_GMII) for RGMII rather than internal GMII.
- Enable STMMAC_FLAG_SPH_DISABLE, STMMAC_FLAG_MULTI_MSI_EN for the
per-queue TX/RX interrupts, and STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP.
Add sun60i_a733_gmac210_data and its glue handling to dwmac-sun55i.
Assisted-by: LLM
Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
---
.../ethernet/stmicro/stmmac/dwmac-sun55i.c | 98 ++++++++++++++++++-
1 file changed, 93 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c
index e872e241a220..c7117802abb8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c
@@ -19,11 +19,15 @@
#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
+#include <linux/reset.h>
#include <linux/stmmac.h>
#include "stmmac.h"
#include "stmmac_platform.h"
+#define SYSCON_GMAC210_CLK_GATE 0x80
+#define SYSCON_GMAC210_CLK_GATE_DIS BIT(0)
+
/* RMII specific bits */
#define SYSCON_RMII_EN BIT(13) /* 1: enable RMII (overrides EPIT) */
/* Generic system control EMAC_CLK bits */
@@ -42,9 +46,12 @@ struct sun55i_gmac_data {
int (*init_resources)(struct platform_device *pdev,
struct sun55i_gmac *gmac);
unsigned int flags;
+ u32 etxdc_ext_mask;
u32 txdly_step_ps;
u32 rxdly_step_ps;
u32 offset;
+ u32 etcs_rgmii;
+ bool has_clk_gate;
};
struct sun55i_gmac {
@@ -65,6 +72,31 @@ static int sun55i_gmac200_init_resources(struct platform_device *pdev,
return 0;
}
+static const struct regmap_config sun60i_a733_regmap_cfg = {
+ .reg_bits = 32,
+ .val_bits = 32,
+ .reg_stride = 4,
+};
+
+static int sun60i_gmac210_init_resources(struct platform_device *pdev,
+ struct sun55i_gmac *gmac)
+{
+ struct device *dev = &pdev->dev;
+ void __iomem *base;
+
+ base = devm_platform_ioremap_resource(pdev, 1);
+ if (IS_ERR(base))
+ return dev_err_probe(dev, PTR_ERR(base),
+ "Unable to get glue memory region\n");
+
+ gmac->regmap = devm_regmap_init_mmio(dev, base, &sun60i_a733_regmap_cfg);
+ if (IS_ERR(gmac->regmap))
+ return dev_err_probe(dev, PTR_ERR(gmac->regmap),
+ "Unable to init regmap for glue region\n");
+
+ return 0;
+}
+
static int sun55i_gmac200_validate_delay(struct device *dev, const char *dir,
u32 *val, u32 step, u32 max)
{
@@ -93,13 +125,18 @@ static int sun55i_gmac200_parse_config(struct device *dev,
int ret;
if (!of_property_read_u32(node, "tx-internal-delay-ps", &val)) {
+ u32 low_bits = hweight32(SYSCON_ETXDC_MASK);
+ u32 max = (1U << (low_bits + hweight32(data->etxdc_ext_mask))) - 1;
+
ret = sun55i_gmac200_validate_delay(dev, "tx", &val,
- data->txdly_step_ps,
- FIELD_MAX(SYSCON_ETXDC_MASK));
+ data->txdly_step_ps, max);
if (ret)
return ret;
- reg |= FIELD_PREP(SYSCON_ETXDC_MASK, val);
+ reg |= FIELD_PREP(SYSCON_ETXDC_MASK,
+ val & FIELD_MAX(SYSCON_ETXDC_MASK));
+ if (data->etxdc_ext_mask)
+ reg |= field_prep(data->etxdc_ext_mask, val >> low_bits);
}
if (!of_property_read_u32(node, "rx-internal-delay-ps", &val)) {
@@ -117,10 +154,10 @@ static int sun55i_gmac200_parse_config(struct device *dev,
/* default */
break;
case PHY_INTERFACE_MODE_RGMII:
+ case PHY_INTERFACE_MODE_RGMII_TXID:
case PHY_INTERFACE_MODE_RGMII_ID:
case PHY_INTERFACE_MODE_RGMII_RXID:
- case PHY_INTERFACE_MODE_RGMII_TXID:
- reg |= SYSCON_EPIT | SYSCON_ETCS_INT_GMII;
+ reg |= SYSCON_EPIT | data->etcs_rgmii;
break;
case PHY_INTERFACE_MODE_RMII:
reg |= SYSCON_RMII_EN;
@@ -145,9 +182,31 @@ static int sun55i_gmac200_init(struct device *dev, void *priv)
return dev_err_probe(dev, ret,
"Failed to write glue configuration\n");
+ if (gmac->data->has_clk_gate) {
+ ret = regmap_clear_bits(gmac->regmap, SYSCON_GMAC210_CLK_GATE,
+ SYSCON_GMAC210_CLK_GATE_DIS);
+ if (ret < 0)
+ return dev_err_probe(dev, ret,
+ "Failed to enable GMAC clock gate\n");
+ }
+
return 0;
}
+static void sun55i_gmac200_exit(struct device *dev, void *priv)
+{
+ struct sun55i_gmac *gmac = priv;
+
+ if (gmac->data->has_clk_gate)
+ regmap_set_bits(gmac->regmap, SYSCON_GMAC210_CLK_GATE,
+ SYSCON_GMAC210_CLK_GATE_DIS);
+}
+
+static void sun55i_gmac_reset_assert(void *data)
+{
+ reset_control_assert(data);
+}
+
static int sun55i_gmac200_probe(struct platform_device *pdev)
{
struct plat_stmmacenet_data *plat_dat;
@@ -184,8 +243,21 @@ static int sun55i_gmac200_probe(struct platform_device *pdev)
if (ret)
return ret;
+ if (gmac->data->has_clk_gate && plat_dat->stmmac_ahb_rst) {
+ ret = reset_control_deassert(plat_dat->stmmac_ahb_rst);
+ if (ret)
+ return dev_err_probe(dev, ret,
+ "Failed to deassert ahb reset\n");
+
+ ret = devm_add_action_or_reset(dev, sun55i_gmac_reset_assert,
+ plat_dat->stmmac_ahb_rst);
+ if (ret)
+ return ret;
+ }
+
plat_dat->bsp_priv = gmac;
plat_dat->init = sun55i_gmac200_init;
+ plat_dat->exit = sun55i_gmac200_exit;
clk = devm_clk_get_enabled(dev, "mbus");
if (IS_ERR(clk))
@@ -205,11 +277,27 @@ static const struct sun55i_gmac_data sun55i_a523_gmac200_data = {
.offset = 0x34,
.txdly_step_ps = 100,
.rxdly_step_ps = 100,
+ .etcs_rgmii = SYSCON_ETCS_INT_GMII,
+};
+
+static const struct sun55i_gmac_data sun60i_a733_gmac210_data = {
+ .init_resources = sun60i_gmac210_init_resources,
+ .flags = STMMAC_FLAG_SPH_DISABLE |
+ STMMAC_FLAG_MULTI_MSI_EN |
+ STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP,
+ .offset = 0x0,
+ .etxdc_ext_mask = GENMASK(17, 16),
+ .txdly_step_ps = 180,
+ .rxdly_step_ps = 180,
+ .etcs_rgmii = SYSCON_ETCS_EXT_GMII,
+ .has_clk_gate = true,
};
static const struct of_device_id sun55i_gmac200_match[] = {
{ .compatible = "allwinner,sun55i-a523-gmac200",
.data = &sun55i_a523_gmac200_data },
+ { .compatible = "allwinner,sun60i-a733-gmac210",
+ .data = &sun60i_a733_gmac210_data },
{ }
};
MODULE_DEVICE_TABLE(of, sun55i_gmac200_match);
--
2.53.0
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH 3/5] net: stmmac: dwmac-sun55i: Add Allwinner A733 GMAC210 support
2026-11-25 13:06 ` [PATCH 3/5] net: stmmac: dwmac-sun55i: Add Allwinner A733 GMAC210 support Alastair D'Silva
@ 2026-11-25 17:25 ` Andrew Lunn
0 siblings, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2026-11-25 17:25 UTC (permalink / raw)
To: Alastair D'Silva
Cc: netdev, devicetree, linux-sunxi, linux-kernel, Andrew Lunn,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen-Yu Tsai,
Jernej Skrabec, Samuel Holland, Maxime Chevallier, Maxime Ripard
> @@ -117,10 +154,10 @@ static int sun55i_gmac200_parse_config(struct device *dev,
> /* default */
> break;
> case PHY_INTERFACE_MODE_RGMII:
> + case PHY_INTERFACE_MODE_RGMII_TXID:
> case PHY_INTERFACE_MODE_RGMII_ID:
> case PHY_INTERFACE_MODE_RGMII_RXID:
> - case PHY_INTERFACE_MODE_RGMII_TXID:
nitpick: No need to change the order.
Andrew
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 4/5] arm64: dts: allwinner: sun60i-a733: Add GMAC0 node
2026-11-25 13:06 [PATCH 0/5] net: stmmac: dwmac-sun55i: Add Allwinner A733 GMAC210 support Alastair D'Silva
` (2 preceding siblings ...)
2026-11-25 13:06 ` [PATCH 3/5] net: stmmac: dwmac-sun55i: Add Allwinner A733 GMAC210 support Alastair D'Silva
@ 2026-11-25 13:06 ` Alastair D'Silva
2026-11-25 13:06 ` [PATCH 5/5] arm64: dts: allwinner: sun60i-a733-orangepi-4-pro: Enable GMAC0 Ethernet Alastair D'Silva
4 siblings, 0 replies; 8+ messages in thread
From: Alastair D'Silva @ 2026-11-25 13:06 UTC (permalink / raw)
To: netdev, devicetree, linux-sunxi
Cc: linux-kernel, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
Maxime Chevallier, Maxime Ripard, Alastair D'Silva
Boards using the Allwinner A733 SoC need the SoC-level GMAC0 controller,
MDIO bus, and PH0-PH15 RGMII pinmux nodes to enable wired Ethernet.
Disable internal bias pulls and use drive-strength = <20> on
gmac0_rgmii_pins to avoid distorting 125 MHz RGMII signaling.
Add gmac0, mdio0, and gmac0_rgmii_pins (disabled by default) to
sun60i-a733.dtsi.
Assisted-by: LLM
Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
---
.../arm64/boot/dts/allwinner/sun60i-a733.dtsi | 41 +++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/arch/arm64/boot/dts/allwinner/sun60i-a733.dtsi b/arch/arm64/boot/dts/allwinner/sun60i-a733.dtsi
index f4fff495e234..d9f90d8de0de 100644
--- a/arch/arm64/boot/dts/allwinner/sun60i-a733.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun60i-a733.dtsi
@@ -164,6 +164,18 @@ mmc2_pins: mmc2-pins {
drive-strength = <30>;
bias-pull-up;
};
+
+ /omit-if-no-ref/
+ gmac0_rgmii_pins: gmac0-rgmii-pins {
+ pins = "PH0", "PH1", "PH2", "PH3",
+ "PH4", "PH5", "PH6", "PH7",
+ "PH8", "PH9", "PH10", "PH11",
+ "PH12", "PH13", "PH14", "PH15";
+ function = "gmac0";
+ allwinner,pinmux = <5>;
+ drive-strength = <20>;
+ bias-disable;
+ };
};
ccu: clock-controller@2002000 {
@@ -241,6 +253,35 @@ mmc2: mmc@4022000 {
status = "disabled";
};
+ gmac0: ethernet@4500000 {
+ compatible = "allwinner,sun60i-a733-gmac210",
+ "snps,dwmac-5.20";
+ reg = <0x04500000 0x8000>,
+ <0x04508000 0x100>;
+ interrupts = <GIC_SPI 172 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 178 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 173 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 174 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "macirq", "eth_lpi",
+ "tx-queue-0", "rx-queue-0";
+ clocks = <&ccu CLK_BUS_GMAC0>,
+ <&ccu CLK_MBUS_GMAC0>,
+ <&ccu CLK_GMAC_PTP>;
+ clock-names = "stmmaceth", "mbus", "ptp_ref";
+ resets = <&ccu RST_BUS_GMAC0_AXI>,
+ <&ccu RST_BUS_GMAC0>;
+ reset-names = "stmmaceth", "ahb";
+ pinctrl-names = "default";
+ pinctrl-0 = <&gmac0_rgmii_pins>;
+ status = "disabled";
+
+ mdio0: mdio {
+ compatible = "snps,dwmac-mdio";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ };
+ };
+
r_ccu: clock-controller@7010000 {
compatible = "allwinner,sun60i-a733-r-ccu";
reg = <0x07010000 0x1000>;
--
2.53.0
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 5/5] arm64: dts: allwinner: sun60i-a733-orangepi-4-pro: Enable GMAC0 Ethernet
2026-11-25 13:06 [PATCH 0/5] net: stmmac: dwmac-sun55i: Add Allwinner A733 GMAC210 support Alastair D'Silva
` (3 preceding siblings ...)
2026-11-25 13:06 ` [PATCH 4/5] arm64: dts: allwinner: sun60i-a733: Add GMAC0 node Alastair D'Silva
@ 2026-11-25 13:06 ` Alastair D'Silva
2026-11-25 17:30 ` Andrew Lunn
4 siblings, 1 reply; 8+ messages in thread
From: Alastair D'Silva @ 2026-11-25 13:06 UTC (permalink / raw)
To: netdev, devicetree, linux-sunxi
Cc: linux-kernel, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
Maxime Chevallier, Maxime Ripard, Alastair D'Silva
The Orange Pi 4 Pro connects A733 GMAC0 to a Motorcomm YT8531 Gigabit
PHY over RGMII without PCB trace delays. Use phy-mode = "rgmii" rather
than "rgmii-id" so PHY-side delays stay disabled and the MAC applies the
calibrated TX (2160 ps) and RX (3780 ps) delays directly. Because
mainline motorcomm.c disables CLK_OUT unless requested, specify
motorcomm,clk-out-frequency-hz = <125000000> to provide the external
GMII TX clock while CLK_GMAC0_PHY supplies the 25 MHz PHY reference.
Enable GMAC0 with its reset GPIO and 3.3V reg_swout1/reg_swout2
supplies.
Assisted-by: LLM
Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
---
.../allwinner/sun60i-a733-orangepi-4-pro.dts | 28 +++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/arch/arm64/boot/dts/allwinner/sun60i-a733-orangepi-4-pro.dts b/arch/arm64/boot/dts/allwinner/sun60i-a733-orangepi-4-pro.dts
index df70967264ed..26f97318b842 100644
--- a/arch/arm64/boot/dts/allwinner/sun60i-a733-orangepi-4-pro.dts
+++ b/arch/arm64/boot/dts/allwinner/sun60i-a733-orangepi-4-pro.dts
@@ -14,6 +14,7 @@ / {
compatible = "xunlong,orangepi-4-pro", "allwinner,sun60i-a733";
aliases {
+ ethernet0 = &gmac0;
serial0 = &uart0;
};
@@ -27,6 +28,29 @@ memory@40000000 {
};
};
+&gmac0 {
+ assigned-clocks = <&ccu CLK_GMAC0_PHY>;
+ assigned-clock-rates = <25000000>;
+ phy-mode = "rgmii"; /* MAC applies TX and RX delays */
+ phy-handle = <&ext_rgmii_phy>;
+ phy-supply = <®_swout1>;
+ tx-internal-delay-ps = <2160>;
+ rx-internal-delay-ps = <3780>;
+ status = "okay";
+};
+
+&mdio0 {
+ ext_rgmii_phy: ethernet-phy@1 {
+ compatible = "ethernet-phy-ieee802.3-c22";
+ reg = <1>;
+ clocks = <&ccu CLK_GMAC0_PHY>;
+ motorcomm,clk-out-frequency-hz = <125000000>;
+ reset-gpios = <&pio 7 16 GPIO_ACTIVE_LOW>; /* PH16 */
+ reset-assert-us = <10000>;
+ reset-deassert-us = <150000>;
+ };
+};
+
&mmc0 {
vmmc-supply = <®_dldo1>;
cd-gpios = <&pio 5 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; /* PF6 */
@@ -34,6 +58,10 @@ &mmc0 {
status = "okay";
};
+&pio {
+ vcc-ph-supply = <®_swout2>;
+};
+
&r_i2c0 {
pinctrl-names = "default";
pinctrl-0 = <&r_i2c0_pins>;
--
2.53.0
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH 5/5] arm64: dts: allwinner: sun60i-a733-orangepi-4-pro: Enable GMAC0 Ethernet
2026-11-25 13:06 ` [PATCH 5/5] arm64: dts: allwinner: sun60i-a733-orangepi-4-pro: Enable GMAC0 Ethernet Alastair D'Silva
@ 2026-11-25 17:30 ` Andrew Lunn
0 siblings, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2026-11-25 17:30 UTC (permalink / raw)
To: Alastair D'Silva
Cc: netdev, devicetree, linux-sunxi, linux-kernel, Andrew Lunn,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen-Yu Tsai,
Jernej Skrabec, Samuel Holland, Maxime Chevallier, Maxime Ripard
On Thu, Nov 26, 2026 at 12:06:13AM +1100, Alastair D'Silva wrote:
> The Orange Pi 4 Pro connects A733 GMAC0 to a Motorcomm YT8531 Gigabit
> PHY over RGMII without PCB trace delays. Use phy-mode = "rgmii" rather
> than "rgmii-id" so PHY-side delays stay disabled and the MAC applies the
> calibrated TX (2160 ps) and RX (3780 ps) delays directly.
https://elixir.bootlin.com/linux/v6.15/source/Documentation/devicetree/bindings/net/ethernet-controller.yaml#L287
phy-mode describes the PCB. If the PCB has no delays, rgmii-id should
be used.
The MAC/PHY pair need to decide which of the two add the delays. This
is not decided by phy-mode.
3780 ps is also huge, much greater than the 2ns required by the
standard. It suggests something else is going on, maybe a clock is
inverted? Please investigate.
Andrew
^ permalink raw reply [flat|nested] 8+ messages in thread