Skip to contentSkip to conversation

tsec: Fix a bug in soft-resetting

PATCH New Andy Fleming 3 participants 3 messages Feb 4, 2009 – Feb 6, 2009 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tsec: Fix a bug in soft-resetting

SOFT_RESET must be asserted for at least 3 TX clocks. Usually, that's about 30 clock cycles, so it's been mostly working. But we had no guarantee, and at slower bitrates, it's just over a microsecond (over 1000 clock cycles). This enforces a 2 microsecond gap between assertion and deassertion.

---
 drivers/net/tsec.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/net/tsec.c +1 -0
index fbc9a6d..4682c8b 100644
@@ -158,6 +158,7 @@ int tsec_initialize(bd_t * bis, struct tsec_info_struct *tsec_info)
 
 	/* Reset the MAC */
 	priv->regs->maccfg1 |= MACCFG1_SOFT_RESET;
+	udelay(2);  /* Soft Reset must be asserted for 3 TX clocks */
 	priv->regs->maccfg1 &= ~(MACCFG1_SOFT_RESET);
 
 #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) \
Signature · 1 line
1.5.4.GIT
#1 lore raw

PATCH 1/1 tsec: Fix a bug in soft-resetting

Quoted 15 lines · Andy Fleming

SOFT_RESET must be asserted for at least 3 TX clocks. Usually, that's about 30 clock cycles, so it's been mostly working. But we had no guarantee, and at slower bitrates, it's just over a microsecond (over 1000 clock cycles). This enforces a 2 microsecond gap between assertion and deassertion.

---
 drivers/net/tsec.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/net/tsec.c +0 -0
index fbc9a6d..4682c8b 100644

drivers/net/tsec.c int tsec_initialize(bd_t * bis, struct tsec_info_struct *tsec_info) · line 164

Quoted 7 lines
drivers/net/tsec.c +1 -0
@@ -158,6 +158,7 @@ int tsec_initialize(bd_t * bis, struct tsec_info_struct *tsec_info)
 
 	/* Reset the MAC */
 	priv->regs->maccfg1 |= MACCFG1_SOFT_RESET;
+	udelay(2);  /* Soft Reset must be asserted for 3 TX clocks */
 	priv->regs->maccfg1 &= ~(MACCFG1_SOFT_RESET);
 
 #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) \

I tried the patch out and it resolves a semi-common issue I was seeing where the 1st received packet would have a CRC error that would result in an error such as:
=> dhcp
Enet starting in 100BT/HD
Speed: 100, half duplex
BOOTP broadcast 1
Got error 4
BOOTP broadcast 2

Thanks!

Applied
#2 lore raw

PATCH 1/1 tsec: Fix a bug in soft-resetting

In reply to Andy Fleming

Hi Andy,

Quoted 16 lines · Andy Fleming

SOFT_RESET must be asserted for at least 3 TX clocks. Usually, that's about 30 clock cycles, so it's been mostly working. But we had no guarantee, and at slower bitrates, it's just over a microsecond (over 1000 clock cycles). This enforces a 2 microsecond gap between assertion and deassertion.

---
 drivers/net/tsec.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/net/tsec.c +0 -0
index fbc9a6d..4682c8b 100644

drivers/net/tsec.c int tsec_initialize(bd_t * bis, struct tsec_info_struct *tsec_info) · line 164

Quoted 7 lines
drivers/net/tsec.c +1 -0
@@ -158,6 +158,7 @@ int tsec_initialize(bd_t * bis, struct tsec_info_struct *tsec_info)
 
 	/* Reset the MAC */
 	priv->regs->maccfg1 |= MACCFG1_SOFT_RESET;
+	udelay(2);  /* Soft Reset must be asserted for 3 TX clocks */
 	priv->regs->maccfg1 &= ~(MACCFG1_SOFT_RESET);
 
 #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) \

Applied to net repo.

thanks,
Ben