linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Add support for RK3308 gmac
@ 2021-05-14 11:38 Tobias Schramm
  2021-05-14 11:38 ` [PATCH 1/3] dt-bindings: net: rockchip-dwmac: add rk3308 gmac compatible Tobias Schramm
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Tobias Schramm @ 2021-05-14 11:38 UTC (permalink / raw)
  To: netdev, devicetree, linux-rockchip, Heiko Stuebner
  Cc: David S . Miller, Jakub Kicinski, Rob Herring,
	Giuseppe Cavallaro, David Wu, linux-arm-kernel, linux-kernel,
	Tobias Schramm

The Rockchip RK3308 SoC features an internal gmac. Only the signals
required for RMII are exposed so it is limited to 10/100 Mbit/s operation.
This patchset adds support for it.
I've tested the patchset on a Rock Pi S, works fine.

Cheers,
Tobias

Tobias Schramm (3):
  dt-bindings: net: rockchip-dwmac: add rk3308 gmac compatible
  net: stmmac: dwmac-rk: add support for rk3308 gmac
  arm64: dts: rockchip: add gmac to rk3308 dts

 .../bindings/net/rockchip-dwmac.yaml          |  2 +
 arch/arm64/boot/dts/rockchip/rk3308.dtsi      | 22 +++++++++
 .../net/ethernet/stmicro/stmmac/dwmac-rk.c    | 49 +++++++++++++++++++
 3 files changed, 73 insertions(+)

-- 
2.31.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 1/3] dt-bindings: net: rockchip-dwmac: add rk3308 gmac compatible
  2021-05-14 11:38 [PATCH 0/3] Add support for RK3308 gmac Tobias Schramm
@ 2021-05-14 11:38 ` Tobias Schramm
  2021-05-14 11:38 ` [PATCH 2/3] net: stmmac: dwmac-rk: add support for rk3308 gmac Tobias Schramm
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Tobias Schramm @ 2021-05-14 11:38 UTC (permalink / raw)
  To: netdev, devicetree, linux-rockchip, Heiko Stuebner
  Cc: David S . Miller, Jakub Kicinski, Rob Herring,
	Giuseppe Cavallaro, David Wu, linux-arm-kernel, linux-kernel,
	Tobias Schramm

The Rockchip RK3308 has a gmac that is not fully compatible with any of the
other Rockchip gmacs.
This patch adds a compatible string for it.

Signed-off-by: Tobias Schramm <t.schramm@manjaro.org>
---
 Documentation/devicetree/bindings/net/rockchip-dwmac.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/rockchip-dwmac.yaml b/Documentation/devicetree/bindings/net/rockchip-dwmac.yaml
index 5acddb6171bf..34a660ad6b30 100644
--- a/Documentation/devicetree/bindings/net/rockchip-dwmac.yaml
+++ b/Documentation/devicetree/bindings/net/rockchip-dwmac.yaml
@@ -19,6 +19,7 @@ select:
           - rockchip,rk3128-gmac
           - rockchip,rk3228-gmac
           - rockchip,rk3288-gmac
+          - rockchip,rk3308-gmac
           - rockchip,rk3328-gmac
           - rockchip,rk3366-gmac
           - rockchip,rk3368-gmac
@@ -38,6 +39,7 @@ properties:
           - rockchip,rk3128-gmac
           - rockchip,rk3228-gmac
           - rockchip,rk3288-gmac
+          - rockchip,rk3308-gmac
           - rockchip,rk3328-gmac
           - rockchip,rk3366-gmac
           - rockchip,rk3368-gmac
-- 
2.31.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 2/3] net: stmmac: dwmac-rk: add support for rk3308 gmac
  2021-05-14 11:38 [PATCH 0/3] Add support for RK3308 gmac Tobias Schramm
  2021-05-14 11:38 ` [PATCH 1/3] dt-bindings: net: rockchip-dwmac: add rk3308 gmac compatible Tobias Schramm
