netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] DWMAC support for Rockchip RK3506
@ 2025-10-21 22:43 Heiko Stuebner
  2025-10-21 22:43 ` [PATCH 1/4] dt-bindings: net: snps,dwmac: move rk3399 line to its correct position Heiko Stuebner
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Heiko Stuebner @ 2025-10-21 22:43 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni
  Cc: robh, krzk+dt, conor+dt, heiko, netdev, devicetree,
	linux-arm-kernel, linux-rockchip, linux-kernel

Some cleanups to the DT binding for Rockchip variants of the dwmac
and adding the RK3506 support on top.

As well as the driver-glue needed for setting up the correct RMII
speed seitings.

David Wu (1):
  ethernet: stmmac: dwmac-rk: Add RK3506 GMAC support

Heiko Stuebner (3):
  dt-bindings: net: snps,dwmac: move rk3399 line to its correct position
  dt-bindings: net: snps,dwmac: Sync list of Rockchip compatibles
  dt-bindings: net: rockchip-dwmac: Add compatible string for RK3506

 .../bindings/net/rockchip-dwmac.yaml          |  3 +
 .../devicetree/bindings/net/snps,dwmac.yaml   |  6 +-
 .../net/ethernet/stmicro/stmmac/dwmac-rk.c    | 79 +++++++++++++++++++
 3 files changed, 87 insertions(+), 1 deletion(-)

-- 
2.47.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/4] dt-bindings: net: snps,dwmac: move rk3399 line to its correct position
  2025-10-21 22:43 [PATCH 0/4] DWMAC support for Rockchip RK3506 Heiko Stuebner
@ 2025-10-21 22:43 ` Heiko Stuebner
  2025-10-22 13:41   ` Andrew Lunn
  2025-10-22 17:55   ` Conor Dooley
  2025-10-21 22:43 ` [PATCH 2/4] dt-bindings: net: snps,dwmac: Sync list of Rockchip compatibles Heiko Stuebner
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 14+ messages in thread
From: Heiko Stuebner @ 2025-10-21 22:43 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni
  Cc: robh, krzk+dt, conor+dt, heiko, netdev, devicetree,
	linux-arm-kernel, linux-rockchip, linux-kernel

Move the rk3399 compatible to its alphabetically correct position.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 Documentation/devicetree/bindings/net/snps,dwmac.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
index 658c004e6a5c..28113ac5e11a 100644
--- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml
+++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
@@ -86,9 +86,9 @@ properties:
         - rockchip,rk3328-gmac
         - rockchip,rk3366-gmac
         - rockchip,rk3368-gmac
+        - rockchip,rk3399-gmac
         - rockchip,rk3576-gmac
         - rockchip,rk3588-gmac
-        - rockchip,rk3399-gmac
         - rockchip,rv1108-gmac
         - snps,dwmac
         - snps,dwmac-3.40a
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/4] dt-bindings: net: snps,dwmac: Sync list of Rockchip compatibles
  2025-10-21 22:43 [PATCH 0/4] DWMAC support for Rockchip RK3506 Heiko Stuebner
  2025-10-21 22:43 ` [PATCH 1/4] dt-bindings: net: snps,dwmac: move rk3399 line to its correct position Heiko Stuebner
@ 2025-10-21 22:43 ` Heiko Stuebner
  2025-10-22 13:41   ` Andrew Lunn
  2025-10-22 17:56   ` Conor Dooley
  2025-10-21 22:43 ` [PATCH 3/4] dt-bindings: net: rockchip-dwmac: Add compatible string for RK3506 Heiko Stuebner
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 14+ messages in thread
From: Heiko Stuebner @ 2025-10-21 22:43 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni
  Cc: robh, krzk+dt, conor+dt, heiko, netdev, devicetree,
	linux-arm-kernel, linux-rockchip, linux-kernel

A number of dwmac variants from Rockchip SoCs have turned up in the
Rockchip-specific binding, but not in the main list in snps,dwmac.yaml
which as the comment indicates is needed for accurate matching.

So add the missing rk3528, rk3568 and rv1126 to the main list.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 Documentation/devicetree/bindings/net/snps,dwmac.yaml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
index 28113ac5e11a..1a0d6789a59b 100644
--- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml
+++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
@@ -87,9 +87,12 @@ properties:
         - rockchip,rk3366-gmac
         - rockchip,rk3368-gmac
         - rockchip,rk3399-gmac
