[edk2-devel] [PATCH v3 6/7] Platform/RaspberryPi: Power up sd, and tweak GPIOs

Jeremy Linton posted 7 patches 5 years, 1 month ago
[edk2-devel] [PATCH v3 6/7] Platform/RaspberryPi: Power up sd, and tweak GPIOs
Posted by Jeremy Linton 5 years, 1 month ago
It seems we should be powering up the sd cards, and possibly
the clocks as well to assure they are setup properly before
we attempt to access the controller.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Reviewed-by: Andrei Warkentin <awarkentin@vmware.com>
---
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
index 28f57438c5..e55ed63efa 100644
--- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
+++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
@@ -552,6 +552,16 @@ ApplyVariables (
       GpioPinFuncSet (37, GPIO_FSEL_ALT3);
       GpioPinFuncSet (38, GPIO_FSEL_ALT3);
       GpioPinFuncSet (39, GPIO_FSEL_ALT3);
+
+      /*
+       * power and clock everything by default
+       */
+      Status = mFwProtocol->SetPowerState (RPI_MBOX_POWER_STATE_SDHCI,
+                                           TRUE, TRUE); //SD on with wait
+      Status = mFwProtocol->SetGpioConfig (RPI_EXP_GPIO_SD_VOLT, 
+                                           RPI_EXP_GPIO_DIR_OUT, TRUE); //3.3v
+      Status = mFwProtocol->SetClockState (RPI_MBOX_CLOCK_RATE_EMMC2, TRUE);
+      Status = mFwProtocol->SetClockState (RPI_MBOX_CLOCK_RATE_EMMC, TRUE);
     }
   } else {
     DEBUG ((DEBUG_ERROR, "Model Family %d not supported...\n", mModelFamily));
-- 
2.13.7



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#69610): https://edk2.groups.io/g/devel/message/69610
Mute This Topic: https://groups.io/mt/79429634/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH v3 6/7] Platform/RaspberryPi: Power up sd, and tweak GPIOs
Posted by Philippe Mathieu-Daudé 5 years, 1 month ago
On 1/4/21 6:37 PM, Jeremy Linton wrote:
> It seems we should be powering up the sd cards, and possibly
> the clocks as well to assure they are setup properly before
> we attempt to access the controller.
> 
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> Reviewed-by: Andrei Warkentin <awarkentin@vmware.com>
> ---
>  Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
> index 28f57438c5..e55ed63efa 100644
> --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
> +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
> @@ -552,6 +552,16 @@ ApplyVariables (
>        GpioPinFuncSet (37, GPIO_FSEL_ALT3);
>        GpioPinFuncSet (38, GPIO_FSEL_ALT3);
>        GpioPinFuncSet (39, GPIO_FSEL_ALT3);
> +
> +      /*
> +       * power and clock everything by default

Isn't this comment a bit exaggerated? You only power the minimum
required to use the SD controller to access the card.

> +       */
> +      Status = mFwProtocol->SetPowerState (RPI_MBOX_POWER_STATE_SDHCI,
> +                                           TRUE, TRUE); //SD on with wait
> +      Status = mFwProtocol->SetGpioConfig (RPI_EXP_GPIO_SD_VOLT, 
> +                                           RPI_EXP_GPIO_DIR_OUT, TRUE); //3.3v
> +      Status = mFwProtocol->SetClockState (RPI_MBOX_CLOCK_RATE_EMMC2, TRUE);
> +      Status = mFwProtocol->SetClockState (RPI_MBOX_CLOCK_RATE_EMMC, TRUE);
>      }
>    } else {
>      DEBUG ((DEBUG_ERROR, "Model Family %d not supported...\n", mModelFamily));
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#69626): https://edk2.groups.io/g/devel/message/69626
Mute This Topic: https://groups.io/mt/79429634/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH v3 6/7] Platform/RaspberryPi: Power up sd, and tweak GPIOs
Posted by Jeremy Linton 5 years, 1 month ago
Hi,

On 1/4/21 12:44 PM, Philippe Mathieu-Daudé wrote:
> On 1/4/21 6:37 PM, Jeremy Linton wrote:
>> It seems we should be powering up the sd cards, and possibly
>> the clocks as well to assure they are setup properly before
>> we attempt to access the controller.
>>
>> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
>> Reviewed-by: Andrei Warkentin <awarkentin@vmware.com>
>> ---
>>   Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 10 ++++++++++
>>   1 file changed, 10 insertions(+)
>>
>> diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
>> index 28f57438c5..e55ed63efa 100644
>> --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
>> +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
>> @@ -552,6 +552,16 @@ ApplyVariables (
>>         GpioPinFuncSet (37, GPIO_FSEL_ALT3);
>>         GpioPinFuncSet (38, GPIO_FSEL_ALT3);
>>         GpioPinFuncSet (39, GPIO_FSEL_ALT3);
>> +
>> +      /*
>> +       * power and clock everything by default
> 
> Isn't this comment a bit exaggerated? You only power the minimum
> required to use the SD controller to access the card.

Maybe. Since I will be re-posting, maybe just dropping the comment is 
reasonable since the code is fairly self explanatory now.


> 
>> +       */
>> +      Status = mFwProtocol->SetPowerState (RPI_MBOX_POWER_STATE_SDHCI,
>> +                                           TRUE, TRUE); //SD on with wait
>> +      Status = mFwProtocol->SetGpioConfig (RPI_EXP_GPIO_SD_VOLT,
>> +                                           RPI_EXP_GPIO_DIR_OUT, TRUE); //3.3v
>> +      Status = mFwProtocol->SetClockState (RPI_MBOX_CLOCK_RATE_EMMC2, TRUE);
>> +      Status = mFwProtocol->SetClockState (RPI_MBOX_CLOCK_RATE_EMMC, TRUE);
>>       }
>>     } else {
>>       DEBUG ((DEBUG_ERROR, "Model Family %d not supported...\n", mModelFamily));
>>
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#69671): https://edk2.groups.io/g/devel/message/69671
Mute This Topic: https://groups.io/mt/79429634/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-