From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by mx.groups.io with SMTP id smtpd.web09.46544.1622478956674933204 for ; Mon, 31 May 2021 09:35:57 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tKi5IKQH; spf=pass (domain: gmail.com, ip: 209.85.221.42, mailfrom: mariobalanica02@gmail.com) Received: by mail-wr1-f42.google.com with SMTP id j14so11485835wrq.5 for ; Mon, 31 May 2021 09:35:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XPrmjZmvui/MBHx7uO+jp8+nS/X4F8tQgWTGi/ZabMo=; b=tKi5IKQH6lhNE8f5QK5lT4ND0JjVJCV6YgxoGqFsx/G1mL9XT1Wlz9bDy6myUAqb9c 12RxNepdjGMGrQoqxaeITca57rP9+xRrzbX3KiOyrYiPj17NNUQCQgLSMozFZBiMfSZB 38d9MtiAIJECgNf3l2lfZxwLGdyyadDfW/xw77PUAQwLpsO5oU1dyBscPaLZYSllNRLA OWg/QHjtufAyJ7m2jpEef4vKWyNtfm6Wqukl12qZvoiWd189CiH7ncBFrXGdV3ee7kih lSMGEsJ0PT+7DZfHK34hJ5O0Z5JXuL8P/wRd635eBeA1Qj9BOmuROHgDJjkQZhjyny4k OdNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=XPrmjZmvui/MBHx7uO+jp8+nS/X4F8tQgWTGi/ZabMo=; b=L+pwBfqofKyHNiBv44FsQwVSaJDZh7xE2Wjk0tTv9R17ZBgNIaTnAtMtI72waRCgRh WwNiGPLqFgYLIKf3O4LPjwN6N4nExbYvVzyKZGxVPL9PA8xtcuYbk466Pd4ujN1j8ds6 r62pIahfZ8DYuQOggzbhWF4JZ4qjTWCb9obgj+5nXYaVUJe+jDst9YU5MfV8GLmewef1 c7sBu6FRhxMyrhWLCnqOnEAVEN8nkWhRBi4CbH4koETv02uKulruobVAW+fl8yvPn4Q5 hbOz/RvPP+7riS5J4iqDGBOnBbP5mZKwuQuMpuz9fBfUqduB7j7wja0tdTe0Xe8SDb12 MMlw== X-Gm-Message-State: AOAM5303VCqp8/yNwd8m8DhONBr1i57yExHX03+tte47cd9eNv6VA1Fc gKonMjhL3d0mvwU5BEireeEt6/N0ETLUnFMamS0= X-Google-Smtp-Source: ABdhPJzoJPtE/LeLOEFv4zjRLn7jKUdquDi4Jg0oFyIIeJj5yUx4Gd/YLZ+Sz4EobKtEbspuDALTG+k7Y+PouOAD4u0= X-Received: by 2002:a5d:4890:: with SMTP id g16mr23207333wrq.353.1622478955137; Mon, 31 May 2021 09:35:55 -0700 (PDT) MIME-Version: 1.0 References: <20210531082239.918-1-Sunny.Wang@arm.com> <20210531082239.918-3-Sunny.Wang@arm.com> In-Reply-To: From: =?UTF-8?B?TWFyaW8gQsSDbMSDbmljxIM=?= Date: Mon, 31 May 2021 19:35:44 +0300 Message-ID: Subject: Re: [edk2-devel] [PATCH v3 2/2] Platform/RaspberryPi: Enable Bluetooth and UART in Windows OS To: Sunny Wang Cc: "devel@edk2.groups.io" , Samer El-Haj-Mahmoud , Sami Mujawar , Jeremy Linton , Pete Batard , Ard Biesheuvel Content-Type: multipart/alternative; boundary="000000000000c6ccc905c3a2d19c" --000000000000c6ccc905c3a2d19c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable edit: "GpioPinSet (31, 0);" should be "GpioPinSet (31, FALSE);" and maybe add the "fake the CTS signal as we don't support HW flow control yet" comment too. When this patch gets merged, I'll add my Bluetooth changes to raspberrypi/windows-drivers: Windows IOT drivers (github.com) and submit another patch here to enable hardware flow control. --Mario =C3=8En lun., 31 mai 2021 la 18:56, Mario B=C4=83l=C4=83nic=C4=83 a scris: > If there is no COM port for PL011 UART, how can I check PL011 UART=E2=80= = =99s >> functionality? How can I use a telnet tool like PuTTY to send messages = from >> RPi4 to my laptop? > > > You can use: samples/MinComm at develop =C2=B7 ms-iot/samples (github.co= m) > (let me know if > you need a precompiled binary) > > As for why I mux both UARTs to the BT chip, I was trying to address your >> comment =E2=80=9CThis always assumes that PL011 is used for Bluetooth= =E2=80=9D. Apparently, >> it didn=E2=80=99t address your comment. No matter whether I add =E2=80= =9CPinFunction >> (Exclusive, PullDown, BCM_ALT5, "\\_SB.GDV0.GPI0", 0, ResourceConsumer, >> , ) { 32, 33 }=E2=80=9D or not, the Bluetooth has NOT worked when I con= figure >> PL011 UART as the primary serial console. Bluetooth only works when I >> configure Mini UART as the Primary serial console. I also confirmed tha= t >> this problem also exists with RPi4 Release FW 1.26 + >> edk2-platforms-raspberrypi-pl011-bth-noflow.diff in >> https://github.com/worproject/RPi-Bluetooth-Testing/. Do you have any >> idea to make the Bluetooth work with configuring PL011 UART as the prim= ary >> serial console? > > > Bluetooth doesn't really work with the mini UART driver at the moment. T= he > chip stalls after a few transfers, as far as I remember. Haven't looked > much into it. > > By the way, it is good to know the loading sequence. Do you know where I >> can quickly find this information without using WinDbg? > > > I'm not aware of any way to see the driver loading order without WinDbg. > Also, verbose mode must be enabled before boot: View Verbose Output - > Windows drivers | Microsoft Docs > > > You could also test if Bluetooth will break by uninstalling / > re-installing the mini UART driver while the system is running, then try= to > scan for nearby BT devices. > > 1. What is the connection between GPIO 128 and Bluetooth (BT_ON)? Why d= id >> we add this line in the beginning? I just removed it by your request an= d >> according to the change in worproject/RPi-Bluetooth-Testing/, but I=E2= =80=99m >> still worried about if we did this for some other purposes. > > > That is a leftover from the MS-IOT tables. It tries to toggle BT_ON from > the GPIO expander (I2C) through RPIQ (mailbox), but the driver has no > knowledge of it. And since the firmware blob turns on Bluetooth by defau= lt, > the line is completely useless. > > We may want to have something like this in the future, for power > management of the BT chip (will require some driver changes too). > > 2. Why do we need to configure GPIO 32 and 33? Is the Bluetooth using >> GPIO 32 and 33? Or Is Windows OS checking GPIO 32 and 33 for Bluetooth? >> Where can I find the information? > > > Yes, the Bluetooth chip is available on pins 32, 33 (TX / RX). Also 30, = 31 > for hardware flow control (CTS / RTS). More info can be found in the BCM= 2711 > datasheet > (5.= 3. > Alternative Function Assignments) > > 3. As for your comment about GPIO 31, I was confused, so I didn=E2=80= =99t update >> anything for addressing this comment. My understanding was that It is >> intended to override the BCM_ALT2=E2=80=99s default setting from PullLo= w to >> PullNone to fack the CTS signal. If we change it to PullLow, it will be >> used for HW flow control, which is unwanted, isn=E2=80=99t it? What did= you want me >> to change? Could you directly paste the code change you wanted here for= my >> reference? > > > The BCM_ALT2 thing is a dirty hack. Pin 31 must be held LOW so that we c= an > talk to the BT chip without flow control. It seems this can't be describ= ed > with PinFunction, so I've relied on the default value of ALT2 for pin 31 > (which turns out to be always LOW). > > My proposal is to move the pin muxing stuff in ConfigDxe, like this: > > STATIC VOID >> >> ApplyVariables ( >> >> VOID >> >> ) >> >> { >> >> ... >> >> >>> if (FanOnGpio) { >> >> DEBUG ((DEBUG_INFO, "Fan enabled on GPIO %d\n", FanOnGpio)); >> >> GpioPinFuncSet (FanOnGpio, GPIO_FSEL_OUTPUT); >> >> } >> >> >>> /* >> >> * Bluetooth pin muxing >> >> */ >> >> GpioPinFuncSet (31, GPIO_FSEL_OUTPUT); >> >> GpioPinSet (31, 0); >> >> >>> if ((PcdGet32 (PcdUartInUse) =3D=3D PL011_UART_IN_USE)) { >> >> GpioPinFuncSet (32, GPIO_FSEL_ALT3); >> >> GpioPinFuncSet (33, GPIO_FSEL_ALT3); >> >> } else { >> >> GpioPinFuncSet (32, GPIO_FSEL_ALT5); >> >> GpioPinFuncSet (33, GPIO_FSEL_ALT5); >> >> } >> >> } >> >> > --Mario > > =C3=8En lun., 31 mai 2021 la 16:26, Sunny Wang a sc= ris: > >> Hi Mario, >> >> >> >> Thanks for checking this. >> >> Yeah, the problem is NO COM port for PL011 UART in Windows IOT=E2=80=99= s device >> manager, so I thought it doesn=E2=80=99t work. If there is no COM port = for PL011 >> UART, how can I check PL011 UART=E2=80=99s functionality? How can I use= a >> telnet tool like PuTTY to send messages from RPi4 to my laptop? How to = use >> SerCx2? Is there a guideline for using PL011 UART on RPi4 with Windows = IoT? >> >> >> >> As for why I mux both UARTs to the BT chip, I was trying to address you= r >> comment =E2=80=9CThis always assumes that PL011 is used for Bluetooth= =E2=80=9D. Apparently, >> it didn=E2=80=99t address your comment. No matter whether I add =E2=80= =9CPinFunction >> (Exclusive, PullDown, BCM_ALT5, "\\_SB.GDV0.GPI0", 0, ResourceConsumer, >> , ) { 32, 33 }=E2=80=9D or not, the Bluetooth has NOT worked when I con= figure >> PL011 UART as the primary serial console. Bluetooth only works when I >> configure Mini UART as the Primary serial console. I also confirmed tha= t >> this problem also exists with RPi4 Release FW 1.26 + >> edk2-platforms-raspberrypi-pl011-bth-noflow.diff in >> https://github.com/worproject/RPi-Bluetooth-Testing/. Do you have any >> idea to make the Bluetooth work with configuring PL011 UART as the prim= ary >> serial console? By the way, it is good to know the loading sequence. Do= you >> know where I can quickly find this information without using WinDbg? >> >> >> >> >> >> Actually, the original code change (Patch 2/2) is the patch >> (edk2-platforms-raspberrypi-pl011-bth-noflow.diff) on >> https://github.com/worproject/RPi-Bluetooth-Testing/. I=E2=80=99m not f= amiliar >> with Windows drivers=E2=80=99 behavior, so I had no idea about why we n= eed to >> change them and couldn=E2=80=99t find more information about the change= s=E2=80=99 >> background either. It looks like you know the details. Could you share = with >> me more information about the background of these changes? At least, I = have >> some questions below: >> >> 1. What is the connection between GPIO 128 and Bluetooth (BT_ON)? Why >> did we add this line in the beginning? I just removed it by your reques= t >> and according to the change in worproject/RPi-Bluetooth-Testing/, but I= = =E2=80=99m >> still worried about if we did this for some other purposes. >> >> 2. Why do we need to configure GPIO 32 and 33? Is the Bluetooth using >> GPIO 32 and 33? Or Is Windows OS checking GPIO 32 and 33 for Bluetooth? >> Where can I find the information? >> >> 3. As for your comment about GPIO 31, I was confused, so I didn=E2=80= =99t update >> anything for addressing this comment. My understanding was that It is >> intended to override the BCM_ALT2=E2=80=99s default setting from PullLo= w to >> PullNone to fack the CTS signal. If we change it to PullLow, it will be >> used for HW flow control, which is unwanted, isn=E2=80=99t it? What did= you want me >> to change? Could you directly paste the code change you wanted here for= my >> reference? >> >> >> >> Moreover, for the changes you want, could you also paste the code chang= e? >> >> >> Best Regards, >> >> Sunny Wang >> >> >> >> *From:* devel@edk2.groups.io * On Behalf Of *Mar= io >> Balanica via groups.io >> *Sent:* Monday, May 31, 2021 8:41 PM >> *To:* Sunny Wang >> *Cc:* devel@edk2.groups.io; Samer El-Haj-Mahmoud < >> Samer.El-Haj-Mahmoud@arm.com>; Sami Mujawar ; >> Jeremy Linton ; Pete Batard ; Ard >> Biesheuvel >> *Subject:* Re: [edk2-devel] [PATCH v3 2/2] Platform/RaspberryPi: Enable >> Bluetooth and UART in Windows OS >> >> >> >> Hi Sunny, >> >> >> >> What issues are you seeing with the PL011 UART in Windows? Last time I >> checked, it worked fine, and the fact that Bluetooth works also confirm= s >> this. >> >> It won't show up as a COM port (like mini UART does) as it's built usin= g >> SerCx2. >> >> >> >> @@ -30,6 +30,12 @@ Device (URT0) >> { >> MEMORY32FIXED (ReadWrite, 0, BCM2836_PL011_UART_LENGTH, RMEM) >> Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { >> BCM2836_PL011_UART_INTERRUPT } >> + >> + PinFunction (Exclusive, PullDown, BCM_ALT3, "\\_SB.GDV0.GPI0", 0, >> ResourceConsumer, , ) { 32, 33 } >> + >> >> >> >> @@ -79,6 +85,11 @@ Device (URTM) >> // from muxing the pins away. >> >> // PinFunction (Exclusive, PullDown, BCM_ALT5, "\\_SB.GPI0", 0, >> ResourceConsumer, , ) { 14, 15 } >> + PinFunction (Exclusive, PullDown, BCM_ALT5, "\\_SB.GDV0.GPI0", 0, >> ResourceConsumer, , ) { 32, 33 } >> + >> >> >> >> What is the reason for trying to mux both UARTs to the BT chip? If PL01= 1 >> is used for Bluetooth and the mini UART driver loads *after* it, >> wouldn't it mux away the pins and break Bluetooth? >> >> >> >> >> >> >> >> >> >> =C3=8En lun., 31 mai 2021 la 11:23, Sunny Wang a s= cris: >> >> This change is based on edk2-platforms-raspberrypi-pl011-bth-noflow.dif= f >> in https://github.com/worproject/RPi-Bluetooth-Testing/ for enabling >> Bluetooth and serial port (Mini UART) in Windows IOT. >> >> Note that PL011 UART still doesn't work with Windows 10 IOT with this >> change, but PL011 UART works fine with VMware ESXi-Arm Fling v1.3. >> Therefore, there should be no issue with PL011 UART related changes, >> and we will still need a Windows expert to take a further look in the >> future. Making PL011 UART work properly with Windows 10 IOT may require >> additional changes to Windows driver or firmware's ACPI table. >> >> Testing Done: >> - Successfully booted Windows Windows 10 IOT (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. >> - Successfully booted VMware ESXi-Arm Fling v1.3 with only serial >> console connection (PL011 UART). >> >> Cc: Samer El-Haj-Mahmoud >> Cc: Sami Mujawar >> Cc: Jeremy Linton >> Cc: Pete Batard >> Cc: Ard Biesheuvel >> Cc: Mario B=C4=83l=C4=83nic=C4=83 >> Signed-off-by: Sunny Wang >> --- >> Platform/RaspberryPi/AcpiTables/Uart.asl | 19 +++++++++++-------- >> 1 file changed, 11 insertions(+), 8 deletions(-) >> >> diff --git a/Platform/RaspberryPi/AcpiTables/Uart.asl >> b/Platform/RaspberryPi/AcpiTables/Uart.asl >> index bac9d791eb..cb99086d39 100644 >> --- a/Platform/RaspberryPi/AcpiTables/Uart.asl >> +++ b/Platform/RaspberryPi/AcpiTables/Uart.asl >> @@ -30,6 +30,12 @@ Device (URT0) >> { >> MEMORY32FIXED (ReadWrite, 0, BCM2836_PL011_UART_LENGTH, RMEM) >> Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { >> BCM2836_PL011_UART_INTERRUPT } >> + >> + PinFunction (Exclusive, PullDown, BCM_ALT3, "\\_SB.GDV0.GPI0", 0, >> ResourceConsumer, , ) { 32, 33 } >> + >> + // fake the CTS signal as we don't support HW flow control yet >> + // BCM_ALT2 is set as output (low) by default >> + PinFunction (Exclusive, PullNone, BCM_ALT2, "\\_SB.GDV0.GPI0", 0, >> ResourceConsumer, , ) { 31 } >> }) >> Method (_CRS, 0x0, Serialized) >> { >> @@ -79,6 +85,11 @@ Device (URTM) >> // from muxing the pins away. >> >> // PinFunction (Exclusive, PullDown, BCM_ALT5, "\\_SB.GPI0", 0, >> ResourceConsumer, , ) { 14, 15 } >> + PinFunction (Exclusive, PullDown, BCM_ALT5, "\\_SB.GDV0.GPI0", 0, >> ResourceConsumer, , ) { 32, 33 } >> + >> + // fake the CTS signal as we don't support HW flow control yet >> + // BCM_ALT2 is set as output (low) by default >> + PinFunction (Exclusive, PullNone, BCM_ALT2, "\\_SB.GDV0.GPI0", 0, >> ResourceConsumer, , ) { 31 } >> }) >> Method (_CRS, 0x0, Serialized) >> { >> @@ -143,10 +154,6 @@ Device(BTH0) >> UAR0, // DescriptorName: creates name >> // for offset of resource descriptor >> ) // Vendor data >> - // >> - // RPIQ connection for BT_ON/OFF >> - // >> - GpioIO (Shared, PullUp, 0, 0, IoRestrictionNone, "\\_SB.GDV0.RPIQ"= , >> 0, ResourceConsumer, , ) { 128 } >> }) >> >> // >> @@ -190,10 +197,6 @@ Device(BTH0) >> UARM, // DescriptorName: creates name >> // for offset of resource descriptor >> ) // Vendor data >> - // >> - // RPIQ connection for BT_ON/OFF >> - // >> - GpioIO (Shared, PullUp, 0, 0, IoRestrictionNone, "\\_SB.GDV0.RPIQ"= , >> 0, ResourceConsumer, , ) { 128 } >> }) >> >> Method (_CRS, 0x0, Serialized) >> -- >> 2.31.0.windows.1 >> >>=20 >> IMPORTANT NOTICE: The contents of this email and any attachments are >> confidential and may also be privileged. If you are not the intended >> recipient, please notify the sender immediately and do not disclose the >> contents to any other person, use it for any purpose, or store or copy = the >> information in any medium. Thank you. >> > --000000000000c6ccc905c3a2d19c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
edit: "GpioPinSet (31, 0);" should be "GpioPinSet = (31, FALSE);" and maybe add the "fake the CTS signal as we don= 9;t support HW flow control yet" comment too.
When this patch gets merged, I'll add my Bluetooth changes= to=C2=A0raspber= rypi/windows-drivers: Windows IOT drivers (github.com)=C2=A0and submit = another patch here to enable hardware flow control.

