Skip to content

Commit

Permalink
net: pcs: pcs-mtk-lynxi fix _get_state for 2500base-x
Browse files Browse the repository at this point in the history
Need to fix mtk_pcs_lynxi_get_state() in order for the pcs to function
correctly when the interface is set to 2500base-x.

When the pcs is set to 2500base-x, the register values are not compatible with
phylink_mii_c22_pcs_decode_state().

fixes: net: pcs: add driver for MediaTek SGMII PCS
  • Loading branch information
ericwoud committed Dec 30, 2023
1 parent 7ac6098 commit fd790a7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions drivers/net/pcs/pcs-mtk-lynxi.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,23 @@ static void mtk_pcs_lynxi_get_state(struct phylink_pcs *pcs,
struct phylink_link_state *state)
{
struct mtk_pcs_lynxi *mpcs = pcs_to_mtk_pcs_lynxi(pcs);
unsigned int bm, adv;
unsigned int bm, bmsr, adv;

/* Read the BMSR and LPA */
regmap_read(mpcs->regmap, SGMSYS_PCS_CONTROL_1, &bm);
regmap_read(mpcs->regmap, SGMSYS_PCS_ADVERTISE, &adv);
bmsr = FIELD_GET(SGMII_BMSR, bm);

if (state->interface == PHY_INTERFACE_MODE_2500BASEX) {
state->link = !!(bmsr & BMSR_LSTATUS);
state->an_complete = !!(bmsr & BMSR_ANEGCOMPLETE);
state->speed = SPEED_2500;
state->duplex = DUPLEX_FULL;

return;
}

phylink_mii_c22_pcs_decode_state(state, FIELD_GET(SGMII_BMSR, bm),
FIELD_GET(SGMII_LPA, adv));
regmap_read(mpcs->regmap, SGMSYS_PCS_ADVERTISE, &adv);
phylink_mii_c22_pcs_decode_state(state, bmsr, FIELD_GET(SGMII_LPA, adv));
}

static int mtk_pcs_lynxi_config(struct phylink_pcs *pcs, unsigned int neg_mode,
Expand Down

0 comments on commit fd790a7

Please sign in to comment.