Skip to contentSkip to conversation

Davinci Ethernet driver cleanup

PATCH Superseded Ben Warren 2 participants 6 messages May 26, 2009

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Ben Warren

author
#0 lore raw

v2 cover Davinci Ethernet driver cleanup

Hello,

The second spin of this patchset is identical to the first but has been re-based against u-boot/next. Since there were no technical objections with the first spin, I've applied this to the net/next branch.

Please let me know if there are any problems.

regards,
Ben

author
#1 lore raw

PATCH v2 1/3 Moved Davinci Ethernet driver to drivers/net

This driver has been renamed dm644x_emac.c

---
 cpu/arm926ejs/davinci/Makefile                     |    2 +-
 drivers/net/Makefile                               |    1 +
 .../davinci/ether.c => drivers/net/dm644x_emac.c   |    0 
 3 files changed, 2 insertions(+), 1 deletions(-)
 rename cpu/arm926ejs/davinci/ether.c => drivers/net/dm644x_emac.c (100%)
cpu/arm926ejs/davinci/Makefile +1 -1
index 6eaa89c..e45ad25 100644
@@ -30,7 +30,7 @@ LIB	= $(obj)lib$(SOC).a
 COBJS-y				+= cpu.o timer.o psc.o
 COBJS-$(CONFIG_SOC_DM355)	+= dm355.o
 COBJS-$(CONFIG_SOC_DM644X)	+= dm644x.o
-COBJS-$(CONFIG_DRIVER_TI_EMAC)	+= ether.o lxt972.o dp83848.o
+COBJS-$(CONFIG_DRIVER_TI_EMAC)	+= lxt972.o dp83848.o
 
 SOBJS	= reset.o
 
drivers/net/Makefile +1 -0
index a360a50..26f1ea6 100644
@@ -64,6 +64,7 @@ COBJS-$(CONFIG_SH_ETHER) += sh_eth.o
 COBJS-$(CONFIG_DRIVER_SMC91111) += smc91111.o
 COBJS-$(CONFIG_DRIVER_SMC911X) += smc911x.o
 COBJS-$(CONFIG_TIGON3) += tigon3.o bcm570x_autoneg.o 5701rls.o
+COBJS-$(CONFIG_DRIVER_TI_EMAC) += dm644x_emac.o
 COBJS-$(CONFIG_TSEC_ENET) += tsec.o
 COBJS-$(CONFIG_TSI108_ETH) += tsi108_eth.o
 COBJS-$(CONFIG_ULI526X) += uli526x.o
drivers/net/dm644x_emac.c renamed from cpu/arm926ejs/davinci/ether.c +0 -0
similarity index 100%
rename from cpu/arm926ejs/davinci/ether.c
rename to drivers/net/dm644x_emac.c
Signature · 1 line
1.5.6.3
author
#2 lore raw

PATCH v2 2/3 Initial cleanup of Davinci Ethernet driver

Removed pointless #ifdefs
Moved functions around in file in preparation for switch to newer API

---
 drivers/net/dm644x_emac.c |  146 +++++++++++++++++++++------------------------
 1 files changed, 69 insertions(+), 77 deletions(-)
drivers/net/dm644x_emac.c +69 -77
index f6f81df..f5cec05 100644
@@ -42,10 +42,6 @@
 #include <miiphy.h>
 #include <asm/arch/emac_defs.h>
 
-#ifdef CONFIG_DRIVER_TI_EMAC
-
-#ifdef CONFIG_CMD_NET
-
 unsigned int	emac_dbg = 0;
 #define debug_emac(fmt,args...)	if (emac_dbg) printf(fmt,##args)
 
@@ -291,77 +287,6 @@ int davinci_eth_miiphy_initialize(bd_t *bis)
 }
 #endif
 
