From 6bc77e7a21155b247d9eb2b1ab93214f07bf194e Mon Sep 17 00:00:00 2001 From: oliviermartin Date: Sun, 14 Apr 2013 09:23:30 +0000 Subject: ArmPlatformPkg/PL011Uart: Added support for default BaudRate Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14261 6f19259b-4bc3-4df7-8a09-765794883524 --- ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c | 25 +++++++++++++++---------- ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.inf | 5 ++++- 2 files changed, 19 insertions(+), 11 deletions(-) (limited to 'ArmPlatformPkg/Drivers') 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.
- Copyright (c) 2011 - 2012, ARM Ltd. All rights reserved.
+ Copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.
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.
+# Copyright (c) 2011-2013, ARM Ltd. All rights reserved.
# # 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 -- cgit v1.2.3