+        - rockchip,rk3528-gmac
+        - rockchip,rk3568-gmac
         - rockchip,rk3576-gmac
         - rockchip,rk3588-gmac
         - rockchip,rv1108-gmac
+        - rockchip,rv1126-gmac
         - snps,dwmac
         - snps,dwmac-3.40a
         - snps,dwmac-3.50a
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/4] dt-bindings: net: rockchip-dwmac: Add compatible string for RK3506
  2025-10-21 22:43 [PATCH 0/4] DWMAC support for Rockchip RK3506 Heiko Stuebner
  2025-10-21 22:43 ` [PATCH 1/4] dt-bindings: net: snps,dwmac: move rk3399 line to its correct position Heiko Stuebner
  2025-10-21 22:43 ` [PATCH 2/4] dt-bindings: net: snps,dwmac: Sync list of Rockchip compatibles Heiko Stuebner
@ 2025-10-21 22:43 ` Heiko Stuebner
  2025-10-22 13:42   ` Andrew Lunn
  2025-10-22 17:56   ` Conor Dooley
  2025-10-21 22:43 ` [PATCH 4/4] ethernet: stmmac: dwmac-rk: Add RK3506 GMAC support Heiko Stuebner
  2025-10-23  1:26 ` [PATCH 0/4] DWMAC support for Rockchip RK3506 Jakub Kicinski
  4 siblings, 2 replies; 14+ messages in thread
From: Heiko Stuebner @ 2025-10-21 22:43 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni
  Cc: robh, krzk+dt, conor+dt, heiko, netdev, devicetree,
	linux-arm-kernel, linux-rockchip, linux-kernel

Rockchip RK3506 has two Ethernet controllers based on Synopsys DWC
Ethernet QoS IP.

Add compatible string for the RK3506 variant.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 Documentation/devicetree/bindings/net/rockchip-dwmac.yaml | 3 +++
 Documentation/devicetree/bindings/net/snps,dwmac.yaml     | 1 +
 2 files changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/rockchip-dwmac.yaml b/Documentation/devicetree/bindings/net/rockchip-dwmac.yaml
index 0ac7c4b47d6b..d17112527dab 100644
--- a/Documentation/devicetree/bindings/net/rockchip-dwmac.yaml
+++ b/Documentation/devicetree/bindings/net/rockchip-dwmac.yaml
@@ -24,6 +24,7 @@ select:
           - rockchip,rk3366-gmac
           - rockchip,rk3368-gmac
           - rockchip,rk3399-gmac
+          - rockchip,rk3506-gmac
           - rockchip,rk3528-gmac
           - rockchip,rk3568-gmac
           - rockchip,rk3576-gmac
@@ -50,6 +51,7 @@ properties:
               - rockchip,rv1108-gmac
       - items:
           - enum:
+              - rockchip,rk3506-gmac
               - rockchip,rk3528-gmac
               - rockchip,rk3568-gmac
               - rockchip,rk3576-gmac
@@ -148,6 +150,7 @@ allOf:
           compatible:
             contains:
               enum:
+                - rockchip,rk3506-gmac
                 - rockchip,rk3528-gmac
     then:
       properties:
diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
index 1a0d6789a59b..dd3c72e8363e 100644
--- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml
+++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
@@ -87,6 +87,7 @@ properties:
         - rockchip,rk3366-gmac
         - rockchip,rk3368-gmac
         - rockchip,rk3399-gmac
+        - rockchip,rk3506-gmac
         - rockchip,rk3528-gmac
         - rockchip,rk3568-gmac
         - rockchip,rk3576-gmac
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/4] ethernet: stmmac: dwmac-rk: Add RK3506 GMAC support
  2025-10-21 22:43 [PATCH 0/4] DWMAC support for Rockchip RK3506 Heiko Stuebner
                   ` (2 preceding siblings ...)
  2025-10-21 22:43 ` [PATCH 3/4] dt-bindings: net: rockchip-dwmac: Add compatible string for RK3506 Heiko Stuebner
@ 2025-10-21 22:43 ` Heiko Stuebner
  2025-10-22 13:44   ` Andrew Lunn
  2025-10-22 20:43   ` Jonas Karlman
  2025-10-23  1:26 ` [PATCH 0/4] DWMAC support for Rockchip RK3506 Jakub Kicinski
  4 siblings, 2 replies; 14+ messages in thread
From: Heiko Stuebner @ 2025-10-21 22:43 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni
  Cc: robh, krzk+dt, conor+dt, heiko, netdev, devicetree,
	linux-arm-kernel, linux-rockchip, linux-kernel, David Wu

From: David Wu <david.wu@rock-chips.com>

Add the needed glue blocks for the RK3506-specific setup.

The RK3506 dwmac only supports up to 100MBit with a RMII PHY,
but no RGMII.

Signed-off-by: David Wu <david.wu@rock-chips.com>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 .../net/ethernet/stmicro/stmmac/dwmac-rk.c    | 79 +++++++++++++++++++
 1 file changed, 79 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index 51ea0caf16c1..e1e036e7163c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -827,6 +827,84 @@ static const struct rk_gmac_ops rk3399_ops = {
 	.set_speed = rk3399_set_speed,
 };
 
+#define RK3506_GRF_SOC_CON8		0X0020
+#define RK3506_GRF_SOC_CON11		0X002c
+
+#define RK3506_GMAC_RMII_MODE		GRF_BIT(1)
+
+#define RK3506_GMAC_CLK_RMII_DIV2	GRF_BIT(3)
+#define RK3506_GMAC_CLK_RMII_DIV20	GRF_CLR_BIT(3)
+
+#define RK3506_GMAC_CLK_SELET_CRU	GRF_CLR_BIT(5)
+#define RK3506_GMAC_CLK_SELET_IO	GRF_BIT(5)
+
+#define RK3506_GMAC_CLK_RMII_GATE	GRF_BIT(2)
+#define RK3506_GMAC_CLK_RMII_NOGATE	GRF_CLR_BIT(2)
+
+static void rk3506_set_to_rmii(struct rk_priv_data *bsp_priv)
+{
+	struct device *dev = bsp_priv->dev;
+	unsigned int id = bsp_priv->id, offset;
+
+	if (IS_ERR(bsp_priv->grf)) {
+		dev_err(dev, "%s: Missing rockchip,grf property\n", __func__);
+		return;
+	}
+
+	offset = (id == 1) ? RK3506_GRF_SOC_CON11 : RK3506_GRF_SOC_CON8;
+	regmap_write(bsp_priv->grf, offset, RK3506_GMAC_RMII_MODE);
+}
+
+static int rk3506_set_speed(struct rk_priv_data *bsp_priv,
+			    phy_interface_t interface, int speed)
+{
+	struct device *dev = bsp_priv->dev;
+	unsigned int val, offset, id = bsp_priv->id;
+
+	switch (speed) {
+	case 10:
+		val = RK3506_GMAC_CLK_RMII_DIV20;
+		break;
+	case 100:
+		val = RK3506_GMAC_CLK_RMII_DIV2;
+		break;
+	default:
+		dev_err(dev, "unknown speed value for RMII! speed=%d", speed);
+		return -EINVAL;
+	}
+
+	offset = (id == 1) ? RK3506_GRF_SOC_CON11 : RK3506_GRF_SOC_CON8;
+	regmap_write(bsp_priv->grf, offset, val);
+
+	return 0;
+}
+
+static void rk3506_set_clock_selection(struct rk_priv_data *bsp_priv,
+				       bool input, bool enable)
+{
+	unsigned int value, offset, id = bsp_priv->id;
+
+	offset = (id == 1) ? RK3506_GRF_SOC_CON11 : RK3506_GRF_SOC_CON8;
+
+	value = input ? RK3506_GMAC_CLK_SELET_IO :
+			RK3506_GMAC_CLK_SELET_CRU;
+	value |= enable ? RK3506_GMAC_CLK_RMII_NOGATE :
+			  RK3506_GMAC_CLK_RMII_GATE;
+	regmap_write(bsp_priv->grf, offset, value);
+}
+
+static const struct rk_gmac_ops rk3506_ops = {
+	.set_to_rmii = rk3506_set_to_rmii,
+	.set_speed = rk3506_set_speed,
+	.set_clock_selection = rk3506_set_clock_selection,
+	.regs_valid = true,
+	.regs = {
+		0xff4c8000, /* gmac0 */
+		0xff4d0000, /* gmac1 */
+		0x0, /* sentinel */
+	},
+};
+
 #define RK3528_VO_GRF_GMAC_CON		0x0018
 #define RK3528_VO_GRF_MACPHY_CON0	0x001c
 #define RK3528_VO_GRF_MACPHY_CON1	0x0020
@@ -1808,6 +1886,7 @@ static const struct of_device_id rk_gmac_dwmac_match[] = {
 	{ .compatible = "rockchip,rk3366-gmac", .data = &rk3366_ops },
 	{ .compatible = "rockchip,rk3368-gmac", .data = &rk3368_ops },
 	{ .compatible = "rockchip,rk3399-gmac", .data = &rk3399_ops },
+	{ .compatible = "rockchip,rk3506-gmac", .data = &rk3506_ops },
 	{ .compatible = "rockchip,rk3528-gmac", .data = &rk3528_ops },
 	{ .compatible = "rockchip,rk3568-gmac", .data = &rk3568_ops },
 	{ .compatible = "rockchip,rk3576-gmac", .data = &rk3576_ops },
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/4] dt-bindings: net: snps,dwmac: move rk3399 line to its correct position
  2025-10-21 22:43 ` [PATCH 1/4] dt-bindings: net: snps,dwmac: move rk3399 line to its correct position Heiko Stuebner
