You've already forked edk2-platforms
mirror of
https://github.com/Dasharo/edk2-platforms.git
synced 2026-03-06 14:51:43 -08:00
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 config.txt 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 a simple MMIO call. This patch does just this by adding a new DualSerialPortLib that directs the SerialPortLib implementation to use either 16650 or PL011 according to the GPIO pinmuxing. It should be noted that this code mostly a merge of * MdeModulePkg/Library/BaseSerialPortLib16550 * ArmPlatformPkg/Library/PL011SerialPortLib with non-relevant elements stripped from BaseSerialPortLib16550 (such as PCI support) and a new call added to retreive the 16650 baudrate divisor, since it is dependent on the platform's VPU's clock divisor. Signed-off-by: Pete Batard <pete@akeo.ie> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>