1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #ifndef SUPERIO_FINTEK_FAN_CONTROL_H
4 #define SUPERIO_FINTEK_FAN_CONTROL_H
17 TEMP_SENSOR_THERMISTOR
= 0,
23 FAN_TYPE_PWM_PUSH_PULL
= 0,
25 FAN_TYPE_PWM_OPEN_DRAIN
,
28 #define FAN_TYPE_PWM_CHECK 1 /* bit 0 must be 0 for PWM */
31 FAN_MODE_AUTO_RPM
= 0,
32 FAN_MODE_AUTO_PWM_DAC
,
34 FAN_MODE_MANUAL_PWM_DAC
,
39 FAN_PWM_FREQ_23500
= 0,
63 FAN_DOWN_RATE_2HZ
= 0,
67 FAN_DOWN_RATE_DEFAULT
,
68 FAN_DOWN_RATE_SAME_AS_UP
,
69 FAN_DOWN_RATE_JUMP
= 8
74 FAN_FOLLOW_INTERPOLATION
79 external_sensor sensor
;
80 temp_sensor_type stype
;
81 fan_temp_source temp_source
;
84 fan_pwm_freq fan_freq
;
86 fan_rate_down rate_down
;
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
107 #define CPU_DAMAGE_TEMP 110
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].
113 #define FINTEK_BOUNDARIES_SIZE 4
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].
121 #define FINTEK_SECTIONS_SIZE 5
124 * When using external sensor, its type must be defined. When using PECI,
125 * TSI or MXM use IGNORE_SENSOR to indicate so.
127 int set_sensor_type(u16 base_address
, external_sensor sensor
,
128 temp_sensor_type type
);
131 * Define the temperature source used to control a fan.
133 int set_fan_temperature_source(u16 base_address
, u8 fan
,
134 fan_temp_source source
);
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).
142 int set_fan_type_mode(u16 base_address
, u8 fan
, fan_type type
, fan_mode mode
);
145 * For fans controlled through pulse width, define the base frequency used.
147 int set_pwm_frequency(u16 base_address
, u8 fan
, fan_pwm_freq frequency
);
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
156 int set_sections(u16 base_address
, u8 fan
, u8
*boundaries
, u8
*sections
);
159 * Define how often temperature is measured to change fan speed.
161 int set_fan_speed_change_rate(u16 base_address
, u8 fan
, fan_rate_up rate_up
,
162 fan_rate_down rate_down
);
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.
174 int set_fan_follow(u16 base_address
, u8 fan
, fan_follow follow
);
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.
182 int set_fan(struct fintek_fan
*fan_init
);
184 #endif /* SUPERIO_FINTEK_FAN_CONTROL_H */