]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmVirtPkg/FdtPL011SerialPortLib: honor DT node 'status' property
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 4 Apr 2017 13:07:16 +0000 (14:07 +0100)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 4 Apr 2017 14:25:16 +0000 (15:25 +0100)
In some cases, (e.g., when running QEMU with TrustZone emulation), the
DT may contain DT nodes whose status is set to 'secure'. Similarly, the
status may be set to 'disabled' if the consumer of the DT image is
expected to treat it as if it weren't there.

So check whether a 'status' property is present, and if so, ignore the
node if the status is not 'okay'.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.c

index c458abb622d9c25de5a9ea9dfa8ae0e52c4ac739..e28750f3b4c4ce5412e76c39e5f9b185dc6b0153 100644 (file)
@@ -66,6 +66,7 @@ SerialPortGetBaseAddress (
   INT32               Node, Prev;\r
   INT32               Len;\r
   CONST CHAR8         *Compatible;\r
+  CONST CHAR8         *NodeStatus;\r
   CONST CHAR8         *CompatibleItem;\r
   CONST UINT64        *RegProperty;\r
   UINTN               UartBase;\r
@@ -98,6 +99,11 @@ SerialPortGetBaseAddress (
       CompatibleItem += 1 + AsciiStrLen (CompatibleItem)) {\r
 \r
       if (AsciiStrCmp (CompatibleItem, "arm,pl011") == 0) {\r
+        NodeStatus = fdt_getprop (DeviceTreeBase, Node, "status", &Len);\r
+        if (NodeStatus != NULL && AsciiStrCmp (NodeStatus, "okay") != 0) {\r
+          continue;\r
+        }\r
+\r
         RegProperty = fdt_getprop (DeviceTreeBase, Node, "reg", &Len);\r
         if (Len != 16) {\r
           return 0;\r