Re: [PATCH 1/1] rtemsbsd/sdhci: Fix Arasan driver when no card present

2023-03-23 Thread Kinsey Moore
On Thu, Mar 23, 2023 at 7:19 PM Rick VanderWal 
wrote:

>
> On 3/23/23 10:26, Kinsey Moore wrote:
>
> On Wed, Mar 22, 2023 at 7:02 PM  wrote:
>
>>
>> +   if (!(RD4(sc, SDHCI_PRESENT_STATE) & SDHCI_CARD_STABLE))
>> +   {
>> +   device_printf(dev,
>> +   "CD failed to stabilize, setting to not
>> present.\n");
>>
>
> What is "CD"? Should this be "SD"?
>
> CD is the "Card Detect" signal line from the SD card socket. In this case
> it may be better to spell out to avoid confusion.
>
Yes, I think it'd be best to spell this out since none of the surrounding
text does so. I think with that tweak it'll be ready to get committed.
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH 1/1] rtemsbsd/sdhci: Fix Arasan driver when no card present

2023-03-23 Thread Rick VanderWal

Kinsey,

Thanks for the feedback! I added the git config as recommended.

Response to your comment is inline below.

Regards,

-Rick

On 3/23/23 10:26, Kinsey Moore wrote:

Hey Rick,
This looks good for the most part and thanks for the contribution.

For future patches, please make sure you specify the repository in 
your subject line if the patch isn't for the RTEMS repository. This 
can be configured to occur automatically in your local per-repo git 
configuration using this:

git config format.subjectprefix "PATCH rtems-libbsd"

This should actually be referenced in the git docs for this project, 
but it appears that there's a mistake in the markup that I'm about to 
go fix.


Just one comment inline below:

On Wed, Mar 22, 2023 at 7:02 PM  wrote:

From: Rick VanderWal 

This fixes an issue where the card present signal doesn't stabilize
quickly and indicates present when no card is inserted in a removable
slot.
---
 rtemsbsd/sys/dev/sdhci/arasan_sdhci.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/rtemsbsd/sys/dev/sdhci/arasan_sdhci.c
b/rtemsbsd/sys/dev/sdhci/arasan_sdhci.c
index 0e87d903..7ac0a971 100644
--- a/rtemsbsd/sys/dev/sdhci/arasan_sdhci.c
+++ b/rtemsbsd/sys/dev/sdhci/arasan_sdhci.c
@@ -195,6 +195,26 @@ arasan_sdhci_get_card_present(device_t dev,
struct sdhci_slot *slot)
 {
        struct arasan_sdhci_softc *sc = device_get_softc(dev);

+       // wait a maximum of 1 second for card stable to settle
+       const unsigned int max_tries = 20;
+       const rtems_interval sleep_ticks =
+               rtems_clock_get_ticks_per_second() / max_tries;
+
+       unsigned int count = 0;
+       while (!(RD4(sc, SDHCI_PRESENT_STATE) & SDHCI_CARD_STABLE) &&
+               (count < max_tries))
+       {
+               rtems_task_wake_after(sleep_ticks);
+               ++count;
+       }
+
+       if (!(RD4(sc, SDHCI_PRESENT_STATE) & SDHCI_CARD_STABLE))
+       {
+               device_printf(dev,
+                       "CD failed to stabilize, setting to not
present.\n");


What is "CD"? Should this be "SD"?


CD is the "Card Detect" signal line from the SD card socket. In this 
case it may be better to spell out to avoid confusion.



+               return false;
+       }
+
        return (RD4(sc, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT);
 }
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH 1/1] rtemsbsd/sdhci: Fix Arasan driver when no card present

2023-03-23 Thread Kinsey Moore
Hey Rick,
This looks good for the most part and thanks for the contribution.

For future patches, please make sure you specify the repository in your
subject line if the patch isn't for the RTEMS repository. This can be
configured to occur automatically in your local per-repo git configuration
using this:
git config format.subjectprefix "PATCH rtems-libbsd"

This should actually be referenced in the git docs for this project, but it
appears that there's a mistake in the markup that I'm about to go fix.

Just one comment inline below:

On Wed, Mar 22, 2023 at 7:02 PM  wrote:

> From: Rick VanderWal 
>
> This fixes an issue where the card present signal doesn't stabilize
> quickly and indicates present when no card is inserted in a removable
> slot.
> ---
>  rtemsbsd/sys/dev/sdhci/arasan_sdhci.c | 20 
>  1 file changed, 20 insertions(+)
>
> diff --git a/rtemsbsd/sys/dev/sdhci/arasan_sdhci.c
> b/rtemsbsd/sys/dev/sdhci/arasan_sdhci.c
> index 0e87d903..7ac0a971 100644
> --- a/rtemsbsd/sys/dev/sdhci/arasan_sdhci.c
> +++ b/rtemsbsd/sys/dev/sdhci/arasan_sdhci.c
> @@ -195,6 +195,26 @@ arasan_sdhci_get_card_present(device_t dev, struct
> sdhci_slot *slot)
>  {
> struct arasan_sdhci_softc *sc = device_get_softc(dev);
>
> +   // wait a maximum of 1 second for card stable to settle
> +   const unsigned int max_tries = 20;
> +   const rtems_interval sleep_ticks =
> +   rtems_clock_get_ticks_per_second() / max_tries;
> +
> +   unsigned int count = 0;
> +   while (!(RD4(sc, SDHCI_PRESENT_STATE) & SDHCI_CARD_STABLE) &&
> +   (count < max_tries))
> +   {
> +   rtems_task_wake_after(sleep_ticks);
> +   ++count;
> +   }
> +
> +   if (!(RD4(sc, SDHCI_PRESENT_STATE) & SDHCI_CARD_STABLE))
> +   {
> +   device_printf(dev,
> +   "CD failed to stabilize, setting to not
> present.\n");
>

What is "CD"? Should this be "SD"?


> +   return false;
> +   }
> +
> return (RD4(sc, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT);
>  }
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

[PATCH 1/1] rtemsbsd/sdhci: Fix Arasan driver when no card present

2023-03-22 Thread rvanderwal
From: Rick VanderWal 

This fixes an issue where the card present signal doesn't stabilize
quickly and indicates present when no card is inserted in a removable
slot.
---
 rtemsbsd/sys/dev/sdhci/arasan_sdhci.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/rtemsbsd/sys/dev/sdhci/arasan_sdhci.c 
b/rtemsbsd/sys/dev/sdhci/arasan_sdhci.c
index 0e87d903..7ac0a971 100644
--- a/rtemsbsd/sys/dev/sdhci/arasan_sdhci.c
+++ b/rtemsbsd/sys/dev/sdhci/arasan_sdhci.c
@@ -195,6 +195,26 @@ arasan_sdhci_get_card_present(device_t dev, struct 
sdhci_slot *slot)
 {
struct arasan_sdhci_softc *sc = device_get_softc(dev);
 
+   // wait a maximum of 1 second for card stable to settle
+   const unsigned int max_tries = 20;
+   const rtems_interval sleep_ticks =
+   rtems_clock_get_ticks_per_second() / max_tries;
+
+   unsigned int count = 0;
+   while (!(RD4(sc, SDHCI_PRESENT_STATE) & SDHCI_CARD_STABLE) &&
+   (count < max_tries))
+   {
+   rtems_task_wake_after(sleep_ticks);
+   ++count;
+   }
+
+   if (!(RD4(sc, SDHCI_PRESENT_STATE) & SDHCI_CARD_STABLE))
+   {
+   device_printf(dev,
+   "CD failed to stabilize, setting to not present.\n");
+   return false;
+   }
+
return (RD4(sc, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT);
 }
 
-- 
2.34.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel