summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Stockhausen2026-01-12 09:29:44 +0000
committerRobert Marko2026-01-15 14:26:44 +0000
commit10ae743260b57d2a371efce11b35c25db8d97d0b (patch)
treefd5e2ec998d50a4469592806cbd9823e1c04586c
parent1e3139d483c63ff26614c3434d07f8d3f741d38a (diff)
downloadxback-10ae743260b57d2a371efce11b35c25db8d97d0b.tar.gz
realtek: phy: simplify RTL8214FC configuration
Initialization of the RTL8214FC was coded like "put the cart before the horse". Configuration was called from probing and only when called for the last port. Testing showed that there is no need to overcomplicate things. Reorganize the setup as follows: - Let probe() & config() do what they are meant for - Split the config part between a package and a port sequence Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de> Link: https://github.com/openwrt/openwrt/pull/21508 Signed-off-by: Robert Marko <robimarko@gmail.com>
-rw-r--r--target/linux/realtek/files-6.12/drivers/net/phy/rtl83xx-phy.c61
1 files changed, 27 insertions, 34 deletions
diff --git a/target/linux/realtek/files-6.12/drivers/net/phy/rtl83xx-phy.c b/target/linux/realtek/files-6.12/drivers/net/phy/rtl83xx-phy.c
index 92591d0eff..e1a60ce55e 100644
--- a/target/linux/realtek/files-6.12/drivers/net/phy/rtl83xx-phy.c
+++ b/target/linux/realtek/files-6.12/drivers/net/phy/rtl83xx-phy.c
@@ -800,48 +800,41 @@ static int rtl8218b_config_init(struct phy_device *phydev)
static int rtl8214fc_config_init(struct phy_device *phydev)
{
static int regs[] = {16, 19, 20, 21};
- struct phy_device *portphy;
- int port;
-
- /* Hardware is similar to RTL8218B reuse coding for serdes and copper init */
- rtl8218b_config_init(phydev);
+ int ret;
- if (phydev->mdio.addr % 8)
- return 0;
+ /* Step 1 - package setup: Due to similar design reuse RTL8218B coding */
+ ret = rtl8218b_config_init(phydev);
+ if (ret)
+ return ret;
- for (port = 0; port < 4; port++) {
- portphy = get_package_phy(phydev, port);
-
- phy_write(phydev, RTL821XEXT_MEDIA_PAGE_SELECT, 0x8);
- /* setup basic fiber control in base phy and default to copper */
- phy_write_paged(phydev, 0x266, regs[port], 0x0f95);
- phy_write(phydev, RTL821XEXT_MEDIA_PAGE_SELECT, 0x0);
-
- phy_write(portphy, RTL821XEXT_MEDIA_PAGE_SELECT, 0x3);
- /* set fiber SerDes RX to negative edge */
- phy_modify_paged(portphy, 0x8, 0x17, 0, BIT(14));
- /* auto negotiation disable link on */
- phy_modify_paged(portphy, 0x8, 0x14, 0, BIT(2));
- /* disable fiber 100MBit */
- phy_modify_paged(portphy, 0x8, 0x11, BIT(5), 0);
- phy_write(portphy, RTL821XEXT_MEDIA_PAGE_SELECT, 0x0);
-
- /* Disable EEE. 0xa5d/0x10 is the same as MDIO_MMD_AN / MDIO_AN_EEE_ADV */
- phy_write_paged(portphy, 0xa5d, 0x10, 0x0000);
+ if (phydev->mdio.addr % 8 == 0) {
+ for (int port = 0; port < 4; port++) {
+ phy_write(phydev, RTL821XEXT_MEDIA_PAGE_SELECT, 0x8);
+ /* setup basic fiber control in base phy and default to copper */
+ phy_write_paged(phydev, 0x266, regs[port], 0x0f95);
+ phy_write(phydev, RTL821XEXT_MEDIA_PAGE_SELECT, 0x0);
+ }
}
+ /* Step 2 - port setup */
+ phy_write(phydev, RTL821XEXT_MEDIA_PAGE_SELECT, 0x3);
+ /* set fiber SerDes RX to negative edge */
+ phy_modify_paged(phydev, 0x8, 0x17, 0, BIT(14));
+ /* auto negotiation disable link on */
+ phy_modify_paged(phydev, 0x8, 0x14, 0, BIT(2));
+ /* disable fiber 100MBit */
+ phy_modify_paged(phydev, 0x8, 0x11, BIT(5), 0);
+ phy_write(phydev, RTL821XEXT_MEDIA_PAGE_SELECT, 0x0);
+
+ /* Disable EEE. 0xa5d/0x10 is the same as MDIO_MMD_AN / MDIO_AN_EEE_ADV */
+ phy_write_paged(phydev, 0xa5d, 0x10, 0x0000);
+
return 0;
}
static int rtl8214fc_phy_probe(struct phy_device *phydev)
{
- int ret = 0;
-
- if (rtl821x_package_join(phydev, 4) == RTL821X_JOIN_LAST) {
- ret = rtl8214fc_config_init(get_base_phy(phydev));
- if (ret)
- return ret;
- }
+ rtl821x_package_join(phydev, 4);
return phy_sfp_probe(phydev, &rtl8214fc_sfp_ops);
}
@@ -861,7 +854,7 @@ static struct phy_driver rtl83xx_phy_driver[] = {
.match_phy_device = rtl8214fc_match_phy_device,
.name = "Realtek RTL8214FC",
.config_aneg = rtl8214fc_config_aneg,
- .config_init = rtl821x_config_init,
+ .config_init = rtl8214fc_config_init,
.get_features = rtl8214fc_get_features,
.get_tunable = rtl8214fc_get_tunable,
.probe = rtl8214fc_phy_probe,