public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: evan.lloyd@arm.com
To: edk2-devel@ml01.01.org
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Leif Lindholm <leif.lindholm@linaro.org>,
	Ryan Harkin <ryan.harkin@linaro.org>
Subject: [PATCH 1/3] ArmPlatformPkg: Fix PL011 FIFO size test
Date: Wed, 21 Sep 2016 21:33:13 +0100	[thread overview]
Message-ID: <20160921203315.11204-2-evan.lloyd@arm.com> (raw)
In-Reply-To: <20160921203315.11204-1-evan.lloyd@arm.com>

From: Evan Lloyd <evan.lloyd@arm.com>

This change updates PL011UartInitializePort to compare ReceiveFifoDepth
with the correct hardware FIFO size instead of the constant 32 used
previously.
This corrects a minor bug where a request for a fifo size > 15 and < 32
would not have been honoured on a system with a 16 byte FIFO.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
---
 ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c b/ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c
index 3748972acbfc80f1077b9b928756a72cc77b5c75..b3ea138bf60b93a1000dd29aedaad206f2d15f2b 100644
--- a/ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c
+++ b/ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c
@@ -79,17 +79,18 @@ PL011UartInitializePort (
   UINT32      Divisor;
   UINT32      Integer;
   UINT32      Fractional;
+  UINT32      HardwareFifoDepth;
 
+  HardwareFifoDepth = (PL011_UARTPID2_VER (MmioRead32 (UartBase + UARTPID2)) \
+                       > PL011_VER_R1P4) \
+                      ? 32 : 16 ;
   // The PL011 supports a buffer of 1, 16 or 32 chars. Therefore we can accept
   // 1 char buffer as the minimum FIFO size. Because everything can be rounded
   // down, there is no maximum FIFO size.
-  if ((*ReceiveFifoDepth == 0) || (*ReceiveFifoDepth >= 32)) {
+  if ((*ReceiveFifoDepth == 0) || (*ReceiveFifoDepth >= HardwareFifoDepth)) {
     // Enable FIFO
     LineControl = PL011_UARTLCR_H_FEN;
-    if (PL011_UARTPID2_VER (MmioRead32 (UartBase + UARTPID2)) > PL011_VER_R1P4)
-      *ReceiveFifoDepth = 32;
-    else
-      *ReceiveFifoDepth = 16;
+    *ReceiveFifoDepth = HardwareFifoDepth;
   } else {
     // Disable FIFO
     LineControl = 0;
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



  reply	other threads:[~2016-09-21 20:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-21 20:33 [PATCH 0/3] PL011 updates evan.lloyd
2016-09-21 20:33 ` evan.lloyd [this message]
2016-10-10 18:58   ` [PATCH 1/3] ArmPlatformPkg: Fix PL011 FIFO size test Leif Lindholm
2016-09-21 20:33 ` [PATCH 2/3] ArmPlatformPkg: Correct mendacious comments evan.lloyd
2016-10-10 19:00   ` Leif Lindholm
2016-09-21 20:33 ` [PATCH 3/3] ArmPlatformPkg: Remove UINTN cast when setting BaudRate evan.lloyd
2016-10-10 19:04   ` Leif Lindholm
2016-10-11 10:23     ` Evan Lloyd
2016-10-11 11:27       ` Leif Lindholm
2016-10-11 12:29         ` Evan Lloyd
2016-10-11 11:34       ` Laszlo Ersek
2016-10-12  7:30 ` [PATCH 0/3] PL011 updates Ryan Harkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160921203315.11204-2-evan.lloyd@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox