halapi: power: Add new PASS_RESOURCE_BATTER_ID for battery h/w 53/262153/1
authorChanwoo Choi <cw00.choi@samsung.com>
Mon, 2 Aug 2021 04:12:58 +0000 (13:12 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Mon, 2 Aug 2021 09:34:35 +0000 (18:34 +0900)
The battery h/w resource is very important in order to prevent
the dangerous situation such as fire, skin burn and so on.

So that it must need to monitor the temperature of battery
and then if over-temperature is detected, need to change
the battery status like discharging for decreasing the temperture
until safe tempeature.

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

index 47db319e9855ef507c0d8eb7f9c19ab23215ac6f..f40670b6460fd9772c357d6757f8935219815fa7 100644 (file)
@@ -130,6 +130,15 @@ struct pass_resource_memory {
        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).
+ */
+struct pass_resource_battery {
+       struct pass_resource_tmu_ops tmu;
+};
+
 /*
  * Define the resource structure for nonstandard H/W.
  *
@@ -157,6 +166,7 @@ typedef struct _hal_backend_power_funcs {
        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;
 
index 5a656d6afde0b9c1ede325533c07809a1f8d28ae..d3cc46278d550f629ccfc82beaba47a4bdfd8cd8 100644 (file)
@@ -28,12 +28,14 @@ extern "C" {
 #define PASS_RESOURCE_BUS_ID           2
 #define PASS_RESOURCE_GPU_ID           3
 #define PASS_RESOURCE_MEMORY_ID                4
+#define PASS_RESOURCE_BATTERY_ID       5
 #define PASS_RESOURCE_NONSTANDARD_ID   99
 
 #define PASS_RESOURCE_CPU_NAME         "cpu"
 #define PASS_RESOURCE_BUS_NAME         "bus"
 #define PASS_RESOURCE_GPU_NAME         "gpu"
 #define PASS_RESOURCE_MEMORY_NAME      "memory"
+#define PASS_RESOURCE_BATTERY_NAME     "battery"
 #define PASS_RESOURCE_NONSTANDARD_NAME "nonstandard"
 
 int hal_power_get_backend(unsigned int res_type);
index 902445dfac2f60b0ab96f0ce5a6434aeec2b17af..1248a1d4763c0577283ae46e2b114dd48bfc2b60 100644 (file)
@@ -52,6 +52,10 @@ static int is_supported_from_backend(hal_backend_power_funcs *funcs, int res_typ
                if (funcs && funcs->memory)
                        return 1;
                break;
+       case PASS_RESOURCE_BATTERY_ID:
+               if (funcs && funcs->battery)
+                       return 1;
+               break;
        case PASS_RESOURCE_NONSTANDARD_ID:
                if (funcs && funcs->nonstandard)
                        return 1;
@@ -102,6 +106,10 @@ static struct pass_resource_tmu_ops *get_tmu(hal_backend_power_funcs *funcs,
                if (funcs && funcs->gpu)
                        tmu = &(funcs->gpu->tmu);
                break;
+       case PASS_RESOURCE_BATTERY_ID:
+               if (funcs && funcs->battery)
+                       tmu = &(funcs->battery->tmu);
+               break;
        }
 
        return tmu;