summaryrefslogtreecommitdiff
path: root/drivers/net
diff options
context:
space:
mode:
authorBryan Wu <bryan.wu@canonical.com>2010-04-22 13:49:48 +0800
committerRob Herring <r.herring@freescale.com>2010-05-05 17:41:30 -0500
commit8e716e445a4411cca7274a12320d5e74df13f47b (patch)
tree26405c10bb1ba43c5398170a1d1a9adbda574a26 /drivers/net
parentaf5569b47267abf4682543eb3799ebe63d4ced97 (diff)
UBUNTU: SAUCE: (upstream) netdev/fec: fix phy_speed caculating
BugLink: http://bugs.launchpad.net/bugs/546649 BugLink: http://bugs.launchpad.net/bugs/457878 - remove duplicated phy_speed caculation - fix the phy_speed caculation according to the DataSheet Signed-off-by: Bryan Wu <bryan.wu@canonical.com> Acked-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andy Whitcroft <apw@canonical.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/fec.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index 34556b5627cb..29adc810fce8 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -763,10 +763,9 @@ static int fec_enet_mii_init(struct platform_device *pdev)
fep->mii_timeout = 0;
/*
- * Set MII speed to 2.5 MHz
+ * Set MII speed to 2.5 MHz (= clk_get_rate() / 2 * phy_speed)
*/
- fep->phy_speed = ((((clk_get_rate(fep->clk) / 2 + 4999999)
- / 2500000) / 2) & 0x3F) << 1;
+ fep->phy_speed = DIV_ROUND_UP(clk_get_rate(fep->clk), 5000000) << 1;
writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
fep->mii_bus = mdiobus_alloc();
@@ -1195,10 +1194,6 @@ int __init fec_enet_init(struct net_device *dev, int index)
dev->netdev_ops = &fec_netdev_ops;
dev->ethtool_ops = &fec_enet_ethtool_ops;
- /* Set MII speed to 2.5 MHz */
- fep->phy_speed = ((((clk_get_rate(fep->clk) / 2 + 4999999)
- / 2500000) / 2) & 0x3F) << 1;
-
#ifdef CONFIG_ARCH_MXS
/* Can't get phy(8720) ID when set to 2.5M, lower it*/
fep->phy_speed <<= 2;