summaryrefslogtreecommitdiff
path: root/zephyr/shim/src/thermal.c
blob: abe6b7da9e4955e48ac013f946f43f1031cf5233 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* Copyright 2021 The ChromiumOS Authors
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "temp_sensor.h"
#include "temp_sensor/temp_sensor.h"
#include "ec_commands.h"

#define THERMAL_CONFIG(node_id) \
	[TEMP_SENSOR_ID(node_id)] = {				\
		.temp_host = {						\
			[EC_TEMP_THRESH_WARN] =			\
			C_TO_K(DT_PROP_OR(node_id,			\
					  temp_host_warn,		\
					  -273)),			\
			[EC_TEMP_THRESH_HIGH] =			\
			C_TO_K(DT_PROP_OR(node_id,			\
					  temp_host_high,		\
					  -273)),			\
			[EC_TEMP_THRESH_HALT] =			\
			C_TO_K(DT_PROP_OR(node_id,			\
					  temp_host_halt,		\
					  -273)),			\
		},							\
		.temp_host_release = {					\
			[EC_TEMP_THRESH_WARN] = C_TO_K(		\
				DT_PROP_OR(node_id,			\
					   temp_host_release_warn,	\
					   -273)),			\
			[EC_TEMP_THRESH_HIGH] = C_TO_K(		\
				DT_PROP_OR(node_id,			\
					   temp_host_release_high,	\
					   -273)),			\
			[EC_TEMP_THRESH_HALT] = C_TO_K(		\
				DT_PROP_OR(node_id,			\
					   temp_host_release_halt,	\
					   -273)),			\
		},							\
		.temp_fan_off = C_TO_K(DT_PROP_OR(node_id,		\
						  temp_fan_off,	\
						  -273)),		\
		.temp_fan_max = C_TO_K(DT_PROP_OR(node_id,		\
						  temp_fan_max,	\
						  -273)),		\
	}

struct ec_thermal_config thermal_params[] = {
#if DT_HAS_COMPAT_STATUS_OKAY(TEMP_SENSORS_COMPAT)
	DT_FOREACH_CHILD_SEP(TEMP_SENSORS_NODEID, THERMAL_CONFIG, (, ))
#endif /* DT_HAS_COMPAT_STATUS_OKAY(TEMP_SENSORS_COMPAT) */
};