Skip to content

Commit f27abde

Browse files
wvoondavem330
authored andcommitted
net: pcs: add 2500BASEX support for Intel mGbE controller
XPCS IP supports 2500BASEX as PHY interface. It is configured as autonegotiation disable to cater for PHYs that does not supports 2500BASEX autonegotiation. v2: Add supported link speed masking. v3: Restructure to introduce xpcs_config_2500basex() used to configure the xpcs for 2.5G speeds. Added 2500BASEX specific information for configuration. v4: Fix indentation error Signed-off-by: Voon Weifeng <weifeng.voon@intel.com> Signed-off-by: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 597a68c commit f27abde

2 files changed

Lines changed: 57 additions & 0 deletions

File tree

‎drivers/net/pcs/pcs-xpcs.c‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,12 @@
5757

5858
/* Clause 37 Defines */
5959
/* VR MII MMD registers offsets */
60+
#define DW_VR_MII_MMD_CTRL 0x0000
6061
#define DW_VR_MII_DIG_CTRL1 0x8000
6162
#define DW_VR_MII_AN_CTRL 0x8001
6263
#define DW_VR_MII_AN_INTR_STS 0x8002
64+
/* Enable 2.5G Mode */
65+
#define DW_VR_MII_DIG_CTRL1_2G5_EN BIT(2)
6366
/* EEE Mode Control Register */
6467
#define DW_VR_MII_EEE_MCTRL0 0x8006
6568
#define DW_VR_MII_EEE_MCTRL1 0x800b
@@ -86,6 +89,11 @@
8689
#define DW_VR_MII_C37_ANSGM_SP_1000 0x2
8790
#define DW_VR_MII_C37_ANSGM_SP_LNKSTS BIT(4)
8891

92+
/* SR MII MMD Control defines */
93+
#define AN_CL37_EN BIT(12) /* Enable Clause 37 auto-nego */
94+
#define SGMII_SPEED_SS13 BIT(13) /* SGMII speed along with SS6 */
95+
#define SGMII_SPEED_SS6 BIT(6) /* SGMII speed along with SS13 */
96+
8997
/* VR MII EEE Control 0 defines */
9098
#define DW_VR_MII_EEE_LTX_EN BIT(0) /* LPI Tx Enable */
9199
#define DW_VR_MII_EEE_LRX_EN BIT(1) /* LPI Rx Enable */
@@ -161,6 +169,14 @@ static const int xpcs_sgmii_features[] = {
161169
__ETHTOOL_LINK_MODE_MASK_NBITS,
162170
};
163171

172+
static const int xpcs_2500basex_features[] = {
173+
ETHTOOL_LINK_MODE_Asym_Pause_BIT,
174+
ETHTOOL_LINK_MODE_Autoneg_BIT,
175+
ETHTOOL_LINK_MODE_2500baseX_Full_BIT,
176+
ETHTOOL_LINK_MODE_2500baseT_Full_BIT,
177+
__ETHTOOL_LINK_MODE_MASK_NBITS,
178+
};
179+
164180
static const phy_interface_t xpcs_usxgmii_interfaces[] = {
165181
PHY_INTERFACE_MODE_USXGMII,
166182
};
@@ -177,11 +193,17 @@ static const phy_interface_t xpcs_sgmii_interfaces[] = {
177193
PHY_INTERFACE_MODE_SGMII,
178194
};
179195

196+
static const phy_interface_t xpcs_2500basex_interfaces[] = {
197+
PHY_INTERFACE_MODE_2500BASEX,
198+
PHY_INTERFACE_MODE_MAX,
199+
};
200+
180201
enum {
181202
DW_XPCS_USXGMII,
182203
DW_XPCS_10GKR,
183204
DW_XPCS_XLGMII,
184205
DW_XPCS_SGMII,
206+
DW_XPCS_2500BASEX,
185207
DW_XPCS_INTERFACE_MAX,
186208
};
187209

@@ -306,6 +328,7 @@ static int xpcs_soft_reset(struct mdio_xpcs_args *xpcs,
306328
dev = MDIO_MMD_PCS;
307329
break;
308330
case DW_AN_C37_SGMII:
331+
case DW_2500BASEX:
309332
dev = MDIO_MMD_VEND2;
310333
break;
311334
default:
@@ -804,6 +827,28 @@ static int xpcs_config_aneg_c37_sgmii(struct mdio_xpcs_args *xpcs)
804827
return xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_DIG_CTRL1, ret);
805828
}
806829

830+
static int xpcs_config_2500basex(struct mdio_xpcs_args *xpcs)
831+
{
832+
int ret;
833+
834+
ret = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_DIG_CTRL1);
835+
if (ret < 0)
836+
return ret;
837+
ret |= DW_VR_MII_DIG_CTRL1_2G5_EN;
838+
ret &= ~DW_VR_MII_DIG_CTRL1_MAC_AUTO_SW;
839+
ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_DIG_CTRL1, ret);
840+
if (ret < 0)
841+
return ret;
842+
843+
ret = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_CTRL);
844+
if (ret < 0)
845+
return ret;
846+
ret &= ~AN_CL37_EN;
847+
ret |= SGMII_SPEED_SS6;
848+
ret &= ~SGMII_SPEED_SS13;
849+
return xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_CTRL, ret);
850+
}
851+
807852
static int xpcs_do_config(struct mdio_xpcs_args *xpcs,
808853
phy_interface_t interface, unsigned int mode)
809854
{
@@ -827,6 +872,11 @@ static int xpcs_do_config(struct mdio_xpcs_args *xpcs,
827872
if (ret)
828873
return ret;
829874
break;
875+
case DW_2500BASEX:
876+
ret = xpcs_config_2500basex(xpcs);
877+
if (ret)
878+
return ret;
879+
break;
830880
default:
831881
return -1;
832882
}
@@ -1023,6 +1073,12 @@ static const struct xpcs_compat synopsys_xpcs_compat[DW_XPCS_INTERFACE_MAX] = {
10231073
.num_interfaces = ARRAY_SIZE(xpcs_sgmii_interfaces),
10241074
.an_mode = DW_AN_C37_SGMII,
10251075
},
1076+
[DW_XPCS_2500BASEX] = {
1077+
.supported = xpcs_2500basex_features,
1078+
.interface = xpcs_2500basex_interfaces,
1079+
.num_interfaces = ARRAY_SIZE(xpcs_2500basex_features),
1080+
.an_mode = DW_2500BASEX,
1081+
},
10261082
};
10271083

10281084
static const struct xpcs_id xpcs_id_list[] = {

‎include/linux/pcs/pcs-xpcs.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
/* AN mode */
1414
#define DW_AN_C73 1
1515
#define DW_AN_C37_SGMII 2
16+
#define DW_2500BASEX 3
1617

1718
struct xpcs_id;
1819

0 commit comments

Comments
 (0)