* [PATCH net-next v2 0/3] net: stmmac: Add the Siflower SF19A2890 glue
@ 2026-12-01 7:00 Joseph Telaak via B4 Relay
2026-12-01 7:00 ` [PATCH net-next v2 1/3] dt-bindings: net: ethernet-controller: Allow a device-specific nvmem cell Joseph Telaak via B4 Relay
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Joseph Telaak via B4 Relay @ 2026-12-01 7:00 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Richard Cochran, Alexandre Torgue, Jose Abreu, Maxime Chevallier,
Maxime Coquelin
Cc: Chuanhong Guo, Russell King, linux-mips, netdev, devicetree,
linux-kernel, linux-arm-kernel, Joseph Telaak
The Siflower SF19A2890, a MIPS SoC for home routers, has a DesignWare
GMAC 3.73a. Its interface type and RGMII clock delays are set in a small
configuration block next to its clock and reset manager. This series
adds a binding and the glue.
The SoC support itself (MACH_SIFLOWER_MIPS) comes through the MIPS or
the clk tree, both of which carry its patch; until then the glue builds
with COMPILE_TEST.
v1 took the delays in picoseconds from rx-internal-delay-ps and
tx-internal-delay-ps. Andrew asked whether a TX delay of 0 really adds
nothing, and that cannot be established: the TX delay line has no
bypass, Siflower publishes no timing for the SoC, and its own material
gives 40 ps per step where a sweep measures 55 ps. So v2 does what
Siflower's and GL.iNet's firmware and Chuanhong Guo's driver, which this
glue is based on, do. Siflower calibrates both delay lines of each unit
at the factory and stores the settings, in the lines' own steps, in the
factory partition; the glue programs them from that nvmem cell, and
without one it leaves the lines as the bootloader set them. Nothing in
picoseconds enters the binding, which rejects rx-internal-delay-ps and
tx-internal-delay-ps.
Andrew also suggested making the glue depend on BROKEN, so that device
trees could be broken once the delays are understood. v2 does not,
because the device tree no longer holds a delay value: the board's tree
says only where the unit's calibration is stored. If the delays later
need handling differently, only the glue changes, and existing device
trees keep working.
Patch 1 lets ethernet-controller.yaml take a second nvmem cell after
mac-address, named by the device's own binding. Today it allows only
mac-address, and every MAC binding includes it, so no binding can add a
calibration cell.
The measurements behind this, on the GL.iNet GL-SFT1200, where the GMAC
is the CPU port of a MaxLinear GSW150 switch over RGMII:
- Sweeping each delay register over 0-255 at 1000 Mb/s, the working
windows repeat every 145 steps (TX) and 144.5 steps (RX), one 8 ns
period of the RGMII clock, so a step is about 55 ps. The TX eye is
about 3.1 ns wide and the RX eye about 1.75 ns.
- With every programmed delay at 0 the link passes traffic, at the early
edge of both eyes. Sweeping the switch's own delays with the MAC's at
0, switch to MAC works with 0 to 1.5 ns added and fails from 2 ns, and
MAC to switch works with 0 to 2 ns and fails from 2.5 ns. The RX delay
line at step 0 adds at most about 0.25 ns over its bypass.
- The GSW150 datasheet, which is public, says that with its delay
register at 0 the switch transmits with clock and data aligned to
within 0.5 ns and needs the clock 1.0 to 2.6 ns after the data. So the
MAC's input samples about 1.1 to 1.3 ns earlier than an RGMII v1.3
receiver, and the RX delay it needs, about 0.7 ns, is its own. For TX
the datasheet only bounds the MAC's step-0 delay, its output skew and
the board together to -0.24 to +1.23 ns.
- The two units I have read 0x11/0x0a and 0x10/0x09 from their
calibration cells. GL.iNet's bootloader programs 0x17 for both lines
on every boot, which leaves RX about 0.25 ns inside the edge of the
measured window, so the calibration is worth taking.
Tested on a GL-SFT1200 with the GSW150 driver:
- each of WAN, LAN 1 and LAN 2 links at 1000 Mb/s full duplex and
passes iperf3 both ways (160-205 Mb/s out, 262-273 Mb/s in, well
under line rate; I have not looked into where the limit is);
- 10 GB each way through LAN 1, after which every CRC, alignment,
error, drop, overflow and underflow counter on eth0 and lan1 is 0;
- 50 link down/up cycles, after which the link and traffic recover;
- the MAC address from the factory partition, and ethtool reporting the
link without the STMMAC_FLAG_HAS_INTEGRATED_PCS that the OpenWrt
driver needed;
- v2 on a second GL-SFT1200, whose bootloader leaves both delay
registers at 0x17: the glue programs the unit's calibration, 0x10 and
0x09; 50 of 50 pings of 1400 bytes; iperf3 201 Mb/s out and 288 Mb/s
in with no retransmits; and every CRC, error and drop counter at 0.
---
Changes in v2:
- Patch 1 (new): let ethernet-controller.yaml take a device-specific
nvmem cell after mac-address.
- Patches 2 and 3 were patches 1 and 2 in v1.
- Take the RGMII delays from the unit's factory calibration, the
rgmii-delay nvmem cell, in the delay lines' own steps, instead of
rx-internal-delay-ps and tx-internal-delay-ps, which the binding now
rejects (Andrew).
- Do not depend on BROKEN: the device tree holds no delay value, so
later changes stay in the glue (Andrew).
- Pass the device to the delay helper instead of storing it (Maxime).
- Add a MAINTAINERS entry for the glue and its binding (Maxime).
- Set has_internal_tx_delay and has_internal_rx_delay where the MAC adds
the delays, so the same delays are not asked of the PHY.
- Probe with devm_stmmac_pltfr_probe() and drop .remove.
- Say in a comment that the RX delay line is bypassed while RX_DELAY_EN
is clear (Andrew).
- Describe the measured delays and what the GSW150 datasheet and
Siflower's firmware say about them.
- Link to v1: https://patch.msgid.link/20261104-sf19a2890-gmac-v1-0-a15965a49574@telaak.dev
---
Joseph Telaak (3):
dt-bindings: net: ethernet-controller: Allow a device-specific nvmem cell
dt-bindings: net: Add Siflower SF19A2890 GMAC
net: stmmac: Add Siflower SF19A2890 glue
.../bindings/net/ethernet-controller.yaml | 11 +-
.../bindings/net/siflower,sf19a2890-gmac.yaml | 119 +++++++++++++++
.../devicetree/bindings/net/snps,dwmac.yaml | 1 +
MAINTAINERS | 7 +
drivers/net/ethernet/stmicro/stmmac/Kconfig | 12 ++
drivers/net/ethernet/stmicro/stmmac/Makefile | 1 +
.../net/ethernet/stmicro/stmmac/dwmac-sf19a2890.c | 167 +++++++++++++++++++++
7 files changed, 315 insertions(+), 3 deletions(-)
---
base-commit: d35a725a7c96504f7deece4dfaa83bee6a98fe0e
change-id: 20261102-sf19a2890-gmac-4fb4808f869c
Best regards,
--
Joseph Telaak <joseph@telaak.dev>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net-next v2 1/3] dt-bindings: net: ethernet-controller: Allow a device-specific nvmem cell
2026-12-01 7:00 [PATCH net-next v2 0/3] net: stmmac: Add the Siflower SF19A2890 glue Joseph Telaak via B4 Relay
@ 2026-12-01 7:00 ` Joseph Telaak via B4 Relay
2026-12-01 7:00 ` [PATCH net-next v2 2/3] dt-bindings: net: Add Siflower SF19A2890 GMAC Joseph Telaak via B4 Relay
2026-12-01 7:00 ` [PATCH net-next v2 3/3] net: stmmac: Add Siflower SF19A2890 glue Joseph Telaak via B4 Relay
2 siblings, 0 replies; 4+ messages in thread
From: Joseph Telaak via B4 Relay @ 2026-12-01 7:00 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Richard Cochran, Alexandre Torgue, Jose Abreu, Maxime Chevallier,
Maxime Coquelin
Cc: Chuanhong Guo, Russell King, linux-mips, netdev, devicetree,
linux-kernel, linux-arm-kernel, Joseph Telaak
From: Joseph Telaak <joseph@telaak.dev>
An Ethernet controller may take more from nvmem than its MAC address,
such as a factory calibration. Every MAC binding includes
ethernet-controller.yaml, which allows only the mac-address cell, so no
binding can add a cell of its own.
Allow a second cell after mac-address, which the device's binding names
and describes. The first user is the Siflower SF19A2890 GMAC, whose
RGMII delay lines are calibrated per unit at the factory.
Signed-off-by: Joseph Telaak <joseph@telaak.dev>
---
.../devicetree/bindings/net/ethernet-controller.yaml | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/Documentation/devicetree/bindings/net/ethernet-controller.yaml b/Documentation/devicetree/bindings/net/ethernet-controller.yaml
index 30b2a335116e..da27ff8012eb 100644
--- a/Documentation/devicetree/bindings/net/ethernet-controller.yaml
+++ b/Documentation/devicetree/bindings/net/ethernet-controller.yaml
@@ -22,12 +22,17 @@ properties:
Specifies maximum speed in Mbit/s supported by the device.
nvmem-cells:
- maxItems: 1
+ minItems: 1
+ maxItems: 2
description:
- Reference to an nvmem node for the MAC address
+ Reference to an nvmem node for the MAC address, then optionally to a
+ cell that the device's own binding describes
nvmem-cell-names:
- const: mac-address
+ minItems: 1
+ items:
+ - const: mac-address
+ - description: Named by the device's own binding
phy-connection-type:
description:
--
Git-155)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net-next v2 2/3] dt-bindings: net: Add Siflower SF19A2890 GMAC
2026-12-01 7:00 [PATCH net-next v2 0/3] net: stmmac: Add the Siflower SF19A2890 glue Joseph Telaak via B4 Relay
2026-12-01 7:00 ` [PATCH net-next v2 1/3] dt-bindings: net: ethernet-controller: Allow a device-specific nvmem cell Joseph Telaak via B4 Relay
@ 2026-12-01 7:00 ` Joseph Telaak via B4 Relay
2026-12-01 7:00 ` [PATCH net-next v2 3/3] net: stmmac: Add Siflower SF19A2890 glue Joseph Telaak via B4 Relay
2 siblings, 0 replies; 4+ messages in thread
From: Joseph Telaak via B4 Relay @ 2026-12-01 7:00 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Richard Cochran, Alexandre Torgue, Jose Abreu, Maxime Chevallier,
Maxime Coquelin
Cc: Chuanhong Guo, Russell King, linux-mips, netdev, devicetree,
linux-kernel, linux-arm-kernel, Joseph Telaak
From: Joseph Telaak <joseph@telaak.dev>
The Siflower SF19A2890 has a DesignWare GMAC 3.73a whose interface
type and RGMII clock delays are set in a configuration block of its
own, next to its clock and reset manager. It takes a fourth clock, the
RGMII transmit reference.
The delay lines are calibrated per unit at the factory, and the result
is stored in flash in the lines' own steps, so the delays come from an
nvmem cell, rgmii-delay. The delay of the TX line at its lowest setting
is not known, so rx-internal-delay-ps and tx-internal-delay-ps are not
accepted: a value in picoseconds could not be honored.
Signed-off-by: Joseph Telaak <joseph@telaak.dev>
---
.../bindings/net/siflower,sf19a2890-gmac.yaml | 119 +++++++++++++++++++++
.../devicetree/bindings/net/snps,dwmac.yaml | 1 +
MAINTAINERS | 6 ++
3 files changed, 126 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/siflower,sf19a2890-gmac.yaml b/Documentation/devicetree/bindings/net/siflower,sf19a2890-gmac.yaml
new file mode 100644
index 000000000000..f42276c25d2c
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/siflower,sf19a2890-gmac.yaml
@@ -0,0 +1,119 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/siflower,sf19a2890-gmac.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Siflower SF19A2890 GMAC
+
+maintainers:
+ - Joseph Telaak <joseph@telaak.dev>
+
+description:
+ The Siflower SF19A2890 has a Synopsys DesignWare GMAC 3.73a. Its
+ interface type and RGMII clock delays are set in a configuration block
+ of its own. The delay lines are calibrated per unit at the factory, and
+ the MAC adds the delays only where that calibration is given.
+
+select:
+ properties:
+ compatible:
+ contains:
+ const: siflower,sf19a2890-gmac
+ required:
+ - compatible
+
+properties:
+ compatible:
+ items:
+ - const: siflower,sf19a2890-gmac
+ - const: snps,dwmac
+
+ reg:
+ items:
+ - description: MAC registers
+ - description: Interface configuration registers
+
+ interrupts:
+ maxItems: 3
+
+ interrupt-names:
+ items:
+ - const: macirq
+ - const: eth_wake_irq
+ - const: eth_lpi
+
+ clocks:
+ items:
+ - description: GMAC main clock
+ - description: Peripheral registers interface clock
+ - description: PTP reference clock
+ - description: RGMII transmit reference clock
+
+ clock-names:
+ items:
+ - const: stmmaceth
+ - const: pclk
+ - const: ptp_ref
+ - const: byp_ref
+
+ nvmem-cells:
+ minItems: 1
+ maxItems: 2
+
+ nvmem-cell-names:
+ minItems: 1
+ items:
+ - const: mac-address
+ - const: rgmii-delay
+ description:
+ rgmii-delay is the factory calibration of the RGMII clock delay
+ lines, four ASCII hexadecimal digits giving the TX setting and then
+ the RX setting, in the lines' own steps.
+
+ # The delay of the TX delay line at its lowest setting is not known, so
+ # the delays cannot be given in picoseconds.
+ rx-internal-delay-ps: false
+ tx-internal-delay-ps: false
+
+required:
+ - compatible
+ - reg
+ - interrupts
+ - interrupt-names
+ - clocks
+ - clock-names
+ - resets
+ - reset-names
+
+allOf:
+ - $ref: snps,dwmac.yaml#
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/interrupt-controller/irq.h>
+ #include <dt-bindings/interrupt-controller/mips-gic.h>
+
+ ethernet@10800000 {
+ compatible = "siflower,sf19a2890-gmac", "snps,dwmac";
+ reg = <0x10800000 0x200000>, <0x19e04440 0x10>;
+ interrupt-parent = <&gic>;
+ interrupts = <GIC_SHARED 32 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SHARED 34 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SHARED 33 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "macirq", "eth_wake_irq", "eth_lpi";
+ clocks = <&gmac_crm 0>, <&gmac_crm 1>, <&gmac_crm 3>, <&gmac_crm 2>;
+ clock-names = "stmmaceth", "pclk", "ptp_ref", "byp_ref";
+ resets = <&gmac_crm 0>;
+ reset-names = "stmmaceth";
+ phy-mode = "rgmii-id";
+ nvmem-cells = <&macaddr>, <&rgmii_delay>;
+ nvmem-cell-names = "mac-address", "rgmii-delay";
+
+ fixed-link {
+ speed = <1000>;
+ full-duplex;
+ };
+ };
diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
index 69d88a9b1925..225aa597a012 100644
--- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml
+++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
@@ -99,6 +99,7 @@ properties:
- rockchip,rk3588-gmac
- rockchip,rv1108-gmac
- rockchip,rv1126-gmac
+ - siflower,sf19a2890-gmac
- snps,dwmac
- snps,dwmac-3.40a
- snps,dwmac-3.50a
diff --git a/MAINTAINERS b/MAINTAINERS
index 9336fa93ce38..c279b28bce86 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -25820,6 +25820,12 @@ N: sifive
K: fu[57]40
K: [^@]sifive
+SIFLOWER SF19A2890 DWMAC GLUE LAYER
+M: Joseph Telaak <joseph@telaak.dev>
+L: netdev@vger.kernel.org
+S: Maintained
+F: Documentation/devicetree/bindings/net/siflower,sf19a2890-gmac.yaml
+
SILEAD TOUCHSCREEN DRIVER
M: Hans de Goede <hansg@kernel.org>
L: linux-input@vger.kernel.org
--
Git-155)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net-next v2 3/3] net: stmmac: Add Siflower SF19A2890 glue
2026-12-01 7:00 [PATCH net-next v2 0/3] net: stmmac: Add the Siflower SF19A2890 glue Joseph Telaak via B4 Relay
2026-12-01 7:00 ` [PATCH net-next v2 1/3] dt-bindings: net: ethernet-controller: Allow a device-specific nvmem cell Joseph Telaak via B4 Relay
2026-12-01 7:00 ` [PATCH net-next v2 2/3] dt-bindings: net: Add Siflower SF19A2890 GMAC Joseph Telaak via B4 Relay
@ 2026-12-01 7:00 ` Joseph Telaak via B4 Relay
2 siblings, 0 replies; 4+ messages in thread
From: Joseph Telaak via B4 Relay @ 2026-12-01 7:00 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Richard Cochran, Alexandre Torgue, Jose Abreu, Maxime Chevallier,
Maxime Coquelin
Cc: Chuanhong Guo, Russell King, linux-mips, netdev, devicetree,
linux-kernel, linux-arm-kernel, Joseph Telaak
From: Joseph Telaak <joseph@telaak.dev>
Add the glue for the DesignWare GMAC of the Siflower SF19A2890. The
interface type is set in the GMAC's configuration block through the
set_phy_intf_sel hook, and so are the RGMII clock delays.
Siflower calibrates the delay lines of each unit at the factory and
stores the settings in flash as four hex digits, TX and then RX. The
glue programs them from the rgmii-delay nvmem cell and sets
has_internal_tx_delay and has_internal_rx_delay, so stmmac takes the
delays off the mode it passes on. Without a calibration it leaves the
lines as the bootloader set them.
Based on Chuanhong Guo's driver from OpenWrt and his siflower-7.1
branch, which read the same calibration. That driver also set
STMMAC_FLAG_HAS_INTEGRATED_PCS, because the core reports a PCS that
does not work in RGMII mode; stmmac now uses the integrated PCS only
for SGMII, and the flag is gone.
Signed-off-by: Joseph Telaak <joseph@telaak.dev>
---
MAINTAINERS | 1 +
drivers/net/ethernet/stmicro/stmmac/Kconfig | 12 ++
drivers/net/ethernet/stmicro/stmmac/Makefile | 1 +
.../net/ethernet/stmicro/stmmac/dwmac-sf19a2890.c | 167 +++++++++++++++++++++
4 files changed, 181 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index c279b28bce86..c659c4e5cce2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -25825,6 +25825,7 @@ M: Joseph Telaak <joseph@telaak.dev>
L: netdev@vger.kernel.org
S: Maintained
F: Documentation/devicetree/bindings/net/siflower,sf19a2890-gmac.yaml
+F: drivers/net/ethernet/stmicro/stmmac/dwmac-sf19a2890.c
SILEAD TOUCHSCREEN DRIVER
M: Hans de Goede <hansg@kernel.org>
diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
index c6559e749c0c..3175f3c2bbc9 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
+++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
@@ -201,6 +201,18 @@ config DWMAC_S32
SOCs GMAC ethernet controller, ie. S32G2xx, S32G3xx and
S32R45.
+config DWMAC_SF19A2890
+ tristate "Siflower SF19A2890 GMAC support"
+ default MACH_SIFLOWER_MIPS
+ depends on OF && (MACH_SIFLOWER_MIPS || COMPILE_TEST)
+ help
+ Support for the Ethernet controller of the Siflower SF19A2890 SoC.
+
+ This selects the SF19A2890 glue layer support for the stmmac
+ device driver. It sets the interface type and the RGMII clock
+ delays, from the unit's factory calibration, in the GMAC's
+ configuration block.
+
config DWMAC_SOCFPGA
tristate "SOCFPGA dwmac support"
default ARCH_INTEL_SOCFPGA
diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile
index b16a456b730e..9330de094202 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Makefile
+++ b/drivers/net/ethernet/stmicro/stmmac/Makefile
@@ -26,6 +26,7 @@ obj-$(CONFIG_DWMAC_RENESAS_GBETH) += dwmac-renesas-gbeth.o
obj-$(CONFIG_DWMAC_ROCKCHIP) += dwmac-rk.o
obj-$(CONFIG_DWMAC_RZN1) += dwmac-rzn1.o
obj-$(CONFIG_DWMAC_S32) += dwmac-s32.o
+obj-$(CONFIG_DWMAC_SF19A2890) += dwmac-sf19a2890.o
obj-$(CONFIG_DWMAC_SOCFPGA) += dwmac-altr-socfpga.o
obj-$(CONFIG_DWMAC_SOPHGO) += dwmac-sophgo.o
obj-$(CONFIG_DWMAC_SPACEMIT) += dwmac-spacemit.o
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sf19a2890.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sf19a2890.c
new file mode 100644
index 000000000000..d53f8fbede71
--- /dev/null
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sf19a2890.c
@@ -0,0 +1,167 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Siflower SF19A2890 GMAC glue
+ *
+ * The SF19A2890 has a DWMAC 3.73a. Its interface type and RGMII clock delays
+ * are set in a register block of its own.
+ *
+ * Based on the driver by Chuanhong Guo <gch981213@gmail.com>.
+ */
+
+#include <linux/bitfield.h>
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/kstrtox.h>
+#include <linux/minmax.h>
+#include <linux/module.h>
+#include <linux/nvmem-consumer.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/stmmac.h>
+
+#include "stmmac_platform.h"
+
+/* GMAC configuration block */
+#define SF19A2890_GMAC_MISC 0x0
+#define SF19A2890_PHY_INTF_SEL GENMASK(2, 0)
+#define SF19A2890_GMAC_TX_DELAY 0x4
+#define SF19A2890_GMAC_RX_DELAY 0x8
+#define SF19A2890_GMAC_RX_DELAY_EN 0xc
+
+/* The factory calibration: four hex digits, the TX setting and then RX */
+#define SF19A2890_DELAY_CAL_LEN 4
+#define SF19A2890_DELAY_CAL_TX GENMASK(15, 8)
+#define SF19A2890_DELAY_CAL_RX GENMASK(7, 0)
+
+struct sf19a2890_gmac {
+ void __iomem *cfg;
+};
+
+static int sf19a2890_gmac_set_phy_intf_sel(void *bsp_priv, u8 phy_intf_sel)
+{
+ struct sf19a2890_gmac *gmac = bsp_priv;
+ u32 val;
+
+ if (phy_intf_sel != PHY_INTF_SEL_GMII_MII &&
+ phy_intf_sel != PHY_INTF_SEL_RGMII &&
+ phy_intf_sel != PHY_INTF_SEL_RMII)
+ return -EINVAL;
+
+ val = readl(gmac->cfg + SF19A2890_GMAC_MISC);
+ val &= ~SF19A2890_PHY_INTF_SEL;
+ val |= FIELD_PREP(SF19A2890_PHY_INTF_SEL, phy_intf_sel);
+ writel(val, gmac->cfg + SF19A2890_GMAC_MISC);
+
+ return 0;
+}
+
+/*
+ * The delay lines are calibrated per unit at the factory, in their own steps.
+ * Without a calibration, keep what the bootloader set.
+ */
+static int sf19a2890_gmac_set_delays(struct device *dev,
+ struct sf19a2890_gmac *gmac,
+ struct plat_stmmacenet_data *plat_dat)
+{
+ char str[SF19A2890_DELAY_CAL_LEN + 1] = {};
+ struct nvmem_cell *cell;
+ size_t len;
+ void *buf;
+ u16 cal;
+
+ cell = devm_nvmem_cell_get(dev, "rgmii-delay");
+ if (IS_ERR(cell)) {
+ if (PTR_ERR(cell) == -ENOENT)
+ return 0;
+ return dev_err_probe(dev, PTR_ERR(cell),
+ "failed to get the delay calibration\n");
+ }
+
+ buf = nvmem_cell_read(cell, &len);
+ if (IS_ERR(buf))
+ return dev_err_probe(dev, PTR_ERR(buf),
+ "failed to read the delay calibration\n");
+
+ memcpy(str, buf, min(len, sizeof(str) - 1));
+ kfree(buf);
+
+ /* An uncalibrated unit reads back erased flash */
+ if (len != SF19A2890_DELAY_CAL_LEN || kstrtou16(str, 16, &cal)) {
+ dev_warn(dev, "no valid delay calibration, keeping the bootloader's\n");
+ return 0;
+ }
+
+ writel(FIELD_GET(SF19A2890_DELAY_CAL_TX, cal),
+ gmac->cfg + SF19A2890_GMAC_TX_DELAY);
+ writel(FIELD_GET(SF19A2890_DELAY_CAL_RX, cal),
+ gmac->cfg + SF19A2890_GMAC_RX_DELAY);
+ /* With RX_DELAY_EN clear, the RX delay line is bypassed */
+ writel(1, gmac->cfg + SF19A2890_GMAC_RX_DELAY_EN);
+
+ /* The MAC adds the delays, so stmmac must not ask the PHY for them */
+ plat_dat->has_internal_tx_delay = true;
+ plat_dat->has_internal_rx_delay = true;
+
+ return 0;
+}
+
+static int sf19a2890_gmac_probe(struct platform_device *pdev)
+{
+ struct plat_stmmacenet_data *plat_dat;
+ struct stmmac_resources stmmac_res;
+ struct device *dev = &pdev->dev;
+ struct sf19a2890_gmac *gmac;
+ struct clk *clk;
+ int ret;
+
+ gmac = devm_kzalloc(dev, sizeof(*gmac), GFP_KERNEL);
+ if (!gmac)
+ return -ENOMEM;
+
+ gmac->cfg = devm_platform_ioremap_resource(pdev, 1);
+ if (IS_ERR(gmac->cfg))
+ return dev_err_probe(dev, PTR_ERR(gmac->cfg),
+ "failed to map the configuration block\n");
+
+ clk = devm_clk_get_enabled(dev, "byp_ref");
+ if (IS_ERR(clk))
+ return dev_err_probe(dev, PTR_ERR(clk),
+ "failed to enable the byp_ref clock\n");
+
+ ret = stmmac_get_platform_resources(pdev, &stmmac_res);
+ 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);
+
+ ret = sf19a2890_gmac_set_delays(dev, gmac, plat_dat);
+ if (ret)
+ return ret;
+
+ plat_dat->bsp_priv = gmac;
+ plat_dat->set_phy_intf_sel = sf19a2890_gmac_set_phy_intf_sel;
+
+ return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
+}
+
+static const struct of_device_id sf19a2890_gmac_match[] = {
+ { .compatible = "siflower,sf19a2890-gmac" },
+ { }
+};
+MODULE_DEVICE_TABLE(of, sf19a2890_gmac_match);
+
+static struct platform_driver sf19a2890_gmac_driver = {
+ .probe = sf19a2890_gmac_probe,
+ .driver = {
+ .name = "sf19a2890-gmac",
+ .pm = &stmmac_pltfr_pm_ops,
+ .of_match_table = sf19a2890_gmac_match,
+ },
+};
+module_platform_driver(sf19a2890_gmac_driver);
+
+MODULE_DESCRIPTION("Siflower SF19A2890 GMAC glue");
+MODULE_LICENSE("GPL");
--
Git-155)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-01 7:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-01 7:00 [PATCH net-next v2 0/3] net: stmmac: Add the Siflower SF19A2890 glue Joseph Telaak via B4 Relay
2026-12-01 7:00 ` [PATCH net-next v2 1/3] dt-bindings: net: ethernet-controller: Allow a device-specific nvmem cell Joseph Telaak via B4 Relay
2026-12-01 7:00 ` [PATCH net-next v2 2/3] dt-bindings: net: Add Siflower SF19A2890 GMAC Joseph Telaak via B4 Relay
2026-12-01 7:00 ` [PATCH net-next v2 3/3] net: stmmac: Add Siflower SF19A2890 glue Joseph Telaak via B4 Relay
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®