<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div dir="ltr"><div>This patch and the mail subject look good. Thanks, Rick! I'll send this over to Joel for commit tomorrow.<br></div><div><br></div><div>Kinsey<br></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 27, 2023 at 7:31 PM <<a href="mailto:rvanderwal@bellsouth.net">rvanderwal@bellsouth.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From: Rick VanderWal <<a href="mailto:rvanderwal@bellsouth.net" target="_blank">rvanderwal@bellsouth.net</a>><br>
<br>
This fixes an issue where the card present signal doesn't stabilize<br>
quickly and indicates present when no card is inserted in a removable<br>
slot.<br>
---<br>
 rtemsbsd/sys/dev/sdhci/arasan_sdhci.c | 21 +++++++++++++++++++++<br>
 1 file changed, 21 insertions(+)<br>
<br>
diff --git a/rtemsbsd/sys/dev/sdhci/arasan_sdhci.c b/rtemsbsd/sys/dev/sdhci/arasan_sdhci.c<br>
index 0e87d903..722e609d 100644<br>
--- a/rtemsbsd/sys/dev/sdhci/arasan_sdhci.c<br>
+++ b/rtemsbsd/sys/dev/sdhci/arasan_sdhci.c<br>
@@ -195,6 +195,27 @@ arasan_sdhci_get_card_present(device_t dev, struct sdhci_slot *slot)<br>
 {<br>
        struct arasan_sdhci_softc *sc = device_get_softc(dev);<br>
<br>
+       // wait a maximum of 1 second for card stable to settle<br>
+       const unsigned int max_tries = 20;<br>
+       const rtems_interval sleep_ticks =<br>
+               rtems_clock_get_ticks_per_second() / max_tries;<br>
+<br>
+       unsigned int count = 0;<br>
+       while (!(RD4(sc, SDHCI_PRESENT_STATE) & SDHCI_CARD_STABLE) &&<br>
+               (count < max_tries))<br>
+       {<br>
+               rtems_task_wake_after(sleep_ticks);<br>
+               ++count;<br>
+       }<br>
+<br>
+       if (!(RD4(sc, SDHCI_PRESENT_STATE) & SDHCI_CARD_STABLE))<br>
+       {<br>
+               device_printf(dev,<br>
+                       "Card Detect failed to stabilize,"<br>
+                       " setting to not present.\n");<br>
+               return false;<br>
+       }<br>
+<br>
        return (RD4(sc, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT);<br>
 }<br>
<br>
-- <br>
2.34.1<br>
<br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</blockquote></div>