--Mario

=C3=8En lun., 31 mai 2021 la 18:56, Mario = B=C4=83l=C4=83nic=C4=83 <ma= riobalanica02@gmail.com> a scris:
I= f there is no COM port for PL011 UART, how can I check PL011 UART=E2=80=99s= functionality? How can I use a telnet=C2=A0tool like PuTTY to send message= s from RPi4 to my laptop?=C2=A0
=C2=A0
Yo= u can use:=C2=A0samples/MinComm at develop =C2=B7 ms-iot/samples = (github.com)=C2=A0(let me know if you need a precompiled binary)
<= div>
As for why I mux both UARTs to the BT chip, I wa= s trying to address your comment =E2=80=9CThis always assumes that PL011 is= used for Bluetooth=E2=80=9D. Apparently, it didn=E2=80=99t address your co= mment. No matter whether I add =E2=80=9CPinFunction (Exclusive, Pull= Down, BCM_ALT5, "\\_SB.GDV0.GPI0", 0, ResourceConsumer, , = ) { 32, 33 }=E2=80=9D=C2=A0or not, the= Bluetooth has NOT worked when I configure PL011 UART as the primary serial= console. Bluetooth only works when I configure Mini UART as the Primary se= rial console. I also confirmed that this problem also exists with RPi4 Rele= ase FW 1.26 + edk2-platforms-raspberrypi-pl011-bth-noflow.diff in=C2=A0https://github.com/worproject/RPi-Bluetooth-Testing/. Do you have a= ny idea to make the Bluetooth work with configuring PL011 UART as the prima= ry serial console?
=C2=A0
Bluetooth doesn= 't really work with the mini UART driver at the moment. The chip stalls= after a few transfers, as far as I remember. Haven't looked much into = it.

