Merge branch 'master' of git://git.denx.de/u-boot into resolve
[platform/kernel/u-boot.git] / drivers / net / mcffec.c
index c00474e..ed7459c 100644 (file)
 #include <common.h>
 #include <malloc.h>
 
-#include <asm/fec.h>
-#include <asm/immap.h>
-
 #include <command.h>
 #include <net.h>
 #include <netdev.h>
 #include <miiphy.h>
 
+#include <asm/fec.h>
+#include <asm/immap.h>
+
 #undef ET_DEBUG
 #undef MII_DEBUG
 
@@ -95,24 +95,11 @@ struct fec_info_s fec_info[] = {
 #endif
 };
 
-int fec_send(struct eth_device *dev, volatile void *packet, int length);
 int fec_recv(struct eth_device *dev);
 int fec_init(struct eth_device *dev, bd_t * bd);
 void fec_halt(struct eth_device *dev);
 void fec_reset(struct eth_device *dev);
 
-extern int fecpin_setclear(struct eth_device *dev, int setclear);
-
-#ifdef CONFIG_SYS_DISCOVER_PHY
-extern void __mii_init(void);
-extern uint mii_send(uint mii_cmd);
-extern int mii_discover_phy(struct eth_device *dev);
-extern int mcffec_miiphy_read(char *devname, unsigned char addr,
-                             unsigned char reg, unsigned short *value);
-extern int mcffec_miiphy_write(char *devname, unsigned char addr,
-                              unsigned char reg, unsigned short value);
-#endif
-
 void setFecDuplexSpeed(volatile fec_t * fecp, bd_t * bd, int dup_spd)
 {
        if ((dup_spd >> 16) == FULL) {
@@ -146,14 +133,14 @@ void setFecDuplexSpeed(volatile fec_t * fecp, bd_t * bd, int dup_spd)
        }
 }
 
-int fec_send(struct eth_device *dev, volatile void *packet, int length)
+static int fec_send(struct eth_device *dev, void *packet, int length)
 {
        struct fec_info_s *info = dev->priv;
        volatile fec_t *fecp = (fec_t *) (info->iobase);
        int j, rc;
        u16 phyStatus;
 
-       miiphy_read(dev->name, info->phy_addr, PHY_BMSR, &phyStatus);
+       miiphy_read(dev->name, info->phy_addr, MII_BMSR, &phyStatus);
 
        /* section 16.9.23.3
         * Wait for ready
@@ -428,7 +415,7 @@ int fec_init(struct eth_device *dev, bd_t * bd)
        struct fec_info_s *info = dev->priv;
        volatile fec_t *fecp = (fec_t *) (info->iobase);
        int i;
-       u8 *ea = NULL;
+       uchar ea[6];
 
        fecpin_setclear(dev, 1);
 
@@ -456,25 +443,25 @@ int fec_init(struct eth_device *dev, bd_t * bd)
        if ((u32) fecp == CONFIG_SYS_FEC0_IOBASE) {
 #ifdef CONFIG_SYS_FEC1_IOBASE
                volatile fec_t *fecp1 = (fec_t *) (CONFIG_SYS_FEC1_IOBASE);
-               ea = &bd->bi_enet1addr[0];
+               eth_getenv_enetaddr("eth1addr", ea);
                fecp1->palr =
                    (ea[0] << 24) | (ea[1] << 16) | (ea[2] << 8) | (ea[3]);
                fecp1->paur = (ea[4] << 24) | (ea[5] << 16);
 #endif
-               ea = &bd->bi_enetaddr[0];
+               eth_getenv_enetaddr("ethaddr", ea);
                fecp->palr =
                    (ea[0] << 24) | (ea[1] << 16) | (ea[2] << 8) | (ea[3]);
                fecp->paur = (ea[4] << 24) | (ea[5] << 16);
        } else {
 #ifdef CONFIG_SYS_FEC0_IOBASE
                volatile fec_t *fecp0 = (fec_t *) (CONFIG_SYS_FEC0_IOBASE);
-               ea = &bd->bi_enetaddr[0];
+               eth_getenv_enetaddr("ethaddr", ea);
                fecp0->palr =
                    (ea[0] << 24) | (ea[1] << 16) | (ea[2] << 8) | (ea[3]);
                fecp0->paur = (ea[4] << 24) | (ea[5] << 16);
 #endif
 #ifdef CONFIG_SYS_FEC1_IOBASE
-               ea = &bd->bi_enet1addr[0];
+               eth_getenv_enetaddr("eth1addr", ea);
                fecp->palr =
                    (ea[0] << 24) | (ea[1] << 16) | (ea[2] << 8) | (ea[3]);
                fecp->paur = (ea[4] << 24) | (ea[5] << 16);