-/*
- * This function initializes the emac hardware. It does NOT initialize
- * EMAC modules power or pin multiplexors, that is done by board_init()
- * much earlier in bootup process. Returns 1 on success, 0 otherwise.
- */
-static int davinci_eth_hw_init(void)
-{
-	u_int32_t	phy_id;
-	u_int16_t	tmp;
-	int		i;
-
-	davinci_eth_mdio_enable();
-
-	for (i = 0; i < 256; i++) {
-		if (adap_mdio->ALIVE)
-			break;
-		udelay(10);
-	}
-
-	if (i >= 256) {
-		printf("No ETH PHY detected!!!\n");
-		return(0);
-	}
-
-	/* Find if a PHY is connected and get it's address */
-	if (!davinci_eth_phy_detect())
-		return(0);
-
-	/* Get PHY ID and initialize phy_ops for a detected PHY */
-	if (!davinci_eth_phy_read(active_phy_addr, PHY_PHYIDR1, &tmp)) {
-		active_phy_addr = 0xff;
-		return(0);
-	}
-
-	phy_id = (tmp << 16) & 0xffff0000;
-
-	if (!davinci_eth_phy_read(active_phy_addr, PHY_PHYIDR2, &tmp)) {
-		active_phy_addr = 0xff;
-		return(0);
-	}
-
-	phy_id |= tmp & 0x0000ffff;
-
-	switch (phy_id) {
-		case PHY_LXT972:
-			sprintf(phy.name, "LXT972 @ 0x%02x", active_phy_addr);
-			phy.init = lxt972_init_phy;
-			phy.is_phy_connected = lxt972_is_phy_connected;
-			phy.get_link_speed = lxt972_get_link_speed;
-			phy.auto_negotiate = lxt972_auto_negotiate;
-			break;
-		case PHY_DP83848:
-			sprintf(phy.name, "DP83848 @ 0x%02x", active_phy_addr);
-			phy.init = dp83848_init_phy;
-			phy.is_phy_connected = dp83848_is_phy_connected;
-			phy.get_link_speed = dp83848_get_link_speed;
-			phy.auto_negotiate = dp83848_auto_negotiate;
-			break;
-		default:
-			sprintf(phy.name, "GENERIC @ 0x%02x", active_phy_addr);
-			phy.init = gen_init_phy;
-			phy.is_phy_connected = gen_is_phy_connected;
-			phy.get_link_speed = gen_get_link_speed;
-			phy.auto_negotiate = gen_auto_negotiate;
-	}
-
-	printf("Ethernet PHY: %s\n", phy.name);
-
-	return(1);
-}
-
 
 /* Eth device open */
 static int davinci_eth_open(void)
@@ -650,6 +575,73 @@ static int davinci_eth_rcv_packet (void)
 	return (0);
 }
 
-#endif /* CONFIG_CMD_NET */
+/*
+ * This function initializes the emac hardware. It does NOT initialize
+ * EMAC modules power or pin multiplexors, that is done by board_init()
+ * much earlier in bootup process. Returns 1 on success, 0 otherwise.
+ */
+static int davinci_eth_hw_init(void)
+{
+	u_int32_t	phy_id;
+	u_int16_t	tmp;
+	int		i;
+
+	davinci_eth_mdio_enable();
+
+	for (i = 0; i < 256; i++) {
+		if (adap_mdio->ALIVE)
+			break;
+		udelay(10);
+	}
+
+	if (i >= 256) {
+		printf("No ETH PHY detected!!!\n");
+		return(0);
+	}
+
+	/* Find if a PHY is connected and get it's address */
+	if (!davinci_eth_phy_detect())
+		return(0);
+
+	/* Get PHY ID and initialize phy_ops for a detected PHY */
+	if (!davinci_eth_phy_read(active_phy_addr, PHY_PHYIDR1, &tmp)) {
+		active_phy_addr = 0xff;
+		return(0);
+	}
 
-#endif /* CONFIG_DRIVER_TI_EMAC */
+	phy_id = (tmp << 16) & 0xffff0000;
+
+	if (!davinci_eth_phy_read(active_phy_addr, PHY_PHYIDR2, &tmp)) {
+		active_phy_addr = 0xff;
+		return(0);
+	}
+
+	phy_id |= tmp & 0x0000ffff;
+
+	switch (phy_id) {
+		case PHY_LXT972:
+			sprintf(phy.name, "LXT972 @ 0x%02x", active_phy_addr);
+			phy.init = lxt972_init_phy;
+			phy.is_phy_connected = lxt972_is_phy_connected;
+			phy.get_link_speed = lxt972_get_link_speed;
+			phy.auto_negotiate = lxt972_auto_negotiate;
+			break;
+		case PHY_DP83848:
+			sprintf(phy.name, "DP83848 @ 0x%02x", active_phy_addr);
+			phy.init = dp83848_init_phy;
+			phy.is_phy_connected = dp83848_is_phy_connected;
+			phy.get_link_speed = dp83848_get_link_speed;
+			phy.auto_negotiate = dp83848_auto_negotiate;
+			break;
+		default:
+			sprintf(phy.name, "GENERIC @ 0x%02x", active_phy_addr);
+			phy.init = gen_init_phy;
+			phy.is_phy_connected = gen_is_phy_connected;
+			phy.get_link_speed = gen_get_link_speed;
+			phy.auto_negotiate = gen_auto_negotiate;
+	}
+
+	printf("Ethernet PHY: %s\n", phy.name);
+
+	return(1);
+}
Signature · 1 line
1.5.6.3
author
#3 lore raw

