coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
fan_control.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef SUPERIO_FINTEK_FAN_CONTROL_H
4 #define SUPERIO_FINTEK_FAN_CONTROL_H
5 
6 #include <stdint.h>
7 
8 typedef enum {
15 
16 typedef enum {
21 
22 typedef enum {
28 #define FAN_TYPE_PWM_CHECK 1 /* bit 0 must be 0 for PWM */
29 
30 typedef enum {
37 
38 typedef enum {
44 
45 typedef enum {
52 
53 typedef enum {
61 
62 typedef enum {
71 
72 typedef enum {
76 
77 struct fintek_fan {
90 };
91 
92 #define HWM_STATUS_SUCCESS 0
93 #define HWM_STATUS_INVALID_FAN -1
94 #define HWM_STATUS_INVALID_TEMP_SOURCE -2
95 #define HWM_STATUS_INVALID_TYPE -3
96 #define HWM_STATUS_INVALID_MODE -4
97 #define HWM_STATUS_INVALID_RATE -5
98 #define HWM_STATUS_INVALID_FREQUENCY -6
99 #define HWM_STATUS_INVALID_TEMP_SENSOR -7
100 #define HWM_STATUS_INVALID_BOUNDARY_VALUE -8
101 #define HWM_STATUS_INVALID_SECTION_VALUE -9
102 #define HWM_STATUS_BOUNDARY_WRONG_ORDER -10
103 #define HWM_STATUS_SECTIONS_WRONG_ORDER -11
104 #define HWM_STATUS_WARNING_SENSOR_DISCONNECTED 1
105 #define HWM_STATUS_WARNING_FAN_NOT_PWM 2
106 
107 #define CPU_DAMAGE_TEMP 110
108 
109 /*
110  * Boundaries order is from highest temp. to lowest. Values from 0 to 127.
111  * Boundaries should be defined as u8 boundaries[FINTEK_BOUNDARIES_SIZE].
112  */
113 #define FINTEK_BOUNDARIES_SIZE 4
114 /*
115  * Section defines the duty_cycle/voltage to be used based on where the
116  * temperature lies with respect to the boundaries. There are 5 sections
117  * (4 boundaries) and the order must be from highest to lowest. Values
118  * from 0% to 100%, will be converted internally to percent of 255.
119  * Sections should be defined as u8 sections[FINTEK_SECTIONS_SIZE].
120  */
121 #define FINTEK_SECTIONS_SIZE 5
122 
123 /*
124  * When using external sensor, its type must be defined. When using PECI,
125  * TSI or MXM use IGNORE_SENSOR to indicate so.
126  */
127 int set_sensor_type(u16 base_address, external_sensor sensor,
129 
130 /*
131  * Define the temperature source used to control a fan.
132  */
133 int set_fan_temperature_source(u16 base_address, u8 fan,
134  fan_temp_source source);
135 
136 /*
137  * Define if fan is controlled through PWM or absolute voltage powering it
138  * (DAC). Then, under mode, define if control is automatic (SIO) or manual
139  * (CPU, through ACPI). Notice there needs to be a match between type and
140  * mode (PWM with PWM or DAC with DAC).
141  */
142 int set_fan_type_mode(u16 base_address, u8 fan, fan_type type, fan_mode mode);
143 
144 /*
145  * For fans controlled through pulse width, define the base frequency used.
146  */
147 int set_pwm_frequency(u16 base_address, u8 fan, fan_pwm_freq frequency);
148 
149 /*
150  * For fintek SIO HWM there are 4 (temperature) boundaries points, defining
151  * 5 sections (1 fan speed per section). Start with the highest temperature/
152  * speed. Temperature is in Celsius, speed is in percentile of max speed. The
153  * highest speed should be 100%, no requirements for minimum speed, could be
154  * 0 or above 0.
155  */
156 int set_sections(u16 base_address, u8 fan, u8 *boundaries, u8 *sections);
157 
158 /*
159  * Define how often temperature is measured to change fan speed.
160  */
161 int set_fan_speed_change_rate(u16 base_address, u8 fan, fan_rate_up rate_up,
162  fan_rate_down rate_down);
163 
164 /*
165  * There a 2 ways a fan can be controlled: A single speed per section, or
166  * interpolation. Under interpolation, the section speed is the speed at the
167  * lowest temperature of the section (0 Celsius for the lowest section), and
168  * it's the speed of the next section at the boundary to the next section.
169  * In between these 2 points, it's a linear function. For example, midway
170  * between temperature points it'll have a speed that is midway between the
171  * section speed and next section speed. Obviously, there's no variation for
172  * the highest section, reason why it must be 100% max speed.
173  */
174 int set_fan_follow(u16 base_address, u8 fan, fan_follow follow);
175 
176 /*
177  * This is an upper level API which calls all the above APIs in the
178  * appropriate order. Any API failure will be displayed. Alerts will
179  * also be displayed, but will not interrupt the sequence, while errors
180  * will interrupt the sequence.
181  */
182 int set_fan(struct fintek_fan *fan_init);
183 
184 #endif /* SUPERIO_FINTEK_FAN_CONTROL_H */
int set_sections(u16 base_address, u8 fan, u8 *boundaries, u8 *sections)
Definition: fan_control.c:250
fan_type
Definition: fan_control.h:22
@ FAN_TYPE_RESERVED
Definition: fan_control.h:26
@ FAN_TYPE_PWM_OPEN_DRAIN
Definition: fan_control.h:25
@ FAN_TYPE_PWM_PUSH_PULL
Definition: fan_control.h:23
@ FAN_TYPE_DAC_POWER
Definition: fan_control.h:24
int set_fan(struct fintek_fan *fan_init)
Definition: fan_api_call.c:13
int set_fan_speed_change_rate(u16 base_address, u8 fan, fan_rate_up rate_up, fan_rate_down rate_down)
Definition: fan_control.c:291
fan_pwm_freq
Definition: fan_control.h:38
@ FAN_PWM_FREQ_11750
Definition: fan_control.h:40
@ FAN_PWM_FREQ_5875
Definition: fan_control.h:41
@ FAN_PWM_FREQ_220
Definition: fan_control.h:42
@ FAN_PWM_FREQ_23500
Definition: fan_control.h:39
fan_follow
Definition: fan_control.h:72
@ FAN_FOLLOW_STEP
Definition: fan_control.h:73
@ FAN_FOLLOW_INTERPOLATION
Definition: fan_control.h:74
fan_rate_down
Definition: fan_control.h:62
@ FAN_DOWN_RATE_20HZ
Definition: fan_control.h:66
@ FAN_DOWN_RATE_5HZ
Definition: fan_control.h:64
@ FAN_DOWN_RATE_SAME_AS_UP
Definition: fan_control.h:68
@ FAN_DOWN_RATE_DEFAULT
Definition: fan_control.h:67
@ FAN_DOWN_RATE_10HZ
Definition: fan_control.h:65
@ FAN_DOWN_RATE_JUMP
Definition: fan_control.h:69
@ FAN_DOWN_RATE_2HZ
Definition: fan_control.h:63
external_sensor
Definition: fan_control.h:8
@ IGNORE_SENSOR
Definition: fan_control.h:9
@ EXTERNAL_SENSOR1
Definition: fan_control.h:10
@ EXTERNAL_SENSOR3
Definition: fan_control.h:12
@ EXTERNAL_SENSOR4
Definition: fan_control.h:13
@ EXTERNAL_SENSOR2
Definition: fan_control.h:11
int set_pwm_frequency(u16 base_address, u8 fan, fan_pwm_freq frequency)
Definition: fan_control.c:224
fan_rate_up
Definition: fan_control.h:53
@ FAN_UP_RATE_10HZ
Definition: fan_control.h:56
@ FAN_UP_RATE_JUMP
Definition: fan_control.h:59
@ FAN_UP_RATE_DEFAULT
Definition: fan_control.h:58
@ FAN_UP_RATE_5HZ
Definition: fan_control.h:55
@ FAN_UP_RATE_2HZ
Definition: fan_control.h:54
@ FAN_UP_RATE_20HZ
Definition: fan_control.h:57
temp_sensor_type
Definition: fan_control.h:16
@ TEMP_SENSOR_THERMISTOR
Definition: fan_control.h:17
@ TEMP_SENSOR_DEFAULT
Definition: fan_control.h:19
@ TEMP_SENSOR_BJT
Definition: fan_control.h:18
int set_fan_temperature_source(u16 base_address, u8 fan, fan_temp_source source)
Definition: fan_control.c:170
fan_mode
Definition: fan_control.h:30
@ FAN_MODE_AUTO_PWM_DAC
Definition: fan_control.h:32
@ FAN_MODE_MANUAL_PWM_DAC
Definition: fan_control.h:34
@ FAN_MODE_MANUAL_RPM
Definition: fan_control.h:33
@ FAN_MODE_DEFAULT
Definition: fan_control.h:35
@ FAN_MODE_AUTO_RPM
Definition: fan_control.h:31
int set_fan_type_mode(u16 base_address, u8 fan, fan_type type, fan_mode mode)
Definition: fan_control.c:203
fan_temp_source
Definition: fan_control.h:45
@ FAN_TEMP_MXM
Definition: fan_control.h:50
@ FAN_TEMP_EXTERNAL_2
Definition: fan_control.h:48
@ FAN_TEMP_EXTERNAL_1
Definition: fan_control.h:47
@ FAN_TEMP_PECI
Definition: fan_control.h:46
@ FAN_TEMP_TSI
Definition: fan_control.h:49
int set_sensor_type(u16 base_address, external_sensor sensor, temp_sensor_type type)
Definition: fan_control.c:139
int set_fan_follow(u16 base_address, u8 fan, fan_follow follow)
Definition: fan_control.c:338
unsigned int type
Definition: edid.c:57
uint16_t u16
Definition: stdint.h:48
uint8_t u8
Definition: stdint.h:45
unsigned char uint8_t
Definition: stdint.h:8
temp_sensor_type stype
Definition: fan_control.h:80
uint8_t * sections
Definition: fan_control.h:89
fan_temp_source temp_source
Definition: fan_control.h:81
external_sensor sensor
Definition: fan_control.h:79
fan_rate_down rate_down
Definition: fan_control.h:86
uint8_t fan
Definition: fan_control.h:78
fan_pwm_freq fan_freq
Definition: fan_control.h:84
fan_rate_up rate_up
Definition: fan_control.h:85
fan_mode fmode
Definition: fan_control.h:83
fan_follow follow
Definition: fan_control.h:87
uint8_t * boundaries
Definition: fan_control.h:88
fan_type ftype
Definition: fan_control.h:82