2 * i8k.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 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_DESCRIPTION("Driver for accessing SMM BIOS on Dell laptops");
84 MODULE_LICENSE("GPL");
87 module_param(force
, bool, 0);
88 MODULE_PARM_DESC(force
, "Force loading without checking for supported models");
90 static bool ignore_dmi
;
91 module_param(ignore_dmi
, bool, 0);
92 MODULE_PARM_DESC(ignore_dmi
, "Continue probing hardware even if DMI data does not match");
94 static bool restricted
;
95 module_param(restricted
, bool, 0);
96 MODULE_PARM_DESC(restricted
, "Allow fan control if SYS_ADMIN capability set");
98 static bool power_status
;
99 module_param(power_status
, bool, 0600);
100 MODULE_PARM_DESC(power_status
, "Report power status in /proc/i8k");
102 static uint fan_mult
;
103 module_param(fan_mult
, uint
, 0);
104 MODULE_PARM_DESC(fan_mult
, "Factor to multiply fan speed with (default: autodetect)");
107 module_param(fan_max
, uint
, 0);
108 MODULE_PARM_DESC(fan_max
, "Maximum configurable fan speed (default: autodetect)");
110 static int i8k_open_fs(struct inode
*inode
, struct file
*file
);
111 static long i8k_ioctl(struct file
*, unsigned int, unsigned long);
113 static const struct file_operations i8k_fops
= {
114 .owner
= THIS_MODULE
,
118 .release
= single_release
,
119 .unlocked_ioctl
= i8k_ioctl
,
124 unsigned int ebx __packed
;
125 unsigned int ecx __packed
;
126 unsigned int edx __packed
;
127 unsigned int esi __packed
;
128 unsigned int edi __packed
;
131 static inline const char *i8k_get_dmi_data(int field
)
133 const char *dmi_data
= dmi_get_system_info(field
);
135 return dmi_data
&& *dmi_data
? dmi_data
: "?";
139 * Call the System Management Mode BIOS. Code provided by Jonathan Buzzard.
141 static int i8k_smm(struct smm_regs
*regs
)
145 cpumask_var_t old_mask
;
147 /* SMM requires CPU 0 */
148 if (!alloc_cpumask_var(&old_mask
, GFP_KERNEL
))
150 cpumask_copy(old_mask
, ¤t
->cpus_allowed
);
151 rc
= set_cpus_allowed_ptr(current
, cpumask_of(0));
154 if (smp_processor_id() != 0) {
159 #if defined(CONFIG_X86_64)
160 asm volatile("pushq %%rax\n\t"
161 "movl 0(%%rax),%%edx\n\t"
163 "movl 4(%%rax),%%ebx\n\t"
164 "movl 8(%%rax),%%ecx\n\t"
165 "movl 12(%%rax),%%edx\n\t"
166 "movl 16(%%rax),%%esi\n\t"
167 "movl 20(%%rax),%%edi\n\t"
171 "xchgq %%rax,(%%rsp)\n\t"
172 "movl %%ebx,4(%%rax)\n\t"
173 "movl %%ecx,8(%%rax)\n\t"
174 "movl %%edx,12(%%rax)\n\t"
175 "movl %%esi,16(%%rax)\n\t"
176 "movl %%edi,20(%%rax)\n\t"
178 "movl %%edx,0(%%rax)\n\t"
184 : "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory");
186 asm volatile("pushl %%eax\n\t"
187 "movl 0(%%eax),%%edx\n\t"
189 "movl 4(%%eax),%%ebx\n\t"
190 "movl 8(%%eax),%%ecx\n\t"
191 "movl 12(%%eax),%%edx\n\t"
192 "movl 16(%%eax),%%esi\n\t"
193 "movl 20(%%eax),%%edi\n\t"
197 "xchgl %%eax,(%%esp)\n\t"
198 "movl %%ebx,4(%%eax)\n\t"
199 "movl %%ecx,8(%%eax)\n\t"
200 "movl %%edx,12(%%eax)\n\t"
201 "movl %%esi,16(%%eax)\n\t"
202 "movl %%edi,20(%%eax)\n\t"
204 "movl %%edx,0(%%eax)\n\t"
210 : "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory");
212 if (rc
!= 0 || (regs
->eax
& 0xffff) == 0xffff || regs
->eax
== eax
)
216 set_cpus_allowed_ptr(current
, old_mask
);
217 free_cpumask_var(old_mask
);
222 * Read the Fn key status.
224 static int i8k_get_fn_status(void)
226 struct smm_regs regs
= { .eax
= I8K_SMM_FN_STATUS
, };
233 switch ((regs
.eax
>> I8K_FN_SHIFT
) & I8K_FN_MASK
) {
246 * Read the power status.
248 static int i8k_get_power_status(void)
250 struct smm_regs regs
= { .eax
= I8K_SMM_POWER_STATUS
, };
257 return (regs
.eax
& 0xff) == I8K_POWER_AC
? I8K_AC
: I8K_BATTERY
;
261 * Read the fan status.
263 static int i8k_get_fan_status(int fan
)
265 struct smm_regs regs
= { .eax
= I8K_SMM_GET_FAN
, };
267 regs
.ebx
= fan
& 0xff;
268 return i8k_smm(®s
) ? : regs
.eax
& 0xff;
272 * Read the fan speed in RPM.
274 static int i8k_get_fan_speed(int fan
)
276 struct smm_regs regs
= { .eax
= I8K_SMM_GET_SPEED
, };
278 regs
.ebx
= fan
& 0xff;
279 return i8k_smm(®s
) ? : (regs
.eax
& 0xffff) * i8k_fan_mult
;
285 static int i8k_get_fan_type(int fan
)
287 struct smm_regs regs
= { .eax
= I8K_SMM_GET_FAN_TYPE
, };
289 regs
.ebx
= fan
& 0xff;
290 return i8k_smm(®s
) ? : regs
.eax
& 0xff;
294 * Read the fan nominal rpm for specific fan speed.
296 static int i8k_get_fan_nominal_speed(int fan
, int speed
)
298 struct smm_regs regs
= { .eax
= I8K_SMM_GET_NOM_SPEED
, };
300 regs
.ebx
= (fan
& 0xff) | (speed
<< 8);
301 return i8k_smm(®s
) ? : (regs
.eax
& 0xffff) * i8k_fan_mult
;
305 * Set the fan speed (off, low, high). Returns the new fan status.
307 static int i8k_set_fan(int fan
, int speed
)
309 struct smm_regs regs
= { .eax
= I8K_SMM_SET_FAN
, };
311 speed
= (speed
< 0) ? 0 : ((speed
> i8k_fan_max
) ? i8k_fan_max
: speed
);
312 regs
.ebx
= (fan
& 0xff) | (speed
<< 8);
314 return i8k_smm(®s
) ? : i8k_get_fan_status(fan
);
317 static int i8k_get_temp_type(int sensor
)
319 struct smm_regs regs
= { .eax
= I8K_SMM_GET_TEMP_TYPE
, };
321 regs
.ebx
= sensor
& 0xff;
322 return i8k_smm(®s
) ? : regs
.eax
& 0xff;
326 * Read the cpu temperature.
328 static int _i8k_get_temp(int sensor
)
330 struct smm_regs regs
= {
331 .eax
= I8K_SMM_GET_TEMP
,
332 .ebx
= sensor
& 0xff,
335 return i8k_smm(®s
) ? : regs
.eax
& 0xff;
338 static int i8k_get_temp(int sensor
)
340 int temp
= _i8k_get_temp(sensor
);
343 * Sometimes the temperature sensor returns 0x99, which is out of range.
344 * In this case we retry (once) before returning an error.
345 # 1003655137 00000058 00005a4b
346 # 1003655138 00000099 00003a80 <--- 0x99 = 153 degrees
347 # 1003655139 00000054 00005c52
351 temp
= _i8k_get_temp(sensor
);
354 * Return -ENODATA for all invalid temperatures.
356 * Known instances are the 0x99 value as seen above as well as
357 * 0xc1 (193), which may be returned when trying to read the GPU
358 * temperature if the system supports a GPU and it is currently
361 if (temp
> I8K_MAX_TEMP
)
367 static int i8k_get_dell_signature(int req_fn
)
369 struct smm_regs regs
= { .eax
= req_fn
, };
376 return regs
.eax
== 1145651527 && regs
.edx
== 1145392204 ? 0 : -1;
380 i8k_ioctl_unlocked(struct file
*fp
, unsigned int cmd
, unsigned long arg
)
384 unsigned char buff
[16];
385 int __user
*argp
= (int __user
*)arg
;
391 case I8K_BIOS_VERSION
:
392 val
= (bios_version
[0] << 16) |
393 (bios_version
[1] << 8) | bios_version
[2];
398 strlcpy(buff
, i8k_get_dmi_data(DMI_PRODUCT_SERIAL
),
403 val
= i8k_get_fn_status();
406 case I8K_POWER_STATUS
:
407 val
= i8k_get_power_status();
411 val
= i8k_get_temp(0);
415 if (copy_from_user(&val
, argp
, sizeof(int)))
418 val
= i8k_get_fan_speed(val
);
422 if (copy_from_user(&val
, argp
, sizeof(int)))
425 val
= i8k_get_fan_status(val
);
429 if (restricted
&& !capable(CAP_SYS_ADMIN
))
432 if (copy_from_user(&val
, argp
, sizeof(int)))
435 if (copy_from_user(&speed
, argp
+ 1, sizeof(int)))
438 val
= i8k_set_fan(val
, speed
);
449 case I8K_BIOS_VERSION
:
450 if (copy_to_user(argp
, &val
, 4))
455 if (copy_to_user(argp
, buff
, 16))
460 if (copy_to_user(argp
, &val
, sizeof(int)))
469 static long i8k_ioctl(struct file
*fp
, unsigned int cmd
, unsigned long arg
)
473 mutex_lock(&i8k_mutex
);
474 ret
= i8k_ioctl_unlocked(fp
, cmd
, arg
);
475 mutex_unlock(&i8k_mutex
);
481 * Print the information for /proc/i8k.
483 static int i8k_proc_show(struct seq_file
*seq
, void *offset
)
485 int fn_key
, cpu_temp
, ac_power
;
486 int left_fan
, right_fan
, left_speed
, right_speed
;
488 cpu_temp
= i8k_get_temp(0); /* 11100 µs */
489 left_fan
= i8k_get_fan_status(I8K_FAN_LEFT
); /* 580 µs */
490 right_fan
= i8k_get_fan_status(I8K_FAN_RIGHT
); /* 580 µs */
491 left_speed
= i8k_get_fan_speed(I8K_FAN_LEFT
); /* 580 µs */
492 right_speed
= i8k_get_fan_speed(I8K_FAN_RIGHT
); /* 580 µs */
493 fn_key
= i8k_get_fn_status(); /* 750 µs */
495 ac_power
= i8k_get_power_status(); /* 14700 µs */
502 * 1) Format version (this will change if format changes)
507 * 6) Right fan status
513 seq_printf(seq
, "%s %s %s %d %d %d %d %d %d %d\n",
516 i8k_get_dmi_data(DMI_PRODUCT_SERIAL
),
518 left_fan
, right_fan
, left_speed
, right_speed
,
524 static int i8k_open_fs(struct inode
*inode
, struct file
*file
)
526 return single_open(file
, i8k_proc_show
, NULL
);
534 static ssize_t
i8k_hwmon_show_temp_label(struct device
*dev
,
535 struct device_attribute
*devattr
,
538 static const char * const labels
[] = {
546 int index
= to_sensor_dev_attr(devattr
)->index
;
549 type
= i8k_get_temp_type(index
);
552 if (type
>= ARRAY_SIZE(labels
))
553 type
= ARRAY_SIZE(labels
) - 1;
554 return sprintf(buf
, "%s\n", labels
[type
]);
557 static ssize_t
i8k_hwmon_show_temp(struct device
*dev
,
558 struct device_attribute
*devattr
,
561 int index
= to_sensor_dev_attr(devattr
)->index
;
564 temp
= i8k_get_temp(index
);
567 return sprintf(buf
, "%d\n", temp
* 1000);
570 static ssize_t
i8k_hwmon_show_fan_label(struct device
*dev
,
571 struct device_attribute
*devattr
,
574 static const char * const labels
[] = {
582 int index
= to_sensor_dev_attr(devattr
)->index
;
586 type
= i8k_get_fan_type(index
);
595 if (type
>= ARRAY_SIZE(labels
))
596 type
= (ARRAY_SIZE(labels
) - 1);
598 return sprintf(buf
, "%s%s\n", (dock
? "Docking " : ""), labels
[type
]);
601 static ssize_t
i8k_hwmon_show_fan(struct device
*dev
,
602 struct device_attribute
*devattr
,
605 int index
= to_sensor_dev_attr(devattr
)->index
;
608 fan_speed
= i8k_get_fan_speed(index
);
611 return sprintf(buf
, "%d\n", fan_speed
);
614 static ssize_t
i8k_hwmon_show_pwm(struct device
*dev
,
615 struct device_attribute
*devattr
,
618 int index
= to_sensor_dev_attr(devattr
)->index
;
621 status
= i8k_get_fan_status(index
);
624 return sprintf(buf
, "%d\n", clamp_val(status
* i8k_pwm_mult
, 0, 255));
627 static ssize_t
i8k_hwmon_set_pwm(struct device
*dev
,
628 struct device_attribute
*attr
,
629 const char *buf
, size_t count
)
631 int index
= to_sensor_dev_attr(attr
)->index
;
635 err
= kstrtoul(buf
, 10, &val
);
638 val
= clamp_val(DIV_ROUND_CLOSEST(val
, i8k_pwm_mult
), 0, i8k_fan_max
);
640 mutex_lock(&i8k_mutex
);
641 err
= i8k_set_fan(index
, val
);
642 mutex_unlock(&i8k_mutex
);
644 return err
< 0 ? -EIO
: count
;
647 static SENSOR_DEVICE_ATTR(temp1_input
, S_IRUGO
, i8k_hwmon_show_temp
, NULL
, 0);
648 static SENSOR_DEVICE_ATTR(temp1_label
, S_IRUGO
, i8k_hwmon_show_temp_label
, NULL
,
650 static SENSOR_DEVICE_ATTR(temp2_input
, S_IRUGO
, i8k_hwmon_show_temp
, NULL
, 1);
651 static SENSOR_DEVICE_ATTR(temp2_label
, S_IRUGO
, i8k_hwmon_show_temp_label
, NULL
,
653 static SENSOR_DEVICE_ATTR(temp3_input
, S_IRUGO
, i8k_hwmon_show_temp
, NULL
, 2);
654 static SENSOR_DEVICE_ATTR(temp3_label
, S_IRUGO
, i8k_hwmon_show_temp_label
, NULL
,
656 static SENSOR_DEVICE_ATTR(temp4_input
, S_IRUGO
, i8k_hwmon_show_temp
, NULL
, 3);
657 static SENSOR_DEVICE_ATTR(temp4_label
, S_IRUGO
, i8k_hwmon_show_temp_label
, NULL
,
659 static SENSOR_DEVICE_ATTR(fan1_input
, S_IRUGO
, i8k_hwmon_show_fan
, NULL
, 0);
660 static SENSOR_DEVICE_ATTR(fan1_label
, S_IRUGO
, i8k_hwmon_show_fan_label
, NULL
,
662 static SENSOR_DEVICE_ATTR(pwm1
, S_IRUGO
| S_IWUSR
, i8k_hwmon_show_pwm
,
663 i8k_hwmon_set_pwm
, 0);
664 static SENSOR_DEVICE_ATTR(fan2_input
, S_IRUGO
, i8k_hwmon_show_fan
, NULL
,
666 static SENSOR_DEVICE_ATTR(fan2_label
, S_IRUGO
, i8k_hwmon_show_fan_label
, NULL
,
668 static SENSOR_DEVICE_ATTR(pwm2
, S_IRUGO
| S_IWUSR
, i8k_hwmon_show_pwm
,
669 i8k_hwmon_set_pwm
, 1);
671 static struct attribute
*i8k_attrs
[] = {
672 &sensor_dev_attr_temp1_input
.dev_attr
.attr
, /* 0 */
673 &sensor_dev_attr_temp1_label
.dev_attr
.attr
, /* 1 */
674 &sensor_dev_attr_temp2_input
.dev_attr
.attr
, /* 2 */
675 &sensor_dev_attr_temp2_label
.dev_attr
.attr
, /* 3 */
676 &sensor_dev_attr_temp3_input
.dev_attr
.attr
, /* 4 */
677 &sensor_dev_attr_temp3_label
.dev_attr
.attr
, /* 5 */
678 &sensor_dev_attr_temp4_input
.dev_attr
.attr
, /* 6 */
679 &sensor_dev_attr_temp4_label
.dev_attr
.attr
, /* 7 */
680 &sensor_dev_attr_fan1_input
.dev_attr
.attr
, /* 8 */
681 &sensor_dev_attr_fan1_label
.dev_attr
.attr
, /* 9 */
682 &sensor_dev_attr_pwm1
.dev_attr
.attr
, /* 10 */
683 &sensor_dev_attr_fan2_input
.dev_attr
.attr
, /* 11 */
684 &sensor_dev_attr_fan2_label
.dev_attr
.attr
, /* 12 */
685 &sensor_dev_attr_pwm2
.dev_attr
.attr
, /* 13 */
689 static umode_t
i8k_is_visible(struct kobject
*kobj
, struct attribute
*attr
,
692 if (index
>= 0 && index
<= 1 &&
693 !(i8k_hwmon_flags
& I8K_HWMON_HAVE_TEMP1
))
695 if (index
>= 2 && index
<= 3 &&
696 !(i8k_hwmon_flags
& I8K_HWMON_HAVE_TEMP2
))
698 if (index
>= 4 && index
<= 5 &&
699 !(i8k_hwmon_flags
& I8K_HWMON_HAVE_TEMP3
))
701 if (index
>= 6 && index
<= 7 &&
702 !(i8k_hwmon_flags
& I8K_HWMON_HAVE_TEMP4
))
704 if (index
>= 8 && index
<= 10 &&
705 !(i8k_hwmon_flags
& I8K_HWMON_HAVE_FAN1
))
707 if (index
>= 11 && index
<= 13 &&
708 !(i8k_hwmon_flags
& I8K_HWMON_HAVE_FAN2
))
714 static const struct attribute_group i8k_group
= {
716 .is_visible
= i8k_is_visible
,
718 __ATTRIBUTE_GROUPS(i8k
);
720 static int __init
i8k_init_hwmon(void)
726 /* CPU temperature attributes, if temperature type is OK */
727 err
= i8k_get_temp_type(0);
729 i8k_hwmon_flags
|= I8K_HWMON_HAVE_TEMP1
;
730 /* check for additional temperature sensors */
731 err
= i8k_get_temp_type(1);
733 i8k_hwmon_flags
|= I8K_HWMON_HAVE_TEMP2
;
734 err
= i8k_get_temp_type(2);
736 i8k_hwmon_flags
|= I8K_HWMON_HAVE_TEMP3
;
737 err
= i8k_get_temp_type(3);
739 i8k_hwmon_flags
|= I8K_HWMON_HAVE_TEMP4
;
741 /* First fan attributes, if fan type is OK */
742 err
= i8k_get_fan_type(0);
744 i8k_hwmon_flags
|= I8K_HWMON_HAVE_FAN1
;
746 /* Second fan attributes, if fan type is OK */
747 err
= i8k_get_fan_type(1);
749 i8k_hwmon_flags
|= I8K_HWMON_HAVE_FAN2
;
751 i8k_hwmon_dev
= hwmon_device_register_with_groups(NULL
, "i8k", NULL
,
753 if (IS_ERR(i8k_hwmon_dev
)) {
754 err
= PTR_ERR(i8k_hwmon_dev
);
755 i8k_hwmon_dev
= NULL
;
756 pr_err("hwmon registration failed (%d)\n", err
);
762 struct i8k_config_data
{
774 static const struct i8k_config_data i8k_config_data
[] = {
775 [DELL_LATITUDE_D520
] = {
777 .fan_max
= I8K_FAN_TURBO
,
779 [DELL_PRECISION_490
] = {
781 .fan_max
= I8K_FAN_TURBO
,
785 .fan_max
= I8K_FAN_HIGH
,
789 .fan_max
= I8K_FAN_HIGH
,
793 static struct dmi_system_id i8k_dmi_table
[] __initdata
= {
795 .ident
= "Dell Inspiron",
797 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Computer"),
798 DMI_MATCH(DMI_PRODUCT_NAME
, "Inspiron"),
802 .ident
= "Dell Latitude",
804 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Computer"),
805 DMI_MATCH(DMI_PRODUCT_NAME
, "Latitude"),
809 .ident
= "Dell Inspiron 2",
811 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
812 DMI_MATCH(DMI_PRODUCT_NAME
, "Inspiron"),
816 .ident
= "Dell Latitude D520",
818 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
819 DMI_MATCH(DMI_PRODUCT_NAME
, "Latitude D520"),
821 .driver_data
= (void *)&i8k_config_data
[DELL_LATITUDE_D520
],
824 .ident
= "Dell Latitude 2",
826 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
827 DMI_MATCH(DMI_PRODUCT_NAME
, "Latitude"),
830 { /* UK Inspiron 6400 */
831 .ident
= "Dell Inspiron 3",
833 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
834 DMI_MATCH(DMI_PRODUCT_NAME
, "MM061"),
838 .ident
= "Dell Inspiron 3",
840 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
841 DMI_MATCH(DMI_PRODUCT_NAME
, "MP061"),
845 .ident
= "Dell Precision 490",
847 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
848 DMI_MATCH(DMI_PRODUCT_NAME
,
849 "Precision WorkStation 490"),
851 .driver_data
= (void *)&i8k_config_data
[DELL_PRECISION_490
],
854 .ident
= "Dell Precision",
856 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
857 DMI_MATCH(DMI_PRODUCT_NAME
, "Precision"),
861 .ident
= "Dell Vostro",
863 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
864 DMI_MATCH(DMI_PRODUCT_NAME
, "Vostro"),
868 .ident
= "Dell XPS421",
870 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
871 DMI_MATCH(DMI_PRODUCT_NAME
, "XPS L421X"),
875 .ident
= "Dell Studio",
877 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
878 DMI_MATCH(DMI_PRODUCT_NAME
, "Studio"),
880 .driver_data
= (void *)&i8k_config_data
[DELL_STUDIO
],
883 .ident
= "Dell XPS 13",
885 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
886 DMI_MATCH(DMI_PRODUCT_NAME
, "XPS13"),
888 .driver_data
= (void *)&i8k_config_data
[DELL_XPS
],
891 .ident
= "Dell XPS M140",
893 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
894 DMI_MATCH(DMI_PRODUCT_NAME
, "MXC051"),
896 .driver_data
= (void *)&i8k_config_data
[DELL_XPS
],
901 MODULE_DEVICE_TABLE(dmi
, i8k_dmi_table
);
904 * Probe for the presence of a supported laptop.
906 static int __init
i8k_probe(void)
908 const struct dmi_system_id
*id
;
912 * Get DMI information
914 if (!dmi_check_system(i8k_dmi_table
)) {
915 if (!ignore_dmi
&& !force
)
918 pr_info("not running on a supported Dell system.\n");
919 pr_info("vendor=%s, model=%s, version=%s\n",
920 i8k_get_dmi_data(DMI_SYS_VENDOR
),
921 i8k_get_dmi_data(DMI_PRODUCT_NAME
),
922 i8k_get_dmi_data(DMI_BIOS_VERSION
));
925 strlcpy(bios_version
, i8k_get_dmi_data(DMI_BIOS_VERSION
),
926 sizeof(bios_version
));
929 * Get SMM Dell signature
931 if (i8k_get_dell_signature(I8K_SMM_GET_DELL_SIG1
) &&
932 i8k_get_dell_signature(I8K_SMM_GET_DELL_SIG2
)) {
933 pr_err("unable to get SMM Dell signature\n");
939 * Set fan multiplier and maximal fan speed from dmi config
940 * Values specified in module parameters override values from dmi
942 id
= dmi_first_match(i8k_dmi_table
);
943 if (id
&& id
->driver_data
) {
944 const struct i8k_config_data
*conf
= id
->driver_data
;
945 if (!fan_mult
&& conf
->fan_mult
)
946 fan_mult
= conf
->fan_mult
;
947 if (!fan_max
&& conf
->fan_max
)
948 fan_max
= conf
->fan_max
;
951 i8k_fan_max
= fan_max
? : I8K_FAN_HIGH
; /* Must not be 0 */
952 i8k_pwm_mult
= DIV_ROUND_UP(255, i8k_fan_max
);
956 * Autodetect fan multiplier based on nominal rpm
957 * If fan reports rpm value too high then set multiplier to 1
959 for (fan
= 0; fan
< 2; ++fan
) {
960 ret
= i8k_get_fan_nominal_speed(fan
, i8k_fan_max
);
963 if (ret
> I8K_FAN_MAX_RPM
)
968 /* Fan multiplier was specified in module param or in dmi */
969 i8k_fan_mult
= fan_mult
;
975 static int __init
i8k_init(void)
977 struct proc_dir_entry
*proc_i8k
;
980 /* Are we running on an supported laptop? */
984 /* Register the proc entry */
985 proc_i8k
= proc_create("i8k", 0, NULL
, &i8k_fops
);
989 err
= i8k_init_hwmon();
991 goto exit_remove_proc
;
996 remove_proc_entry("i8k", NULL
);
1000 static void __exit
i8k_exit(void)
1002 hwmon_device_unregister(i8k_hwmon_dev
);
1003 remove_proc_entry("i8k", NULL
);
1006 module_init(i8k_init
);
1007 module_exit(i8k_exit
);