fan.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * ACPI fan device IDs are shared between the fan driver and the device power
  4. * management code.
  5. *
  6. * Add new device IDs before the generic ACPI fan one.
  7. */
  8. #ifndef _ACPI_FAN_H_
  9. #define _ACPI_FAN_H_
  10. #include <linux/kconfig.h>
  11. #include <linux/limits.h>
  12. #define ACPI_FAN_DEVICE_IDS \
  13. {"INT3404", }, /* Fan */ \
  14. {"INTC1044", }, /* Fan for Tiger Lake generation */ \
  15. {"INTC1048", }, /* Fan for Alder Lake generation */ \
  16. {"INTC1063", }, /* Fan for Meteor Lake generation */ \
  17. {"INTC106A", }, /* Fan for Lunar Lake generation */ \
  18. {"INTC10A2", }, /* Fan for Raptor Lake generation */ \
  19. {"INTC10D6", }, /* Fan for Panther Lake generation */ \
  20. {"INTC10FE", }, /* Fan for Wildcat Lake generation */ \
  21. {"INTC10F5", }, /* Fan for Nova Lake generation */ \
  22. {"PNP0C0B", } /* Generic ACPI fan */
  23. #define ACPI_FPS_NAME_LEN 20
  24. struct acpi_fan_fps {
  25. u64 control;
  26. u64 trip_point;
  27. u64 speed;
  28. u64 noise_level;
  29. u64 power;
  30. char name[ACPI_FPS_NAME_LEN];
  31. struct device_attribute dev_attr;
  32. };
  33. struct acpi_fan_fif {
  34. u8 revision;
  35. u8 fine_grain_ctrl;
  36. u8 step_size;
  37. u8 low_speed_notification;
  38. };
  39. struct acpi_fan_fst {
  40. u64 revision;
  41. u64 control;
  42. u64 speed;
  43. };
  44. struct acpi_fan {
  45. acpi_handle handle;
  46. bool acpi4;
  47. bool has_fst;
  48. struct acpi_fan_fif fif;
  49. struct acpi_fan_fps *fps;
  50. int fps_count;
  51. /* A value of 0 means that trippoint-related functions are not supported */
  52. u32 fan_trip_granularity;
  53. #if IS_REACHABLE(CONFIG_HWMON)
  54. struct device *hdev;
  55. #endif
  56. struct thermal_cooling_device *cdev;
  57. struct device_attribute fst_speed;
  58. struct device_attribute fine_grain_control;
  59. };
  60. /**
  61. * acpi_fan_speed_valid - Check if fan speed value is valid
  62. * @speeed: Speed value returned by the ACPI firmware
  63. *
  64. * Check if the fan speed value returned by the ACPI firmware is valid. This function is
  65. * necessary as ACPI firmware implementations can return 0xFFFFFFFF to signal that the
  66. * ACPI fan does not support speed reporting. Additionally, some buggy ACPI firmware
  67. * implementations return a value larger than the 32-bit integer value defined by
  68. * the ACPI specification when using placeholder values. Such invalid values are also
  69. * detected by this function.
  70. *
  71. * Returns: True if the fan speed value is valid, false otherwise.
  72. */
  73. static inline bool acpi_fan_speed_valid(u64 speed)
  74. {
  75. return speed < U32_MAX;
  76. }
  77. /**
  78. * acpi_fan_power_valid - Check if fan power value is valid
  79. * @power: Power value returned by the ACPI firmware
  80. *
  81. * Check if the fan power value returned by the ACPI firmware is valid.
  82. * See acpi_fan_speed_valid() for details.
  83. *
  84. * Returns: True if the fan power value is valid, false otherwise.
  85. */
  86. static inline bool acpi_fan_power_valid(u64 power)
  87. {
  88. return power < U32_MAX;
  89. }
  90. int acpi_fan_get_fst(acpi_handle handle, struct acpi_fan_fst *fst);
  91. int acpi_fan_create_attributes(struct acpi_device *device);
  92. void acpi_fan_delete_attributes(struct acpi_device *device);
  93. #if IS_REACHABLE(CONFIG_HWMON)
  94. int devm_acpi_fan_create_hwmon(struct device *dev);
  95. void acpi_fan_notify_hwmon(struct device *dev);
  96. #else
  97. static inline int devm_acpi_fan_create_hwmon(struct device *dev) { return 0; };
  98. static inline void acpi_fan_notify_hwmon(struct device *dev) { };
  99. #endif
  100. #endif