Skip to contentSkip to conversation

net: stmmac: Add support for Allwinner A523 GMAC200

PATCH Superseded Chen-Yu Tsai 6 participants 20 messages Jul 1, 2025 – Jul 8, 2025

Subsystems (6)

v1 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Chen-Yu Tsai

author maintainer
#0 lore raw

cover net: stmmac: Add support for Allwinner A523 GMAC200

From: Chen-Yu Tsai <[email protected]>

Hi everyone,

This series adds support for the second Ethernet controller found on the Allwinner A523 SoC family. This controller, dubbed GMAC200, is a DWMAC4 core with an integration layer around it. The integration layer is similar to older Allwinner generations, but with an extra memory bus gate and separate power domain.

The series stacks on top of three other series inflight:

- Orangepi 4A series

    https://lore.kernel.org/all/[email protected]/
  - A523 power controller support series
    https://lore.kernel.org/all/[email protected]/
  - Rename emac0 to gmac0 for A523 series
    https://lore.kernel.org/all/[email protected]/

Patch 1 adds a new compatible string combo to the existing Allwinner EMAC binding.

Patch 2 adds a new driver for this core and integration combo.

Patch 3 extends the sunxi SRAM driver to allow access to the clock delay controls for the second Ethernet controller.

Patch 4 registers the special regmap for the clock delay controls as a syscon. This allows the new network driver to use the syscon interface, instead of the following dance which the existing dwmac-sun8i driver does:

    of_parse_phandle();
    of_find_device_by_node();
    dev_get_regmap();

With this change in place we can also drop the above from the dwmac-sun8i driver.

Patch 5 adds a device node and pinmux settings for the GMAC200.

Patches 6 and 8 add missing Ethernet PHY reset settings for the already enabled controller.

Patches 7, 9, and 10 enable the GMAC200 on three boards. I only have the Orangepi 4A, so I am asking for people to help test the two other boards. The RX/TX clock delay settings were taken from their respective BSPs, though those numbers don't always work, as is was the case for the Orangepi 4A.

Please have a look and help test.

Patches 1 and 2 should go through net-next, and I will take all the other patches through the sunxi tree.

Thanks
ChenYu

Chen-Yu Tsai (10):
dt-bindings: net: sun8i-emac: Add A523 GMAC200 compatible
net: stmmac: Add support for Allwinner A523 GMAC200
soc: sunxi: sram: add entry for a523
soc: sunxi: sram: register regmap as syscon
arm64: dts: allwinner: a523: Add GMAC200 ethernet controller
arm64: dts: allwinner: a527: cubie-a5e: Add ethernet PHY reset setting
arm64: dts: allwinner: a527: cubie-a5e: Enable second Ethernet port
arm64: dts: allwinner: t527: avaota-a1: Add ethernet PHY reset setting
arm64: dts: allwinner: t527: avaota-a1: enable second Ethernet port
arm64: dts: allwinner: t527: orangepi-4a: Enable Ethernet port

 .../net/allwinner,sun8i-a83t-emac.yaml        |  68 +++++++-
 .../arm64/boot/dts/allwinner/sun55i-a523.dtsi |  55 ++++++
 .../dts/allwinner/sun55i-a527-cubie-a5e.dts   |  29 +++-
 .../dts/allwinner/sun55i-t527-avaota-a1.dts   |  29 +++-
 .../dts/allwinner/sun55i-t527-orangepi-4a.dts |  23 +++
 drivers/net/ethernet/stmicro/stmmac/Kconfig   |  12 ++
 drivers/net/ethernet/stmicro/stmmac/Makefile  |   1 +
 .../ethernet/stmicro/stmmac/dwmac-sun55i.c    | 161 ++++++++++++++++++
 drivers/soc/sunxi/sunxi_sram.c                |  14 ++
 9 files changed, 386 insertions(+), 6 deletions(-)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c
Signature · 1 line
2.39.5
author maintainer
#1 lore raw

PATCH 1/10 dt-bindings: net: sun8i-emac: Add A523 GMAC200 compatible

From: Chen-Yu Tsai <[email protected]>

The Allwinner A523 SoC family has a second Ethernet controller, called the GMAC200 in the BSP and T527 datasheet, and referred to as GMAC1 for numbering. This controller, according to BSP sources, is fully compatible with a slightly newer version of the Synopsys DWMAC core. The glue layer around the controller is the same as found around older DWMAC cores on Allwinner SoCs. The only slight difference is that since this is the second controller on the SoC, the register for the clock delay controls is at a different offset. Last, the integration includes a dedicated clock gate for the memory bus and the whole thing is put in a separately controllable power domain.

Add a compatible string entry for it, and work in the requirements for a second clock and a power domain.

---
 .../net/allwinner,sun8i-a83t-emac.yaml        | 68 ++++++++++++++++++-
 1 file changed, 66 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/net/allwinner,sun8i-a83t-emac.yaml +66 -2
index 2ac709a4c472..1058e5af92ba 100644
@@ -26,6 +26,9 @@ properties:
               - allwinner,sun50i-h616-emac0
               - allwinner,sun55i-a523-gmac0
           - const: allwinner,sun50i-a64-emac
+      - items:
+          - const: allwinner,sun55i-a523-gmac200
+          - const: snps,dwmac-4.20a
 
   reg:
     maxItems: 1
@@ -37,14 +40,19 @@ properties:
     const: macirq
 
   clocks:
-    maxItems: 1
+    minItems: 1
+    maxItems: 2
 
   clock-names:
-    const: stmmaceth
+    minItems: 1
+    maxItems: 2
 
   phy-supply:
     description: PHY regulator
 
+  power-domains:
+    maxItems: 1
+
   syscon:
     $ref: /schemas/types.yaml#/definitions/phandle
     description:
@@ -75,6 +83,7 @@ allOf:
               - allwinner,sun8i-h3-emac
               - allwinner,sun8i-v3s-emac
               - allwinner,sun50i-a64-emac
+              - allwinner,sun55i-a523-gmac200
 
     then:
       properties:
