Skip to content

Commit 2deea43

Browse files
Jiawen Wudavem330
authored andcommitted
net: pcs: xpcs: add 1000BASE-X AN interrupt support
Enable CL37 AN complete interrupt for DW XPCS. It requires to clear the bit(0) [CL37_ANCMPLT_INTR] of VR_MII_AN_INTR_STS after AN completed. And there is a quirk for Wangxun devices to enable CL37 AN in backplane configurations because of the special hardware design. Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f629acc commit 2deea43

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

drivers/net/pcs/pcs-xpcs.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,9 @@ static int xpcs_config_aneg_c37_1000basex(struct dw_xpcs *xpcs,
755755
int ret, mdio_ctrl, adv;
756756
bool changed = 0;
757757

758+
if (xpcs->dev_flag == DW_DEV_TXGBE)
759+
xpcs_write_vpcs(xpcs, DW_VR_XS_PCS_DIG_CTRL1, DW_CL37_BP | DW_EN_VSMMD1);
760+
758761
/* According to Chap 7.12, to set 1000BASE-X C37 AN, AN must
759762
* be disabled first:-
760763
* 1) VR_MII_MMD_CTRL Bit(12)[AN_ENABLE] = 0b
@@ -776,6 +779,8 @@ static int xpcs_config_aneg_c37_1000basex(struct dw_xpcs *xpcs,
776779
return ret;
777780

778781
ret &= ~DW_VR_MII_PCS_MODE_MASK;
782+
if (!xpcs->pcs.poll)
783+
ret |= DW_VR_MII_AN_INTR_EN;
779784
ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_CTRL, ret);
780785
if (ret < 0)
781786
return ret;
@@ -1029,6 +1034,17 @@ static int xpcs_get_state_c37_1000basex(struct dw_xpcs *xpcs,
10291034
if (bmsr < 0)
10301035
return bmsr;
10311036

1037+
/* Clear AN complete interrupt */
1038+
if (!xpcs->pcs.poll) {
1039+
int an_intr;
1040+
1041+
an_intr = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS);
1042+
if (an_intr & DW_VR_MII_AN_STS_C37_ANCMPLT_INTR) {
1043+
an_intr &= ~DW_VR_MII_AN_STS_C37_ANCMPLT_INTR;
1044+
xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS, an_intr);
1045+
}
1046+
}
1047+
10321048
phylink_mii_c22_pcs_decode_state(state, bmsr, lpa);
10331049
}
10341050

@@ -1319,9 +1335,10 @@ static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev,
13191335

13201336
xpcs->pcs.ops = &xpcs_phylink_ops;
13211337
xpcs->pcs.neg_mode = true;
1322-
xpcs->pcs.poll = true;
13231338

13241339
if (xpcs->dev_flag != DW_DEV_TXGBE) {
1340+
xpcs->pcs.poll = true;
1341+
13251342
ret = xpcs_soft_reset(xpcs, compat);
13261343
if (ret)
13271344
goto out;

drivers/net/pcs/pcs-xpcs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define DW_VR_XS_PCS_DIG_CTRL1 0x0000
1919
#define DW_VR_RST BIT(15)
2020
#define DW_EN_VSMMD1 BIT(13)
21+
#define DW_CL37_BP BIT(12)
2122
#define DW_VR_XS_PCS_DIG_STS 0x0010
2223
#define DW_RXFIFO_ERR GENMASK(6, 5)
2324
#define DW_PSEQ_ST GENMASK(4, 2)
@@ -80,8 +81,10 @@
8081
#define DW_VR_MII_PCS_MODE_MASK GENMASK(2, 1)
8182
#define DW_VR_MII_PCS_MODE_C37_1000BASEX 0x0
8283
#define DW_VR_MII_PCS_MODE_C37_SGMII 0x2
84+
#define DW_VR_MII_AN_INTR_EN BIT(0)
8385

8486
/* VR_MII_AN_INTR_STS */
87+
#define DW_VR_MII_AN_STS_C37_ANCMPLT_INTR BIT(0)
8588
#define DW_VR_MII_AN_STS_C37_ANSGM_FD BIT(1)
8689
#define DW_VR_MII_AN_STS_C37_ANSGM_SP_SHIFT 2
8790
#define DW_VR_MII_AN_STS_C37_ANSGM_SP GENMASK(3, 2)

0 commit comments

Comments
 (0)