]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/PL011Uart: Added support for default BaudRate
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Sun, 14 Apr 2013 09:23:30 +0000 (09:23 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Sun, 14 Apr 2013 09:23:30 +0000 (09:23 +0000)
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

ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c
ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.inf

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