realtek: mdio: add SerDes driver
authorMarkus Stockhausen <[email protected]>
Mon, 15 Sep 2025 16:08:53 +0000 (12:08 -0400)
committerRobert Marko <[email protected]>
Wed, 17 Sep 2025 17:23:15 +0000 (19:23 +0200)
commit7a7ee72c4d306e7324a8ea0c1d541c4a7fea5ab1
tree8b0596be68bec557c590564e28d19071a979ab70
parent60bdae3ab3f82c4968445a88275e53e3e6991bc2
realtek: mdio: add SerDes driver

Until now the SerDes access is realized with some helper functions
in the mdio bus. These were moved around a lot and had no real home.
End that temporary solution to move them where they belong.

The target design for the different Realtek drivers is as follows:

- dsa driver manages switch
- pcs driver manages SerDes on high level (to be developed)
- mdio driver manages SerDes on low level (this commit)

This driver adds the low level SerDes access via mdio. For debugging
purposes the user can interact with the SerDes in different ways.

First, there is a debug interface in
/sys/kernel/debug/realtek_otto_serdes/serdes.X/registers.
With that a dump of all registers can be shown.

> cat /sys/kernel/debug/realtek_otto_serdes/serdes.4/registers
Back SDS  4:   00   01   02   03   04   05   06   07   08
SDS        : 0C03 0F00 7060 7106 074D 0EBF 0F0F 0359 5248
SDS_EXT    : 0000 0000 85FA 8C6D 5CCC 0000 20D8 0003 79AA
...

Second, one can read/write registers via the mmd functions of the
mdio command line tool. Important to know: The registers are accessed
on the vendor specific MDIO_MMD_VEND1 device address (=30). Additionally
the SerDes page and register are concatenated into the the mmd register.
Top 8 bits are SerDes page and bottom 8 bits are SerDEs register.
E.g.

- mmd 0x0206 : SerDes page 0x02, SerDes register 0x06
- mmd 0x041f : SerDes page 0x04, SerDes register 0x1f

Read register 0x02 on page 0x03 of SerDes 0
> mdio realtek-serdes-mdio mmd 0:30 raw 0x0302

Write register 0x12 on page 0x02 of SerDes 1
> mdio realtek-serdes-mdio mmd 1:30 raw 0x0212 0x2222

For now this driver is only defined in the devicetree and activated
in the kernel build. There is no current consumer but at least
the debugging interface is available. Cleanup of the currently used
SerDes functions will come later.

Signed-off-by: Markus Stockhausen <[email protected]>
Link: https://github.com/openwrt/openwrt/pull/20062
Signed-off-by: Robert Marko <[email protected]>
12 files changed:
target/linux/realtek/dts/rtl838x.dtsi
target/linux/realtek/dts/rtl839x.dtsi
target/linux/realtek/dts/rtl930x.dtsi
target/linux/realtek/dts/rtl931x.dtsi
target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto-serdes.c [new file with mode: 0644]
target/linux/realtek/patches-6.12/808-add-serdes-mdio-driver.patch [new file with mode: 0644]
target/linux/realtek/rtl838x/config-6.12
target/linux/realtek/rtl839x/config-6.12
target/linux/realtek/rtl930x/config-6.12
target/linux/realtek/rtl930x_nand/config-6.12
target/linux/realtek/rtl931x/config-6.12
target/linux/realtek/rtl931x_nand/config-6.12