diff mbox

[API,NEXT,v5,07/17] api: sysinfo: add new API to get per-CPU max frequency

Message ID 1442325342-13806-8-git-send-email-hongbo.zhang@freescale.com
State New
Headers show

Commit Message

hongbo.zhang@freescale.com Sept. 15, 2015, 1:55 p.m. UTC
From: Hongbo Zhang <hongbo.zhang@linaro.org>

This patch adds new API odp_cpu_hz_max_id() to get the
corresponding max frequency for each CPU indexed by CPU ID.

Signed-off-by: Hongbo Zhang <hongbo.zhang@linaro.org>
---
 include/odp/api/cpu.h                    | 11 +++++++++++
 platform/linux-generic/odp_system_info.c | 10 +++++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/include/odp/api/cpu.h b/include/odp/api/cpu.h
index 93d3e7f..4ec59b4 100644
--- a/include/odp/api/cpu.h
+++ b/include/odp/api/cpu.h
@@ -82,6 +82,17 @@  uint64_t odp_cpu_hz(void);
 uint64_t odp_cpu_hz_max(void);
 
 /**
+ * Maximum CPU frequency of a CPU (in Hz)
+ *
+ * Returns maximum frequency of specified CPU
+ *
+ * @param id    CPU ID
+ *
+ * @return CPU frequency in Hz
+ */
+uint64_t odp_cpu_hz_max_id(int id);
+
+/**
  * @}
  */
 
diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c
index 43bfcc0..8532fa0 100644
--- a/platform/linux-generic/odp_system_info.c
+++ b/platform/linux-generic/odp_system_info.c
@@ -373,7 +373,15 @@  uint64_t odp_cpu_hz(void)
 
 uint64_t odp_cpu_hz_max(void)
 {
-	return odp_global_data.system_info.cpu_hz[0];
+	return odp_cpu_hz_max_id(0);
+}
+
+uint64_t odp_cpu_hz_max_id(int id)
+{
+	if (id >= 0 && id < MAX_CPU_NUMBER)
+		return odp_global_data.system_info.cpu_hz[id];
+	else
+		return -1;
 }
 
 uint64_t odp_sys_huge_page_size(void)