From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by mx.groups.io with SMTP id smtpd.web10.4260.1581673710988803140 for ; Fri, 14 Feb 2020 01:48:31 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=PAi1xEG6; spf=pass (domain: linaro.org, ip: 209.85.221.65, mailfrom: ard.biesheuvel@linaro.org) Received: by mail-wr1-f65.google.com with SMTP id t3so10141977wru.7 for ; Fri, 14 Feb 2020 01:48:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lTeANQo0pcQmYcO2PrMIarH+Jf7v6FRIWecctTW4+WM=; b=PAi1xEG6KatS7Bsb1f9e5pdGNTQG/6Vmn4hCXfeHRVMnEIrXOiu57hT/D20YyhKXj0 0cXKmXEVqEbW6CyiaGQmxfI6Le6/2YrLiDdXbW8AhQy9dsdzon3dm2aj2gc02cqoO7CD +w1h9c5jlx50edY3N3q/gdIpx5q3O830ROJHPjtl0y8n5jX9qgjmKwYClFvBcbod+8p3 z99cPQ2UyabyTUpiiPv2G7vEW7hwoPMwOT8lmDKJQX6DkR6n6K+mm5tJ1Lfqk/xmOugI V8y7l1wwJ/CIBzH2t39EeXqDEdmG7G8rqdOpv8Fz5rz76i6wlLt72T63aQ9tr0h3YwwV dn9Q== 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=lTeANQo0pcQmYcO2PrMIarH+Jf7v6FRIWecctTW4+WM=; b=nrD33yZG8ZkTuLS19AdGTEm3i5K1O9Vvs05lnwJPWrkXtWSu3IfbFQctjmOaAkhxEw zDafii75X2fc7C6aRpLUlMMSTW0Fi/sHTNkjD9+7K6FBio/fioD6nC1xLZiCE4JxQ6gW WyHFsL32fRPg2hwsDdSF1R/5DhOxNRYxvY6D4drnryfAQRqPUodWHST+CktZc7eAuLMT H6X84q05zhtWFmBrnPF57kRb+IYv3JGoSS7KntlPgivlxf1YbeenTXFNM+q+NtKOzarf ouEY/zIvQvivcDAjuav0EfD3pQaUh3lPYaaBagAf0jWze0lk2lcBd/L55xEHM1ssRIIw Te2A== X-Gm-Message-State: APjAAAXPh1whyN5UQbVSosZOkKsmWndlHBNeXOeVX9xea3cA4Wa2Aq2y eNH5ZJVWr1fFSMRDe7EgC+VJBLQojvOAi1WybTOJ7g== X-Google-Smtp-Source: APXvYqw7rwRKP1LklA6xyuVhOsLOzUPTQrwc+k9LQVFaEGXIL1EpCOuVVN8FC1UKBlh1bEqNn2JZf+XBdZ1urb8FTAQ= X-Received: by 2002:a5d:6a4b:: with SMTP id t11mr3112537wrw.262.1581673709328; Fri, 14 Feb 2020 01:48:29 -0800 (PST) MIME-Version: 1.0 References: <20200128171956.9680-1-pete@akeo.ie> In-Reply-To: <20200128171956.9680-1-pete@akeo.ie> From: "Ard Biesheuvel" Date: Fri, 14 Feb 2020 09:48:18 +0000 Message-ID: Subject: Re: [edk2-platforms][PATCH 0/4] Platform/RPi: Automate runtime UART selection To: Pete Batard Cc: edk2-devel-groups-io , Leif Lindholm , =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= Content-Type: text/plain; charset="UTF-8" On Tue, 28 Jan 2020 at 18:20, Pete Batard wrote: > > The Raspberry Pi platform contains two UARTs, one PL011-based and the > other (called miniUART) 16650-compatible, that are pinmuxed to the GPIO > serial port according to whether a Device Tree overlay is present in > config.txt or not. In most cases, it takes only the user commenting > or uncommenting an overlay line in their config to switch between PL011 > and miniUART. > > As such, the use of a build time option to select the UART should be > avoided when it is effectively possible to detect which of the UART > is in use at runtime, through an MMIO call. > > This series of patches achieves just this by: > > * Adding the relevant clock manager constant to Silicon (which we'll > need to retrieve the VPU divisor, needed to set the 16550 baudrate). > > * Adding a new DualSerialPortLibrary that handles runtime detection > and switching between PL011 and 16650. > > * Enabling the use of DualSerialPortLibrar for both the RPi3 and RPi4. > > Important notes: > > * This patch does not cover ACPI serial bindings, as this requires > switching to using DynamicTablesPkg / ConfigurationManagerDxe to > generate the ACPI tables at runtime. As such, each of the RPi > platforms is currently hardcoded to use one of the UARTs for ACPI: > miniUART for RPi3 and PL011 for RPi4. Of course, there is no issue > for Device Tree usage, since the relevant UART overlay will have > been applied then. We don't see the current ACPI UART hardcoding > as a major issue, as this doesn't change anything for RPi3 and we > expect RPi4 users to prefer PL011 over miniUART anyway, but we > will look into using DynamicTablesPkg once we see clearer in terms > of ACPI for RPi4. > > * There is work underway to produce a PL011 vs miniUART aware TF-A, > which we hope will be completed by the next TF-A release. Once > that release has occurred, we will update the TF-A blobs in > non-osi, since the ones we have right now are hardcoded to output > through one UART only. > > * One the subject of TF-A usage, there appears to be an issue when > using a 16650 (miniUART) based TF-A in a PL011 configuration as > the system freezes then. This issue does not occur when using a > PL011 based TF-A in a 16650/miniUART configuration (which is one > of the the reason why we picked the PL011 TF-A binary over the > 16650 one for RPi4). What this means is that, unless you replace > the current RPi3 TF-A blobs from non-osi with a version that > outputs to PL011, and attempt to use a Raspberry Pi 3 in PL011 > mode, then a boot freezout will happen before the UEFI firmware > gets a chance to apply UART runtime selection. This is an issue > that will of course resolve itself once we replace the current > TF-A blobs with the upcoming runtime selection version. However, > I can also produce a patch that replaces the current 16650-based > RPI3 TF-A in non-osi with PL011-based ones, if we think it's > needed before we get the upcoming runtime selection TF-A binaries. > > * It appears that we are issuing serial write calls before the > UARTs are initialized, which is a problem if 16650 is being used > instead of PL011 (produces a freezout similar to what occurs when > using 16650 TF-A in a PL011 enabled conf). As such, we do perform > miniUART vs PL011 detection in both initialize and write. > > * The 16650 code applies the recent bugfix from Ashish Singhal in > https://edk2.groups.io/g/devel/message/53487. > > Regards, > > /Pete > > Pete Batard (4): > Silicon/Broadcom/Bcm283x: Add clock manager constants > Platform/RPi: Add serial lib for runtime PL011 vs miniUART detection > Platform/RPi3: Enable the use of DualSerialPortLib > Platform/RPi4: Enable the use of DualSerialPortLib > Reviewed-by: Ard Biesheuvel Pushed as 9369b01e86ad..41c1d9ba3304 Thanks! > Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c | 836 ++++++++++++++++++++ > Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.inf | 55 ++ > Platform/RaspberryPi/RPi3/RPi3.dsc | 15 +- > Platform/RaspberryPi/RPi3/Readme.md | 7 + > Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf | 7 + > Platform/RaspberryPi/RPi4/RPi4.dsc | 26 +- > Platform/RaspberryPi/RPi4/RPi4.fdf | 4 - > Platform/RaspberryPi/RPi4/Readme.md | 21 +- > Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h | 22 + > 9 files changed, 944 insertions(+), 49 deletions(-) > create mode 100644 Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c > create mode 100644 Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.inf > > -- > 2.21.0.windows.1 >