]> git.sur5r.net Git - u-boot/blobdiff - drivers/net/mcffec.c
net: Move enetaddr env access code to env config instead of net config
[u-boot] / drivers / net / mcffec.c
index 6b537d505ecb2bd8e293de1c2bc915dd919038a5..505a2d1bee8e4cc5be80f9f9181283e2eccb83cc 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include <common.h>
+#include <environment.h>
 #include <malloc.h>
 
 #include <command.h>
@@ -219,7 +220,8 @@ int fec_recv(struct eth_device *dev)
 
                        length -= 4;
                        /* Pass the packet up to the protocol layers. */
-                       NetReceive(NetRxPackets[info->rxIdx], length);
+                       net_process_received_packet(net_rx_packets[info->rxIdx],
+                                                   length);
 
                        fecp->eir |= FEC_EIR_RXF;
                }
@@ -427,25 +429,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);
-               eth_getenv_enetaddr("eth1addr", ea);
+               eth_env_get_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
-               eth_getenv_enetaddr("ethaddr", ea);
+               eth_env_get_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);
-               eth_getenv_enetaddr("ethaddr", ea);
+               eth_env_get_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
-               eth_getenv_enetaddr("eth1addr", ea);
+               eth_env_get_enetaddr("eth1addr", ea);
                fecp->palr =
                    (ea[0] << 24) | (ea[1] << 16) | (ea[2] << 8) | (ea[3]);
                fecp->paur = (ea[4] << 24) | (ea[5] << 16);
@@ -464,7 +466,7 @@ int fec_init(struct eth_device *dev, bd_t * bd)
        fecp->emrbr = PKT_MAXBLR_SIZE;
 
        /*
-        * Setup Buffers and Buffer Desriptors
+        * Setup Buffers and Buffer Descriptors
         */
        info->rxIdx = 0;
        info->txIdx = 0;
@@ -477,7 +479,7 @@ int fec_init(struct eth_device *dev, bd_t * bd)
        for (i = 0; i < PKTBUFSRX; i++) {
                info->rxbd[i].cbd_sc = BD_ENET_RX_EMPTY;
                info->rxbd[i].cbd_datlen = 0;   /* Reset */
-               info->rxbd[i].cbd_bufaddr = (uint) NetRxPackets[i];
+               info->rxbd[i].cbd_bufaddr = (uint) net_rx_packets[i];
        }
        info->rxbd[PKTBUFSRX - 1].cbd_sc |= BD_ENET_RX_WRAP;
 
@@ -543,7 +545,7 @@ int mcffec_initialize(bd_t * bis)
        u32 tmp = CONFIG_SYS_INIT_RAM_ADDR + 0x1000;
 #endif
 
-       for (i = 0; i < sizeof(fec_info) / sizeof(fec_info[0]); i++) {
+       for (i = 0; i < ARRAY_SIZE(fec_info); i++) {
 
                dev =
                    (struct eth_device *)memalign(CONFIG_SYS_CACHELINE_SIZE,
@@ -594,8 +596,17 @@ int mcffec_initialize(bd_t * bis)
                eth_register(dev);
 
 #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
-               miiphy_register(dev->name,
-                               mcffec_miiphy_read, mcffec_miiphy_write);
+               int retval;
+               struct mii_dev *mdiodev = mdio_alloc();
+               if (!mdiodev)
+                       return -ENOMEM;
+               strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN);
+               mdiodev->read = mcffec_miiphy_read;
+               mdiodev->write = mcffec_miiphy_write;
+
+               retval = mdio_register(mdiodev);
+               if (retval < 0)
+                       return retval;
 #endif
                if (i > 0)
                        fec_info[i - 1].next = &fec_info[i];