<= span style=3D"color:rgb(32,56,100)">By the way, it is good to know the load= ing sequence. Do you know where I can quickly find this information without= using WinDbg?

I'm not aware of = any way to see the driver loading order without WinDbg. Also, verbose mode = must be enabled before boot:=C2=A0View Verbose Output - Windows drivers | Microsoft Docs
You could also test if Bluetooth will break by uninstalling / r= e-installing the mini UART driver while the system is running, then try to = scan for nearby BT devices.

1.=C2=A0 What i= s the connection between GPIO 128 and Bluetooth (BT_ON)? Why did we add thi= s line in the beginning? I just removed it by your request and according to= the change in worproject/RPi-Bluetooth-Testing/, but I=E2=80=99m still worried about if we did this for s= ome other purposes.=C2=A0=C2=A0
=C2=A0
Th= at is a leftover from the MS-IOT tables. It tries to toggle BT_ON from the = GPIO expander (I2C) through RPIQ (mailbox), but the driver has no knowledge= of it. And since the firmware blob turns on Bluetooth by default, the line= is completely useless.

We may want to have someth= ing like this in the future, for power management of the BT chip (will requ= ire some driver changes too).

2.=C2=A0 Why = do we need to configure GPIO 32 and 33? Is the Bluetooth using GPIO 32 and = 33? Or Is Windows OS checking GPIO 32 and 33 for Bluetooth? Where can I fin= d the information?

