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 9CDC5941C69 for ; Wed, 17 Jan 2024 21:36:20 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=x8SKCj1MAPxraUju/hREt04AvnU7v7tV9qRAvr3MHI8=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1705527379; v=1; b=AXt+qW9TzsU85XcYDOexbqYt97Q/BbP3KaVSAgW25R4TyaDWhy3Lzbq7d+ARnXZ/n7+Nt/g7 Wb8F4Os5rRXa7EkmfJwoPm9uMyPZcxg0ndUVA6EBU6z2bmVIQMSEWBGT50crR7ABd2t+z1Tnu5a wWGZyKuhvpX/uhCHlwryJOJ8= X-Received: by 127.0.0.2 with SMTP id C4FEYY7687511x2ceol2YfCk; Wed, 17 Jan 2024 13:36:19 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.650.1705527378691614911 for ; Wed, 17 Jan 2024 13:36:18 -0800 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 54C58152B; Wed, 17 Jan 2024 13:37:04 -0800 (PST) X-Received: from u200865.usa.arm.com (unknown [10.119.39.253]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 21FBF3F73F; Wed, 17 Jan 2024 13:36:18 -0800 (PST) From: "Jeremy Linton" To: devel@edk2.groups.io Cc: ardb+tianocore@kernel.org, quic_llindhol@quicinc.com, Jeremy Linton Subject: [edk2-devel] [PATCH v2 1/5] Platform/RaspberryPi/DualSerialPortLib: Always configure the pl011 Date: Wed, 17 Jan 2024 15:36:10 -0600 Message-ID: <20240117213614.4188518-2-jeremy.linton@arm.com> In-Reply-To: <20240117213614.4188518-1-jeremy.linton@arm.com> References: <20240117213614.4188518-1-jeremy.linton@arm.com> MIME-Version: 1.0 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,jeremy.linton@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: Vws7jBdfdPkjzniE8OhVmM9Ix7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=AXt+qW9T; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (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 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/DualSerialPor= tLib.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; =20 // // First thing we need to do is determine which of PL011 or miniUART i= s selected @@ -85,23 +87,34 @@ SerialPortInitialize ( UsePl011UartSet =3D TRUE; } =20 - if (UsePl011Uart) { - BaudRate =3D 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 a= s a console + if ((UsePl011Uart) || (RPI_MODEL =3D=3D 4)) { ReceiveFifoDepth =3D 0; // Use default FIFO depth + if (!UsePl011Uart) + { + BaudRate =3D 115200; + } + else + { + BaudRate =3D FixedPcdGet64 (PcdUartDefaultBaudRate); + } Parity =3D (EFI_PARITY_TYPE)FixedPcdGet8 (PcdUartDefaultParity); DataBits =3D FixedPcdGet8 (PcdUartDefaultDataBits); StopBits =3D (EFI_STOP_BITS_TYPE) FixedPcdGet8 (PcdUartDefaultStopBi= ts); =20 - return PL011UartInitializePort ( - PL011_UART_REGISTER_BASE, - PL011UartClockGetFreq(), - &BaudRate, - &ReceiveFifoDepth, - &Parity, - &DataBits, - &StopBits - ); - } else { + Ret =3D PL011UartInitializePort ( + PL011_UART_REGISTER_BASE, + PL011UartClockGetFreq(), + &BaudRate, + &ReceiveFifoDepth, + &Parity, + &DataBits, + &StopBits + ); + } + + if (!UsePl011Uart) { SerialRegisterBase =3D MINI_UART_REGISTER_BASE; Divisor =3D SerialPortGetDivisor (PcdGet32 (PcdSerialBaudRate)); =20 @@ -127,7 +140,8 @@ SerialPortInitialize ( // Wait for the serial port to be ready. // Verify that both the transmit FIFO and the shift register are emp= ty. // - while ((SerialPortReadRegister (SerialRegisterBase, R_UART_LSR) & (B= _UART_LSR_TEMT | B_UART_LSR_TXRDY)) !=3D (B_UART_LSR_TEMT | B_UART_LSR_TX= RDY)); + Timeout =3D 1000; + while (((SerialPortReadRegister (SerialRegisterBase, R_UART_LSR) & (= B_UART_LSR_TEMT | B_UART_LSR_TXRDY)) !=3D (B_UART_LSR_TEMT | B_UART_LSR_T= XRDY)) && (Timeout--)); =20 // // 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 =3D RETURN_SUCCESS; } + return Ret; } =20 /** --=20 2.43.0 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113961): https://edk2.groups.io/g/devel/message/113961 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] -=-=-=-=-=-=-=-=-=-=-=-