@ 2025-10-22 13:41   ` Andrew Lunn
  2025-10-22 17:55   ` Conor Dooley
  1 sibling, 0 replies; 14+ messages in thread
From: Andrew Lunn @ 2025-10-22 13:41 UTC (permalink / raw)
  To: Heiko Stuebner
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, robh, krzk+dt,
	conor+dt, netdev, devicetree, linux-arm-kernel, linux-rockchip,
	linux-kernel

On Wed, Oct 22, 2025 at 12:43:54AM +0200, Heiko Stuebner wrote:
> Move the rk3399 compatible to its alphabetically correct position.
> 
> Signed-off-by: Heiko Stuebner <heiko@sntech.de>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/4] dt-bindings: net: snps,dwmac: Sync list of Rockchip compatibles
  2025-10-21 22:43 ` [PATCH 2/4] dt-bindings: net: snps,dwmac: Sync list of Rockchip compatibles Heiko Stuebner
@ 2025-10-22 13:41   ` Andrew Lunn
  2025-10-22 17:56   ` Conor Dooley
  1 sibling, 0 replies; 14+ messages in thread
From: Andrew Lunn @ 2025-10-22 13:41 UTC (permalink / raw)
  To: Heiko Stuebner
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, robh, krzk+dt,
	conor+dt, netdev, devicetree, linux-arm-kernel, linux-rockchip,
	linux-kernel

On Wed, Oct 22, 2025 at 12:43:55AM +0200, Heiko Stuebner wrote:
> A number of dwmac variants from Rockchip SoCs have turned up in the
> Rockchip-specific binding, but not in the main list in snps,dwmac.yaml
> which as the comment indicates is needed for accurate matching.
> 
> So add the missing rk3528, rk3568 and rv1126 to the main list.
> 
> Signed-off-by: Heiko Stuebner <heiko@sntech.de>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/4] dt-bindings: net: rockchip-dwmac: Add compatible string for RK3506
  2025-10-21 22:43 ` [PATCH 3/4] dt-bindings: net: rockchip-dwmac: Add compatible string for RK3506 Heiko Stuebner
