125 lines
4.6 KiB
Diff
125 lines
4.6 KiB
Diff
From 3aab567792a7fa949e8aca7a92a31f15d435efbe Mon Sep 17 00:00:00 2001
|
|
From: ashthespy <ashthespy@gmail.com>
|
|
Date: Thu, 16 Jan 2020 21:11:56 +0100
|
|
Subject: [PATCH 04/23] ethernet: stmmac: dwmac-rk: Add MAC driver support for
|
|
rk3308
|
|
|
|
Probably in the wrong place, as it's only 10/100 but :meh:
|
|
|
|
From 67e46ea01439010eadbc220c7600fa6dae01e8e8 Mon Sep 17 00:00:00 2001
|
|
From: David Wu <david.wu@rock-chips.com>
|
|
Date: Thu, 8 Mar 2018 20:07:12 +0800
|
|
Subject: [PATCH] ethernet: stmmac: dwmac-rk: Add MAC driver support for rk3308
|
|
|
|
Add constants and callback functions for the dwmac on rk3308 soc.
|
|
The base structure is the same, but registers and the bits in
|
|
them moved slightly, and add the clk_mac_speed for the select
|
|
of mac speed.
|
|
|
|
Change-Id: Ieaea3ade9e51d5118f0eb855d8e02febfb2275d1
|
|
Signed-off-by: David Wu <david.wu@rock-chips.com>
|
|
---
|
|
.../bindings/net/rockchip-dwmac.txt | 3 +-
|
|
.../net/ethernet/stmicro/stmmac/dwmac-rk.c | 59 +++++++++++++++++++
|
|
2 files changed, 61 insertions(+), 1 deletion(-)
|
|
|
|
:100644 100644 3b71da7e874 553d5e17eca M Documentation/devicetree/bindings/net/rockchip-dwmac.txt
|
|
:100644 100644 dc50ba13a74 3b9b4731118 M drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
|
|
---
|
|
.../bindings/net/rockchip-dwmac.txt | 1 +
|
|
.../net/ethernet/stmicro/stmmac/dwmac-rk.c | 59 +++++++++++++++++++
|
|
2 files changed, 60 insertions(+)
|
|
|
|
diff --git a/Documentation/devicetree/bindings/net/rockchip-dwmac.txt b/Documentation/devicetree/bindings/net/rockchip-dwmac.txt
|
|
index 3b71da7e8742..553d5e17eca8 100644
|
|
--- a/Documentation/devicetree/bindings/net/rockchip-dwmac.txt
|
|
+++ b/Documentation/devicetree/bindings/net/rockchip-dwmac.txt
|
|
@@ -8,6 +8,7 @@ Required properties:
|
|
"rockchip,rk3128-gmac": found on RK312x SoCs
|
|
"rockchip,rk3228-gmac": found on RK322x SoCs
|
|
"rockchip,rk3288-gmac": found on RK3288 SoCs
|
|
+ "rockchip,rk3308-gmac": found on RK3308 SoCs
|
|
"rockchip,rk3328-gmac": found on RK3328 SoCs
|
|
"rockchip,rk3366-gmac": found on RK3366 SoCs
|
|
"rockchip,rk3368-gmac": found on RK3368 SoCs
|
|
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
|
|
index dc50ba13a746..cfeca75ed284 100644
|
|
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
|
|
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
|
|
@@ -482,6 +482,64 @@ static const struct rk_gmac_ops rk3288_ops = {
|
|
.set_rmii_speed = rk3288_set_rmii_speed,
|
|
};
|
|
|
|
+#define RK3308_GRF_MAC_CON0 0x04a0
|
|
+
|
|
+/* Rk3308_GRF_MAC_CON1 */
|
|
+#define RK3308_MAC_PHY_INTF_SEL_RMII (GRF_CLR_BIT(2) | GRF_CLR_BIT(3) | \
|
|
+ GRF_BIT(4))
|
|
+#define RK3308_MAC_SPEED_10M GRF_CLR_BIT(0)
|
|
+#define Rk3308_MAC_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, "%s: Missing rockchip,grf property\n", __func__);
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ regmap_write(bsp_priv->grf, RK3308_GRF_MAC_CON0,
|
|
+ RK3308_MAC_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;
|
|
+ int ret;
|
|
+
|
|
+ if (IS_ERR(bsp_priv->clk_mac_speed)) {
|
|
+ dev_err(dev, "%s: Missing clk_mac_speed clock\n", __func__);
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ if (speed == 10) {
|
|
+ regmap_write(bsp_priv->grf, RK3308_GRF_MAC_CON0,
|
|
+ RK3308_MAC_SPEED_10M);
|
|
+
|
|
+ ret = clk_set_rate(bsp_priv->clk_mac_speed, 2500000);
|
|
+ if (ret)
|
|
+ dev_err(dev, "%s: set clk_mac_speed rate 2500000 failed: %d\n",
|
|
+ __func__, ret);
|
|
+ } else if (speed == 100) {
|
|
+ regmap_write(bsp_priv->grf, RK3308_GRF_MAC_CON0,
|
|
+ Rk3308_MAC_SPEED_100M);
|
|
+
|
|
+ ret = clk_set_rate(bsp_priv->clk_mac_speed, 25000000);
|
|
+ if (ret)
|
|
+ dev_err(dev, "%s: set clk_mac_speed rate 25000000 failed: %d\n",
|
|
+ __func__, ret);
|
|
+
|
|
+ } 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 +1535,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.25.1
|
|
|