• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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-845"
21 #include <log/log.h>
22 
23 #include <hardware/hardware.h>
24 #include <hardware/thermal.h>
25 #include "thermal_common.h"
26 
27 static char *cpu_sensors_845[] =
28 {
29     "cpu0-silver-usr",
30     "cpu1-silver-usr",
31     "cpu2-silver-usr",
32     "cpu3-silver-usr",
33     "cpu0-gold-usr",
34     "cpu1-gold-usr",
35     "cpu2-gold-usr",
36     "cpu3-gold-usr",
37 };
38 
39 static char *misc_sensors_845[] =
40 {
41     "gpu0-usr",
42     "battery",
43     "xo-therm-adc"
44 };
45 
46 static struct target_therm_cfg sensor_cfg_845[] = {
47     {
48         .type = DEVICE_TEMPERATURE_CPU,
49         .sensor_list = cpu_sensors_845,
50         .sens_cnt = ARRAY_SIZE(cpu_sensors_845),
51         .mult = 0.001,
52         .throt_thresh = 60,
53         .shutdwn_thresh = 115,
54     },
55     {
56         .type = DEVICE_TEMPERATURE_GPU,
57         .sensor_list = &misc_sensors_845[0],
58         .sens_cnt = 1,
59         .mult = 0.001,
60         .label = "GPU",
61     },
62     {
63         .type = DEVICE_TEMPERATURE_BATTERY,
64         .sensor_list = &misc_sensors_845[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_845[2],
73         .sens_cnt = 1,
74         .mult = 0.001,
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_845,
88                                 ARRAY_SIZE(sensor_cfg_845));
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