Yes, the Bluetoot= h chip is available on pins 32, 33 (TX / RX). Also 30, 31 for hardware flow= control (CTS / RTS). More info can be found in the B= CM2711 datasheet=C2=A0(5.3. Alternative Function Assignments)

3.=C2=A0 As for your comment about GPIO 31, I was co= nfused, so I didn=E2=80=99t update anything for addressing this comment. My= understanding was that It is intended to override the BCM_ALT2=E2=80=99s d= efault setting from PullLow to PullNone to fack the CTS signal. If we chang= e it to PullLow, it will be used for HW flow control, which is unwanted, is= n=E2=80=99t it? What did you want me to change? Could you directly paste th= e code change you wanted here for my reference?
The BCM_ALT2 thing is a dirty hack. Pin 31 must be held LOW so = that we can talk to the BT chip without flow control. It seems this can'= ;t be described with PinFunction, so I've relied on the default value o= f ALT2 for pin 31 (which turns out to be always LOW).=C2=A0

<= /div>
My proposal is to move the pin muxing stuff in ConfigDxe, like th= is:

<= blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l= eft:1px solid rgb(204,204,204);padding-left:1ex">STATIC VOID
ApplyVariables (
=C2=A0 VOID
=C2=A0 )
{
...

=C2=A0 if (FanOnGpio) {
=C2=A0 =C2=A0 DEBUG ((DEBUG_INFO, "Fan e= nabled on GPIO %d\n", FanOnGpio));
=C2=A0 =C2=A0 GpioPinFuncSet (FanOnGpio, GPIO_FS= EL_OUTPUT);
= =C2=A0 }
=C2=A0 /*
=C2=A0 =C2=A0*= Bluetooth pin muxing
=C2=A0 =C2=A0*/=C2=A0 =C2=A0
=C2=A0 GpioPinFuncSet (31, GPIO_FSEL_OUTPUT);
=C2=A0 GpioPin= Set (31, 0);
=
=C2=A0 i= f ((PcdGet32 (PcdUartInUse) =3D=3D PL011_UART_IN_USE)) {=C2=A0=C2=A0
=C2=A0 =C2=A0 GpioP= inFuncSet (32, GPIO_FSEL_ALT3);
=C2=A0 =C2=A0 GpioPinFuncSet (33, GPIO_FSEL_ALT3);
=C2=A0 } else {
=C2=A0 =C2=A0 G= pioPinFuncSet (32, GPIO_FSEL_ALT5);
=C2=A0 =C2=A0 GpioPinFuncSet (33, GPIO_FSEL_ALT5);
=C2=A0 }
}
=C2=A0
--Mario
<= /div>

