1
1

realtek: pcs: introduce per-variant SerDes deactivate helpers

Add rtpcs_{838x,930x,931x}_sds_deactivate() helpers that each encapsulate
the variant-specific "make SerDes inert before reconfigure" sequence, and
replace the inline calls at the start of each setup_serdes with a single
call to the new helper:

 - 838x: wraps rtpcs_838x_sds_power(sds, false)
 - 930x: wraps rtpcs_930x_sds_set_mode(sds, RTPCS_SDS_MODE_OFF)
 - 931x: rtpcs_931x_sds_power(sds, false) + rtpcs_931x_sds_set_mode(sds,
         RTPCS_SDS_MODE_OFF)

RTL839x has no deactivate step to factor out and is left unchanged.

This is a pure refactor: same register writes, same order, same return-
value handling at the call site. The helpers give each variant a named
hook for the deactivate phase and prepare for a subsequent commit that
promotes it to an rtpcs_sds_ops entry and hoists the call site into
rtpcs_pcs_config.

Link: https://github.com/openwrt/openwrt/pull/23513
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
This commit is contained in:
Jonas Jelonek 2026-04-22 13:26:11 +00:00
parent 81fde127a8
commit c484f93a0b
No known key found for this signature in database

View File

@ -821,6 +821,11 @@ static int rtpcs_838x_sds_power(struct rtpcs_serdes *sds, bool power_on)
return ret;
}
static int rtpcs_838x_sds_deactivate(struct rtpcs_serdes *sds)
{
return rtpcs_838x_sds_power(sds, false);
}
/*
* RTL838X wrapper: after setting the MAC mode, SerDes 4-5 also need the
* companion INT_MODE_CTRL field written.
@ -930,7 +935,7 @@ static int rtpcs_838x_setup_serdes(struct rtpcs_serdes *sds,
if (!rtpcs_838x_sds_is_hw_mode_supported(sds, hw_mode))
return -ENOTSUPP;
rtpcs_838x_sds_power(sds, false);
rtpcs_838x_sds_deactivate(sds);
/* take reset */
rtpcs_sds_write(sds, 0x0, 0x0, 0xc00);
@ -1852,6 +1857,11 @@ static int rtpcs_930x_sds_set_mode(struct rtpcs_serdes *sds, enum rtpcs_sds_mode
return rtpcs_93xx_sds_apply_usxgmii_submode(sds, hw_mode);
}
static int rtpcs_930x_sds_deactivate(struct rtpcs_serdes *sds)
{
return rtpcs_930x_sds_set_mode(sds, RTPCS_SDS_MODE_OFF);
}
static void rtpcs_930x_sds_tx_config(struct rtpcs_serdes *sds,
enum rtpcs_sds_mode hw_mode)
{
@ -3003,8 +3013,7 @@ static int rtpcs_930x_setup_serdes(struct rtpcs_serdes *sds,
{
int calib_tries = 0, ret;
/* Turn Off Serdes */
ret = rtpcs_930x_sds_set_mode(sds, RTPCS_SDS_MODE_OFF);
ret = rtpcs_930x_sds_deactivate(sds);
if (ret < 0)
return ret;
@ -3238,6 +3247,17 @@ static int rtpcs_931x_sds_set_mode(struct rtpcs_serdes *sds,
return rtpcs_93xx_sds_apply_usxgmii_submode(sds, hw_mode);
}
static int rtpcs_931x_sds_deactivate(struct rtpcs_serdes *sds)
{
int ret;
ret = rtpcs_931x_sds_power(sds, false);
if (ret)
return ret;
return rtpcs_931x_sds_set_mode(sds, RTPCS_SDS_MODE_OFF);
}
static void rtpcs_931x_sds_reset(struct rtpcs_serdes *sds)
{
u32 o_mode, f_bit;
@ -3782,8 +3802,7 @@ static int rtpcs_931x_setup_serdes(struct rtpcs_serdes *sds,
if (hw_mode == RTPCS_SDS_MODE_XSGMII)
return 0;
rtpcs_931x_sds_power(sds, false);
rtpcs_931x_sds_set_mode(sds, RTPCS_SDS_MODE_OFF);
rtpcs_931x_sds_deactivate(sds);
ret = rtpcs_931x_sds_config_hw_mode(sds, hw_mode);
if (ret < 0)