2 * dell-smm-hwmon.c -- Linux driver for accessing the SMM BIOS on Dell laptops.
4 * Copyright (C) 2001 Massimo Dal Zotto <dz@debian.org>
7 * Copyright (C) 2011 Jean Delvare <jdelvare@suse.de>
8 * Copyright (C) 2013, 2014 Guenter Roeck <linux@roeck-us.net>
9 * Copyright (C) 2014, 2015 Pali Rohár <pali.rohar@gmail.com>
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2, or (at your option) any
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
22 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
24 #include <linux/delay.h>
25 #include <linux/module.h>
26 #include <linux/types.h>
27 #include <linux/init.h>
28 #include <linux/proc_fs.h>
29 #include <linux/seq_file.h>
30 #include <linux/dmi.h>
31 #include <linux/capability.h>
32 #include <linux/mutex.h>
33 #include <linux/hwmon.h>
34 #include <linux/hwmon-sysfs.h>
35 #include <linux/uaccess.h>
37 #include <linux/sched.h>
39 #include <linux/i8k.h>
41 #define I8K_SMM_FN_STATUS 0x0025
42 #define I8K_SMM_POWER_STATUS 0x0069
43 #define I8K_SMM_SET_FAN 0x01a3
44 #define I8K_SMM_GET_FAN 0x00a3
45 #define I8K_SMM_GET_SPEED 0x02a3
46 #define I8K_SMM_GET_FAN_TYPE 0x03a3
47 #define I8K_SMM_GET_NOM_SPEED 0x04a3
48 #define I8K_SMM_GET_TEMP 0x10a3
49 #define I8K_SMM_GET_TEMP_TYPE 0x11a3
50 #define I8K_SMM_GET_DELL_SIG1 0xfea3
51 #define I8K_SMM_GET_DELL_SIG2 0xffa3
53 #define I8K_FAN_MULT 30
54 #define I8K_FAN_MAX_RPM 30000
55 #define I8K_MAX_TEMP 127
57 #define I8K_FN_NONE 0x00
58 #define I8K_FN_UP 0x01
59 #define I8K_FN_DOWN 0x02
60 #define I8K_FN_MUTE 0x04
61 #define I8K_FN_MASK 0x07
62 #define I8K_FN_SHIFT 8
64 #define I8K_POWER_AC 0x05
65 #define I8K_POWER_BATTERY 0x01
67 static DEFINE_MUTEX(i8k_mutex
);
68 static char bios_version
[4];
69 static struct device
*i8k_hwmon_dev
;
70 static u32 i8k_hwmon_flags
;
71 static uint i8k_fan_mult
= I8K_FAN_MULT
;
72 static uint i8k_pwm_mult
;
73 static uint i8k_fan_max
= I8K_FAN_HIGH
;
75 #define I8K_HWMON_HAVE_TEMP1 (1 << 0)
76 #define I8K_HWMON_HAVE_TEMP2 (1 << 1)
77 #define I8K_HWMON_HAVE_TEMP3 (1 << 2)
78 #define I8K_HWMON_HAVE_TEMP4 (1 << 3)
79 #define I8K_HWMON_HAVE_FAN1 (1 << 4)
80 #define I8K_HWMON_HAVE_FAN2 (1 << 5)
82 MODULE_AUTHOR("Massimo Dal Zotto (dz@debian.org)");
83 MODULE_AUTHOR("Pali Rohár <pali.rohar@gmail.com>");
84 MODULE_DESCRIPTION("Dell laptop SMM BIOS hwmon driver");
85 MODULE_LICENSE("GPL");
89 module_param(force
, bool, 0);
90 MODULE_PARM_DESC(force
, "Force loading without checking for supported models");
92 static bool ignore_dmi
;
93 module_param(ignore_dmi
, bool, 0);
94 MODULE_PARM_DESC(ignore_dmi
, "Continue probing hardware even if DMI data does not match");
96 #if IS_ENABLED(CONFIG_I8K)
97 static bool restricted
;
98 module_param(restricted
, bool, 0);
99 MODULE_PARM_DESC(restricted
, "Allow fan control if SYS_ADMIN capability set");
101 static bool power_status
;
102 module_param(power_status
, bool, 0600);
103 MODULE_PARM_DESC(power_status
, "Report power status in /proc/i8k");
106 static uint fan_mult
;
107 module_param(fan_mult
, uint
, 0);
108 MODULE_PARM_DESC(fan_mult
, "Factor to multiply fan speed with (default: autodetect)");
111 module_param(fan_max
, uint
, 0);
112 MODULE_PARM_DESC(fan_max
, "Maximum configurable fan speed (default: autodetect)");
116 unsigned int ebx __packed
;
117 unsigned int ecx __packed
;
118 unsigned int edx __packed
;
119 unsigned int esi __packed
;
120 unsigned int edi __packed
;
123 static inline const char *i8k_get_dmi_data(int field
)
125 const char *dmi_data
= dmi_get_system_info(field
);
127 return dmi_data
&& *dmi_data
? dmi_data
: "?";
131 * Call the System Management Mode BIOS. Code provided by Jonathan Buzzard.
133 static int i8k_smm(struct smm_regs
*regs
)
137 cpumask_var_t old_mask
;
139 /* SMM requires CPU 0 */
140 if (!alloc_cpumask_var(&old_mask
, GFP_KERNEL
))
142 cpumask_copy(old_mask
, ¤t
->cpus_allowed
);
143 rc
= set_cpus_allowed_ptr(current
, cpumask_of(0));
146 if (smp_processor_id() != 0) {
151 #if defined(CONFIG_X86_64)
152 asm volatile("pushq %%rax\n\t"
153 "movl 0(%%rax),%%edx\n\t"
155 "movl 4(%%rax),%%ebx\n\t"
156 "movl 8(%%rax),%%ecx\n\t"
157 "movl 12(%%rax),%%edx\n\t"
158 "movl 16(%%rax),%%esi\n\t"
159 "movl 20(%%rax),%%edi\n\t"
163 "xchgq %%rax,(%%rsp)\n\t"
164 "movl %%ebx,4(%%rax)\n\t"
165 "movl %%ecx,8(%%rax)\n\t"
166 "movl %%edx,12(%%rax)\n\t"
167 "movl %%esi,16(%%rax)\n\t"
168 "movl %%edi,20(%%rax)\n\t"
170 "movl %%edx,0(%%rax)\n\t"
176 : "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory");
178 asm volatile("pushl %%eax\n\t"
179 "movl 0(%%eax),%%edx\n\t"
181 "movl 4(%%eax),%%ebx\n\t"
182 "movl 8(%%eax),%%ecx\n\t"
183 "movl 12(%%eax),%%edx\n\t"
184 "movl 16(%%eax),%%esi\n\t"
185 "movl 20(%%eax),%%edi\n\t"
189 "xchgl %%eax,(%%esp)\n\t"
190 "movl %%ebx,4(%%eax)\n\t"
191 "movl %%ecx,8(%%eax)\n\t"
192 "movl %%edx,12(%%eax)\n\t"
193 "movl %%esi,16(%%eax)\n\t"
194 "movl %%edi,20(%%eax)\n\t"
196 "movl %%edx,0(%%eax)\n\t"
202 : "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory");
204 if (rc
!= 0 || (regs
->eax
& 0xffff) == 0xffff || regs
->eax
== eax
)
208 set_cpus_allowed_ptr(current
, old_mask
);
209 free_cpumask_var(old_mask
);
214 * Read the fan status.
216 static int i8k_get_fan_status(int fan
)
218 struct smm_regs regs
= { .eax
= I8K_SMM_GET_FAN
, };
220 regs
.ebx
= fan
& 0xff;
221 return i8k_smm(®s
) ? : regs
.eax
& 0xff;
225 * Read the fan speed in RPM.
227 static int i8k_get_fan_speed(int fan
)
229 struct smm_regs regs
= { .eax
= I8K_SMM_GET_SPEED
, };
231 regs
.ebx
= fan
& 0xff;
232 return i8k_smm(®s
) ? : (regs
.eax
& 0xffff) * i8k_fan_mult
;
238 static int i8k_get_fan_type(int fan
)
240 struct smm_regs regs
= { .eax
= I8K_SMM_GET_FAN_TYPE
, };
242 regs
.ebx
= fan
& 0xff;
243 return i8k_smm(®s
) ? : regs
.eax
& 0xff;
247 * Read the fan nominal rpm for specific fan speed.
249 static int i8k_get_fan_nominal_speed(int fan
, int speed
)
251 struct smm_regs regs
= { .eax
= I8K_SMM_GET_NOM_SPEED
, };
253 regs
.ebx
= (fan
& 0xff) | (speed
<< 8);
254 return i8k_smm(®s
) ? : (regs
.eax
& 0xffff) * i8k_fan_mult
;
258 * Set the fan speed (off, low, high). Returns the new fan status.
260 static int i8k_set_fan(int fan
, int speed
)
262 struct smm_regs regs
= { .eax
= I8K_SMM_SET_FAN
, };
264 speed
= (speed
< 0) ? 0 : ((speed
> i8k_fan_max
) ? i8k_fan_max
: speed
);
265 regs
.ebx
= (fan
& 0xff) | (speed
<< 8);
267 return i8k_smm(®s
) ? : i8k_get_fan_status(fan
);
270 static int i8k_get_temp_type(int sensor
)
272 struct smm_regs regs
= { .eax
= I8K_SMM_GET_TEMP_TYPE
, };
274 regs
.ebx
= sensor
& 0xff;
275 return i8k_smm(®s
) ? : regs
.eax
& 0xff;
279 * Read the cpu temperature.
281 static int _i8k_get_temp(int sensor
)
283 struct smm_regs regs
= {
284 .eax
= I8K_SMM_GET_TEMP
,
285 .ebx
= sensor
& 0xff,
288 return i8k_smm(®s
) ? : regs
.eax
& 0xff;
291 static int i8k_get_temp(int sensor
)
293 int temp
= _i8k_get_temp(sensor
);
296 * Sometimes the temperature sensor returns 0x99, which is out of range.
297 * In this case we retry (once) before returning an error.
298 # 1003655137 00000058 00005a4b
299 # 1003655138 00000099 00003a80 <--- 0x99 = 153 degrees
300 # 1003655139 00000054 00005c52
304 temp
= _i8k_get_temp(sensor
);
307 * Return -ENODATA for all invalid temperatures.
309 * Known instances are the 0x99 value as seen above as well as
310 * 0xc1 (193), which may be returned when trying to read the GPU
311 * temperature if the system supports a GPU and it is currently
314 if (temp
> I8K_MAX_TEMP
)
320 static int i8k_get_dell_signature(int req_fn
)
322 struct smm_regs regs
= { .eax
= req_fn
, };
329 return regs
.eax
== 1145651527 && regs
.edx
== 1145392204 ? 0 : -1;
332 #if IS_ENABLED(CONFIG_I8K)
335 * Read the Fn key status.
337 static int i8k_get_fn_status(void)
339 struct smm_regs regs
= { .eax
= I8K_SMM_FN_STATUS
, };
346 switch ((regs
.eax
>> I8K_FN_SHIFT
) & I8K_FN_MASK
) {
359 * Read the power status.
361 static int i8k_get_power_status(void)
363 struct smm_regs regs
= { .eax
= I8K_SMM_POWER_STATUS
, };
370 return (regs
.eax
& 0xff) == I8K_POWER_AC
? I8K_AC
: I8K_BATTERY
;
378 i8k_ioctl_unlocked(struct file
*fp
, unsigned int cmd
, unsigned long arg
)
382 unsigned char buff
[16];
383 int __user
*argp
= (int __user
*)arg
;
389 case I8K_BIOS_VERSION
:
390 val
= (bios_version
[0] << 16) |
391 (bios_version
[1] << 8) | bios_version
[2];
396 strlcpy(buff
, i8k_get_dmi_data(DMI_PRODUCT_SERIAL
),
401 val
= i8k_get_fn_status();
404 case I8K_POWER_STATUS
:
405 val
= i8k_get_power_status();
409 val
= i8k_get_temp(0);
413 if (copy_from_user(&val
, argp
, sizeof(int)))
416 val
= i8k_get_fan_speed(val
);
420 if (copy_from_user(&val
, argp
, sizeof(int)))
423 val
= i8k_get_fan_status(val
);
427 if (restricted
&& !capable(CAP_SYS_ADMIN
))
430 if (copy_from_user(&val
, argp
, sizeof(int)))
433 if (copy_from_user(&speed
, argp
+ 1, sizeof(int)))
436 val
= i8k_set_fan(val
, speed
);
447 case I8K_BIOS_VERSION
:
448 if (copy_to_user(argp
, &val
, 4))
453 if (copy_to_user(argp
, buff
, 16))
458 if (copy_to_user(argp
, &val
, sizeof(int)))
467 static long i8k_ioctl(struct file
*fp
, unsigned int cmd
, unsigned long arg
)
471 mutex_lock(&i8k_mutex
);
472 ret
= i8k_ioctl_unlocked(fp
, cmd
, arg
);
473 mutex_unlock(&i8k_mutex
);
479 * Print the information for /proc/i8k.
481 static int i8k_proc_show(struct seq_file
*seq
, void *offset
)
483 int fn_key
, cpu_temp
, ac_power
;
484 int left_fan
, right_fan
, left_speed
, right_speed
;
486 cpu_temp
= i8k_get_temp(0); /* 11100 µs */
487 left_fan
= i8k_get_fan_status(I8K_FAN_LEFT
); /* 580 µs */
488 right_fan
= i8k_get_fan_status(I8K_FAN_RIGHT
); /* 580 µs */
489 left_speed
= i8k_get_fan_speed(I8K_FAN_LEFT
); /* 580 µs */
490 right_speed
= i8k_get_fan_speed(I8K_FAN_RIGHT
); /* 580 µs */
491 fn_key
= i8k_get_fn_status(); /* 750 µs */
493 ac_power
= i8k_get_power_status(); /* 14700 µs */
500 * 1) Format version (this will change if format changes)
505 * 6) Right fan status
511 seq_printf(seq
, "%s %s %s %d %d %d %d %d %d %d\n",
514 i8k_get_dmi_data(DMI_PRODUCT_SERIAL
),
516 left_fan
, right_fan
, left_speed
, right_speed
,
522 static int i8k_open_fs(struct inode
*inode
, struct file
*file
)
524 return single_open(file
, i8k_proc_show
, NULL
);
527 static const struct file_operations i8k_fops
= {
528 .owner
= THIS_MODULE
,
532 .release
= single_release
,
533 .unlocked_ioctl
= i8k_ioctl
,
536 static void __init
i8k_init_procfs(void)
538 /* Register the proc entry */
539 proc_create("i8k", 0, NULL
, &i8k_fops
);
542 static void __exit
i8k_exit_procfs(void)
544 remove_proc_entry("i8k", NULL
);
549 static inline void __init
i8k_init_procfs(void)
553 static inline void __exit
i8k_exit_procfs(void)
563 static ssize_t
i8k_hwmon_show_temp_label(struct device
*dev
,
564 struct device_attribute
*devattr
,
567 static const char * const labels
[] = {
575 int index
= to_sensor_dev_attr(devattr
)->index
;
578 type
= i8k_get_temp_type(index
);
581 if (type
>= ARRAY_SIZE(labels
))
582 type
= ARRAY_SIZE(labels
) - 1;
583 return sprintf(buf
, "%s\n", labels
[type
]);
586 static ssize_t
i8k_hwmon_show_temp(struct device
*dev
,
587 struct device_attribute
*devattr
,
590 int index
= to_sensor_dev_attr(devattr
)->index
;
593 temp
= i8k_get_temp(index
);
596 return sprintf(buf
, "%d\n", temp
* 1000);
599 static ssize_t
i8k_hwmon_show_fan_label(struct device
*dev
,
600 struct device_attribute
*devattr
,
603 static const char * const labels
[] = {
611 int index
= to_sensor_dev_attr(devattr
)->index
;
615 type
= i8k_get_fan_type(index
);
624 if (type
>= ARRAY_SIZE(labels
))
625 type
= (ARRAY_SIZE(labels
) - 1);
627 return sprintf(buf
, "%s%s\n", (dock
? "Docking " : ""), labels
[type
]);
630 static ssize_t
i8k_hwmon_show_fan(struct device
*dev
,
631 struct device_attribute
*devattr
,
634 int index
= to_sensor_dev_attr(devattr
)->index
;
637 fan_speed
= i8k_get_fan_speed(index
);
640 return sprintf(buf
, "%d\n", fan_speed
);
643 static ssize_t
i8k_hwmon_show_pwm(struct device
*dev
,
644 struct device_attribute
*devattr
,
647 int index
= to_sensor_dev_attr(devattr
)->index
;
650 status
= i8k_get_fan_status(index
);
653 return sprintf(buf
, "%d\n", clamp_val(status
* i8k_pwm_mult
, 0, 255));
656 static ssize_t
i8k_hwmon_set_pwm(struct device
*dev
,
657 struct device_attribute
*attr
,
658 const char *buf
, size_t count
)
660 int index
= to_sensor_dev_attr(attr
)->index
;
664 err
= kstrtoul(buf
, 10, &val
);
667 val
= clamp_val(DIV_ROUND_CLOSEST(val
, i8k_pwm_mult
), 0, i8k_fan_max
);
669 mutex_lock(&i8k_mutex
);
670 err
= i8k_set_fan(index
, val
);
671 mutex_unlock(&i8k_mutex
);
673 return err
< 0 ? -EIO
: count
;
676 static SENSOR_DEVICE_ATTR(temp1_input
, S_IRUGO
, i8k_hwmon_show_temp
, NULL
, 0);
677 static SENSOR_DEVICE_ATTR(temp1_label
, S_IRUGO
, i8k_hwmon_show_temp_label
, NULL
,
679 static SENSOR_DEVICE_ATTR(temp2_input
, S_IRUGO
, i8k_hwmon_show_temp
, NULL
, 1);
680 static SENSOR_DEVICE_ATTR(temp2_label
, S_IRUGO
, i8k_hwmon_show_temp_label
, NULL
,
682 static SENSOR_DEVICE_ATTR(temp3_input
, S_IRUGO
, i8k_hwmon_show_temp
, NULL
, 2);
683 static SENSOR_DEVICE_ATTR(temp3_label
, S_IRUGO
, i8k_hwmon_show_temp_label
, NULL
,
685 static SENSOR_DEVICE_ATTR(temp4_input
, S_IRUGO
, i8k_hwmon_show_temp
, NULL
, 3);
686 static SENSOR_DEVICE_ATTR(temp4_label
, S_IRUGO
, i8k_hwmon_show_temp_label
, NULL
,
688 static SENSOR_DEVICE_ATTR(fan1_input
, S_IRUGO
, i8k_hwmon_show_fan
, NULL
, 0);
689 static SENSOR_DEVICE_ATTR(fan1_label
, S_IRUGO
, i8k_hwmon_show_fan_label
, NULL
,
691 static SENSOR_DEVICE_ATTR(pwm1
, S_IRUGO
| S_IWUSR
, i8k_hwmon_show_pwm
,
692 i8k_hwmon_set_pwm
, 0);
693 static SENSOR_DEVICE_ATTR(fan2_input
, S_IRUGO
, i8k_hwmon_show_fan
, NULL
,
695 static SENSOR_DEVICE_ATTR(fan2_label
, S_IRUGO
, i8k_hwmon_show_fan_label
, NULL
,
697 static SENSOR_DEVICE_ATTR(pwm2
, S_IRUGO
| S_IWUSR
, i8k_hwmon_show_pwm
,
698 i8k_hwmon_set_pwm
, 1);
700 static struct attribute
*i8k_attrs
[] = {
701 &sensor_dev_attr_temp1_input
.dev_attr
.attr
, /* 0 */
702 &sensor_dev_attr_temp1_label
.dev_attr
.attr
, /* 1 */
703 &sensor_dev_attr_temp2_input
.dev_attr
.attr
, /* 2 */
704 &sensor_dev_attr_temp2_label
.dev_attr
.attr
, /* 3 */
705 &sensor_dev_attr_temp3_input
.dev_attr
.attr
, /* 4 */
706 &sensor_dev_attr_temp3_label
.dev_attr
.attr
, /* 5 */
707 &sensor_dev_attr_temp4_input
.dev_attr
.attr
, /* 6 */
708 &sensor_dev_attr_temp4_label
.dev_attr
.attr
, /* 7 */
709 &sensor_dev_attr_fan1_input
.dev_attr
.attr
, /* 8 */
710 &sensor_dev_attr_fan1_label
.dev_attr
.attr
, /* 9 */
711 &sensor_dev_attr_pwm1
.dev_attr
.attr
, /* 10 */
712 &sensor_dev_attr_fan2_input
.dev_attr
.attr
, /* 11 */
713 &sensor_dev_attr_fan2_label
.dev_attr
.attr
, /* 12 */
714 &sensor_dev_attr_pwm2
.dev_attr
.attr
, /* 13 */
718 static umode_t
i8k_is_visible(struct kobject
*kobj
, struct attribute
*attr
,
721 if (index
>= 0 && index
<= 1 &&
722 !(i8k_hwmon_flags
& I8K_HWMON_HAVE_TEMP1
))
724 if (index
>= 2 && index
<= 3 &&
725 !(i8k_hwmon_flags
& I8K_HWMON_HAVE_TEMP2
))
727 if (index
>= 4 && index
<= 5 &&
728 !(i8k_hwmon_flags
& I8K_HWMON_HAVE_TEMP3
))
730 if (index
>= 6 && index
<= 7 &&
731 !(i8k_hwmon_flags
& I8K_HWMON_HAVE_TEMP4
))
733 if (index
>= 8 && index
<= 10 &&
734 !(i8k_hwmon_flags
& I8K_HWMON_HAVE_FAN1
))
736 if (index
>= 11 && index
<= 13 &&
737 !(i8k_hwmon_flags
& I8K_HWMON_HAVE_FAN2
))
743 static const struct attribute_group i8k_group
= {
745 .is_visible
= i8k_is_visible
,
747 __ATTRIBUTE_GROUPS(i8k
);
749 static int __init
i8k_init_hwmon(void)
755 /* CPU temperature attributes, if temperature type is OK */
756 err
= i8k_get_temp_type(0);
758 i8k_hwmon_flags
|= I8K_HWMON_HAVE_TEMP1
;
759 /* check for additional temperature sensors */
760 err
= i8k_get_temp_type(1);
762 i8k_hwmon_flags
|= I8K_HWMON_HAVE_TEMP2
;
763 err
= i8k_get_temp_type(2);
765 i8k_hwmon_flags
|= I8K_HWMON_HAVE_TEMP3
;
766 err
= i8k_get_temp_type(3);
768 i8k_hwmon_flags
|= I8K_HWMON_HAVE_TEMP4
;
770 /* First fan attributes, if fan type is OK */
771 err
= i8k_get_fan_type(0);
773 i8k_hwmon_flags
|= I8K_HWMON_HAVE_FAN1
;
775 /* Second fan attributes, if fan type is OK */
776 err
= i8k_get_fan_type(1);
778 i8k_hwmon_flags
|= I8K_HWMON_HAVE_FAN2
;
780 i8k_hwmon_dev
= hwmon_device_register_with_groups(NULL
, "dell_smm",
782 if (IS_ERR(i8k_hwmon_dev
)) {
783 err
= PTR_ERR(i8k_hwmon_dev
);
784 i8k_hwmon_dev
= NULL
;
785 pr_err("hwmon registration failed (%d)\n", err
);
791 struct i8k_config_data
{
803 static const struct i8k_config_data i8k_config_data
[] = {
804 [DELL_LATITUDE_D520
] = {
806 .fan_max
= I8K_FAN_TURBO
,
808 [DELL_PRECISION_490
] = {
810 .fan_max
= I8K_FAN_TURBO
,
814 .fan_max
= I8K_FAN_HIGH
,
818 .fan_max
= I8K_FAN_HIGH
,
822 static struct dmi_system_id i8k_dmi_table
[] __initdata
= {
824 .ident
= "Dell Inspiron",
826 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Computer"),
827 DMI_MATCH(DMI_PRODUCT_NAME
, "Inspiron"),
831 .ident
= "Dell Latitude",
833 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Computer"),
834 DMI_MATCH(DMI_PRODUCT_NAME
, "Latitude"),
838 .ident
= "Dell Inspiron 2",
840 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
841 DMI_MATCH(DMI_PRODUCT_NAME
, "Inspiron"),
845 .ident
= "Dell Latitude D520",
847 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
848 DMI_MATCH(DMI_PRODUCT_NAME
, "Latitude D520"),
850 .driver_data
= (void *)&i8k_config_data
[DELL_LATITUDE_D520
],
853 .ident
= "Dell Latitude 2",
855 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
856 DMI_MATCH(DMI_PRODUCT_NAME
, "Latitude"),
859 { /* UK Inspiron 6400 */
860 .ident
= "Dell Inspiron 3",
862 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
863 DMI_MATCH(DMI_PRODUCT_NAME
, "MM061"),
867 .ident
= "Dell Inspiron 3",
869 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
870 DMI_MATCH(DMI_PRODUCT_NAME
, "MP061"),
874 .ident
= "Dell Precision 490",
876 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
877 DMI_MATCH(DMI_PRODUCT_NAME
,
878 "Precision WorkStation 490"),
880 .driver_data
= (void *)&i8k_config_data
[DELL_PRECISION_490
],
883 .ident
= "Dell Precision",
885 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
886 DMI_MATCH(DMI_PRODUCT_NAME
, "Precision"),
890 .ident
= "Dell Vostro",
892 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
893 DMI_MATCH(DMI_PRODUCT_NAME
, "Vostro"),
897 .ident
= "Dell XPS421",
899 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
900 DMI_MATCH(DMI_PRODUCT_NAME
, "XPS L421X"),
904 .ident
= "Dell Studio",
906 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
907 DMI_MATCH(DMI_PRODUCT_NAME
, "Studio"),
909 .driver_data
= (void *)&i8k_config_data
[DELL_STUDIO
],
912 .ident
= "Dell XPS 13",
914 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
915 DMI_MATCH(DMI_PRODUCT_NAME
, "XPS13"),
917 .driver_data
= (void *)&i8k_config_data
[DELL_XPS
],
920 .ident
= "Dell XPS M140",
922 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
923 DMI_MATCH(DMI_PRODUCT_NAME
, "MXC051"),
925 .driver_data
= (void *)&i8k_config_data
[DELL_XPS
],
930 MODULE_DEVICE_TABLE(dmi
, i8k_dmi_table
);
932 static struct dmi_system_id i8k_blacklist_dmi_table
[] __initdata
= {
935 * CPU fan speed going up and down on Dell Studio XPS 8100
936 * for unknown reasons.
938 .ident
= "Dell Studio XPS 8100",
940 DMI_EXACT_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
941 DMI_EXACT_MATCH(DMI_PRODUCT_NAME
, "Studio XPS 8100"),
948 * Probe for the presence of a supported laptop.
950 static int __init
i8k_probe(void)
952 const struct dmi_system_id
*id
;
956 * Get DMI information
958 if (!dmi_check_system(i8k_dmi_table
) ||
959 dmi_check_system(i8k_blacklist_dmi_table
)) {
960 if (!ignore_dmi
&& !force
)
963 pr_info("not running on a supported Dell system.\n");
964 pr_info("vendor=%s, model=%s, version=%s\n",
965 i8k_get_dmi_data(DMI_SYS_VENDOR
),
966 i8k_get_dmi_data(DMI_PRODUCT_NAME
),
967 i8k_get_dmi_data(DMI_BIOS_VERSION
));
970 strlcpy(bios_version
, i8k_get_dmi_data(DMI_BIOS_VERSION
),
971 sizeof(bios_version
));
974 * Get SMM Dell signature
976 if (i8k_get_dell_signature(I8K_SMM_GET_DELL_SIG1
) &&
977 i8k_get_dell_signature(I8K_SMM_GET_DELL_SIG2
)) {
978 pr_err("unable to get SMM Dell signature\n");
984 * Set fan multiplier and maximal fan speed from dmi config
985 * Values specified in module parameters override values from dmi
987 id
= dmi_first_match(i8k_dmi_table
);
988 if (id
&& id
->driver_data
) {
989 const struct i8k_config_data
*conf
= id
->driver_data
;
990 if (!fan_mult
&& conf
->fan_mult
)
991 fan_mult
= conf
->fan_mult
;
992 if (!fan_max
&& conf
->fan_max
)
993 fan_max
= conf
->fan_max
;
996 i8k_fan_max
= fan_max
? : I8K_FAN_HIGH
; /* Must not be 0 */
997 i8k_pwm_mult
= DIV_ROUND_UP(255, i8k_fan_max
);
1001 * Autodetect fan multiplier based on nominal rpm
1002 * If fan reports rpm value too high then set multiplier to 1
1004 for (fan
= 0; fan
< 2; ++fan
) {
1005 ret
= i8k_get_fan_nominal_speed(fan
, i8k_fan_max
);
1008 if (ret
> I8K_FAN_MAX_RPM
)
1013 /* Fan multiplier was specified in module param or in dmi */
1014 i8k_fan_mult
= fan_mult
;
1020 static int __init
i8k_init(void)
1024 /* Are we running on an supported laptop? */
1028 err
= i8k_init_hwmon();
1036 static void __exit
i8k_exit(void)
1038 hwmon_device_unregister(i8k_hwmon_dev
);
1042 module_init(i8k_init
);
1043 module_exit(i8k_exit
);