@ 2025-10-22 13:42   ` Andrew Lunn
  2025-10-22 17:56   ` Conor Dooley
  1 sibling, 0 replies; 14+ messages in thread
From: Andrew Lunn @ 2025-10-22 13:42 UTC (permalink / raw)
  To: Heiko Stuebner
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, robh, krzk+dt,
	conor+dt, netdev, devicetree, linux-arm-kernel, linux-rockchip,
	linux-kernel

On Wed, Oct 22, 2025 at 12:43:56AM +0200, Heiko Stuebner wrote:
> Rockchip RK3506 has two Ethernet controllers based on Synopsys DWC
> Ethernet QoS IP.
> 
> Add compatible string for the RK3506 variant.
> 
> Signed-off-by: Heiko Stuebner <heiko@sntech.de>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/4] ethernet: stmmac: dwmac-rk: Add RK3506 GMAC support
  2025-10-21 22:43 ` [PATCH 4/4] ethernet: stmmac: dwmac-rk: Add RK3506 GMAC support Heiko Stuebner
@ 2025-10-22 13:44   ` Andrew Lunn
  2025-10-22 20:43   ` Jonas Karlman
  1 sibling, 0 replies; 14+ messages in thread
From: Andrew Lunn @ 2025-10-22 13:44 UTC (permalink / raw)
  To: Heiko Stuebner
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, robh, krzk+dt,
	conor+dt, netdev, devicetree, linux-arm-kernel, linux-rockchip,
	linux-kernel, David Wu

On Wed, Oct 22, 2025 at 12:43:57AM +0200, Heiko Stuebner wrote:
> From: David Wu <david.wu@rock-chips.com>
> 
> Add the needed glue blocks for the RK3506-specific setup.
> 
> The RK3506 dwmac only supports up to 100MBit with a RMII PHY,
> but no RGMII.
> 
> Signed-off-by: David Wu <david.wu@rock-chips.com>
> Signed-off-by: Heiko Stuebner <heiko@sntech.de>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/4] dt-bindings: net: snps,dwmac: move rk3399 line to its correct position
  2025-10-21 22:43 ` [PATCH 1/4] dt-bindings: net: snps,dwmac: move rk3399 line to its correct position Heiko Stuebner
  2025-10-22 13:41   ` Andrew Lunn
@ 2025-10-22 17:55   ` Conor Dooley
  1 sibling, 0 replies; 14+ messages in thread
