From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Pete Batard <pete@akeo.ie>, devel@edk2.groups.io
Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org,
samer.el-haj-mahmoud@arm.com, andrey.warkentin@gmail.com
Subject: Re: [edk2-platforms][PATCH 5/5] Platform/RPi: Set SD routing according to model
Date: Wed, 27 Nov 2019 16:24:10 +0100 [thread overview]
Message-ID: <672a8fd3-f9db-3d60-ea02-188af6e8a6a5@redhat.com> (raw)
In-Reply-To: <20191127123706.4604-6-pete@akeo.ie>
On 11/27/19 1:37 PM, Pete Batard wrote:
> From: Samer El-Haj-Mahmoud <samer.el-haj-mahmoud@arm.com>
>
> The Raspberry Pi 4 has a new SD controller. As a result we must
> handle SD routing according to the model, which we perform in
> the Config driver by using the GetModelFamily () call that was
> recently introduced.
>
> Signed-off-by: Pete Batard <pete@akeo.ie>
> ---
> Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 137 ++++++++++++++------
> 1 file changed, 96 insertions(+), 41 deletions(-)
>
> diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
> index 98e58a560ed4..26bc92f28185 100644
> --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
> +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
> @@ -1,6 +1,7 @@
> /** @file
> *
> - * Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
> + * Copyright (c) 2019, ARM Limited. All rights reserved.
"All rights reserved."?
> + * Copyright (c) 2018 - 2019, Andrei Warkentin <andrey.warkentin@gmail.com>
> *
> * SPDX-License-Identifier: BSD-2-Clause-Patent
> *
> @@ -9,10 +10,12 @@
> #include <Uefi.h>
> #include <Library/HiiLib.h>
> #include <Library/DebugLib.h>
> +#include <Library/IoLib.h>
> #include <Library/UefiBootServicesTableLib.h>
> #include <Library/UefiRuntimeServicesTableLib.h>
> #include <Library/DevicePathLib.h>
> #include <IndustryStandard/RpiMbox.h>
> +#include <IndustryStandard/Bcm2836.h>
> #include <IndustryStandard/Bcm2836Gpio.h>
> #include <Library/GpioLib.h>
> #include <Protocol/RpiFirmware.h>
> @@ -212,6 +215,7 @@ ApplyVariables (
> UINT32 CpuClock = PcdGet32 (PcdCpuClock);
> UINT32 CustomCpuClock = PcdGet32 (PcdCustomCpuClock);
> UINT32 Rate = 0;
> + UINT32 ModelFamily = 0;
>
> if (CpuClock != 0) {
> if (CpuClock == 2) {
> @@ -245,51 +249,102 @@ ApplyVariables (
> DEBUG ((DEBUG_INFO, "Current CPU speed is %uHz\n", Rate));
> }
>
> - /*
> - * Switching two groups around, so disable both first.
> - *
> - * No, I've not seen a problem, but having a group be
> - * routed to two sets of pins seems like asking for trouble.
> - */
> - GpioPinFuncSet (34, GPIO_FSEL_INPUT);
> - GpioPinFuncSet (35, GPIO_FSEL_INPUT);
> - GpioPinFuncSet (36, GPIO_FSEL_INPUT);
> - GpioPinFuncSet (37, GPIO_FSEL_INPUT);
> - GpioPinFuncSet (38, GPIO_FSEL_INPUT);
> - GpioPinFuncSet (39, GPIO_FSEL_INPUT);
> - GpioPinFuncSet (48, GPIO_FSEL_INPUT);
> - GpioPinFuncSet (49, GPIO_FSEL_INPUT);
> - GpioPinFuncSet (50, GPIO_FSEL_INPUT);
> - GpioPinFuncSet (51, GPIO_FSEL_INPUT);
> - GpioPinFuncSet (52, GPIO_FSEL_INPUT);
> - GpioPinFuncSet (53, GPIO_FSEL_INPUT);
> - if (PcdGet32 (PcdSdIsArasan)) {
> - DEBUG ((DEBUG_INFO, "Routing SD to Arasan\n"));
> - Gpio48Group = GPIO_FSEL_ALT3;
> + Status = mFwProtocol->GetModelFamily (&ModelFamily);
> + if (Status != EFI_SUCCESS) {
> + DEBUG ((DEBUG_ERROR, "Couldn't get the Raspberry Pi model family: %r\n", Status));
> + } else {
> + DEBUG ((DEBUG_INFO, "Current Raspberry Pi model family is 0x%x\n", ModelFamily));
> + }
> +
> +
> + if (ModelFamily == 3) {
> /*
> - * Route SDIO to SdHost.
> + * Pi 3: either Arasan or SdHost goes to SD card.
> + *
> + * Switching two groups around, so disable both first.
> + *
> + * No, I've not seen a problem, but having a group be
> + * routed to two sets of pins seems like asking for trouble.
> */
> - Gpio34Group = GPIO_FSEL_ALT0;
> - } else {
> - DEBUG ((DEBUG_INFO, "Routing SD to SdHost\n"));
> - Gpio48Group = GPIO_FSEL_ALT0;
> + GpioPinFuncSet (34, GPIO_FSEL_INPUT);
> + GpioPinFuncSet (35, GPIO_FSEL_INPUT);
> + GpioPinFuncSet (36, GPIO_FSEL_INPUT);
> + GpioPinFuncSet (37, GPIO_FSEL_INPUT);
> + GpioPinFuncSet (38, GPIO_FSEL_INPUT);
> + GpioPinFuncSet (39, GPIO_FSEL_INPUT);
> + GpioPinFuncSet (48, GPIO_FSEL_INPUT);
> + GpioPinFuncSet (49, GPIO_FSEL_INPUT);
> + GpioPinFuncSet (50, GPIO_FSEL_INPUT);
> + GpioPinFuncSet (51, GPIO_FSEL_INPUT);
> + GpioPinFuncSet (52, GPIO_FSEL_INPUT);
> + GpioPinFuncSet (53, GPIO_FSEL_INPUT);
> +
> + if (PcdGet32 (PcdSdIsArasan)) {
> + DEBUG ((DEBUG_INFO, "Routing SD to Arasan\n"));
> + Gpio48Group = GPIO_FSEL_ALT3;
> + /*
> + * Route SDIO to SdHost.
> + */
> + Gpio34Group = GPIO_FSEL_ALT0;
> + } else {
> + DEBUG ((DEBUG_INFO, "Routing SD to SdHost\n"));
> + Gpio48Group = GPIO_FSEL_ALT0;
> + /*
> + * Route SDIO to Arasan.
> + */
> + Gpio34Group = GPIO_FSEL_ALT3;
> + }
> + GpioPinFuncSet (34, Gpio34Group);
> + GpioPinFuncSet (35, Gpio34Group);
> + GpioPinFuncSet (36, Gpio34Group);
> + GpioPinFuncSet (37, Gpio34Group);
> + GpioPinFuncSet (38, Gpio34Group);
> + GpioPinFuncSet (39, Gpio34Group);
> + GpioPinFuncSet (48, Gpio48Group);
> + GpioPinFuncSet (49, Gpio48Group);
> + GpioPinFuncSet (50, Gpio48Group);
> + GpioPinFuncSet (51, Gpio48Group);
> + GpioPinFuncSet (52, Gpio48Group);
> + GpioPinFuncSet (53, Gpio48Group);
> +
> + } else if (ModelFamily == 4){
Missing space before opening brackets.
Patch looks good otherwise.
> /*
> - * Route SDIO to Arasan.
> + * Pi 4: either Arasan or eMMC2 goes to SD card.
> */
> - Gpio34Group = GPIO_FSEL_ALT3;
> + if (PcdGet32 (PcdSdIsArasan)) {
> + /*
> + * WiFi disabled.
> + */
> + GpioPinFuncSet (34, GPIO_FSEL_INPUT);
> + GpioPinFuncSet (35, GPIO_FSEL_INPUT);
> + GpioPinFuncSet (36, GPIO_FSEL_INPUT);
> + GpioPinFuncSet (37, GPIO_FSEL_INPUT);
> + GpioPinFuncSet (38, GPIO_FSEL_INPUT);
> + GpioPinFuncSet (39, GPIO_FSEL_INPUT);
> + /*
> + * SD card pins go to Arasan.
> + */
> + MmioWrite32((GPIO_BASE_ADDRESS + 0xD0),
> + MmioRead32(GPIO_BASE_ADDRESS + 0xD0) | 0x2);
> + } else {
> + /*
> + * SD card pins back to eMMC2.
> + */
> + MmioWrite32((GPIO_BASE_ADDRESS + 0xD0),
> + MmioRead32(GPIO_BASE_ADDRESS + 0xD0) & ~0x2);
> + /*
> + * WiFi back to Arasan.
> + */
> + GpioPinFuncSet (34, GPIO_FSEL_ALT3);
> + GpioPinFuncSet (35, GPIO_FSEL_ALT3);
> + GpioPinFuncSet (36, GPIO_FSEL_ALT3);
> + GpioPinFuncSet (37, GPIO_FSEL_ALT3);
> + GpioPinFuncSet (38, GPIO_FSEL_ALT3);
> + GpioPinFuncSet (39, GPIO_FSEL_ALT3);
> + }
> + } else {
> + DEBUG ((DEBUG_ERROR, "Model Family %d not supported...\n", ModelFamily));
> }
> - GpioPinFuncSet (34, Gpio34Group);
> - GpioPinFuncSet (35, Gpio34Group);
> - GpioPinFuncSet (36, Gpio34Group);
> - GpioPinFuncSet (37, Gpio34Group);
> - GpioPinFuncSet (38, Gpio34Group);
> - GpioPinFuncSet (39, Gpio34Group);
> - GpioPinFuncSet (48, Gpio48Group);
> - GpioPinFuncSet (49, Gpio48Group);
> - GpioPinFuncSet (50, Gpio48Group);
> - GpioPinFuncSet (51, Gpio48Group);
> - GpioPinFuncSet (52, Gpio48Group);
> - GpioPinFuncSet (53, Gpio48Group);
>
> /*
> * JTAG pin JTAG sig GPIO Mode Header pin
>
next prev parent reply other threads:[~2019-11-27 15:24 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-27 12:37 [edk2-platforms][PATCH 0/5] Further RPi4 support groundwork Pete Batard
2019-11-27 12:37 ` [edk2-platforms][PATCH 1/5] Silicon/Bcm283x: Clean up Bcm2836.h header Pete Batard
2019-11-27 12:48 ` Ard Biesheuvel
2019-11-27 12:56 ` Pete Batard
2019-11-27 13:00 ` Ard Biesheuvel
2019-11-27 13:09 ` Pete Batard
2019-11-27 13:17 ` Ard Biesheuvel
2019-11-27 13:21 ` Pete Batard
2019-11-27 14:47 ` Philippe Mathieu-Daudé
2019-11-27 14:59 ` [edk2-devel] " Pete Batard
2019-11-27 15:18 ` Philippe Mathieu-Daudé
2019-11-27 12:37 ` [edk2-platforms][PATCH 2/5] Silicon/Bcm283x: Add FIFO mode for RNG Pete Batard
2019-11-27 12:44 ` Ard Biesheuvel
2019-11-27 12:47 ` Pete Batard
2019-11-27 12:37 ` [edk2-platforms][PATCH 3/5] Platform/RPi/MmcDxe: Factorize SCR call and clean up MMC init Pete Batard
2019-11-27 12:37 ` [edk2-platforms][PATCH 4/5] Platform/RPi/MmcDxe: Improve MMC driver stability Pete Batard
2019-11-27 12:37 ` [edk2-platforms][PATCH 5/5] Platform/RPi: Set SD routing according to model Pete Batard
2019-11-27 15:24 ` Philippe Mathieu-Daudé [this message]
2019-11-27 16:33 ` Pete Batard
2019-11-27 17:04 ` Leif Lindholm
2019-11-27 17:17 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=672a8fd3-f9db-3d60-ea02-188af6e8a6a5@redhat.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox