From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
To: davem@davemloft.net, netdev@vger.kernel.org,
devicetree@vger.kernel.org, linux-amlogic@lists.infradead.org
Cc: robh+dt@kernel.org, mark.rutland@arm.com, carlo@caione.org,
khilman@baylibre.com, narmstrong@baylibre.com,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Subject: [PATCH net-next v5 2/2] net: stmmac: dwmac-meson8b: make the RGMII TX delay configurable
Date: Sun, 22 Jan 2017 23:02:46 +0100 [thread overview]
Message-ID: <20170122220246.13602-3-martin.blumenstingl@googlemail.com> (raw)
In-Reply-To: <20170122220246.13602-1-martin.blumenstingl@googlemail.com>
Prior to this patch we were using a hardcoded RGMII TX clock delay of
2ns (= 1/4 cycle of the 125MHz RGMII TX clock). This value works for
many boards, but unfortunately not for all (due to the way the actual
circuit is designed, sometimes because the TX delay is enabled in the
PHY, etc.). Making the TX delay on the MAC side configurable allows us
to support all possible hardware combinations.
This allows fixing a compatibility issue on some boards, where the
RTL8211F PHY is configured to generate the TX delay. We can now turn
off the TX delay in the MAC, because otherwise we would be applying the
delay twice (which results in non-working TX traffic).
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Tested-by: Neil Armstrong <narmstrong@baylibre.com>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
index ffaed1f35efe..8840a360a0b7 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
@@ -35,10 +35,6 @@
#define PRG_ETH0_TXDLY_SHIFT 5
#define PRG_ETH0_TXDLY_MASK GENMASK(6, 5)
-#define PRG_ETH0_TXDLY_OFF (0x0 << PRG_ETH0_TXDLY_SHIFT)
-#define PRG_ETH0_TXDLY_QUARTER (0x1 << PRG_ETH0_TXDLY_SHIFT)
-#define PRG_ETH0_TXDLY_HALF (0x2 << PRG_ETH0_TXDLY_SHIFT)
-#define PRG_ETH0_TXDLY_THREE_QUARTERS (0x3 << PRG_ETH0_TXDLY_SHIFT)
/* divider for the result of m250_sel */
#define PRG_ETH0_CLK_M250_DIV_SHIFT 7
@@ -69,6 +65,8 @@ struct meson8b_dwmac {
struct clk_divider m25_div;
struct clk *m25_div_clk;
+
+ u32 tx_delay_ns;
};
static void meson8b_dwmac_mask_bits(struct meson8b_dwmac *dwmac, u32 reg,
@@ -179,6 +177,7 @@ static int meson8b_init_prg_eth(struct meson8b_dwmac *dwmac)
{
int ret;
unsigned long clk_rate;
+ u8 tx_dly_val;
switch (dwmac->phy_mode) {
case PHY_INTERFACE_MODE_RGMII:
@@ -196,9 +195,13 @@ static int meson8b_init_prg_eth(struct meson8b_dwmac *dwmac)
meson8b_dwmac_mask_bits(dwmac, PRG_ETH0,
PRG_ETH0_INVERTED_RMII_CLK, 0);
- /* TX clock delay - all known boards use a 1/4 cycle delay */
+ /* TX clock delay in ns = "8ns / 4 * tx_dly_val" (where
+ * 8ns are exactly one cycle of the 125MHz RGMII TX clock):
+ * 0ns = 0x0, 2ns = 0x1, 4ns = 0x2, 6ns = 0x3
+ */
+ tx_dly_val = dwmac->tx_delay_ns >> 1;
meson8b_dwmac_mask_bits(dwmac, PRG_ETH0, PRG_ETH0_TXDLY_MASK,
- PRG_ETH0_TXDLY_QUARTER);
+ tx_dly_val << PRG_ETH0_TXDLY_SHIFT);
break;
case PHY_INTERFACE_MODE_RMII:
@@ -284,6 +287,11 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
goto err_remove_config_dt;
}
+ /* use 2ns as fallback since this value was previously hardcoded */
+ if (of_property_read_u32(pdev->dev.of_node, "amlogic,tx-delay-ns",
+ &dwmac->tx_delay_ns))
+ dwmac->tx_delay_ns = 2;
+
ret = meson8b_init_clk(dwmac);
if (ret)
goto err_remove_config_dt;
--
2.11.0
next prev parent reply other threads:[~2017-01-22 22:02 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-24 14:34 [net-next PATCH v1 0/2] stmmac: dwmac-meson8b: configurable RGMII TX delay Martin Blumenstingl
[not found] ` <20161124143417.10178-1-martin.blumenstingl-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
2016-11-24 14:34 ` [net-next PATCH v1 1/2] net: dt-bindings: add RGMII TX delay configuration to meson8b-dwmac Martin Blumenstingl
2016-11-24 15:48 ` Andrew Lunn
[not found] ` <20161124154858.GB20455-g2DYL2Zd6BY@public.gmane.org>
2016-11-24 16:52 ` Martin Blumenstingl
2016-11-24 14:34 ` [net-next PATCH v1 2/2] net: stmmac: dwmac-meson8b: make the RGMII TX delay configurable Martin Blumenstingl
2016-11-24 15:56 ` [net-next PATCH v1 0/2] stmmac: dwmac-meson8b: configurable RGMII TX delay Jerome Brunet
[not found] ` <1480002964.17538.131.camel-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>
2016-11-24 17:05 ` Martin Blumenstingl
[not found] ` <CAFBinCB7sXjXor++W+PW0-j_VxATRzhexjqHgXj2jD10tBpZFg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-11-24 18:55 ` Florian Fainelli
2016-11-25 0:41 ` Martin Blumenstingl
2016-11-25 11:13 ` Sebastian Frias
2016-11-25 12:01 ` Måns Rullgård
[not found] ` <6a6af561-4e83-ca6e-d989-f421e18bce1e-QFKgK+z4sOrR7s880joybQ@public.gmane.org>
2016-11-25 17:44 ` Florian Fainelli
[not found] ` <1b7f113e-34f9-69f4-a45f-9fd687d87990-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-11-28 10:34 ` Sebastian Frias
2016-11-25 9:53 ` Jerome Brunet
2016-11-24 16:08 ` Jerome Brunet
[not found] ` <1480003681.17538.142.camel-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>
2016-11-25 8:59 ` Giuseppe CAVALLARO
2016-11-25 13:01 ` [PATCH v2 0/7] " Martin Blumenstingl
2016-11-25 13:01 ` [PATCH v2 1/7] net: dt-bindings: add RGMII TX delay configuration to meson8b-dwmac Martin Blumenstingl
[not found] ` <20161125130156.17879-2-martin.blumenstingl-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
2016-11-30 21:44 ` Rob Herring
2016-11-30 22:33 ` Martin Blumenstingl
2016-11-25 13:01 ` [PATCH v2 2/7] net: stmmac: dwmac-meson8b: make the RGMII TX delay configurable Martin Blumenstingl
2016-11-25 13:01 ` [PATCH v2 3/7] ARM64: dts: meson-gx: move the MDIO node to meson-gx Martin Blumenstingl
[not found] ` <20161125130156.17879-1-martin.blumenstingl-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
2016-11-25 13:01 ` [PATCH v2 4/7] ARM64: dts: meson-gxbb-odroidc2: add reset for the ethernet PHY Martin Blumenstingl
2016-11-25 13:01 ` [PATCH v2 5/7] ARM64: dts: meson-gxbb-p20x: " Martin Blumenstingl
2016-11-25 13:01 ` [PATCH v2 6/7] ARM64: dts: meson-gxbb-vega-s95: " Martin Blumenstingl
2016-11-25 13:01 ` [PATCH v2 7/7] ARM64: dts: amlogic: add the ethernet TX delay configuration Martin Blumenstingl
2016-11-28 1:33 ` [PATCH v2 0/7] stmmac: dwmac-meson8b: configurable RGMII TX delay David Miller
[not found] ` <20161127.203324.1634866862730391239.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2016-12-02 23:52 ` Martin Blumenstingl
2016-12-02 23:32 ` [PATCH net-next v3 0/2] " Martin Blumenstingl
2016-12-02 23:32 ` [PATCH net-next v3 1/2] net: dt-bindings: add RGMII TX delay configuration to meson8b-dwmac Martin Blumenstingl
[not found] ` <20161202233238.17561-2-martin.blumenstingl-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
2016-12-09 21:31 ` Rob Herring
2016-12-02 23:32 ` [PATCH net-next v3 2/2] net: stmmac: dwmac-meson8b: make the RGMII TX delay configurable Martin Blumenstingl
[not found] ` <20161202233238.17561-1-martin.blumenstingl-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
2016-12-17 18:21 ` [PATCH net-next v4 0/2] stmmac: dwmac-meson8b: configurable RGMII TX delay Martin Blumenstingl
2016-12-17 18:21 ` [PATCH net-next v4 1/2] net: dt-bindings: add RGMII TX delay configuration to meson8b-dwmac Martin Blumenstingl
2016-12-17 18:21 ` [PATCH net-next v4 2/2] net: stmmac: dwmac-meson8b: make the RGMII TX delay configurable Martin Blumenstingl
2016-12-18 15:49 ` David Miller
2016-12-18 16:13 ` Martin Blumenstingl
2017-01-09 17:37 ` Martin Blumenstingl
2017-01-20 13:47 ` Martin Blumenstingl
2017-01-22 22:02 ` [PATCH net-next v5 0/2] stmmac: dwmac-meson8b: configurable RGMII TX delay Martin Blumenstingl
[not found] ` <20170122220246.13602-1-martin.blumenstingl-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
2017-01-22 22:02 ` [PATCH net-next v5 1/2] net: dt-bindings: add RGMII TX delay configuration to meson8b-dwmac Martin Blumenstingl
2017-01-24 18:36 ` [PATCH net-next v5 0/2] stmmac: dwmac-meson8b: configurable RGMII TX delay David Miller
2017-01-22 22:02 ` Martin Blumenstingl [this message]
2016-11-25 13:41 ` [PATCH v2 0/7] " David Laight
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=20170122220246.13602-3-martin.blumenstingl@googlemail.com \
--to=martin.blumenstingl@googlemail.com \
--cc=carlo@caione.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=khilman@baylibre.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=narmstrong@baylibre.com \
--cc=netdev@vger.kernel.org \
--cc=robh+dt@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).