Revision: 17106
          http://sourceforge.net/p/edk2/code/17106
Author:   oliviermartin
Date:     2015-04-02 13:49:05 +0000 (Thu, 02 Apr 2015)
Log Message:
-----------
EmbeddedPkg/Lan9118Dxe: Fix the reset after a receiver or transmitter error

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 <[email protected]>
Reviewed-by: Olivier Martin <[email protected]>

Modified Paths:
--------------
    trunk/edk2/EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118Dxe.c

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


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to