soc/intel/ptl: Update ME specification version to 21
[coreboot.git] / src / superio / fintek / common / fan_api_call.c
blob78d21788eca89db566ee16a103c8e5e54fe098db
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <console/console.h>
4 #include "fan_control.h"
6 static int check_status(int status)
8 if (status < HWM_STATUS_SUCCESS)
9 return status;
10 return HWM_STATUS_SUCCESS; /* positive values are warnings only */
13 int set_fan(struct fintek_fan *fan_init)
15 int s;
17 s = set_sensor_type(CONFIG_HWM_PORT, fan_init->sensor, fan_init->stype);
18 if (check_status(s) != HWM_STATUS_SUCCESS)
19 return s;
21 s = set_fan_temperature_source(CONFIG_HWM_PORT, fan_init->fan, fan_init->temp_source);
22 if (check_status(s) != HWM_STATUS_SUCCESS)
23 return s;
25 s = set_fan_type_mode(CONFIG_HWM_PORT, fan_init->fan, fan_init->ftype, fan_init->fmode);
26 if (check_status(s) != HWM_STATUS_SUCCESS)
27 return s;
29 s = set_pwm_frequency(CONFIG_HWM_PORT, fan_init->fan, fan_init->fan_freq);
30 if (check_status(s) != HWM_STATUS_SUCCESS)
31 return s;
33 s = set_fan_speed_change_rate(CONFIG_HWM_PORT, fan_init->fan, fan_init->rate_up,
34 fan_init->rate_down);
35 if (check_status(s) != HWM_STATUS_SUCCESS)
36 return s;
38 s = set_fan_follow(CONFIG_HWM_PORT, fan_init->fan, fan_init->follow);
39 if (check_status(s) != HWM_STATUS_SUCCESS)
40 return s;
42 s = set_sections(CONFIG_HWM_PORT, fan_init->fan, fan_init->boundaries,
43 fan_init->sections);
44 if (check_status(s) != HWM_STATUS_SUCCESS)
45 return s;
47 printk(BIOS_DEBUG, "Fan %d completed\n", fan_init->fan);
48 return HWM_STATUS_SUCCESS;