tizen 2.3.1 release
[platform/kernel/u-boot.git] / board / Marvell / db64360 / mv_eth.c
index b2df1f7..30304b0 100644 (file)
@@ -5,7 +5,23 @@
  * based on - Driver for MV64360X ethernet ports
  * Copyright (C) 2002 rabeeh@galileo.co.il
  *
- * SPDX-License-Identifier:    GPL-2.0+
+ * 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
  */
 
 /*
@@ -79,6 +95,8 @@ int mv64360_eth_xmit (struct eth_device *, volatile void *packet, int length);
 #ifndef  UPDATE_STATS_BY_SOFTWARE
 static void mv64360_eth_print_stat (struct eth_device *dev);
 #endif
+/* Processes a received packet */
+extern void NetReceive (volatile uchar *, int);
 
 extern unsigned int INTERNAL_REG_BASE_ADDR;
 
@@ -174,7 +192,8 @@ int db64360_eth_poll (struct eth_device *dev)
        return mv64360_eth_receive (dev);
 }
 
-int db64360_eth_transmit(struct eth_device *dev, void *packet, int length)
+int db64360_eth_transmit (struct eth_device *dev, volatile void *packet,
+                         int length)
 {
        mv64360_eth_xmit (dev, packet, length);
        return 0;
@@ -202,7 +221,7 @@ void mv6436x_eth_initialize (bd_t * bis)
                        return;
                }
 
-               /* must be less than sizeof(dev->name) */
+               /* must be less than NAMESIZE (16) */
                sprintf (dev->name, "mv_enet%d", devnum);
 
 #ifdef DEBUG
@@ -402,7 +421,7 @@ static int mv64360_eth_real_open (struct eth_device *dev)
        ETH_PORT_INFO *ethernet_private;
        struct mv64360_eth_priv *port_private;
        unsigned int port_num;
-       u32 phy_reg_data;
+       u32 port_status, phy_reg_data;
 
        ethernet_private = (ETH_PORT_INFO *) dev->priv;
        /* ronen - when we update the MAC env params we only update dev->enetaddr
@@ -500,7 +519,7 @@ static int mv64360_eth_real_open (struct eth_device *dev)
         */
 
        MV_REG_WRITE (MV64360_ETH_MAXIMUM_TRANSMIT_UNIT (port_num), 0);
-       MV_REG_READ (MV64360_ETH_PORT_STATUS_REG (port_num));
+       port_status = MV_REG_READ (MV64360_ETH_PORT_STATUS_REG (port_num));
 
        /* Check Link status on phy */
        eth_port_read_smi_reg (port_num, 1, &phy_reg_data);
