1 /*
2 * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
3 * Not a contribution
4 * Copyright (C) 2016 The Android Open Source Project
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19
20 #define LOG_TAG "ThermalHAL-8998"
21 #include <utils/Log.h>
22
23 #include <hardware/hardware.h>
24 #include <hardware/thermal.h>
25 #include "thermal_common.h"
26
27 static char *cpu_sensors_8998[] =
28 {
29 "tsens_tz_sensor1",
30 "tsens_tz_sensor2",
31 "tsens_tz_sensor3",
32 "tsens_tz_sensor4",
33 "tsens_tz_sensor7",
34 "tsens_tz_sensor8",
35 "tsens_tz_sensor9",
36 "tsens_tz_sensor10",
37 };
38
39 static char *misc_sensors_8998[] =
40 {
41 "tsens_tz_sensor12",
42 "battery",
43 "quiet_therm"
44 };
45
46 static struct target_therm_cfg sensor_cfg_8998[] = {
47 {
48 .type = DEVICE_TEMPERATURE_CPU,
49 .sensor_list = cpu_sensors_8998,
50 .sens_cnt = ARRAY_SIZE(cpu_sensors_8998),
51 .mult = 0.1,
52 .throt_thresh = 60,
53 .shutdwn_thresh = 115,
54 },
55 {
56 .type = DEVICE_TEMPERATURE_GPU,
57 .sensor_list = &misc_sensors_8998[0],
58 .sens_cnt = 1,
59 .mult = 0.1,
60 .label = "GPU",
61 },
62 {
63 .type = DEVICE_TEMPERATURE_BATTERY,
64 .sensor_list = &misc_sensors_8998[1],
65 .sens_cnt = 1,
66 .mult = 0.001,
67 .shutdwn_thresh = 60,
68 .label = "battery",
69 },
70 {
71 .type = DEVICE_TEMPERATURE_SKIN,
72 .sensor_list = &misc_sensors_8998[2],
73 .sens_cnt = 1,
74 .mult = 1.0,
75 .throt_thresh = 44,
76 .shutdwn_thresh = 70,
77 .vr_thresh = 58,
78 .label = "skin",
79 }
80 };
81
get_temperatures(thermal_module_t * module,temperature_t * list,size_t size)82 ssize_t get_temperatures(thermal_module_t *module, temperature_t *list, size_t size) {
83 ALOGD("Entering %s",__func__);
84 static int thermal_sens_size;
85
86 if (!thermal_sens_size) {
87 thermal_sens_size = thermal_zone_init(sensor_cfg_8998,
88 ARRAY_SIZE(sensor_cfg_8998));
89 if (thermal_sens_size <= 0) {
90 ALOGE("thermal sensor initialization is failed\n");
91 thermal_sens_size = 0;
92 return 0;
93 }
94 }
95
96 if (list == NULL)
97 return thermal_sens_size;
98
99 return get_temperature_for_all(list, size);
100 }
101