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 7244F940F6F for ; Wed, 13 Mar 2024 02:06:12 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=KYh5tbGZmhJxia/71fFNde9O88ki/qd6yk1rgwrtBjU=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20240206; t=1710295571; v=1; b=psHeNgBnl/2XsVw6y1j6ie9y5q5y+AZTcC31ituxTpUWvK56HKkQQUZU8bb6/1zKYvvrjDxx m4HMR/qrpPTV47YMeL0cybTJqitEHslxnJYmhmcK/JHSsKqiA5TIlrWa4v/aUoycBxBjQUO1cuG 5iZTis4sqSMliNB3QWTVilenRqjIw5FNe5+eilvo3OyyCt1jnByAocLC9ZNBVVegPnHfEZmGMks ZJ7e3/ExFSRSAuoalxHigYzIK92z+Wej1ojO+zze6MCfUfRa4myrtFRlbVnm6NHK6qEkjyX58Qk 0Uk/xp6Fi1OmYPFv1XsXJQf3vOoWM+DwsVPu058tLCGUQ== X-Received: by 127.0.0.2 with SMTP id WphvYY7687511xQdssAIxXEY; Tue, 12 Mar 2024 19:06:11 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.6962.1710295570336351959 for ; Tue, 12 Mar 2024 19:06:10 -0700 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 E1FC21007; Tue, 12 Mar 2024 19:06:46 -0700 (PDT) X-Received: from [192.168.20.50] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B59113F73F; Tue, 12 Mar 2024 19:06:08 -0700 (PDT) Message-ID: <1c379b50-5994-4d14-ba63-6e424acee9a4@arm.com> Date: Tue, 12 Mar 2024 21:06:07 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [PATCH v2 1/5] Platform/RaspberryPi/DualSerialPortLib: Always configure the pl011 To: devel@edk2.groups.io, ardb@kernel.org Cc: quic_llindhol@quicinc.com References: <20240117213614.4188518-1-jeremy.linton@arm.com> <20240117213614.4188518-2-jeremy.linton@arm.com> From: "Jeremy Linton" In-Reply-To: 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 Resent-Date: Tue, 12 Mar 2024 19:06:10 -0700 Reply-To: devel@edk2.groups.io,jeremy.linton@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: fMb4D1KSmkQXHhiFCNDLy85fx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=psHeNgBn; 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 Hi, On 3/11/24 09:13, Ard Biesheuvel via groups.io wrote: > 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/DualSerialPo= rtLib.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 =3D TRUE; >> } >> >> - 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 (PcdUartDefaultStop= Bits); >> >> - 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)); >> >> @@ -127,7 +140,8 @@ SerialPortInitialize ( >> // Wait for the serial port to be ready. >> // Verify that both the transmit FIFO and the shift register are e= mpty. >> // >> - while ((SerialPortReadRegister (SerialRegisterBase, R_UART_LSR) & (= B_UART_LSR_TEMT | B_UART_LSR_TXRDY)) !=3D (B_UART_LSR_TEMT | B_UART_LSR_TXR= DY)); >> + 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_TX= RDY)) && (Timeout--)); >> >=20 > Why is this necessary, and what does it have to do with the rest of the p= atch? I think last time I noted that it side steps a problem when both of the=20 uarts are being unilaterally configured but the clock wasn't because the=20 default selected in the config.txt was the pl011 (IIRC). But it=20 shouldn't be hit by default unless the config.txt and edk2 configs is=20 differing. I will drop or move it, if that is whats holding up this set. >=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; >> } >> >> /** >> -- >> 2.43.0 >> >=20 >=20 >=20 >=20 >=20 -=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 (#116702): https://edk2.groups.io/g/devel/message/116702 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] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-