mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-01-21 08:23:25 +07:00
net: ethernet: fec: Allow configuration of MDIO bus speed
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. Before using this property, ensure all devices on the bus do actually support the requested clock speed. Suggested-by: Chris Healy <Chris.Healy@zii.aero> Signed-off-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
29ae6bd1b0
commit
3e782985cb
@ -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>;
|
||||
|
@ -39,6 +39,12 @@ 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. Values greater than IEEE 802.3
|
||||
defined 2.5MHz should only be used when all devices on the bus support
|
||||
the given clock speed.
|
||||
|
||||
patternProperties:
|
||||
"^ethernet-phy@[0-9a-f]+$":
|
||||
type: object
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user