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 632E3740035 for ; Mon, 11 Mar 2024 14:14:01 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=BOLIZKTxs6Ef00XJyWrfSr+WE0jUFlfMvEE3pAoQIvE=; 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=20240206; t=1710166440; v=1; b=snU4c0wIGSGxZunluTYIzxcMiaRCC78VI4kJSXUipOEZhJiOvA+AIjvbRgKsnvqnh38dDfjP /7UfqzbdJyaUJbJUPlYZivKsdDY0DvjBaDGyO7JAD1zjDA7uipahrsIkn8Z0kJsHr8oHw5xDmQX ob55bqHI4nPMV0YwGGzVIHVQZfiT/ojtQ6IgRvaEf3/p7MJ8VBypHvubkSpDVZ6mIrxjv/YmCIk 0pRQTaR5ph9TeZAG4EL20+pR1k1vLc1RbtQBmkLs9qrXE+9p7nMnuf0/pMWXNJMkZ/mRBzkZXuW F2lxHJwha7oUlIonBar/pMCVjEBV/lwq6ImIJxjwe5fXw== X-Received: by 127.0.0.2 with SMTP id YqT8YY7687511xKd55Pdd5hG; Mon, 11 Mar 2024 07:14:00 -0700 X-Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by mx.groups.io with SMTP id smtpd.web11.63946.1710166438735055854 for ; Mon, 11 Mar 2024 07:13:59 -0700 X-Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B9B6ECE0503 for ; Mon, 11 Mar 2024 14:13:54 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECD2BC433C7 for ; Mon, 11 Mar 2024 14:13:53 +0000 (UTC) X-Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-5139d80f8b6so2082971e87.1 for ; Mon, 11 Mar 2024 07:13:53 -0700 (PDT) X-Gm-Message-State: PjE1Tk0Y4Y38X13tWQQujik8x7686176AA= X-Google-Smtp-Source: AGHT+IE5XYs2frjHsdfCT7sv7ARhMHmsX8dNDlAtirFc2NZNa+pxLEId8+v0977+F81S2szYebl3RcZpYFWWHfvTjqU= X-Received: by 2002:a05:6512:234b:b0:513:a0a3:c543 with SMTP id p11-20020a056512234b00b00513a0a3c543mr5816720lfu.54.1710166432120; Mon, 11 Mar 2024 07:13:52 -0700 (PDT) MIME-Version: 1.0 References: <20240117213614.4188518-1-jeremy.linton@arm.com> <20240117213614.4188518-2-jeremy.linton@arm.com> In-Reply-To: <20240117213614.4188518-2-jeremy.linton@arm.com> From: "Ard Biesheuvel" Date: Mon, 11 Mar 2024 07:13:59 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [PATCH v2 1/5] Platform/RaspberryPi/DualSerialPortLib: Always configure the pl011 To: Jeremy Linton Cc: devel@edk2.groups.io, 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=20240206 header.b=snU4c0wI; 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 On Wed, 17 Jan 2024 at 22:36, 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 | 44 ++++++++++++------- > 1 file changed, 29 insertions(+), 15 deletions(-) > > diff --git a/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c b/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c > index d2f983bf0a..09d3e33c00 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; > > // > // First thing we need to do is determine which of PL011 or miniUART is selected > @@ -85,23 +87,34 @@ SerialPortInitialize ( > UsePl011UartSet = TRUE; > } > > - if (UsePl011Uart) { > - BaudRate = FixedPcdGet64 (PcdUartDefaultBaudRate); > + // always init the pl011 on the RPi4, linux expects a SBSA uart to be at 115200 > + // this means we need to set the baud/etc even if we aren't using it as a console > + if ((UsePl011Uart) || (RPI_MODEL == 4)) { > ReceiveFifoDepth = 0; // Use default FIFO depth > + if (!UsePl011Uart) > + { > + BaudRate = 115200; > + } > + else > + { > + BaudRate = FixedPcdGet64 (PcdUartDefaultBaudRate); > + } > 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 +140,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--)); > Why is this necessary, and what does it have to do with the rest of the patch? > // > // Configure baud rate > @@ -158,9 +172,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 (#116630): https://edk2.groups.io/g/devel/message/116630 Mute This Topic: https://groups.io/mt/103796307/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-