]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg: detect correct pl011 fifo depth
authorLeif Lindholm <leif.lindholm@linaro.org>
Fri, 23 Jan 2015 16:10:00 +0000 (16:10 +0000)
committeroliviermartin <oliviermartin@Edk2>
Fri, 23 Jan 2015 16:10:00 +0000 (16:10 +0000)
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 <leif.lindholm@linaro.org>
Reviewed-by: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16656 6f19259b-4bc3-4df7-8a09-765794883524

ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c
ArmPlatformPkg/Include/Drivers/PL011Uart.h

index 7e74a05df7fcdea37621da6a56f8a6b7caa8ba55..8b256de945d2115bf98de16e890bf944afc470a6 100644 (file)
@@ -50,12 +50,15 @@ PL011UartInitializePort (
 \r
   LineControl = 0;\r
 \r
-  // The PL011 supports a buffer of either 1 or 32 chars. Therefore we can accept\r
+  // The PL011 supports a buffer of 1, 16 or 32 chars. Therefore we can accept\r
   // 1 char buffer as the minimum fifo size. Because everything can be rounded down,\r
   // there is no maximum fifo size.\r
   if ((*ReceiveFifoDepth == 0) || (*ReceiveFifoDepth >= 32)) {\r
     LineControl |= PL011_UARTLCR_H_FEN;\r
-    *ReceiveFifoDepth = 32;\r
+    if (PL011_UARTPID2_VER (MmioRead32 (UartBase + UARTPID2)) > PL011_VER_R1P4)\r
+      *ReceiveFifoDepth = 32;\r
+    else\r
+      *ReceiveFifoDepth = 16;\r
   } else {\r
     ASSERT (*ReceiveFifoDepth < 32);\r
     // Nothing else to do. 1 byte fifo is default.\r
index 6675cefeb38a3e652266ae85436706be22955260..2fe796f9e42e663ae838a9559c16e237bf3db28b 100644 (file)
 #define UARTICR                   0x044\r
 #define UARTDMACR                 0x048\r
 \r
+#define UARTPID0                  0xFE0\r
+#define UARTPID1                  0xFE4\r
+#define UARTPID2                  0xFE8\r
+#define UARTPID3                  0xFEC\r
+\r
 // Data status bits\r
 #define UART_DATA_ERROR_MASK      0x0F00\r
 \r
@@ -81,6 +86,9 @@
 #define PL011_UARTLCR_H_PEN       (1 << 1)  // Parity Enable\r
 #define PL011_UARTLCR_H_BRK       (1 << 0)  // Send break\r
 \r
+#define PL011_UARTPID2_VER(X)     (((X) >> 4) & 0xF)\r
+#define PL011_VER_R1P4            0x2\r
+\r
 /*\r
 \r
   Programmed hardware of Serial port.\r