=C3=8En lun., 31 mai 2021 la 16:26, Sunny Wa= ng <Sunny.Wang@a= rm.com> a scris:

Hi Mario, <= /u>

=C2=A0<= u>

Thanks for che= cking this.

=

Yeah, the prob= lem is NO COM port for PL011 UART in Windows IOT=E2=80=99s device manager, = so I thought it doesn=E2=80=99t work. If there is no COM port for PL011 UAR= T, how can I check PL011 UART=E2=80=99s functionality? How can I use a telnet=C2=A0tool like PuTTY to send messages from RPi4 to my laptop? Ho= w to use SerCx2? Is there a guideline for using PL011 UART on RPi4 with Win= dows IoT?

=C2=A0<= u>

As for why I m= ux both UARTs to the BT chip, I was trying to address your comment =E2=80= =9CThis always assumes that PL011 is used for Bluetooth=E2=80=9D. Apparent= ly, it didn=E2=80=99t address your comment. No matter whether I add =E2=80= =9CPinFunction (Exclusive, PullDown, BCM_ALT5, "\\_SB.GDV0.GPI0", 0, Re= sourceConsumer, , ) { 32, 33 }=E2=80=9D or not, the Bluetooth has NOT worked = when I configure PL011 UART as the primary serial console. Bluetooth only w= orks when I configure Mini UART as the Primary serial console. I also confi= rmed that this problem also exists with RPi4 Release FW 1.26 + edk2-platforms-raspberrypi-pl011-bth-noflow.diff in https://github.com/worproject/RPi-Bluetooth-Testing/. Do you have any = idea to make the Bluetooth work with configuring PL011 UART as the primary = serial console? By the way, it is good to know the loading sequence. Do you= know where I can quickly find this information without using WinDbg?

=C2=A0<= u>

=C2=A0<= u>

Actually, the = original code change (Patch 2/2) is the patch (edk2-platforms-raspberrypi-p= l011-bth-noflow.diff) on =C2=A0https://github.com/worproject/RPi-Bl= uetooth-Testing/. I=E2=80=99m not familiar with Windows drivers=E2=80=99 behavior, so I had= no idea about why we need to change them and couldn=E2=80=99t find more in= formation about the changes=E2=80=99 background either. It looks like you k= now the details. Could you share with me more information about the background of these changes? At least, I have some questions below:

1.=C2=A0 What = is the connection between GPIO 128 and Bluetooth (BT_ON)? Why did we add th= is line in the beginning? I just removed it by your request and according t= o the change in worproject/RPi-Bluetooth-Testing/, but I=E2=80=99m still worried about if we did this for some other purpose= s. =C2=A0

2.=C2=A0 Why d= o we need to configure GPIO 32 and 33? Is the Bluetooth using GPIO 32 and 3= 3? Or Is Windows OS checking GPIO 32 and 33 for Bluetooth? Where can I find= the information?

3.=C2=A0 As fo= r your comment about GPIO 31, I was confused, so I didn=E2=80=99t update an= ything for addressing this comment. My understanding was that It is intende= d to override the BCM_ALT2=E2=80=99s default setting from PullLow to PullNone to fack the CTS signal. If we change it to PullLow, it will b= e used for HW flow control, which is unwanted, isn=E2=80=99t it? What did y= ou want me to change? Could you directly paste the code change you wanted h= ere for my reference?

=C2=A0<= u>

Moreover, for = the changes you want, could you also paste the code change?


Best Regards,

Sunny Wang

=C2=A0

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Mario Balanica via groups.io
Sent: Monday, May 31, 2021 8:41 PM
To: Sunny Wang <Sunny.Wang@arm.com>
Cc: devel= @edk2.groups.io; Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>; = Sami Mujawar <= Sami.Mujawar@arm.com>; Jeremy Linton <Jeremy.Linton@arm.com>; Pete Batard = <pete@akeo.ie>;= Ard Biesheuvel <ardb+tianocore@kernel.org>
Subject: Re: [edk2-devel] [PATCH v3 2/2] Platform/RaspberryPi: Enab= le Bluetooth and UART in Windows OS

=C2=A0

Hi Sunny,

=C2=A0

What issues are you seeing with the PL011 UART in W= indows? Last time I checked, it worked fine, and the fact that Bluetooth wo= rks also confirms this.

It won't show up as a COM port (like mini UART = does) as it's built using SerCx2.

=C2=A0

@@ -30,6 +30,12 @@ Device (URT0)
=C2=A0 =C2=A0{
=C2=A0 =C2=A0 =C2=A0MEMORY32FIXED (ReadWrite, 0, BCM2836_PL011_UART_LENGTH= , RMEM)
=C2=A0 =C2=A0 =C2=A0Interrupt (ResourceConsumer, Level, ActiveHigh, Exclus= ive) { BCM2836_PL011_UART_INTERRUPT }
+
+=C2=A0 =C2=A0 PinFunction (Exclusive, PullDown, BCM_ALT3, "\\_SB.= GDV0.GPI0", 0, ResourceConsumer, , ) { 32, 33 }
+

=C2=A0

@@ -79,6 +85,11 @@ Device (URTM)
=C2=A0 =C2=A0 =C2=A0// from muxing the pins away.

=C2=A0 =C2=A0 =C2=A0// PinFunction (Exclusive, PullDown, BCM_ALT5, "<= a>\\_SB.GPI0", 0, ResourceConsumer, , ) { 14, 15 }
+=C2=A0 =C2=A0 PinFunction (Exclusive, PullDown, BCM_ALT5, "\\_SB.= GDV0.GPI0", 0, ResourceConsumer, , ) { 32, 33 }
+

=C2=A0

What is the reason for trying to mux both UARTs to = the BT chip? If PL011 is used for Bluetooth and the mini UART driver loads after=C2=A0it, wouldn't it mux away the pins and break Bluetoot= h?

=C2=A0

=C2=A0

=C2=A0

=C2=A0

=C3=8En lun., 31 mai 2021 la 11:23, Sunny Wang <= Sunny.Wang@arm.com<= /a>> a scris:

This change is based o= n 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 IOT.

Note that PL011 UART still doesn't work with Windows 10 IOT with this<= br> change, but PL011 UART works fine with VMware ESXi-Arm Fling v1.3.
Therefore, there should be no issue with PL011 UART related changes,
and we will still need a Windows expert to take a further look in the
future. Making PL011 UART work properly with Windows 10 IOT may require additional changes to Windows driver or firmware's ACPI table.

Testing Done:
=C2=A0 - Successfully booted Windows Windows 10 IOT (20279.1) on SD (made = by WOR) with
=C2=A0 =C2=A0 the RPi-Windows-Drivers release ver 0.5 downloaded from
=C2=A0 =C2=A0 https://github.com/worproject/RPi-Windows-Drivers/releases
=C2=A0 =C2=A0 and checked that both Bluetooth and serial port (Mini UART) = can
=C2=A0 =C2=A0 work fine.
=C2=A0 - Successfully booted VMware ESXi-Arm Fling v1.3 with only serial =C2=A0 =C2=A0 console connection (PL011 UART).

Cc: Samer El-Haj-Mahmoud <samer.el-haj-mahmoud@arm.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Jeremy Linton <jeremy.linton@arm.com>
Cc: Pete Batard <pete= @akeo.ie>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Mario B=C4=83l=C4=83nic=C4=83 <mariobalanica02@gmail.com>
Signed-off-by: Sunny Wang <sunny.wang@arm.com>
---
=C2=A0Platform/RaspberryPi/AcpiTables/Uart.asl | 19 +++++++++++-------- =C2=A01 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/Platform/RaspberryPi/AcpiTables/Uart.asl b/Platform/Raspberry= Pi/AcpiTables/Uart.asl
index bac9d791eb..cb99086d39 100644
--- a/Platform/RaspberryPi/AcpiTables/Uart.asl
+++ b/Platform/RaspberryPi/AcpiTables/Uart.asl
@@ -30,6 +30,12 @@ Device (URT0)
=C2=A0 =C2=A0{
=C2=A0 =C2=A0 =C2=A0MEMORY32FIXED (ReadWrite, 0, BCM2836_PL011_UART_LENGTH= , RMEM)
=C2=A0 =C2=A0 =C2=A0Interrupt (ResourceConsumer, Level, ActiveHigh, Exclus= ive) { BCM2836_PL011_UART_INTERRUPT }
+
+=C2=A0 =C2=A0 PinFunction (Exclusive, PullDown, BCM_ALT3, "\\_SB.= GDV0.GPI0", 0, ResourceConsumer, , ) { 32, 33 }
+
+=C2=A0 =C2=A0 // fake the CTS signal as we don't support HW flow cont= rol yet
+=C2=A0 =C2=A0 // BCM_ALT2 is set as output (low) by default
+=C2=A0 =C2=A0 PinFunction (Exclusive, PullNone, BCM_ALT2, "\\_SB.= GDV0.GPI0", 0, ResourceConsumer, , ) { 31 }
=C2=A0 =C2=A0})
=C2=A0 =C2=A0Method (_CRS, 0x0, Serialized)
=C2=A0 =C2=A0{
@@ -79,6 +85,11 @@ Device (URTM)
=C2=A0 =C2=A0 =C2=A0// from muxing the pins away.

=C2=A0 =C2=A0 =C2=A0// PinFunction (Exclusive, PullDown, BCM_ALT5, "<= a>\\_SB.GPI0", 0, ResourceConsumer, , ) { 14, 15 }
+=C2=A0 =C2=A0 PinFunction (Exclusive, PullDown, BCM_ALT5, "\\_SB.= GDV0.GPI0", 0, ResourceConsumer, , ) { 32, 33 }
+
+=C2=A0 =C2=A0 // fake the CTS signal as we don't support HW flow cont= rol yet
+=C2=A0 =C2=A0 // BCM_ALT2 is set as output (low) by default
+=C2=A0 =C2=A0 PinFunction (Exclusive, PullNone, BCM_ALT2, "\\_SB.= GDV0.GPI0", 0, ResourceConsumer, , ) { 31 }
=C2=A0 =C2=A0})
=C2=A0 =C2=A0Method (_CRS, 0x0, Serialized)
=C2=A0 =C2=A0{
@@ -143,10 +154,6 @@ Device(BTH0)
=C2=A0 =C2=A0 =C2=A0 =C2=A0UAR0,=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 // Desc= riptorName: creates name
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0//=C2=A0 =C2=A0for offset of resource descriptor
=C2=A0 =C2=A0 =C2=A0)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 // Vendor data
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 // RPIQ connection for BT_ON/OFF
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 GpioIO (Shared, PullUp, 0, 0, IoRestrictionNone, "\= \_SB.GDV0.RPIQ", 0, ResourceConsumer, , ) { 128 }
=C2=A0 =C2=A0})

=C2=A0 =C2=A0//
@@ -190,10 +197,6 @@ Device(BTH0)
=C2=A0 =C2=A0 =C2=A0 =C2=A0UARM,=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 // Desc= riptorName: creates name
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0//=C2=A0 =C2=A0for offset of resource descriptor
=C2=A0 =C2=A0 =C2=A0)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 // Vendor data
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 // RPIQ connection for BT_ON/OFF
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 GpioIO (Shared, PullUp, 0, 0, IoRestrictionNone, "\= \_SB.GDV0.RPIQ", 0, ResourceConsumer, , ) { 128 }
=C2=A0 =C2=A0})

=C2=A0 =C2=A0Method (_CRS, 0x0, Serialized)
--
2.31.0.windows.1

IMPORTANT NOTICE: The contents of this email and any attachments are confi= dential and may also be privileged. If you are not the intended recipient, = please notify the sender immediately and do not disclose the contents to an= y other person, use it for any purpose, or store or copy the information in any medium. Thank you.
--000000000000c6ccc905c3a2d19c--