From: Conor Dooley @ 2025-10-22 17:55 UTC (permalink / raw)
  To: Heiko Stuebner
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, robh, krzk+dt,
	conor+dt, netdev, devicetree, linux-arm-kernel, linux-rockchip,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 52 bytes --]

Acked-by: Conor Dooley <conor.dooley@microchip.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/4] dt-bindings: net: rockchip-dwmac: Add compatible string for RK3506
  2025-10-21 22:43 ` [PATCH 3/4] dt-bindings: net: rockchip-dwmac: Add compatible string for RK3506 Heiko Stuebner
  2025-10-22 13:42   ` Andrew Lunn
@ 2025-10-22 17:56   ` Conor Dooley
  1 sibling, 0 replies; 14+ messages in thread
From: Conor Dooley @ 2025-10-22 17:56 UTC (permalink / raw)
  To: Heiko Stuebner
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, robh, krzk+dt,
	conor+dt, netdev, devicetree, linux-arm-kernel, linux-rockchip,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 52 bytes --]

Acked-by: Conor Dooley <conor.dooley@microchip.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/4] dt-bindings: net: snps,dwmac: Sync list of Rockchip compatibles
  2025-10-21 22:43 ` [PATCH 2/4] dt-bindings: net: snps,dwmac: Sync list of Rockchip compatibles Heiko Stuebner
  2025-10-22 13:41   ` Andrew Lunn
@ 2025-10-22 17:56   ` Conor Dooley
  1 sibling, 0 replies; 14+ messages in thread
From: Conor Dooley @ 2025-10-22 17:56 UTC (permalink / raw)
  To: Heiko Stuebner
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, robh, krzk+dt,
	conor+dt, netdev, devicetree, linux-arm-kernel, linux-rockchip,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 52 bytes --]

Acked-by: Conor Dooley <conor.dooley@microchip.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/4] ethernet: stmmac: dwmac-rk: Add RK3506 GMAC support
  2025-10-21 22:43 ` [PATCH 4/4] ethernet: stmmac: dwmac-rk: Add RK3506 GMAC support Heiko Stuebner
  2025-10-22 13:44   ` Andrew Lunn
