]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Omap35xxPkg/MMCHSDxe/MMCHS.c
Program SD Cards into 4-bit mode (support for this is required in the spec). This...
[mirror_edk2.git] / Omap35xxPkg / MMCHSDxe / MMCHS.c
index 61bf215f7ea4cbe685cfebab8ea623d7042bcac6..a6d2940cc92c8f3f4f5b77f1c73087757c8cbbb3 100644 (file)
@@ -616,6 +616,23 @@ PerformCardConfiguration (
     return Status;
   }
 
     return Status;
   }
 
+  if ((gCardInfo.CardType != UNKNOWN_CARD) && (gCardInfo.CardType != MMC_CARD)) {
+    // We could read SCR register, but SD Card Phys spec stats any SD Card shall
+    // set SCR.SD_BUS_WIDTHS to support 4-bit mode, so why bother?
+    // Send ACMD6 (application specific commands must be prefixed with CMD55)
+    Status = SendCmd (CMD55, CMD55_INT_EN, CmdArgument);
+    if (!EFI_ERROR (Status)) {
+      // set device into 4-bit data bus mode
+      Status = SendCmd (ACMD6, ACMD6_INT_EN, 0x2);
+      if (!EFI_ERROR (Status)) {
+        // Set host controler into 4-bit mode
+        MmioOr32 (MMCHS_HCTL, DTW_4_BIT);
+        DEBUG ((EFI_D_INFO, "SD Memory Card set to 4-bit mode\n"));
+      }
+    }
+  }
+
   //Send CMD16 to set the block length
   CmdArgument = gCardInfo.BlockSize;
   Status = SendCmd (CMD16, CMD16_INT_EN, CmdArgument);
   //Send CMD16 to set the block length
   CmdArgument = gCardInfo.BlockSize;
   Status = SendCmd (CMD16, CMD16_INT_EN, CmdArgument);
@@ -876,6 +893,8 @@ DetectCard (
   gMMCHSMedia.MediaId++; 
   gMediaChange = FALSE;
 
   gMMCHSMedia.MediaId++; 
   gMediaChange = FALSE;
 
+  DEBUG ((EFI_D_INFO, "SD Card Media Change\n"));
+
   return Status;
 }
 
   return Status;
 }
 
@@ -1190,7 +1209,7 @@ MMCHSInitialize (
   Status = gBS->CreateEvent (EVT_TIMER | EVT_NOTIFY_SIGNAL, TPL_CALLBACK, TimerCallback, NULL, &gTimerEvent);
   ASSERT_EFI_ERROR (Status);
  
   Status = gBS->CreateEvent (EVT_TIMER | EVT_NOTIFY_SIGNAL, TPL_CALLBACK, TimerCallback, NULL, &gTimerEvent);
   ASSERT_EFI_ERROR (Status);
  
-  Status = gBS->SetTimer (gTimerEvent, TimerPeriodic, 1000000); // make me a PCD
+  Status = gBS->SetTimer (gTimerEvent, TimerPeriodic, 1000000ULL); // make me a PCD
   ASSERT_EFI_ERROR (Status);
 
   //Publish BlockIO.
   ASSERT_EFI_ERROR (Status);
 
   //Publish BlockIO.