realtek: pcs: rtl838x: fold lane enables and fiber path into {de,}activate

Expand the 838x deactivate/activate helpers to also cover the analog lane
enables (REG0 EN_RX/EN_TX) and the fiber path power-down (FIB_REG0
CFG_FIB_PDOWN), which are operational-state concerns rather than reset
concerns:

 - _deactivate: clear EN_RX/EN_TX and set CFG_FIB_PDOWN in addition to
   block-level power off.
 - _activate: clear CFG_FIB_PDOWN and set EN_RX/EN_TX before block-level
   power on. The pulse-start EN=0 is omitted since _deactivate already
   established EN=0 and nothing in between touches REG0[1:0].

Shrink rtpcs_838x_sds_reset() accordingly: it now owns only the SOFT_RST
toggle, making it a pure digital reset primitive. The stale "SerDes %d
reset" dev_info was dropped along with the analog/fiber writes.

Behavioural note: the EN and FIB_PDOWN writes now happen *after* the
SOFT_RST release inside rtpcs_838x_sds_reset(), rather than before it as
in the old combined sds_reset. This creates a brief window where the
SerDes is out of digital reset with lanes still disabled, before
activate re-enables them. Consistent with the new
power_off/deactivate -> configure -> reset -> activate/power_on phase
structure, but diverges from the SDK ordering (EN pulse before SOFT_RST
release). Testing on real hardware shows no difference.

Link: https://github.com/openwrt/openwrt/pull/23741
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
This commit is contained in:
Jonas Jelonek
2026-06-11 20:27:29 +02:00
parent bc3d4fa5b2
commit 057314a5d2
@@ -773,17 +773,8 @@ static void rtpcs_838x_sds_patch_5_fiber_6275b(struct rtpcs_ctrl *ctrl)
static void rtpcs_838x_sds_reset(struct rtpcs_serdes *sds)
{
rtpcs_sds_write_bits(sds, 2, 0, 11, 11, 0x0); /* FIB_REG0 CFG_FIB_PDOWN */
/* analog reset */
rtpcs_sds_write_bits(sds, 0, 0, 1, 0, 0x0); /* REG0 EN_RX/EN_TX */
rtpcs_sds_write_bits(sds, 0, 0, 1, 0, 0x3); /* REG0 EN_RX/EN_TX */
/* digital reset */
rtpcs_sds_write_bits(sds, 0, 3, 6, 6, 0x1); /* REG3 SOFT_RST */
rtpcs_sds_write_bits(sds, 0, 3, 6, 6, 0x0); /* REG3 SOFT_RST */
dev_info(sds->ctrl->dev, "SerDes %d reset\n", sds->id);
}
static void rtpcs_838x_sds_fill_caps(struct rtpcs_serdes *sds)
@@ -820,11 +811,35 @@ static int rtpcs_838x_sds_power(struct rtpcs_serdes *sds, bool power_on)
static int rtpcs_838x_sds_deactivate(struct rtpcs_serdes *sds)
{
return rtpcs_838x_sds_power(sds, false);
int ret;
ret = rtpcs_838x_sds_power(sds, false);
if (ret)
return ret;
/* EN_RX | EN_TX */
ret = rtpcs_sds_write_bits(sds, 0, 0, 1, 0, 0x0);
if (ret)
return ret;
/* CFG_FIB_PDOWN / BMCR_PDOWN */
return rtpcs_sds_write_bits(sds, 2, MII_BMCR, 11, 11, 0x1);
}
static int rtpcs_838x_sds_activate(struct rtpcs_serdes *sds)
{
int ret;
/* CFG_FIB_PDOWN / BMCR_PDOWN */
ret = rtpcs_sds_write_bits(sds, 2, 0, 11, 11, 0x0);
if (ret)
return ret;
/* EN_RX | EN_TX */
ret = rtpcs_sds_write_bits(sds, 0, 0, 1, 0, 0x3);
if (ret)
return ret;
return rtpcs_838x_sds_power(sds, true);
}