immortalwrt/target/linux
Markus Stockhausen 0f7131baf3 realtek: rework hardware-assisted indirect mdio access
With commit b53202a8c3 ("realtek: switch to use generic MDIO accessor functions")
the phy access logic was enhanced. A quite big kernel patch was introduced that
allowed to make use of hardware-assisted page access like we have in the realtek
target. Basically it works the following way

- The enhanced bus intercepts page write accesses
- Currently selected pages are stored in internal vars.
- Finally only all-in-one-consistent bus/register accesses are issued
- It intercepted page changes and ensured that only a complete bus call

For the details see https://github.com/openwrt/openwrt/pull/16172

Switching over to newer kernels this patch is really hard to maintain. Its heavy
modifcations exist only in the realtek target. So it does not matter if we keep
it as an kernel modification or directly include it in our driver. To make it the
future brighter we drop this patch and take over its logic. Thus the kernel will
stay totally modification-free. What do we do?

1. Up to now the bus->priv structure directly pointed to ethernet->priv. Create an
explicit private structure rtl838x_bus_priv that not only holds the ethernet->priv
pointer but also space for some bus status tracking vars as well.

2. Wherever we use a reference to ethernet->priv directly replace that by an
additional indirection over the new rtl838x_bus_priv structure.

3. Up to now the phy flag PHY_HAS_REALTEK_PAGES identified that we can use the
alternative paged access from the patch. As this will be no longer available
remove it and provide read_page/write_page functions for each possible PHY.
These functions will be pretty standard as for other Realtek PHYs.

4. The existing mdio bus read/write function rely on the classic MII_ADDR_C45
flag - one interface for two access types. This mixup will be removed on the way
to kernel 6.6. In the future there will be two pairs of access functions. One for
classic access one for c45 style access. Rewrite our functions into 3 parts:

- a classic read/write function: ready for kernel 6.6
- a new c45 read/write function: ready for kernel 6.6
- a legacy read/write wrapper: for current 5.15 for the time being

When we switch to 6.6 we only need to remove the legacy wrappers and link the
new functions. Life can be so easy.

5. The classic read/write functions will incorporate the interception logic that
was originally in the patch.

6. The package convenience functions that were embedded in the patch get lost as
well. Rewrite them inside our phy driver.

Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
[Minor checkpatch.pl cleanups]
Signed-off-by: Sander Vanheule <sander@svanheule.net>
2024-09-14 19:58:21 +02:00
..
airoha airoha: drop kernel 6.1 support 2024-06-05 09:34:06 +02:00
apm821xx kernel: rtl8367b: use realtek,extif property 2024-08-06 00:34:14 +02:00
archs38 kernel: activate *_FS_SECURITY and *_FS_ACL_ATTR options for all big flash targets 2024-09-06 22:46:59 +02:00
armsr kernel: bump 6.1 to 6.1.107 2024-08-31 20:11:41 +02:00
at91 at91: 5.15: remove old config and patch files 2024-04-28 17:50:37 +02:00
ath79 kernel: bump 6.6 to 6.6.48 2024-08-31 20:08:13 +02:00
bcm27xx kernel: bump 6.6 to 6.6.50 2024-09-08 21:29:13 +02:00
bcm47xx generic: 6.6: add backported bmips CBR patches 2024-08-06 14:06:09 +02:00
bcm53xx bcm53xx: drop 6.1 support 2024-09-09 14:29:58 +02:00
bcm4908 bcm4908: drop 6.1 support 2024-08-30 11:39:44 +02:00
bmips bmips: add support for TP-Link TD-W8968 V3 2024-08-24 20:35:30 +02:00
d1 d1: drop 6.1 support 2024-05-29 17:56:28 +02:00
gemini kernel: activate *_FS_SECURITY and *_FS_ACL_ATTR options for all big flash targets 2024-09-06 22:46:59 +02:00
generic kernel: backport nvmem changes from v6.12 2024-09-12 08:59:36 +02:00
imx kernel: activate *_FS_SECURITY and *_FS_ACL_ATTR options for all big flash targets 2024-09-06 22:46:59 +02:00
ipq40xx ipq40xx: define config-names for Aruba boards 2024-09-11 00:37:34 +02:00
ipq806x treewide: rename ZyXEL to Zyxel 2024-08-25 15:08:25 +02:00
ixp4xx ixp4xx: Add back support for D-Link DSM G600 A 2024-05-25 09:17:19 +02:00
kirkwood treewide: rename ZyXEL to Zyxel 2024-08-25 15:08:25 +02:00
lantiq treewide: rename ZyXEL to Zyxel 2024-08-25 15:08:25 +02:00
layerscape kernel: activate *_FS_SECURITY and *_FS_ACL_ATTR options for all big flash targets 2024-09-06 22:46:59 +02:00
loongarch64 kernel: activate *_FS_SECURITY and *_FS_ACL_ATTR options for all big flash targets 2024-09-06 22:46:59 +02:00
malta kernel: activate *_FS_SECURITY and *_FS_ACL_ATTR options for all big flash targets 2024-09-06 22:46:59 +02:00
mediatek mediatek: apply pending PHY driver fixes 2024-09-12 15:43:05 +02:00
mpc85xx mpc85xx: add static to init functions 2024-09-07 22:24:07 +02:00
mvebu mvebu: GL-MV1000: let u-boot-env be writable again 2024-08-06 21:46:25 +02:00
mxs mxs: drop 6.1 support 2024-04-25 14:33:22 +02:00
octeon octeon: set Linux 6.6 as the default kernel 2024-09-09 18:24:34 +02:00
omap kernel: activate *_FS_SECURITY and *_FS_ACL_ATTR options for all big flash targets 2024-09-06 22:46:59 +02:00
pistachio kernel: activate *_FS_SECURITY and *_FS_ACL_ATTR options for all big flash targets 2024-09-06 22:46:59 +02:00
qoriq kernel: activate *_FS_SECURITY and *_FS_ACL_ATTR options for all big flash targets 2024-09-06 22:46:59 +02:00
qualcommax ipq807x: add support for TP-Link EAP660 HD v1 2024-09-08 12:01:19 +02:00
ramips ramips: mt76x8: add missing model string to Yuncore M300 2024-09-11 00:17:05 +02:00
realtek realtek: rework hardware-assisted indirect mdio access 2024-09-14 19:58:21 +02:00
rockchip treewide: update contact information 2024-09-11 00:37:34 +02:00
sifiveu sifiveu: drop 6.1 support 2024-04-30 11:02:48 +02:00
starfive starfive: drop 6.1 support 2024-09-10 12:04:09 +02:00
sunxi kernel: activate *_FS_SECURITY and *_FS_ACL_ATTR options for all big flash targets 2024-09-06 22:46:59 +02:00
tegra tegra: promote kernel 6.6 as default 2024-07-13 14:29:16 +02:00
uml uml: fix glibc-static check with GCC14 2024-06-22 22:06:06 +02:00
x86 armsr: use console=tty1 to make console more readily available 2024-08-25 13:15:33 +02:00
zynq zynq: drop 6.1 support 2024-08-03 11:36:59 +02:00
Makefile linux: add dtb makefile target to targets list 2024-02-08 23:04:55 +01:00