From 45512d9b989d458d74137b4f04c3757ed6f6d695 Mon Sep 17 00:00:00 2001 From: Zhuo Wang Date: Wed, 12 Jun 2019 16:07:22 +0800 Subject: [PATCH] ethernet: add interface to delay rx/tx clk [1/1] PD#SWPL-9720 Problem: difference window area between chips Solution: add interface to custom Verify: verify on g12a u200 board Change-Id: I589c890e36961f533bffae557337b24a09f1bf41 Signed-off-by: Zhuo Wang --- drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c | 4 ++++ drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h | 3 ++- drivers/net/phy/realtek.c | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c index 1235225..3fe1544 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c @@ -377,6 +377,10 @@ static void __iomem *g12a_network_interface_setup(struct platform_device *pdev) /*config extern phy*/ if (internal_phy == 0) { + if (of_property_read_u32(np, "tx_delay", &external_tx_delay)) + pr_debug("set exphy tx delay\n"); + if (of_property_read_u32(np, "rx_delay", &external_rx_delay)) + pr_debug("set exphy rx delay\n"); /* only exphy support wol since g12a*/ /*we enable/disable wol with item in dts with "wol=<1>"*/ if (of_property_read_u32(np, "wol", diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h index a902bb6..5b44e9b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h @@ -33,6 +33,8 @@ int stmmac_pltfr_remove(struct platform_device *pdev); #ifdef CONFIG_AMLOGIC_ETH_PRIVE int stmmac_pltfr_suspend(struct device *dev); int stmmac_pltfr_resume(struct device *dev); +extern unsigned int external_rx_delay; +extern unsigned int external_tx_delay; #endif extern const struct dev_pm_ops stmmac_pltfr_pm_ops; @@ -43,5 +45,4 @@ static inline void *get_stmmac_bsp_priv(struct device *dev) return priv->plat->bsp_priv; } - #endif /* __STMMAC_PLATFORM_H__ */ diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index 68c27b5..5adeeb8 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -50,6 +50,8 @@ static int wol_enable = 0; #ifdef CONFIG_AMLOGIC_ETH_PRIVE unsigned int support_external_phy_wol; +unsigned int external_rx_delay; +unsigned int external_tx_delay; #endif static int __init init_wol_state(char *str) @@ -190,6 +192,20 @@ static int rtl8211f_config_init(struct phy_device *phydev) phy_write(phydev, 0x11, reg); #ifdef CONFIG_AMLOGIC_ETH_PRIVE + if (external_rx_delay) { + /*add 2ns delay for rx*/ + phy_write(phydev, RTL8211F_PAGE_SELECT, 0xd08); + reg = phy_read(phydev, 0x15); + reg = phy_write(phydev, 0x15, reg | 0x8); + phy_write(phydev, RTL8211F_PAGE_SELECT, 0x0); + } + if (external_tx_delay) { + /*add 2ns delay for tx*/ + phy_write(phydev, RTL8211F_PAGE_SELECT, 0xd08); + reg = phy_read(phydev, 0x11); + reg = phy_write(phydev, 0x11, reg | 0x100); + phy_write(phydev, RTL8211F_PAGE_SELECT, 0x0); + } /*disable clk_out pin 35 set page 0x0a43 reg25.0 as 0*/ phy_write(phydev, RTL8211F_PAGE_SELECT, 0x0a43); reg = phy_read(phydev, 0x19); -- 2.7.4