diff mbox series

[edk2,edk2-platforms,v3,08/18] Hisilicon/D06: Add OemGetCpuFreq to encapsulate difference

Message ID 20190320080829.52003-9-ming.huang@linaro.org
State New
Headers show
Series Fix issues and improve D0x | expand

Commit Message

Ming Huang March 20, 2019, 8:08 a.m. UTC
From: xingjiang tang <tangxingjiang@huawei.com>


Implementation OemGetCpuFreq() to get cpu frequency from cpld to
encapsulate project difference, for some projects don't support
get cpu frequency by this way.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang <ming.huang@linaro.org>

---
 Platform/Hisilicon/D06/Include/Library/CpldD06.h             |  4 ++++
 Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.c | 16 ++++++++++++++++
 2 files changed, 20 insertions(+)

-- 
2.9.5

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
diff mbox series

Patch

diff --git a/Platform/Hisilicon/D06/Include/Library/CpldD06.h b/Platform/Hisilicon/D06/Include/Library/CpldD06.h
index ec9b49f4e70d..8eb333de529c 100644
--- a/Platform/Hisilicon/D06/Include/Library/CpldD06.h
+++ b/Platform/Hisilicon/D06/Include/Library/CpldD06.h
@@ -36,4 +36,8 @@ 
 #define CPLD_X8_X8_X8_BOARD_ID            0x92
 #define CPLD_X16_X8_BOARD_ID              0x93
 
+#define CPLD_CLOCK_FLAG      0xFD
+#define CPLD_BOM_VER_FLAG    0x0B
+#define CPLD_BOARD_REVISION_4TH           0x4
+
 #endif /* __CPLDD06_H__ */
diff --git a/Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.c b/Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.c
index c5cb77696031..c8f71ecf890a 100644
--- a/Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.c
+++ b/Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.c
@@ -206,3 +206,19 @@  OemIsNeedDisableExpanderBuffer (
 {
   return TRUE;
 }
+
+UINTN OemGetCpuFreq (UINT8 Socket)
+{
+  UINT8 BoardRevision;
+
+  BoardRevision = MmioRead8 (CPLD_BASE_ADDRESS + CPLD_BOM_VER_FLAG);
+
+  // Board revision 4 and higher run at 2.5GHz
+  // Earlier revisions run at 2GHz
+  if (BoardRevision >= CPLD_BOARD_REVISION_4TH) {
+    return 2500000000;
+  } else {
+    return 2000000000;
+  }
+}
+