]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
NET: fec_mxc: fix MDIO clock prescaler calculation
authorMarkus Niebel <Markus.Niebel@tqs.de>
Wed, 5 Feb 2014 09:54:11 +0000 (10:54 +0100)
committerStefano Babic <sbabic@denx.de>
Tue, 11 Feb 2014 10:33:45 +0000 (11:33 +0100)
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

Signed-off-by: Markus Niebel <Markus.Niebel@tqs.de>
drivers/net/fec_mxc.c

index 3b2b995b53fd3d195a77294f547b83ae8f7eeaf7..4cefda48e45b533453a1671e1c3618ae6d4ba853 100644 (file)
@@ -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));
 }