diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2012-08-09 15:49:51 +0800 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-09-25 08:18:58 +0200 |
commit | 2263e27814f1db83745a9e65c373c957307c36a0 (patch) | |
tree | e0ce1c1acaef410531018e0d390854194ef91478 /drivers/net/smc911x.c | |
parent | 26eab97b41da45353300d447870fe1c7fbfe7542 (diff) | |
download | barebox-2263e27814f1db83745a9e65c373c957307c36a0.tar.gz barebox-2263e27814f1db83745a9e65c373c957307c36a0.tar.xz |
net: introduce phylib
Adapt phylib from linux
switch all the driver to it
reimplement mii bus
This will allow to have
- phy drivers
- to only connect the phy at then opening of the device
- if the phy is not ready or not up fail on open
Same behaviour as in linux and will allow to share code and simplify porting.
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Diffstat (limited to 'drivers/net/smc911x.c')
-rw-r--r-- | drivers/net/smc911x.c | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index f69760853d..c58ea72564 100644 --- a/drivers/net/smc911x.c +++ b/drivers/net/smc911x.c @@ -30,7 +30,6 @@ #include <command.h> #include <net.h> -#include <miidev.h> #include <malloc.h> #include <init.h> #include <xfuncs.h> @@ -38,12 +37,13 @@ #include <clock.h> #include <io.h> #include <smc911x.h> +#include <linux/phy.h> #include "smc911x.h" struct smc911x_priv { struct eth_device edev; - struct mii_device miidev; + struct mii_bus miibus; void __iomem *base; int shift; @@ -198,9 +198,9 @@ static int smc911x_set_ethaddr(struct eth_device *edev, unsigned char *m) return 0; } -static int smc911x_phy_read(struct mii_device *mdev, int phy_addr, int reg) +static int smc911x_phy_read(struct mii_bus *bus, int phy_addr, int reg) { - struct eth_device *edev = mdev->edev; + struct eth_device *edev = bus->priv; while (smc911x_get_mac_csr(edev, MII_ACC) & MII_ACC_MII_BUSY); @@ -212,10 +212,10 @@ static int smc911x_phy_read(struct mii_device *mdev, int phy_addr, int reg) return smc911x_get_mac_csr(edev, MII_DATA); } -static int smc911x_phy_write(struct mii_device *mdev, int phy_addr, - int reg, int val) +static int smc911x_phy_write(struct mii_bus *bus, int phy_addr, + int reg, u16 val) { - struct eth_device *edev = mdev->edev; + struct eth_device *edev = bus->priv; while (smc911x_get_mac_csr(edev, MII_ACC) & MII_ACC_MII_BUSY); @@ -308,9 +308,12 @@ static void smc911x_enable(struct eth_device *edev) static int smc911x_eth_open(struct eth_device *edev) { struct smc911x_priv *priv = (struct smc911x_priv *)edev->priv; + int ret; - miidev_wait_aneg(&priv->miidev); - miidev_print_status(&priv->miidev); + ret = phy_device_connect(edev, &priv->miibus, 1, NULL, + 0, PHY_INTERFACE_MODE_NA); + if (ret) + return ret; /* Turn on Tx + Rx */ smc911x_enable(edev); @@ -405,13 +408,9 @@ static int smc911x_eth_rx(struct eth_device *edev) static int smc911x_init_dev(struct eth_device *edev) { - struct smc911x_priv *priv = (struct smc911x_priv *)edev->priv; - smc911x_set_mac_csr(edev, MAC_CR, MAC_CR_TXEN | MAC_CR_RXEN | MAC_CR_HBDIS); - miidev_restart_aneg(&priv->miidev); - return 0; } @@ -536,17 +535,15 @@ static int smc911x_probe(struct device_d *dev) edev->set_ethaddr = smc911x_set_ethaddr; edev->parent = dev; - priv->miidev.read = smc911x_phy_read; - priv->miidev.write = smc911x_phy_write; - priv->miidev.address = 1; - priv->miidev.flags = 0; - priv->miidev.edev = edev; - priv->miidev.parent = dev; + priv->miibus.read = smc911x_phy_read; + priv->miibus.write = smc911x_phy_write; + priv->miibus.priv = edev; + priv->miibus.parent = dev; smc911x_reset(edev); smc911x_phy_reset(edev); - mii_register(&priv->miidev); + mdiobus_register(&priv->miibus); eth_register(edev); return 0; |