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
)
10 return HWM_STATUS_SUCCESS
; /* positive values are warnings only */
13 int set_fan(struct fintek_fan
*fan_init
)
17 s
= set_sensor_type(CONFIG_HWM_PORT
, fan_init
->sensor
, fan_init
->stype
);
18 if (check_status(s
) != HWM_STATUS_SUCCESS
)
21 s
= set_fan_temperature_source(CONFIG_HWM_PORT
, fan_init
->fan
, fan_init
->temp_source
);
22 if (check_status(s
) != HWM_STATUS_SUCCESS
)
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
)
29 s
= set_pwm_frequency(CONFIG_HWM_PORT
, fan_init
->fan
, fan_init
->fan_freq
);
30 if (check_status(s
) != HWM_STATUS_SUCCESS
)
33 s
= set_fan_speed_change_rate(CONFIG_HWM_PORT
, fan_init
->fan
, fan_init
->rate_up
,
35 if (check_status(s
) != HWM_STATUS_SUCCESS
)
38 s
= set_fan_follow(CONFIG_HWM_PORT
, fan_init
->fan
, fan_init
->follow
);
39 if (check_status(s
) != HWM_STATUS_SUCCESS
)
42 s
= set_sections(CONFIG_HWM_PORT
, fan_init
->fan
, fan_init
->boundaries
,
44 if (check_status(s
) != HWM_STATUS_SUCCESS
)
47 printk(BIOS_DEBUG
, "Fan %d completed\n", fan_init
->fan
);
48 return HWM_STATUS_SUCCESS
;