Skip to contentSkip to conversation

net: phy: microchip_t1: add lan87xx_config_rgmii_delay for lan87xx phy

PATCH In review Yuiko Oshino 2 participants 3 messages Nov 1, 2021 – Nov 2, 2021

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

PATCH 1/1 net: phy: microchip_t1: add lan87xx_config_rgmii_delay for lan87xx phy

Add a function to initialize phy rgmii delay according to phydev->interface.

---
 drivers/net/phy/microchip_t1.c | 44 +++++++++++++++++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)
drivers/net/phy/microchip_t1.c +43 -1
index a4de3d2081c5..bc50224d43dd 100644
@@ -28,6 +28,11 @@
 #define LAN87XX_MASK_LINK_UP                    (0x0004)
 #define LAN87XX_MASK_LINK_DOWN                  (0x0002)
 
+/* MISC Control 1 Register */
+#define LAN87XX_CTRL_1                          (0x11)
+#define LAN87XX_MASK_RGMII_TXC_DLY_EN           (0x4000)
+#define LAN87XX_MASK_RGMII_RXC_DLY_EN           (0x2000)
+
 /* phyaccess nested types */
 #define	PHYACC_ATTR_MODE_READ		0
 #define	PHYACC_ATTR_MODE_WRITE		1
@@ -112,6 +117,43 @@ static int access_ereg_modify_changed(struct phy_device *phydev,
 	return rc;
 }
 
+static int lan87xx_config_rgmii_delay(struct phy_device *phydev)
+{
+	int rc;
+
+	if (!phy_interface_is_rgmii(phydev))
+		return 0;
+
+	rc = access_ereg(phydev, PHYACC_ATTR_MODE_READ,
+			 PHYACC_ATTR_BANK_MISC, LAN87XX_CTRL_1, 0);
+	if (rc < 0)
+		return rc;
+
+	switch (phydev->interface) {
+	case PHY_INTERFACE_MODE_RGMII:
+		rc &= ~LAN87XX_MASK_RGMII_TXC_DLY_EN;
+		rc &= ~LAN87XX_MASK_RGMII_RXC_DLY_EN;
+		break;
+	case PHY_INTERFACE_MODE_RGMII_ID:
+		rc |= LAN87XX_MASK_RGMII_TXC_DLY_EN;
+		rc |= LAN87XX_MASK_RGMII_RXC_DLY_EN;
+		break;
+	case PHY_INTERFACE_MODE_RGMII_RXID:
+		rc &= ~LAN87XX_MASK_RGMII_TXC_DLY_EN;
+		rc |= LAN87XX_MASK_RGMII_RXC_DLY_EN;
+		break;
+	case PHY_INTERFACE_MODE_RGMII_TXID:
+		rc |= LAN87XX_MASK_RGMII_TXC_DLY_EN;
+		rc &= ~LAN87XX_MASK_RGMII_RXC_DLY_EN;
+		break;
+	default:
+		return 0;
+	}
+
+	return access_ereg(phydev, PHYACC_ATTR_MODE_WRITE,
+			   PHYACC_ATTR_BANK_MISC, LAN87XX_CTRL_1, rc);
+}
+
 static int lan87xx_phy_init(struct phy_device *phydev)
 {
 	static const struct access_ereg_val init[] = {
@@ -185,7 +227,7 @@ static int lan87xx_phy_init(struct phy_device *phydev)
 			return rc;
 	}
 
-	return 0;
+	return lan87xx_config_rgmii_delay(phydev);
 }
 
 static int lan87xx_phy_config_intr(struct phy_device *phydev)
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 1 line · Yuiko Oshino

Add a function to initialize phy rgmii delay according to phydev->interface.

How does this differ to the first version you posted?

Andrew

#2 lore raw

Hi Andrew,

I forgot to add "PATCH" in the first version of the subject. Sorry to confuse you. I was not sure where I should mention that I forgot it.

Thank you for your review.
Best regards,
Yuiko

Quoted 19 lines

-----Original Message-----
From: Andrew Lunn <[email protected]>
Sent: Tuesday, November 2, 2021 1:07 PM
To: Yuiko Oshino - C18177 <[email protected]>
Cc: [email protected]; [email protected]; Nisar Sayed - I17970 <[email protected]>; UNGLinuxDriver <[email protected]>
Subject: Re: [PATCH net-next] net: phy: microchip_t1: add lan87xx_config_rgmii_delay for lan87xx phy

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Quoted 1 line · Yuiko Oshino

Add a function to initialize phy rgmii delay according to phydev->interface.

How does this differ to the first version you posted?

Andrew