target/rockchip: r2s gmac auto delay based on phy id
This commit is contained in:
parent
37bb4095a2
commit
7a358d4f9b
@ -0,0 +1,36 @@
|
||||
From a0b57de81e4ecb47f5655bdab3284c4732d830a1 Mon Sep 17 00:00:00 2001
|
||||
From: jjm2473 <1129525450@qq.com>
|
||||
Date: Thu, 9 Feb 2023 01:08:22 +0800
|
||||
Subject: [PATCH] rockchip: rk3328: add delay config to NanoPi R2S ethernet MAC
|
||||
|
||||
---
|
||||
arch/arm64/boot/dts/rockchip/rk3328-nanopi-r2s.dts | 13 +++++++++++++
|
||||
1 file changed, 13 insertions(+)
|
||||
|
||||
diff --git a/arch/arm64/boot/dts/rockchip/rk3328-nanopi-r2s.dts b/arch/arm64/boot/dts/rockchip/rk3328-nanopi-r2s.dts
|
||||
index 4c611594d..ca05e820e 100644
|
||||
--- a/arch/arm64/boot/dts/rockchip/rk3328-nanopi-r2s.dts
|
||||
+++ b/arch/arm64/boot/dts/rockchip/rk3328-nanopi-r2s.dts
|
||||
@@ -163,6 +163,19 @@
|
||||
reset-gpios = <&gpio1 RK_PC2 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
};
|
||||
+
|
||||
+ delay_cfg {
|
||||
+ rtl8211e {
|
||||
+ phy_id = <0x001cc915>;
|
||||
+ rx_delay = <0x18>;
|
||||
+ tx_delay = <0x24>;
|
||||
+ };
|
||||
+ yt8521s {
|
||||
+ phy_id = <0x0000011a>;
|
||||
+ rx_delay = <0x12>;
|
||||
+ tx_delay = <0x22>;
|
||||
+ };
|
||||
+ };
|
||||
};
|
||||
|
||||
&i2c1 {
|
||||
--
|
||||
2.31.0
|
||||
|
||||
@ -0,0 +1,41 @@
|
||||
From 4c6f48598e0ce29a6f71db88f3ff93f103c83890 Mon Sep 17 00:00:00 2001
|
||||
From: jjm2473 <1129525450@qq.com>
|
||||
Date: Thu, 9 Feb 2023 00:55:56 +0800
|
||||
Subject: [PATCH] net/phylink: add api phylink_get_phy
|
||||
|
||||
---
|
||||
drivers/net/phy/phylink.c | 5 +++++
|
||||
include/linux/phylink.h | 1 +
|
||||
2 files changed, 6 insertions(+)
|
||||
|
||||
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
|
||||
index 496c95e47..e3dc91983 100644
|
||||
--- a/drivers/net/phy/phylink.c
|
||||
+++ b/drivers/net/phy/phylink.c
|
||||
@@ -877,6 +877,11 @@ int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(phylink_of_phy_connect);
|
||||
|
||||
+struct phy_device *phylink_get_phy(struct phylink *pl) {
|
||||
+ return pl->phydev;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(phylink_get_phy);
|
||||
+
|
||||
/**
|
||||
* phylink_disconnect_phy() - disconnect any PHY attached to the phylink
|
||||
* instance.
|
||||
diff --git a/include/linux/phylink.h b/include/linux/phylink.h
|
||||
index 300ecdb67..4df80cd1f 100644
|
||||
--- a/include/linux/phylink.h
|
||||
+++ b/include/linux/phylink.h
|
||||
@@ -238,6 +238,7 @@ struct phylink *phylink_create(struct phylink_config *, struct fwnode_handle *,
|
||||
void phylink_destroy(struct phylink *);
|
||||
|
||||
int phylink_connect_phy(struct phylink *, struct phy_device *);
|
||||
+struct phy_device *phylink_get_phy(struct phylink *);
|
||||
int phylink_of_phy_connect(struct phylink *, struct device_node *, u32 flags);
|
||||
void phylink_disconnect_phy(struct phylink *);
|
||||
int phylink_fixed_state_cb(struct phylink *,
|
||||
--
|
||||
2.31.0
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
From a5c8c7853ce56fef7c820c2670b99f40b757a78e Mon Sep 17 00:00:00 2001
|
||||
From: jjm2473 <1129525450@qq.com>
|
||||
Date: Thu, 9 Feb 2023 01:01:13 +0800
|
||||
Subject: [PATCH] drivers/net/stmmac: add callback to bsp when phy attached
|
||||
|
||||
---
|
||||
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +++++
|
||||
include/linux/stmmac.h | 2 ++
|
||||
2 files changed, 7 insertions(+)
|
||||
|
||||
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
|
||||
index 9cbc0179d..04526788f 100644
|
||||
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
|
||||
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
|
||||
@@ -2651,6 +2651,11 @@ static int stmmac_open(struct net_device *dev)
|
||||
}
|
||||
}
|
||||
|
||||
+ if (priv->plat->fix_phy) {
|
||||
+ // callback bsp when phy attached
|
||||
+ priv->plat->fix_phy(priv->plat->bsp_priv, phylink_get_phy(priv->phylink));
|
||||
+ }
|
||||
+
|
||||
/* Extra statistics */
|
||||
memset(&priv->xstats, 0, sizeof(struct stmmac_extra_stats));
|
||||
priv->xstats.threshold = tc;
|
||||
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
|
||||
index dc60d03c4..04aa2c238 100644
|
||||
--- a/include/linux/stmmac.h
|
||||
+++ b/include/linux/stmmac.h
|
||||
@@ -13,6 +13,7 @@
|
||||
#define __STMMAC_PLATFORM_DATA
|
||||
|
||||
#include <linux/platform_device.h>
|
||||
+#include <linux/phy.h>
|
||||
|
||||
#define MTL_MAX_RX_QUEUES 8
|
||||
#define MTL_MAX_TX_QUEUES 8
|
||||
@@ -179,5 +180,6 @@ struct plat_stmmacenet_data {
|
||||
int mac_port_sel_speed;
|
||||
bool en_tx_lpi_clockgating;
|
||||
int has_xgmac;
|
||||
+ void (*fix_phy)(void *priv, struct phy_device *phy);
|
||||
};
|
||||
#endif
|
||||
--
|
||||
2.31.0
|
||||
|
||||
@ -0,0 +1,70 @@
|
||||
From 6a07ec52fd6e8f595550f0b2eef63b2d5ae9d100 Mon Sep 17 00:00:00 2001
|
||||
From: jjm2473 <1129525450@qq.com>
|
||||
Date: Thu, 9 Feb 2023 14:07:13 +0800
|
||||
Subject: [PATCH] drivers/net/stmmac: dwmac-rk set mac delay on phy attached
|
||||
|
||||
---
|
||||
.../net/ethernet/stmicro/stmmac/dwmac-rk.c | 40 +++++++++++++++++++
|
||||
1 file changed, 40 insertions(+)
|
||||
|
||||
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
|
||||
index 9f9aaa47a..ba2c85213 100644
|
||||
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
|
||||
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
|
||||
@@ -1210,6 +1210,43 @@ static int phy_power_on(struct rk_priv_data *bsp_priv, bool enable)
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static void rk_fix_phy(void *priv, struct phy_device *phy)
|
||||
+{
|
||||
+ int ret;
|
||||
+ int phy_id;
|
||||
+ int tx_delay;
|
||||
+ int rx_delay;
|
||||
+ struct device_node *child;
|
||||
+ struct device_node *delay_cfg;
|
||||
+ struct rk_priv_data *bsp_priv = priv;
|
||||
+ struct device *dev = &bsp_priv->pdev->dev;
|
||||
+
|
||||
+ delay_cfg = of_get_child_by_name(dev->of_node, "delay_cfg");
|
||||
+ if (!delay_cfg) {
|
||||
+ return;
|
||||
+ }
|
||||
+ for_each_available_child_of_node(delay_cfg, child) {
|
||||
+ ret = of_property_read_u32(dev->of_node, "phy_id", &phy_id);
|
||||
+ if (ret)
|
||||
+ continue;
|
||||
+ if (phy_id != phy->phy_id)
|
||||
+ continue;
|
||||
+ ret = of_property_read_u32(dev->of_node, "tx_delay", &tx_delay);
|
||||
+ if (ret)
|
||||
+ break;
|
||||
+ ret = of_property_read_u32(dev->of_node, "rx_delay", &rx_delay);
|
||||
+ if (ret)
|
||||
+ break;
|
||||
+
|
||||
+ dev_info(dev, "Set MAC tx_delay: 0x%x rx_delay: 0x%x for PHY 0x%08x\n", tx_delay, rx_delay, phy->phy_id);
|
||||
+ bsp_priv->ops->set_to_rgmii(bsp_priv, tx_delay,
|
||||
+ rx_delay);
|
||||
+ bsp_priv->tx_delay = tx_delay;
|
||||
+ bsp_priv->rx_delay = rx_delay;
|
||||
+ break;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev,
|
||||
struct plat_stmmacenet_data *plat,
|
||||
const struct rk_gmac_ops *ops)
|
||||
@@ -1272,6 +1309,9 @@ static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev,
|
||||
bsp_priv->rx_delay = value;
|
||||
}
|
||||
|
||||
+ if (bsp_priv->phy_iface == PHY_INTERFACE_MODE_RGMII && of_get_child_by_name(dev->of_node, "delay_cfg"))
|
||||
+ plat->fix_phy = rk_fix_phy;
|
||||
+
|
||||
bsp_priv->grf = syscon_regmap_lookup_by_phandle(dev->of_node,
|
||||
"rockchip,grf");
|
||||
|
||||
--
|
||||
2.31.0
|
||||
|
||||
Loading…
Reference in New Issue
Block a user