Skip to contentSkip to conversation

net: phy: mscc: Fix the VSC 8530/31/40/41 Chips Init sequence

PATCH In review Raju Lakkaraju 2 participants 2 messages Dec 18, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: phy: mscc: Fix the VSC 8530/31/40/41 Chips Init sequence

From: Raju Lakkaraju <[email protected]>

Fix the VSC 8530/31/40/41 Chips Init sequence
- Turn on Broadcast writes
- UNH 1.8.1 clear bias for UNH 1000BT distortion
- UNH 1.8.7 optimize pre-emphasis for 100BasTx UNH 100W fix
- Enable Token-ring during 'Coma Mode'

---
 drivers/net/phy/mscc.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 53 insertions(+), 1 deletion(-)
drivers/net/phy/mscc.c +53 -1
index cfe680f..766d64e 100644
@@ -853,6 +853,51 @@ static void vsc85xx_tr_write(struct phy_device *phydev, u16 addr, u32 val)
 	__phy_write(phydev, MSCC_PHY_TR_CNTL, TR_WRITE | TR_ADDR(addr));
 }
 
+static int vsc8531_pre_init_seq_set(struct phy_device *phydev)
+{
+	int rc;
+	const struct reg_val init_seq[] = {
+		{0x0f90, 0x00688980},
+		{0x0696, 0x00000003},
+		{0x07fa, 0x0050100f},
+		{0x1686, 0x00000004},
+	};
+	unsigned int i;
+	int oldpage;
+
+	rc = phy_modify_paged(phydev, MSCC_PHY_PAGE_STANDARD,
+			      MSCC_PHY_EXT_CNTL_STATUS, SMI_BROADCAST_WR_EN,
+			      SMI_BROADCAST_WR_EN);
+	if (rc < 0)
+		return rc;
+	rc = phy_modify_paged(phydev, MSCC_PHY_PAGE_TEST,
+			      MSCC_PHY_TEST_PAGE_24, 0, 0x0400);
+	if (rc < 0)
+		return rc;
+	rc = phy_modify_paged(phydev, MSCC_PHY_PAGE_TEST,
+			      MSCC_PHY_TEST_PAGE_5, 0x0a00, 0x0e00);
+	if (rc < 0)
+		return rc;
+	rc = phy_modify_paged(phydev, MSCC_PHY_PAGE_TEST,
+			      MSCC_PHY_TEST_PAGE_8, 0x8000, 0x8000);
+	if (rc < 0)
+		return rc;
+
+	mutex_lock(&phydev->lock);
+	oldpage = phy_select_page(phydev, MSCC_PHY_PAGE_TR);
+	if (oldpage < 0)
+		goto out_unlock;
+
+	for (i = 0; i < ARRAY_SIZE(init_seq); i++)
+		vsc85xx_tr_write(phydev, init_seq[i].reg, init_seq[i].val);
+
+out_unlock:
+	oldpage = phy_restore_page(phydev, oldpage, oldpage);
+	mutex_unlock(&phydev->lock);
+
+	return oldpage;
+}
+
 static int vsc85xx_eee_init_seq_set(struct phy_device *phydev)
 {
 	const struct reg_val init_eee[] = {
@@ -1650,7 +1695,7 @@ static int vsc8584_config_init(struct phy_device *phydev)
 
 static int vsc85xx_config_init(struct phy_device *phydev)
 {
-	int rc, i;
+	int rc, i, phy_id;
 	struct vsc8531_private *vsc8531 = phydev->priv;
 
 	rc = vsc85xx_default_config(phydev);
@@ -1665,6 +1710,13 @@ static int vsc85xx_config_init(struct phy_device *phydev)
 	if (rc)
 		return rc;
 
+	phy_id = phydev->drv->phy_id & phydev->drv->phy_id_mask;
+	if (PHY_ID_VSC8531 == phy_id || PHY_ID_VSC8541 == phy_id ||
+	    PHY_ID_VSC8530 == phy_id || PHY_ID_VSC8540 == phy_id)
+		rc = vsc8531_pre_init_seq_set(phydev);
+		if (rc)
+			return rc;
+
 	rc = vsc85xx_eee_init_seq_set(phydev);
 	if (rc)
 		return rc;
Signature · 1 line
2.7.4
#1 lore raw

Hello!

Quoted 17 lines · Raju Lakkaraju

From: Raju Lakkaraju <[email protected]>

Fix the VSC 8530/31/40/41 Chips Init sequence
- Turn on Broadcast writes
- UNH 1.8.1 clear bias for UNH 1000BT distortion
- UNH 1.8.7 optimize pre-emphasis for 100BasTx UNH 100W fix
- Enable Token-ring during 'Coma Mode'

---
  drivers/net/phy/mscc.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++-
  1 file changed, 53 insertions(+), 1 deletion(-)
drivers/net/phy/mscc.c +0 -0
index cfe680f..766d64e 100644

[...]

Quoted 10 lines
drivers/net/phy/mscc.c +1 -1
@@ -1650,7 +1695,7 @@ static int vsc8584_config_init(struct phy_device *phydev)
 
  static int vsc85xx_config_init(struct phy_device *phydev)
  {
-	int rc, i;
+	int rc, i, phy_id;
  	struct vsc8531_private *vsc8531 = phydev->priv;
 
  	rc = vsc85xx_default_config(phydev);

drivers/net/phy/mscc.c static int vsc85xx_config_init(struct phy_device *phydev) · line 1715

Quoted 6 lines
drivers/net/phy/mscc.c +3 -0
@@ -1665,6 +1710,13 @@ static int vsc85xx_config_init(struct phy_device *phydev)
  	if (rc)
  		return rc;
 
+	phy_id = phydev->drv->phy_id & phydev->drv->phy_id_mask;
+	if (PHY_ID_VSC8531 == phy_id || PHY_ID_VSC8541 == phy_id ||
+	    PHY_ID_VSC8530 == phy_id || PHY_ID_VSC8540 == phy_id)

This is asking for *switch*. And the immediates should be on the right side
of ==, anyway.

drivers/net/phy/mscc.c static int vsc85xx_config_init(struct phy_device *phydev) · line 1722

Quoted 7 lines
drivers/net/phy/mscc.c +4 -0
+		rc = vsc8531_pre_init_seq_set(phydev);
+		if (rc)
+			return rc;
+
  	rc = vsc85xx_eee_init_seq_set(phydev);
  	if (rc)
  		return rc;

MBR, Sergei