loongson_hwmon.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef __LOONGSON_HWMON_H_
  2. #define __LOONGSON_HWMON_H_
  3. #include <linux/types.h>
  4. #define MIN_TEMP 0
  5. #define MAX_TEMP 255
  6. #define NOT_VALID_TEMP 999
  7. typedef int (*get_temp_fun)(int);
  8. extern int loongson3_cpu_temp(int);
  9. /* 0:Max speed, 1:Manual, 2:Auto */
  10. enum fan_control_mode {
  11. FAN_FULL_MODE = 0,
  12. FAN_MANUAL_MODE = 1,
  13. FAN_AUTO_MODE = 2,
  14. FAN_MODE_END
  15. };
  16. struct temp_range {
  17. u8 low;
  18. u8 high;
  19. u8 level;
  20. };
  21. #define CONSTANT_SPEED_POLICY 0 /* at constant speed */
  22. #define STEP_SPEED_POLICY 1 /* use up/down arrays to describe policy */
  23. #define KERNEL_HELPER_POLICY 2 /* kernel as a helper to fan control */
  24. #define MAX_STEP_NUM 16
  25. #define MAX_FAN_LEVEL 255
  26. /* loongson_fan_policy works when fan work at FAN_AUTO_MODE */
  27. struct loongson_fan_policy {
  28. u8 type;
  29. /* percent only used when type is CONSTANT_SPEED_POLICY */
  30. u8 percent;
  31. /* period between two check. (Unit: S) */
  32. u8 adjust_period;
  33. /* fan adjust usually depend on a temprature input */
  34. get_temp_fun depend_temp;
  35. /* up_step/down_step used when type is STEP_SPEED_POLICY */
  36. u8 up_step_num;
  37. u8 down_step_num;
  38. struct temp_range up_step[MAX_STEP_NUM];
  39. struct temp_range down_step[MAX_STEP_NUM];
  40. struct delayed_work work;
  41. };
  42. #endif /* __LOONGSON_HWMON_H_*/