]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/net/davinci_emac.c
net: davinci_emac: don't teardown inactive rx channel
[karo-tx-uboot.git] / drivers / net / davinci_emac.c
index 476039059126fc0895f0ca4a25407335d4982fd9..04447953c92f1efea7b4cc577e7c3c93debc352d 100644 (file)
  *
  * ----------------------------------------------------------------------------
  *
- * 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.
+ * SPDX-License-Identifier:    GPL-2.0+
  *
- * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- * ----------------------------------------------------------------------------
-
  * Modifications:
  * ver. 1.0: Sep 2005, Anant Gole - Created EMAC version for uBoot.
  * ver  1.1: Nov 2005, Anant Gole - Extended the RX logic for multiple descriptors
- *
  */
 #include <common.h>
 #include <command.h>
 #include <net.h>
 #include <miiphy.h>
 #include <malloc.h>
+#include <netdev.h>
 #include <linux/compiler.h>
 #include <asm/arch/emac_defs.h>
 #include <asm/io.h>
@@ -220,7 +207,7 @@ static int davinci_eth_phy_detect(void)
        for (i = 0, j = 0; i < 32; i++)
                if (phy_act_state & (1 << i)) {
                        count++;
-                       if (count < CONFIG_SYS_DAVINCI_EMAC_PHY_COUNT) {
+                       if (count <= CONFIG_SYS_DAVINCI_EMAC_PHY_COUNT) {
                                active_phy_addr[j++] = i;
                        } else {
                                printf("%s: to many PHYs detected.\n",
@@ -520,7 +507,8 @@ static int davinci_eth_open(struct eth_device *dev, bd_t *bis)
        writel(1, &adap_emac->RXUNICASTSET);
 
        /* Enable MII interface and Full duplex mode */
-#ifdef CONFIG_SOC_DA8XX
+#if defined(CONFIG_SOC_DA8XX) || \
+       (defined(CONFIG_OMAP34XX) && defined(CONFIG_DRIVER_TI_EMAC_USE_RMII))
        writel((EMAC_MACCONTROL_MIIEN_ENABLE |
                EMAC_MACCONTROL_FULLDUPLEX_ENABLE |
                EMAC_MACCONTROL_RMIISPEED_100),
@@ -610,7 +598,8 @@ static void davinci_eth_close(struct eth_device *dev)
        debug_emac("+ emac_close\n");
 
        davinci_eth_ch_teardown(EMAC_CH_TX);    /* TX Channel teardown */
-       davinci_eth_ch_teardown(EMAC_CH_RX);    /* RX Channel teardown */
+       if (readl(&adap_emac->RXCONTROL) & 1)
+               davinci_eth_ch_teardown(EMAC_CH_RX); /* RX Channel teardown */
 
        /* Reset EMAC module and disable interrupts in wrapper */
        writel(1, &adap_emac->SOFTRESET);
@@ -636,7 +625,7 @@ static int tx_send_loop = 0;
  * positive number (number of bytes transmitted) or negative for error
  */
 static int davinci_eth_send_packet (struct eth_device *dev,
-                                       volatile void *packet, int length)
+                                       void *packet, int length)
 {
        int ret_status = -1;
        int index;
@@ -712,8 +701,9 @@ static int davinci_eth_rcv_packet (struct eth_device *dev)
                        unsigned long tmp = (unsigned long)rx_curr_desc->buffer;
 
                        invalidate_dcache_range(tmp, tmp + EMAC_RXBUF_SIZE);
-                       NetReceive (rx_curr_desc->buffer,
-                                   (rx_curr_desc->buff_off_len & 0xffff));
+                       net_process_received_packet(
+                               rx_curr_desc->buffer,
+                               rx_curr_desc->buff_off_len & 0xffff);
                        ret = rx_curr_desc->buff_off_len & 0xffff;
                }
 
@@ -894,5 +884,14 @@ int davinci_emac_initialize(void)
                miiphy_register(phy[i].name, davinci_mii_phy_read,
                                                davinci_mii_phy_write);
        }
+
+#if defined(CONFIG_DRIVER_TI_EMAC_USE_RMII) && \
+               defined(CONFIG_MACH_DAVINCI_DA850_EVM) && \
+                       !defined(CONFIG_DRIVER_TI_EMAC_RMII_NO_NEGOTIATE)
+       for (i = 0; i < num_phy; i++) {
+               if (phy[i].is_phy_connected(i))
+                       phy[i].auto_negotiate(i);
+       }
+#endif
        return(1);
 }