xref: /linux/drivers/net/phy/marvell10g.c (revision ea4efe25ec937a7bc1108e26261c9dd4082375af)
120b2af32SRussell King /*
220b2af32SRussell King  * Marvell 10G 88x3310 PHY driver
320b2af32SRussell King  *
420b2af32SRussell King  * Based upon the ID registers, this PHY appears to be a mixture of IPs
520b2af32SRussell King  * from two different companies.
620b2af32SRussell King  *
720b2af32SRussell King  * There appears to be several different data paths through the PHY which
820b2af32SRussell King  * are automatically managed by the PHY.  The following has been determined
905ca1b32SRussell King  * via observation and experimentation for a setup using single-lane Serdes:
1020b2af32SRussell King  *
1120b2af32SRussell King  *       SGMII PHYXS -- BASE-T PCS -- 10G PMA -- AN -- Copper (for <= 1G)
1220b2af32SRussell King  *  10GBASE-KR PHYXS -- BASE-T PCS -- 10G PMA -- AN -- Copper (for 10G)
1320b2af32SRussell King  *  10GBASE-KR PHYXS -- BASE-R PCS -- Fiber
1420b2af32SRussell King  *
1505ca1b32SRussell King  * With XAUI, observation shows:
1605ca1b32SRussell King  *
1705ca1b32SRussell King  *        XAUI PHYXS -- <appropriate PCS as above>
1805ca1b32SRussell King  *
1905ca1b32SRussell King  * and no switching of the host interface mode occurs.
2005ca1b32SRussell King  *
2120b2af32SRussell King  * If both the fiber and copper ports are connected, the first to gain
2220b2af32SRussell King  * link takes priority and the other port is completely locked out.
2320b2af32SRussell King  */
2420b2af32SRussell King #include <linux/phy.h>
25952b6b3bSAntoine Tenart #include <linux/marvell_phy.h>
2620b2af32SRussell King 
2720b2af32SRussell King enum {
2820b2af32SRussell King 	MV_PCS_BASE_T		= 0x0000,
2920b2af32SRussell King 	MV_PCS_BASE_R		= 0x1000,
3020b2af32SRussell King 	MV_PCS_1000BASEX	= 0x2000,
3120b2af32SRussell King 
32*ea4efe25SRussell King 	MV_PCS_PAIRSWAP		= 0x8182,
33*ea4efe25SRussell King 	MV_PCS_PAIRSWAP_MASK	= 0x0003,
34*ea4efe25SRussell King 	MV_PCS_PAIRSWAP_AB	= 0x0002,
35*ea4efe25SRussell King 	MV_PCS_PAIRSWAP_NONE	= 0x0003,
36*ea4efe25SRussell King 
3720b2af32SRussell King 	/* These registers appear at 0x800X and 0xa00X - the 0xa00X control
3820b2af32SRussell King 	 * registers appear to set themselves to the 0x800X when AN is
3920b2af32SRussell King 	 * restarted, but status registers appear readable from either.
4020b2af32SRussell King 	 */
4120b2af32SRussell King 	MV_AN_CTRL1000		= 0x8000, /* 1000base-T control register */
4220b2af32SRussell King 	MV_AN_STAT1000		= 0x8001, /* 1000base-T status register */
4320b2af32SRussell King 
4420b2af32SRussell King 	/* This register appears to reflect the copper status */
4520b2af32SRussell King 	MV_AN_RESULT		= 0xa016,
4620b2af32SRussell King 	MV_AN_RESULT_SPD_10	= BIT(12),
4720b2af32SRussell King 	MV_AN_RESULT_SPD_100	= BIT(13),
4820b2af32SRussell King 	MV_AN_RESULT_SPD_1000	= BIT(14),
4920b2af32SRussell King 	MV_AN_RESULT_SPD_10000	= BIT(15),
5020b2af32SRussell King };
5120b2af32SRussell King 
5220b2af32SRussell King static int mv3310_modify(struct phy_device *phydev, int devad, u16 reg,
5320b2af32SRussell King 			 u16 mask, u16 bits)
5420b2af32SRussell King {
5520b2af32SRussell King 	int old, val, ret;
5620b2af32SRussell King 
5720b2af32SRussell King 	old = phy_read_mmd(phydev, devad, reg);
5820b2af32SRussell King 	if (old < 0)
5920b2af32SRussell King 		return old;
6020b2af32SRussell King 
6120b2af32SRussell King 	val = (old & ~mask) | (bits & mask);
6220b2af32SRussell King 	if (val == old)
6320b2af32SRussell King 		return 0;
6420b2af32SRussell King 
6520b2af32SRussell King 	ret = phy_write_mmd(phydev, devad, reg, val);
6620b2af32SRussell King 
6720b2af32SRussell King 	return ret < 0 ? ret : 1;
6820b2af32SRussell King }
6920b2af32SRussell King 
7020b2af32SRussell King static int mv3310_probe(struct phy_device *phydev)
7120b2af32SRussell King {
7220b2af32SRussell King 	u32 mmd_mask = MDIO_DEVS_PMAPMD | MDIO_DEVS_AN;
7320b2af32SRussell King 
7420b2af32SRussell King 	if (!phydev->is_c45 ||
7520b2af32SRussell King 	    (phydev->c45_ids.devices_in_package & mmd_mask) != mmd_mask)
7620b2af32SRussell King 		return -ENODEV;
7720b2af32SRussell King 
7820b2af32SRussell King 	return 0;
7920b2af32SRussell King }
8020b2af32SRussell King 
8120b2af32SRussell King /*
8220b2af32SRussell King  * Resetting the MV88X3310 causes it to become non-responsive.  Avoid
8320b2af32SRussell King  * setting the reset bit(s).
8420b2af32SRussell King  */
8520b2af32SRussell King static int mv3310_soft_reset(struct phy_device *phydev)
8620b2af32SRussell King {
8720b2af32SRussell King 	return 0;
8820b2af32SRussell King }
8920b2af32SRussell King 
9020b2af32SRussell King static int mv3310_config_init(struct phy_device *phydev)
9120b2af32SRussell King {
9220b2af32SRussell King 	__ETHTOOL_DECLARE_LINK_MODE_MASK(supported) = { 0, };
9320b2af32SRussell King 	u32 mask;
9420b2af32SRussell King 	int val;
9520b2af32SRussell King 
9620b2af32SRussell King 	/* Check that the PHY interface type is compatible */
9720b2af32SRussell King 	if (phydev->interface != PHY_INTERFACE_MODE_SGMII &&
9820b2af32SRussell King 	    phydev->interface != PHY_INTERFACE_MODE_XAUI &&
9920b2af32SRussell King 	    phydev->interface != PHY_INTERFACE_MODE_RXAUI &&
10020b2af32SRussell King 	    phydev->interface != PHY_INTERFACE_MODE_10GKR)
10120b2af32SRussell King 		return -ENODEV;
10220b2af32SRussell King 
10320b2af32SRussell King 	__set_bit(ETHTOOL_LINK_MODE_Pause_BIT, supported);
10420b2af32SRussell King 	__set_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, supported);
10520b2af32SRussell King 
10620b2af32SRussell King 	if (phydev->c45_ids.devices_in_package & MDIO_DEVS_AN) {
10720b2af32SRussell King 		val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_STAT1);
10820b2af32SRussell King 		if (val < 0)
10920b2af32SRussell King 			return val;
11020b2af32SRussell King 
11120b2af32SRussell King 		if (val & MDIO_AN_STAT1_ABLE)
11220b2af32SRussell King 			__set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, supported);
11320b2af32SRussell King 	}
11420b2af32SRussell King 
11520b2af32SRussell King 	val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_STAT2);
11620b2af32SRussell King 	if (val < 0)
11720b2af32SRussell King 		return val;
11820b2af32SRussell King 
11920b2af32SRussell King 	/* Ethtool does not support the WAN mode bits */
12020b2af32SRussell King 	if (val & (MDIO_PMA_STAT2_10GBSR | MDIO_PMA_STAT2_10GBLR |
12120b2af32SRussell King 		   MDIO_PMA_STAT2_10GBER | MDIO_PMA_STAT2_10GBLX4 |
12220b2af32SRussell King 		   MDIO_PMA_STAT2_10GBSW | MDIO_PMA_STAT2_10GBLW |
12320b2af32SRussell King 		   MDIO_PMA_STAT2_10GBEW))
12420b2af32SRussell King 		__set_bit(ETHTOOL_LINK_MODE_FIBRE_BIT, supported);
12520b2af32SRussell King 	if (val & MDIO_PMA_STAT2_10GBSR)
12620b2af32SRussell King 		__set_bit(ETHTOOL_LINK_MODE_10000baseSR_Full_BIT, supported);
12720b2af32SRussell King 	if (val & MDIO_PMA_STAT2_10GBLR)
12820b2af32SRussell King 		__set_bit(ETHTOOL_LINK_MODE_10000baseLR_Full_BIT, supported);
12920b2af32SRussell King 	if (val & MDIO_PMA_STAT2_10GBER)
13020b2af32SRussell King 		__set_bit(ETHTOOL_LINK_MODE_10000baseER_Full_BIT, supported);
13120b2af32SRussell King 
13220b2af32SRussell King 	if (val & MDIO_PMA_STAT2_EXTABLE) {
13320b2af32SRussell King 		val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_EXTABLE);
13420b2af32SRussell King 		if (val < 0)
13520b2af32SRussell King 			return val;
13620b2af32SRussell King 
13720b2af32SRussell King 		if (val & (MDIO_PMA_EXTABLE_10GBT | MDIO_PMA_EXTABLE_1000BT |
13820b2af32SRussell King 			   MDIO_PMA_EXTABLE_100BTX | MDIO_PMA_EXTABLE_10BT))
13920b2af32SRussell King 			__set_bit(ETHTOOL_LINK_MODE_TP_BIT, supported);
14020b2af32SRussell King 		if (val & MDIO_PMA_EXTABLE_10GBLRM)
14120b2af32SRussell King 			__set_bit(ETHTOOL_LINK_MODE_FIBRE_BIT, supported);
14220b2af32SRussell King 		if (val & (MDIO_PMA_EXTABLE_10GBKX4 | MDIO_PMA_EXTABLE_10GBKR |
14320b2af32SRussell King 			   MDIO_PMA_EXTABLE_1000BKX))
14420b2af32SRussell King 			__set_bit(ETHTOOL_LINK_MODE_Backplane_BIT, supported);
14520b2af32SRussell King 		if (val & MDIO_PMA_EXTABLE_10GBLRM)
14620b2af32SRussell King 			__set_bit(ETHTOOL_LINK_MODE_10000baseLRM_Full_BIT,
14720b2af32SRussell King 				  supported);
14820b2af32SRussell King 		if (val & MDIO_PMA_EXTABLE_10GBT)
14920b2af32SRussell King 			__set_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT,
15020b2af32SRussell King 				  supported);
15120b2af32SRussell King 		if (val & MDIO_PMA_EXTABLE_10GBKX4)
15220b2af32SRussell King 			__set_bit(ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT,
15320b2af32SRussell King 				  supported);
15420b2af32SRussell King 		if (val & MDIO_PMA_EXTABLE_10GBKR)
15520b2af32SRussell King 			__set_bit(ETHTOOL_LINK_MODE_10000baseKR_Full_BIT,
15620b2af32SRussell King 				  supported);
15720b2af32SRussell King 		if (val & MDIO_PMA_EXTABLE_1000BT)
15820b2af32SRussell King 			__set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
15920b2af32SRussell King 				  supported);
16020b2af32SRussell King 		if (val & MDIO_PMA_EXTABLE_1000BKX)
16120b2af32SRussell King 			__set_bit(ETHTOOL_LINK_MODE_1000baseKX_Full_BIT,
16220b2af32SRussell King 				  supported);
16320b2af32SRussell King 		if (val & MDIO_PMA_EXTABLE_100BTX)
16420b2af32SRussell King 			__set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT,
16520b2af32SRussell King 				  supported);
16620b2af32SRussell King 		if (val & MDIO_PMA_EXTABLE_10BT)
16720b2af32SRussell King 			__set_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT,
16820b2af32SRussell King 				  supported);
16920b2af32SRussell King 	}
17020b2af32SRussell King 
17120b2af32SRussell King 	if (!ethtool_convert_link_mode_to_legacy_u32(&mask, supported))
17220b2af32SRussell King 		dev_warn(&phydev->mdio.dev,
17320b2af32SRussell King 			 "PHY supports (%*pb) more modes than phylib supports, some modes not supported.\n",
17420b2af32SRussell King 			 __ETHTOOL_LINK_MODE_MASK_NBITS, supported);
17520b2af32SRussell King 
17620b2af32SRussell King 	phydev->supported &= mask;
17720b2af32SRussell King 	phydev->advertising &= phydev->supported;
17820b2af32SRussell King 
17920b2af32SRussell King 	return 0;
18020b2af32SRussell King }
18120b2af32SRussell King 
18220b2af32SRussell King static int mv3310_config_aneg(struct phy_device *phydev)
18320b2af32SRussell King {
18420b2af32SRussell King 	bool changed = false;
18520b2af32SRussell King 	u32 advertising;
18620b2af32SRussell King 	int ret;
18720b2af32SRussell King 
188*ea4efe25SRussell King 	/* We don't support manual MDI control */
189*ea4efe25SRussell King 	phydev->mdix_ctrl = ETH_TP_MDI_AUTO;
190*ea4efe25SRussell King 
19120b2af32SRussell King 	if (phydev->autoneg == AUTONEG_DISABLE) {
19220b2af32SRussell King 		ret = genphy_c45_pma_setup_forced(phydev);
19320b2af32SRussell King 		if (ret < 0)
19420b2af32SRussell King 			return ret;
19520b2af32SRussell King 
19620b2af32SRussell King 		return genphy_c45_an_disable_aneg(phydev);
19720b2af32SRussell King 	}
19820b2af32SRussell King 
19920b2af32SRussell King 	phydev->advertising &= phydev->supported;
20020b2af32SRussell King 	advertising = phydev->advertising;
20120b2af32SRussell King 
20220b2af32SRussell King 	ret = mv3310_modify(phydev, MDIO_MMD_AN, MDIO_AN_ADVERTISE,
20320b2af32SRussell King 			    ADVERTISE_ALL | ADVERTISE_100BASE4 |
20420b2af32SRussell King 			    ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM,
20520b2af32SRussell King 			    ethtool_adv_to_mii_adv_t(advertising));
20620b2af32SRussell King 	if (ret < 0)
20720b2af32SRussell King 		return ret;
20820b2af32SRussell King 	if (ret > 0)
20920b2af32SRussell King 		changed = true;
21020b2af32SRussell King 
21120b2af32SRussell King 	ret = mv3310_modify(phydev, MDIO_MMD_AN, MV_AN_CTRL1000,
21220b2af32SRussell King 			    ADVERTISE_1000FULL | ADVERTISE_1000HALF,
21320b2af32SRussell King 			    ethtool_adv_to_mii_ctrl1000_t(advertising));
21420b2af32SRussell King 	if (ret < 0)
21520b2af32SRussell King 		return ret;
21620b2af32SRussell King 	if (ret > 0)
21720b2af32SRussell King 		changed = true;
21820b2af32SRussell King 
21920b2af32SRussell King 	/* 10G control register */
22020b2af32SRussell King 	ret = mv3310_modify(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL,
22120b2af32SRussell King 			    MDIO_AN_10GBT_CTRL_ADV10G,
22220b2af32SRussell King 			    advertising & ADVERTISED_10000baseT_Full ?
22320b2af32SRussell King 				MDIO_AN_10GBT_CTRL_ADV10G : 0);
22420b2af32SRussell King 	if (ret < 0)
22520b2af32SRussell King 		return ret;
22620b2af32SRussell King 	if (ret > 0)
22720b2af32SRussell King 		changed = true;
22820b2af32SRussell King 
22920b2af32SRussell King 	if (changed)
23020b2af32SRussell King 		ret = genphy_c45_restart_aneg(phydev);
23120b2af32SRussell King 
23220b2af32SRussell King 	return ret;
23320b2af32SRussell King }
23420b2af32SRussell King 
23520b2af32SRussell King static int mv3310_aneg_done(struct phy_device *phydev)
23620b2af32SRussell King {
23720b2af32SRussell King 	int val;
23820b2af32SRussell King 
23920b2af32SRussell King 	val = phy_read_mmd(phydev, MDIO_MMD_PCS, MV_PCS_BASE_R + MDIO_STAT1);
24020b2af32SRussell King 	if (val < 0)
24120b2af32SRussell King 		return val;
24220b2af32SRussell King 
24320b2af32SRussell King 	if (val & MDIO_STAT1_LSTATUS)
24420b2af32SRussell King 		return 1;
24520b2af32SRussell King 
24620b2af32SRussell King 	return genphy_c45_aneg_done(phydev);
24720b2af32SRussell King }
24820b2af32SRussell King 
24920b2af32SRussell King /* 10GBASE-ER,LR,LRM,SR do not support autonegotiation. */
25020b2af32SRussell King static int mv3310_read_10gbr_status(struct phy_device *phydev)
25120b2af32SRussell King {
25220b2af32SRussell King 	phydev->link = 1;
25320b2af32SRussell King 	phydev->speed = SPEED_10000;
25420b2af32SRussell King 	phydev->duplex = DUPLEX_FULL;
25520b2af32SRussell King 
25620b2af32SRussell King 	if (phydev->interface == PHY_INTERFACE_MODE_SGMII)
25720b2af32SRussell King 		phydev->interface = PHY_INTERFACE_MODE_10GKR;
25820b2af32SRussell King 
25920b2af32SRussell King 	return 0;
26020b2af32SRussell King }
26120b2af32SRussell King 
26220b2af32SRussell King static int mv3310_read_status(struct phy_device *phydev)
26320b2af32SRussell King {
26420b2af32SRussell King 	u32 mmd_mask = phydev->c45_ids.devices_in_package;
26520b2af32SRussell King 	int val;
26620b2af32SRussell King 
26720b2af32SRussell King 	/* The vendor devads do not report link status.  Avoid the PHYXS
26820b2af32SRussell King 	 * instance as there are three, and its status depends on the MAC
26920b2af32SRussell King 	 * being appropriately configured for the negotiated speed.
27020b2af32SRussell King 	 */
27120b2af32SRussell King 	mmd_mask &= ~(BIT(MDIO_MMD_VEND1) | BIT(MDIO_MMD_VEND2) |
27220b2af32SRussell King 		      BIT(MDIO_MMD_PHYXS));
27320b2af32SRussell King 
27420b2af32SRussell King 	phydev->speed = SPEED_UNKNOWN;
27520b2af32SRussell King 	phydev->duplex = DUPLEX_UNKNOWN;
27620b2af32SRussell King 	phydev->lp_advertising = 0;
27720b2af32SRussell King 	phydev->link = 0;
27820b2af32SRussell King 	phydev->pause = 0;
27920b2af32SRussell King 	phydev->asym_pause = 0;
280*ea4efe25SRussell King 	phydev->mdix = 0;
28120b2af32SRussell King 
28220b2af32SRussell King 	val = phy_read_mmd(phydev, MDIO_MMD_PCS, MV_PCS_BASE_R + MDIO_STAT1);
28320b2af32SRussell King 	if (val < 0)
28420b2af32SRussell King 		return val;
28520b2af32SRussell King 
28620b2af32SRussell King 	if (val & MDIO_STAT1_LSTATUS)
28720b2af32SRussell King 		return mv3310_read_10gbr_status(phydev);
28820b2af32SRussell King 
28920b2af32SRussell King 	val = genphy_c45_read_link(phydev, mmd_mask);
29020b2af32SRussell King 	if (val < 0)
29120b2af32SRussell King 		return val;
29220b2af32SRussell King 
29320b2af32SRussell King 	phydev->link = val > 0 ? 1 : 0;
29420b2af32SRussell King 
29520b2af32SRussell King 	val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_STAT1);
29620b2af32SRussell King 	if (val < 0)
29720b2af32SRussell King 		return val;
29820b2af32SRussell King 
29920b2af32SRussell King 	if (val & MDIO_AN_STAT1_COMPLETE) {
30020b2af32SRussell King 		val = genphy_c45_read_lpa(phydev);
30120b2af32SRussell King 		if (val < 0)
30220b2af32SRussell King 			return val;
30320b2af32SRussell King 
30420b2af32SRussell King 		/* Read the link partner's 1G advertisment */
30520b2af32SRussell King 		val = phy_read_mmd(phydev, MDIO_MMD_AN, MV_AN_STAT1000);
30620b2af32SRussell King 		if (val < 0)
30720b2af32SRussell King 			return val;
30820b2af32SRussell King 
30920b2af32SRussell King 		phydev->lp_advertising |= mii_stat1000_to_ethtool_lpa_t(val);
31020b2af32SRussell King 
31120b2af32SRussell King 		if (phydev->autoneg == AUTONEG_ENABLE) {
31220b2af32SRussell King 			val = phy_read_mmd(phydev, MDIO_MMD_AN, MV_AN_RESULT);
31320b2af32SRussell King 			if (val < 0)
31420b2af32SRussell King 				return val;
31520b2af32SRussell King 
31620b2af32SRussell King 			if (val & MV_AN_RESULT_SPD_10000)
31720b2af32SRussell King 				phydev->speed = SPEED_10000;
31820b2af32SRussell King 			else if (val & MV_AN_RESULT_SPD_1000)
31920b2af32SRussell King 				phydev->speed = SPEED_1000;
32020b2af32SRussell King 			else if (val & MV_AN_RESULT_SPD_100)
32120b2af32SRussell King 				phydev->speed = SPEED_100;
32220b2af32SRussell King 			else if (val & MV_AN_RESULT_SPD_10)
32320b2af32SRussell King 				phydev->speed = SPEED_10;
32420b2af32SRussell King 
32520b2af32SRussell King 			phydev->duplex = DUPLEX_FULL;
32620b2af32SRussell King 		}
32720b2af32SRussell King 	}
32820b2af32SRussell King 
32920b2af32SRussell King 	if (phydev->autoneg != AUTONEG_ENABLE) {
33020b2af32SRussell King 		val = genphy_c45_read_pma(phydev);
33120b2af32SRussell King 		if (val < 0)
33220b2af32SRussell King 			return val;
33320b2af32SRussell King 	}
33420b2af32SRussell King 
335*ea4efe25SRussell King 	if (phydev->speed == SPEED_10000) {
336*ea4efe25SRussell King 		val = genphy_c45_read_mdix(phydev);
337*ea4efe25SRussell King 		if (val < 0)
338*ea4efe25SRussell King 			return val;
339*ea4efe25SRussell King 	} else {
340*ea4efe25SRussell King 		val = phy_read_mmd(phydev, MDIO_MMD_PCS, MV_PCS_PAIRSWAP);
341*ea4efe25SRussell King 		if (val < 0)
342*ea4efe25SRussell King 			return val;
343*ea4efe25SRussell King 
344*ea4efe25SRussell King 		switch (val & MV_PCS_PAIRSWAP_MASK) {
345*ea4efe25SRussell King 		case MV_PCS_PAIRSWAP_AB:
346*ea4efe25SRussell King 			phydev->mdix = ETH_TP_MDI_X;
347*ea4efe25SRussell King 			break;
348*ea4efe25SRussell King 		case MV_PCS_PAIRSWAP_NONE:
349*ea4efe25SRussell King 			phydev->mdix = ETH_TP_MDI;
350*ea4efe25SRussell King 			break;
351*ea4efe25SRussell King 		default:
352*ea4efe25SRussell King 			phydev->mdix = ETH_TP_MDI_INVALID;
353*ea4efe25SRussell King 			break;
354*ea4efe25SRussell King 		}
355*ea4efe25SRussell King 	}
356*ea4efe25SRussell King 
35720b2af32SRussell King 	if ((phydev->interface == PHY_INTERFACE_MODE_SGMII ||
35820b2af32SRussell King 	     phydev->interface == PHY_INTERFACE_MODE_10GKR) && phydev->link) {
35920b2af32SRussell King 		/* The PHY automatically switches its serdes interface (and
36020b2af32SRussell King 		 * active PHYXS instance) between Cisco SGMII and 10GBase-KR
36120b2af32SRussell King 		 * modes according to the speed.  Florian suggests setting
36220b2af32SRussell King 		 * phydev->interface to communicate this to the MAC. Only do
36320b2af32SRussell King 		 * this if we are already in either SGMII or 10GBase-KR mode.
36420b2af32SRussell King 		 */
36520b2af32SRussell King 		if (phydev->speed == SPEED_10000)
36620b2af32SRussell King 			phydev->interface = PHY_INTERFACE_MODE_10GKR;
36720b2af32SRussell King 		else if (phydev->speed >= SPEED_10 &&
36820b2af32SRussell King 			 phydev->speed < SPEED_10000)
36920b2af32SRussell King 			phydev->interface = PHY_INTERFACE_MODE_SGMII;
37020b2af32SRussell King 	}
37120b2af32SRussell King 
37220b2af32SRussell King 	return 0;
37320b2af32SRussell King }
37420b2af32SRussell King 
37520b2af32SRussell King static struct phy_driver mv3310_drivers[] = {
37620b2af32SRussell King 	{
37720b2af32SRussell King 		.phy_id		= 0x002b09aa,
378952b6b3bSAntoine Tenart 		.phy_id_mask	= MARVELL_PHY_ID_MASK,
37920b2af32SRussell King 		.name		= "mv88x3310",
38020b2af32SRussell King 		.features	= SUPPORTED_10baseT_Full |
38120b2af32SRussell King 				  SUPPORTED_100baseT_Full |
38220b2af32SRussell King 				  SUPPORTED_1000baseT_Full |
38320b2af32SRussell King 				  SUPPORTED_Autoneg |
38420b2af32SRussell King 				  SUPPORTED_TP |
38520b2af32SRussell King 				  SUPPORTED_FIBRE |
38620b2af32SRussell King 				  SUPPORTED_10000baseT_Full |
38720b2af32SRussell King 				  SUPPORTED_Backplane,
38820b2af32SRussell King 		.probe		= mv3310_probe,
38920b2af32SRussell King 		.soft_reset	= mv3310_soft_reset,
39020b2af32SRussell King 		.config_init	= mv3310_config_init,
39120b2af32SRussell King 		.config_aneg	= mv3310_config_aneg,
39220b2af32SRussell King 		.aneg_done	= mv3310_aneg_done,
39320b2af32SRussell King 		.read_status	= mv3310_read_status,
39420b2af32SRussell King 	},
39520b2af32SRussell King };
39620b2af32SRussell King 
39720b2af32SRussell King module_phy_driver(mv3310_drivers);
39820b2af32SRussell King 
39920b2af32SRussell King static struct mdio_device_id __maybe_unused mv3310_tbl[] = {
400952b6b3bSAntoine Tenart 	{ 0x002b09aa, MARVELL_PHY_ID_MASK },
40120b2af32SRussell King 	{ },
40220b2af32SRussell King };
40320b2af32SRussell King MODULE_DEVICE_TABLE(mdio, mv3310_tbl);
40420b2af32SRussell King MODULE_DESCRIPTION("Marvell Alaska X 10Gigabit Ethernet PHY driver (MV88X3310)");
40520b2af32SRussell King MODULE_LICENSE("GPL");
406