summaryrefslogtreecommitdiff
path: root/common/thermal_commands.c
blob: 4638b60ac3a087b7981cf5eed750e8fa77b973b1 (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 (c) 2012 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

/* Thermal engine host commands for Chrome EC */

#include "common.h"
#include "host_command.h"
#include "thermal.h"

int thermal_command_set_threshold(struct host_cmd_handler_args *args)
{
	const struct ec_params_thermal_set_threshold *p = args->params;

	if (thermal_set_threshold(p->sensor_type, p->threshold_id, p->value))
		return EC_RES_ERROR;

	return EC_RES_SUCCESS;
}
DECLARE_HOST_COMMAND(EC_CMD_THERMAL_SET_THRESHOLD,
		     thermal_command_set_threshold,
		     EC_VER_MASK(0));

int thermal_command_get_threshold(struct host_cmd_handler_args *args)
{
	const struct ec_params_thermal_get_threshold *p = args->params;
	struct ec_response_thermal_get_threshold *r = args->response;
	int value = thermal_get_threshold(p->sensor_type, p->threshold_id);

	if (value == -1)
		return EC_RES_ERROR;
	r->value = value;

	args->response_size = sizeof(*r);

	return EC_RES_SUCCESS;
}
DECLARE_HOST_COMMAND(EC_CMD_THERMAL_GET_THRESHOLD,
		     thermal_command_get_threshold,
		     EC_VER_MASK(0));

int thermal_command_auto_fan_ctrl(struct host_cmd_handler_args *args)
{
	if (thermal_toggle_auto_fan_ctrl(1))
		return EC_RES_ERROR;
	return EC_RES_SUCCESS;
}
DECLARE_HOST_COMMAND(EC_CMD_THERMAL_AUTO_FAN_CTRL,
		     thermal_command_auto_fan_ctrl,
		     EC_VER_MASK(0));