Skip to content

Commit e117033

Browse files
baruchsiachdavem330
authored andcommitted
net: phy: marvell10g: support XFI rate matching mode
When the hardware MACTYPE hardware configuration pins are set to "XFI with Rate Matching" the PHY interface operate at fixed 10Gbps speed. The MAC buffer packets in both directions to match various wire speeds. Read the MAC Type field in the Port Control register, and set the MAC interface speed accordingly. Signed-off-by: Baruch Siach <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1078029 commit e117033

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

drivers/net/phy/marvell10g.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ enum {
8080
MV_V2_PORT_CTRL = 0xf001,
8181
MV_V2_PORT_CTRL_SWRST = BIT(15),
8282
MV_V2_PORT_CTRL_PWRDOWN = BIT(11),
83+
MV_V2_PORT_MAC_TYPE_MASK = 0x7,
84+
MV_V2_PORT_MAC_TYPE_RATE_MATCH = 0x6,
8385
/* Temperature control/read registers (88X3310 only) */
8486
MV_V2_TEMP_CTRL = 0xf08a,
8587
MV_V2_TEMP_CTRL_MASK = 0xc000,
@@ -91,6 +93,7 @@ enum {
9193

9294
struct mv3310_priv {
9395
u32 firmware_ver;
96+
bool rate_match;
9497

9598
struct device *hwmon_dev;
9699
char *hwmon_name;
@@ -458,7 +461,9 @@ static bool mv3310_has_pma_ngbaset_quirk(struct phy_device *phydev)
458461

459462
static int mv3310_config_init(struct phy_device *phydev)
460463
{
464+
struct mv3310_priv *priv = dev_get_drvdata(&phydev->mdio.dev);
461465
int err;
466+
int val;
462467

463468
/* Check that the PHY interface type is compatible */
464469
if (phydev->interface != PHY_INTERFACE_MODE_SGMII &&
@@ -475,6 +480,12 @@ static int mv3310_config_init(struct phy_device *phydev)
475480
if (err)
476481
return err;
477482

483+
val = phy_read_mmd(phydev, MDIO_MMD_VEND2, MV_V2_PORT_CTRL);
484+
if (val < 0)
485+
return val;
486+
priv->rate_match = ((val & MV_V2_PORT_MAC_TYPE_MASK) ==
487+
MV_V2_PORT_MAC_TYPE_RATE_MATCH);
488+
478489
/* Enable EDPD mode - saving 600mW */
479490
return mv3310_set_edpd(phydev, ETHTOOL_PHY_EDPD_DFLT_TX_MSECS);
480491
}
@@ -581,6 +592,17 @@ static int mv3310_aneg_done(struct phy_device *phydev)
581592

582593
static void mv3310_update_interface(struct phy_device *phydev)
583594
{
595+
struct mv3310_priv *priv = dev_get_drvdata(&phydev->mdio.dev);
596+
597+
/* In "XFI with Rate Matching" mode the PHY interface is fixed at
598+
* 10Gb. The PHY adapts the rate to actual wire speed with help of
599+
* internal 16KB buffer.
600+
*/
601+
if (priv->rate_match) {
602+
phydev->interface = PHY_INTERFACE_MODE_10GBASER;
603+
return;
604+
}
605+
584606
if ((phydev->interface == PHY_INTERFACE_MODE_SGMII ||
585607
phydev->interface == PHY_INTERFACE_MODE_2500BASEX ||
586608
phydev->interface == PHY_INTERFACE_MODE_10GBASER) &&

0 commit comments

Comments
 (0)