dell-smm-hwmon: Add support for disabling automatic BIOS fan control
Subsystems (3)
PATCH v4 1/2 dell-smm-hwmon: Add support for disabling automatic BIOS fan control
This patch exports standard hwmon pwmX_enable sysfs attribute for enabling or disabling automatic fan control by BIOS. Standard value "1" is for disabling automatic BIOS fan control and value "2" for enabling.
By default BIOS auto mode is enabled by laptop firmware.
When BIOS auto mode is enabled, custom fan speed value (set via hwmon pwmX sysfs attribute) is overwritten by SMM in few seconds and therefore any custom settings are without effect. So this is reason why implementing option for disabling BIOS auto mode is needed.
So finally this patch allows kernel to set and control fan speed on laptops, but it can be dangerous (like setting speed of other fans).
The SMM commands to enable or disable automatic fan control are not documented and are not the same on all Dell laptops. Therefore a whitelist is used to send the correct codes only on laptopts for which they are known.
This patch was originally developed by Pali Rohár; later Giovanni Mascellani implemented the whitelist.
--- drivers/hwmon/dell-smm-hwmon.c | 114 ++++++++++++++++++++++++++++++--- 1 file changed, 104 insertions(+), 10 deletions(-)
drivers/hwmon/dell-smm-hwmon.c +104 -10
@@ -68,6 +68,8 @@ static uint i8k_pwm_mult;static uint i8k_fan_max =I8K_FAN_HIGH ;static bool disallow_fan_type_call;static bool disallow_fan_support; +static unsigned int manual_fan; +static unsigned int auto_fan;#define I8K_HWMON_HAVE_TEMP1 (1 << 0)#define I8K_HWMON_HAVE_TEMP2 (1 << 1)
@@ -300,6 +302,20 @@ static int i8k_get_fan_nominal_speed(int fan, int speed)return i8k_smm (®s) ? : (regs.eax &0xffff ) * i8k_fan_mult; } +/* +* Enable or disable automatic BIOS fan control support +*/ +static int i8k_enable_fan_auto_mode (bool enable) +{ +struct smm_regs regs = { }; + +if (disallow_fan_support) +return -EINVAL ; + + regs.eax = enable ? auto_fan : manual_fan; +return i8k_smm (®s); +} +/* * Set the fan speed (off, low, high). Returns the new fan status. */
@@ -726,6 +742,35 @@ static ssize_t i8k_hwmon_pwm_store(struct device *dev,return err <0 ? -EIO : count; } +static ssize_t i8k_hwmon_pwm_enable_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) +{ +int err; +bool enable; +unsigned long val; + +if (!auto_fan) +return -ENODEV ; + + err =kstrtoul (buf,10 , &val); +if (err) +return err; + +if (val ==1 ) + enable = false; +else if (val ==2 ) + enable = true; +else +return -EINVAL ; + +mutex_lock (&i8k_mutex); + err =i8k_enable_fan_auto_mode (enable); +mutex_unlock (&i8k_mutex); + +return err ? err : count; +} + static SENSOR_DEVICE_ATTR_RO(temp1_input, i8k_hwmon_temp, 0); static SENSOR_DEVICE_ATTR_RO(temp1_label, i8k_hwmon_temp_label, 0); static SENSOR_DEVICE_ATTR_RO(temp2_input, i8k_hwmon_temp, 1);
@@ -749,6 +794,7 @@ static SENSOR_DEVICE_ATTR_RO(temp10_label, i8k_hwmon_temp_label, 9); static SENSOR_DEVICE_ATTR_RO(fan1_input, i8k_hwmon_fan, 0); static SENSOR_DEVICE_ATTR_RO(fan1_label, i8k_hwmon_fan_label, 0); static SENSOR_DEVICE_ATTR_RW(pwm1, i8k_hwmon_pwm, 0); +static SENSOR_DEVICE_ATTR_WO(pwm1_enable, i8k_hwmon_pwm_enable, 0); static SENSOR_DEVICE_ATTR_RO(fan2_input, i8k_hwmon_fan, 1); static SENSOR_DEVICE_ATTR_RO(fan2_label, i8k_hwmon_fan_label, 1); static SENSOR_DEVICE_ATTR_RW(pwm2, i8k_hwmon_pwm, 1);
@@ -780,12 +826,13 @@ static struct attribute *i8k_attrs[] = { &sensor_dev_attr_fan1_input.dev_attr.attr,/* 20 */ &sensor_dev_attr_fan1_label.dev_attr.attr,/* 21 */ &sensor_dev_attr_pwm1.dev_attr.attr,/* 22 */ - &sensor_dev_attr_fan2_input.dev_attr.attr,/* 23 */ - &sensor_dev_attr_fan2_label.dev_attr.attr,/* 24 */ - &sensor_dev_attr_pwm2.dev_attr.attr,/* 25 */ - &sensor_dev_attr_fan3_input.dev_attr.attr,/* 26 */ - &sensor_dev_attr_fan3_label.dev_attr.attr,/* 27 */ - &sensor_dev_attr_pwm3.dev_attr.attr,/* 28 */ + &sensor_dev_attr_pwm1_enable.dev_attr.attr,/* 23 */ + &sensor_dev_attr_fan2_input.dev_attr.attr,/* 24 */ + &sensor_dev_attr_fan2_label.dev_attr.attr,/* 25 */ + &sensor_dev_attr_pwm2.dev_attr.attr,/* 26 */ + &sensor_dev_attr_fan3_input.dev_attr.attr,/* 27 */ + &sensor_dev_attr_fan3_label.dev_attr.attr,/* 28 */ + &sensor_dev_attr_pwm3.dev_attr.attr,/* 29 */ NULL };
@@ -828,16 +875,19 @@ static umode_t i8k_is_visible(struct kobject *kobj, struct attribute *attr, !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP10))return 0 ; -if (index >=20 && index <=22 && +if (index >=20 && index <=23 && !(i8k_hwmon_flags &I8K_HWMON_HAVE_FAN1 ))return 0 ; -if (index >=23 && index <=25 && +if (index >=24 && index <=26 && !(i8k_hwmon_flags &I8K_HWMON_HAVE_FAN2 ))return 0 ; -if (index >=26 && index <=28 && +if (index >=27 && index <=29 && !(i8k_hwmon_flags &I8K_HWMON_HAVE_FAN3 ))return 0 ; +if (index ==23 && !auto_fan) +return 0 ; +return attr->mode; }
@@ -1135,12 +1185,48 @@ static struct dmi_system_id i8k_blacklist_fan_support_dmi_table[] __initdata = { { } }; +struct i8k_fan_control_data { +unsigned int manual_fan; +unsigned int auto_fan; +}; + +enum i8k_fan_controls { +I8K_FAN_34A3_35A3 , +}; + +static const struct i8k_fan_control_data i8k_fan_control_data[] = { + [I8K_FAN_34A3_35A3 ] = { + .manual_fan =0x34a3 , + .auto_fan =0x35a3 , + }, +}; + +static struct dmi_system_id i8k_whitelist_fan_control[]__initdata = { + { + .ident ="Dell Precision 5530" , + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), +DMI_EXACT_MATCH (DMI_PRODUCT_NAME ,"Precision 5530" ), + }, + .driver_data = (void *)&i8k_fan_control_data[I8K_FAN_34A3_35A3 ], + }, + { + .ident ="Dell Latitude E6440" , + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), +DMI_EXACT_MATCH (DMI_PRODUCT_NAME ,"Latitude E6440" ), + }, + .driver_data = (void *)&i8k_fan_control_data[I8K_FAN_34A3_35A3 ], + }, + { } +}; +/* * Probe for the presence of a supported laptop. */ static int __init i8k_probe (void ) { -const struct dmi_system_id *id; +const struct dmi_system_id *id, *fan_control;int fan, ret;/*
@@ -1200,6 +1286,14 @@ static int __init i8k_probe(void) i8k_fan_max = fan_max ? :I8K_FAN_HIGH ;/* Must not be 0 */ i8k_pwm_mult =DIV_ROUND_UP (255 , i8k_fan_max); + fan_control =dmi_first_match (i8k_whitelist_fan_control); +if (fan_control && fan_control->driver_data) { +const struct i8k_fan_control_data *fan_control_data = fan_control->driver_data; + manual_fan = fan_control_data->manual_fan; + auto_fan = fan_control_data->auto_fan; +pr_info ("enabling support for setting automatic/manual fan control\n" ); + } +if (!fan_mult) {/* * Autodetect fan multiplier based on nominal rpm
Signature · 1 line
2.24.0
PATCH v4 2/2 dell-smm-hwmon: Add documentation
Part of the documentation is taken from the README of the userspace utils (https://github.com/vitorafsr/i8kutils). The license is GPL-2+ and the author Massimo Dal Zotto is already credited as author of the module. Therefore there should be no copyright problem.
I also added a paragraph with specific information on the experimental support for automatic BIOS fan control.
--- Documentation/hwmon/dell-smm-hwmon.rst | 112 +++++++++++++++++++++++++ Documentation/hwmon/index.rst | 1 + 2 files changed, 113 insertions(+) create mode 100644 Documentation/hwmon/dell-smm-hwmon.rst
Documentation/hwmon/dell-smm-hwmon.rst new file +112 -0
@@ -0,0 +1,112 @@ +Kernel driver dell-smm-hwmon +============================ + +Description +----------- + +On many Dell laptops the System Management Mode (SMM) BIOS can be +queried for the status of fans and temperature sensors. The userspace +suite `i8kutils`__ can be used to read the sensors and automatically +adjust fan speed. + + __ https://github.com/vitorafsr/i8kutils + +``/proc`` interface +------------------- + +The information provided by the kernel driver can be accessed by +simply reading the ``/proc/i8k`` file. For example:: + + $ cat /proc/i8k + 1.0 A17 2J59L02 52 2 1 8040 6420 1 2 + +The fields read from ``/proc/i8k`` are:: + + 1.0 A17 2J59L02 52 2 1 8040 6420 1 2 + | | | | | | | | | | + | | | | | | | | | +------- 10. buttons status + | | | | | | | | +--------- 9. AC status + | | | | | | | +-------------- 8. right fan rpm + | | | | | | +------------------- 7. left fan rpm + | | | | | +--------------------- 6. right fan status + | | | | +----------------------- 5. left fan status + | | | +-------------------------- 4. CPU temperature (Celsius) + | | +---------------------------------- 3. Dell service tag (later known as 'serial number') + | +-------------------------------------- 2. BIOS version + +------------------------------------------ 1. /proc/i8k format version + +A negative value, for example -22, indicates that the BIOS doesn't +return the corresponding information. This is normal on some +models/BIOSes. + +For performance reasons the ``/proc/i8k`` doesn't report by default +the AC status since this SMM call takes a long time to execute and is +not really needed. If you want to see the ac status in ``/proc/i8k`` +you must explictitly enable this option by passing the +``power_status=1`` parameter to insmod. If AC status is not +available -1 is printed instead. + +The driver provides also an ioctl interface which can be used to +obtain the same information and to control the fan status. The ioctl +interface can be accessed from C programs or from shell using the +i8kctl utility. See the source file of ``i8kutils`` for more +information on how to use the ioctl interface. + +``sysfs`` interface +------------------- + +Temperature sensors and fans can also be queried and set via the +standard ``hwmon`` interface on ``sysfs``. + +Disabling automatic BIOS fan control +------------------------------------ + +On some laptops, the BIOS automatically sets fan speed every few +seconds. Therefore the fan speed set via ``/proc/i8k`` or via the +``sysfs`` interface is quickly overwritten. + +There is experimental support for disabling automatic BIOS fan +control, at least on laptops where the corresponding SMM command is +known, by writing the value ``1`` in the attribute ``pwm1_enable`` +(writing ``2`` enables automatic BIOS control again). Even if you have +more than one fan, all of them are set to either enabled or disabled +automatic fan control at the same time and, notwithstanding the name, +``pwm1_enable`` sets automatic control for all fans. + +If ``pwm1_enable`` is not available, then it means that SMM codes for +enabling and disabling automatic BIOS fan control are not known for +your laptop. You can experiment with the code in `this repository`__ +to probe the BIOS on your machine and discover the appropriate codes. + + __ https://github.com/clopez/dellfan/ + +Module parameters +----------------- + +* force:bool + Force loading without checking for supported + models. (default: 0) + +* ignore_dmi:bool + Continue probing hardware even if DMI data does not + match. (default: 0) + +* restricted:bool + Allow fan control only to processes with the + ``CAP_SYS_ADMIN`` capability set or processes run + as root. In this case normal users will be able to + read temperature and fan status but not to control + the fan. If your notebook is shared with other + users and you don't trust them you may want to use + this option. (default: 1) + +* power_status:bool + Report AC status in ``/proc/i8k``. (default: 0) + +* fan_mult:uint + Factor to multiply fan speed with. (default: + autodetect) + +* fan_max:uint + Maximum configurable fan speed. (default: + autodetect)
Documentation/hwmon/index.rst +1 -0
@@ -44,6 +44,7 @@ Hardware Monitoring Kernel Drivers coretemp da9052 da9055 + dell-smm-hwmon dme1737 ds1621 ds620
Signature · 1 line
2.24.0
Re: [PATCH v4 2/2] dell-smm-hwmon: Add documentation
Hi! It is great that kernel would have up-to-date documentation.
Quoted 26 lines · On Monday 18 November 2019 18:11:48 Giovanni Mascellani wrote:
Part of the documentation is taken from the README of the userspace utils (https://github.com/vitorafsr/i8kutils). The license is GPL-2+ and the author Massimo Dal Zotto is already credited as author of the module. Therefore there should be no copyright problem.
I also added a paragraph with specific information on the experimental support for automatic BIOS fan control.
Signed-off-by Giovanni Mascellani <[email protected]>--- Documentation/hwmon/dell-smm-hwmon.rst | 112 +++++++++++++++++++++++++ Documentation/hwmon/index.rst | 1 + 2 files changed, 113 insertions(+) create mode 100644 Documentation/hwmon/dell-smm-hwmon.rstDocumentation/hwmon/dell-smm-hwmon.rst new file +5
-0@@ -0,0 +1,112 @@ +Kernel driver dell-smm-hwmon +============================ + +Description +-----------
Documentation/hwmon/dell-smm-hwmon.rst line 15
Quoted 10 lines
Documentation/hwmon/dell-smm-hwmon.rst new file +10
-0+ +On many Dell laptops the System Management Mode (SMM) BIOS can be +queried for the status of fans and temperature sensors. The userspace +suite `i8kutils`__ can be used to read the sensors and automatically +adjust fan speed. + + __ https://github.com/vitorafsr/i8kutils + +``/proc`` interface +-------------------
/proc/i8k is legacy interface and ioctl is already obsoleted/deprecated. New applications should not use this interface. It is replaced by acpi, input layer and hwmon interface. /proc/i8k is needed for old Dell laptops (like Dell Inspiron 8000) which do not support acpi or does not provide input events. Please express this in documentation, so people would not try to use this old interface in new applications. Also this legacy interface is available only when kernel is compile with CONFIG_I8K option.
Quoted 4 lines
Documentation/hwmon/dell-smm-hwmon.rst new file +4
-0+The information provided by the kernel driver can be accessed by +simply reading the ``/proc/i8k`` file. For example:: + + $ cat /proc/i8k
Documentation/hwmon/dell-smm-hwmon.rst line 30
Quoted 10 lines
Documentation/hwmon/dell-smm-hwmon.rst new file +10
-0+ 1.0 A17 2J59L02 52 2 1 8040 6420 1 2 + +The fields read from ``/proc/i8k`` are:: + + 1.0 A17 2J59L02 52 2 1 8040 6420 1 2 + | | | | | | | | | | + | | | | | | | | | +------- 10. buttons status + | | | | | | | | +--------- 9. AC status + | | | | | | | +-------------- 8. right fan rpm + | | | | | | +------------------- 7. left fan rpm
It is not right or left fan, but rather fan0 and fan1 (right = 0). On some laptops is really fan with index 0 on right side, but on some not.
Documentation/hwmon/dell-smm-hwmon.rst line 32
Quoted 2 lines
Documentation/hwmon/dell-smm-hwmon.rst new file +2
-0+ | | | | | +--------------------- 6. right fan status + | | | | +----------------------- 5. left fan status
Ditto.
Documentation/hwmon/dell-smm-hwmon.rst line 33
Quoted 1 line
Documentation/hwmon/dell-smm-hwmon.rst new file +1
-0+ | | | +-------------------------- 4. CPU temperature (Celsius)
This is not CPU temperature, but rather temperature sensor with index 0. Probably in most cases it CPU temperature. See i8k_hwmon_temp_label_show for mapping index to sensor name.
Quoted 13 lines
Documentation/hwmon/dell-smm-hwmon.rst new file +13
-0+ | | +---------------------------------- 3. Dell service tag (later known as 'serial number') + | +-------------------------------------- 2. BIOS version + +------------------------------------------ 1. /proc/i8k format version + +A negative value, for example -22, indicates that the BIOS doesn't +return the corresponding information. This is normal on some +models/BIOSes. + +For performance reasons the ``/proc/i8k`` doesn't report by default +the AC status since this SMM call takes a long time to execute and is +not really needed. If you want to see the ac status in ``/proc/i8k`` +you must explictitly enable this option by passing the +``power_status=1`` parameter to insmod. If AC status is not
Documentation/hwmon/dell-smm-hwmon.rst line 56
Quoted 10 lines
Documentation/hwmon/dell-smm-hwmon.rst new file +10
-0+available -1 is printed instead. + +The driver provides also an ioctl interface which can be used to +obtain the same information and to control the fan status. The ioctl +interface can be accessed from C programs or from shell using the +i8kctl utility. See the source file of ``i8kutils`` for more +information on how to use the ioctl interface. + +``sysfs`` interface +-------------------
Please move sysfs hwmon section before legacy /proc/i8k. So users first read information about new interface and then (who is interested) can read details about legacy interface. Personally I would move proc interface even after module parameters, to be at the bottom of document.
Documentation/hwmon/dell-smm-hwmon.rst line 59
Quoted 3 lines
Documentation/hwmon/dell-smm-hwmon.rst new file +3
-0+ +Temperature sensors and fans can also be queried and set via the +standard ``hwmon`` interface on ``sysfs``.
Maybe add comment that this interface is available in /sys/class/hwmon/ path. And that there is "sensors" command line tool as alternative to calling legacy "cat /proc/i8k".
Quoted 13 lines
Documentation/hwmon/dell-smm-hwmon.rst new file +13
-0+ +Disabling automatic BIOS fan control +------------------------------------ + +On some laptops, the BIOS automatically sets fan speed every few +seconds. Therefore the fan speed set via ``/proc/i8k`` or via the +``sysfs`` interface is quickly overwritten. + +There is experimental support for disabling automatic BIOS fan +control, at least on laptops where the corresponding SMM command is +known, by writing the value ``1`` in the attribute ``pwm1_enable`` +(writing ``2`` enables automatic BIOS control again). Even if you have +more than one fan, all of them are set to either enabled or disabled
Documentation/hwmon/dell-smm-hwmon.rst line 82
Quoted 10 lines
Documentation/hwmon/dell-smm-hwmon.rst new file +10
-0+automatic fan control at the same time and, notwithstanding the name, +``pwm1_enable`` sets automatic control for all fans. + +If ``pwm1_enable`` is not available, then it means that SMM codes for +enabling and disabling automatic BIOS fan control are not known for +your laptop. You can experiment with the code in `this repository`__ +to probe the BIOS on your machine and discover the appropriate codes. + + __ https://github.com/clopez/dellfan/ +
Ideally add some comments what could users do when they find correct SMM commands for enabling/disabling BIOS mode. How and where to add these SMM commands and where to send patch (to ML [email protected])
Quoted 9 lines
Documentation/hwmon/dell-smm-hwmon.rst new file +9
-0+Module parameters +----------------- + +* force:bool + Force loading without checking for supported + models. (default: 0) + +* ignore_dmi:bool + Continue probing hardware even if DMI data does not
Documentation/hwmon/dell-smm-hwmon.rst line 101
Quoted 10 lines
Documentation/hwmon/dell-smm-hwmon.rst new file +10
-0+ match. (default: 0) + +* restricted:bool + Allow fan control only to processes with the + ``CAP_SYS_ADMIN`` capability set or processes run + as root. In this case normal users will be able to + read temperature and fan status but not to control + the fan. If your notebook is shared with other + users and you don't trust them you may want to use + this option. (default: 1)
Add a note that option is only for /proc/i8k and so it is available only when kernel is compiled with CONFIG_I8K.
Documentation/hwmon/dell-smm-hwmon.rst line 104
Quoted 3 lines
Documentation/hwmon/dell-smm-hwmon.rst new file +3
-0+ +* power_status:bool + Report AC status in ``/proc/i8k``. (default: 0)
Again, this is available only when kernel is compiled with CONFIG_I8K.
Quoted 20 lines
Documentation/hwmon/dell-smm-hwmon.rst new file +8
-0+ +* fan_mult:uint + Factor to multiply fan speed with. (default: + autodetect) + +* fan_max:uint + Maximum configurable fan speed. (default: + autodetect)Documentation/hwmon/index.rst +1
-0@@ -44,6 +44,7 @@ Hardware Monitoring Kernel Drivers coretemp da9052 da9055 + dell-smm-hwmon dme1737 ds1621 ds620
Signature · 2 lines
Pali Rohár [email protected]
Quoted 20 lines · On Monday 18 November 2019 18:11:47 Giovanni Mascellani wrote:
This patch exports standard hwmon
pwmX_enablesysfs attribute for enabling or disabling automatic fan control by BIOS. Standard value "1" is for disabling automatic BIOS fan control and value "2" for enabling.By default BIOS auto mode is enabled by laptop firmware.
When BIOS auto mode is enabled, custom fan speed value (set via hwmon pwmX sysfs attribute) is overwritten by SMM in few seconds and therefore any custom settings are without effect. So this is reason why implementing option for disabling BIOS auto mode is needed.
So finally this patch allows kernel to set and control fan speed on laptops, but it can be dangerous (like setting speed of other fans).
The SMM commands to enable or disable automatic fan control are not documented and are not the same on all Dell laptops. Therefore a whitelist is used to send the correct codes only on laptopts for which they are known.
Quoted 5 lines
This patch was originally developed by Pali Rohár; later Giovanni Mascellani implemented the whitelist.
Signed-off-by Giovanni Mascellani <[email protected]>Co-Developer-by Pali Rohár <[email protected]>
This patch is fine for me now. I'm not sure if Co-Developer-by: tag is supported, but you can add:
Quoted 190 lines
--- drivers/hwmon/dell-smm-hwmon.c | 114 ++++++++++++++++++++++++++++++--- 1 file changed, 104 insertions(+), 10 deletions(-)drivers/hwmon/dell-smm-hwmon.c +104
-10@@ -68,6 +68,8 @@ static uint i8k_pwm_mult;static uint i8k_fan_max =I8K_FAN_HIGH ;static bool disallow_fan_type_call;static bool disallow_fan_support; +static unsigned int manual_fan; +static unsigned int auto_fan;#define I8K_HWMON_HAVE_TEMP1 (1 << 0)#define I8K_HWMON_HAVE_TEMP2 (1 << 1)@@ -300,6 +302,20 @@ static int i8k_get_fan_nominal_speed(int fan, int speed)return i8k_smm (®s) ? : (regs.eax &0xffff ) * i8k_fan_mult; } +/* +* Enable or disable automatic BIOS fan control support +*/ +static int i8k_enable_fan_auto_mode (bool enable) +{ +struct smm_regs regs = { }; + +if (disallow_fan_support) +return -EINVAL ; + + regs.eax = enable ? auto_fan : manual_fan; +return i8k_smm (®s); +} +/* * Set the fan speed (off, low, high). Returns the new fan status. */ @@ -726,6 +742,35 @@ static ssize_t i8k_hwmon_pwm_store(struct device *dev,return err <0 ? -EIO : count; } +static ssize_t i8k_hwmon_pwm_enable_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) +{ +int err; +bool enable; +unsigned long val; + +if (!auto_fan) +return -ENODEV ; + + err =kstrtoul (buf,10 , &val); +if (err) +return err; + +if (val ==1 ) + enable = false; +else if (val ==2 ) + enable = true; +else +return -EINVAL ; + +mutex_lock (&i8k_mutex); + err =i8k_enable_fan_auto_mode (enable); +mutex_unlock (&i8k_mutex); + +return err ? err : count; +} + static SENSOR_DEVICE_ATTR_RO(temp1_input, i8k_hwmon_temp, 0); static SENSOR_DEVICE_ATTR_RO(temp1_label, i8k_hwmon_temp_label, 0); static SENSOR_DEVICE_ATTR_RO(temp2_input, i8k_hwmon_temp, 1);@@ -749,6 +794,7 @@ static SENSOR_DEVICE_ATTR_RO(temp10_label, i8k_hwmon_temp_label, 9); static SENSOR_DEVICE_ATTR_RO(fan1_input, i8k_hwmon_fan, 0); static SENSOR_DEVICE_ATTR_RO(fan1_label, i8k_hwmon_fan_label, 0); static SENSOR_DEVICE_ATTR_RW(pwm1, i8k_hwmon_pwm, 0); +static SENSOR_DEVICE_ATTR_WO(pwm1_enable, i8k_hwmon_pwm_enable, 0); static SENSOR_DEVICE_ATTR_RO(fan2_input, i8k_hwmon_fan, 1); static SENSOR_DEVICE_ATTR_RO(fan2_label, i8k_hwmon_fan_label, 1); static SENSOR_DEVICE_ATTR_RW(pwm2, i8k_hwmon_pwm, 1);@@ -780,12 +826,13 @@ static struct attribute *i8k_attrs[] = { &sensor_dev_attr_fan1_input.dev_attr.attr,/* 20 */ &sensor_dev_attr_fan1_label.dev_attr.attr,/* 21 */ &sensor_dev_attr_pwm1.dev_attr.attr,/* 22 */ - &sensor_dev_attr_fan2_input.dev_attr.attr,/* 23 */ - &sensor_dev_attr_fan2_label.dev_attr.attr,/* 24 */ - &sensor_dev_attr_pwm2.dev_attr.attr,/* 25 */ - &sensor_dev_attr_fan3_input.dev_attr.attr,/* 26 */ - &sensor_dev_attr_fan3_label.dev_attr.attr,/* 27 */ - &sensor_dev_attr_pwm3.dev_attr.attr,/* 28 */ + &sensor_dev_attr_pwm1_enable.dev_attr.attr,/* 23 */ + &sensor_dev_attr_fan2_input.dev_attr.attr,/* 24 */ + &sensor_dev_attr_fan2_label.dev_attr.attr,/* 25 */ + &sensor_dev_attr_pwm2.dev_attr.attr,/* 26 */ + &sensor_dev_attr_fan3_input.dev_attr.attr,/* 27 */ + &sensor_dev_attr_fan3_label.dev_attr.attr,/* 28 */ + &sensor_dev_attr_pwm3.dev_attr.attr,/* 29 */ NULL };@@ -828,16 +875,19 @@ static umode_t i8k_is_visible(struct kobject *kobj, struct attribute *attr, !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP10))return 0 ; -if (index >=20 && index <=22 && +if (index >=20 && index <=23 && !(i8k_hwmon_flags &I8K_HWMON_HAVE_FAN1 ))return 0 ; -if (index >=23 && index <=25 && +if (index >=24 && index <=26 && !(i8k_hwmon_flags &I8K_HWMON_HAVE_FAN2 ))return 0 ; -if (index >=26 && index <=28 && +if (index >=27 && index <=29 && !(i8k_hwmon_flags &I8K_HWMON_HAVE_FAN3 ))return 0 ; +if (index ==23 && !auto_fan) +return 0 ; +return attr->mode; }@@ -1135,12 +1185,48 @@ static struct dmi_system_id i8k_blacklist_fan_support_dmi_table[] __initdata = { { } }; +struct i8k_fan_control_data { +unsigned int manual_fan; +unsigned int auto_fan; +}; + +enum i8k_fan_controls { +I8K_FAN_34A3_35A3 , +}; + +static const struct i8k_fan_control_data i8k_fan_control_data[] = { + [I8K_FAN_34A3_35A3 ] = { + .manual_fan =0x34a3 , + .auto_fan =0x35a3 , + }, +}; + +static struct dmi_system_id i8k_whitelist_fan_control[]__initdata = { + { + .ident ="Dell Precision 5530" , + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), +DMI_EXACT_MATCH (DMI_PRODUCT_NAME ,"Precision 5530" ), + }, + .driver_data = (void *)&i8k_fan_control_data[I8K_FAN_34A3_35A3 ], + }, + { + .ident ="Dell Latitude E6440" , + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), +DMI_EXACT_MATCH (DMI_PRODUCT_NAME ,"Latitude E6440" ), + }, + .driver_data = (void *)&i8k_fan_control_data[I8K_FAN_34A3_35A3 ], + }, + { } +}; +/* * Probe for the presence of a supported laptop. */ static int __init i8k_probe (void ) { -const struct dmi_system_id *id; +const struct dmi_system_id *id, *fan_control;int fan, ret;/* @@ -1200,6 +1286,14 @@ static int __init i8k_probe(void) i8k_fan_max = fan_max ? :I8K_FAN_HIGH ;/* Must not be 0 */ i8k_pwm_mult =DIV_ROUND_UP (255 , i8k_fan_max); + fan_control =dmi_first_match (i8k_whitelist_fan_control); +if (fan_control && fan_control->driver_data) { +const struct i8k_fan_control_data *fan_control_data = fan_control->driver_data; + manual_fan = fan_control_data->manual_fan; + auto_fan = fan_control_data->auto_fan; +pr_info ("enabling support for setting automatic/manual fan control\n" ); + } +if (!fan_mult) {/* * Autodetect fan multiplier based on nominal rpm
Signature · 2 lines
Pali Rohár [email protected]