130ad29bbSHuacai Chen #ifndef __LOONGSON_HWMON_H_
230ad29bbSHuacai Chen #define __LOONGSON_HWMON_H_
330ad29bbSHuacai Chen 
430ad29bbSHuacai Chen #include <linux/types.h>
530ad29bbSHuacai Chen 
630ad29bbSHuacai Chen #define MIN_TEMP	0
730ad29bbSHuacai Chen #define MAX_TEMP	255
830ad29bbSHuacai Chen #define NOT_VALID_TEMP	999
930ad29bbSHuacai Chen 
1030ad29bbSHuacai Chen typedef int (*get_temp_fun)(int);
1130ad29bbSHuacai Chen extern int loongson3_cpu_temp(int);
1230ad29bbSHuacai Chen 
1330ad29bbSHuacai Chen /* 0:Max speed, 1:Manual, 2:Auto */
1430ad29bbSHuacai Chen enum fan_control_mode {
1530ad29bbSHuacai Chen 	FAN_FULL_MODE = 0,
1630ad29bbSHuacai Chen 	FAN_MANUAL_MODE = 1,
1730ad29bbSHuacai Chen 	FAN_AUTO_MODE = 2,
1830ad29bbSHuacai Chen 	FAN_MODE_END
1930ad29bbSHuacai Chen };
2030ad29bbSHuacai Chen 
2130ad29bbSHuacai Chen struct temp_range {
2230ad29bbSHuacai Chen 	u8 low;
2330ad29bbSHuacai Chen 	u8 high;
2430ad29bbSHuacai Chen 	u8 level;
2530ad29bbSHuacai Chen };
2630ad29bbSHuacai Chen 
2730ad29bbSHuacai Chen #define CONSTANT_SPEED_POLICY	0  /* at constent speed */
2830ad29bbSHuacai Chen #define STEP_SPEED_POLICY	1  /* use up/down arrays to describe policy */
2930ad29bbSHuacai Chen #define KERNEL_HELPER_POLICY	2  /* kernel as a helper to fan control */
3030ad29bbSHuacai Chen 
3130ad29bbSHuacai Chen #define MAX_STEP_NUM	16
3230ad29bbSHuacai Chen #define MAX_FAN_LEVEL	255
3330ad29bbSHuacai Chen 
3430ad29bbSHuacai Chen /* loongson_fan_policy works when fan work at FAN_AUTO_MODE */
3530ad29bbSHuacai Chen struct loongson_fan_policy {
3630ad29bbSHuacai Chen 	u8	type;
3730ad29bbSHuacai Chen 
3830ad29bbSHuacai Chen 	/* percent only used when type is CONSTANT_SPEED_POLICY */
3930ad29bbSHuacai Chen 	u8	percent;
4030ad29bbSHuacai Chen 
4130ad29bbSHuacai Chen 	/* period between two check. (Unit: S) */
4230ad29bbSHuacai Chen 	u8	adjust_period;
4330ad29bbSHuacai Chen 
4430ad29bbSHuacai Chen 	/* fan adjust usually depend on a temprature input */
4530ad29bbSHuacai Chen 	get_temp_fun	depend_temp;
4630ad29bbSHuacai Chen 
4730ad29bbSHuacai Chen 	/* up_step/down_step used when type is STEP_SPEED_POLICY */
4830ad29bbSHuacai Chen 	u8	up_step_num;
4930ad29bbSHuacai Chen 	u8	down_step_num;
5030ad29bbSHuacai Chen 	struct temp_range up_step[MAX_STEP_NUM];
5130ad29bbSHuacai Chen 	struct temp_range down_step[MAX_STEP_NUM];
5230ad29bbSHuacai Chen 	struct delayed_work work;
5330ad29bbSHuacai Chen };
5430ad29bbSHuacai Chen 
5530ad29bbSHuacai Chen #endif /* __LOONGSON_HWMON_H_*/
56