I know it has been months but I just had an idea that seems to fix
this issue. I still need to test for some time to make sure but so far
it is working fine.

What I did is simply add a delay before the SD card is initialized.
The attached patch takes a brute force approach and will attempt to
initialize multiple times. However, so far it has never had to attempt
the initialize more than once.

That little "msleep(5)" before setting up the card seems to be all
that is needed. Like I said though, still testing but looking good.

Chris
diff --git a/src/hw/sdcard.c b/src/hw/sdcard.c
index 6410340..70bb08f 100644
--- a/src/hw/sdcard.c
+++ b/src/hw/sdcard.c
@@ -507,15 +507,23 @@ sdcard_controller_setup(struct sdhci_s *regs, int prio)
         warn_noalloc();
         goto fail;
     }
-    memset(drive, 0, sizeof(*drive));
-    drive->drive.type = DTYPE_SDCARD;
-    drive->regs = regs;
-    int ret = sdcard_card_setup(drive, volt, prio);
-    if (ret) {
-        free(drive);
-        goto fail;
+
+    for (int i = 0; i < 500; i++)
+    {
+        msleep(5);
+        memset(drive, 0, sizeof(*drive));
+        drive->drive.type = DTYPE_SDCARD;
+        drive->regs = regs;
+        int ret = sdcard_card_setup(drive, volt, prio);
+        if (!ret) {
+            // Success
+            dprintf(9, "sdcard setup took %d\n", i);
+            return;
+        }
     }
-    return;
+
+    free(drive);
+
 fail:
     writeb(&regs->power_control, 0);
     writew(&regs->clock_control, 0);
_______________________________________________
SeaBIOS mailing list
SeaBIOS@seabios.org
https://mail.coreboot.org/mailman/listinfo/seabios

Reply via email to