From nobody Mon Sep 16 20:28:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+113961+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+113961+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1705527379; cv=none; d=zohomail.com; s=zohoarc; b=C0Gco049leVZdGNx9XwgQvRlTCRgvr+1v5T8Tl563v4R4d/+SuXIgxVcDpAv0WaJZBe3ifUC5kKToq84AngGia+QE4j7PE6U2U1ycYvVWyBXQPEiDvOqut0fmvAkTmeC6bVCAW5t8os77SOKUvc9/B6igNsdj3TKuFXShhnITcM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705527379; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=xXsa7NX8ZLRm8p4E89SEFl1MMzRR3V78OocIjBH6uHU=; b=LMgvCgITjjL0gWmxtQdnhAW43EFLa4KpOGlfAgCkS+oVPQcECT3YuFNnsSmY7JEd/OlyNI+9B1satB5YX0iQKJA408dE8nOlFcaggCczsSmBMhl8TrWpgv7jA3c/CGHWTGt5hf5LNuiYtNaae8YaOOU3N2F435mj9c1EVIzktxU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+113961+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1705527379929578.9620127145768; Wed, 17 Jan 2024 13:36:19 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=8yaaqHpf9Lz26zH2UMzKAHdXoJ7tN/JYkHC3ZYm7ddE=; 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=i8XTLCbsH79Vm39zEzE3Rz4S+NXGYdDwX55OMHYUeDLC2l+CZTJnD9LiqqNl3Psr8djqsujx 0mGsY+fQD1Z4qa17inIjyPWFwPegC/8aTGu8aolIjY9rzhk2t5eBx2BBPKVvZ/x3RBwSdbf7D8l bC8ox8/kqqhPjhfv77xVKkC4= X-Received: by 127.0.0.2 with SMTP id IKmBYY1788612x0t7XLh0TY1; 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: 5QPUcxRpPOzeD38JWbOuc0Nax1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1705527380671100002 Content-Type: text/plain; charset="utf-8" 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/DualSerialPortL= ib.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 is = 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 as = 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 (PcdUartDefaultStopBits= ); =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 empty. // - while ((SerialPortReadRegister (SerialRegisterBase, R_UART_LSR) & (B_U= ART_LSR_TEMT | B_UART_LSR_TXRDY)) !=3D (B_UART_LSR_TEMT | B_UART_LSR_TXRDY)= ); + 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_TXRDY= )) && (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 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- 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/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-