linux/drivers/net/mdio
Christian Marangi bdce82e960 net: mdio: ipq4019: add support for clock-frequency property
The IPQ4019 MDIO internally divide the clock feed by AHB based on the
MDIO_MODE reg. On reset or power up, the default value for the
divider is 0xff that reflect the divider set to /256.

This makes the MDC run at a very low rate, that is, considering AHB is
always fixed to 100Mhz, a value of 390KHz.

This hasn't have been a problem as MDIO wasn't used for time sensitive
operation, it is now that on IPQ807x is usually mounted with PHY that
requires MDIO to load their firmware (example Aquantia PHY).

To handle this problem and permit to set the correct designed MDC
frequency for the SoC add support for the standard "clock-frequency"
property for the MDIO node.

The divider supports value from /1 to /256 and the common value are to
set it to /16 to reflect 6.25Mhz or to /8 on newer platform to reflect
12.5Mhz.

To scan if the requested rate is supported by the divider, loop with
each supported divider and stop when the requested rate match the final
rate with the current divider. An error is returned if the rate doesn't
match any value.

On MDIO reset, the divider is restored to the requested value to prevent
any kind of downclocking caused by the divider reverting to a default
value.

To follow 802.3 spec of 2.5MHz of default value, if divider is set at
/256 and "clock-frequency" is not set in DT, assume nobody set the
divider and try to find the closest MDC rate to 2.5MHz. (in the case of
AHB set to 100MHz, it's 1.5625MHz)

While at is also document other bits of the MDIO_MODE reg to have a
clear idea of what is actually applied there.

Documentation of some BITs is skipped as they are marked as reserved and
their usage is not clear (RES 11:9 GENPHY 16:13 RES1 19:17)

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
2024-02-02 10:08:02 +00:00
..
acpi_mdio.c net: mdio: fill in missing MODULE_DESCRIPTION()s 2023-11-01 21:50:57 -07:00
fwnode_mdio.c net: mdio: fill in missing MODULE_DESCRIPTION()s 2023-11-01 21:50:57 -07:00
Kconfig net: mdio: Introduce a regmap-based mdio driver 2023-06-05 09:56:36 +01:00
Makefile net: mdio: Introduce a regmap-based mdio driver 2023-06-05 09:56:36 +01:00
mdio-aspeed.c net: mdio: fill in missing MODULE_DESCRIPTION()s 2023-11-01 21:50:57 -07:00
mdio-bcm-iproc.c net: mdio: bcm-iproc: Convert to platform remove callback returning void 2023-09-20 10:29:33 +01:00
mdio-bcm-unimac.c net: mdio: mdio-bcm-unimac: Use read_poll_timeout 2023-12-14 17:58:58 -08:00
mdio-bitbang.c net: mdio: fill in missing MODULE_DESCRIPTION()s 2023-11-01 21:50:57 -07:00
mdio-cavium.c net: mdio: cavium: Remove unneeded simicolons 2023-01-17 13:19:05 +01:00
mdio-cavium.h net: mdio: cavium: Separate C22 and C45 transactions 2023-01-13 21:40:53 -08:00
mdio-gpio.c net: mdio-gpio: replace deprecated strncpy with strscpy 2023-12-12 16:00:02 -08:00
mdio-hisi-femac.c net: mdio: hisi-femac: Convert to platform remove callback returning void 2023-09-20 10:29:33 +01:00
mdio-i2c.c net: mdio: i2c: fix rollball accessors 2023-05-15 10:15:57 +01:00
mdio-ipq4019.c net: mdio: ipq4019: add support for clock-frequency property 2024-02-02 10:08:02 +00:00
mdio-ipq8064.c net: mdio: ipq8064: Convert to platform remove callback returning void 2023-09-20 10:29:34 +01:00
mdio-moxart.c net: mdio: moxart: Convert to platform remove callback returning void 2023-09-20 10:29:34 +01:00
mdio-mscc-miim.c net: mdio: mscc-miim: Convert to platform remove callback returning void 2023-09-20 10:29:34 +01:00
mdio-mux-bcm-iproc.c net: mdio: mux-bcm-iproc: Use alignment helpers and SZ_4K 2024-01-03 16:40:59 -08:00
mdio-mux-bcm6368.c net: mdio: mux-bcm6368: Convert to platform remove callback returning void 2023-09-20 10:29:34 +01:00
mdio-mux-gpio.c net: mdio: mux-gpio: Convert to platform remove callback returning void 2023-09-20 10:29:34 +01:00
mdio-mux-meson-g12a.c net: mdio: mux-meson-g12a: Convert to platform remove callback returning void 2023-09-20 10:29:34 +01:00
mdio-mux-meson-gxl.c net: mdio: mux-meson-gxl: Convert to platform remove callback returning void 2023-09-20 10:29:34 +01:00
mdio-mux-mmioreg.c net: mdio: mux-mmioreg: Convert to platform remove callback returning void 2023-09-20 10:29:34 +01:00
mdio-mux-multiplexer.c net: mdio: mux-multiplexer: Convert to platform remove callback returning void 2023-09-20 10:29:34 +01:00
mdio-mux.c net: mdio-mux: be compatible with parent buses which only support C45 2023-12-14 18:55:38 -08:00
mdio-mvusb.c net: mdio: mvusb: Fix an error handling path in mvusb_mdio_probe() 2023-05-07 14:59:02 +01:00
mdio-octeon.c net: mdio: octeon: Convert to platform remove callback returning void 2023-09-20 10:29:35 +01:00
mdio-regmap.c net: mdio: Introduce a regmap-based mdio driver 2023-06-05 09:56:36 +01:00
mdio-sun4i.c net: mdio: sun4i: Convert to platform remove callback returning void 2023-09-20 10:29:35 +01:00
mdio-thunder.c net: mdio: thunder: Add missing fwnode_handle_put() 2023-03-23 08:46:55 +00:00
mdio-xgene.c net: mdio: xgene: Fix unused xgene_mdio_of_match warning for !CONFIG_OF 2023-10-23 10:16:47 -07:00
of_mdio.c Revert "net: mdio: get/put device node during (un)registration" 2024-01-02 14:23:39 -08:00