Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __LOONGSON_HWMON_H_
0003 #define __LOONGSON_HWMON_H_
0004 
0005 #include <linux/types.h>
0006 
0007 #define MIN_TEMP    0
0008 #define MAX_TEMP    255
0009 #define NOT_VALID_TEMP  999
0010 
0011 typedef int (*get_temp_fun)(int);
0012 extern int loongson3_cpu_temp(int);
0013 
0014 /* 0:Max speed, 1:Manual, 2:Auto */
0015 enum fan_control_mode {
0016     FAN_FULL_MODE = 0,
0017     FAN_MANUAL_MODE = 1,
0018     FAN_AUTO_MODE = 2,
0019     FAN_MODE_END
0020 };
0021 
0022 struct temp_range {
0023     u8 low;
0024     u8 high;
0025     u8 level;
0026 };
0027 
0028 #define CONSTANT_SPEED_POLICY   0  /* at constant speed */
0029 #define STEP_SPEED_POLICY   1  /* use up/down arrays to describe policy */
0030 #define KERNEL_HELPER_POLICY    2  /* kernel as a helper to fan control */
0031 
0032 #define MAX_STEP_NUM    16
0033 #define MAX_FAN_LEVEL   255
0034 
0035 /* loongson_fan_policy works when fan work at FAN_AUTO_MODE */
0036 struct loongson_fan_policy {
0037     u8  type;
0038 
0039     /* percent only used when type is CONSTANT_SPEED_POLICY */
0040     u8  percent;
0041 
0042     /* period between two check. (Unit: S) */
0043     u8  adjust_period;
0044 
0045     /* fan adjust usually depend on a temprature input */
0046     get_temp_fun    depend_temp;
0047 
0048     /* up_step/down_step used when type is STEP_SPEED_POLICY */
0049     u8  up_step_num;
0050     u8  down_step_num;
0051     struct temp_range up_step[MAX_STEP_NUM];
0052     struct temp_range down_step[MAX_STEP_NUM];
0053     struct delayed_work work;
0054 };
0055 
0056 #endif /* __LOONGSON_HWMON_H_*/