PATCH v2 3/3 Switched dm644x_emac Ethernet driver to use newer API

Added CONFIG_NET_MULTI to all Davinci boards Removed all calls to Davinci network driver from board code Added cpu_eth_init() to cpu/arm926ejs/cpu.c

---
 board/davinci/common/misc.h         |    1 -
 board/davinci/dvevm/dvevm.c         |    3 -
 board/davinci/schmoogie/schmoogie.c |    3 -
 board/davinci/sffsdr/sffsdr.c       |    3 -
 board/davinci/sonata/sonata.c       |    3 -
 cpu/arm926ejs/davinci/cpu.c         |   12 ++++++
 drivers/net/dm644x_emac.c           |   70 ++++++++++++-----------------------
 include/configs/davinci_dvevm.h     |    1 +
 include/configs/davinci_schmoogie.h |    1 +
 include/configs/davinci_sffsdr.h    |    1 +
 include/configs/davinci_sonata.h    |    1 +
 include/netdev.h                    |    1 +
 net/eth.c                           |    4 --
 13 files changed, 41 insertions(+), 63 deletions(-)
board/davinci/common/misc.h +0 -1
index 316159a..dc3cc41 100644
@@ -22,7 +22,6 @@
 #ifndef __MISC_H
 #define __MISC_H
 
-extern int eth_hw_init(void);
 
 int dvevm_read_mac_address(uint8_t *buf);
 void dv_configure_mac_address(uint8_t *rom_enetaddr);
board/davinci/dvevm/dvevm.c +0 -3
index 8f38633..98937a9 100644
@@ -73,9 +73,6 @@ int misc_init_r(void)
 	if (dvevm_read_mac_address(eeprom_enetaddr))
 		dv_configure_mac_address(eeprom_enetaddr);
 
-	if (!eth_hw_init())
-		printf("ethernet init failed!\n");
-
 	i2c_read(0x39, 0x00, 1, &video_mode, 1);
 
 	setenv("videostd", ((video_mode & 0x80) ? "pal" : "ntsc"));
board/davinci/schmoogie/schmoogie.c +0 -3
index 6e0f591..19c9580 100644
@@ -130,8 +130,5 @@ int misc_init_r(void)
 		forceenv("serial#", (char *)&tmp[0]);
 	}
 
-	if (!eth_hw_init())
-		printf("ethernet init failed!\n");
-
 	return(0);
 }
board/davinci/sffsdr/sffsdr.c +0 -3
index 7f4ee36..c24b9e1 100644
@@ -143,8 +143,5 @@ int misc_init_r(void)
 	if (sffsdr_read_mac_address(eeprom_enetaddr))
 		dv_configure_mac_address(eeprom_enetaddr);
 
-	if (!eth_hw_init())
-		printf("Ethernet init failed\n");
-
 	return(0);
 }
board/davinci/sonata/sonata.c +0 -3
index a0bea05..7f9d9bb 100644
@@ -70,8 +70,5 @@ int misc_init_r(void)
 	if (dvevm_read_mac_address(eeprom_enetaddr))
 		dv_configure_mac_address(eeprom_enetaddr);
 
-	if (!eth_hw_init())
-		printf("ethernet init failed!\n");
-
 	return(0);
 }
cpu/arm926ejs/davinci/cpu.c +12 -0
index 29aead6..fcd1f1a 100644
@@ -21,6 +21,7 @@
  */
 
 #include <common.h>
+#include <netdev.h>
 #include <asm/arch/hardware.h>
 
 
@@ -129,3 +130,14 @@ int print_cpuinfo(void)
 
 #endif
 
+/*
+ * Initializes on-chip ethernet controllers.
+ * to override, implement board_eth_init()
+ */
+int cpu_eth_init(bd_t *bis)
+{
+#if defined(CONFIG_DRIVER_TI_EMAC)
+	dm644x_emac_initialize();
+#endif
+	return 0;
+}
drivers/net/dm644x_emac.c +24 -46

140 lines not on this page · raw message

include/configs/davinci_dvevm.h +1 -0
index 6c5d065..96b6afc 100644
@@ -109,6 +109,7 @@
 #define CONFIG_BOOTP_DNS2
 #define CONFIG_BOOTP_SEND_HOSTNAME
 #define CONFIG_NET_RETRY_COUNT	10
+#define CONFIG_NET_MULTI
 /*=====================*/
 /* Flash & Environment */
 /*=====================*/
