* [PATCH net-next v2 0/2] net: stmmac: Add support for Allwinner A733 GMAC210
@ 2026-09-10 10:25 Jerome Brunet
2026-09-10 10:25 ` [PATCH net-next v2 1/2] dt-bindings: net: sun8i-emac: Add A733 GMAC210 compatible Jerome Brunet
2026-09-10 10:25 ` [PATCH net-next v2 2/2] net: stmmac: Add support for Allwinner A733 GMAC210 Jerome Brunet
0 siblings, 2 replies; 6+ messages in thread
From: Jerome Brunet @ 2026-09-10 10:25 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, Richard Cochran,
Maxime Ripard, Maxime Coquelin, Alexandre Torgue, Philipp Zabel,
Maxime Chevallier
Cc: netdev, devicetree, linux-arm-kernel, linux-sunxi, linux-kernel,
linux-stm32, Andre Przywara, Jerome Brunet
The A733 GMAC210 is a DesignWare MAC 5.20 with an Allwinner glue close to
the A523 GMAC200 already supported by dwmac-sun55i, but with a few
significant differences:
* The glue configuration registers are a dedicated MMIO region of the
controller instead of a syscon register.
* That region is inside the controller reset domain, so the reset must be
released before the configuration is written, and must not be asserted
again afterwards or the configuration is lost.
* The DMA channels have their own interrupt lines.
* A PTP reference clock and an AHB reset are needed.
* The controllers do not require a power domain (AFAIK).
* The TX clock delay value is 5 bits wide instead of 3, split over 2
register fields.
The DT changes for the A733 and the Cubie A7A board are not part of this
series and will be sent separately through the sunxi tree.
Tested on a Cubie A7A, RGMII with a MAXIO external PHY on GMAC0.
Problems found while testing (none impacting this driver directly):
* Unstable EEE/LPI: If the device stays in LPI mode long enough, the
link sometimes (but not always) goes down, coming back up when the device
exits LPI mode. This is apparently due to PHY, the vendor driver disables
this feature. Solution is to use genphy with eee-broken-* DT prop or wait
for the incoming mainline driver:
https://lore.kernel.org/all/MN0PR19MB609154F210DF84DCB29D3696ACC62@MN0PR19MB6091.namprd19.prod.outlook.com
* Tx-delay: The vendor kernel ships with a Tx delay of 1.2ns. It may seem
to work at first but breaks under heavy load. It turns out the vendor kernel
is configured for an external RGMII clock but this can't work on the A7A.
Th 125MHz input and 25Mhz reference output are not wired to the PHY.
Most likely, It was not tested on this device. Using 0.9ns Tx-delays works well.
DT example is available here (gated on CCU and pinctrl mainline support currently):
https://github.com/jbrun3t/linux/commit/7b8be41a4130d2471b187b3a1ab33643970ef8a7
Changes in v2:
- No driver change since RFC, just more tests.
- Rebase on net-next/main - proper prefix added
- Link to v1: https://patch.msgid.link/20260731-allwinner-a733-gmac-support-v1-0-d0a8732bfa82@baylibre.com
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
Jerome Brunet (2):
dt-bindings: net: sun8i-emac: Add A733 GMAC210 compatible
net: stmmac: Add support for Allwinner A733 GMAC210
.../bindings/net/allwinner,sun8i-a83t-emac.yaml | 130 +++++++++++++++---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c | 145 ++++++++++++++++++---
2 files changed, 242 insertions(+), 33 deletions(-)
---
base-commit: 211f2a875f6f447745d80d5762d6d614503ac84a
change-id: 20260731-allwinner-a733-gmac-support-163bde10c152
Best regards,
--
Jerome
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH net-next v2 1/2] dt-bindings: net: sun8i-emac: Add A733 GMAC210 compatible 2026-09-10 10:25 [PATCH net-next v2 0/2] net: stmmac: Add support for Allwinner A733 GMAC210 Jerome Brunet @ 2026-09-10 10:25 ` Jerome Brunet 2026-09-10 10:25 ` [PATCH net-next v2 2/2] net: stmmac: Add support for Allwinner A733 GMAC210 Jerome Brunet 1 sibling, 0 replies; 6+ messages in thread From: Jerome Brunet @ 2026-09-10 10:25 UTC (permalink / raw) To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, Richard Cochran, Maxime Ripard, Maxime Coquelin, Alexandre Torgue, Philipp Zabel, Maxime Chevallier Cc: netdev, devicetree, linux-arm-kernel, linux-sunxi, linux-kernel, linux-stm32, Andre Przywara, Jerome Brunet The A733 GMAC210 is a DesignWare MAC 5.20 close to the A523 GMAC200, with the following differences: * The glue configuration registers are a dedicated MMIO region of the controller instead of a syscon register, so a second reg entry replaces the syscon phandle. * The DMA channels and the LPI event have their own interrupt lines. * A PTP reference clock and an AHB reset are needed. * Unlike the A523, the controller does not appear to belong to a power domain. * The TX clock delay field is 5 bits wide, allowing up to 3100ps. Add the new compatible and describe those differences. Signed-off-by: Jerome Brunet <jbrunet@baylibre.com> --- .../bindings/net/allwinner,sun8i-a83t-emac.yaml | 130 ++++++++++++++++++--- 1 file changed, 115 insertions(+), 15 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..fec42f46378a 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# @@ -219,36 +232,94 @@ allOf: properties: compatible: contains: - const: allwinner,sun55i-a523-gmac200 + enum: + - allwinner,sun55i-a523-gmac200 + - allwinner,sun60i-a733-gmac210 then: properties: - clocks: - minItems: 2 - clock-names: - minItems: 2 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 PHY 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. - required: - - power-domains + Internal RGMII PHY RX clock delay chain value in ps. else: properties: + reg: + maxItems: 1 + interrupts: + maxItems: 1 + interrupt-names: + maxItems: 1 clocks: maxItems: 1 clock-names: maxItems: 1 power-domains: false + required: + - syscon + + - if: + properties: + compatible: + contains: + 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: + maximum: 700 + required: + - power-domains + - syscon + + - if: + properties: + compatible: + contains: + const: allwinner,sun60i-a733-gmac210 + then: + properties: + reg: + minItems: 2 + interrupts: + minItems: 4 + interrupt-names: + minItems: 4 + clocks: + minItems: 3 + clock-names: + minItems: 3 + resets: + minItems: 2 + reset-names: + minItems: 2 + tx-internal-delay-ps: + maximum: 3100 + syscon: false + power-domains: false unevaluatedProperties: false @@ -412,4 +483,33 @@ examples: }; }; }; + + - | + ethernet@4510000 { + compatible = "allwinner,sun60i-a733-gmac210", + "snps,dwmac-5.20"; + reg = <0x04510000 0x8000>, + <0x04518000 0x1000>; + clocks = <&ccu 58>, <&ccu 59>, <&ccu 60>; + clock-names = "stmmaceth", "mbus", "ptp_ref"; + resets = <&ccu 30>, <&ccu 31>; + reset-names = "stmmaceth", "ahb"; + interrupts = <0 175 4>, <0 179 4>, <0 176 4>, <0 177 4>; + interrupt-names = "macirq", "eth_lpi", "tx-queue-0", "rx-queue-0"; + pinctrl-names = "default"; + pinctrl-0 = <&rgmii1_pins>; + phy-handle = <&ext_rgmii_phy_2>; + phy-mode = "rgmii-id"; + snps,fixed-burst; + + mdio { + compatible = "snps,dwmac-mdio"; + #address-cells = <1>; + #size-cells = <0>; + + ext_rgmii_phy_2: ethernet-phy@1 { + reg = <1>; + }; + }; + }; ... -- 2.53.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next v2 2/2] net: stmmac: Add support for Allwinner A733 GMAC210 2026-09-10 10:25 [PATCH net-next v2 0/2] net: stmmac: Add support for Allwinner A733 GMAC210 Jerome Brunet 2026-09-10 10:25 ` [PATCH net-next v2 1/2] dt-bindings: net: sun8i-emac: Add A733 GMAC210 compatible Jerome Brunet @ 2026-09-10 10:25 ` Jerome Brunet 2026-09-10 10:59 ` Maxime Chevallier 2026-09-11 10:25 ` sashiko-bot 1 sibling, 2 replies; 6+ messages in thread From: Jerome Brunet @ 2026-09-10 10:25 UTC (permalink / raw) To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, Richard Cochran, Maxime Ripard, Maxime Coquelin, Alexandre Torgue, Philipp Zabel, Maxime Chevallier Cc: netdev, devicetree, linux-arm-kernel, linux-sunxi, linux-kernel, linux-stm32, Andre Przywara, Jerome Brunet The A733 GMAC210 is a DesignWare MAC 5.20 using an Allwinner glue close to the A523 GMAC200 already supported by this driver, with the following differences to handle: * The glue configuration registers are a dedicated MMIO region of the controller instead of a syscon register. This new register region appears to be in the reset domain of stmmac's main reset. This requires the glue driver to handle the reset rather than letting stmmac deal with it. * The TX clock delay value is 5 bits wide, split over 2 register fields, allowing delays up to 3100ps. * The DMA channels have their own interrupt lines, so the per-DMA-channel interrupt mode is enabled, as the vendor SDK does. * TX LPI clock gating is supported, as the vendor SDK indicates. Follow the PHY capability with STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP rather than forcing it on with the deprecated 'snps,en-tx-lpi-clockgating' DT property. Unlike the A523, both GMAC instances are supported by the same driver. Signed-off-by: Jerome Brunet <jbrunet@baylibre.com> --- drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c | 145 ++++++++++++++++++--- 1 file changed, 127 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c index 862df173d963..3d434a52fb02 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c @@ -10,21 +10,22 @@ */ #include <linux/bitfield.h> +#include <linux/bitops.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/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_REG 0x34 - /* RMII specific bits */ #define SYSCON_RMII_EN BIT(13) /* 1: enable RMII (overrides EPIT) */ /* Generic system control EMAC_CLK bits */ @@ -37,17 +38,99 @@ #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_data { + struct regmap *(*get_regmap)(struct platform_device *pdev, + struct plat_stmmacenet_data *plat); + unsigned int flags; + u32 etxdc_ext_mask; + u32 offset; +}; + +static struct regmap *sun55i_gmac200_get_regmap(struct platform_device *pdev, + struct plat_stmmacenet_data *plat) +{ + struct regmap *map = + syscon_regmap_lookup_by_phandle(pdev->dev.of_node, "syscon"); + + if (IS_ERR(map)) + dev_err_probe(&pdev->dev, PTR_ERR(map), "Unable to map syscon\n"); + + return map; +} + +static const struct regmap_config sun60i_a733_regmap_cfg = { + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4, +}; + +static void sun60i_gmac210_reset_assert(void *data) { - struct device_node *node = dev->of_node; + struct reset_control *rst = data; + + reset_control_assert(rst); +} + +static struct regmap *sun60i_gmac210_get_regmap(struct platform_device *pdev, + struct plat_stmmacenet_data *plat) +{ + struct device *dev = &pdev->dev; + void __iomem *base; + int ret; + + base = devm_platform_ioremap_resource(pdev, 1); + if (IS_ERR(base)) { + dev_err_probe(dev, PTR_ERR(base), "unable to get glue memory region\n"); + return ERR_CAST(base); + } + + if (!plat->stmmac_rst || !plat->stmmac_ahb_rst) { + dev_err(dev, "missing required reset controls\n"); + return ERR_PTR(-EINVAL); + } + + /* + * The configuration registers are inside the controller + * reset domain, so the reset must happen before any write to them + * and should not be done again by stmmac or the configuration will + * be lost. + */ + ret = reset_control_assert(plat->stmmac_rst); + if (!ret) + ret = reset_control_deassert(plat->stmmac_rst); + + if (ret) { + dev_err_probe(dev, ret, "device reset failed\n"); + return ERR_PTR(ret); + } + + ret = devm_add_action_or_reset(dev, sun60i_gmac210_reset_assert, + plat->stmmac_rst); + if (ret) + return ERR_PTR(ret); + + plat->stmmac_rst = NULL; + + return devm_regmap_init_mmio(&pdev->dev, base, &sun60i_a733_regmap_cfg); +} + +static int sun55i_gmac200_setup(struct platform_device *pdev, + struct plat_stmmacenet_data *plat, + const struct sun55i_gmac_data *data) +{ + unsigned int lo_bits = hweight32(SYSCON_ETXDC_MASK); + struct device_node *node = pdev->dev.of_node; + struct device *dev = &pdev->dev; struct regmap *regmap; u32 val, reg = 0; + u32 max_delay; int ret; - regmap = syscon_regmap_lookup_by_phandle(node, "syscon"); + max_delay = (1U << (lo_bits + hweight32(data->etxdc_ext_mask))) - 1; + + regmap = data->get_regmap(pdev, plat); if (IS_ERR(regmap)) - return dev_err_probe(dev, PTR_ERR(regmap), "Unable to map syscon\n"); + return PTR_ERR(regmap); if (!of_property_read_u32(node, "tx-internal-delay-ps", &val)) { if (val % 100) @@ -55,12 +138,15 @@ static int sun55i_gmac200_set_syscon(struct device *dev, "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)) + if (val > max_delay) return dev_err_probe(dev, -EINVAL, - "TX clock delay exceeds maximum (%u00ps > %lu00ps)\n", - val, FIELD_MAX(SYSCON_ETXDC_MASK)); + "TX clock delay exceeds maximum (%u00ps > %u00ps)\n", + val, max_delay); - reg |= FIELD_PREP(SYSCON_ETXDC_MASK, val); + reg |= field_prep(SYSCON_ETXDC_MASK, val); + if (data->etxdc_ext_mask) + reg |= field_prep(data->etxdc_ext_mask, + val >> lo_bits); } if (!of_property_read_u32(node, "rx-internal-delay-ps", &val)) { @@ -95,21 +181,29 @@ static int sun55i_gmac200_set_syscon(struct device *dev, phy_modes(plat->phy_interface)); } - ret = regmap_write(regmap, SYSCON_REG, reg); + ret = regmap_write(regmap, data->offset, reg); if (ret < 0) return dev_err_probe(dev, ret, "Failed to write to syscon\n"); + plat->flags |= data->flags; + plat->host_dma_width = 32; + return 0; } static int sun55i_gmac200_probe(struct platform_device *pdev) { struct plat_stmmacenet_data *plat_dat; + const struct sun55i_gmac_data *data; struct stmmac_resources stmmac_res; struct device *dev = &pdev->dev; struct clk *clk; int ret; + data = device_get_match_data(dev); + if (!data) + return -EINVAL; + ret = stmmac_get_platform_resources(pdev, &stmmac_res); if (ret) return ret; @@ -118,11 +212,7 @@ static int sun55i_gmac200_probe(struct platform_device *pdev) if (IS_ERR(plat_dat)) return PTR_ERR(plat_dat); - /* BSP disables it */ - plat_dat->flags |= STMMAC_FLAG_SPH_DISABLE; - plat_dat->host_dma_width = 32; - - ret = sun55i_gmac200_set_syscon(dev, plat_dat); + ret = sun55i_gmac200_setup(pdev, plat_dat, data); if (ret) return ret; @@ -138,8 +228,27 @@ 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 = { + .get_regmap = sun55i_gmac200_get_regmap, + .flags = STMMAC_FLAG_SPH_DISABLE, + .offset = 0x34, + .etxdc_ext_mask = 0, +}; + +static const struct sun55i_gmac_data sun60i_a733_gmac210_data = { + .get_regmap = sun60i_gmac210_get_regmap, + .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), +}; + static const struct of_device_id sun55i_gmac200_match[] = { - { .compatible = "allwinner,sun55i-a523-gmac200" }, + { .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 related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v2 2/2] net: stmmac: Add support for Allwinner A733 GMAC210 2026-09-10 10:25 ` [PATCH net-next v2 2/2] net: stmmac: Add support for Allwinner A733 GMAC210 Jerome Brunet @ 2026-09-10 10:59 ` Maxime Chevallier 2026-09-10 13:06 ` Jerome Brunet 2026-09-11 10:25 ` sashiko-bot 1 sibling, 1 reply; 6+ messages in thread From: Maxime Chevallier @ 2026-09-10 10:59 UTC (permalink / raw) To: Jerome Brunet, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, Richard Cochran, Maxime Ripard, Maxime Coquelin, Alexandre Torgue, Philipp Zabel Cc: netdev, devicetree, linux-arm-kernel, linux-sunxi, linux-kernel, linux-stm32, Andre Przywara Hi Jerome, On 9/10/26 12:25, Jerome Brunet wrote: > The A733 GMAC210 is a DesignWare MAC 5.20 using an Allwinner glue close to > the A523 GMAC200 already supported by this driver, with the following > differences to handle: > > * The glue configuration registers are a dedicated MMIO region of the > controller instead of a syscon register. This new register region > appears to be in the reset domain of stmmac's main reset. This requires > the glue driver to handle the reset rather than letting stmmac deal with > it. > * The TX clock delay value is 5 bits wide, split over 2 register fields, > allowing delays up to 3100ps. > * The DMA channels have their own interrupt lines, so the per-DMA-channel > interrupt mode is enabled, as the vendor SDK does. > * TX LPI clock gating is supported, as the vendor SDK indicates. Follow > the PHY capability with STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP rather than > forcing it on with the deprecated 'snps,en-tx-lpi-clockgating' DT > property. > > Unlike the A523, both GMAC instances are supported by the same driver. > > Signed-off-by: Jerome Brunet <jbrunet@baylibre.com> [...] > + > +static struct regmap *sun60i_gmac210_get_regmap(struct platform_device *pdev, > + struct plat_stmmacenet_data *plat) > +{ > + struct device *dev = &pdev->dev; > + void __iomem *base; > + int ret; > + > + base = devm_platform_ioremap_resource(pdev, 1); > + if (IS_ERR(base)) { > + dev_err_probe(dev, PTR_ERR(base), "unable to get glue memory region\n"); > + return ERR_CAST(base); > + } > + > + if (!plat->stmmac_rst || !plat->stmmac_ahb_rst) { Why check stmmac_ahb_rst, but not do anything with it ? > + dev_err(dev, "missing required reset controls\n"); > + return ERR_PTR(-EINVAL); > + } > + > + /* > + * The configuration registers are inside the controller > + * reset domain, so the reset must happen before any write to them > + * and should not be done again by stmmac or the configuration will > + * be lost. > + */ > + ret = reset_control_assert(plat->stmmac_rst); > + if (!ret) > + ret = reset_control_deassert(plat->stmmac_rst); > + > + if (ret) { > + dev_err_probe(dev, ret, "device reset failed\n"); > + return ERR_PTR(ret); > + } > + > + ret = devm_add_action_or_reset(dev, sun60i_gmac210_reset_assert, > + plat->stmmac_rst); > + if (ret) > + return ERR_PTR(ret); > + > + plat->stmmac_rst = NULL; > + > + return devm_regmap_init_mmio(&pdev->dev, base, &sun60i_a733_regmap_cfg); I wonder if this is the first glue to face this... If you need further setup to be done after reset has been deasserted, I suggest adding a dedicated callback in plat_stmmacenet_data, instead of doing this behind the generic code's back. maybe something like "post_reset_init()", something like that ? the ->mac_setup already runs after reset, but isn't really for this type of usecase. For readability of the patch, maybe you should split this patch to first do the a523 rework, then add a733 support. Thanks ! Maxime ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v2 2/2] net: stmmac: Add support for Allwinner A733 GMAC210 2026-09-10 10:59 ` Maxime Chevallier @ 2026-09-10 13:06 ` Jerome Brunet 0 siblings, 0 replies; 6+ messages in thread From: Jerome Brunet @ 2026-09-10 13:06 UTC (permalink / raw) To: Maxime Chevallier, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, Richard Cochran, Maxime Ripard, Maxime Coquelin, Alexandre Torgue, Philipp Zabel Cc: netdev, devicetree, linux-arm-kernel, linux-sunxi, linux-kernel, linux-stm32, Andre Przywara On jeu. 10 sept. 2026 at 12:59, Maxime Chevallier <maxime.chevallier@bootlin.com> wrote: > Hi Jerome, > > On 9/10/26 12:25, Jerome Brunet wrote: >> The A733 GMAC210 is a DesignWare MAC 5.20 using an Allwinner glue close to >> the A523 GMAC200 already supported by this driver, with the following >> differences to handle: >> >> * The glue configuration registers are a dedicated MMIO region of the >> controller instead of a syscon register. This new register region >> appears to be in the reset domain of stmmac's main reset. This requires >> the glue driver to handle the reset rather than letting stmmac deal with >> it. >> * The TX clock delay value is 5 bits wide, split over 2 register fields, >> allowing delays up to 3100ps. >> * The DMA channels have their own interrupt lines, so the per-DMA-channel >> interrupt mode is enabled, as the vendor SDK does. >> * TX LPI clock gating is supported, as the vendor SDK indicates. Follow >> the PHY capability with STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP rather than >> forcing it on with the deprecated 'snps,en-tx-lpi-clockgating' DT >> property. >> >> Unlike the A523, both GMAC instances are supported by the same driver. >> >> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com> > > [...] > >> + >> +static struct regmap *sun60i_gmac210_get_regmap(struct platform_device *pdev, >> + struct plat_stmmacenet_data *plat) >> +{ >> + struct device *dev = &pdev->dev; >> + void __iomem *base; >> + int ret; >> + >> + base = devm_platform_ioremap_resource(pdev, 1); >> + if (IS_ERR(base)) { >> + dev_err_probe(dev, PTR_ERR(base), "unable to get glue memory region\n"); >> + return ERR_CAST(base); >> + } >> + >> + if (!plat->stmmac_rst || !plat->stmmac_ahb_rst) { > > Why check stmmac_ahb_rst, but not do anything with it ? Not strictly required, it was cheap to do and catch mis-configuration since the stmmac treat them as optional. I'll drop it > >> + dev_err(dev, "missing required reset controls\n"); >> + return ERR_PTR(-EINVAL); >> + } >> + >> + /* >> + * The configuration registers are inside the controller >> + * reset domain, so the reset must happen before any write to them >> + * and should not be done again by stmmac or the configuration will >> + * be lost. >> + */ >> + ret = reset_control_assert(plat->stmmac_rst); >> + if (!ret) >> + ret = reset_control_deassert(plat->stmmac_rst); >> + >> + if (ret) { >> + dev_err_probe(dev, ret, "device reset failed\n"); >> + return ERR_PTR(ret); >> + } >> + >> + ret = devm_add_action_or_reset(dev, sun60i_gmac210_reset_assert, >> + plat->stmmac_rst); >> + if (ret) >> + return ERR_PTR(ret); >> + >> + plat->stmmac_rst = NULL; >> + >> + return devm_regmap_init_mmio(&pdev->dev, base, &sun60i_a733_regmap_cfg); > > I wonder if this is the first glue to face this... > > If you need further setup to be done after reset has been deasserted, I suggest > adding a dedicated callback in plat_stmmacenet_data, instead of doing this behind > the generic code's back. > > maybe something like "post_reset_init()", something like that ? > I'll check in this direction. The idea was to do things behind anything's back, more to handle the specifities of this SoC without polluting the rest. The timing seemed a bit sensitve. For example touching the other reset in here broke the link for some reason (recognize as GMII instead of RGMII) > the ->mac_setup already runs after reset, but isn't really for this type of usecase. > > For readability of the patch, maybe you should split this patch to first do the > a523 rework, then add a733 support. ok > > Thanks ! > > Maxime -- Jerome ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v2 2/2] net: stmmac: Add support for Allwinner A733 GMAC210 2026-09-10 10:25 ` [PATCH net-next v2 2/2] net: stmmac: Add support for Allwinner A733 GMAC210 Jerome Brunet 2026-09-10 10:59 ` Maxime Chevallier @ 2026-09-11 10:25 ` sashiko-bot 1 sibling, 0 replies; 6+ messages in thread From: sashiko-bot @ 2026-09-11 10:25 UTC (permalink / raw) To: Jerome Brunet; +Cc: linux-sunxi, conor+dt, robh, devicetree Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] Writing to the GMAC configuration MMIO registers before the required AHB reset is deasserted and bus clocks are enabled will cause a bus fault (synchronous external abort) and hang the system. - [Medium] Hardware configuration programmed into the controller's glue registers will be lost if the power domain is cycled during suspend, because the driver lacks a resume callback. -- commit b1b91e273360986b68768571246550826028aa8d Author: Jerome Brunet <jbrunet@baylibre.com> net: stmmac: Add support for Allwinner A733 GMAC210 This commit adds support for the A733 GMAC210 controller, introducing a dedicated MMIO region for glue configuration registers. It handles TX clock delays, enables per-DMA-channel interrupts, and configures TX LPI clock gating. > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c > index 862df173d963f..3d434a52fb02d 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun55i.c [ ... ] > @@ -37,17 +38,99 @@ [ ... ] > +static struct regmap *sun60i_gmac210_get_regmap(struct platform_device *pdev, > + struct plat_stmmacenet_data *plat) > +{ > + struct device *dev = &pdev->dev; > + void __iomem *base; > + int ret; > + > + base = devm_platform_ioremap_resource(pdev, 1); > + if (IS_ERR(base)) { > + dev_err_probe(dev, PTR_ERR(base), "unable to get glue memory region\n"); > + return ERR_CAST(base); > + } > + > + if (!plat->stmmac_rst || !plat->stmmac_ahb_rst) { > + dev_err(dev, "missing required reset controls\n"); > + return ERR_PTR(-EINVAL); > + } [Severity: High] Does this leave the AHB reset asserted during register access? The driver verifies that plat->stmmac_ahb_rst is present, but it does not appear to deassert it before returning the regmap or performing writes. [ ... ] > @@ -118,11 +212,7 @@ static int sun55i_gmac200_probe(struct platform_device *pdev) > if (IS_ERR(plat_dat)) > return PTR_ERR(plat_dat); > > - /* BSP disables it */ > - plat_dat->flags |= STMMAC_FLAG_SPH_DISABLE; > - plat_dat->host_dma_width = 32; > - > - ret = sun55i_gmac200_setup(pdev, plat_dat, data); [Severity: High] Can writing to the controller's MMIO region here trigger a synchronous external abort? sun55i_gmac200_setup() calls regmap_write() on the glue configuration registers. However, at this point, the AHB reset has not been deasserted, and the mbus clock is only enabled below this call. Accessing an ARM SoC peripheral's MMIO registers while its reset is asserted or its bus clocks are disabled typically results in a bus fault and a system hang. > if (ret) > return ret; > > @@ -138,8 +228,27 @@ static int sun55i_gmac200_probe(struct platform_device *pdev) > return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res); > } [Severity: Medium] Will the hardware configuration be lost after a system suspend? The commit message notes that the glue configuration registers are in the controller's reset domain. When the system enters suspend (e.g., S2RAM), power is cycled and these registers will likely revert to their hardware defaults. Since the driver writes this configuration exactly once during probe in sun55i_gmac200_setup(), and there is no resume callback assigned (e.g., via plat_dat->resume) to restore it on wake, could this lead to a silent network failure after system resume? -- Sashiko AI review · https://sashiko.dev/#/patchset/20260910-allwinner-a733-gmac-support-v2-0-4f4a1e520c23@baylibre.com?part=2 ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-09-11 10:25 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-09-10 10:25 [PATCH net-next v2 0/2] net: stmmac: Add support for Allwinner A733 GMAC210 Jerome Brunet 2026-09-10 10:25 ` [PATCH net-next v2 1/2] dt-bindings: net: sun8i-emac: Add A733 GMAC210 compatible Jerome Brunet 2026-09-10 10:25 ` [PATCH net-next v2 2/2] net: stmmac: Add support for Allwinner A733 GMAC210 Jerome Brunet 2026-09-10 10:59 ` Maxime Chevallier 2026-09-10 13:06 ` Jerome Brunet 2026-09-11 10:25 ` sashiko-bot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox