hal-power: Add support for HAL_MODULE_POWER v1.0 31/312931/1
authorChanwoo Choi <cw00.choi@samsung.com>
Mon, 17 Jun 2024 06:29:05 +0000 (15:29 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Mon, 17 Jun 2024 10:29:51 +0000 (19:29 +0900)
HAL_MODULE_POWER will support the multiple version of HAL interface.
So that v1.0 is first supported version of HAL_MODULE_POWER.
hal-power-interface-1.h contains the v1.0 HAL interface.

Change-Id: Ie77ca6146521d583b309e6b0b2c02bf2611ab7c4
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
include/hal-power-interface-1.h [new file with mode: 0644]
include/hal-power-interface.h

diff --git a/include/hal-power-interface-1.h b/include/hal-power-interface-1.h
new file mode 100644 (file)
index 0000000..1321fc6
--- /dev/null
@@ -0,0 +1,194 @@
+/*
+ * HAL (Hardware Abstract Layer) Power Interface
+ *
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __HAL_POWER_INTERFACE_1__
+#define __HAL_POWER_INTERFACE_1__
+
+#include <hal/hal-common-interface.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Define the ops (operations) structure which are used on specific resource.
+ */
+struct pass_resource_dvfs_ops {
+       /* Get and set the current governor. */
+       int (*get_curr_governor)(char *res_name, char *governor);
+       int (*set_curr_governor)(char *res_name, char *governor);
+
+       int (*get_avail_governor)(char *res_name, char **avail_governor);
+
+       /* Get the current frequency. */
+       int (*get_curr_freq)(char *res_name);
+
+       /* Get and set the minimum frequency. */
+       int (*get_min_freq)(char *res_name);
+       int (*set_min_freq)(char *res_name, int freq);
+
+       /* Get and set the maximum frequency. */
+       int (*get_max_freq)(char *res_name);
+       int (*set_max_freq)(char *res_name, int freq);
+
+       /* Get the minimum/maximum frequency which can be set to resource. */
+       int (*get_available_min_freq)(char *res_name);
+       int (*get_available_max_freq)(char *res_name);
+
+       /* Get and set the up_threshold to support boosting. */
+       int (*get_up_threshold)(char *res_name);
+       int (*set_up_threshold)(char *res_name, int up_threshold);
+
+       /* Get the load_table of each resource to estimate the system load. */
+       int (*get_load_table)(char *name, void *pass_cpu_load_table);
+};
+
+struct pass_resource_hotplug_ops {
+       /* Get and set the online status of resource. */
+       int (*get_online_state)(char *res_name, int cpu);
+       int (*set_online_state)(char *res_name, int cpu, int on);
+       /* Get and set the minimum number of online CPUs */
+       int (*get_online_min_num) (char *res_name);
+       int (*set_online_min_num) (char *res_name, int min_num);
+       /* Get and set the maximum number of online CPUs */
+       int (*get_online_max_num) (char *res_name);
+       int (*set_online_max_num) (char *res_name, int max_num);
+};
+
+struct pass_resource_tmu_ops {
+       /* Get the current temperature of resource. */
+       int (*get_temp)(char *res_thermal_name);
+
+       /* Get the policy of thermal management unit. */
+       int (*get_policy)(char *res_thermal_name, char *policy);
+
+       /* Get and set the state of thermal cooling-device */
+       int (*set_cooling_device_state)(char *coolign_device_name, int state);
+       int (*get_cooling_device_state)(char *cooling_device_name);
+
+       /* Get the maximum state of thermal cooling-device */
+       int (*get_cooling_device_max_state)(char *cooling_device_name);
+};
+
+struct pass_resource_battery_ops {
+       /* Get and set the state of batterh charging */
+       int (*set_charging_status)(char *res_name, int state);
+       int (*get_charging_status)(char *res_name);
+
+       /* Get and set the battery charging current (unit: uA) */
+       int (*set_charging_current)(char *res_name, int charing_current_uA);
+       int (*get_charging_current)(char *res_name);
+};
+
+/*
+ * Define the resource structure for CPU H/W.
+ *
+ * @dvfs       : function lists for the DVFS (Dynamic Volt. & Freq. Scaling).
+ * @tmu                : function lists for the TMU (Thermal Management Unit).
+ * @hotplug    : function lists for the CPU on/off.
+ */
+struct pass_resource_cpu {
+       struct pass_resource_dvfs_ops dvfs;
+       struct pass_resource_tmu_ops tmu;
+       struct pass_resource_hotplug_ops hotplug;
+};
+
+/*
+ * Define the resource structure for Memory Bus H/W.
+ *
+ * @dvfs       : function lists for the DVFS (Dynamic Volt. & Freq. Scaling).
+ * @tmu                : function lists for the TMU (Thermal Management Unit).
+ */
+struct pass_resource_bus {
+       struct pass_resource_dvfs_ops dvfs;
+       struct pass_resource_tmu_ops tmu;
+};
+
+/*
+ * Define the resource structure for GPU H/W.
+ *
+ * @dvfs       : function lists for the DVFS (Dynamic Volt. & Freq. Scaling).
+ * @tmu                : function lists for the TMU (Thermal Management Unit).
+ */
+struct pass_resource_gpu {
+       struct pass_resource_dvfs_ops dvfs;
+       struct pass_resource_tmu_ops tmu;
+};
+
+/*
+ * Define the resource structure for Memory H/W.
+ *
+ */
+struct pass_resource_memory {
+       /* Get and set the /sys/kernel/debug/fault_around_bytes */
+       int (*get_fault_around_bytes)(char *res_name);
+       int (*set_fault_around_bytes)(char *res_name, int fault_around_bytes);
+};
+
+/*
+ * Define the resource structure for Battery H/W.
+ *
+ * @tmu                : function lists for the TMU (Thermal Management Unit).
+ * @battery    : function lists for the battery charging.
+ */
+struct pass_resource_battery {
+       struct pass_resource_tmu_ops tmu;
+       struct pass_resource_battery_ops battery;
+};
+
+/*
+ * Define the resource structure for nonstandard H/W.
+ *
+ * @tmu                : function lists for the TMU (Thermal Management Unit).
+ * @battery    : function lists for the battery charging.
+ *
+ * Following function is Deprecated. (Not recommended for use)
+ * @set_pmqos_data : function to bypass the scenario data to HAL.
+ *
+ * This structure indicates the nonstandard H/W which doesn't have
+ * the official supported framework (e.g., cpufreq, devfreq and so on)
+ * in Linux Kernel. But, the specific device might be controlled
+ * according to PMQoS scenario or other cases.
+ */
+struct pass_resource_nonstandard {
+       struct pass_resource_tmu_ops tmu;
+       struct pass_resource_battery_ops battery;
+
+       /*
+        * NOTE: It is not propper method. But PASS must need to keep
+        * the backwards compatibility, set the PMQoS's data from
+        * platform to hal. So, It is not recommended to use it.
+        *
+        * This function will be removed after finding the proper method.
+        */
+       int (*set_pmqos_data)(char *res_name, void *data);
+};
+
+typedef struct _hal_backend_power_funcs {
+       struct pass_resource_cpu *cpu;
+       struct pass_resource_bus *bus;
+       struct pass_resource_gpu *gpu;
+       struct pass_resource_memory *memory;
+       struct pass_resource_battery *battery;
+       struct pass_resource_nonstandard *nonstandard;
+} hal_backend_power_funcs;
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __HAL_POWER_INTERFACE_1__ */
index 1b5b57fbbdf08fee0578b6fc69ad0e927840bef8..3b7f4c2edf4e4d495e17a8ed5194fd32a76255be 100644 (file)
 #ifndef __HAL_POWER_INTERFACE__
 #define __HAL_POWER_INTERFACE__
 
-#include <hal/hal-common-interface.h>
+#include "hal-power-interface-1.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Define the ops (operations) structure which are used on specific resource.
- */
-struct pass_resource_dvfs_ops {
-       /* Get and set the current governor. */
-       int (*get_curr_governor)(char *res_name, char *governor);
-       int (*set_curr_governor)(char *res_name, char *governor);
-
-       int (*get_avail_governor)(char *res_name, char **avail_governor);
-
-       /* Get the current frequency. */
-       int (*get_curr_freq)(char *res_name);
-
-       /* Get and set the minimum frequency. */
-       int (*get_min_freq)(char *res_name);
-       int (*set_min_freq)(char *res_name, int freq);
-
-       /* Get and set the maximum frequency. */
-       int (*get_max_freq)(char *res_name);
-       int (*set_max_freq)(char *res_name, int freq);
-
-       /* Get the minimum/maximum frequency which can be set to resource. */
-       int (*get_available_min_freq)(char *res_name);
-       int (*get_available_max_freq)(char *res_name);
-
-       /* Get and set the up_threshold to support boosting. */
-       int (*get_up_threshold)(char *res_name);
-       int (*set_up_threshold)(char *res_name, int up_threshold);
-
-       /* Get the load_table of each resource to estimate the system load. */
-       int (*get_load_table)(char *name, void *pass_cpu_load_table);
-};
-
-struct pass_resource_hotplug_ops {
-       /* Get and set the online status of resource. */
-       int (*get_online_state)(char *res_name, int cpu);
-       int (*set_online_state)(char *res_name, int cpu, int on);
-       /* Get and set the minimum number of online CPUs */
-       int (*get_online_min_num) (char *res_name);
-       int (*set_online_min_num) (char *res_name, int min_num);
-       /* Get and set the maximum number of online CPUs */
-       int (*get_online_max_num) (char *res_name);
-       int (*set_online_max_num) (char *res_name, int max_num);
-};
-
-struct pass_resource_tmu_ops {
-       /* Get the current temperature of resource. */
-       int (*get_temp)(char *res_thermal_name);
-
-       /* Get the policy of thermal management unit. */
-       int (*get_policy)(char *res_thermal_name, char *policy);
-
-       /* Get and set the state of thermal cooling-device */
-       int (*set_cooling_device_state)(char *coolign_device_name, int state);
-       int (*get_cooling_device_state)(char *cooling_device_name);
-
-       /* Get the maximum state of thermal cooling-device */
-       int (*get_cooling_device_max_state)(char *cooling_device_name);
-};
-
-struct pass_resource_battery_ops {
-       /* Get and set the state of batterh charging */
-       int (*set_charging_status)(char *res_name, int state);
-       int (*get_charging_status)(char *res_name);
-
-       /* Get and set the battery charging current (unit: uA) */
-       int (*set_charging_current)(char *res_name, int charing_current_uA);
-       int (*get_charging_current)(char *res_name);
-};
-
-/*
- * Define the resource structure for CPU H/W.
- *
- * @dvfs       : function lists for the DVFS (Dynamic Volt. & Freq. Scaling).
- * @tmu                : function lists for the TMU (Thermal Management Unit).
- * @hotplug    : function lists for the CPU on/off.
- */
-struct pass_resource_cpu {
-       struct pass_resource_dvfs_ops dvfs;
-       struct pass_resource_tmu_ops tmu;
-       struct pass_resource_hotplug_ops hotplug;
-};
-
-/*
- * Define the resource structure for Memory Bus H/W.
- *
- * @dvfs       : function lists for the DVFS (Dynamic Volt. & Freq. Scaling).
- * @tmu                : function lists for the TMU (Thermal Management Unit).
- */
-struct pass_resource_bus {
-       struct pass_resource_dvfs_ops dvfs;
-       struct pass_resource_tmu_ops tmu;
-};
-
-/*
- * Define the resource structure for GPU H/W.
- *
- * @dvfs       : function lists for the DVFS (Dynamic Volt. & Freq. Scaling).
- * @tmu                : function lists for the TMU (Thermal Management Unit).
- */
-struct pass_resource_gpu {
-       struct pass_resource_dvfs_ops dvfs;
-       struct pass_resource_tmu_ops tmu;
-};
-
-/*
- * Define the resource structure for Memory H/W.
- *
- */
-struct pass_resource_memory {
-       /* Get and set the /sys/kernel/debug/fault_around_bytes */
-       int (*get_fault_around_bytes)(char *res_name);
-       int (*set_fault_around_bytes)(char *res_name, int fault_around_bytes);
-};
-
-/*
- * Define the resource structure for Battery H/W.
- *
- * @tmu                : function lists for the TMU (Thermal Management Unit).
- * @battery    : function lists for the battery charging.
- */
-struct pass_resource_battery {
-       struct pass_resource_tmu_ops tmu;
-       struct pass_resource_battery_ops battery;
-};
-
-/*
- * Define the resource structure for nonstandard H/W.
- *
- * @tmu                : function lists for the TMU (Thermal Management Unit).
- * @battery    : function lists for the battery charging.
- *
- * Following function is Deprecated. (Not recommended for use)
- * @set_pmqos_data : function to bypass the scenario data to HAL.
- *
- * This structure indicates the nonstandard H/W which doesn't have
- * the official supported framework (e.g., cpufreq, devfreq and so on)
- * in Linux Kernel. But, the specific device might be controlled
- * according to PMQoS scenario or other cases.
- */
-struct pass_resource_nonstandard {
-       struct pass_resource_tmu_ops tmu;
-       struct pass_resource_battery_ops battery;
-
-       /*
-        * NOTE: It is not propper method. But PASS must need to keep
-        * the backwards compatibility, set the PMQoS's data from
-        * platform to hal. So, It is not recommended to use it.
-        *
-        * This function will be removed after finding the proper method.
-        */
-       int (*set_pmqos_data)(char *res_name, void *data);
-};
-
-typedef struct _hal_backend_power_funcs {
-       struct pass_resource_cpu *cpu;
-       struct pass_resource_bus *bus;
-       struct pass_resource_gpu *gpu;
-       struct pass_resource_memory *memory;
-       struct pass_resource_battery *battery;
-       struct pass_resource_nonstandard *nonstandard;
-} hal_backend_power_funcs;
-
-#ifdef __cplusplus
-}
-#endif
 #endif /* __HAL_POWER_INTERFACE__ */