summaryrefslogtreecommitdiff
path: root/ArmPlatformPkg/Drivers
diff options
context:
space:
mode:
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2013-04-14 09:23:30 +0000
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2013-04-14 09:23:30 +0000
commit6bc77e7a21155b247d9eb2b1ab93214f07bf194e (patch)
tree0982d6506f9289687093362dcaead501100af671 /ArmPlatformPkg/Drivers
parent007f932de64bf2b67f63b1656134120dc3856339 (diff)
downloadedk2-platforms-6bc77e7a21155b247d9eb2b1ab93214f07bf194e.tar.xz
ArmPlatformPkg/PL011Uart: Added support for default BaudRate
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin <olivier.martin@arm.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14261 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPlatformPkg/Drivers')
-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