]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EmbeddedPkg/Lan9118Dxe: Fix the reset after a receiver or transmitter error
authorRonald Cron <ronald.cron@arm.com>
Thu, 2 Apr 2015 13:49:05 +0000 (13:49 +0000)
committeroliviermartin <oliviermartin@Edk2>
Thu, 2 Apr 2015 13:49:05 +0000 (13:49 +0000)
The Lan9118 driver did not recover after a receiver error as the error
handling code stopped the transmitter but did not restart it. Added the
restart of the transmitter.

Added also the restart of the receiver after a transmitter error and
the reactivation of the LEDs after all resets.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Reviewed-by: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17106 6f19259b-4bc3-4df7-8a09-765794883524

EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118Dxe.c

index 0503dbce1e5536a95dc6b3b2ab8eb81908cce711..3b7882d5d708d9bd11c78636f4c641d8a8a58530 100644 (file)
@@ -434,6 +434,12 @@ SnpReset (
   MmioWrite32 (LAN9118_PMT_CTRL, PmConf);\r
   gBS->Stall (LAN9118_STALL);\r
 \r
   MmioWrite32 (LAN9118_PMT_CTRL, PmConf);\r
   gBS->Stall (LAN9118_STALL);\r
 \r
+  // Reactivate the LEDs\r
+  Status = ConfigureHardware (HW_CONF_USE_LEDS, Snp);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
   // Check that a buffer size was specified in SnpInitialize\r
   if (gTxBuffer != 0) {\r
     HwConf = MmioRead32 (LAN9118_HW_CFG);        // Read the HW register\r
   // Check that a buffer size was specified in SnpInitialize\r
   if (gTxBuffer != 0) {\r
     HwConf = MmioRead32 (LAN9118_HW_CFG);        // Read the HW register\r
@@ -1062,19 +1068,28 @@ SnpGetStatus (
   if (Interrupts & INSTS_TXE) {\r
     DEBUG ((EFI_D_ERROR, "LAN9118: Transmitter error. Restarting..."));\r
 \r
   if (Interrupts & INSTS_TXE) {\r
     DEBUG ((EFI_D_ERROR, "LAN9118: Transmitter error. Restarting..."));\r
 \r
-    // Initiate a software reset\r
+    // Software reset, the TXE interrupt is cleared by the reset.\r
     Status = SoftReset (0, Snp);\r
     if (EFI_ERROR (Status)) {\r
       DEBUG ((EFI_D_ERROR, "\n\tSoft Reset Failed: Hardware Error\n"));\r
       return EFI_DEVICE_ERROR;\r
     }\r
 \r
     Status = SoftReset (0, Snp);\r
     if (EFI_ERROR (Status)) {\r
       DEBUG ((EFI_D_ERROR, "\n\tSoft Reset Failed: Hardware Error\n"));\r
       return EFI_DEVICE_ERROR;\r
     }\r
 \r
-    // Acknowledge the TXE\r
-    MmioWrite32 (LAN9118_INT_STS, INSTS_TXE);\r
-    gBS->Stall (LAN9118_STALL);\r
+    // Reactivate the LEDs\r
+    Status = ConfigureHardware (HW_CONF_USE_LEDS, Snp);\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
 \r
 \r
-    // Restart the transmitter\r
+    //\r
+    // Restart the transmitter and if necessary the receiver.\r
+    // Do not ask for FIFO reset as it has already been done\r
+    // by SoftReset().\r
+    //\r
     StartTx (START_TX_MAC | START_TX_CFG, Snp);\r
     StartTx (START_TX_MAC | START_TX_CFG, Snp);\r
+    if (Snp->Mode->ReceiveFilterSetting != 0) {\r
+      StartRx (0, Snp);\r
+    }\r
   }\r
 \r
   // Update the media status\r
   }\r
 \r
   // Update the media status\r
@@ -1442,19 +1457,25 @@ SnpReceive (
   if (MmioRead32 (LAN9118_INT_STS) & INSTS_RXE) {\r
     DEBUG ((EFI_D_WARN, "Warning: Receiver Error. Restarting...\n"));\r
 \r
   if (MmioRead32 (LAN9118_INT_STS) & INSTS_RXE) {\r
     DEBUG ((EFI_D_WARN, "Warning: Receiver Error. Restarting...\n"));\r
 \r
-    // Initiate a software reset\r
+    // Software reset, the RXE interrupt is cleared by the reset.\r
     Status = SoftReset (0, Snp);\r
     if (EFI_ERROR (Status)) {\r
       DEBUG ((EFI_D_ERROR, "Error: Soft Reset Failed: Hardware Error.\n"));\r
       return EFI_DEVICE_ERROR;\r
     }\r
 \r
     Status = SoftReset (0, Snp);\r
     if (EFI_ERROR (Status)) {\r
       DEBUG ((EFI_D_ERROR, "Error: Soft Reset Failed: Hardware Error.\n"));\r
       return EFI_DEVICE_ERROR;\r
     }\r
 \r
-    // Acknowledge the RXE\r
-    MmioWrite32 (LAN9118_INT_STS, INSTS_RXE);\r
-    gBS->Stall (LAN9118_STALL);\r
+    // Reactivate the LEDs\r
+    Status = ConfigureHardware (HW_CONF_USE_LEDS, Snp);\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
 \r
 \r
-    // Restart the rx (and do not clear FIFO)\r
+    //\r
+    // Restart the receiver and the transmitter without reseting the FIFOs\r
+    // as it has been done by SoftReset().\r
+    //\r
     StartRx (0, Snp);\r
     StartRx (0, Snp);\r
+    StartTx (START_TX_MAC | START_TX_CFG, Snp);\r
 \r
     // Say that command could not be sent\r
     return EFI_DEVICE_ERROR;\r
 \r
     // Say that command could not be sent\r
     return EFI_DEVICE_ERROR;\r