]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - arch/powerpc/cpu/mpc8xx/fec.c
powerpc: Drop CONFIG_SYS_ALLOC_DPRAM
[people/ms/u-boot.git] / arch / powerpc / cpu / mpc8xx / fec.c
index 2e196033c240af33a4dbc0b8ccd765a0a2857b25..b27310fffb97bb46b03652a7dafe5a08472b8b80 100644 (file)
@@ -6,10 +6,12 @@
  */
 
 #include <common.h>
-#include <malloc.h>
+#include <command.h>
 #include <commproc.h>
+#include <malloc.h>
 #include <net.h>
-#include <command.h>
+
+#include <phy.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -47,10 +49,9 @@ DECLARE_GLOBAL_DATA_PTR;
 static int mii_discover_phy(struct eth_device *dev);
 #endif
 
-int fec8xx_miiphy_read(const char *devname, unsigned char addr,
-               unsigned char  reg, unsigned short *value);
-int fec8xx_miiphy_write(const char *devname, unsigned char  addr,
-               unsigned char  reg, unsigned short value);
+int fec8xx_miiphy_read(struct mii_dev *bus, int addr, int devad, int reg);
+int fec8xx_miiphy_write(struct mii_dev *bus, int addr, int devad, int reg,
+                       u16 value);
 
 static struct ether_fcc_info_s
 {
@@ -137,7 +138,7 @@ int fec_initialize(bd_t *bis)
        struct ether_fcc_info_s *efis;
        int             i;
 
-       for (i = 0; i < sizeof(ether_fcc_info) / sizeof(ether_fcc_info[0]); i++) {
+       for (i = 0; i < ARRAY_SIZE(ether_fcc_info); i++) {
 
                dev = malloc(sizeof(*dev));
                if (dev == NULL)
@@ -148,7 +149,7 @@ int fec_initialize(bd_t *bis)
                /* for FEC1 make sure that the name of the interface is the same
                   as the old one for compatibility reasons */
                if (i == 0) {
-                       sprintf (dev->name, "FEC");
+                       strcpy(dev->name, "FEC");
                } else {
                        sprintf (dev->name, "FEC%d",
                                ether_fcc_info[i].ether_index + 1);
@@ -170,8 +171,17 @@ int fec_initialize(bd_t *bis)
                eth_register(dev);
 
 #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
-               miiphy_register(dev->name,
-                       fec8xx_miiphy_read, fec8xx_miiphy_write);
+               int retval;
+               struct mii_dev *mdiodev = mdio_alloc();
+               if (!mdiodev)
+                       return -ENOMEM;
+               strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN);
+               mdiodev->read = fec8xx_miiphy_read;
+               mdiodev->write = fec8xx_miiphy_write;
+
+               retval = mdio_register(mdiodev);
+               if (retval < 0)
+                       return retval;
 #endif
        }
        return 1;
@@ -560,14 +570,8 @@ static int fec_init (struct eth_device *dev, bd_t * bd)
        rxIdx = 0;
        txIdx = 0;
 
-       if (!rtx) {
-#ifdef CONFIG_SYS_ALLOC_DPRAM
-               rtx = (RTXBD *) (immr->im_cpm.cp_dpmem +
-                                dpram_alloc_align (sizeof (RTXBD), 8));
-#else
-               rtx = (RTXBD *) (immr->im_cpm.cp_dpmem + CPM_FEC_BASE);
-#endif
-       }
+       if (!rtx)
+               rtx = (RTXBD *)(immr->im_cpm.cp_dpmem + CPM_FEC_BASE);
        /*
         * Setup Receiver Buffer Descriptors (13.14.24.18)
         * Settings:
@@ -879,7 +883,7 @@ void mii_init (void)
 
        /* Setup the pin configuration of the FEC(s)
        */
-       for (i = 0; i < sizeof(ether_fcc_info) / sizeof(ether_fcc_info[0]); i++)
+       for (i = 0; i < ARRAY_SIZE(ether_fcc_info); i++)
                fec_pin_init(ether_fcc_info[i].ether_index);
 }
 
@@ -894,9 +898,9 @@ void mii_init (void)
  *       Otherwise they hang in mii_send() !!! Sorry!
  *****************************************************************************/
 
-int fec8xx_miiphy_read(const char *devname, unsigned char addr,
-               unsigned char  reg, unsigned short *value)
+int fec8xx_miiphy_read(struct mii_dev *bus, int addr, int devad, int reg)
 {
+       unsigned short value = 0;
        short rdreg;    /* register working value */
 
 #ifdef MII_DEBUG
@@ -904,15 +908,15 @@ int fec8xx_miiphy_read(const char *devname, unsigned char addr,
 #endif
        rdreg = mii_send(mk_mii_read(addr, reg));
 
-       *value = rdreg;
+       value = rdreg;
 #ifdef MII_DEBUG
-       printf ("0x%04x\n", *value);
+       printf ("0x%04x\n", value);
 #endif
-       return 0;
+       return value;
 }
 
-int fec8xx_miiphy_write(const char *devname, unsigned char  addr,
-               unsigned char  reg, unsigned short value)
+int fec8xx_miiphy_write(struct mii_dev *bus, int addr, int devad, int reg,
+                       u16 value)
 {
 #ifdef MII_DEBUG
        printf ("miiphy_write(0x%x) @ 0x%x = ", reg, addr);