diff mbox

[API-NEXT,v4,07/10] linux-generic: sysinfo: add new API to get max frequency for each CPU

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

Commit Message

hongbo.zhang@freescale.com Aug. 11, 2015, 7:33 a.m. UTC
From: Hongbo Zhang <hongbo.zhang@linaro.org>

Previous patch makes varible cpu_hz to array cpu_hz[] to contain data for
each CPU on AMP platforms, and then this patch adds new API 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 8f4d11b..36bc47f 100644
--- a/include/odp/api/cpu.h
+++ b/include/odp/api/cpu.h
@@ -51,6 +51,17 @@  int odp_cpu_count(void);
 uint64_t odp_cpu_hz_max(void);
 
 /**
+ * Maximum CPU frequency of a CPU (in Hz)
+ *
+ * Returns maximum frequency of the specified CPU
+ *
+ * @param id    CPU ID
+ *
+ * @return CPU frequency in Hz
+ */
+uint64_t odp_cpu_id_hz_max(int id);
+
+/**
  * CPU model name
  *
  * @return Pointer to CPU model name string
diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c
index a279061..55516d0 100644
--- a/platform/linux-generic/odp_system_info.c
+++ b/platform/linux-generic/odp_system_info.c
@@ -369,7 +369,15 @@  int odp_system_info_init(void)
  */
 uint64_t odp_cpu_hz_max(void)
 {
-	return odp_global_data.system_info.cpu_hz[0];
+	return odp_cpu_id_hz_max(0);
+}
+
+uint64_t odp_cpu_id_hz_max(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)