| 1 |
|
| 2 |
|
| 3 |
#ifndef SUPERIO_NUVOTON_NCT6687D_CHIP_H |
| 4 |
#define SUPERIO_NUVOTON_NCT6687D_CHIP_H |
| 5 |
|
| 6 |
#include <stdbool.h> |
| 7 |
|
| 8 |
#define MAX_TEMP_SPEED_LEVELS 7 |
| 9 |
#define MAX_TEMP_SRC 4 |
| 10 |
#define MAX_NUM_FANS 10 |
| 11 |
#define MAX_NUM_SENSORS 32 |
| 12 |
#define MAX_WEIGHT_POINTS 8 |
| 13 |
#define MAX_DTS_CTL_POINTS 5 |
| 14 |
|
| 15 |
enum nct6687d_sensor_src_select { |
| 16 |
|
| 17 |
SENSOR_DISABLE = 0x00, |
| 18 |
SENSOR_LOCAL = 0x01, |
| 19 |
TD0P_CURRENT_MODE = 0x02, |
| 20 |
TD1P_CURRENT_MODE = 0x03, |
| 21 |
TD2P_CURRENT_MODE = 0x04, |
| 22 |
TD0P_VOLTAGE_MODE = 0x05, |
| 23 |
TD1P_VOLTAGE_MODE = 0x06, |
| 24 |
TD2P_VOLTAGE_MODE = 0x07, |
| 25 |
THERMISTOR14 = 0x08, |
| 26 |
THERMISTOR15 = 0x09, |
| 27 |
THERMISTOR16 = 0x0A, |
| 28 |
THERMISTOR0 = 0x0B, |
| 29 |
THERMISTOR1 = 0x0C, |
| 30 |
THERMISTOR2 = 0x0D, |
| 31 |
THERMISTOR3 = 0x0E, |
| 32 |
THERMISTOR4 = 0x0F, |
| 33 |
THERMISTOR5 = 0x10, |
| 34 |
THERMISTOR6 = 0x11, |
| 35 |
THERMISTOR7 = 0x12, |
| 36 |
THERMISTOR8 = 0x13, |
| 37 |
THERMISTOR9 = 0x14, |
| 38 |
THERMISTOR10 = 0x15, |
| 39 |
THERMISTOR11 = 0x16, |
| 40 |
THERMISTOR12 = 0x17, |
| 41 |
THERMISTOR13 = 0x18, |
| 42 |
PECI_AGENT0_DOMAIN0 = 0x20, |
| 43 |
PECI_AGENT1_DOMAIN0 = 0x21, |
| 44 |
PECI_AGENT2_DOMAIN0 = 0x22, |
| 45 |
PECI_AGENT3_DOMAIN0 = 0x23, |
| 46 |
PECI_AGENT0_DOMAIN1 = 0x24, |
| 47 |
PECI_AGENT1_DOMAIN1 = 0x25, |
| 48 |
PECI_AGENT2_DOMAIN1 = 0x26, |
| 49 |
PECI_AGENT3_DOMAIN1 = 0x27, |
| 50 |
PECI_DIMM_TMP0 = 0x28, |
| 51 |
PECI_DIMM_TMP1 = 0x29, |
| 52 |
PECI_DIMM_TMP2 = 0x2A, |
| 53 |
PECI_DIMM_TMP3 = 0x2B, |
| 54 |
PCH_CPU = 0x30, |
| 55 |
PCH_CHIP = 0x31, |
| 56 |
PCH_CHIP_CPU_MAX = 0x32, |
| 57 |
PCH_MCH = 0x33, |
| 58 |
PCH_DIMM0 = 0x34, |
| 59 |
PCH_DIMM1 = 0x35, |
| 60 |
PCH_DIMM2 = 0x36, |
| 61 |
PCH_DIMM3 = 0x37, |
| 62 |
SMBUS_THERMAL_SENSOR0 = 0x38, |
| 63 |
SMBUS_THERMAL_SENSOR1 = 0x39, |
| 64 |
SMBUS_THERMAL_SENSOR2 = 0x3A, |
| 65 |
SMBUS_THERMAL_SENSOR3 = 0x3B, |
| 66 |
SMBUS_THERMAL_SENSOR4 = 0x3C, |
| 67 |
SMBUS_THERMAL_SENSOR5 = 0x3D, |
| 68 |
DIMM_THERMAL_SENSOR0 = 0x3E, |
| 69 |
DIMM_THERMAL_SENSOR1 = 0x3F, |
| 70 |
DIMM_THERMAL_SENSOR2 = 0x40, |
| 71 |
DIMM_THERMAL_SENSOR3 = 0x41, |
| 72 |
AMD_TSI_ADDRESS_0x90 = 0x42, |
| 73 |
AMD_TSI_ADDRESS_0x92 = 0x43, |
| 74 |
AMD_TSI_ADDRESS_0x94 = 0x44, |
| 75 |
AMD_TSI_ADDRESS_0x96 = 0x45, |
| 76 |
AMD_TSI_ADDRESS_0x98 = 0x46, |
| 77 |
AMD_TSI_ADDRESS_0x9A = 0x47, |
| 78 |
AMD_TSI_ADDRESS_0x9C = 0x48, |
| 79 |
AMD_TSI_ADDRESS_0x9D = 0x49, |
| 80 |
VIRTUAL_TEMPIN0 = 0x50, |
| 81 |
VIRTUAL_TEMPIN1 = 0x51, |
| 82 |
VIRTUAL_TEMPIN2 = 0x52, |
| 83 |
VIRTUAL_TEMPIN3 = 0x53, |
| 84 |
VIRTUAL_TEMPIN4 = 0x54, |
| 85 |
VIRTUAL_TEMPIN5 = 0x55, |
| 86 |
VIRTUAL_TEMPIN6 = 0x56, |
| 87 |
VIRTUAL_TEMPIN7 = 0x57, |
| 88 |
|
| 89 |
VCC = 0x60, |
| 90 |
VSB = 0x61, |
| 91 |
AVSB = 0x62, |
| 92 |
VTT = 0x63, |
| 93 |
VBAT = 0x64, |
| 94 |
VREF = 0x65, |
| 95 |
VIN0 = 0x66, |
| 96 |
VIN1 = 0x67, |
| 97 |
VIN2 = 0x68, |
| 98 |
VIN3 = 0x69, |
| 99 |
VIN4 = 0x6A, |
| 100 |
VIN5 = 0x6B, |
| 101 |
VIN6 = 0x6C, |
| 102 |
VIN7 = 0x6D, |
| 103 |
VIN8 = 0x6E, |
| 104 |
VIN9 = 0x6F, |
| 105 |
VIN10 = 0x70, |
| 106 |
VIN11 = 0x71, |
| 107 |
VIN12 = 0x72, |
| 108 |
VIN13 = 0x73, |
| 109 |
VIN14 = 0x74, |
| 110 |
VIN15 = 0x75, |
| 111 |
VIN16 = 0x76, |
| 112 |
}; |
| 113 |
|
| 114 |
enum nct6687d_peci_speed { |
| 115 |
PECI_2MHZ = 0, |
| 116 |
PECI_1200KHZ, |
| 117 |
PECI_800KHZ, |
| 118 |
PECI_400KHZ, |
| 119 |
}; |
| 120 |
|
| 121 |
enum nct6687d_baud_rate { |
| 122 |
BAUD_12_5K = 0, |
| 123 |
BAUD_25K, |
| 124 |
BAUD_50K, |
| 125 |
BAUD_100K, |
| 126 |
BAUD_200K, |
| 127 |
BAUD_400K, |
| 128 |
BAUD_800K, |
| 129 |
BAUD_1200K, |
| 130 |
}; |
| 131 |
|
| 132 |
enum nct6687d_fan_mode { |
| 133 |
FAN_IGNORE = 0, |
| 134 |
FAN_THERMAL_CRUISE, |
| 135 |
FAN_SPEED_CRUISE, |
| 136 |
FAN_SMART_FAN_IV, |
| 137 |
FAN_PID_CONTROL, |
| 138 |
FAN_MODE_MANUAL, |
| 139 |
}; |
| 140 |
|
| 141 |
enum nct6687d_tach_pwm_sel { |
| 142 |
TACH_PWM0 = 0, |
| 143 |
TACH_PWM1, |
| 144 |
TACH_PWM2, |
| 145 |
TACH_PWM3, |
| 146 |
TACH_PWM4, |
| 147 |
TACH_PWM5, |
| 148 |
TACH_PWM6, |
| 149 |
TACH_PWM7, |
| 150 |
TACH_PWM8, |
| 151 |
TACH_PWM9, |
| 152 |
TACH_PWM10, |
| 153 |
TACH_PWM11, |
| 154 |
TACH_PWM12, |
| 155 |
TACH_PWM13, |
| 156 |
TACH_PWM14, |
| 157 |
TACH_PWM15, |
| 158 |
TACH_PWM16, |
| 159 |
TACH_PWM17, |
| 160 |
TACH_PWM18, |
| 161 |
TACH_PWM19, |
| 162 |
TACH_PWM20, |
| 163 |
TACH_PWM21, |
| 164 |
TACH_PWM22, |
| 165 |
TACH_PWM23, |
| 166 |
}; |
| 167 |
|
| 168 |
enum nct6687d_fan_unit_sel { |
| 169 |
FAN_PWM = 0, |
| 170 |
FAN_RPM, |
| 171 |
}; |
| 172 |
|
| 173 |
enum nct6687d_fast_track_weight { |
| 174 |
WEIGHT_DIV_1 = 0, |
| 175 |
WEIGHT_DIV_2, |
| 176 |
WEIGHT_DIV_4, |
| 177 |
WEIGHT_DIV_8, |
| 178 |
WEIGHT_DIV_16, |
| 179 |
WEIGHT_DIV_32, |
| 180 |
WEIGHT_DIV_64, |
| 181 |
}; |
| 182 |
|
| 183 |
struct nct6687d_pch_smbus_sensor { |
| 184 |
bool sensor_en; |
| 185 |
uint8_t sensor_idx; |
| 186 |
bool report_one_byte; |
| 187 |
uint8_t port_sel; |
| 188 |
enum nct6687d_baud_rate baud_rate; |
| 189 |
uint8_t sensor_addr; |
| 190 |
uint8_t sensor_cmd; |
| 191 |
}; |
| 192 |
|
| 193 |
struct nct6687d_dts_sensor_config { |
| 194 |
uint8_t ambient_temp[MAX_DTS_CTL_POINTS]; |
| 195 |
uint16_t rpm_start_point[MAX_DTS_CTL_POINTS]; |
| 196 |
uint16_t rpm_end_point[MAX_DTS_CTL_POINTS]; |
| 197 |
uint8_t temp_start; |
| 198 |
uint8_t temp_end; |
| 199 |
uint16_t max_speed; |
| 200 |
bool peci_adjust; |
| 201 |
uint8_t peci_agent_idx; |
| 202 |
}; |
| 203 |
|
| 204 |
struct nct6687d_dts2_sensor_config { |
| 205 |
int8_t target_margin; |
| 206 |
uint8_t target_margin_tolerance; |
| 207 |
int8_t t_control; |
| 208 |
int8_t t_control_offset; |
| 209 |
uint16_t step_speed; |
| 210 |
uint16_t min_speed; |
| 211 |
|
| 212 |
uint8_t delay_time; |
| 213 |
uint8_t divisor; |
| 214 |
}; |
| 215 |
|
| 216 |
struct nct6687d_smart_fan_iv_config { |
| 217 |
uint8_t temp_src[MAX_TEMP_SRC]; |
| 218 |
uint8_t temp_levels[MAX_TEMP_SPEED_LEVELS]; |
| 219 |
uint16_t speed_levels[MAX_TEMP_SPEED_LEVELS]; |
| 220 |
uint8_t temp_hystheresis; |
| 221 |
uint8_t temp_cut_off; |
| 222 |
uint8_t cut_off_delay; |
| 223 |
|
| 224 |
uint8_t step_up_time; |
| 225 |
uint8_t step_down_time; |
| 226 |
}; |
| 227 |
|
| 228 |
struct nct6687d_manual_fan_config { |
| 229 |
uint8_t manual_duty; |
| 230 |
}; |
| 231 |
|
| 232 |
struct nct6687d_fan_thermal_cruise_config { |
| 233 |
bool keep_min_fan_output; |
| 234 |
uint8_t target_temp; |
| 235 |
uint8_t temp_tolerance; |
| 236 |
uint8_t initial_value; |
| 237 |
uint8_t stop_value; |
| 238 |
|
| 239 |
uint8_t stop_time; |
| 240 |
uint8_t step_up_time; |
| 241 |
uint8_t step_down_time; |
| 242 |
}; |
| 243 |
|
| 244 |
struct nct6687d_fan_speed_cruise_config { |
| 245 |
uint16_t target_rpm; |
| 246 |
uint16_t rpm_tolerance; |
| 247 |
|
| 248 |
uint8_t step_up_time; |
| 249 |
uint8_t step_down_time; |
| 250 |
}; |
| 251 |
|
| 252 |
struct nct6687d_ambient_floor_fan_config { |
| 253 |
|
| 254 |
uint16_t minout_start; |
| 255 |
uint16_t minout_end; |
| 256 |
uint16_t minout_max; |
| 257 |
}; |
| 258 |
|
| 259 |
struct nct6687d_ambient_floor_config { |
| 260 |
uint8_t temp_start; |
| 261 |
uint8_t temp_end; |
| 262 |
}; |
| 263 |
|
| 264 |
struct nct6687d_smart_tracking_config { |
| 265 |
uint8_t rpm_tolerance_low; |
| 266 |
uint8_t rpm_tolerance_mid; |
| 267 |
uint8_t rpm_tolerance_high; |
| 268 |
|
| 269 |
uint16_t speed_boundary_low; |
| 270 |
uint16_t speed_boundary_high; |
| 271 |
|
| 272 |
|
| 273 |
uint8_t step_up; |
| 274 |
uint8_t step_down; |
| 275 |
|
| 276 |
|
| 277 |
uint8_t temp_boundary; |
| 278 |
|
| 279 |
enum nct6687d_fast_track_weight weight_up_low; |
| 280 |
enum nct6687d_fast_track_weight weight_up_mid; |
| 281 |
enum nct6687d_fast_track_weight weight_up_high; |
| 282 |
enum nct6687d_fast_track_weight weight_down_low; |
| 283 |
enum nct6687d_fast_track_weight weight_down_mid; |
| 284 |
enum nct6687d_fast_track_weight weight_down_high; |
| 285 |
|
| 286 |
uint8_t duty_step_low; |
| 287 |
uint8_t duty_step_mid; |
| 288 |
uint8_t duty_step_high; |
| 289 |
|
| 290 |
|
| 291 |
uint8_t ambient_temp_boundary; |
| 292 |
uint8_t weight_val; |
| 293 |
}; |
| 294 |
|
| 295 |
|
| 296 |
struct nct6687d_fan_config { |
| 297 |
enum nct6687d_fan_mode mode; |
| 298 |
enum nct6687d_fan_unit_sel unit_sel; |
| 299 |
enum nct6687d_tach_pwm_sel fanin_sel; |
| 300 |
enum nct6687d_tach_pwm_sel fanout_sel; |
| 301 |
|
| 302 |
struct nct6687d_smart_fan_iv_config smart_fan; |
| 303 |
struct nct6687d_manual_fan_config manual_fan; |
| 304 |
struct nct6687d_fan_thermal_cruise_config thermal_cruise_fan; |
| 305 |
struct nct6687d_fan_speed_cruise_config speed_cruise_fan; |
| 306 |
|
| 307 |
|
| 308 |
uint8_t fan_alg_weight; |
| 309 |
|
| 310 |
uint8_t crit_temp; |
| 311 |
uint8_t crit_temp_tolerance; |
| 312 |
|
| 313 |
uint8_t temp_err_duty; |
| 314 |
|
| 315 |
bool dts1_en; |
| 316 |
bool dts2_en; |
| 317 |
bool dts_ub_en; |
| 318 |
|
| 319 |
|
| 320 |
bool smart_tracking_en; |
| 321 |
bool fast_tracking_en; |
| 322 |
bool markup_tracking_en; |
| 323 |
|
| 324 |
bool ambient_floor_en; |
| 325 |
struct nct6687d_ambient_floor_fan_config amb_floor_fan_cfg; |
| 326 |
|
| 327 |
uint8_t startup_duty; |
| 328 |
uint8_t manual_offset; |
| 329 |
uint8_t min_duty; |
| 330 |
}; |
| 331 |
|
| 332 |
struct superio_nuvoton_nct6687d_config { |
| 333 |
struct nct6687d_fan_config fans[MAX_NUM_FANS]; |
| 334 |
enum nct6687d_sensor_src_select sensors[MAX_NUM_SENSORS]; |
| 335 |
|
| 336 |
enum nct6687d_peci_speed peci_speed; |
| 337 |
|
| 338 |
struct nct6687d_pch_smbus_sensor smbus_sensor; |
| 339 |
struct nct6687d_dts_sensor_config dts_sensor; |
| 340 |
struct nct6687d_dts2_sensor_config dts2_sensor; |
| 341 |
|
| 342 |
struct nct6687d_ambient_floor_config ambient_floor; |
| 343 |
struct nct6687d_smart_tracking_config smart_tracking; |
| 344 |
|
| 345 |
uint8_t fan_default_val; |
| 346 |
}; |
| 347 |
|
| 348 |
#define FAN1 fans[0] |
| 349 |
#define FAN2 fans[1] |
| 350 |
#define FAN3 fans[2] |
| 351 |
#define FAN4 fans[3] |
| 352 |
#define FAN5 fans[4] |
| 353 |
#define FAN6 fans[5] |
| 354 |
#define FAN7 fans[6] |
| 355 |
#define FAN8 fans[7] |
| 356 |
#define FAN9 fans[8] |
| 357 |
#define FAN10 fans[9] |
| 358 |
|
| 359 |
void nct6687d_hwm_init(uint16_t hwm_base, const struct superio_nuvoton_nct6687d_config *conf); |
| 360 |
|
| 361 |
#endif |