Re: [edk2-devel] [PATCH] Platform/RaspberryPi: Dynamically build UARTs info in ACPI
> > +=0D > + PinFunction (Exclusive, PullDown, BCM_ALT3, "\\_SB.GDV0.GPI0", 0, Reso= > urceConsumer, , ) { 32, 33 }=0D > +=0D > + // fake the CTS signal as we don't support HW flow control yet=0D > + // BCM_ALT2 is set as output (low) by default=0D > + PinFunction (Exclusive, PullNone, BCM_ALT2, "\\_SB.GDV0.GPI0", 0, Reso= > urceConsumer, , ) { 31 }=0D > })=0D > I think it's better to do the pin muxing in ConfigDxe, depending on which UART is free to be used for Bluetooth. -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#72679): https://edk2.groups.io/g/devel/message/72679 Mute This Topic: https://groups.io/mt/81178450/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH] Platform/RaspberryPi: Dynamically build UARTs info in ACPI
Thanks for the review and good comments, Pete. Since I'm busy with other things, I will work on your comments next week or later. Regards, Sunny On Tue, Mar 9, 2021 at 12:58 AM Pete Batard wrote: > Hi Sunny, > > Thanks a lot for submitting this patch! > > This is something that has been on the Raspberry Pi platform TODO list > for some time, so your contribution is much appreciated. > > Please find 4 comments inline: > > On 2021.03.06 09:24, Sunny Hsuan-Wen Wang wrote: > > Changes: > > > >1. Add code to ConfigDxe driver and AcpiTables module to dynamically > > > > build either Mini UART or PL011 UART info in ACPI. This fixes the > > > > issue discussed in https://github.com/pftf/RPi4/issues/118. > > > >2. Merge changes in edk2-platforms-raspberrypi-pl011-bth-noflow.diff > > > > in https://github.com/worproject/RPi-Bluetooth-Testing/ > > > > for enabling Bluetooth and serial port (Mini UART) in Windows OS. > > > >3. Cleanup by moving duplicate Debug Port 2 table related defines and > > > > structures to a newly created header file (RpiDebugPort2Table.h). > > Ideally, I would prefer if 1-3 and 2 were submitted as separate patches > in a series, as one can consider that the ACPI assigning of the > Spcr/Dbg2 tables is independent of the Bluetooth related changes. > > For instance, regardless of Bluetooth usage, one of course wants the > serial ports used by Windows to match the ones defined in config.txt. So > I would say that we have at least two separate functional changes in > this patch, that should probably be made more explicit by splitting them > into separare commits. > > > Testing Done: > > > >- Booted to UEFI shell and use acpiview command to check the result of > > > > the different UART settings in config.txt (enabling either Mini UART > > > > or PL011) and SPCR, DBG2 tables and device BTH0 are dynamically > > > > changed as expected. > > > >- Successfully booted Windows 10 (20279.1) on SD (made by WOR) with > > > > the RPi-Windows-Drivers release ver 0.5 downloaded from > > > > https://github.com/worproject/RPi-Windows-Drivers/releases > > > > and checked that both Bluetooth and serial port (Mini UART) can > > > > work fine. > > > > > > > > Cc: Samer El-Haj-Mahmoud > > > > Cc: Pete Batard > > > > Cc: Ard Biesheuvel > > > > Cc: Leif Lindholm > > > > Signed-off-by: Sunny Hsuan-Wen Wang > > > > --- > > > > .../RaspberryPi/AcpiTables/AcpiTables.inf | 7 +- > > > > .../RaspberryPi/AcpiTables/Dbg2MiniUart.aslc | 82 > > > > .../AcpiTables/{Dbg2.aslc => Dbg2Pl011.aslc} | 187 - > > > > .../RaspberryPi/AcpiTables/SpcrMiniUart.aslc | 92 + > > > > .../AcpiTables/{Spcr.aslc => SpcrPl011.aslc} | 189 +- > > > > Platform/RaspberryPi/AcpiTables/Uart.asl | 18 +- > > > > .../RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 123 +++- > > > > .../IndustryStandard/RpiDebugPort2Table.h | 33 +++ > > > > 8 files changed, 516 insertions(+), 215 deletions(-) > > > > create mode 100644 Platform/RaspberryPi/AcpiTables/Dbg2MiniUart.aslc > > > > rename Platform/RaspberryPi/AcpiTables/{Dbg2.aslc => Dbg2Pl011.aslc} > (73%) > > > > create mode 100644 Platform/RaspberryPi/AcpiTables/SpcrMiniUart.aslc > > > > rename Platform/RaspberryPi/AcpiTables/{Spcr.aslc => SpcrPl011.aslc} > (88%) > > > > create mode 100644 > Platform/RaspberryPi/Include/IndustryStandard/RpiDebugPort2Table.h > > > > > > > > diff --git a/Platform/RaspberryPi/AcpiTables/AcpiTables.inf > b/Platform/RaspberryPi/AcpiTables/AcpiTables.inf > > > > index d2cce074e5..6c08cacbb3 100644 > > > > --- a/Platform/RaspberryPi/AcpiTables/AcpiTables.inf > > > > +++ b/Platform/RaspberryPi/AcpiTables/AcpiTables.inf > > > > @@ -2,6 +2,7 @@ > > > > # > > > > # ACPI table data and ASL sources required to boot the platform. > > > > # > > > > +# Copyright (c) 2021, Sunny Hsuan-Wen Wang < > sunny.hsuanwen.w...@gmail.com> > > > > # Copyright (c) 2019, ARM Limited. All rights reserved. > > > > # Copyright (c) 2017, Andrey Warkentin > > > > # Copyright (c) Microsoft Corporation. All rights reserved. > > > > @@ -27,12 +28,14 @@ > > > > AcpiTables.h > > > > Madt.aslc > > > > Fadt.aslc > > > > - Dbg2.aslc > > > > + Dbg2MiniUart.aslc > > > > + Dbg2Pl011.aslc > > > > Gtdt.aslc > > > > Iort.aslc > > > > Dsdt.asl > > > > Csrt.aslc > > > > - Spcr.aslc > > > > + SpcrMiniUart.aslc > > > > + SpcrPl011.aslc > > > > Pptt.aslc > > > > SsdtThermal.asl > > > > > > > > diff --git a/Platform/RaspberryPi/AcpiTables/Dbg2MiniUart.aslc > b/Platform/RaspberryPi/AcpiTables/Dbg2MiniUart.aslc > > > > new file mode 100644 > > > > index 00..eec4ba1562 > > > > --- /dev/null > > > > +++ b/Platform/RaspberryPi/AcpiTables/Dbg2MiniUart.aslc > > > > @@ -0,0 +1,82 @@ > > > > +/** @file > > > > + * > > > > + * Debug Port Table (DBG2) > > > > + * > > > > + *
Re: [edk2-devel] [PATCH] Platform/RaspberryPi: Dynamically build UARTs info in ACPI
Hi Sunny, Thanks a lot for submitting this patch! This is something that has been on the Raspberry Pi platform TODO list for some time, so your contribution is much appreciated. Please find 4 comments inline: On 2021.03.06 09:24, Sunny Hsuan-Wen Wang wrote: Changes: 1. Add code to ConfigDxe driver and AcpiTables module to dynamically build either Mini UART or PL011 UART info in ACPI. This fixes the issue discussed in https://github.com/pftf/RPi4/issues/118. 2. Merge changes in edk2-platforms-raspberrypi-pl011-bth-noflow.diff in https://github.com/worproject/RPi-Bluetooth-Testing/ for enabling Bluetooth and serial port (Mini UART) in Windows OS. 3. Cleanup by moving duplicate Debug Port 2 table related defines and structures to a newly created header file (RpiDebugPort2Table.h). Ideally, I would prefer if 1-3 and 2 were submitted as separate patches in a series, as one can consider that the ACPI assigning of the Spcr/Dbg2 tables is independent of the Bluetooth related changes. For instance, regardless of Bluetooth usage, one of course wants the serial ports used by Windows to match the ones defined in config.txt. So I would say that we have at least two separate functional changes in this patch, that should probably be made more explicit by splitting them into separare commits. Testing Done: - Booted to UEFI shell and use acpiview command to check the result of the different UART settings in config.txt (enabling either Mini UART or PL011) and SPCR, DBG2 tables and device BTH0 are dynamically changed as expected. - Successfully booted Windows 10 (20279.1) on SD (made by WOR) with the RPi-Windows-Drivers release ver 0.5 downloaded from https://github.com/worproject/RPi-Windows-Drivers/releases and checked that both Bluetooth and serial port (Mini UART) can work fine. Cc: Samer El-Haj-Mahmoud Cc: Pete Batard Cc: Ard Biesheuvel Cc: Leif Lindholm Signed-off-by: Sunny Hsuan-Wen Wang --- .../RaspberryPi/AcpiTables/AcpiTables.inf | 7 +- .../RaspberryPi/AcpiTables/Dbg2MiniUart.aslc | 82 .../AcpiTables/{Dbg2.aslc => Dbg2Pl011.aslc} | 187 - .../RaspberryPi/AcpiTables/SpcrMiniUart.aslc | 92 + .../AcpiTables/{Spcr.aslc => SpcrPl011.aslc} | 189 +- Platform/RaspberryPi/AcpiTables/Uart.asl | 18 +- .../RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 123 +++- .../IndustryStandard/RpiDebugPort2Table.h | 33 +++ 8 files changed, 516 insertions(+), 215 deletions(-) create mode 100644 Platform/RaspberryPi/AcpiTables/Dbg2MiniUart.aslc rename Platform/RaspberryPi/AcpiTables/{Dbg2.aslc => Dbg2Pl011.aslc} (73%) create mode 100644 Platform/RaspberryPi/AcpiTables/SpcrMiniUart.aslc rename Platform/RaspberryPi/AcpiTables/{Spcr.aslc => SpcrPl011.aslc} (88%) create mode 100644 Platform/RaspberryPi/Include/IndustryStandard/RpiDebugPort2Table.h diff --git a/Platform/RaspberryPi/AcpiTables/AcpiTables.inf b/Platform/RaspberryPi/AcpiTables/AcpiTables.inf index d2cce074e5..6c08cacbb3 100644 --- a/Platform/RaspberryPi/AcpiTables/AcpiTables.inf +++ b/Platform/RaspberryPi/AcpiTables/AcpiTables.inf @@ -2,6 +2,7 @@ # # ACPI table data and ASL sources required to boot the platform. # +# Copyright (c) 2021, Sunny Hsuan-Wen Wang # Copyright (c) 2019, ARM Limited. All rights reserved. # Copyright (c) 2017, Andrey Warkentin # Copyright (c) Microsoft Corporation. All rights reserved. @@ -27,12 +28,14 @@ AcpiTables.h Madt.aslc Fadt.aslc - Dbg2.aslc + Dbg2MiniUart.aslc + Dbg2Pl011.aslc Gtdt.aslc Iort.aslc Dsdt.asl Csrt.aslc - Spcr.aslc + SpcrMiniUart.aslc + SpcrPl011.aslc Pptt.aslc SsdtThermal.asl diff --git a/Platform/RaspberryPi/AcpiTables/Dbg2MiniUart.aslc b/Platform/RaspberryPi/AcpiTables/Dbg2MiniUart.aslc new file mode 100644 index 00..eec4ba1562 --- /dev/null +++ b/Platform/RaspberryPi/AcpiTables/Dbg2MiniUart.aslc @@ -0,0 +1,82 @@ +/** @file + * + * Debug Port Table (DBG2) + * + * Copyright (c) 2021, Sunny Hsuan-Wen Wang + * Copyright (c) 2019, Pete Batard + * Copyright (c) 2012-2020, ARM Limited. All rights reserved. + * + * SPDX-License-Identifier: BSD-2-Clause-Patent + * + **/ + +#include +#include +#include +#include +#include + +#include "AcpiTables.h" + +#pragma pack(1) + +#define RPI_UART_INTERFACE_TYPE EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_BCM2835_UART +#define RPI_UART_BASE_ADDRESS BCM2836_MINI_UART_BASE_ADDRESS +#define RPI_UART_LENGTH BCM2836_MINI_UART_LENGTH +// +// RPI_UART_STR should match the value used Uart.asl +// +#define RPI_UART_STR{ '\\', '_', 'S', 'B', '.', 'G', 'D', 'V', '0', '.', 'U', 'R', 'T', 'M', 0x00 } + +#define
[edk2-devel] [PATCH] Platform/RaspberryPi: Dynamically build UARTs info in ACPI
Changes: 1. Add code to ConfigDxe driver and AcpiTables module to dynamically build either Mini UART or PL011 UART info in ACPI. This fixes the issue discussed in https://github.com/pftf/RPi4/issues/118. 2. Merge changes in edk2-platforms-raspberrypi-pl011-bth-noflow.diff in https://github.com/worproject/RPi-Bluetooth-Testing/ for enabling Bluetooth and serial port (Mini UART) in Windows OS. 3. Cleanup by moving duplicate Debug Port 2 table related defines and structures to a newly created header file (RpiDebugPort2Table.h). Testing Done: - Booted to UEFI shell and use acpiview command to check the result of the different UART settings in config.txt (enabling either Mini UART or PL011) and SPCR, DBG2 tables and device BTH0 are dynamically changed as expected. - Successfully booted Windows 10 (20279.1) on SD (made by WOR) with the RPi-Windows-Drivers release ver 0.5 downloaded from https://github.com/worproject/RPi-Windows-Drivers/releases and checked that both Bluetooth and serial port (Mini UART) can work fine. Cc: Samer El-Haj-Mahmoud Cc: Pete Batard Cc: Ard Biesheuvel Cc: Leif Lindholm Signed-off-by: Sunny Hsuan-Wen Wang --- .../RaspberryPi/AcpiTables/AcpiTables.inf | 7 +- .../RaspberryPi/AcpiTables/Dbg2MiniUart.aslc | 82 .../AcpiTables/{Dbg2.aslc => Dbg2Pl011.aslc} | 187 - .../RaspberryPi/AcpiTables/SpcrMiniUart.aslc | 92 + .../AcpiTables/{Spcr.aslc => SpcrPl011.aslc} | 189 +- Platform/RaspberryPi/AcpiTables/Uart.asl | 18 +- .../RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 123 +++- .../IndustryStandard/RpiDebugPort2Table.h | 33 +++ 8 files changed, 516 insertions(+), 215 deletions(-) create mode 100644 Platform/RaspberryPi/AcpiTables/Dbg2MiniUart.aslc rename Platform/RaspberryPi/AcpiTables/{Dbg2.aslc => Dbg2Pl011.aslc} (73%) create mode 100644 Platform/RaspberryPi/AcpiTables/SpcrMiniUart.aslc rename Platform/RaspberryPi/AcpiTables/{Spcr.aslc => SpcrPl011.aslc} (88%) create mode 100644 Platform/RaspberryPi/Include/IndustryStandard/RpiDebugPort2Table.h diff --git a/Platform/RaspberryPi/AcpiTables/AcpiTables.inf b/Platform/RaspberryPi/AcpiTables/AcpiTables.inf index d2cce074e5..6c08cacbb3 100644 --- a/Platform/RaspberryPi/AcpiTables/AcpiTables.inf +++ b/Platform/RaspberryPi/AcpiTables/AcpiTables.inf @@ -2,6 +2,7 @@ # # ACPI table data and ASL sources required to boot the platform. # +# Copyright (c) 2021, Sunny Hsuan-Wen Wang # Copyright (c) 2019, ARM Limited. All rights reserved. # Copyright (c) 2017, Andrey Warkentin # Copyright (c) Microsoft Corporation. All rights reserved. @@ -27,12 +28,14 @@ AcpiTables.h Madt.aslc Fadt.aslc - Dbg2.aslc + Dbg2MiniUart.aslc + Dbg2Pl011.aslc Gtdt.aslc Iort.aslc Dsdt.asl Csrt.aslc - Spcr.aslc + SpcrMiniUart.aslc + SpcrPl011.aslc Pptt.aslc SsdtThermal.asl diff --git a/Platform/RaspberryPi/AcpiTables/Dbg2MiniUart.aslc b/Platform/RaspberryPi/AcpiTables/Dbg2MiniUart.aslc new file mode 100644 index 00..eec4ba1562 --- /dev/null +++ b/Platform/RaspberryPi/AcpiTables/Dbg2MiniUart.aslc @@ -0,0 +1,82 @@ +/** @file + * + * Debug Port Table (DBG2) + * + * Copyright (c) 2021, Sunny Hsuan-Wen Wang + * Copyright (c) 2019, Pete Batard + * Copyright (c) 2012-2020, ARM Limited. All rights reserved. + * + * SPDX-License-Identifier: BSD-2-Clause-Patent + * + **/ + +#include +#include +#include +#include +#include + +#include "AcpiTables.h" + +#pragma pack(1) + +#define RPI_UART_INTERFACE_TYPE EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_BCM2835_UART +#define RPI_UART_BASE_ADDRESS BCM2836_MINI_UART_BASE_ADDRESS +#define RPI_UART_LENGTH BCM2836_MINI_UART_LENGTH +// +// RPI_UART_STR should match the value used Uart.asl +// +#define RPI_UART_STR{ '\\', '_', 'S', 'B', '.', 'G', 'D', 'V', '0', '.', 'U', 'R', 'T', 'M', 0x00 } + +#define DBG2_DEBUG_PORT_DDI(NumReg, SubType, UartBase, UartAddrLen, UartNameStr) {\ +{ \ + EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION, /* UINT8 Revision */\ + sizeof (DBG2_DEBUG_DEVICE_INFORMATION), /* UINT16Length */ \ + NumReg, /* UINT8 NumberofGenericAddressRegisters */ \ + RPI_DBG2_NAMESPACESTRING_FIELD_SIZE,/* UINT16NameSpaceStringLength */ \ + OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, NameSpaceString), /* UINT16NameSpaceStringOffset */ \ + 0, /* UINT16