18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef __LOONGSON_HWMON_H_ 38c2ecf20Sopenharmony_ci#define __LOONGSON_HWMON_H_ 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <linux/types.h> 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#define MIN_TEMP 0 88c2ecf20Sopenharmony_ci#define MAX_TEMP 255 98c2ecf20Sopenharmony_ci#define NOT_VALID_TEMP 999 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_citypedef int (*get_temp_fun)(int); 128c2ecf20Sopenharmony_ciextern int loongson3_cpu_temp(int); 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci/* 0:Max speed, 1:Manual, 2:Auto */ 158c2ecf20Sopenharmony_cienum fan_control_mode { 168c2ecf20Sopenharmony_ci FAN_FULL_MODE = 0, 178c2ecf20Sopenharmony_ci FAN_MANUAL_MODE = 1, 188c2ecf20Sopenharmony_ci FAN_AUTO_MODE = 2, 198c2ecf20Sopenharmony_ci FAN_MODE_END 208c2ecf20Sopenharmony_ci}; 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_cistruct temp_range { 238c2ecf20Sopenharmony_ci u8 low; 248c2ecf20Sopenharmony_ci u8 high; 258c2ecf20Sopenharmony_ci u8 level; 268c2ecf20Sopenharmony_ci}; 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#define CONSTANT_SPEED_POLICY 0 /* at constant speed */ 298c2ecf20Sopenharmony_ci#define STEP_SPEED_POLICY 1 /* use up/down arrays to describe policy */ 308c2ecf20Sopenharmony_ci#define KERNEL_HELPER_POLICY 2 /* kernel as a helper to fan control */ 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#define MAX_STEP_NUM 16 338c2ecf20Sopenharmony_ci#define MAX_FAN_LEVEL 255 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci/* loongson_fan_policy works when fan work at FAN_AUTO_MODE */ 368c2ecf20Sopenharmony_cistruct loongson_fan_policy { 378c2ecf20Sopenharmony_ci u8 type; 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci /* percent only used when type is CONSTANT_SPEED_POLICY */ 408c2ecf20Sopenharmony_ci u8 percent; 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci /* period between two check. (Unit: S) */ 438c2ecf20Sopenharmony_ci u8 adjust_period; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci /* fan adjust usually depend on a temprature input */ 468c2ecf20Sopenharmony_ci get_temp_fun depend_temp; 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci /* up_step/down_step used when type is STEP_SPEED_POLICY */ 498c2ecf20Sopenharmony_ci u8 up_step_num; 508c2ecf20Sopenharmony_ci u8 down_step_num; 518c2ecf20Sopenharmony_ci struct temp_range up_step[MAX_STEP_NUM]; 528c2ecf20Sopenharmony_ci struct temp_range down_step[MAX_STEP_NUM]; 538c2ecf20Sopenharmony_ci struct delayed_work work; 548c2ecf20Sopenharmony_ci}; 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci#endif /* __LOONGSON_HWMON_H_*/ 57