@ 2021-05-14 11:38 ` Tobias Schramm
  2021-05-14 11:38 ` [PATCH 3/3] arm64: dts: rockchip: add gmac to rk3308 dts Tobias Schramm
  2021-05-14 22:20 ` [PATCH 0/3] Add support for RK3308 gmac patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Tobias Schramm @ 2021-05-14 11:38 UTC (permalink / raw)
  To: netdev, devicetree, linux-rockchip, Heiko Stuebner
  Cc: David S . Miller, Jakub Kicinski, Rob Herring,
	Giuseppe Cavallaro, David Wu, linux-arm-kernel, linux-kernel,
	Tobias Schramm

The Rockchip RK3308 SoC has a gmac with only the RMII interface signals
exposed.
This patch adds support for it.

Signed-off-by: Tobias Schramm <t.schramm@manjaro.org>
---
 .../net/ethernet/stmicro/stmmac/dwmac-rk.c    | 49 +++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index 8d28a536e1bb..584db4ce6e39 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -482,6 +482,54 @@ static const struct rk_gmac_ops rk3288_ops = {
 	.set_rmii_speed = rk3288_set_rmii_speed,
 };
 
+#define RK3308_GRF_MAC_CON0		0x04a0
+
+/* RK3308_GRF_MAC_CON0 */
+#define RK3308_GMAC_PHY_INTF_SEL_RMII	(GRF_CLR_BIT(2) | GRF_CLR_BIT(3) | \
+					GRF_BIT(4))
+#define RK3308_GMAC_FLOW_CTRL		GRF_BIT(3)
+#define RK3308_GMAC_FLOW_CTRL_CLR	GRF_CLR_BIT(3)
+#define RK3308_GMAC_SPEED_10M		GRF_CLR_BIT(0)
+#define RK3308_GMAC_SPEED_100M		GRF_BIT(0)
+
+static void rk3308_set_to_rmii(struct rk_priv_data *bsp_priv)
+{
+	struct device *dev = &bsp_priv->pdev->dev;
+
+	if (IS_ERR(bsp_priv->grf)) {
+		dev_err(dev, "Missing rockchip,grf property\n");
+		return;
+	}
+
+	regmap_write(bsp_priv->grf, RK3308_GRF_MAC_CON0,
+		     RK3308_GMAC_PHY_INTF_SEL_RMII);
+}
+
+static void rk3308_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed)
+{
+	struct device *dev = &bsp_priv->pdev->dev;
+
+	if (IS_ERR(bsp_priv->grf)) {
+		dev_err(dev, "Missing rockchip,grf property\n");
+		return;
+	}
+
+	if (speed == 10) {
+		regmap_write(bsp_priv->grf, RK3308_GRF_MAC_CON0,
+			     RK3308_GMAC_SPEED_10M);
+	} else if (speed == 100) {
+		regmap_write(bsp_priv->grf, RK3308_GRF_MAC_CON0,
+			     RK3308_GMAC_SPEED_100M);
+	} else {
+		dev_err(dev, "unknown speed value for RMII! speed=%d", speed);
+	}
+}
+
+static const struct rk_gmac_ops rk3308_ops = {
+	.set_to_rmii = rk3308_set_to_rmii,
+	.set_rmii_speed = rk3308_set_rmii_speed,
+};
+
 #define RK3328_GRF_MAC_CON0	0x0900
 #define RK3328_GRF_MAC_CON1	0x0904
 #define RK3328_GRF_MAC_CON2	0x0908
@@ -1477,6 +1525,7 @@ static const struct of_device_id rk_gmac_dwmac_match[] = {
 	{ .compatible = "rockchip,rk3128-gmac", .data = &rk3128_ops },
 	{ .compatible = "rockchip,rk3228-gmac", .data = &rk3228_ops },
 	{ .compatible = "rockchip,rk3288-gmac", .data = &rk3288_ops },
+	{ .compatible = "rockchip,rk3308-gmac", .data = &rk3308_ops },
 	{ .compatible = "rockchip,rk3328-gmac", .data = &rk3328_ops },
 	{ .compatible = "rockchip,rk3366-gmac", .data = &rk3366_ops },
 	{ .compatible = "rockchip,rk3368-gmac", .data = &rk3368_ops },
-- 
2.31.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 3/3] arm64: dts: rockchip: add gmac to rk3308 dts
  2021-05-14 11:38 [PATCH 0/3] Add support for RK3308 gmac Tobias Schramm
  2021-05-14 11:38 ` [PATCH 1/3] dt-bindings: net: rockchip-dwmac: add rk3308 gmac compatible Tobias Schramm
  2021-05-14 11:38 ` [PATCH 2/3] net: stmmac: dwmac-rk: add support for rk3308 gmac Tobias Schramm
@ 2021-05-14 11:38 ` Tobias Schramm
  2021-05-14 22:20 ` [PATCH 0/3] Add support for RK3308 gmac patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Tobias Schramm @ 2021-05-14 11:38 UTC (permalink / raw)
  To: netdev, devicetree, linux-rockchip, Heiko Stuebner
  Cc: David S . Miller, Jakub Kicinski, Rob Herring,
	Giuseppe Cavallaro, David Wu, linux-arm-kernel, linux-kernel,
	Tobias Schramm

The RK3308 SoC has a gmac with only the RMII interface exposed. This
commit adds it to the RK3308 dtsi.

Signed-off-by: Tobias Schramm <t.schramm@manjaro.org>
---
 arch/arm64/boot/dts/rockchip/rk3308.dtsi | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3308.dtsi b/arch/arm64/boot/dts/rockchip/rk3308.dtsi
index 0c5fa9801e6f..b815ce73e5c6 100644
--- a/arch/arm64/boot/dts/rockchip/rk3308.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3308.dtsi
@@ -637,6 +637,28 @@ nfc: nand-controller@ff4b0000 {
 		status = "disabled";
 	};
 
+	gmac: ethernet@ff4e0000 {
+		compatible = "rockchip,rk3308-gmac";
+		reg = <0x0 0xff4e0000 0x0 0x10000>;
+		interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-names = "macirq";
+		clocks = <&cru SCLK_MAC>, <&cru SCLK_MAC_RX_TX>,
+			 <&cru SCLK_MAC_RX_TX>, <&cru SCLK_MAC_REF>,
+			 <&cru SCLK_MAC>, <&cru ACLK_MAC>,
+			 <&cru PCLK_MAC>, <&cru SCLK_MAC_RMII>;
+		clock-names = "stmmaceth", "mac_clk_rx",
+			      "mac_clk_tx", "clk_mac_ref",
+			      "clk_mac_refout", "aclk_mac",
+			      "pclk_mac", "clk_mac_speed";
+		phy-mode = "rmii";
+		pinctrl-names = "default";
+		pinctrl-0 = <&rmii_pins &mac_refclk_12ma>;
+		resets = <&cru SRST_MAC_A>;
+		reset-names = "stmmaceth";
+		rockchip,grf = <&grf>;
+		status = "disabled";
+	};
+
 	cru: clock-controller@ff500000 {
 		compatible = "rockchip,rk3308-cru";
 		reg = <0x0 0xff500000 0x0 0x1000>;
-- 
2.31.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 0/3] Add support for RK3308 gmac
  2021-05-14 11:38 [PATCH 0/3] Add support for RK3308 gmac Tobias Schramm
                   ` (2 preceding siblings ...)
  2021-05-14 11:38 ` [PATCH 3/3] arm64: dts: rockchip: add gmac to rk3308 dts Tobias Schramm
@ 2021-05-14 22:20 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-05-14 22:20 UTC (permalink / raw)
  To: Tobias Schramm
  Cc: netdev, devicetree, linux-rockchip, heiko, davem, kuba, robh+dt,
	peppe.cavallaro, david.wu, linux-arm-kernel, linux-kernel

Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

On Fri, 14 May 2021 13:38:10 +0200 you wrote:
> The Rockchip RK3308 SoC features an internal gmac. Only the signals
> required for RMII are exposed so it is limited to 10/100 Mbit/s operation.
> This patchset adds support for it.
> I've tested the patchset on a Rock Pi S, works fine.
> 
> Cheers,
> Tobias
> 
> [...]

Here is the summary with links:
  - [1/3] dt-bindings: net: rockchip-dwmac: add rk3308 gmac compatible
    https://git.kernel.org/netdev/net-next/c/2cc8c910f515
  - [2/3] net: stmmac: dwmac-rk: add support for rk3308 gmac
    https://git.kernel.org/netdev/net-next/c/b4ac94565c14
  - [3/3] arm64: dts: rockchip: add gmac to rk3308 dts
    https://git.kernel.org/netdev/net-next/c/8d1a81f21a9e

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2021-05-14 22:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-14 11:38 [PATCH 0/3] Add support for RK3308 gmac Tobias Schramm
2021-05-14 11:38 ` [PATCH 1/3] dt-bindings: net: rockchip-dwmac: add rk3308 gmac compatible Tobias Schramm
2021-05-14 11:38 ` [PATCH 2/3] net: stmmac: dwmac-rk: add support for rk3308 gmac Tobias Schramm
2021-05-14 11:38 ` [PATCH 3/3] arm64: dts: rockchip: add gmac to rk3308 dts Tobias Schramm
2021-05-14 22:20 ` [PATCH 0/3] Add support for RK3308 gmac patchwork-bot+netdevbpf

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).