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