[U-Boot] [U-boot] [Patch 5/5] net: keystone_net: remove redundant code from keystone_net.c

Ivan Khoronzhuk ivan.khoronzhuk at ti.com
Mon Sep 22 14:44:26 CEST 2014


Remove unused tx_send_loop variable.

Removes duplicated get_link_status() call from the
keystone2_eth_send_packet().

The emac_gigabit_enable() is called at opening Ethernet and there is no
need to enable it on sending each packet. So remove that call
from keystone2_eth_send_packet() as well.

The calling of power/clock up functions are mostly the responsibility
of SoC/board code, so move these functions to appropriate place.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk at ti.com>
---
 board/ti/ks2_evm/board.c   |  9 +++++++++
 drivers/net/keystone_net.c | 19 +------------------
 2 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/board/ti/ks2_evm/board.c b/board/ti/ks2_evm/board.c
index f9d5f90..cdfca23 100644
--- a/board/ti/ks2_evm/board.c
+++ b/board/ti/ks2_evm/board.c
@@ -12,6 +12,7 @@
 #include <exports.h>
 #include <fdt_support.h>
 #include <asm/arch/ddr3.h>
+#include <asm/arch/psc_defs.h>
 #include <asm/ti-common/ti-aemif.h>
 #include <asm/ti-common/keystone_net.h>
 
@@ -68,6 +69,14 @@ int board_eth_init(bd_t *bis)
 	int port_num;
 	char link_type_name[32];
 
+	/* By default, select PA PLL clock as PA clock source */
+	if (psc_enable_module(KS2_LPSC_PA))
+		return -1;
+	if (psc_enable_module(KS2_LPSC_CPGMAC))
+		return -1;
+	if (psc_enable_module(KS2_LPSC_CRYPTO))
+		return -1;
+
 	port_num = get_num_eth_ports();
 
 	for (j = 0; j < port_num; j++) {
diff --git a/drivers/net/keystone_net.c b/drivers/net/keystone_net.c
index edd2bb0..730a721 100644
--- a/drivers/net/keystone_net.c
+++ b/drivers/net/keystone_net.c
@@ -12,12 +12,9 @@
 #include <net.h>
 #include <miiphy.h>
 #include <malloc.h>
-#include <asm/arch/psc_defs.h>
 #include <asm/ti-common/keystone_nav.h>
 #include <asm/ti-common/keystone_net.h>
 
-unsigned int emac_dbg;
-
 unsigned int emac_open;
 static unsigned int sys_has_mdio = 1;
 
@@ -409,10 +406,7 @@ static int keystone2_eth_open(struct eth_device *dev, bd_t *bis)
 	sys_has_mdio =
 		(eth_priv->sgmii_link_type == SGMII_LINK_MAC_PHY) ? 1 : 0;
 
-	psc_enable_module(KS2_LPSC_PA);
-	psc_enable_module(KS2_LPSC_CPGMAC);
-
-	sgmii_serdes_setup_156p25mhz();
+	keystone2_net_serdes_sgmii_setup();
 
 	if (sys_has_mdio)
 		keystone2_eth_mdio_enable();
@@ -490,8 +484,6 @@ void keystone2_eth_close(struct eth_device *dev)
 	debug("- emac_close\n");
 }
 
-static int tx_send_loop;
-
 /*
  * This function sends a single packet on the network and returns
  * positive number (number of bytes transmitted) or negative for error
@@ -502,21 +494,12 @@ static int keystone2_eth_send_packet(struct eth_device *dev,
 	int ret_status = -1;
 	struct eth_priv_t *eth_priv = (struct eth_priv_t *)dev->priv;
 
-	tx_send_loop = 0;
-
 	if (keystone_get_link_status(dev) == 0)
 		return -1;
 
-	emac_gigabit_enable(dev);
-
 	if (cpmac_drv_send((u32 *)packet, length, eth_priv->slave_port) != 0)
 		return ret_status;
 
-	if (keystone_get_link_status(dev) == 0)
-		return -1;
-
-	emac_gigabit_enable(dev);
-
 	return length;
 }
 
-- 
1.8.3.2



More information about the U-Boot mailing list