From: "Ard Biesheuvel" <ardb@kernel.org>
To: Jeremy Linton <jeremy.linton@arm.com>
Cc: devel@edk2.groups.io, ardb+tianocore@kernel.org,
quic_llindhol@quicinc.com
Subject: Re: [edk2-devel] [PATCH 1/5] Platform/RaspberryPi/DualSerialPortLib: Always configure the pl011
Date: Thu, 11 Jan 2024 08:46:22 +0100 [thread overview]
Message-ID: <CAMj1kXG9oEbBj7pCTq+onZEqdPkx5TrUDe3fWgV-MVzFSma6Ag@mail.gmail.com> (raw)
In-Reply-To: <20240110235227.2734271-2-jeremy.linton@arm.com>
Hi Jeremy,
Thanks for the patches.
On Thu, 11 Jan 2024 at 00:52, Jeremy Linton <jeremy.linton@arm.com> wrote:
>
> The rpi's config.txt controls which uart (pl011, or miniuart) is
> selected as the console. TFA and edk2 follow its lead, but if the
> miniuart is selected as the primary and the machine is booted in ACPI
> mode the baud/etc is never configured for the pl011. The linux kernel
> won't reconfigure it either as its listed as a "SBSA" uart, so it
> simply won't work.
>
> This re-enables BT on the pl011 in ACPI mode, and it somewhat starts
> to work again.
>
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> ---
> .../DualSerialPortLib/DualSerialPortLib.c | 37 +++++++++++--------
> 1 file changed, 22 insertions(+), 15 deletions(-)
>
> diff --git a/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c b/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c
> index d2f983bf0a..79545d93d6 100644
> --- a/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c
> +++ b/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c
> @@ -76,6 +76,8 @@ SerialPortInitialize (
> EFI_PARITY_TYPE Parity;
> UINT8 DataBits;
> EFI_STOP_BITS_TYPE StopBits;
> + RETURN_STATUS Ret;
> + UINTN Timeout;
What is this for?
>
> //
> // First thing we need to do is determine which of PL011 or miniUART is selected
> @@ -85,23 +87,27 @@ SerialPortInitialize (
> UsePl011UartSet = TRUE;
> }
>
> - if (UsePl011Uart) {
> - BaudRate = FixedPcdGet64 (PcdUartDefaultBaudRate);
> + // always init the pl011 on the pi4, linux expects a SBSA uart to be at 115200
> + // this means we need to set the baud/etc even if we arn't using it as a console
> + if ((UsePl011Uart) || (RPI_MODEL == 4)) {
> ReceiveFifoDepth = 0; // Use default FIFO depth
> + BaudRate = FixedPcdGet64 (PcdUartDefaultBaudRate);
Shouldn't we hardcode 115200 here if !UsePl011Uart?
> Parity = (EFI_PARITY_TYPE)FixedPcdGet8 (PcdUartDefaultParity);
> DataBits = FixedPcdGet8 (PcdUartDefaultDataBits);
> StopBits = (EFI_STOP_BITS_TYPE) FixedPcdGet8 (PcdUartDefaultStopBits);
>
> - return PL011UartInitializePort (
> - PL011_UART_REGISTER_BASE,
> - PL011UartClockGetFreq(),
> - &BaudRate,
> - &ReceiveFifoDepth,
> - &Parity,
> - &DataBits,
> - &StopBits
> - );
> - } else {
> + Ret = PL011UartInitializePort (
> + PL011_UART_REGISTER_BASE,
> + PL011UartClockGetFreq(),
> + &BaudRate,
> + &ReceiveFifoDepth,
> + &Parity,
> + &DataBits,
> + &StopBits
> + );
> + }
> +
> + if (!UsePl011Uart) {
> SerialRegisterBase = MINI_UART_REGISTER_BASE;
> Divisor = SerialPortGetDivisor (PcdGet32 (PcdSerialBaudRate));
>
> @@ -127,7 +133,8 @@ SerialPortInitialize (
> // Wait for the serial port to be ready.
> // Verify that both the transmit FIFO and the shift register are empty.
> //
> - while ((SerialPortReadRegister (SerialRegisterBase, R_UART_LSR) & (B_UART_LSR_TEMT | B_UART_LSR_TXRDY)) != (B_UART_LSR_TEMT | B_UART_LSR_TXRDY));
> + Timeout = 1000;
> + while (((SerialPortReadRegister (SerialRegisterBase, R_UART_LSR) & (B_UART_LSR_TEMT | B_UART_LSR_TXRDY)) != (B_UART_LSR_TEMT | B_UART_LSR_TXRDY)) && (Timeout--));
>
> //
> // Configure baud rate
> @@ -158,9 +165,9 @@ SerialPortInitialize (
> // Put Modem Control Register(MCR) into its reset state of 0x00.
> //
> SerialPortWriteRegister (SerialRegisterBase, R_UART_MCR, 0x00);
> -
> - return RETURN_SUCCESS;
> + Ret = RETURN_SUCCESS;
> }
> + return Ret;
> }
>
> /**
> --
> 2.43.0
>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113589): https://edk2.groups.io/g/devel/message/113589
Mute This Topic: https://groups.io/mt/103652853/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2024-01-11 7:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-10 23:52 [edk2-devel] [PATCH 0/5] Platform/RaspberryPi: Various minor fixes Jeremy Linton
2024-01-10 23:52 ` [edk2-devel] [PATCH 1/5] Platform/RaspberryPi/DualSerialPortLib: Always configure the pl011 Jeremy Linton
2024-01-11 7:46 ` Ard Biesheuvel [this message]
2024-01-11 15:02 ` Jeremy Linton
2024-01-10 23:52 ` [edk2-devel] [PATCH 2/5] Silicon/Broadcom/BcmGenetDxe: Suppress some bogus compiler warnings Jeremy Linton
2024-01-10 23:52 ` [edk2-devel] [PATCH 3/5] Platform/RaspberryPi: Cleanup menu visibility Jeremy Linton
2024-01-10 23:52 ` [edk2-devel] [PATCH 4/5] Platform/RaspberryPi: Give the user control over the XHCI mailbox Jeremy Linton
2024-01-11 7:48 ` Ard Biesheuvel
2024-01-10 23:52 ` [edk2-devel] [PATCH 5/5] Platform/RaspberryPi: Update PCIe MMIO window for DT Jeremy Linton
2024-01-11 7:49 ` Ard Biesheuvel
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=CAMj1kXG9oEbBj7pCTq+onZEqdPkx5TrUDe3fWgV-MVzFSma6Ag@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