halapi: power: Add new thermal HAL API for cooling device of thermal 52/262152/1
authorChanwoo Choi <cw00.choi@samsung.com>
Mon, 2 Aug 2021 03:58:57 +0000 (12:58 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Mon, 2 Aug 2021 09:34:30 +0000 (18:34 +0900)
When over-temperature is meaused for h/w resource, must need to change
the state in order to down the temperature for preventing the dangerous
situation. So that add new thermal HAL API for cooling device of thermal
to change the state of h/w resource such as discharging the battery,
decrease the maximum freuqency of CPU/GPU/BUS and so on.

[Detailed new thermal HAL API]
int hal_power_thermal_set_cooling_device_state(unsigned int device_type,
char *cooling_device_name, int state);
int hal_power_thermal_get_cooling_device_state(unsigned int device_type,
char *cooling_device_name);
int hal_power_thermal_get_cooling_device_max_state(unsigned int device_type,
char *cooling_device_name);

Change-Id: I7cde3f47e607f2f92c87e6874ddb291e3b7bb99e
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
include/hal-power-interface.h
include/hal-power.h
src/hal-api-power.c

index 5f7c181dd8d3fbf07fe1dd5b2d85ad272f8b2d2d..47db319e9855ef507c0d8eb7f9c19ab23215ac6f 100644 (file)
@@ -76,6 +76,13 @@ struct pass_resource_tmu_ops {
 
        /* 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);
 };
 
 /*
index 80390d517141922b8e5cf4571ada3c32f7d4758a..5a656d6afde0b9c1ede325533c07809a1f8d28ae 100644 (file)
@@ -93,6 +93,13 @@ int hal_power_thermal_get_temp(unsigned int res_type, char *res_thermal_name);
 /* Get the policy of thermal management unit. */
 int hal_power_thermal_get_policy(unsigned int res_type, char *res_thermal_name, char *policy);
 
+/* Get and set the state of thermal cooling-device */
+int hal_power_thermal_set_cooling_device_state(unsigned int device_type, char *cooling_device_name, int state);
+int hal_power_thermal_get_cooling_device_state(unsigned int device_type, char *cooling_device_name);
+
+/* Get maximum state of thermal cooling-device */
+int hal_power_thermal_get_cooling_device_max_state(unsigned int device_type, char *cooling_device_name);
+
 /**
  * Memory Operation for Memory H/W
  */
index ba93186a72948d2cb0f66ced518d62be6f6e6efd..902445dfac2f60b0ab96f0ce5a6434aeec2b17af 100644 (file)
@@ -608,6 +608,83 @@ EXPORT int hal_power_thermal_get_policy(unsigned int res_type,
        return tmu->get_policy(res_thermal_name, policy);
 }
 
+/* Get and set the state of thermal cooling-device */
+EXPORT int hal_power_thermal_set_cooling_device_state(unsigned int device_type,
+                                                       char *cooling_device_name,
+                                                       int state)
+{
+       struct pass_resource_tmu_ops *tmu;
+
+       if (!g_power_funcs)
+               return -ENOTSUP;
+
+       if (!cooling_device_name || state < 0)
+               return -EINVAL;
+
+       tmu = get_tmu(g_power_funcs, device_type);
+       if (!tmu)
+               return -EPERM;
+
+       if (!tmu->set_cooling_device_state)
+               return -ENOTSUP;
+
+       /*
+        * In the case of the HAL TMU ops, cooling_device_name is used
+        * as the first argument instead of res_name.
+        */
+       return tmu->set_cooling_device_state(cooling_device_name, state);
+}
+
+EXPORT int hal_power_thermal_get_cooling_device_state(unsigned int device_type,
+                                                       char *cooling_device_name)
+{
+       struct pass_resource_tmu_ops *tmu;
+
+       if (!g_power_funcs)
+               return -ENOTSUP;
+
+       if (!cooling_device_name)
+               return -EINVAL;
+
+       tmu = get_tmu(g_power_funcs, device_type);
+       if (!tmu)
+               return -EPERM;
+
+       if (!tmu->get_cooling_device_state)
+               return -ENOTSUP;
+
+       /*
+        * In the case of the HAL TMU ops, cooling_device_name is used
+        * as the first argument instead of res_name.
+        */
+       return tmu->get_cooling_device_state(cooling_device_name);
+}
+
+EXPORT int hal_power_thermal_get_cooling_device_max_state(unsigned int device_type,
+                                                       char *cooling_device_name)
+{
+       struct pass_resource_tmu_ops *tmu;
+
+       if (!g_power_funcs)
+               return -ENOTSUP;
+
+       if (!cooling_device_name)
+               return -EINVAL;
+
+       tmu = get_tmu(g_power_funcs, device_type);
+       if (!tmu)
+               return -EPERM;
+
+       if (!tmu->get_cooling_device_max_state)
+               return -ENOTSUP;
+
+       /*
+        * In the case of the HAL TMU ops, cooling_device_name is used
+        * as the first argument instead of res_name.
+        */
+       return tmu->get_cooling_device_max_state(cooling_device_name);
+}
+
 /**
  * Memory Operation for Memory H/W
  */