summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Schenker <philippe.schenker@toradex.com>2020-03-03 14:55:30 +0100
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2020-03-09 13:45:38 +0100
commitf49da0d7dbf67030f7e12a94fd18a7f1a0b845e0 (patch)
tree66cee0210b66246d70a1f71c0a80969e2edd6bd0
parente87dbd9e5c55cbb3e67903cacde7d8ea80a58ba2 (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.c38
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);