@@ -191,6 +200,31 @@ allOf:
             - mdio-parent-bus
             - mdio@1
 
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: allwinner,sun55i-a523-gmac200
+    then:
+      properties:
+        clocks:
+          minItems: 2
+        clock-names:
+          items:
+            - const: stmmaceth
+            - const: mbus
+      required:
+        - power-domains
+    else:
+      properties:
+        clocks:
+          maxItems: 1
+        clock-names:
+          items:
+            - const: stmmaceth
+        power-domains: false
+
+
 unevaluatedProperties: false
 
 examples:
@@ -323,4 +357,34 @@ examples:
         };
     };
 
+  - |
+    ethernet@4510000 {
+        compatible = "allwinner,sun55i-a523-gmac200",
+                     "snps,dwmac-4.20a";
+        reg = <0x04510000 0x10000>;
+        clocks = <&ccu 117>, <&ccu 79>;
+        clock-names = "stmmaceth", "mbus";
+        resets = <&ccu 43>;
+        reset-names = "stmmaceth";
+        interrupts = <0 47 4>;
+        interrupt-names = "macirq";
+        pinctrl-names = "default";
+        pinctrl-0 = <&rgmii1_pins>;
+        power-domains = <&pck600 4>;
+        syscon = <&syscon>;
+        phy-handle = <&ext_rgmii_phy_1>;
+        phy-mode = "rgmii-id";
+        snps,fixed-burst;
+        snps,axi-config = <&gmac1_stmmac_axi_setup>;
+
+        mdio {
+            compatible = "snps,dwmac-mdio";
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            ext_rgmii_phy_1: ethernet-phy@1 {
+                reg = <1>;
+            };
+        };
+    };
 ...
Signature · 1 line
2.39.5
maintainer Reviewed-by on v1 1/10
#2 lore raw

Re: [PATCH RFT net-next 01/10] dt-bindings: net: sun8i-emac: Add A523 GMAC200 compatible

Quoted 13 lines · Chen-Yu Tsai

From: Chen-Yu Tsai <[email protected]>

The Allwinner A523 SoC family has a second Ethernet controller, called the GMAC200 in the BSP and T527 datasheet, and referred to as GMAC1 for numbering. This controller, according to BSP sources, is fully compatible with a slightly newer version of the Synopsys DWMAC core. The glue layer around the controller is the same as found around older DWMAC cores on Allwinner SoCs. The only slight difference is that since this is the second controller on the SoC, the register for the clock delay controls is at a different offset. Last, the integration includes a dedicated clock gate for the memory bus and the whole thing is put in a separately controllable power domain.

Quoted 8 lines

Add a compatible string entry for it, and work in the requirements for a second clock and a power domain.

---
 .../net/allwinner,sun8i-a83t-emac.yaml        | 68 ++++++++++++++++++-
 1 file changed, 66 insertions(+), 2 deletions(-)
author maintainer
#3 lore raw

PATCH 2/10 net: stmmac: Add support for Allwinner A523 GMAC200

In reply to Chen-Yu Tsai

From: Chen-Yu Tsai <[email protected]>

The Allwinner A523 SoC family has a second Ethernet controller, called the GMAC200 in the BSP and T527 datasheet, and referred to as GMAC1 for numbering. This controller, according to BSP sources, is fully compatible with a slightly newer version of the Synopsys DWMAC core. The glue layer around the controller is the same as found around older DWMAC cores on Allwinner SoCs. The only slight difference is that since this is the second controller on the SoC, the register for the clock delay controls is at a different offset. Last, the integration includes a dedicated clock gate for the memory bus and the whole thing is put in a separately controllable power domain.

Add a new driver for this hardware supporting the integration layer.

---
 drivers/net/ethernet/stmicro/stmmac/Kconfig   |  12 ++
 drivers/net/ethernet/stmicro/stmmac/Makefile  |   1 +
 .../ethernet/stmicro/stmmac/dwmac-sun55i.c    | 161 ++++++++++++++++++
 3 files changed, 174 insertions(+)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c
drivers/net/ethernet/stmicro/stmmac/Kconfig +12 -0
index 67fa879b1e52..38ce9a0cfb5b 100644
@@ -263,6 +263,18 @@ config DWMAC_SUN8I
 	  stmmac device driver. This driver is used for H3/A83T/A64
 	  EMAC ethernet controller.
 
+config DWMAC_SUN55I
+	tristate "Allwinner sun55i GMAC200 support"
+	default ARCH_SUNXI
+	depends on OF && (ARCH_SUNXI || COMPILE_TEST)
+	select MDIO_BUS_MUX
+	help
+	  Support for Allwinner A523/T527 GMAC200 ethernet controllers.
+
+	  This selects Allwinner SoC glue layer support for the
+	  stmmac device driver. This driver is used for A523/T527
+	  GMAC200 ethernet controller.
+
 config DWMAC_THEAD
 	tristate "T-HEAD dwmac support"
 	depends on OF && (ARCH_THEAD || COMPILE_TEST)
drivers/net/ethernet/stmicro/stmmac/Makefile +1 -0
index b591d93f8503..51e068e26ce4 100644
@@ -31,6 +31,7 @@ obj-$(CONFIG_DWMAC_STI)		+= dwmac-sti.o
 obj-$(CONFIG_DWMAC_STM32)	+= dwmac-stm32.o
 obj-$(CONFIG_DWMAC_SUNXI)	+= dwmac-sunxi.o
 obj-$(CONFIG_DWMAC_SUN8I)	+= dwmac-sun8i.o
+obj-$(CONFIG_DWMAC_SUN55I)	+= dwmac-sun55i.o
 obj-$(CONFIG_DWMAC_THEAD)	+= dwmac-thead.o
 obj-$(CONFIG_DWMAC_DWC_QOS_ETH)	+= dwmac-dwc-qos-eth.o
 obj-$(CONFIG_DWMAC_INTEL_PLAT)	+= dwmac-intel-plat.o
drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c new file +161 -0

161 lines not on this page · raw message

Signature · 1 line
2.39.5
#4 lore raw
Quoted 83 lines · Chen-Yu Tsai

From: Chen-Yu Tsai <[email protected]>