@ 2025-10-22 20:43   ` Jonas Karlman
  1 sibling, 0 replies; 14+ messages in thread
From: Jonas Karlman @ 2025-10-22 20:43 UTC (permalink / raw)
  To: Heiko Stuebner
  Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, robh@kernel.org,
	krzk+dt@kernel.org, conor+dt@kernel.org, netdev@vger.kernel.org,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
	David Wu

Hi Heiko,

On 10/22/2025 12:43 AM, Heiko Stuebner wrote:
> From: David Wu <david.wu@rock-chips.com>
> 
> Add the needed glue blocks for the RK3506-specific setup.
> 
> The RK3506 dwmac only supports up to 100MBit with a RMII PHY,
> but no RGMII.
> 
> Signed-off-by: David Wu <david.wu@rock-chips.com>
> Signed-off-by: Heiko Stuebner <heiko@sntech.de>
> ---
>  .../net/ethernet/stmicro/stmmac/dwmac-rk.c    | 79 +++++++++++++++++++
>  1 file changed, 79 insertions(+)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> index 51ea0caf16c1..e1e036e7163c 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> @@ -827,6 +827,84 @@ static const struct rk_gmac_ops rk3399_ops = {
>  	.set_speed = rk3399_set_speed,
>  };
>  
> +#define RK3506_GRF_SOC_CON8		0X0020
> +#define RK3506_GRF_SOC_CON11		0X002c

Maybe 0x0020 and 0x002c (lower case x) ?

> +
> +#define RK3506_GMAC_RMII_MODE		GRF_BIT(1)
> +
> +#define RK3506_GMAC_CLK_RMII_DIV2	GRF_BIT(3)
> +#define RK3506_GMAC_CLK_RMII_DIV20	GRF_CLR_BIT(3)
> +
> +#define RK3506_GMAC_CLK_SELET_CRU	GRF_CLR_BIT(5)
> +#define RK3506_GMAC_CLK_SELET_IO	GRF_BIT(5)

s/SELET/SELECT/

> +
> +#define RK3506_GMAC_CLK_RMII_GATE	GRF_BIT(2)
> +#define RK3506_GMAC_CLK_RMII_NOGATE	GRF_CLR_BIT(2)
> +
> +static void rk3506_set_to_rmii(struct rk_priv_data *bsp_priv)
> +{
> +	struct device *dev = bsp_priv->dev;
> +	unsigned int id = bsp_priv->id, offset;
> +
> +	if (IS_ERR(bsp_priv->grf)) {
> +		dev_err(dev, "%s: Missing rockchip,grf property\n", __func__);
> +		return;
> +	}

Please drop this, it is already checked in rk_gmac_setup().

> +
> +	offset = (id == 1) ? RK3506_GRF_SOC_CON11 : RK3506_GRF_SOC_CON8;
> +	regmap_write(bsp_priv->grf, offset, RK3506_GMAC_RMII_MODE);
> +}
> +
> +static int rk3506_set_speed(struct rk_priv_data *bsp_priv,
> +			    phy_interface_t interface, int speed)
> +{
> +	struct device *dev = bsp_priv->dev;
> +	unsigned int val, offset, id = bsp_priv->id;
> +
> +	switch (speed) {
> +	case 10:
> +		val = RK3506_GMAC_CLK_RMII_DIV20;
> +		break;
> +	case 100:
> +		val = RK3506_GMAC_CLK_RMII_DIV2;
> +		break;
> +	default:
> +		dev_err(dev, "unknown speed value for RMII! speed=%d", speed);
> +		return -EINVAL;
> +	}
> +
> +	offset = (id == 1) ? RK3506_GRF_SOC_CON11 : RK3506_GRF_SOC_CON8;
> +	regmap_write(bsp_priv->grf, offset, val);
> +
> +	return 0;

This should probably be converted to use rk_reg_speed_data with
something like:

static const struct rk_reg_speed_data rk3506_reg_speed_data = {
	.rmii_10 = RK3506_GMAC_CLK_RMII_DIV20,
	.rmii_100 = RK3506_GMAC_CLK_RMII_DIV2,
};

and:

	return rk_set_reg_speed(bsp_priv, &rk3506_reg_speed_data,
				offset, interface, speed);

> +}
> +
> +static void rk3506_set_clock_selection(struct rk_priv_data *bsp_priv,
> +				       bool input, bool enable)
> +{
> +	unsigned int value, offset, id = bsp_priv->id;
> +
> +	offset = (id == 1) ? RK3506_GRF_SOC_CON11 : RK3506_GRF_SOC_CON8;
> +
> +	value = input ? RK3506_GMAC_CLK_SELET_IO :
> +			RK3506_GMAC_CLK_SELET_CRU;

s/SELET/SELECT/

Regards,
Jonas

> +	value |= enable ? RK3506_GMAC_CLK_RMII_NOGATE :
> +			  RK3506_GMAC_CLK_RMII_GATE;
> +	regmap_write(bsp_priv->grf, offset, value);
> +}
> +
> +static const struct rk_gmac_ops rk3506_ops = {
> +	.set_to_rmii = rk3506_set_to_rmii,
> +	.set_speed = rk3506_set_speed,
> +	.set_clock_selection = rk3506_set_clock_selection,
> +	.regs_valid = true,
> +	.regs = {
> +		0xff4c8000, /* gmac0 */
> +		0xff4d0000, /* gmac1 */
> +		0x0, /* sentinel */
> +	},
> +};
> +
>  #define RK3528_VO_GRF_GMAC_CON		0x0018
>  #define RK3528_VO_GRF_MACPHY_CON0	0x001c
>  #define RK3528_VO_GRF_MACPHY_CON1	0x0020
> @@ -1808,6 +1886,7 @@ static const struct of_device_id rk_gmac_dwmac_match[] = {
>  	{ .compatible = "rockchip,rk3366-gmac", .data = &rk3366_ops },
>  	{ .compatible = "rockchip,rk3368-gmac", .data = &rk3368_ops },
>  	{ .compatible = "rockchip,rk3399-gmac", .data = &rk3399_ops },
> +	{ .compatible = "rockchip,rk3506-gmac", .data = &rk3506_ops },
>  	{ .compatible = "rockchip,rk3528-gmac", .data = &rk3528_ops },
>  	{ .compatible = "rockchip,rk3568-gmac", .data = &rk3568_ops },
>  	{ .compatible = "rockchip,rk3576-gmac", .data = &rk3576_ops },


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/4] DWMAC support for Rockchip RK3506
  2025-10-21 22:43 [PATCH 0/4] DWMAC support for Rockchip RK3506 Heiko Stuebner
                   ` (3 preceding siblings ...)
  2025-10-21 22:43 ` [PATCH 4/4] ethernet: stmmac: dwmac-rk: Add RK3506 GMAC support Heiko Stuebner
@ 2025-10-23  1:26 ` Jakub Kicinski
  4 siblings, 0 replies; 14+ messages in thread
