odroid: remove CONFIG_DM_I2C_COMPAT config
[platform/kernel/u-boot.git] / arch / powerpc / cpu / mpc8260 / ether_fcc.c
index 5ac02a0..072eb76 100644 (file)
@@ -6,23 +6,7 @@
  * (C) Copyright 2000 Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  * Marius Groeger <mgroeger@sysgo.de>
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 /*
@@ -40,6 +24,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <malloc.h>
 #include <asm/cpm_8260.h>
 #include <mpc8260.h>
@@ -53,8 +38,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if defined(CONFIG_ETHER_ON_FCC) && defined(CONFIG_CMD_NET) && \
-       defined(CONFIG_NET_MULTI)
+#if defined(CONFIG_ETHER_ON_FCC) && defined(CONFIG_CMD_NET)
 
 static struct ether_fcc_info_s
 {
@@ -143,7 +127,7 @@ static RTXBD rtx __attribute__ ((aligned(8)));
 #error "rtx must be 64-bit aligned"
 #endif
 
-static int fec_send(struct eth_device* dev, volatile void *packet, int length)
+static int fec_send(struct eth_device *dev, void *packet, int length)
 {
     int i;
     int result = 0;
@@ -200,7 +184,7 @@ static int fec_recv(struct eth_device* dev)
        }
        else {
            /* Pass the packet up to the protocol layers. */
-           NetReceive(NetRxPackets[rxIdx], length - 4);
+           net_process_received_packet(net_rx_packets[rxIdx], length - 4);
        }
 
 
@@ -260,7 +244,7 @@ static int fec_init(struct eth_device* dev, bd_t *bis)
     {
       rtx.rxbd[i].cbd_sc = BD_ENET_RX_EMPTY;
       rtx.rxbd[i].cbd_datlen = 0;
-      rtx.rxbd[i].cbd_bufaddr = (uint)NetRxPackets[i];
+      rtx.rxbd[i].cbd_bufaddr = (uint)net_rx_packets[i];
     }
     rtx.rxbd[PKTBUFSRX - 1].cbd_sc |= BD_ENET_RX_WRAP;
 
@@ -316,7 +300,7 @@ static int fec_init(struct eth_device* dev, bd_t *bis)
      * it unique by setting a few bits in the upper byte of the
      * non-static part of the address.
      */
-#define ea eth_get_dev()->enetaddr
+#define ea eth_get_ethaddr()
     pram_ptr->fen_paddrh = (ea[5] << 8) + ea[4];
     pram_ptr->fen_paddrm = (ea[3] << 8) + ea[2];
     pram_ptr->fen_paddrl = (ea[1] << 8) + ea[0];
@@ -378,12 +362,12 @@ int fec_initialize(bd_t *bis)
        struct eth_device* dev;
        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 = (struct eth_device*) malloc(sizeof *dev);
                memset(dev, 0, sizeof *dev);
 
-               sprintf(dev->name, "FCC%d ETHERNET",
+               sprintf(dev->name, "FCC%d",
                        ether_fcc_info[i].ether_index + 1);
                dev->priv   = &ether_fcc_info[i];
                dev->init   = fec_init;
@@ -395,8 +379,17 @@ int fec_initialize(bd_t *bis)
 
 #if (defined(CONFIG_MII) || defined(CONFIG_CMD_MII)) \
                && defined(CONFIG_BITBANGMII)
-               miiphy_register(dev->name,
-                               bb_miiphy_read, bb_miiphy_write);
+               int retval;
+               struct mii_dev *mdiodev = mdio_alloc();
+               if (!mdiodev)
+                       return -ENOMEM;
+               strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN);
+               mdiodev->read = bb_miiphy_read;
+               mdiodev->write = bb_miiphy_write;
+
+               retval = mdio_register(mdiodev);
+               if (retval < 0)
+                       return retval;
 #endif
        }
 
@@ -448,7 +441,7 @@ static elbt_prdesc rxeacc_descs[] = {
        { offsetof(elbt_rxeacc, badlen),        "Bad Frame Length"      },
        { offsetof(elbt_rxeacc, badbit),        "Data Compare Errors"   },
 };