The Allwinner A523 SoC family has a second Ethernet controller, called the GMAC200 in the BSP and T527 datasheet, and referred to as GMAC1 for numbering. This controller, according to BSP sources, is fully compatible with a slightly newer version of the Synopsys DWMAC core. The glue layer around the controller is the same as found around older DWMAC cores on Allwinner SoCs. The only slight difference is that since this is the second controller on the SoC, the register for the clock delay controls is at a different offset. Last, the integration includes a dedicated clock gate for the memory bus and the whole thing is put in a separately controllable power domain.

Add a new driver for this hardware supporting the integration layer.

---
  drivers/net/ethernet/stmicro/stmmac/Kconfig   |  12 ++
  drivers/net/ethernet/stmicro/stmmac/Makefile  |   1 +
  .../ethernet/stmicro/stmmac/dwmac-sun55i.c    | 161 ++++++++++++++++++
  3 files changed, 174 insertions(+)

create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c

drivers/net/ethernet/stmicro/stmmac/Kconfig +12 -0
index 67fa879b1e52..38ce9a0cfb5b 100644
@@ -263,6 +263,18 @@ config DWMAC_SUN8I
  	  stmmac device driver. This driver is used for H3/A83T/A64
  	  EMAC ethernet controller.
 
+config DWMAC_SUN55I
+	tristate "Allwinner sun55i GMAC200 support"
+	default ARCH_SUNXI
+	depends on OF && (ARCH_SUNXI || COMPILE_TEST)
+	select MDIO_BUS_MUX
+	help
+	  Support for Allwinner A523/T527 GMAC200 ethernet controllers.
+
+	  This selects Allwinner SoC glue layer support for the
+	  stmmac device driver. This driver is used for A523/T527
+	  GMAC200 ethernet controller.
+
  config DWMAC_THEAD
  	tristate "T-HEAD dwmac support"
  	depends on OF && (ARCH_THEAD || COMPILE_TEST)
drivers/net/ethernet/stmicro/stmmac/Makefile +1 -0
index b591d93f8503..51e068e26ce4 100644
@@ -31,6 +31,7 @@ obj-$(CONFIG_DWMAC_STI)		+= dwmac-sti.o
  obj-$(CONFIG_DWMAC_STM32)	+= dwmac-stm32.o
  obj-$(CONFIG_DWMAC_SUNXI)	+= dwmac-sunxi.o
  obj-$(CONFIG_DWMAC_SUN8I)	+= dwmac-sun8i.o
+obj-$(CONFIG_DWMAC_SUN55I)	+= dwmac-sun55i.o
  obj-$(CONFIG_DWMAC_THEAD)	+= dwmac-thead.o
  obj-$(CONFIG_DWMAC_DWC_QOS_ETH)	+= dwmac-dwc-qos-eth.o
  obj-$(CONFIG_DWMAC_INTEL_PLAT)	+= dwmac-intel-plat.o
drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c new file +19 -0
new file mode 100644
index 000000000000..7fadb90e3098
@@ -0,0 +1,161 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * dwmac-sun55i.c - Allwinner sun55i GMAC200 specific glue layer
+ *
+ * Copyright (C) 2025 Chen-Yu Tsai <[email protected]>
+ *
+ * syscon parts taken from dwmac-sun8i.c, which is
+ *
+ * Copyright (C) 2017 Corentin Labbe <[email protected]>
+ */
+
+#include <linux/bitfield.h>
+#include <linux/bits.h>
+#include <linux/mfd/syscon.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/phy.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>

drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c line 29

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c new file +10 -0
+#include <linux/regulator/consumer.h>
+#include <linux/stmmac.h>
+
+#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) */

insert a blankline.

drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c line 32

Quoted 3 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c new file +3 -0
+/* Generic system control EMAC_CLK bits */
+#define SYSCON_ETXDC_MASK		GENMASK(12, 10)
+#define SYSCON_ERXDC_MASK		GENMASK(9, 5)