@@ -618,6 +637,15 @@ static int mv64360_eth_free_rx_rings (struct eth_device *dev)
 
 int mv64360_eth_stop (struct eth_device *dev)
 {
+       ETH_PORT_INFO *ethernet_private;
+       struct mv64360_eth_priv *port_private;
+       unsigned int port_num;
+
+       ethernet_private = (ETH_PORT_INFO *) dev->priv;
+       port_private =
+               (struct mv64360_eth_priv *) ethernet_private->port_private;
+       port_num = port_private->port_num;
+
        /* Disable all gigE address decoder */
        MV_REG_WRITE (MV64360_ETH_BASE_ADDR_ENABLE_REG, 0x3f);
        DP (printf ("%s Ethernet stop called ... \n", __FUNCTION__));
@@ -687,6 +715,7 @@ int mv64360_eth_xmit (struct eth_device *dev, volatile void *dataPtr,
 {
        ETH_PORT_INFO *ethernet_private;
        struct mv64360_eth_priv *port_private;
+       unsigned int port_num;
        PKT_INFO pkt_info;
        ETH_FUNC_RET_STATUS status;
        struct net_device_stats *stats;
@@ -695,6 +724,7 @@ int mv64360_eth_xmit (struct eth_device *dev, volatile void *dataPtr,
        ethernet_private = (ETH_PORT_INFO *) dev->priv;
        port_private =
                (struct mv64360_eth_priv *) ethernet_private->port_private;
+       port_num = port_private->port_num;
 
        stats = port_private->stats;
 
@@ -770,12 +800,15 @@ int mv64360_eth_receive (struct eth_device *dev)
 {
        ETH_PORT_INFO *ethernet_private;
        struct mv64360_eth_priv *port_private;
+       unsigned int port_num;
        PKT_INFO pkt_info;
        struct net_device_stats *stats;
 
+
        ethernet_private = (ETH_PORT_INFO *) dev->priv;
        port_private =
                (struct mv64360_eth_priv *) ethernet_private->port_private;
+       port_num = port_private->port_num;
        stats = port_private->stats;
 
        while ((eth_port_receive (ethernet_private, ETH_Q0, &pkt_info) ==
@@ -866,10 +899,12 @@ static struct net_device_stats *mv64360_eth_get_stats (struct eth_device *dev)
 {
        ETH_PORT_INFO *ethernet_private;
        struct mv64360_eth_priv *port_private;
+       unsigned int port_num;
 
        ethernet_private = (ETH_PORT_INFO *) dev->priv;
        port_private =
                (struct mv64360_eth_priv *) ethernet_private->port_private;
+       port_num = port_private->port_num;
 
        mv64360_eth_update_stat (dev);
 
@@ -891,10 +926,13 @@ static void mv64360_eth_update_stat (struct eth_device *dev)
        ETH_PORT_INFO *ethernet_private;
        struct mv64360_eth_priv *port_private;
        struct net_device_stats *stats;
+       unsigned int port_num;
+       volatile unsigned int dummy;
 
        ethernet_private = (ETH_PORT_INFO *) dev->priv;
        port_private =
                (struct mv64360_eth_priv *) ethernet_private->port_private;
+       port_num = port_private->port_num;
        stats = port_private->stats;
 
        /* These are false updates */
@@ -917,12 +955,12 @@ static void mv64360_eth_update_stat (struct eth_device *dev)
         * But the unsigned long in PowerPC and MIPS are 32bit. So the next read
         * is just a dummy read for proper work of the GigE port
         */
-       eth_read_mib_counter (ethernet_private->port_num,
+       dummy = eth_read_mib_counter (ethernet_private->port_num,
                                      ETH_MIB_GOOD_OCTETS_RECEIVED_HIGH);
        stats->tx_bytes += (unsigned long)
                eth_read_mib_counter (ethernet_private->port_num,
                                      ETH_MIB_GOOD_OCTETS_SENT_LOW);
-       eth_read_mib_counter (ethernet_private->port_num,
+       dummy = eth_read_mib_counter (ethernet_private->port_num,
                                      ETH_MIB_GOOD_OCTETS_SENT_HIGH);
        stats->rx_errors += (unsigned long)
                eth_read_mib_counter (ethernet_private->port_num,
@@ -970,10 +1008,12 @@ static void mv64360_eth_print_stat (struct eth_device *dev)
        ETH_PORT_INFO *ethernet_private;
        struct mv64360_eth_priv *port_private;
        struct net_device_stats *stats;
+       unsigned int port_num;
 
        ethernet_private = (ETH_PORT_INFO *) dev->priv;
        port_private =
                (struct mv64360_eth_priv *) ethernet_private->port_private;
+       port_num = port_private->port_num;
        stats = port_private->stats;
 
        /* These are false updates */
@@ -1023,7 +1063,21 @@ bool db64360_eth_start (struct eth_device *dev)
  * based on Linux code
  * arch/powerpc/galileo/EVB64360/mv64360_eth.c - Driver for MV64360X ethernet ports
  * Copyright (C) 2002 rabeeh@galileo.co.il
- * SPDX-License-Identifier:    GPL-2.0+
+
+ * 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.
+ *
  */
 
 /********************************************************************************
@@ -2011,11 +2065,13 @@ static void eth_port_init_mac_tables (ETH_PORT eth_port_num)
 static void eth_clear_mib_counters (ETH_PORT eth_port_num)
 {
        int i;
+       unsigned int dummy;
 
        /* Perform dummy reads from MIB counters */
        for (i = ETH_MIB_GOOD_OCTETS_RECEIVED_LOW; i < ETH_MIB_LATE_COLLISION;
             i += 4)
-               MV_REG_READ((MV64360_ETH_MIB_COUNTERS_BASE(eth_port_num) + i));
+               dummy = MV_REG_READ ((MV64360_ETH_MIB_COUNTERS_BASE
+                                     (eth_port_num) + i));
 
        return;
 }