[edk2-devel] [PATCH v4 0/7] rpi4: Enable eMMC2 controller

Jeremy Linton posted 7 patches 3 years, 3 months ago
Failed in applying to current master (apply log)
There is a newer version of this series
.../Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.c    | 131 ++++++++---
.../Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.h    |   1 +
Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c |   7 +
.../Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c        | 240 ++++++++++++++++++++-
.../RaspberryPi/Include/IndustryStandard/RpiMbox.h |  94 +++++++-
.../RaspberryPi/Include/Protocol/RpiFirmware.h     |  25 +++
.../Library/PlatformBootManagerLib/PlatformBm.c    |   2 +-
.../Bcm283x/Include/IndustryStandard/Bcm2836Sdio.h |  42 ++--
8 files changed, 484 insertions(+), 58 deletions(-)
[edk2-devel] [PATCH v4 0/7] rpi4: Enable eMMC2 controller
Posted by Jeremy Linton 3 years, 3 months ago
The rpi4 has a secondary SD controller at offset
0xfe340000. This controller appears to be a mostly
compliant SDHCI controller (a newer more bugfree
Arasan?). So the existing Arasan driver should be 
bound to it. This allows the rpi4 to boot
with its normal eMMC2->SD card, Arasan->wifi 
configuration that is described in the Linux DT.

To achieve this, it appears we should be tweaking
some of the expansion gpios, and probably telling
the firmware to power everything up. To do that
the vpu mailbox headers are synced with a more recent
list of the mailbox commands, then the rpi
firmware dxe is extended to support some futher
gpio/power commands. Once that is complete we tweak
the arasan driver to use an alternate register base,
add a workaround for a known clock crossing bug, and
set the card voltage.

Of note, this set does _NOT_ change the HID/CID's
and add the additional eMMC2 controller to the
DSDT table. That remains an open item waiting
for a proper set of device ids.

v3->v4: Commit message tweaks, variable rename.
v1->v3: Use some mailbox defines rather than opencoded constants

Jeremy Linton (7):
  Platform/RaspberryPi: Update VPU mailbox constants
  Platform/RaspberryPi: Add further mailbox helpers
  Platform/RaspberryPi: Split MMC register definitions
  Platform/RaspberryPi/Arasan: Add write delay and voltage/clock config
  Platform/RaspberryPi/Arasan: Select the correct base frequency
  Platform/RaspberryPi: Power up SD, and tweak GPIOs
  Platform/RaspberryPi: Correct device path removal.

 .../Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.c    | 131 ++++++++---
 .../Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.h    |   1 +
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c |   7 +
 .../Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c        | 240 ++++++++++++++++++++-
 .../RaspberryPi/Include/IndustryStandard/RpiMbox.h |  94 +++++++-
 .../RaspberryPi/Include/Protocol/RpiFirmware.h     |  25 +++
 .../Library/PlatformBootManagerLib/PlatformBm.c    |   2 +-
 .../Bcm283x/Include/IndustryStandard/Bcm2836Sdio.h |  42 ++--
 8 files changed, 484 insertions(+), 58 deletions(-)

-- 
2.13.7



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


Re: [edk2-devel] [PATCH v4 0/7] rpi4: Enable eMMC2 controller
Posted by Ard Biesheuvel 3 years, 3 months ago
On 1/5/21 5:34 PM, Jeremy Linton wrote:
> The rpi4 has a secondary SD controller at offset
> 0xfe340000. This controller appears to be a mostly
> compliant SDHCI controller (a newer more bugfree
> Arasan?). So the existing Arasan driver should be 
> bound to it. This allows the rpi4 to boot
> with its normal eMMC2->SD card, Arasan->wifi 
> configuration that is described in the Linux DT.
> 

Could you please explain why this is an advantage? Is it related to ACPI
OSes not needing to change pinmuxing etc?


