aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/fec.c
diff options
context:
space:
mode:
authorMahesh Mahadevan <r9aadq@freescale.com>2011-10-25 08:29:15 -0500
committerEric Miao <eric.miao@canonical.com>2011-11-10 07:38:51 +0800
commit7e0d80125d69e24a0793d361d09ff2b301be2795 (patch)
tree1c91068007e5cb109eac0749fa2605df1e2bb506 /drivers/net/fec.c
parent174307d1e6ef9c9dd353462f9724b92aa6891201 (diff)
ENGR00160709-2 Move board specific code out of FEC driver
Move the board specific code out of the FEC driver to the platform layer Signed-off-by: Mahesh Mahadevan <r9aadq@freescale.com>
Diffstat (limited to 'drivers/net/fec.c')
-rw-r--r--drivers/net/fec.c47
1 files changed, 12 insertions, 35 deletions
diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index 736e30809b5..b294d99abd0 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -696,7 +696,7 @@ static int fec_enet_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
usecs_to_jiffies(FEC_MII_TIMEOUT));
if (time_left == 0) {
fep->mii_timeout = 1;
- printk(KERN_ERR "FEC: MDIO read timeout\n");
+ printk(KERN_ERR "FEC: MDIO read timeout, mii_id=%d\n", mii_id);
return -ETIMEDOUT;
}
@@ -724,37 +724,12 @@ static int fec_enet_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
usecs_to_jiffies(FEC_MII_TIMEOUT));
if (time_left == 0) {
fep->mii_timeout = 1;
- printk(KERN_ERR "FEC: MDIO write timeout\n");
+ printk(KERN_ERR "FEC: MDIO write timeout, mii_id=%d\n", mii_id);
return -ETIMEDOUT;
}
return 0;
}
-#ifdef CONFIG_MACH_MX6Q_SABREAUTO
-
-static int mx6_sabreauto_rework(struct mii_bus *bus)
-{
- unsigned short val;
-
- /* To enable AR8031 ouput a 125MHz clk from CLK_25M */
- fec_enet_mdio_write(bus, 0, 0xd, 0x7);
- fec_enet_mdio_write(bus, 0, 0xe, 0x8016);
- fec_enet_mdio_write(bus, 0, 0xd, 0x4007);
- val = fec_enet_mdio_read(bus, 0, 0xe);
-
- val &= 0xffe3;
- val |= 0x18;
- fec_enet_mdio_write(bus, 0, 0xe, val);
-
- /* introduce tx clock delay */
- fec_enet_mdio_write(bus, 0, 0x1d, 0x5);
- val = fec_enet_mdio_read(bus, 0, 0x1e);
- val |= 0x0100;
- fec_enet_mdio_write(bus, 0, 0x1e, val);
-
- return 0;
-}
-#endif
static int fec_enet_mdio_reset(struct mii_bus *bus)
{
@@ -860,10 +835,10 @@ static int fec_enet_mii_init(struct platform_device *pdev)
*/
fep->phy_speed = DIV_ROUND_UP(clk_get_rate(fep->clk), 5000000) << 1;
-#ifdef CONFIG_MACH_MX6Q_SABREAUTO
- /* FIXME: hard code to 0x1a for clock issue */
- fep->phy_speed = 0x11a;
-#endif
+ if (cpu_is_mx6q())
+ /* FIXME: hard code to 0x1a for clock issue */
+ fep->phy_speed = 0x11a;
+
writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
fep->mii_bus = mdiobus_alloc();
@@ -880,10 +855,6 @@ static int fec_enet_mii_init(struct platform_device *pdev)
fep->mii_bus->priv = fep;
fep->mii_bus->parent = &pdev->dev;
-#ifdef CONFIG_MACH_MX6Q_SABREAUTO
- mx6_sabreauto_rework(fep->mii_bus);
-#endif
-
fep->mii_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
if (!fep->mii_bus->irq) {
err = -ENOMEM;
@@ -1046,6 +1017,7 @@ static int
fec_enet_open(struct net_device *dev)
{
struct fec_enet_private *fep = netdev_priv(dev);
+ struct fec_platform_data *pdata = fep->pdev->dev.platform_data;
int ret;
/* I should reset the ring buffers here, but I don't yet know
@@ -1066,6 +1038,11 @@ fec_enet_open(struct net_device *dev)
phy_start(fep->phy_dev);
netif_start_queue(dev);
fep->opened = 1;
+
+ ret = -EINVAL;
+ if (pdata->init && pdata->init(fep->phy_dev))
+ return ret;
+
return 0;
}