pass-hal: tm1: Add get functions to cpu resource 88/139888/1
authorDongwoo Lee <dwoo08.lee@samsung.com>
Tue, 18 Jul 2017 05:04:58 +0000 (14:04 +0900)
committerDongwoo Lee <dwoo08.lee@samsung.com>
Fri, 21 Jul 2017 02:28:31 +0000 (11:28 +0900)
Currently, pass-hal-tm1 doesn't have get functions for min/max
frequency and min/max number of online cpu, and cannot get initial
state of cpu resource. However, they are necessary to support
save/restore feature. For this reason those functions are added.

Change-Id: I42e502bcdcf60fc1d39380455308d81cffa7ea0e
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
src/cpu/cpu.c

index 8ba05e5f1bbbb6bd6ddda92676591c6515dc84c3..439c9161c30525926cedb4bf543bba5aa3b1de08 100644 (file)
@@ -64,6 +64,26 @@ static int tm1_dvfs_get_curr_freq(char *res_name)
        return freq;
 }
 
+static int tm1_dvfs_get_min_freq(char *res_name)
+{
+       char path[PATH_MAX];
+       int min_freq;
+       int ret;
+
+       if (!res_name)
+               return -EINVAL;
+
+       snprintf(path, PATH_MAX, "%s%s",
+                CPUFREQ_PMQOS_PATH_PREFIX,
+                CPUFREQ_MIN_FREQ_PATH_SUFFIX);
+
+       ret = sysfs_read_int(path, &min_freq);
+       if (ret < 0)
+               return ret;
+
+       return min_freq;
+}
+
 static int tm1_dvfs_set_min_freq(char *res_name, int freq)
 {
        char path[PATH_MAX];
@@ -86,6 +106,26 @@ static int tm1_dvfs_set_min_freq(char *res_name, int freq)
        return 0;
 }
 
+static int tm1_dvfs_get_max_freq(char *res_name)
+{
+       char path[PATH_MAX];
+       int max_freq;
+       int ret;
+
+       if (!res_name)
+               return -EINVAL;
+
+       snprintf(path, PATH_MAX, "%s%s",
+                CPUFREQ_PMQOS_PATH_PREFIX,
+                CPUFREQ_MAX_FREQ_PATH_SUFFIX);
+
+       ret = sysfs_read_int(path, &max_freq);
+       if (ret < 0)
+               return ret;
+
+       return max_freq;
+}
+
 static int tm1_dvfs_set_max_freq(char *res_name, int freq)
 {
        char path[PATH_MAX];
@@ -113,15 +153,35 @@ static struct pass_resource_dvfs_ops tm1_cpu_dvfs_ops =  {
        .set_curr_governor = NULL,
        .get_avail_governor = NULL,
        .get_curr_freq = tm1_dvfs_get_curr_freq,
-       .get_min_freq = NULL,
+       .get_min_freq = tm1_dvfs_get_min_freq,
        .set_min_freq = tm1_dvfs_set_min_freq,
-       .get_max_freq = NULL,
+       .get_max_freq = tm1_dvfs_get_max_freq,
        .set_max_freq = tm1_dvfs_set_max_freq,
        .get_up_threshold = NULL,
        .set_up_threshold = NULL,
        .get_load_table = NULL,
 };
 
+static int tm1_hotplug_get_online_min_num(char *res_name)
+{
+       char path[PATH_MAX];
+       int online_min_num;
+       int ret;
+
+       if (!res_name)
+               return -EINVAL;
+
+       snprintf(path, PATH_MAX, "%s%s",
+               CPUFREQ_PMQOS_PATH_PREFIX,
+               CPUFREQ_CPU_ONLINE_MIN_NUM_PATH_SUFFIX);
+
+       ret = sysfs_read_int(path, &online_min_num);
+       if (ret < 0)
+               return ret;
+
+       return online_min_num;
+}
+
 static int tm1_hotplug_set_online_min_num(char *res_name, int num)
 {
        char path[PATH_MAX];
@@ -145,6 +205,26 @@ static int tm1_hotplug_set_online_min_num(char *res_name, int num)
        return 0;
 }
 
+static int tm1_hotplug_get_online_max_num(char *res_name)
+{
+       char path[PATH_MAX];
+       int online_max_num;
+       int ret;
+
+       if (!res_name)
+               return -EINVAL;
+
+       snprintf(path, PATH_MAX, "%s%s",
+               CPUFREQ_PMQOS_PATH_PREFIX,
+               CPUFREQ_CPU_ONLINE_MAX_NUM_PATH_SUFFIX);
+
+       ret = sysfs_read_int(path, &online_max_num);
+       if (ret < 0)
+               return ret;
+
+       return online_max_num;
+}
+
 static int tm1_hotplug_set_online_max_num(char *res_name, int num)
 {
        char path[PATH_MAX];
@@ -170,9 +250,9 @@ static int tm1_hotplug_set_online_max_num(char *res_name, int num)
 static struct pass_resource_hotplug_ops tm1_cpu_hotplug_ops = {
        .get_online_state = NULL,
        .set_online_state = NULL,
-       .get_online_min_num = NULL,
+       .get_online_min_num = tm1_hotplug_get_online_min_num,
        .set_online_min_num = tm1_hotplug_set_online_min_num,
-       .get_online_max_num = NULL,
+       .get_online_max_num = tm1_hotplug_get_online_max_num,
        .set_online_max_num = tm1_hotplug_set_online_max_num,
 };