-static int rxeacc_ndesc = sizeof (rxeacc_descs) / sizeof (rxeacc_descs[0]);
+static int rxeacc_ndesc = ARRAY_SIZE(rxeacc_descs);
 
 typedef
        struct {
@@ -465,7 +458,7 @@ static elbt_prdesc txeacc_descs[] = {
        { offsetof(elbt_txeacc, un),            "Underrun"              },
        { offsetof(elbt_txeacc, csl),           "Carrier Sense Lost"    },
 };
-static int txeacc_ndesc = sizeof (txeacc_descs) / sizeof (txeacc_descs[0]);
+static int txeacc_ndesc = ARRAY_SIZE(txeacc_descs);
 
 typedef
        struct {
@@ -516,7 +509,7 @@ static elbt_prdesc epram_descs[] = {
        { offsetof(fcc_enet_t, fen_p512c),      "512-1023 Octet Frames" },
        { offsetof(fcc_enet_t, fen_p1024c),     "1024-1518 Octet Frames"},
 };
-static int epram_ndesc = sizeof (epram_descs) / sizeof (epram_descs[0]);
+static int epram_ndesc = ARRAY_SIZE(epram_descs);
 
 /*
  * given an elbt_prdesc array and an array of base addresses, print
@@ -654,7 +647,7 @@ eth_loopback_test (void)
 
        puts ("FCC Ethernet External loopback test\n");
 
-       eth_getenv_enetaddr("ethaddr", NetOurEther);
+       eth_getenv_enetaddr("ethaddr", net_ethaddr);
 
        /*
         * global initialisations for all FCC channels
@@ -662,32 +655,7 @@ eth_loopback_test (void)
 
        /* 28.9 - (1-2): ioports have been set up already */
 
-#if defined(CONFIG_HYMOD)
-       /*
-        * Attention: this is board-specific
-        * 0, FCC1
-        * 1, FCC2
-        * 2, FCC3
-        */
-#       define FCC_START_LOOP 0
-#       define FCC_END_LOOP   2
-
-       /*
-        * Attention: this is board-specific
-        * - FCC1 Rx-CLK is CLK10
-        * - FCC1 Tx-CLK is CLK11
-        * - FCC2 Rx-CLK is CLK13
-        * - FCC2 Tx-CLK is CLK14
-        * - FCC3 Rx-CLK is CLK15
-        * - FCC3 Tx-CLK is CLK16
-        */
-
-       /* 28.9 - (3): connect FCC's tx and rx clocks */
-       immr->im_cpmux.cmx_uar = 0;
-       immr->im_cpmux.cmx_fcr = CMXFCR_RF1CS_CLK10|CMXFCR_TF1CS_CLK11|\
-           CMXFCR_RF2CS_CLK13|CMXFCR_TF2CS_CLK14|\
-           CMXFCR_RF3CS_CLK15|CMXFCR_TF3CS_CLK16;
-#elif defined(CONFIG_SBC8260) || defined(CONFIG_SACSng)
+#if defined(CONFIG_SACSng)
        /*
         * Attention: this is board-specific
         * 1, FCC2
@@ -762,8 +730,8 @@ eth_loopback_test (void)
                        bdp->cbd_sc = BD_ENET_TX_READY | BD_ENET_TX_PAD | \
                                BD_ENET_TX_LAST | BD_ENET_TX_TC;
 
-                       memset ((void *)bp, patbytes[i], ELBT_BUFSZ);
-                       NetSetEther (bp, NetBcastAddr, 0x8000);
+                       memset((void *)bp, patbytes[i], ELBT_BUFSZ);
+                       net_set_ether(bp, net_bcast_ethaddr, 0x8000);
                }
                ecp->txbd[ELBT_NTXBD - 1].cbd_sc |= BD_ENET_TX_WRAP;
 
@@ -841,11 +809,9 @@ eth_loopback_test (void)
                 * So, far we have only been given one Ethernet address. We use
                 * the same address for all channels
                 */
-#define ea NetOurEther
-               fpp->fen_paddrh = (ea[5] << 8) + ea[4];
-               fpp->fen_paddrm = (ea[3] << 8) + ea[2];
-               fpp->fen_paddrl = (ea[1] << 8) + ea[0];
-#undef ea
+               fpp->fen_paddrh = (net_ethaddr[5] << 8) + net_ethaddr[4];
+               fpp->fen_paddrm = (net_ethaddr[3] << 8) + net_ethaddr[2];
+               fpp->fen_paddrl = (net_ethaddr[1] << 8) + net_ethaddr[0];
 
                fpp->fen_minflr = PKT_MINBUF_SIZE; /* min frame len register */
                /*
@@ -1050,23 +1016,22 @@ eth_loopback_test (void)
                                        }
                                        else {
                                                ushort datlen = bdp->cbd_datlen;
-                                               Ethernet_t *ehp;
+                                               struct ethernet_hdr *ehp;
                                                ushort prot;
                                                int ours, tb, n, nbytes;
 
-                                               ehp = (Ethernet_t *) \
+                                               ehp = (struct ethernet_hdr *) \
                                                        &ecp->rxbufs[i][0];
 
                                                ours = memcmp (ehp->et_src, \
-                                                       NetOurEther, 6);
+                                                       net_ethaddr, 6);
 
                                                prot = swap16 (ehp->et_protlen);
                                                tb = prot & 0x8000;
                                                n = prot & 0x7fff;
 
-                                               nbytes = ELBT_BUFSZ - \
-                                                       offsetof (Ethernet_t, \
-                                                               et_dsap) - \
+                                               nbytes = ELBT_BUFSZ -
+                                                       ETHER_HDR_SIZE -
                                                        ELBT_CRCSZ;
 
                                                /* check the frame is correct */
@@ -1081,10 +1046,10 @@ eth_loopback_test (void)
                                                                patwords[n];
                                                        uint nbb;
 
-                                                       nbb = badbits ( \
-                                                               &ehp->et_dsap, \
-                                                               nbytes, \
-                                                               patword);
+                                                       nbb = badbits(
+                                                           ((uchar *)&ehp) +
+                                                           ETHER_HDR_SIZE,
+                                                           nbytes, patword);
 
                                                        ecp->rxeacc.badbit += \
                                                                nbb;