realtek: dsa,phy: rtl838x: remove 'SerDes as PHY' leftovers

RTL838X SerDes is now completely managed by the PCS driver so it's time
to remove all the unused leftovers from DSA and PHY drivers to have that
finally separated.

Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/20876
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This commit is contained in:
Jonas Jelonek 2025-11-07 19:00:03 +00:00 committed by Hauke Mehrtens
parent a63da75e44
commit c3887c126d
7 changed files with 0 additions and 261 deletions

View file

@ -369,14 +369,6 @@ static int __init rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv)
continue;
}
/* Check for the integrated SerDes of the RTL8380M first */
if (of_property_read_bool(phy_node, "phy-is-integrated")
&& priv->id == 0x8380 && pn >= 24) {
pr_debug("----> FOUND A SERDES\n");
priv->ports[pn].phy = PHY_RTL838X_SDS;
continue;
}
if (of_property_read_bool(phy_node, "phy-is-integrated") &&
!of_property_read_bool(phy_node, "sfp")) {
priv->ports[pn].phy = PHY_RTL8218B_INT;

View file

@ -652,44 +652,6 @@ static struct phylink_pcs *rtldsa_phylink_mac_select_pcs(struct dsa_switch *ds,
return priv->pcs[port];
}
__attribute__((unused))
static void rtl83xx_config_interface(int port, phy_interface_t interface)
{
u32 old, int_shift, sds_shift;
switch (port) {
case 24:
int_shift = 0;
sds_shift = 5;
break;
case 26:
int_shift = 3;
sds_shift = 0;
break;
default:
return;
}
old = sw_r32(RTL838X_SDS_MODE_SEL);
switch (interface) {
case PHY_INTERFACE_MODE_1000BASEX:
if ((old >> sds_shift & 0x1f) == 4)
return;
sw_w32_mask(0x7 << int_shift, 1 << int_shift, RTL838X_INT_MODE_CTRL);
sw_w32_mask(0x1f << sds_shift, 4 << sds_shift, RTL838X_SDS_MODE_SEL);
break;
case PHY_INTERFACE_MODE_SGMII:
if ((old >> sds_shift & 0x1f) == 2)
return;
sw_w32_mask(0x7 << int_shift, 2 << int_shift, RTL838X_INT_MODE_CTRL);
sw_w32_mask(0x1f << sds_shift, 2 << sds_shift, RTL838X_SDS_MODE_SEL);
break;
default:
return;
}
pr_debug("configured port %d for interface %s\n", port, phy_modes(interface));
}
static void rtldsa_83xx_phylink_get_caps(struct dsa_switch *ds, int port,
struct phylink_config *config)
{

View file

@ -1810,31 +1810,3 @@ void rtl838x_vlan_profile_dump(int profile)
profile, p & 1, (p >> 1) & 0x1ff, (p >> 10) & 0x1ff, (p >> 19) & 0x1ff);
}
void rtl8380_sds_rst(int mac)
{
u32 offset = (mac == 24) ? 0 : 0x100;
sw_w32_mask(1 << 11, 0, RTL838X_SDS4_FIB_REG0 + offset);
sw_w32_mask(0x3, 0, RTL838X_SDS4_REG28 + offset);
sw_w32_mask(0x3, 0x3, RTL838X_SDS4_REG28 + offset);
sw_w32_mask(0, 0x1 << 6, RTL838X_SDS4_DUMMY0 + offset);
sw_w32_mask(0x1 << 6, 0, RTL838X_SDS4_DUMMY0 + offset);
pr_debug("SERDES reset: %d\n", mac);
}
int rtl8380_sds_power(int mac, int val)
{
u32 mode = (val == 1) ? 0x4 : 0x9;
u32 offset = (mac == 24) ? 5 : 0;
if ((mac != 24) && (mac != 26)) {
pr_err("%s: not a fibre port: %d\n", __func__, mac);
return -1;
}
sw_w32_mask(0x1f << offset, mode << offset, RTL838X_SDS_MODE_SEL);
rtl8380_sds_rst(mac);
return 0;
}

View file

@ -21,10 +21,6 @@
#define RTL930X_MAC_FORCE_MODE_CTRL (0xCA1C)
#define RTL931X_MAC_FORCE_MODE_CTRL (0x0DCC)
#define RTL838X_DMY_REG31 (0x3b28)
#define RTL838X_SDS_MODE_SEL (0x0028)
#define RTL838X_SDS_CFG_REG (0x0034)
#define RTL838X_INT_MODE_CTRL (0x005c)
#define RTL838X_PORT_ISO_CTRL(port) (0x4100 + ((port) << 2))
#define RTL839X_PORT_ISO_CTRL(port) (0x1400 + ((port) << 3))
@ -54,12 +50,6 @@
#define RTL839X_SDS12_13_PWR0 (0xb880)
#define RTL839X_SDS12_13_PWR1 (0xb980)
/* Registers of the internal Serdes of the 8380 */
#define RTL838X_SDS4_FIB_REG0 (0xF800)
#define RTL838X_SDS4_REG28 (0xef80)
#define RTL838X_SDS4_DUMMY0 (0xef8c)
#define RTL838X_SDS5_EXT_REG6 (0xf18c)
/* VLAN registers */
#define RTL838X_VLAN_CTRL (0x3A74)
#define RTL838X_VLAN_PROFILE(idx) (0x3A88 + ((idx) << 2))

