]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - cpu/mpc8260/ether_fcc.c
rename CFG_ macros to CONFIG_SYS
[karo-tx-uboot.git] / cpu / mpc8260 / ether_fcc.c
index 76645f3e02fcae8bf747984b68bb8a05f1d6e5bc..3ab57eb5b4eb7ba3f88950d935ddc64bf599b772 100644 (file)
 #include <config.h>
 #include <net.h>
 
-#if defined(CONFIG_ETHER_ON_FCC) && (CONFIG_COMMANDS & CFG_CMD_NET) && \
+#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
+#include <miiphy.h>
+#endif
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#if defined(CONFIG_ETHER_ON_FCC) && defined(CONFIG_CMD_NET) && \
        defined(CONFIG_NET_MULTI)
 
 static struct ether_fcc_info_s
@@ -67,8 +73,8 @@ static struct ether_fcc_info_s
        PROFF_FCC1,
        CPM_CR_FCC1_SBLOCK,
        CPM_CR_FCC1_PAGE,
-       CFG_CMXFCR_MASK1,
-       CFG_CMXFCR_VALUE1
+       CONFIG_SYS_CMXFCR_MASK1,
+       CONFIG_SYS_CMXFCR_VALUE1
 },
 #endif
 
@@ -78,8 +84,8 @@ static struct ether_fcc_info_s
        PROFF_FCC2,
        CPM_CR_FCC2_SBLOCK,
        CPM_CR_FCC2_PAGE,
-       CFG_CMXFCR_MASK2,
-       CFG_CMXFCR_VALUE2
+       CONFIG_SYS_CMXFCR_MASK2,
+       CONFIG_SYS_CMXFCR_VALUE2
 },
 #endif
 
@@ -89,8 +95,8 @@ static struct ether_fcc_info_s
        PROFF_FCC3,
        CPM_CR_FCC3_SBLOCK,
        CPM_CR_FCC3_PAGE,
-       CFG_CMXFCR_MASK3,
-       CFG_CMXFCR_VALUE3
+       CONFIG_SYS_CMXFCR_MASK3,
+       CONFIG_SYS_CMXFCR_VALUE3
 },
 #endif
 };
@@ -149,7 +155,7 @@ static int fec_send(struct eth_device* dev, volatile void *packet, int length)
 
     for(i=0; rtx.txbd[txIdx].cbd_sc & BD_ENET_TX_READY; i++) {
        if (i >= TOUT_LOOP) {
-           printf("fec: tx buffer not ready\n");
+           puts ("fec: tx buffer not ready\n");
            goto out;
        }
     }
@@ -161,7 +167,7 @@ static int fec_send(struct eth_device* dev, volatile void *packet, int length)
 
     for(i=0; rtx.txbd[txIdx].cbd_sc & BD_ENET_TX_READY; i++) {
        if (i >= TOUT_LOOP) {
-           printf("fec: tx error\n");
+           puts ("fec: tx error\n");
            goto out;
        }
     }
@@ -219,7 +225,7 @@ static int fec_init(struct eth_device* dev, bd_t *bis)
 {
     struct ether_fcc_info_s * info = dev->priv;
     int i;
-    volatile immap_t *immr = (immap_t *)CFG_IMMR;
+    volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
     volatile cpm8260_t *cp = &(immr->im_cpm);
     fcc_enet_t *pram_ptr;
     unsigned long mem_addr;
@@ -233,14 +239,14 @@ static int fec_init(struct eth_device* dev, bd_t *bis)
     /* 28.9 - (3): connect FCC's tx and rx clocks */
     immr->im_cpmux.cmx_uar = 0;
     immr->im_cpmux.cmx_fcr = (immr->im_cpmux.cmx_fcr & ~info->cmxfcr_mask) |
-                                                       info->cmxfcr_value;
+                                                       info->cmxfcr_value;
 
     /* 28.9 - (4): GFMR: disable tx/rx, CCITT CRC, Mode Ethernet */
     immr->im_fcc[info->ether_index].fcc_gfmr =
       FCC_GFMR_MODE_ENET | FCC_GFMR_TCRC_32;
 
     /* 28.9 - (5): FPSMR: enable full duplex, select CCITT CRC for Ethernet */
-    immr->im_fcc[info->ether_index].fcc_fpsmr = CFG_FCC_PSMR | FCC_PSMR_ENCRC;
+    immr->im_fcc[info->ether_index].fcc_fpsmr = CONFIG_SYS_FCC_PSMR | FCC_PSMR_ENCRC;
 
     /* 28.9 - (6): FDSR: Ethernet Syn */
     immr->im_fcc[info->ether_index].fcc_fdsr = 0xD555;
@@ -290,10 +296,10 @@ static int fec_init(struct eth_device* dev, bd_t *bis)
      */
     pram_ptr->fen_genfcc.fcc_mrblr = PKT_MAXBLR_SIZE;
     pram_ptr->fen_genfcc.fcc_rstate = (CPMFCR_GBL | CPMFCR_EB |
-                                      CFG_CPMFCR_RAMTYPE) << 24;
+                                      CONFIG_SYS_CPMFCR_RAMTYPE) << 24;
     pram_ptr->fen_genfcc.fcc_rbase = (unsigned int)(&rtx.rxbd[rxIdx]);
     pram_ptr->fen_genfcc.fcc_tstate = (CPMFCR_GBL | CPMFCR_EB |
-                                      CFG_CPMFCR_RAMTYPE) << 24;
+                                      CONFIG_SYS_CPMFCR_RAMTYPE) << 24;
     pram_ptr->fen_genfcc.fcc_tbase = (unsigned int)(&rtx.txbd[txIdx]);
 
     /* protocol-specific area */