> To achieve this, it appears we should be tweaking
> some of the expansion gpios, and probably telling
> the firmware to power everything up. To do that
> the vpu mailbox headers are synced with a more recent
> list of the mailbox commands, then the rpi
> firmware dxe is extended to support some futher
> gpio/power commands. Once that is complete we tweak
> the arasan driver to use an alternate register base,
> add a workaround for a known clock crossing bug, and
> set the card voltage.
> 
> Of note, this set does _NOT_ change the HID/CID's
> and add the additional eMMC2 controller to the
> DSDT table. That remains an open item waiting
> for a proper set of device ids.
> 
> v3->v4: Commit message tweaks, variable rename.
> v1->v3: Use some mailbox defines rather than opencoded constants
> 
> Jeremy Linton (7):
>   Platform/RaspberryPi: Update VPU mailbox constants
>   Platform/RaspberryPi: Add further mailbox helpers
>   Platform/RaspberryPi: Split MMC register definitions
>   Platform/RaspberryPi/Arasan: Add write delay and voltage/clock config
>   Platform/RaspberryPi/Arasan: Select the correct base frequency
>   Platform/RaspberryPi: Power up SD, and tweak GPIOs
>   Platform/RaspberryPi: Correct device path removal.
> 
>  .../Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.c    | 131 ++++++++---
>  .../Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.h    |   1 +
>  Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c |   7 +
>  .../Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c        | 240 ++++++++++++++++++++-
>  .../RaspberryPi/Include/IndustryStandard/RpiMbox.h |  94 +++++++-
>  .../RaspberryPi/Include/Protocol/RpiFirmware.h     |  25 +++
>  .../Library/PlatformBootManagerLib/PlatformBm.c    |   2 +-
>  .../Bcm283x/Include/IndustryStandard/Bcm2836Sdio.h |  42 ++--
>  8 files changed, 484 insertions(+), 58 deletions(-)
> 



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


Re: [edk2-devel] [PATCH v4 0/7] rpi4: Enable eMMC2 controller
Posted by Andrei Warkentin 3 years, 3 months ago
Ard: IIRC eMMC2 is a better SDHCI-like controller. It supports more high-speed modes (e.g. 1.8V ones), resulting in better I/O performance,

A
________________________________
From: Ard Biesheuvel <ard.biesheuvel@arm.com>
Sent: Wednesday, January 6, 2021 3:11 AM
To: Jeremy Linton <jeremy.linton@arm.com>; devel@edk2.groups.io <devel@edk2.groups.io>
Cc: leif@nuviainc.com <leif@nuviainc.com>; pete@akeo.ie <pete@akeo.ie>; samer.el-haj-mahmoud@arm.com <samer.el-haj-mahmoud@arm.com>; Andrei Warkentin <awarkentin@vmware.com>
Subject: Re: [PATCH v4 0/7] rpi4: Enable eMMC2 controller

On 1/5/21 5:34 PM, Jeremy Linton wrote:
> The rpi4 has a secondary SD controller at offset
> 0xfe340000. This controller appears to be a mostly
> compliant SDHCI controller (a newer more bugfree
> Arasan?). So the existing Arasan driver should be
> bound to it. This allows the rpi4 to boot
> with its normal eMMC2->SD card, Arasan->wifi
> configuration that is described in the Linux DT.
>

Could you please explain why this is an advantage? Is it related to ACPI
OSes not needing to change pinmuxing etc?


> To achieve this, it appears we should be tweaking
> some of the expansion gpios, and probably telling
> the firmware to power everything up. To do that
> the vpu mailbox headers are synced with a more recent
> list of the mailbox commands, then the rpi
> firmware dxe is extended to support some futher
> gpio/power commands. Once that is complete we tweak
> the arasan driver to use an alternate register base,
> add a workaround for a known clock crossing bug, and
> set the card voltage.
>
> Of note, this set does _NOT_ change the HID/CID's
> and add the additional eMMC2 controller to the
> DSDT table. That remains an open item waiting
> for a proper set of device ids.
>
> v3->v4: Commit message tweaks, variable rename.
> v1->v3: Use some mailbox defines rather than opencoded constants
>
> Jeremy Linton (7):
>   Platform/RaspberryPi: Update VPU mailbox constants
>   Platform/RaspberryPi: Add further mailbox helpers
>   Platform/RaspberryPi: Split MMC register definitions
>   Platform/RaspberryPi/Arasan: Add write delay and voltage/clock config
>   Platform/RaspberryPi/Arasan: Select the correct base frequency
>   Platform/RaspberryPi: Power up SD, and tweak GPIOs
>   Platform/RaspberryPi: Correct device path removal.
>
>  .../Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.c    | 131 ++++++++---
>  .../Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.h    |   1 +
>  Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c |   7 +
>  .../Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c        | 240 ++++++++++++++++++++-
>  .../RaspberryPi/Include/IndustryStandard/RpiMbox.h |  94 +++++++-
>  .../RaspberryPi/Include/Protocol/RpiFirmware.h     |  25 +++
>  .../Library/PlatformBootManagerLib/PlatformBm.c    |   2 +-
>  .../Bcm283x/Include/IndustryStandard/Bcm2836Sdio.h |  42 ++--
>  8 files changed, 484 insertions(+), 58 deletions(-)
>



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