View file

@ -162,8 +162,6 @@ u32 rtl838x_hash(struct rtl838x_switch_priv *priv, u64 seed);
irqreturn_t rtl838x_switch_irq(int irq, void *dev_id);
void rtl8380_get_version(struct rtl838x_switch_priv *priv);
void rtl838x_vlan_profile_dump(int index);
void rtl8380_sds_rst(int mac);
int rtl8380_sds_power(int mac, int val);
void rtl838x_print_matrix(void);
/* RTL839x-specific */

View file

@ -143,24 +143,6 @@ static void rtl8380_phy_reset(struct phy_device *phydev)
phy_modify(phydev, 0, BMCR_RESET, BMCR_RESET);
}
/* Read the link and speed status of the 2 internal SGMII/1000Base-X
* ports of the RTL838x SoCs
*/
__attribute__((unused))
static int rtl8380_read_status(struct phy_device *phydev)
{
int err;
err = genphy_read_status(phydev);
if (phydev->link) {
phydev->speed = SPEED_1000;
phydev->duplex = DUPLEX_FULL;
}
return err;
}
/* Read the link and speed status of the 2 internal SGMII/1000Base-X
* ports of the RTL8393 SoC
*/
@ -808,127 +790,6 @@ static int rtl8380_configure_rtl8214fc(struct phy_device *phydev)
return 0;
}
static int rtl8380_configure_serdes(struct phy_device *phydev)
{
u32 v;
u32 sds_conf_value;
int i;
struct fw_header *h;
u32 *rtl8380_sds_take_reset;
u32 *rtl8380_sds_common;
u32 *rtl8380_sds01_qsgmii_6275b;
u32 *rtl8380_sds23_qsgmii_6275b;
u32 *rtl8380_sds4_fiber_6275b;
u32 *rtl8380_sds5_fiber_6275b;
u32 *rtl8380_sds_reset;
u32 *rtl8380_sds_release_reset;
phydev_info(phydev, "Detected internal RTL8380 SERDES\n");
h = rtl838x_request_fw(phydev, &rtl838x_8218b_fw, FIRMWARE_838X_8380_1);
if (!h)
return -1;
if (h->magic != 0x83808380) {
phydev_err(phydev, "Wrong firmware file: magic number mismatch.\n");
return -1;
}
rtl8380_sds_take_reset = (void *)h + sizeof(struct fw_header) + h->parts[0].start;
rtl8380_sds_common = (void *)h + sizeof(struct fw_header) + h->parts[1].start;
rtl8380_sds01_qsgmii_6275b = (void *)h + sizeof(struct fw_header) + h->parts[2].start;
rtl8380_sds23_qsgmii_6275b = (void *)h + sizeof(struct fw_header) + h->parts[3].start;
rtl8380_sds4_fiber_6275b = (void *)h + sizeof(struct fw_header) + h->parts[4].start;
rtl8380_sds5_fiber_6275b = (void *)h + sizeof(struct fw_header) + h->parts[5].start;
rtl8380_sds_reset = (void *)h + sizeof(struct fw_header) + h->parts[6].start;
rtl8380_sds_release_reset = (void *)h + sizeof(struct fw_header) + h->parts[7].start;
/* Back up serdes power off value */
sds_conf_value = sw_r32(RTL838X_SDS_CFG_REG);
pr_info("SDS power down value: %x\n", sds_conf_value);
/* take serdes into reset */
i = 0;
while (rtl8380_sds_take_reset[2 * i]) {
sw_w32(rtl8380_sds_take_reset[2 * i + 1], rtl8380_sds_take_reset[2 * i]);
i++;
udelay(1000);
}
/* apply common serdes patch */
i = 0;
while (rtl8380_sds_common[2 * i]) {
sw_w32(rtl8380_sds_common[2 * i + 1], rtl8380_sds_common[2 * i]);
i++;
udelay(1000);
}
/* internal R/W enable */
sw_w32(3, RTL838X_INT_RW_CTRL);
/* SerDes ports 4 and 5 are FIBRE ports */
sw_w32_mask(0x7 | 0x38, 1 | (1 << 3), RTL838X_INT_MODE_CTRL);
/* SerDes module settings, SerDes 0-3 are QSGMII */
v = 0x6 << 25 | 0x6 << 20 | 0x6 << 15 | 0x6 << 10;
/* SerDes 4 and 5 are 1000BX FIBRE */
v |= 0x4 << 5 | 0x4;
sw_w32(v, RTL838X_SDS_MODE_SEL);
pr_info("PLL control register: %x\n", sw_r32(RTL838X_PLL_CML_CTRL));
sw_w32_mask(0xfffffff0, 0xaaaaaaaf & 0xf, RTL838X_PLL_CML_CTRL);
i = 0;
while (rtl8380_sds01_qsgmii_6275b[2 * i]) {
sw_w32(rtl8380_sds01_qsgmii_6275b[2 * i + 1],
rtl8380_sds01_qsgmii_6275b[2 * i]);
i++;
}
i = 0;
while (rtl8380_sds23_qsgmii_6275b[2 * i]) {
sw_w32(rtl8380_sds23_qsgmii_6275b[2 * i + 1], rtl8380_sds23_qsgmii_6275b[2 * i]);
i++;
}
i = 0;
while (rtl8380_sds4_fiber_6275b[2 * i]) {
sw_w32(rtl8380_sds4_fiber_6275b[2 * i + 1], rtl8380_sds4_fiber_6275b[2 * i]);
i++;
}
i = 0;
while (rtl8380_sds5_fiber_6275b[2 * i]) {
sw_w32(rtl8380_sds5_fiber_6275b[2 * i + 1], rtl8380_sds5_fiber_6275b[2 * i]);
i++;
}
i = 0;
while (rtl8380_sds_reset[2 * i]) {
sw_w32(rtl8380_sds_reset[2 * i + 1], rtl8380_sds_reset[2 * i]);
i++;
}
i = 0;
while (rtl8380_sds_release_reset[2 * i]) {
sw_w32(rtl8380_sds_release_reset[2 * i + 1], rtl8380_sds_release_reset[2 * i]);
i++;
}
pr_info("SDS power down value now: %x\n", sw_r32(RTL838X_SDS_CFG_REG));
sw_w32(sds_conf_value, RTL838X_SDS_CFG_REG);
pr_info("Configuration of SERDES done\n");
return 0;
}
static int rtl8390_configure_serdes(struct phy_device *phydev)
{
phydev_info(phydev, "Detected internal RTL8390 SERDES\n");
@ -1099,18 +960,6 @@ static int rtl8218b_config_init(struct phy_device *phydev)
return 0;
}
static int rtl838x_serdes_probe(struct phy_device *phydev)
{
int addr = phydev->mdio.addr;
if (soc_info.family != RTL8380_FAMILY_ID)
return -ENODEV;
if (addr < 24)
return -ENODEV;
return 0;
}
static int rtl8393_serdes_probe(struct phy_device *phydev)
{
int addr = phydev->mdio.addr;
@ -1218,17 +1067,6 @@ static struct phy_driver rtl83xx_phy_driver[] = {
.write_mmd = rtl821x_write_mmd,
.write_page = rtl821x_write_page,
},
{
PHY_ID_MATCH_MODEL(PHY_ID_RTL8218B_I),
.name = "Realtek RTL8380 SERDES",
.features = PHY_GBIT_FIBRE_FEATURES,
.probe = rtl838x_serdes_probe,
.read_page = rtl821x_read_page,
.write_page = rtl821x_write_page,
.suspend = genphy_suspend,
.resume = genphy_resume,
.read_status = rtl8380_read_status,
},
{
PHY_ID_MATCH_MODEL(PHY_ID_RTL8393_I),
.name = "Realtek RTL8393 SERDES",

View file

@ -35,19 +35,6 @@ struct __packed fw_header {
#define PHY_IS_RTL8214FB 2
#define PHY_IS_RTL8218B_E 3
/* Registers of the internal Serdes of the 8380 */
#define RTL838X_SDS_MODE_SEL (0x0028)
#define RTL838X_SDS_CFG_REG (0x0034)
#define RTL838X_INT_MODE_CTRL (0x005c)
#define RTL838X_DMY_REG31 (0x3b28)
#define RTL8380_SDS4_FIB_REG0 (0xF800)
#define RTL838X_SDS4_REG28 (0xef80)
#define RTL838X_SDS4_DUMMY0 (0xef8c)
#define RTL838X_SDS5_EXT_REG6 (0xf18c)
#define RTL838X_SDS4_FIB_REG0 (RTL838X_SDS4_REG28 + 0x880)
#define RTL838X_SDS5_FIB_REG0 (RTL838X_SDS4_REG28 + 0x980)
/* Registers of the internal SerDes of the RTL8390 */
#define RTL839X_SDS12_13_XSG0 (0xB800)