include/configs/davinci_schmoogie.h +1 -0
index 6612cb3..9cb9838 100644
@@ -77,6 +77,7 @@
 #define CONFIG_BOOTP_SEND_HOSTNAME
 #define CONFIG_NET_RETRY_COUNT	10
 #define CONFIG_OVERWRITE_ETHADDR_ONCE
+#define CONFIG_NET_MULTI
 /*=====================*/
 /* Flash & Environment */
 /*=====================*/
include/configs/davinci_sffsdr.h +1 -0
index 6c1dc11..a47620f 100644
@@ -74,6 +74,7 @@
 #define CONFIG_BOOTP_SEND_HOSTNAME
 #define CONFIG_NET_RETRY_COUNT	10
 #define CONFIG_OVERWRITE_ETHADDR_ONCE
+#define CONFIG_NET_MULTI
 /* Flash & Environment */
 #undef CONFIG_ENV_IS_IN_FLASH
 #define CONFIG_SYS_NO_FLASH
include/configs/davinci_sonata.h +1 -0
index 893729c..82901b3 100644
@@ -109,6 +109,7 @@
 #define CONFIG_BOOTP_DNS2
 #define CONFIG_BOOTP_SEND_HOSTNAME
 #define CONFIG_NET_RETRY_COUNT	10
+#define CONFIG_NET_MULTI
 /*=====================*/
 /* Flash & Environment */
 /*=====================*/
include/netdev.h +1 -0
index 4f2b23a..57ffe40 100644
@@ -44,6 +44,7 @@ int cpu_eth_init(bd_t *bis);
 int au1x00_enet_initialize(bd_t*);
 int bfin_EMAC_initialize(bd_t *bis);
 int dc21x4x_initialize(bd_t *bis);
+int dm644x_emac_initialize(void);
 int dnet_eth_initialize(int id, void *regs, unsigned int phy_addr);
 int e1000_initialize(bd_t *bis);
 int eepro100_initialize(bd_t *bis);
net/eth.c +0 -4
index 8940ebf..eb218b6 100644
@@ -504,7 +504,6 @@ extern int at91rm9200_miiphy_initialize(bd_t *bis);
 extern int emac4xx_miiphy_initialize(bd_t *bis);
 extern int mcf52x2_miiphy_initialize(bd_t *bis);
 extern int ns7520_miiphy_initialize(bd_t *bis);
-extern int davinci_eth_miiphy_initialize(bd_t *bis);
 
 
 int eth_initialize(bd_t *bis)
@@ -525,9 +524,6 @@ int eth_initialize(bd_t *bis)
 #if defined(CONFIG_DRIVER_NS7520_ETHERNET)
 	ns7520_miiphy_initialize(bis);
 #endif
-#if defined(CONFIG_DRIVER_TI_EMAC)
-	davinci_eth_miiphy_initialize(bis);
-#endif
 	return 0;
 }
 #endif
Signature · 1 line
1.5.6.3
#4 lore raw

v2 cover Davinci Ethernet driver cleanup

In reply to Ben Warren

Ben,
I believe there was a comment regrading the name of the file.
The present name is dm644x_emac.c and it should be davinci_emac.c Because other floavours of DaVinci will use the same file.

IIRC in the list had the same comment. Also the patch uses "dm644x_emac_initialize" It would be better to use davinci_emac_initialize.

There are not big changes and I can send in a patch if its is ok with you.

Thanks,
Sandeep

Quoted 27 lines

-----Original Message-----
From: u-boot-bounces at lists.denx.de [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Ben Warren
Sent: Tuesday, May 26, 2009 4:07 AM
To: u-boot at lists.denx.de
Cc: Ben Warren
Subject: [U-Boot] [PATCH v2 0/3][Net][ARM] Davinci Ethernet driver cleanup

Hello,

The second spin of this patchset is identical to the first but has been
re-based against u-boot/next. Since there were no technical objections with
the first spin, I've applied this to the net/next branch.

Please let me know if there are any problems.

regards,
Ben
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

author
#5 lore raw

v2 cover Davinci Ethernet driver cleanup

Hi Sandeep,

Quoted 9 lines · Sandeep

Ben,
I believe there was a comment regrading the name of the file.
The present name is dm644x_emac.c and it should be davinci_emac.c Because other floavours of DaVinci will use the same file.

IIRC in the list had the same comment. Also the patch uses "dm644x_emac_initialize" It would be better to use davinci_emac_initialize.

Quoted 7 lines

There are not big changes and I can send in a patch if its is ok with you.

Thanks,
Sandeep

It's better for me to redo the patch set. I named them based on comments in the header of the source file.

regards,
Ben