From: Andrew Lunn <andrew@lunn.ch>
To: David Miller <davem@davemloft.net>
Cc: netdev <netdev@vger.kernel.org>,
Florian Fainelli <f.fainelli@gmail.com>,
Heiner Kallweit <hkallweit1@gmail.com>,
fugang.duan@nxp.com, Andrew Lunn <andrew@lunn.ch>,
Chris Healy <Chris.Healy@zii.aero>
Subject: [PATCH net-next v2 2/3] net: ethernet: fec: Allow configuration of MDIO bus speed
Date: Sat, 18 Apr 2020 02:03:54 +0200 [thread overview]
Message-ID: <20200418000355.804617-3-andrew@lunn.ch> (raw)
In-Reply-To: <20200418000355.804617-1-andrew@lunn.ch>
MDIO busses typically operate at 2.5MHz. However many devices can
operate at faster speeds. This then allows more MDIO transactions per
second, useful for Ethernet switch statistics, or Ethernet PHY TDR
data. Allow the bus speed to be configured, using the standard
"clock-frequency" property, which i2c busses use to indicate the bus
speed.
Suggested-by: Chris Healy <Chris.Healy@zii.aero>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
Documentation/devicetree/bindings/net/fsl-fec.txt | 1 +
Documentation/devicetree/bindings/net/mdio.yaml | 4 ++++
drivers/net/ethernet/freescale/fec_main.c | 11 ++++++++---
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/Documentation/devicetree/bindings/net/fsl-fec.txt b/Documentation/devicetree/bindings/net/fsl-fec.txt
index ff8b0f211aa1..26c492a2e0e1 100644
--- a/Documentation/devicetree/bindings/net/fsl-fec.txt
+++ b/Documentation/devicetree/bindings/net/fsl-fec.txt
@@ -82,6 +82,7 @@ ethernet@83fec000 {
phy-supply = <®_fec_supply>;
phy-handle = <ðphy>;
mdio {
+ clock-frequency = <5000000>;
ethphy: ethernet-phy@6 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <6>;
diff --git a/Documentation/devicetree/bindings/net/mdio.yaml b/Documentation/devicetree/bindings/net/mdio.yaml
index 50c3397a82bc..bcd457c54cd7 100644
--- a/Documentation/devicetree/bindings/net/mdio.yaml
+++ b/Documentation/devicetree/bindings/net/mdio.yaml
@@ -39,6 +39,10 @@ properties:
and must therefore be appropriately determined based on all PHY
requirements (maximum value of all per-PHY RESET pulse widths).
+ clock-frequency:
+ description:
+ Desired MDIO bus clock frequency in Hz.
+
patternProperties:
"^ethernet-phy@[0-9a-f]+$":
type: object
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 6530829632b1..28ef0abfa660 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2067,6 +2067,7 @@ static int fec_enet_mii_init(struct platform_device *pdev)
struct device_node *node;
int err = -ENXIO;
u32 mii_speed, holdtime;
+ u32 bus_freq;
/*
* The i.MX28 dual fec interfaces are not equal.
@@ -2094,15 +2095,20 @@ static int fec_enet_mii_init(struct platform_device *pdev)
return -ENOENT;
}
+ bus_freq = 2500000; /* 2.5MHz by default */
+ node = of_get_child_by_name(pdev->dev.of_node, "mdio");
+ if (node)
+ of_property_read_u32(node, "clock-frequency", &bus_freq);
+
/*
- * Set MII speed to 2.5 MHz (= clk_get_rate() / 2 * phy_speed)
+ * Set MII speed (= clk_get_rate() / 2 * phy_speed)
*
* The formula for FEC MDC is 'ref_freq / (MII_SPEED x 2)' while
* for ENET-MAC is 'ref_freq / ((MII_SPEED + 1) x 2)'. The i.MX28
* Reference Manual has an error on this, and gets fixed on i.MX6Q
* document.
*/
- mii_speed = DIV_ROUND_UP(clk_get_rate(fep->clk_ipg), 5000000);
+ mii_speed = DIV_ROUND_UP(clk_get_rate(fep->clk_ipg), bus_freq * 2);
if (fep->quirks & FEC_QUIRK_ENET_MAC)
mii_speed--;
if (mii_speed > 63) {
@@ -2148,7 +2154,6 @@ static int fec_enet_mii_init(struct platform_device *pdev)
fep->mii_bus->priv = fep;
fep->mii_bus->parent = &pdev->dev;
- node = of_get_child_by_name(pdev->dev.of_node, "mdio");
err = of_mdiobus_register(fep->mii_bus, node);
of_node_put(node);
if (err)
--
2.26.1
next prev parent reply other threads:[~2020-04-18 0:04 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-18 0:03 [PATCH net-next v2 0/3] FEC MDIO speedups Andrew Lunn
2020-04-18 0:03 ` [PATCH net-next v2 1/3] net: ethernet: fec: Replace interrupt driven MDIO with polled IO Andrew Lunn
2020-04-18 13:55 ` [EXT] " Andy Duan
2020-04-18 22:39 ` Chris Healy
2020-04-19 0:35 ` Andrew Lunn
2020-04-19 6:22 ` Andy Duan
2020-04-19 20:47 ` Andrew Lunn
2020-04-18 16:21 ` Fabio Estevam
2020-04-18 21:06 ` Florian Fainelli
2020-04-18 0:03 ` Andrew Lunn [this message]
2020-04-18 0:34 ` [PATCH net-next v2 2/3] net: ethernet: fec: Allow configuration of MDIO bus speed Florian Fainelli
2020-04-18 14:23 ` Andrew Lunn
2020-04-18 16:01 ` Florian Fainelli
2020-04-18 16:49 ` Andrew Lunn
2020-04-18 21:07 ` Florian Fainelli
2020-04-18 21:08 ` Florian Fainelli
2020-04-18 0:03 ` [PATCH net-next v2 3/3] net: ethernet: fec: Allow the MDIO preamble to be disabled Andrew Lunn
2020-04-18 0:39 ` Florian Fainelli
2020-04-18 14:27 ` Andrew Lunn
2020-04-18 16:02 ` Florian Fainelli
2020-04-18 21:09 ` Florian Fainelli
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=20200418000355.804617-3-andrew@lunn.ch \
--to=andrew@lunn.ch \
--cc=Chris.Healy@zii.aero \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=fugang.duan@nxp.com \
--cc=hkallweit1@gmail.com \
--cc=netdev@vger.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).