Re: [edk2-devel] [PATCH v4 0/7] rpi4: Enable eMMC2 controller
Posted by Jeremy Linton 3 years, 3 months ago
Hi,

On 1/6/21 3:11 AM, Ard Biesheuvel via groups.io wrote:
> On 1/5/21 5:34 PM, Jeremy Linton wrote:
>> The rpi4 has a secondary SD controller at offset
>> 0xfe340000. This controller appears to be a mostly
>> compliant SDHCI controller (a newer more bugfree
>> Arasan?). So the existing Arasan driver should be
>> bound to it. This allows the rpi4 to boot
>> with its normal eMMC2->SD card, Arasan->wifi
>> configuration that is described in the Linux DT.
>>
> 
> Could you please explain why this is an advantage? Is it related to ACPI
> OSes not needing to change pinmuxing etc?

As Andrei mentions, there is a perf advantage to having the SD on the 
"emmc", but IMHO a larger issue is that we don't appear to have 
sufficient information to get the SDIO/Wifi routed properly to the 
emmc2. Meaning the only way I've been able to get the wifi to work is 
when its attached to the "arasan". That is true for both DT, and ACPI. 
The latter of course is working and I will hopefully post those fairly 
trivial changes RSN.

Further, this set fixes a rather annoying bug in the current firmware, 
that if the controller is changed to "emmc" in the BDS, then the machine 
is forever stuck, unable to persist any further uefi variable changes.

BTW: For those not on discord, these controllers actually seem to be 
working with the linux sdhci_acpi driver, when the standard PNP id is 
used. Which is a pretty large victory in itself, but that driver doesn't 
have the write delay quirking, or the cmd12 quirking so it throws a 
number of warnings when using the wifi in ACPI mode. So, the best plan 
appears to be a custom HID, and adding the acpi bindings to the 
sdhci_iproc driver which contains those quirks.

> 
> 
>> To achieve this, it appears we should be tweaking
>> some of the expansion gpios, and probably telling
>> the firmware to power everything up. To do that
>> the vpu mailbox headers are synced with a more recent
>> list of the mailbox commands, then the rpi
>> firmware dxe is extended to support some futher
>> gpio/power commands. Once that is complete we tweak
>> the arasan driver to use an alternate register base,
>> add a workaround for a known clock crossing bug, and
>> set the card voltage.
>>
>> Of note, this set does _NOT_ change the HID/CID's
>> and add the additional eMMC2 controller to the
>> DSDT table. That remains an open item waiting
>> for a proper set of device ids.
>>
>> v3->v4: Commit message tweaks, variable rename.
>> v1->v3: Use some mailbox defines rather than opencoded constants
>>
>> Jeremy Linton (7):
>>    Platform/RaspberryPi: Update VPU mailbox constants
>>    Platform/RaspberryPi: Add further mailbox helpers
>>    Platform/RaspberryPi: Split MMC register definitions
>>    Platform/RaspberryPi/Arasan: Add write delay and voltage/clock config
>>    Platform/RaspberryPi/Arasan: Select the correct base frequency
>>    Platform/RaspberryPi: Power up SD, and tweak GPIOs
>>    Platform/RaspberryPi: Correct device path removal.
>>
>>   .../Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.c    | 131 ++++++++---
>>   .../Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.h    |   1 +
>>   Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c |   7 +
>>   .../Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c        | 240 ++++++++++++++++++++-
>>   .../RaspberryPi/Include/IndustryStandard/RpiMbox.h |  94 +++++++-
>>   .../RaspberryPi/Include/Protocol/RpiFirmware.h     |  25 +++
>>   .../Library/PlatformBootManagerLib/PlatformBm.c    |   2 +-
>>   .../Bcm283x/Include/IndustryStandard/Bcm2836Sdio.h |  42 ++--
>>   8 files changed, 484 insertions(+), 58 deletions(-)
>>
> 
> 
> 
> 
> 
> 



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