diff options
author | Philippe Schenker <philippe.schenker@toradex.com> | 2020-03-03 14:55:30 +0100 |
---|---|---|
committer | Philippe Schenker <philippe.schenker@toradex.com> | 2020-03-04 19:02:57 +0100 |
commit | bb42adac48a97341f9339aa4d183ed739fa47181 (patch) | |
tree | b69c1c332d52795c06756ac8f588c4ab7aac3ff9 | |
parent | 45b974df04d7f47d89a90a930731e532aba0cb99 (diff) |
net: phy: micrel: Add KSZ9131 rxdll txdll bypass dt properties
With this patch one is able to control the rx dll and tx dll bypass
bits, hence the 2ns delay on rxc and txc lines in devicetree.
Related-to: ELB-1299
Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
-rw-r--r-- | drivers/net/phy/micrel.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 9c21508332dc..4ab203e2c4ce 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -646,6 +646,42 @@ static int ksz9131_of_load_skew_values(struct phy_device *phydev, return ksz9031_extended_write(phydev, OP_DATA, 2, reg, newval); } +#define KSZ9131_RX_DLL_CTRL 0x4c +#define KSZ9131_TX_DLL_CTRL 0x4d +#define KSZ9131_DLL_CTRL_BYPASS BIT(12) + +static int ksz9131_of_load_dll_skew(struct phy_device *phydev, + struct device_node *of_node) +{ + int ret; + u16 tmp; + u32 val; + + if (!of_property_read_u32(of_node, "rxc-dll-2ns", &val)) { + tmp = phy_read_mmd(phydev, 2, KSZ9131_RX_DLL_CTRL); + if (val == 0) + tmp |= KSZ9131_DLL_CTRL_BYPASS; + if (val == 1) + tmp &= ~KSZ9131_DLL_CTRL_BYPASS; + ret = phy_write_mmd(phydev, 2, KSZ9131_RX_DLL_CTRL, tmp); + if (ret < 0) + return ret; + } + + if (!of_property_read_u32(of_node, "txc-dll-2ns", &val)) { + tmp = phy_read_mmd(phydev, 2, KSZ9131_TX_DLL_CTRL); + if (val == 0) + tmp |= KSZ9131_DLL_CTRL_BYPASS; + if (val == 1) + tmp &= ~KSZ9131_DLL_CTRL_BYPASS; + ret = phy_write_mmd(phydev, 2, KSZ9131_TX_DLL_CTRL, tmp); + if (ret < 0) + return ret; + } + + return 0; +} + static int ksz9131_config_init(struct phy_device *phydev) { const struct device *dev = &phydev->mdio.dev; @@ -672,6 +708,8 @@ static int ksz9131_config_init(struct phy_device *phydev) if (!of_node) return 0; + ksz9131_of_load_dll_skew(phydev, of_node); + ret = ksz9131_of_load_skew_values(phydev, of_node, MII_KSZ9031RN_CLK_PAD_SKEW, 5, clk_skews, 2); |