realtek: pcs: rtl931x: streamline hardware mode setting
authorJonas Jelonek <jelonek.jonas@gmail.com>
Sat, 20 Dec 2025 23:34:10 +0000 (23:34 +0000)
committerRobert Marko <robimarko@gmail.com>
Mon, 29 Dec 2025 16:06:19 +0000 (17:06 +0100)
commit9efcc52a7bf61a3728ffb87f54c03ca1e8840c66
tree68b34e64d047ca23667ea1b594d5231f9f253372
parentd5a4387ac5613c8e235c0197255adff48b0111e7
realtek: pcs: rtl931x: streamline hardware mode setting

The SDK and our code for finally applying the hardware mode are quite
confusing. There are two different "places" where a mode can be set,
in a SerDes register and in a global SerDes mode register. Neither the
SDK nor any of the datasheet/documentation serve any explanation for
that. The functions are just named "fiber_mode_set" and "mii_mode_set"
which is basically as useless as it can be to understand it.

Try to get rid off this confusion by naming the functions
'sds_set_mac_mode' and 'sds_set_ip_mode' to make clear where the mode
is set. While at it, also clarify the naming of 'config_mode' by
renaming it to 'config_hw_mode'.

The naming is based on the following assumption:

> Realtek uses an SerDes IP core design (probably from another vendor)
> in their switch. This supports a variety of modes and must be
> configured properly for each mode. Usually, changing the mode in the
> MAC's registers triggers a proper configuration of the SerDes IP block
> in the background.

> However, for some modes this seems to be incomplete, at least missing
> important parts so it doesn't work on its own in the end. In this
> case, the SerDes IP block needs to be configured manually with the
> missing bits to make it work.

There are several places in the SDK that support this assumption, both
for RTL931X and RTL930X (as they are somewhat similar), e.g. [1].

[1] https://github.com/plappermaul/realtek-doc/blob/f7f85ffc14c6e575ad94f2b427106de533b888fe/sources/rtk-dms1250/src/dal/longan/dal_longan_sds.c#L1746

Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/20736
Signed-off-by: Robert Marko <robimarko@gmail.com>
target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c