All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vinod Koul <vkoul@kernel.org>
To: "David S . Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	Niklas Cassel <niklas.cassel@linaro.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Vinod Koul <vkoul@kernel.org>, Andrew Lunn <andrew@lunn.ch>,
	Florian Fainelli <f.fainelli@gmail.com>
Subject: [PATCH 6/7] net: phy: at803x: Add support to disable tx/rx delays
Date: Wed,  2 Jan 2019 14:47:28 +0530	[thread overview]
Message-ID: <20190102091729.18582-7-vkoul@kernel.org> (raw)
In-Reply-To: <20190102091729.18582-1-vkoul@kernel.org>

Some controllers require the tx and rx delays to be disabled. So check
the property and if present do not enable the delay and disable the
delay explicitly.

Signed-off-by: Vinod Koul <vkoul@kernel.org>
---
 drivers/net/phy/at803x.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index 63e3d3d774d1..9bfc0d381159 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -122,6 +122,17 @@ static inline int at803x_enable_tx_delay(struct phy_device *phydev)
 					AT803X_DEBUG_TX_CLK_DLY_EN);
 }
 
+static inline int at803x_disable_rx_delay(struct phy_device *phydev)
+{
+	return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_0,
+					AT803X_DEBUG_RX_CLK_DLY_EN, 0);
+}
+
+static inline int at803x_disable_tx_delay(struct phy_device *phydev)
+{
+	return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_5,
+					AT803X_DEBUG_TX_CLK_DLY_EN, 0);
+}
 /* save relevant PHY registers to private copy */
 static void at803x_context_save(struct phy_device *phydev,
 				struct at803x_context *context)
@@ -250,12 +261,18 @@ static int at803x_probe(struct phy_device *phydev)
 static int at803x_config_init(struct phy_device *phydev)
 {
 	bool rx_delay = false, tx_delay = false;
+	bool rx_disable_prop, tx_disable_prop;
 	int ret;
 
 	ret = genphy_config_init(phydev);
 	if (ret < 0)
 		return ret;
 
+	rx_disable_prop = device_property_read_bool(&phydev->mdio.dev,
+						    "rx-delay-disable");
+	tx_disable_prop = device_property_read_bool(&phydev->mdio.dev,
+						    "rx-delay-disable");
+
 	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID ||
 			phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
 		rx_delay = true;
@@ -263,6 +280,12 @@ static int at803x_config_init(struct phy_device *phydev)
 			phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
 		tx_delay = true;
 
+	/* if DT specified disable delay then don't enable it */
+	if (rx_disable_prop)
+		rx_delay = false;
+	if (tx_disable_prop)
+		tx_delay = false;
+
 	if (rx_delay) {
 		ret = at803x_enable_rx_delay(phydev);
 		if (ret < 0)
@@ -275,6 +298,19 @@ static int at803x_config_init(struct phy_device *phydev)
 			return ret;
 	}
 
+	/* if DT specified disable delay then disable it explicitly */
+	if (rx_disable_prop) {
+		ret = at803x_disable_rx_delay(phydev);
+		if (ret < 0)
+			return ret;
+	}
+
+	if (tx_disable_prop) {
+		ret = at803x_disable_tx_delay(phydev);
+		if (ret < 0)
+			return ret;
+	}
+
 	return 0;
 }
 
-- 
2.20.1

  parent reply	other threads:[~2019-01-02  9:19 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-02  9:17 [PATCH 0/7] net: Add support for Qualcomm ethqos Vinod Koul
2019-01-02  9:17 ` [PATCH 1/7] dt-bindings: net: Add Qualcomm ethqos binding Vinod Koul
2019-01-02 14:07   ` Andrew Lunn
2019-01-02 14:07     ` Andrew Lunn
2019-01-02 14:37     ` Vinod Koul
2019-01-02 14:37       ` Vinod Koul
2019-01-02  9:17 ` [PATCH 2/7] net: stmmac: Add driver for Qualcomm ethqos Vinod Koul
2019-01-02  9:17 ` [PATCH 3/7] dt-bindings: net: stmmac: Add the bindings documentation for delays Vinod Koul
2019-01-11 15:01   ` Rob Herring
2019-01-11 15:01     ` Rob Herring
2019-01-14 15:26     ` Vinod Koul
2019-01-14 15:26       ` Vinod Koul
2019-01-14 23:34     ` Florian Fainelli
2019-01-14 23:34       ` Florian Fainelli
2019-01-02  9:17 ` [PATCH 4/7] MAINTAINER: Add entry for Qualcomm ETHQOS ethernet driver Vinod Koul
2019-01-02  9:48   ` Sergei Shtylyov
2019-01-02 10:15     ` Vinod Koul
2019-01-02  9:17 ` [PATCH 5/7] net: phy: at803x: Rework at803x_config_init() Vinod Koul
2019-01-02  9:17 ` Vinod Koul [this message]
2019-01-02 13:40   ` [PATCH 6/7] net: phy: at803x: Add support to disable tx/rx delays Andrew Lunn
2019-01-02 13:40     ` Andrew Lunn
2019-01-02 14:36     ` Vinod Koul
2019-01-02 14:36       ` Vinod Koul
2019-01-02  9:17 ` [PATCH 7/7] net: dsa: qca8k: handle disable tx/rx delay Vinod Koul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190102091729.18582-7-vkoul@kernel.org \
    --to=vkoul@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=bjorn.andersson@linaro.org \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=netdev@vger.kernel.org \
    --cc=niklas.cassel@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.