ditto.

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c new file +10 -0
+/* EMAC PHY Interface Type */
+#define SYSCON_EPIT			BIT(2) /* 1: RGMII, 0: MII */
+#define SYSCON_ETCS_MASK		GENMASK(1, 0)
+#define SYSCON_ETCS_MII		0x0
+#define SYSCON_ETCS_EXT_GMII	0x1
+#define SYSCON_ETCS_INT_GMII	0x2
+
+#define MASK_TO_VAL(mask)   ((mask) >> (__builtin_ffsll(mask) - 1))
+
+static int sun55i_gmac200_set_syscon(struct device *dev,

drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c line 52

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c new file +10 -0
+				     struct plat_stmmacenet_data *plat)
+{
+	struct device_node *node = dev->of_node;
+	struct regmap *regmap;
+	u32 val, reg = 0;
+
+	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");
+

-----------

Quoted 19 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c new file +19 -0
+	if (!of_property_read_u32(node, "allwinner,tx-delay-ps", &val)) {
+		if (val % 100) {
+			dev_err(dev, "tx-delay must be a multiple of 100\n");
+			return -EINVAL;
+		}
+		val /= 100;
+		dev_dbg(dev, "set tx-delay to %x\n", val);
+		if (val > MASK_TO_VAL(SYSCON_ETXDC_MASK))
+			return dev_err_probe(dev, -EINVAL,
+					     "Invalid TX clock delay: %d\n",
+					     val);
+
+		reg |= FIELD_PREP(SYSCON_ETXDC_MASK, val);
+	}
+
+	if (!of_property_read_u32(node, "allwinner,rx-delay-ps", &val)) {
+		if (val % 100) {
+			dev_err(dev, "rx-delay must be a multiple of 100\n");
+			return -EINVAL;

drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c line 81

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c new file +10 -0
+		}
+		val /= 100;
+		dev_dbg(dev, "set rx-delay to %x\n", val);
+		if (val > MASK_TO_VAL(SYSCON_ERXDC_MASK))
+			return dev_err_probe(dev, -EINVAL,
+					     "Invalid RX clock delay: %d\n",
+					     val);
+
+		reg |= FIELD_PREP(SYSCON_ERXDC_MASK, val);
+	}

------------
These two parts of the code are highly similar.
Can you construct a separate function?

drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c line 86

Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c new file +5 -0
+
+	switch (plat->mac_interface) {
 
+	case PHY_INTERFACE_MODE_MII:
+		/* default */
+		break;

This line of comment seems a bit abrupt here.

Thanks,
Yanteng

author maintainer
#5 lore raw
Quoted 88 lines · Yanteng Si
Quoted 86 lines · Chen-Yu Tsai

From: Chen-Yu Tsai <[email protected]>

The Allwinner A523 SoC family has a second Ethernet controller, called the GMAC200 in the BSP and T527 datasheet, and referred to as GMAC1 for numbering. This controller, according to BSP sources, is fully compatible with a slightly newer version of the Synopsys DWMAC core. The glue layer around the controller is the same as found around older DWMAC cores on Allwinner SoCs. The only slight difference is that since this is the second controller on the SoC, the register for the clock delay controls is at a different offset. Last, the integration includes a dedicated clock gate for the memory bus and the whole thing is put in a separately controllable power domain.

Add a new driver for this hardware supporting the integration layer.

---
  drivers/net/ethernet/stmicro/stmmac/Kconfig   |  12 ++
  drivers/net/ethernet/stmicro/stmmac/Makefile  |   1 +
  .../ethernet/stmicro/stmmac/dwmac-sun55i.c    | 161 ++++++++++++++++++
  3 files changed, 174 insertions(+)

create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c

drivers/net/ethernet/stmicro/stmmac/Kconfig +12 -0
index 67fa879b1e52..38ce9a0cfb5b 100644
@@ -263,6 +263,18 @@ config DWMAC_SUN8I
        stmmac device driver. This driver is used for H3/A83T/A64
        EMAC ethernet controller.
 
+config DWMAC_SUN55I
+     tristate "Allwinner sun55i GMAC200 support"
+     default ARCH_SUNXI
+     depends on OF && (ARCH_SUNXI || COMPILE_TEST)
+     select MDIO_BUS_MUX
+     help
+       Support for Allwinner A523/T527 GMAC200 ethernet controllers.
+
+       This selects Allwinner SoC glue layer support for the
+       stmmac device driver. This driver is used for A523/T527
+       GMAC200 ethernet controller.
+
  config DWMAC_THEAD
      tristate "T-HEAD dwmac support"
      depends on OF && (ARCH_THEAD || COMPILE_TEST)
drivers/net/ethernet/stmicro/stmmac/Makefile +1 -0
index b591d93f8503..51e068e26ce4 100644
@@ -31,6 +31,7 @@ obj-$(CONFIG_DWMAC_STI)             += dwmac-sti.o
  obj-$(CONFIG_DWMAC_STM32)   += dwmac-stm32.o
  obj-$(CONFIG_DWMAC_SUNXI)   += dwmac-sunxi.o
  obj-$(CONFIG_DWMAC_SUN8I)   += dwmac-sun8i.o
+obj-$(CONFIG_DWMAC_SUN55I)   += dwmac-sun55i.o
  obj-$(CONFIG_DWMAC_THEAD)   += dwmac-thead.o
  obj-$(CONFIG_DWMAC_DWC_QOS_ETH)     += dwmac-dwc-qos-eth.o
  obj-$(CONFIG_DWMAC_INTEL_PLAT)      += dwmac-intel-plat.o
drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c new file +22 -0
new file mode 100644
index 000000000000..7fadb90e3098
@@ -0,0 +1,161 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * dwmac-sun55i.c - Allwinner sun55i GMAC200 specific glue layer
+ *
+ * Copyright (C) 2025 Chen-Yu Tsai <[email protected]>
+ *
+ * syscon parts taken from dwmac-sun8i.c, which is
+ *
+ * Copyright (C) 2017 Corentin Labbe <[email protected]>
+ */
+
+#include <linux/bitfield.h>
+#include <linux/bits.h>
+#include <linux/mfd/syscon.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/phy.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
+#include <linux/stmmac.h>
+
Quoted 8 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c line 29

Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c new file +7 -0
+#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) */

insert a blankline.

OK.

Quoted 4 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c line 32

Quoted 3 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c new file +3 -0
+/* Generic system control EMAC_CLK bits */
+#define SYSCON_ETXDC_MASK            GENMASK(12, 10)
+#define SYSCON_ERXDC_MASK            GENMASK(9, 5)

ditto.

OK.

Quoted 45 lines
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c new file +10 -0
+/* EMAC PHY Interface Type */
+#define SYSCON_EPIT                  BIT(2) /* 1: RGMII, 0: MII */
+#define SYSCON_ETCS_MASK             GENMASK(1, 0)
+#define SYSCON_ETCS_MII              0x0
+#define SYSCON_ETCS_EXT_GMII 0x1
+#define SYSCON_ETCS_INT_GMII 0x2
+
+#define MASK_TO_VAL(mask)   ((mask) >> (__builtin_ffsll(mask) - 1))
+
+static int sun55i_gmac200_set_syscon(struct device *dev,

drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c line 52

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c new file +10 -0
+                                  struct plat_stmmacenet_data *plat)
+{
+     struct device_node *node = dev->of_node;
+     struct regmap *regmap;
+     u32 val, reg = 0;
+
+     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");
+

-----------

Quoted 24 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c new file +24 -0
+     if (!of_property_read_u32(node, "allwinner,tx-delay-ps", &val)) {
+             if (val % 100) {
+                     dev_err(dev, "tx-delay must be a multiple of 100\n");
+                     return -EINVAL;
+             }
+             val /= 100;
+             dev_dbg(dev, "set tx-delay to %x\n", val);
+             if (val > MASK_TO_VAL(SYSCON_ETXDC_MASK))
+                     return dev_err_probe(dev, -EINVAL,
+                                          "Invalid TX clock delay: %d\n",
+                                          val);
+
+             reg |= FIELD_PREP(SYSCON_ETXDC_MASK, val);
+     }
+
+     if (!of_property_read_u32(node, "allwinner,rx-delay-ps", &val)) {
+             if (val % 100) {
+                     dev_err(dev, "rx-delay must be a multiple of 100\n");
+                     return -EINVAL;
+             }
+             val /= 100;
+             dev_dbg(dev, "set rx-delay to %x\n", val);
+             if (val > MASK_TO_VAL(SYSCON_ERXDC_MASK))
+                     return dev_err_probe(dev, -EINVAL,
Quoted 8 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c line 81

Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c new file +5 -0
+                                          "Invalid RX clock delay: %d\n",
+                                          val);
+
+             reg |= FIELD_PREP(SYSCON_ERXDC_MASK, val);
+     }

------------
These two parts of the code are highly similar.
Can you construct a separate function?

As in, have a function that sets up either TX or RX delay based on a parameter? That also means constructing the property name on the fly or using ternary ops. And chopping up the log messages.

I don't think this makes it easier to read. And chopping up the log message makes it harder to grep.

Quoted 7 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c line 86

Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c new file +5 -0
+
+     switch (plat->mac_interface) {
 
+     case PHY_INTERFACE_MODE_MII:
+             /* default */
+             break;

This line of comment seems a bit abrupt here.

Default as in this is the 0 value register default.

OTOH the integration doesn't support MII, so I think I should drop this case.

Thanks
ChenYu

#6 lore raw
Quoted 53 lines · Chen-Yu Tsai
Quoted 45 lines
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c new file +10 -0
+/* EMAC PHY Interface Type */
+#define SYSCON_EPIT                  BIT(2) /* 1: RGMII, 0: MII */
+#define SYSCON_ETCS_MASK             GENMASK(1, 0)
+#define SYSCON_ETCS_MII              0x0
+#define SYSCON_ETCS_EXT_GMII 0x1
+#define SYSCON_ETCS_INT_GMII 0x2
+
+#define MASK_TO_VAL(mask)   ((mask) >> (__builtin_ffsll(mask) - 1))
+
+static int sun55i_gmac200_set_syscon(struct device *dev,

drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c line 52

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c new file +10 -0
+                                  struct plat_stmmacenet_data *plat)
+{
+     struct device_node *node = dev->of_node;
+     struct regmap *regmap;
+     u32 val, reg = 0;
+
+     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");
+

-----------

Quoted 24 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c new file +24 -0
+     if (!of_property_read_u32(node, "allwinner,tx-delay-ps", &val)) {
+             if (val % 100) {
+                     dev_err(dev, "tx-delay must be a multiple of 100\n");
+                     return -EINVAL;
+             }
+             val /= 100;
+             dev_dbg(dev, "set tx-delay to %x\n", val);
+             if (val > MASK_TO_VAL(SYSCON_ETXDC_MASK))
+                     return dev_err_probe(dev, -EINVAL,
+                                          "Invalid TX clock delay: %d\n",
+                                          val);
+
+             reg |= FIELD_PREP(SYSCON_ETXDC_MASK, val);
+     }
+
+     if (!of_property_read_u32(node, "allwinner,rx-delay-ps", &val)) {
+             if (val % 100) {
+                     dev_err(dev, "rx-delay must be a multiple of 100\n");
+                     return -EINVAL;
+             }
+             val /= 100;
+             dev_dbg(dev, "set rx-delay to %x\n", val);
+             if (val > MASK_TO_VAL(SYSCON_ERXDC_MASK))
+                     return dev_err_probe(dev, -EINVAL,
Quoted 8 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c line 81

Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c new file +5 -0
+                                          "Invalid RX clock delay: %d\n",
+                                          val);
+
+             reg |= FIELD_PREP(SYSCON_ERXDC_MASK, val);
+     }

------------
These two parts of the code are highly similar.
Can you construct a separate function?

Quoted 6 lines

As in, have a function that sets up either TX or RX delay based on a parameter? That also means constructing the property name on the fly or using ternary ops. And chopping up the log messages.

I don't think this makes it easier to read. And chopping up the log message makes it harder to grep.

I've looked through other driver codes, and it seems they are all written this way, so let's keep it as it is for now.

Thanks,
Yanteng

#7 lore raw
In reply to Chen-Yu Tsai

drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c line 53

Quoted 1 line
drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c new file +1 -0
+	if (!of_property_read_u32(node, "allwinner,tx-delay-ps", &val)) {

Please use the standard properties rx-internal-delay-ps and tx-internal-delay-ps.

Please also ensure that if the property is missing, the default is 0ps.

Andrew

author maintainer
#8 lore raw
Quoted 5 lines · Andrew Lunn
Quoted 2 lines

+ if (!of_property_read_u32(node, "allwinner,tx-delay-ps", &val)) {

Please use the standard properties rx-internal-delay-ps and tx-internal-delay-ps.

Since they share the same binding, I guess I either need to split the binding so that the new compatible uses the standard properties, or introduce them to the existing dwmac-sun8i driver as well?

Quoted 2 lines

Please also ensure that if the property is missing, the default is 0ps.

This is already implied in this driver with the initial register value being zero.

ChenYu

#9 lore raw
Quoted 10 lines · Chen-Yu Tsai
Quoted 5 lines · Andrew Lunn
Quoted 2 lines

+ if (!of_property_read_u32(node, "allwinner,tx-delay-ps", &val)) {

Please use the standard properties rx-internal-delay-ps and tx-internal-delay-ps.

Since they share the same binding, I guess I either need to split the binding so that the new compatible uses the standard properties, or introduce them to the existing dwmac-sun8i driver as well?

You should get them for free from ethernet-controller.yaml. But you might need to add a constraint that allwinner,tx-delay-ps etc is not valid for this device.

Andrew

author maintainer
#10 lore raw

PATCH 3/10 soc: sunxi: sram: add entry for a523

In reply to Chen-Yu Tsai

From: Chen-Yu Tsai <[email protected]>

The A523 has two Ethernet controllers. So in the system controller address space, there are two registers for Ethernet clock delays, one for each controller.

Add a new entry for the A523 system controller that allows access to the second register.

---
 drivers/soc/sunxi/sunxi_sram.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/soc/sunxi/sunxi_sram.c +8 -0
index 08e264ea0697..4f8d510b7e1e 100644
@@ -320,6 +320,10 @@ static const struct sunxi_sramc_variant sun50i_h616_sramc_variant = {
 	.has_ths_offset = true,
 };
 
+static const struct sunxi_sramc_variant sun55i_a523_sramc_variant = {
+	.num_emac_clocks = 2,
+};
+
 #define SUNXI_SRAM_THS_OFFSET_REG	0x0
 #define SUNXI_SRAM_EMAC_CLOCK_REG	0x30
 #define SUNXI_SYS_LDO_CTRL_REG		0x150
@@ -440,6 +444,10 @@ static const struct of_device_id sunxi_sram_dt_match[] = {
 		.compatible = "allwinner,sun50i-h616-system-control",
 		.data = &sun50i_h616_sramc_variant,
 	},
+	{
+		.compatible = "allwinner,sun55i-a523-system-control",
+		.data = &sun55i_a523_sramc_variant,
+	},
 	{ },
 };
 MODULE_DEVICE_TABLE(of, sunxi_sram_dt_match);
Signature · 1 line
2.39.5
author maintainer
#11 lore raw

PATCH 4/10 soc: sunxi: sram: register regmap as syscon

In reply to Chen-Yu Tsai

From: Chen-Yu Tsai <[email protected]>

Until now, if the system controller had a ethernet controller glue layer control register, a limited access regmap would be registered and tied to the system controller struct device for the ethernet driver to use.

---
 drivers/soc/sunxi/sunxi_sram.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/soc/sunxi/sunxi_sram.c +6 -0
index 4f8d510b7e1e..63c23bdffa78 100644
@@ -12,6 +12,7 @@
 
 #include <linux/debugfs.h>
 #include <linux/io.h>
+#include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
@@ -377,6 +378,7 @@ static int __init sunxi_sram_probe(struct platform_device *pdev)
 	const struct sunxi_sramc_variant *variant;
 	struct device *dev = &pdev->dev;
 	struct regmap *regmap;
+	int ret;
 
 	sram_dev = &pdev->dev;
 
@@ -394,6 +396,10 @@ static int __init sunxi_sram_probe(struct platform_device *pdev)
 		regmap = devm_regmap_init_mmio(dev, base, &sunxi_sram_regmap_config);
 		if (IS_ERR(regmap))
 			return PTR_ERR(regmap);
+
+		ret = of_syscon_register_regmap(dev->of_node, regmap);
+		if (IS_ERR(ret))
+			return ret;
 	}
 
 	of_platform_populate(dev->of_node, NULL, NULL, dev);
Signature · 1 line
2.39.5
#12 lore raw

Re: [PATCH RFT net-next 04/10] soc: sunxi: sram: register regmap as syscon

Quoted 33 lines · Chen-Yu Tsai

From: Chen-Yu Tsai <[email protected]>

Until now, if the system controller had a ethernet controller glue layer control register, a limited access regmap would be registered and tied to the system controller struct device for the ethernet driver to use.

---
 drivers/soc/sunxi/sunxi_sram.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/soc/sunxi/sunxi_sram.c +2 -0
index 4f8d510b7e1e..63c23bdffa78 100644
@@ -12,6 +12,7 @@
 
 #include <linux/debugfs.h>
 #include <linux/io.h>
+#include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
@@ -377,6 +378,7 @@ static int __init sunxi_sram_probe(struct platform_device *pdev)
        const struct sunxi_sramc_variant *variant;
        struct device *dev = &pdev->dev;
        struct regmap *regmap;
+       int ret;
 
        sram_dev = &pdev->dev;
 

drivers/soc/sunxi/sunxi_sram.c static int __init sunxi_sram_probe(struct platform_device *pdev) · line 401

Quoted 6 lines
drivers/soc/sunxi/sunxi_sram.c +3 -0
@@ -394,6 +396,10 @@ static int __init sunxi_sram_probe(struct platform_device *pdev)
                regmap = devm_regmap_init_mmio(dev, base, &sunxi_sram_regmap_config);
                if (IS_ERR(regmap))
                        return PTR_ERR(regmap);
+
+               ret = of_syscon_register_regmap(dev->of_node, regmap);
+               if (IS_ERR(ret))

BroderTuck on IRC pointed out that this gives a compiler warning. Indeed it is incorrect. It should test ret directly.

ChenYu

Quoted 8 lines
drivers/soc/sunxi/sunxi_sram.c +1 -1
+                       return ret;
        }
 
        of_platform_populate(dev->of_node, NULL, NULL, dev);
--

2.39.5

#13 lore raw

Re: [PATCH RFT net-next 04/10] soc: sunxi: sram: register regmap as syscon

Quoted 8 lines · On Wed, 2 Jul 2025 13:01:04 +0800 Chen-Yu Tsai <[email protected]> wrote:
Quoted 7 lines · Chen-Yu Tsai

From: Chen-Yu Tsai <[email protected]>

Until now, if the system controller had a ethernet controller glue layer control register, a limited access regmap would be registered and tied to the system controller struct device for the ethernet driver to use.

"Until now"?
Does that description (i.e. something that used to happen, but not after the patch) really match the change?

- snip -

Quoted 9 lines
Quoted 3 lines

+ ret = of_syscon_register_regmap(dev->of_node,
regmap);
+ if (IS_ERR(ret))

BroderTuck on IRC pointed out that this gives a compiler warning. Indeed it is incorrect. It should test ret directly.

ChenYu

Regards
Per Larsson, known as BroderTuck on #linux-sunxi

author maintainer
#14 lore raw

PATCH 5/10 arm64: dts: allwinner: a523: Add GMAC200 ethernet controller

In reply to Chen-Yu Tsai

From: Chen-Yu Tsai <[email protected]>

The A523 SoC family has a second ethernet controller, called the GMAC200. It is not exposed on all the SoCs in the family.

Add a device node for it. All the hardware specific settings are from the vendor BSP.

---
 .../arm64/boot/dts/allwinner/sun55i-a523.dtsi | 55 +++++++++++++++++++
 1 file changed, 55 insertions(+)
arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi +55 -0
index 65779754427d..5787ad72a918 100644
@@ -165,6 +165,16 @@ rgmii0_pins: rgmii0-pins {
 				bias-disable;
 			};
 
+			rgmii1_pins: rgmii1-pins {
+				pins = "PJ0", "PJ1", "PJ2", "PJ3", "PJ4",
+				       "PJ5", "PJ6", "PJ7", "PJ8", "PJ9",
+				       "PJ11", "PJ12", "PJ13", "PJ14", "PJ15";
+				allwinner,pinmux = <5>;
+				function = "gmac1";
+				drive-strength = <40>;
+				bias-disable;
+			};
+
 			uart0_pb_pins: uart0-pb-pins {
 				pins = "PB9", "PB10";
 				allwinner,pinmux = <2>;
@@ -619,6 +629,51 @@ mdio0: mdio {
 			};
 		};
 
+		gmac1: ethernet@4510000 {
+			compatible = "allwinner,sun55i-a523-gmac200",
+				     "snps,dwmac-4.20a";
+			reg = <0x04510000 0x10000>;
+			clocks = <&ccu CLK_BUS_EMAC1>, <&ccu CLK_MBUS_EMAC1>;
+			clock-names = "stmmaceth", "mbus";
+			resets = <&ccu RST_BUS_EMAC1>;
+			reset-names = "stmmaceth";
+			interrupts = <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "macirq";
+			pinctrl-names = "default";
+			pinctrl-0 = <&rgmii1_pins>;
+			power-domains = <&pck600 PD_VO1>;
+			syscon = <&syscon>;
+			snps,fixed-burst;
+			snps,axi-config = <&gmac1_stmmac_axi_setup>;
+			snps,mtl-rx-config = <&gmac1_mtl_rx_setup>;
+			snps,mtl-tx-config = <&gmac1_mtl_tx_setup>;
+			status = "disabled";
+
+			mdio1: mdio {
+				compatible = "snps,dwmac-mdio";
+				#address-cells = <1>;
+				#size-cells = <0>;
+			};
+
+			gmac1_mtl_rx_setup: rx-queues-config {
+				snps,rx-queues-to-use = <1>;
+
+				queue0 {};
+			};
+
+			gmac1_stmmac_axi_setup: stmmac-axi-config {
+				snps,wr_osr_lmt = <0xf>;
+				snps,rd_osr_lmt = <0xf>;
+				snps,blen = <256 128 64 32 16 8 4>;
+			};
+
+			gmac1_mtl_tx_setup: tx_queues-config {
+				snps,tx-queues-to-use = <1>;
+
+				queue0 {};
+			};
+		};
+
 		ppu: power-controller@7001400 {
 			compatible = "allwinner,sun55i-a523-ppu";
 			reg = <0x07001400 0x400>;
Signature · 1 line
2.39.5
author maintainer
#15 lore raw

PATCH 6/10 arm64: dts: allwinner: a527: cubie-a5e: Add ethernet PHY reset setting

In reply to Chen-Yu Tsai

From: Chen-Yu Tsai <[email protected]>

The external Ethernet PHY has a reset pin that is connected to the SoC. It is missing from the original submission.

Add it to complete the description.

Fixes acca163f3f51 ("arm64: dts: allwinner: a527: add EMAC0 to Radxa A5E board")
---
 arch/arm64/boot/dts/allwinner/sun55i-a527-cubie-a5e.dts | 3 +++
 1 file changed, 3 insertions(+)
arch/arm64/boot/dts/allwinner/sun55i-a527-cubie-a5e.dts +3 -0
index 8bc0f2c72a24..c57ecc420aed 100644
@@ -70,6 +70,9 @@ &mdio0 {
 	ext_rgmii_phy: ethernet-phy@1 {
 		compatible = "ethernet-phy-ieee802.3-c22";
 		reg = <1>;
+		reset-gpios = <&pio 7 8 GPIO_ACTIVE_LOW>; /* PH8 */
+		reset-assert-us = <10000>;
+		reset-deassert-us = <150000>;
 	};
 };
 
Signature · 1 line
2.39.5
author maintainer
#16 lore raw

PATCH 7/10 arm64: dts: allwinner: a527: cubie-a5e: Enable second Ethernet port

In reply to Chen-Yu Tsai

From: Chen-Yu Tsai <[email protected]>

On the Radxa Cubie A5E board, the second Ethernet controller, aka the GMAC200, is connected to a second external Maxio MAE0621A PHY. The PHY uses an external 25MHz crystal, and has the SoC's PJ16 pin connected to its reset pin.

Enable the second Ethernet port. Also fix up the label for the existing external PHY connected to the first Ethernet port.

---
 .../dts/allwinner/sun55i-a527-cubie-a5e.dts   | 26 +++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/allwinner/sun55i-a527-cubie-a5e.dts +24 -2
index c57ecc420aed..4b510a460123 100644
@@ -13,6 +13,7 @@ / {
 
 	aliases {
 		ethernet0 = &gmac0;
+		ethernet1 = &gmac1;
 		serial0 = &uart0;
 	};
 
@@ -57,7 +58,7 @@ &ehci1 {
 
 &gmac0 {
 	phy-mode = "rgmii-id";
-	phy-handle = <&ext_rgmii_phy>;
+	phy-handle = <&ext_rgmii0_phy>;
 	phy-supply = <&reg_cldo3>;
 
 	allwinner,tx-delay-ps = <300>;
@@ -66,8 +67,19 @@ &gmac0 {
 	status = "okay";
 };
 
+&gmac1 {
+	phy-mode = "rgmii-id";
+	phy-handle = <&ext_rgmii1_phy>;
+	phy-supply = <&reg_cldo4>;
+
+	allwinner,tx-delay-ps = <300>;
+	allwinner,rx-delay-ps = <400>;
+
+	status = "okay";
+};
+
 &mdio0 {
-	ext_rgmii_phy: ethernet-phy@1 {
+	ext_rgmii0_phy: ethernet-phy@1 {
 		compatible = "ethernet-phy-ieee802.3-c22";
 		reg = <1>;
 		reset-gpios = <&pio 7 8 GPIO_ACTIVE_LOW>; /* PH8 */
@@ -76,6 +88,16 @@ ext_rgmii_phy: ethernet-phy@1 {
 	};
 };
 
+&mdio1 {
+	ext_rgmii1_phy: ethernet-phy@1 {
+		compatible = "ethernet-phy-ieee802.3-c22";
+		reg = <1>;
+		reset-gpios = <&pio 9 16 GPIO_ACTIVE_LOW>; /* PJ16 */
+		reset-assert-us = <10000>;
+		reset-deassert-us = <150000>;
+	};
+};
+
 &mmc0 {
 	vmmc-supply = <&reg_cldo3>;
 	cd-gpios = <&pio 5 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; /* PF6 */
Signature · 1 line
2.39.5
author maintainer
#17 lore raw

PATCH 8/10 arm64: dts: allwinner: t527: avaota-a1: Add ethernet PHY reset setting

In reply to Chen-Yu Tsai

From: Chen-Yu Tsai <[email protected]>

The external Ethernet PHY has a reset pin that is connected to the SoC. It is missing from the original submission.

Add it to complete the description.

Fixes c6800f15998b ("arm64: dts: allwinner: t527: add EMAC0 to Avaota-A1 board")
---
 arch/arm64/boot/dts/allwinner/sun55i-t527-avaota-a1.dts | 3 +++
 1 file changed, 3 insertions(+)
arch/arm64/boot/dts/allwinner/sun55i-t527-avaota-a1.dts +3 -0
index 142177c1f737..9a2f29201d3c 100644
@@ -80,6 +80,9 @@ &mdio0 {
 	ext_rgmii_phy: ethernet-phy@1 {
 		compatible = "ethernet-phy-ieee802.3-c22";
 		reg = <1>;
+		reset-gpios = <&pio 7 8 GPIO_ACTIVE_LOW>; /* PH8 */
+		reset-assert-us = <10000>;
+		reset-deassert-us = <150000>;
 	};
 };
 
Signature · 1 line
2.39.5
author maintainer
#18 lore raw

PATCH 9/10 arm64: dts: allwinner: t527: avaota-a1: enable second Ethernet port

In reply to Chen-Yu Tsai

From: Chen-Yu Tsai <[email protected]>

On the Avaota A1 board, the second Ethernet controller, aka the GMAC200, is connected to a second external RTL8211F-CG PHY. The PHY uses an external 25MHz crystal, and has the SoC's PJ16 pin connected to its reset pin.

Enable the second Ethernet port. Also fix up the label for the existing external PHY connected to the first Ethernet port.

---
 .../dts/allwinner/sun55i-t527-avaota-a1.dts   | 26 +++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/allwinner/sun55i-t527-avaota-a1.dts +24 -2
index 9a2f29201d3c..62bc9a6b0292 100644
@@ -13,6 +13,7 @@ / {
 
 	aliases {
 		ethernet0 = &gmac0;
+		ethernet1 = &gmac1;
 		serial0 = &uart0;
 	};
 
@@ -67,7 +68,7 @@ &ehci1 {
 
 &gmac0 {
 	phy-mode = "rgmii-id";
-	phy-handle = <&ext_rgmii_phy>;
+	phy-handle = <&ext_rgmii0_phy>;
 	phy-supply = <&reg_dcdc4>;
 
 	allwinner,tx-delay-ps = <100>;
@@ -76,8 +77,19 @@ &gmac0 {
 	status = "okay";
 };
 
+&gmac1 {
+	phy-mode = "rgmii-id";
+	phy-handle = <&ext_rgmii1_phy>;
+	phy-supply = <&reg_dcdc4>;
+
+	allwinner,tx-delay-ps = <100>;
+	allwinner,rx-delay-ps = <100>;
+
+	status = "okay";
+};
+
 &mdio0 {
-	ext_rgmii_phy: ethernet-phy@1 {
+	ext_rgmii0_phy: ethernet-phy@1 {
 		compatible = "ethernet-phy-ieee802.3-c22";
 		reg = <1>;
 		reset-gpios = <&pio 7 8 GPIO_ACTIVE_LOW>; /* PH8 */
@@ -86,6 +98,16 @@ ext_rgmii_phy: ethernet-phy@1 {
 	};
 };
 
+&mdio1 {
+	ext_rgmii1_phy: ethernet-phy@1 {
+		compatible = "ethernet-phy-ieee802.3-c22";
+		reg = <1>;
+		reset-gpios = <&pio 9 16 GPIO_ACTIVE_LOW>; /* PJ16 */
+		reset-assert-us = <10000>;
+		reset-deassert-us = <150000>;
+	};
+};
+
 &mmc0 {
 	vmmc-supply = <&reg_cldo3>;
 	cd-gpios = <&pio 5 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; /* PF6 */
Signature · 1 line
2.39.5
author maintainer
#19 lore raw

PATCH 10/10 arm64: dts: allwinner: t527: orangepi-4a: Enable Ethernet port

In reply to Chen-Yu Tsai

From: Chen-Yu Tsai <[email protected]>

On the Orangepi 4A board, the second Ethernet controller, aka the GMAC200, is connected to an external Motorcomm YT8531 PHY. The PHY uses an external 25MHz crystal, has the SoC's PI15 pin connected to its reset pin, and the PI16 pin for its interrupt pin.

Enable it.

---
 .../dts/allwinner/sun55i-t527-orangepi-4a.dts | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
arch/arm64/boot/dts/allwinner/sun55i-t527-orangepi-4a.dts +23 -0
index 5f97505ec8f9..83bc359029ba 100644
@@ -15,6 +15,7 @@ / {
 	compatible = "xunlong,orangepi-4a", "allwinner,sun55i-t527";
 
 	aliases {
+		ethernet0 = &gmac1;
 		serial0 = &uart0;
 	};
 
@@ -95,6 +96,28 @@ &ehci1 {
 	status = "okay";
 };
 
+&gmac1 {
+	phy-mode = "rgmii-id";
+	phy-handle = <&ext_rgmii_phy>;
+	phy-supply = <&reg_cldo4>;
+
+	allwinner,tx-delay-ps = <0>;
+	allwinner,rx-delay-ps = <300>;
+
+	status = "okay";
+};
+
+&mdio1 {
+	ext_rgmii_phy: ethernet-phy@1 {
+		compatible = "ethernet-phy-ieee802.3-c22";
+		reg = <1>;
+		interrupts-extended = <&pio 8 16 IRQ_TYPE_LEVEL_LOW>; /* PI16 */
+		reset-gpios = <&pio 8 15 GPIO_ACTIVE_LOW>; /* PI15 */
+		reset-assert-us = <10000>;
+		reset-deassert-us = <150000>;
+	};
+};
+
 &mmc0 {
 	vmmc-supply = <&reg_cldo3>;
 	cd-gpios = <&pio 5 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; /* PF6 */
Signature · 1 line
2.39.5