@@ -360,7 +366,7 @@ static int fec_init(struct eth_device* dev, bd_t *bis)
 static void fec_halt(struct eth_device* dev)
 {
     struct ether_fcc_info_s * info = dev->priv;
-    volatile immap_t *immr = (immap_t *)CFG_IMMR;
+    volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
 
     /* write GFMR: disable tx/rx */
     immr->im_fcc[info->ether_index].fcc_gfmr &=
@@ -378,7 +384,7 @@ int fec_initialize(bd_t *bis)
                memset(dev, 0, sizeof *dev);
 
                sprintf(dev->name, "FCC%d ETHERNET",
-                       ether_fcc_info[i].ether_index + 1);
+                       ether_fcc_info[i].ether_index + 1);
                dev->priv   = &ether_fcc_info[i];
                dev->init   = fec_init;
                dev->halt   = fec_halt;
@@ -386,6 +392,12 @@ int fec_initialize(bd_t *bis)
                dev->recv   = fec_recv;
 
                eth_register(dev);
+
+#if (defined(CONFIG_MII) || defined(CONFIG_CMD_MII)) \
+               && defined(CONFIG_BITBANGMII)
+               miiphy_register(dev->name,
+                               bb_miiphy_read, bb_miiphy_write);
+#endif
        }
 
        return 1;
@@ -522,7 +534,7 @@ print_desc (elbt_prdesc descs[], int ndesc, uchar *bases[], int nbase)
        for (i = 0; i < nbase; i++)
                printf ("  Channel %d", i);
 
-       puts ("\n");
+       putc ('\n');
 
        while (dp < edp) {
 
@@ -534,7 +546,7 @@ print_desc (elbt_prdesc descs[], int ndesc, uchar *bases[], int nbase)
                        printf (" %10u", val);
                }
 
-               puts ("\n");
+               putc ('\n');
 
                dp++;
        }
@@ -628,12 +640,13 @@ swap16 (unsigned short x)
        return (((x & 0xff) << 8) | ((x & 0xff00) >> 8));
 }
 
+/* broadcast is not an error - we send them like that */
+#define BD_ENET_RX_ERRS        (BD_ENET_RX_STATS & ~BD_ENET_RX_BC)
+
 void
 eth_loopback_test (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
-       volatile immap_t *immr = (immap_t *)CFG_IMMR;
+       volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
        volatile cpm8260_t *cp = &(immr->im_cpm);
        int c, nclosed;
        ulong runtime, nmsec;
@@ -652,10 +665,10 @@ eth_loopback_test (void)
 #if defined(CONFIG_HYMOD)
        /*
         * Attention: this is board-specific
-        * 0, FCC1 
-        * 1, FCC2 
-        * 2, FCC3 
-         */
+        * 0, FCC1
+        * 1, FCC2
+        * 2, FCC3
+        */
 #       define FCC_START_LOOP 0
 #       define FCC_END_LOOP   2
 
@@ -677,8 +690,8 @@ eth_loopback_test (void)
 #elif defined(CONFIG_SBC8260) || defined(CONFIG_SACSng)
        /*
         * Attention: this is board-specific
-        * 1, FCC2 
-         */
+        * 1, FCC2
+        */
 #       define FCC_START_LOOP 1
 #       define FCC_END_LOOP   1
 
@@ -1002,7 +1015,7 @@ eth_loopback_test (void)
                                                        ecp->rxeacc._f++;
                                        }
 
-                                       if (sc & BD_ENET_RX_STATS) {
+                                       if (sc & BD_ENET_RX_ERRS) {
                                                ulong n;
 
                                                /*
@@ -1033,7 +1046,7 @@ eth_loopback_test (void)
                                                        ecp->rxeacc.cl++;
 
                                                bdp->cbd_sc &= \
-                                                       ~BD_ENET_RX_STATS;
+                                                       ~BD_ENET_RX_ERRS;
                                        }
                                        else {
                                                ushort datlen = bdp->cbd_datlen;
@@ -1143,7 +1156,7 @@ eth_loopback_test (void)
                        printf ("\tFirst %d rx errs:", nerr);
                        for (i = 0; i < nerr; i++)
                                printf (" %04x", ecp->rxerrs[i]);
-                       puts ("\n");
+                       putc ('\n');
                }
 
                if ((nerr = ecp->ntxerr) > 0) {
@@ -1152,7 +1165,7 @@ eth_loopback_test (void)
                        printf ("\tFirst %d tx errs:", nerr);
                        for (i = 0; i < nerr; i++)
                                printf (" %04x", ecp->txerrs[i]);
-                       puts ("\n");
+                       putc ('\n');
                }
        }
 
@@ -1174,4 +1187,4 @@ eth_loopback_test (void)
 
 #endif /* CONFIG_ETHER_LOOPBACK_TEST */
 
-#endif /* CONFIG_ETHER_ON_FCC && CFG_CMD_NET && CONFIG_NET_MULTI */
+#endif