From: Jakub Kicinski @ 2025-10-23  1:26 UTC (permalink / raw)
  To: Heiko Stuebner
  Cc: andrew+netdev, davem, edumazet, pabeni, robh, krzk+dt, conor+dt,
	netdev, devicetree, linux-arm-kernel, linux-rockchip,
	linux-kernel, Jonas Karlman

On Wed, 22 Oct 2025 00:43:53 +0200 Heiko Stuebner wrote:
> Some cleanups to the DT binding for Rockchip variants of the dwmac
> and adding the RK3506 support on top.
> 
> As well as the driver-glue needed for setting up the correct RMII
> speed seitings.

Looks like its not your first contribution, feel free to add yourself
as the maintainer for stmmac/dwmac-rk.c (anyone else who wants to be
listed please raise a hand, Jonas?)

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2025-10-23  1:26 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-21 22:43 [PATCH 0/4] DWMAC support for Rockchip RK3506 Heiko Stuebner
2025-10-21 22:43 ` [PATCH 1/4] dt-bindings: net: snps,dwmac: move rk3399 line to its correct position Heiko Stuebner
2025-10-22 13:41   ` Andrew Lunn
2025-10-22 17:55   ` Conor Dooley
2025-10-21 22:43 ` [PATCH 2/4] dt-bindings: net: snps,dwmac: Sync list of Rockchip compatibles Heiko Stuebner
2025-10-22 13:41   ` Andrew Lunn
2025-10-22 17:56   ` Conor Dooley
2025-10-21 22:43 ` [PATCH 3/4] dt-bindings: net: rockchip-dwmac: Add compatible string for RK3506 Heiko Stuebner
2025-10-22 13:42   ` Andrew Lunn
2025-10-22 17:56   ` Conor Dooley
2025-10-21 22:43 ` [PATCH 4/4] ethernet: stmmac: dwmac-rk: Add RK3506 GMAC support Heiko Stuebner
2025-10-22 13:44   ` Andrew Lunn
2025-10-22 20:43   ` Jonas Karlman
2025-10-23  1:26 ` [PATCH 0/4] DWMAC support for Rockchip RK3506 Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).