From: "Ard Biesheuvel" <ard.biesheuvel@linaro.org>
To: Pete Batard <pete@akeo.ie>
Cc: edk2-devel-groups-io <devel@edk2.groups.io>,
"Leif Lindholm" <leif@nuviainc.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: Re: [edk2-platforms][PATCH 0/4] Platform/RPi: Automate runtime UART selection
Date: Fri, 14 Feb 2020 09:48:18 +0000 [thread overview]
Message-ID: <CAKv+Gu_4fH-rDA3hMs4mPsGzXM9uogWAt10WWS=YJs0TzrH+fg@mail.gmail.com> (raw)
In-Reply-To: <20200128171956.9680-1-pete@akeo.ie>
On Tue, 28 Jan 2020 at 18:20, Pete Batard <pete@akeo.ie> wrote:
>
> The Raspberry Pi platform contains two UARTs, one PL011-based and the
> other (called miniUART) 16650-compatible, that are pinmuxed to the GPIO
> serial port according to whether a Device Tree overlay is present in
> config.txt or not. In most cases, it takes only the user commenting
> or uncommenting an overlay line in their config to switch between PL011
> and miniUART.
>
> As such, the use of a build time option to select the UART should be
> avoided when it is effectively possible to detect which of the UART
> is in use at runtime, through an MMIO call.
>
> This series of patches achieves just this by:
>
> * Adding the relevant clock manager constant to Silicon (which we'll
> need to retrieve the VPU divisor, needed to set the 16550 baudrate).
>
> * Adding a new DualSerialPortLibrary that handles runtime detection
> and switching between PL011 and 16650.
>
> * Enabling the use of DualSerialPortLibrar for both the RPi3 and RPi4.
>
> Important notes:
>
> * This patch does not cover ACPI serial bindings, as this requires
> switching to using DynamicTablesPkg / ConfigurationManagerDxe to
> generate the ACPI tables at runtime. As such, each of the RPi
> platforms is currently hardcoded to use one of the UARTs for ACPI:
> miniUART for RPi3 and PL011 for RPi4. Of course, there is no issue
> for Device Tree usage, since the relevant UART overlay will have
> been applied then. We don't see the current ACPI UART hardcoding
> as a major issue, as this doesn't change anything for RPi3 and we
> expect RPi4 users to prefer PL011 over miniUART anyway, but we
> will look into using DynamicTablesPkg once we see clearer in terms
> of ACPI for RPi4.
>
> * There is work underway to produce a PL011 vs miniUART aware TF-A,
> which we hope will be completed by the next TF-A release. Once
> that release has occurred, we will update the TF-A blobs in
> non-osi, since the ones we have right now are hardcoded to output
> through one UART only.
>
> * One the subject of TF-A usage, there appears to be an issue when
> using a 16650 (miniUART) based TF-A in a PL011 configuration as
> the system freezes then. This issue does not occur when using a
> PL011 based TF-A in a 16650/miniUART configuration (which is one
> of the the reason why we picked the PL011 TF-A binary over the
> 16650 one for RPi4). What this means is that, unless you replace
> the current RPi3 TF-A blobs from non-osi with a version that
> outputs to PL011, and attempt to use a Raspberry Pi 3 in PL011
> mode, then a boot freezout will happen before the UEFI firmware
> gets a chance to apply UART runtime selection. This is an issue
> that will of course resolve itself once we replace the current
> TF-A blobs with the upcoming runtime selection version. However,
> I can also produce a patch that replaces the current 16650-based
> RPI3 TF-A in non-osi with PL011-based ones, if we think it's
> needed before we get the upcoming runtime selection TF-A binaries.
>
> * It appears that we are issuing serial write calls before the
> UARTs are initialized, which is a problem if 16650 is being used
> instead of PL011 (produces a freezout similar to what occurs when
> using 16650 TF-A in a PL011 enabled conf). As such, we do perform
> miniUART vs PL011 detection in both initialize and write.
>
> * The 16650 code applies the recent bugfix from Ashish Singhal in
> https://edk2.groups.io/g/devel/message/53487.
>
> Regards,
>
> /Pete
>
> Pete Batard (4):
> Silicon/Broadcom/Bcm283x: Add clock manager constants
> Platform/RPi: Add serial lib for runtime PL011 vs miniUART detection
> Platform/RPi3: Enable the use of DualSerialPortLib
> Platform/RPi4: Enable the use of DualSerialPortLib
>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Pushed as 9369b01e86ad..41c1d9ba3304
Thanks!
> Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c | 836 ++++++++++++++++++++
> Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.inf | 55 ++
> Platform/RaspberryPi/RPi3/RPi3.dsc | 15 +-
> Platform/RaspberryPi/RPi3/Readme.md | 7 +
> Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf | 7 +
> Platform/RaspberryPi/RPi4/RPi4.dsc | 26 +-
> Platform/RaspberryPi/RPi4/RPi4.fdf | 4 -
> Platform/RaspberryPi/RPi4/Readme.md | 21 +-
> Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h | 22 +
> 9 files changed, 944 insertions(+), 49 deletions(-)
> create mode 100644 Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c
> create mode 100644 Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.inf
>
> --
> 2.21.0.windows.1
>
prev parent reply other threads:[~2020-02-14 9:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-28 17:19 [edk2-platforms][PATCH 0/4] Platform/RPi: Automate runtime UART selection Pete Batard
2020-01-28 17:19 ` [edk2-platforms][PATCH 1/4] Silicon/Broadcom/Bcm283x: Add clock manager constants Pete Batard
2020-01-28 17:19 ` [edk2-platforms][PATCH 2/4] Platform/RPi: Add serial lib for runtime PL011 vs miniUART detection Pete Batard
2020-01-28 17:19 ` [edk2-platforms][PATCH 3/4] Platform/RPi3: Enable the use of DualSerialPortLib Pete Batard
2020-01-28 17:19 ` [edk2-platforms][PATCH 4/4] Platform/RPi4: " Pete Batard
2020-01-28 17:50 ` [edk2-platforms][PATCH 0/4] Platform/RPi: Automate runtime UART selection Ard Biesheuvel
2020-02-14 9:48 ` Ard Biesheuvel [this message]
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='CAKv+Gu_4fH-rDA3hMs4mPsGzXM9uogWAt10WWS=YJs0TzrH+fg@mail.gmail.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