From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 8AB4C7803E0 for ; Thu, 11 Jan 2024 07:46:38 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=y4tZ+ho6mkqbd8pyCBm+8uZwkQZFm/xrl5307e5qnSc=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20140610; t=1704959197; v=1; b=eu9z19IEDdwvfw4tYej0kposJXGWY6ZFaqn5kPuglrDVx2zoWSG+mt9Lo5xG1NK2nk9nc4Op T2Ipnz3+BqDziiU/iicY6dJvwHs+AhwA0bRxLOQ6TBam3BAElx/4jiEoFimEfF59r2s6/XbKQqf 5L8K9WO0RBaya0mCW0qVtrNo= X-Received: by 127.0.0.2 with SMTP id mSi6YY7687511xLRAgbTicZT; Wed, 10 Jan 2024 23:46:37 -0800 X-Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web11.6836.1704959196415420919 for ; Wed, 10 Jan 2024 23:46:36 -0800 X-Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id C6E5F6199F for ; Thu, 11 Jan 2024 07:46:35 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9676EC433F1 for ; Thu, 11 Jan 2024 07:46:35 +0000 (UTC) X-Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2cd0f4f306fso59532801fa.0 for ; Wed, 10 Jan 2024 23:46:35 -0800 (PST) X-Gm-Message-State: inqDWjidqjAo6QlBeQh7koKjx7686176AA= X-Google-Smtp-Source: AGHT+IHNizAib35G7Mu6cDkHvsgSty+vpA1ffpwwiqvbbZeskPh7Lz0zjV0VVmqHSrXheaYEolnUWyENMR7dlivSGYg= X-Received: by 2002:a2e:900d:0:b0:2cc:a5ae:f122 with SMTP id h13-20020a2e900d000000b002cca5aef122mr109548ljg.78.1704959193782; Wed, 10 Jan 2024 23:46:33 -0800 (PST) MIME-Version: 1.0 References: <20240110235227.2734271-1-jeremy.linton@arm.com> <20240110235227.2734271-2-jeremy.linton@arm.com> In-Reply-To: <20240110235227.2734271-2-jeremy.linton@arm.com> From: "Ard Biesheuvel" Date: Thu, 11 Jan 2024 08:46:22 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [PATCH 1/5] Platform/RaspberryPi/DualSerialPortLib: Always configure the pl011 To: Jeremy Linton Cc: devel@edk2.groups.io, ardb+tianocore@kernel.org, quic_llindhol@quicinc.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ardb@kernel.org List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: text/plain; charset="UTF-8" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=eu9z19IE; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Hi Jeremy, Thanks for the patches. On Thu, 11 Jan 2024 at 00:52, Jeremy Linton 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 > --- > .../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] -=-=-=-=-=-=-=-=-=-=-=-