summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c25
-rw-r--r--ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.inf5
2 files changed, 19 insertions, 11 deletions
diff --git a/ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c b/ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c
index 2af207829d..d9280cd0bb 100644
--- a/ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c
+++ b/ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c
@@ -2,7 +2,7 @@
Serial I/O Port library functions with no library constructor/destructor
Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
- Copyright (c) 2011 - 2012, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -42,11 +42,6 @@ PL011UartInitializePort (
UINT32 LineControl;
UINT32 Divisor;
- // The BaudRate must be passed
- if (BaudRate == 0) {
- return RETURN_INVALID_PARAMETER;
- }
-
LineControl = 0;
// The PL011 supports a buffer of either 1 or 32 chars. Therefore we can accept
@@ -130,10 +125,20 @@ PL011UartInitializePort (
//
// Baud Rate
//
- if (PcdGet32(PL011UartInteger) != 0) {
- MmioWrite32 (UartBase + UARTIBRD, PcdGet32(PL011UartInteger));
- MmioWrite32 (UartBase + UARTFBRD, PcdGet32(PL011UartFractional));
- } else {
+
+ // If BaudRate is zero then use default baud rate
+ if (BaudRate == 0) {
+ if (PcdGet32 (PL011UartInteger) != 0) {
+ MmioWrite32 (UartBase + UARTIBRD, PcdGet32 (PL011UartInteger));
+ MmioWrite32 (UartBase + UARTFBRD, PcdGet32 (PL011UartFractional));
+ } else {
+ BaudRate = PcdGet32 (PcdSerialBaudRate);
+ ASSERT (BaudRate != 0);
+ }
+ }
+
+ // If BaudRate != 0 then we must calculate the divisor from the value
+ if (BaudRate != 0) {
Divisor = (PcdGet32 (PL011UartClkInHz) * 4) / BaudRate;
MmioWrite32 (UartBase + UARTIBRD, Divisor >> 6);
MmioWrite32 (UartBase + UARTFBRD, Divisor & 0x3F);
diff --git a/ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.inf b/ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.inf
index 6347ba63f3..7f7709aecf 100644
--- a/ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.inf
+++ b/ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.inf
@@ -2,7 +2,7 @@
#
# Component description file for PL011Uart module
#
-# Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
+# Copyright (c) 2011-2013, ARM Ltd. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -31,9 +31,12 @@
[Packages]
MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
ArmPlatformPkg/ArmPlatformPkg.dec
[Pcd]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate
+
gArmPlatformTokenSpaceGuid.PL011UartClkInHz
gArmPlatformTokenSpaceGuid.PL011UartInteger
gArmPlatformTokenSpaceGuid.PL011UartFractional