Skip to content

Commit 48edf6b

Browse files
Leif Lindholmoliviermartin
Leif Lindholm
authored and
oliviermartin
committed
ArmPlatformPkg: detect correct pl011 fifo depth
pl011 releases earlier than r1p5 has a fifo depth of 16 bytes, whereas version r1p5 upwards has a fifo depth of 32 bytes. The pl011 driver was hardwired to 32 byte depth, causing dropped characters on some platforms (including default settings on FVP Base and Foundation models). Update driver to select 16 or 32 on port initialization by checking the component revision. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Leif Lindholm <[email protected]> Reviewed-by: Olivier Martin <[email protected]> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16656 6f19259b-4bc3-4df7-8a09-765794883524
1 parent ac83357 commit 48edf6b

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,15 @@ PL011UartInitializePort (
5050

5151
LineControl = 0;
5252

53-
// The PL011 supports a buffer of either 1 or 32 chars. Therefore we can accept
53+
// The PL011 supports a buffer of 1, 16 or 32 chars. Therefore we can accept
5454
// 1 char buffer as the minimum fifo size. Because everything can be rounded down,
5555
// there is no maximum fifo size.
5656
if ((*ReceiveFifoDepth == 0) || (*ReceiveFifoDepth >= 32)) {
5757
LineControl |= PL011_UARTLCR_H_FEN;
58-
*ReceiveFifoDepth = 32;
58+
if (PL011_UARTPID2_VER (MmioRead32 (UartBase + UARTPID2)) > PL011_VER_R1P4)
59+
*ReceiveFifoDepth = 32;
60+
else
61+
*ReceiveFifoDepth = 16;
5962
} else {
6063
ASSERT (*ReceiveFifoDepth < 32);
6164
// Nothing else to do. 1 byte fifo is default.

ArmPlatformPkg/Include/Drivers/PL011Uart.h

+8
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@
3535
#define UARTICR 0x044
3636
#define UARTDMACR 0x048
3737

38+
#define UARTPID0 0xFE0
39+
#define UARTPID1 0xFE4
40+
#define UARTPID2 0xFE8
41+
#define UARTPID3 0xFEC
42+
3843
// Data status bits
3944
#define UART_DATA_ERROR_MASK 0x0F00
4045

@@ -81,6 +86,9 @@
8186
#define PL011_UARTLCR_H_PEN (1 << 1) // Parity Enable
8287
#define PL011_UARTLCR_H_BRK (1 << 0) // Send break
8388

89+
#define PL011_UARTPID2_VER(X) (((X) >> 4) & 0xF)
90+
#define PL011_VER_R1P4 0x2
91+
8492
/*
8593
8694
Programmed hardware of Serial port.

0 commit comments

Comments
 (0)