diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2007-07-05 18:02:06 +0200 |
---|---|---|
committer | Sascha Hauer <sha@octopus.labnet.pengutronix.de> | 2007-07-05 18:02:06 +0200 |
commit | 9ff9f6a5efb962c5a76bb745db0bbd459a4ecccd (patch) | |
tree | eac7b55e8d0bb772e082aff1da3161eb76fe2d75 | |
parent | 5fd7544b329644aea342742f84bed93ccc481a4c (diff) | |
download | barebox-9ff9f6a5efb962c5a76bb745db0bbd459a4ecccd.tar.gz barebox-9ff9f6a5efb962c5a76bb745db0bbd459a4ecccd.tar.xz |
svn_rev_579
miiphy
-rw-r--r-- | drivers/net/fec_mpc5200.c | 2 | ||||
-rw-r--r-- | drivers/net/fec_mpc5200.h | 1 | ||||
-rw-r--r-- | drivers/net/miiphy.c | 40 | ||||
-rw-r--r-- | include/miiphy.h | 2 |
4 files changed, 23 insertions, 22 deletions
diff --git a/drivers/net/fec_mpc5200.c b/drivers/net/fec_mpc5200.c index 0ce88944c9..a1c100e802 100644 --- a/drivers/net/fec_mpc5200.c +++ b/drivers/net/fec_mpc5200.c @@ -15,7 +15,7 @@ #include <driver.h> #include <asm/arch/sdma.h> #include <asm/arch/fec.h> -#include <mii_phy.h> +#include <miiphy.h> #include "fec_mpc5200.h" DECLARE_GLOBAL_DATA_PTR; diff --git a/drivers/net/fec_mpc5200.h b/drivers/net/fec_mpc5200.h index 001753b41a..1a2790270d 100644 --- a/drivers/net/fec_mpc5200.h +++ b/drivers/net/fec_mpc5200.h @@ -14,7 +14,6 @@ #include <common.h> #include <mpc5xxx.h> #include <asm/arch/sdma.h> -#include <mii_phy.h> typedef unsigned long uint32; typedef unsigned short uint16; diff --git a/drivers/net/miiphy.c b/drivers/net/miiphy.c index 8f810f54d1..e9652da4c4 100644 --- a/drivers/net/miiphy.c +++ b/drivers/net/miiphy.c @@ -1,7 +1,7 @@ #include <common.h> #include <driver.h> #include <init.h> -#include <mii_phy.h> +#include <miiphy.h> int miiphy_restart_aneg(struct miiphy_device *mdev) { @@ -11,13 +11,13 @@ int miiphy_restart_aneg(struct miiphy_device *mdev) /* * Reset PHY, then delay 300ns */ - mdev->write(mdev, mdev->address, PHY_BMCR, PHY_BMCR_RESET); + mdev->write(mdev, mdev->address, MII_BMCR, BMCR_RESET); udelay(1000); if (mdev->flags & MIIPHY_FORCE_10) { printf("Forcing 10 Mbps ethernet link... "); - mdev->read(mdev, mdev->address, PHY_BMSR, &status); - mdev->write(mdev, mdev->address, PHY_BMCR, PHY_BMCR_DPLX | PHY_BMCR_COL_TST); + mdev->read(mdev, mdev->address, MII_BMSR, &status); + mdev->write(mdev, mdev->address, MII_BMCR, BMCR_FULLDPLX | BMCR_CTST); timeout = 20; do { /* wait for link status to go down */ @@ -28,16 +28,16 @@ int miiphy_restart_aneg(struct miiphy_device *mdev) #endif break; } - mdev->read(mdev, mdev->address, PHY_BMSR, &status); - } while (status & PHY_BMSR_LS); + mdev->read(mdev, mdev->address, MII_BMSR, &status); + } while (status & BMSR_LSTATUS); } else { /* MII100 */ /* * Set the auto-negotiation advertisement register bits */ - mdev->write(mdev, mdev->address, PHY_ANAR, 0x01e1); + mdev->write(mdev, mdev->address, MII_ADVERTISE, ADVERTISE_ALL); - mdev->write(mdev, mdev->address, PHY_BMCR, PHY_BMCR_AUTON | PHY_BMCR_RST_NEG); + mdev->write(mdev, mdev->address, MII_BMCR, BMCR_ANENABLE | BMCR_ANRESTART); } return 0; @@ -60,37 +60,37 @@ int miiphy_wait_aneg(struct miiphy_device *mdev) return -1; } - if (mdev->read(mdev, mdev->address, PHY_BMSR, &status)) { + if (mdev->read(mdev, mdev->address, MII_BMSR, &status)) { printf("%s: Autonegotiation failed. status: 0x%04x\n", mdev->dev.id, status); return -1; } - } while (!(status & PHY_BMSR_LS)); + } while (!(status & BMSR_LSTATUS)); return 0; } int miiphy_print_status(struct miiphy_device *mdev) { - uint16_t bmsr, bmcr, anlpar; + uint16_t bmsr, bmcr, lpa; char *duplex; int speed; - if (mdev->read(mdev, mdev->address, PHY_BMSR, &bmsr) != 0) + if (mdev->read(mdev, mdev->address, MII_BMSR, &bmsr) != 0) goto err_out; - if (mdev->read(mdev, mdev->address, PHY_BMCR, &bmcr) != 0) + if (mdev->read(mdev, mdev->address, MII_BMCR, &bmcr) != 0) goto err_out; - if (mdev->read(mdev, mdev->address, PHY_ANLPAR, &anlpar) != 0) + if (mdev->read(mdev, mdev->address, MII_LPA, &lpa) != 0) goto err_out; printf("%s: Link is %s", mdev->dev.id, - bmsr & PHY_BMSR_LS ? "up" : "down"); + bmsr & BMSR_LSTATUS ? "up" : "down"); - if (bmcr & PHY_BMCR_AUTON) { - duplex = (PHY_ANLPAR_10FD | PHY_ANLPAR_TXFD) ? "Full" : "Half"; - speed = anlpar & PHY_ANLPAR_100 ? 100 : 10; + if (bmcr & BMCR_ANENABLE) { + duplex = lpa & LPA_DUPLEX ? "Full" : "Half"; + speed = lpa & LPA_100 ? 100 : 10; } else { - duplex = bmcr & PHY_BMCR_DPLX ? "Full" : "Half"; - speed = bmcr & PHY_BMCR_100MB ? 100 : 10; + duplex = bmcr & BMCR_FULLDPLX ? "Full" : "Half"; + speed = bmcr & BMCR_SPEED100 ? 100 : 10; } printf(" - %d/%s\n", speed, duplex); diff --git a/include/miiphy.h b/include/miiphy.h index e5ab4df316..2c8d0ec22c 100644 --- a/include/miiphy.h +++ b/include/miiphy.h @@ -8,6 +8,8 @@ #ifndef _MII_PHY_H_ #define _MII_PHY_H_ +#include <driver.h> + #define MIIPHY_FORCE_10 1 #define MII_BMCR 0x00 /* Basic mode control register */ |