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
This commit is contained in:
oliviermartin 2013-04-14 09:23:30 +00:00
parent 007f932de6
commit 6bc77e7a21
2 changed files with 19 additions and 11 deletions

View File

@ -2,7 +2,7 @@
Serial I/O Port library functions with no library constructor/destructor Serial I/O Port library functions with no library constructor/destructor
Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR> 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 This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
@ -42,11 +42,6 @@ PL011UartInitializePort (
UINT32 LineControl; UINT32 LineControl;
UINT32 Divisor; UINT32 Divisor;
// The BaudRate must be passed
if (BaudRate == 0) {
return RETURN_INVALID_PARAMETER;
}
LineControl = 0; LineControl = 0;
// The PL011 supports a buffer of either 1 or 32 chars. Therefore we can accept // The PL011 supports a buffer of either 1 or 32 chars. Therefore we can accept
@ -130,10 +125,20 @@ PL011UartInitializePort (
// //
// Baud Rate // Baud Rate
// //
if (PcdGet32(PL011UartInteger) != 0) {
MmioWrite32 (UartBase + UARTIBRD, PcdGet32(PL011UartInteger)); // If BaudRate is zero then use default baud rate
MmioWrite32 (UartBase + UARTFBRD, PcdGet32(PL011UartFractional)); if (BaudRate == 0) {
} else { 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; Divisor = (PcdGet32 (PL011UartClkInHz) * 4) / BaudRate;
MmioWrite32 (UartBase + UARTIBRD, Divisor >> 6); MmioWrite32 (UartBase + UARTIBRD, Divisor >> 6);
MmioWrite32 (UartBase + UARTFBRD, Divisor & 0x3F); MmioWrite32 (UartBase + UARTFBRD, Divisor & 0x3F);

View File

@ -2,7 +2,7 @@
# #
# Component description file for PL011Uart module # 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 # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
@ -31,9 +31,12 @@
[Packages] [Packages]
MdePkg/MdePkg.dec MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
ArmPlatformPkg/ArmPlatformPkg.dec ArmPlatformPkg/ArmPlatformPkg.dec
[Pcd] [Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate
gArmPlatformTokenSpaceGuid.PL011UartClkInHz gArmPlatformTokenSpaceGuid.PL011UartClkInHz
gArmPlatformTokenSpaceGuid.PL011UartInteger gArmPlatformTokenSpaceGuid.PL011UartInteger
gArmPlatformTokenSpaceGuid.PL011UartFractional gArmPlatformTokenSpaceGuid.PL011UartFractional