Skip to contentSkip to conversation

NET: fec_mxc: fix MDIO clock prescaler calculation

PATCH New Markus Niebel 2 participants 3 messages Feb 5, 2014 – Feb 11, 2014 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NET: fec_mxc: fix MDIO clock prescaler calculation

From: Markus Niebel <[email protected]>

The prescaler value for MDC is calculated wrong for MX6S. Implement the same logic as linux here which handles ENET_MAC different then original FEC.

Tested on a custom board with i.MX6S and 100MBit PHY

---
 drivers/net/fec_mxc.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/fec_mxc.c +6 -2
index 3b2b995..4cefda4 100644
@@ -128,8 +128,12 @@ static void fec_mii_setspeed(struct ethernet_regs *eth)
 	 * Set MII_SPEED = (1/(mii_speed * 2)) * System Clock
 	 * and do not drop the Preamble.
 	 */
-	writel((((imx_get_fecclk() / 1000000) + 2) / 5) << 1,
-			&eth->mii_speed);
+	register u32 speed = DIV_ROUND_UP(imx_get_fecclk(), 5000000);
+#ifdef FEC_QUIRK_ENET_MAC
+	speed--;
+#endif
+	speed <<= 1;
+	writel(speed, &eth->mii_speed);
 	debug("%s: mii_speed %08x\n", __func__, readl(&eth->mii_speed));
 }
 
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 NET: fec_mxc: fix MDIO clock prescaler calculation

Hi Marcus,

Quoted 21 lines · Markus Niebel

From: Markus Niebel <[email protected]>

The prescaler value for MDC is calculated wrong for MX6S. Implement the same logic as linux here which handles ENET_MAC different then original FEC.

Tested on a custom board with i.MX6S and 100MBit PHY

---
 drivers/net/fec_mxc.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/fec_mxc.c +0 -0
index 3b2b995..4cefda4 100644
@@ -128,8 +128,12 @@ static void fec_mii_setspeed(struct ethernet_regs *eth)
 	 * Set MII_SPEED = (1/(mii_speed * 2)) * System Clock
 	 * and do not drop the Preamble.
 	 */

drivers/net/fec_mxc.c static void fec_mii_setspeed(struct ethernet_regs *eth) · line 138

Quoted 10 lines
drivers/net/fec_mxc.c +6 -2
-	writel((((imx_get_fecclk() / 1000000) + 2) / 5) << 1,
-			&eth->mii_speed);
+	register u32 speed = DIV_ROUND_UP(imx_get_fecclk(), 5000000);
+#ifdef FEC_QUIRK_ENET_MAC
+	speed--;
+#endif
+	speed <<= 1;
+	writel(speed, &eth->mii_speed);
 	debug("%s: mii_speed %08x\n", __func__, readl(&eth->mii_speed));
 }

Thanks for this - I go for merging..

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#2 lore raw

PATCH 1/1 NET: fec_mxc: fix MDIO clock prescaler calculation

In reply to Markus Niebel
Quoted 10 lines · Markus Niebel

From: Markus Niebel <[email protected]>

The prescaler value for MDC is calculated wrong for MX6S. Implement the same logic as linux here which handles ENET_MAC different then original FEC.

Tested on a custom board with i.MX6S and 100MBit PHY

---

Applied to u-boot-imx, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================