]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/net/tsi108_eth.c
net: fec_mxc: don't write to reserved register on i.MX6UL
[karo-tx-uboot.git] / drivers / net / tsi108_eth.c
index 2534097df5577e01250728feb7e921b8ab5fa6aa..9da59a018acf7889ad4ee7ee239eaf3cf6be6307 100644 (file)
@@ -2,23 +2,7 @@
  *
  * Copyright (c) 2005 Freescale Semiconductor, Inc.
  *
- * 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+
  *
  * Description:
  *   Ethernet interface for Tundra TSI108 bridge chip
@@ -34,6 +18,7 @@
 #include <common.h>
 #include <malloc.h>
 #include <net.h>
+#include <netdev.h>
 #include <asm/cache.h>
 
 #ifdef DEBUG
@@ -53,7 +38,7 @@ printf ("%s %d: " fmt, __FUNCTION__, __LINE__, ##args)
 #define RX_PRINT_ERRORS
 #define TX_PRINT_ERRORS
 
-#define ETH_BASE       (CFG_TSI108_CSR_BASE + 0x6000)
+#define ETH_BASE       (CONFIG_SYS_TSI108_CSR_BASE + 0x6000)
 
 #define ETH_PORT_OFFSET        0x400
 
@@ -432,8 +417,7 @@ static struct dma_descriptor rx_descr_array[NUM_RX_DESC]
 static struct dma_descriptor *rx_descr_current;
 
 static int tsi108_eth_probe (struct eth_device *dev, bd_t * bis);
-static int tsi108_eth_send (struct eth_device *dev,
-                          volatile void *packet, int length);
+static int tsi108_eth_send(struct eth_device *dev, void *packet, int length);
 static int tsi108_eth_recv (struct eth_device *dev);
 static void tsi108_eth_halt (struct eth_device *dev);
 static unsigned int read_phy (unsigned int base,
@@ -730,7 +714,11 @@ int tsi108_eth_initialize (bd_t * bis)
 
        for (index = 0; index < CONFIG_TSI108_ETH_NUM_PORTS; index++) {
                dev = (struct eth_device *)malloc(sizeof(struct eth_device));
-
+               if (!dev) {
+                       printf("tsi108: Can not allocate memory\n");
+                       break;
+               }
+               memset(dev, 0, sizeof(*dev));
                sprintf (dev->name, "TSI108_eth%d", index);
 
                dev->iobase = ETH_BASE + (index * ETH_PORT_OFFSET);
@@ -816,11 +804,11 @@ static int tsi108_eth_probe (struct eth_device *dev, bd_t * bis)
        rx_descr_current = rx_descr;
        for (index = 0; index < NUM_RX_DESC; index++) {
                /* make sure the receive buffers are not in cache */
-               invalidate_dcache_range((unsigned long)NetRxPackets[index],
-                                       (unsigned long)NetRxPackets[index] +
+               invalidate_dcache_range((unsigned long)net_rx_packets[index],
+                                       (unsigned long)net_rx_packets[index] +
                                        RX_BUFFER_SIZE);
                rx_descr->start_addr0 =
-                   cpu_to_le32((vuint32) NetRxPackets[index]);
+                   cpu_to_le32((vuint32) net_rx_packets[index]);
                rx_descr->start_addr1 = 0;
                rx_descr->next_descr_addr0 =
                    cpu_to_le32((vuint32) (rx_descr + 1));
@@ -867,8 +855,7 @@ static int tsi108_eth_probe (struct eth_device *dev, bd_t * bis)
 /*
  * send a packet
  */
-static int tsi108_eth_send (struct eth_device *dev,
-                          volatile void *packet, int length)
+static int tsi108_eth_send(struct eth_device *dev, void *packet, int length)
 {
        unsigned long base;
        int timeout;
@@ -943,7 +930,7 @@ static int tsi108_eth_recv (struct eth_device *dev)
        unsigned long base;
        int length = 0;
        unsigned long status;
-       volatile uchar *buffer;
+       uchar *buffer;
 
        base = dev->iobase;
 
@@ -978,10 +965,8 @@ static int tsi108_eth_recv (struct eth_device *dev)
                            le32_to_cpu(rx_descr->vlan_byte_count) & 0xFFFF;
 
                        /*** process packet ***/
-                       buffer =
-                           (volatile uchar
-                            *)(le32_to_cpu (rx_descr->start_addr0));
-                       NetReceive (buffer, length);
+                       buffer = (uchar *)(le32_to_cpu(rx_descr->start_addr0));
+                       net_process_received_packet(buffer, length);
 
                        invalidate_dcache_range ((unsigned long)buffer,
                                                (unsigned long)buffer +