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>
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2, or (at your option) any
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
21 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
23 #include <linux/delay.h>
24 #include <linux/module.h>
25 #include <linux/types.h>
26 #include <linux/init.h>
27 #include <linux/proc_fs.h>
28 #include <linux/seq_file.h>
29 #include <linux/dmi.h>
30 #include <linux/capability.h>
31 #include <linux/mutex.h>
32 #include <linux/hwmon.h>
33 #include <linux/hwmon-sysfs.h>
34 #include <linux/uaccess.h>
36 #include <linux/sched.h>
38 #include <linux/i8k.h>
40 #define I8K_SMM_FN_STATUS 0x0025
41 #define I8K_SMM_POWER_STATUS 0x0069
42 #define I8K_SMM_SET_FAN 0x01a3
43 #define I8K_SMM_GET_FAN 0x00a3
44 #define I8K_SMM_GET_SPEED 0x02a3
45 #define I8K_SMM_GET_TEMP 0x10a3
46 #define I8K_SMM_GET_TEMP_TYPE 0x11a3
47 #define I8K_SMM_GET_DELL_SIG1 0xfea3
48 #define I8K_SMM_GET_DELL_SIG2 0xffa3
50 #define I8K_FAN_MULT 30
51 #define I8K_MAX_TEMP 127
53 #define I8K_FN_NONE 0x00
54 #define I8K_FN_UP 0x01
55 #define I8K_FN_DOWN 0x02
56 #define I8K_FN_MUTE 0x04
57 #define I8K_FN_MASK 0x07
58 #define I8K_FN_SHIFT 8
60 #define I8K_POWER_AC 0x05
61 #define I8K_POWER_BATTERY 0x01
63 static DEFINE_MUTEX(i8k_mutex);
64 static char bios_version[4];
65 static struct device *i8k_hwmon_dev;
66 static u32 i8k_hwmon_flags;
67 static uint i8k_fan_mult;
68 static uint i8k_pwm_mult;
69 static uint i8k_fan_max = I8K_FAN_HIGH;
71 #define I8K_HWMON_HAVE_TEMP1 (1 << 0)
72 #define I8K_HWMON_HAVE_TEMP2 (1 << 1)
73 #define I8K_HWMON_HAVE_TEMP3 (1 << 2)
74 #define I8K_HWMON_HAVE_TEMP4 (1 << 3)
75 #define I8K_HWMON_HAVE_FAN1 (1 << 4)
76 #define I8K_HWMON_HAVE_FAN2 (1 << 5)
78 MODULE_AUTHOR("Massimo Dal Zotto (dz@debian.org)");
79 MODULE_DESCRIPTION("Driver for accessing SMM BIOS on Dell laptops");
80 MODULE_LICENSE("GPL");
83 module_param(force, bool, 0);
84 MODULE_PARM_DESC(force, "Force loading without checking for supported models");
86 static bool ignore_dmi;
87 module_param(ignore_dmi, bool, 0);
88 MODULE_PARM_DESC(ignore_dmi, "Continue probing hardware even if DMI data does not match");
90 static bool restricted;
91 module_param(restricted, bool, 0);
92 MODULE_PARM_DESC(restricted, "Allow fan control if SYS_ADMIN capability set");
94 static bool power_status;
95 module_param(power_status, bool, 0600);
96 MODULE_PARM_DESC(power_status, "Report power status in /proc/i8k");
98 static uint fan_mult = I8K_FAN_MULT;
99 module_param(fan_mult, uint, 0);
100 MODULE_PARM_DESC(fan_mult, "Factor to multiply fan speed with");
102 static uint fan_max = I8K_FAN_HIGH;
103 module_param(fan_max, uint, 0);
104 MODULE_PARM_DESC(fan_max, "Maximum configurable fan speed");
106 static int i8k_open_fs(struct inode *inode, struct file *file);
107 static long i8k_ioctl(struct file *, unsigned int, unsigned long);
109 static const struct file_operations i8k_fops = {
110 .owner = THIS_MODULE,
114 .release = single_release,
115 .unlocked_ioctl = i8k_ioctl,
120 unsigned int ebx __packed;
121 unsigned int ecx __packed;
122 unsigned int edx __packed;
123 unsigned int esi __packed;
124 unsigned int edi __packed;
127 static inline const char *i8k_get_dmi_data(int field)
129 const char *dmi_data = dmi_get_system_info(field);
131 return dmi_data && *dmi_data ? dmi_data : "?";
135 * Call the System Management Mode BIOS. Code provided by Jonathan Buzzard.
137 static int i8k_smm(struct smm_regs *regs)
141 cpumask_var_t old_mask;
143 /* SMM requires CPU 0 */
144 if (!alloc_cpumask_var(&old_mask, GFP_KERNEL))
146 cpumask_copy(old_mask, ¤t->cpus_allowed);
147 rc = set_cpus_allowed_ptr(current, cpumask_of(0));
150 if (smp_processor_id() != 0) {
155 #if defined(CONFIG_X86_64)
156 asm volatile("pushq %%rax\n\t"
157 "movl 0(%%rax),%%edx\n\t"
159 "movl 4(%%rax),%%ebx\n\t"
160 "movl 8(%%rax),%%ecx\n\t"
161 "movl 12(%%rax),%%edx\n\t"
162 "movl 16(%%rax),%%esi\n\t"
163 "movl 20(%%rax),%%edi\n\t"
167 "xchgq %%rax,(%%rsp)\n\t"
168 "movl %%ebx,4(%%rax)\n\t"
169 "movl %%ecx,8(%%rax)\n\t"
170 "movl %%edx,12(%%rax)\n\t"
171 "movl %%esi,16(%%rax)\n\t"
172 "movl %%edi,20(%%rax)\n\t"
174 "movl %%edx,0(%%rax)\n\t"
180 : "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory");
182 asm volatile("pushl %%eax\n\t"
183 "movl 0(%%eax),%%edx\n\t"
185 "movl 4(%%eax),%%ebx\n\t"
186 "movl 8(%%eax),%%ecx\n\t"
187 "movl 12(%%eax),%%edx\n\t"
188 "movl 16(%%eax),%%esi\n\t"
189 "movl 20(%%eax),%%edi\n\t"
193 "xchgl %%eax,(%%esp)\n\t"
194 "movl %%ebx,4(%%eax)\n\t"
195 "movl %%ecx,8(%%eax)\n\t"
196 "movl %%edx,12(%%eax)\n\t"
197 "movl %%esi,16(%%eax)\n\t"
198 "movl %%edi,20(%%eax)\n\t"
200 "movl %%edx,0(%%eax)\n\t"
206 : "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory");
208 if (rc != 0 || (regs->eax & 0xffff) == 0xffff || regs->eax == eax)
212 set_cpus_allowed_ptr(current, old_mask);
213 free_cpumask_var(old_mask);
218 * Read the Fn key status.
220 static int i8k_get_fn_status(void)
222 struct smm_regs regs = { .eax = I8K_SMM_FN_STATUS, };
229 switch ((regs.eax >> I8K_FN_SHIFT) & I8K_FN_MASK) {
242 * Read the power status.
244 static int i8k_get_power_status(void)
246 struct smm_regs regs = { .eax = I8K_SMM_POWER_STATUS, };
253 return (regs.eax & 0xff) == I8K_POWER_AC ? I8K_AC : I8K_BATTERY;
257 * Read the fan status.
259 static int i8k_get_fan_status(int fan)
261 struct smm_regs regs = { .eax = I8K_SMM_GET_FAN, };
263 regs.ebx = fan & 0xff;
264 return i8k_smm(®s) ? : regs.eax & 0xff;
268 * Read the fan speed in RPM.
270 static int i8k_get_fan_speed(int fan)
272 struct smm_regs regs = { .eax = I8K_SMM_GET_SPEED, };
274 regs.ebx = fan & 0xff;
275 return i8k_smm(®s) ? : (regs.eax & 0xffff) * i8k_fan_mult;
279 * Set the fan speed (off, low, high). Returns the new fan status.
281 static int i8k_set_fan(int fan, int speed)
283 struct smm_regs regs = { .eax = I8K_SMM_SET_FAN, };
285 speed = (speed < 0) ? 0 : ((speed > i8k_fan_max) ? i8k_fan_max : speed);
286 regs.ebx = (fan & 0xff) | (speed << 8);
288 return i8k_smm(®s) ? : i8k_get_fan_status(fan);
291 static int i8k_get_temp_type(int sensor)
293 struct smm_regs regs = { .eax = I8K_SMM_GET_TEMP_TYPE, };
295 regs.ebx = sensor & 0xff;
296 return i8k_smm(®s) ? : regs.eax & 0xff;
300 * Read the cpu temperature.
302 static int _i8k_get_temp(int sensor)
304 struct smm_regs regs = {
305 .eax = I8K_SMM_GET_TEMP,
306 .ebx = sensor & 0xff,
309 return i8k_smm(®s) ? : regs.eax & 0xff;
312 static int i8k_get_temp(int sensor)
314 int temp = _i8k_get_temp(sensor);
317 * Sometimes the temperature sensor returns 0x99, which is out of range.
318 * In this case we retry (once) before returning an error.
319 # 1003655137 00000058 00005a4b
320 # 1003655138 00000099 00003a80 <--- 0x99 = 153 degrees
321 # 1003655139 00000054 00005c52
325 temp = _i8k_get_temp(sensor);
328 * Return -ENODATA for all invalid temperatures.
330 * Known instances are the 0x99 value as seen above as well as
331 * 0xc1 (193), which may be returned when trying to read the GPU
332 * temperature if the system supports a GPU and it is currently
335 if (temp > I8K_MAX_TEMP)
341 static int i8k_get_dell_signature(int req_fn)
343 struct smm_regs regs = { .eax = req_fn, };
350 return regs.eax == 1145651527 && regs.edx == 1145392204 ? 0 : -1;
354 i8k_ioctl_unlocked(struct file *fp, unsigned int cmd, unsigned long arg)
358 unsigned char buff[16];
359 int __user *argp = (int __user *)arg;
365 case I8K_BIOS_VERSION:
366 val = (bios_version[0] << 16) |
367 (bios_version[1] << 8) | bios_version[2];
372 strlcpy(buff, i8k_get_dmi_data(DMI_PRODUCT_SERIAL),
377 val = i8k_get_fn_status();
380 case I8K_POWER_STATUS:
381 val = i8k_get_power_status();
385 val = i8k_get_temp(0);
389 if (copy_from_user(&val, argp, sizeof(int)))
392 val = i8k_get_fan_speed(val);
396 if (copy_from_user(&val, argp, sizeof(int)))
399 val = i8k_get_fan_status(val);
403 if (restricted && !capable(CAP_SYS_ADMIN))
406 if (copy_from_user(&val, argp, sizeof(int)))
409 if (copy_from_user(&speed, argp + 1, sizeof(int)))
412 val = i8k_set_fan(val, speed);
423 case I8K_BIOS_VERSION:
424 if (copy_to_user(argp, &val, 4))
429 if (copy_to_user(argp, buff, 16))
434 if (copy_to_user(argp, &val, sizeof(int)))
443 static long i8k_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
447 mutex_lock(&i8k_mutex);
448 ret = i8k_ioctl_unlocked(fp, cmd, arg);
449 mutex_unlock(&i8k_mutex);
455 * Print the information for /proc/i8k.
457 static int i8k_proc_show(struct seq_file *seq, void *offset)
459 int fn_key, cpu_temp, ac_power;
460 int left_fan, right_fan, left_speed, right_speed;
462 cpu_temp = i8k_get_temp(0); /* 11100 µs */
463 left_fan = i8k_get_fan_status(I8K_FAN_LEFT); /* 580 µs */
464 right_fan = i8k_get_fan_status(I8K_FAN_RIGHT); /* 580 µs */
465 left_speed = i8k_get_fan_speed(I8K_FAN_LEFT); /* 580 µs */
466 right_speed = i8k_get_fan_speed(I8K_FAN_RIGHT); /* 580 µs */
467 fn_key = i8k_get_fn_status(); /* 750 µs */
469 ac_power = i8k_get_power_status(); /* 14700 µs */
476 * 1) Format version (this will change if format changes)
481 * 6) Right fan status
487 return seq_printf(seq, "%s %s %s %d %d %d %d %d %d %d\n",
490 i8k_get_dmi_data(DMI_PRODUCT_SERIAL),
492 left_fan, right_fan, left_speed, right_speed,
496 static int i8k_open_fs(struct inode *inode, struct file *file)
498 return single_open(file, i8k_proc_show, NULL);
506 static ssize_t i8k_hwmon_show_temp_label(struct device *dev,
507 struct device_attribute *devattr,
510 static const char * const labels[] = {
518 int index = to_sensor_dev_attr(devattr)->index;
521 type = i8k_get_temp_type(index);
524 if (type >= ARRAY_SIZE(labels))
525 type = ARRAY_SIZE(labels) - 1;
526 return sprintf(buf, "%s\n", labels[type]);
529 static ssize_t i8k_hwmon_show_temp(struct device *dev,
530 struct device_attribute *devattr,
533 int index = to_sensor_dev_attr(devattr)->index;
536 temp = i8k_get_temp(index);
539 return sprintf(buf, "%d\n", temp * 1000);
542 static ssize_t i8k_hwmon_show_fan(struct device *dev,
543 struct device_attribute *devattr,
546 int index = to_sensor_dev_attr(devattr)->index;
549 fan_speed = i8k_get_fan_speed(index);
552 return sprintf(buf, "%d\n", fan_speed);
555 static ssize_t i8k_hwmon_show_pwm(struct device *dev,
556 struct device_attribute *devattr,
559 int index = to_sensor_dev_attr(devattr)->index;
562 status = i8k_get_fan_status(index);
565 return sprintf(buf, "%d\n", clamp_val(status * i8k_pwm_mult, 0, 255));
568 static ssize_t i8k_hwmon_set_pwm(struct device *dev,
569 struct device_attribute *attr,
570 const char *buf, size_t count)
572 int index = to_sensor_dev_attr(attr)->index;
576 err = kstrtoul(buf, 10, &val);
579 val = clamp_val(DIV_ROUND_CLOSEST(val, i8k_pwm_mult), 0, i8k_fan_max);
581 mutex_lock(&i8k_mutex);
582 err = i8k_set_fan(index, val);
583 mutex_unlock(&i8k_mutex);
585 return err < 0 ? -EIO : count;
588 static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, i8k_hwmon_show_temp, NULL, 0);
589 static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, i8k_hwmon_show_temp_label, NULL,
591 static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, i8k_hwmon_show_temp, NULL, 1);
592 static SENSOR_DEVICE_ATTR(temp2_label, S_IRUGO, i8k_hwmon_show_temp_label, NULL,
594 static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, i8k_hwmon_show_temp, NULL, 2);
595 static SENSOR_DEVICE_ATTR(temp3_label, S_IRUGO, i8k_hwmon_show_temp_label, NULL,
597 static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, i8k_hwmon_show_temp, NULL, 3);
598 static SENSOR_DEVICE_ATTR(temp4_label, S_IRUGO, i8k_hwmon_show_temp_label, NULL,
600 static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, i8k_hwmon_show_fan, NULL,
602 static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, i8k_hwmon_show_pwm,
603 i8k_hwmon_set_pwm, I8K_FAN_LEFT);
604 static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, i8k_hwmon_show_fan, NULL,
606 static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, i8k_hwmon_show_pwm,
607 i8k_hwmon_set_pwm, I8K_FAN_RIGHT);
609 static struct attribute *i8k_attrs[] = {
610 &sensor_dev_attr_temp1_input.dev_attr.attr, /* 0 */
611 &sensor_dev_attr_temp1_label.dev_attr.attr, /* 1 */
612 &sensor_dev_attr_temp2_input.dev_attr.attr, /* 2 */
613 &sensor_dev_attr_temp2_label.dev_attr.attr, /* 3 */
614 &sensor_dev_attr_temp3_input.dev_attr.attr, /* 4 */
615 &sensor_dev_attr_temp3_label.dev_attr.attr, /* 5 */
616 &sensor_dev_attr_temp4_input.dev_attr.attr, /* 6 */
617 &sensor_dev_attr_temp4_label.dev_attr.attr, /* 7 */
618 &sensor_dev_attr_fan1_input.dev_attr.attr, /* 8 */
619 &sensor_dev_attr_pwm1.dev_attr.attr, /* 9 */
620 &sensor_dev_attr_fan2_input.dev_attr.attr, /* 10 */
621 &sensor_dev_attr_pwm2.dev_attr.attr, /* 11 */
625 static umode_t i8k_is_visible(struct kobject *kobj, struct attribute *attr,
628 if (index >= 0 && index <= 1 &&
629 !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP1))
631 if (index >= 2 && index <= 3 &&
632 !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP2))
634 if (index >= 4 && index <= 5 &&
635 !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP3))
637 if (index >= 6 && index <= 7 &&
638 !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP4))
640 if (index >= 8 && index <= 9 &&
641 !(i8k_hwmon_flags & I8K_HWMON_HAVE_FAN1))
643 if (index >= 10 && index <= 11 &&
644 !(i8k_hwmon_flags & I8K_HWMON_HAVE_FAN2))
650 static const struct attribute_group i8k_group = {
652 .is_visible = i8k_is_visible,
654 __ATTRIBUTE_GROUPS(i8k);
656 static int __init i8k_init_hwmon(void)
662 /* CPU temperature attributes, if temperature type is OK */
663 err = i8k_get_temp_type(0);
665 i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP1;
666 /* check for additional temperature sensors */
667 err = i8k_get_temp_type(1);
669 i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP2;
670 err = i8k_get_temp_type(2);
672 i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP3;
673 err = i8k_get_temp_type(3);
675 i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP4;
677 /* Left fan attributes, if left fan is present */
678 err = i8k_get_fan_status(I8K_FAN_LEFT);
680 i8k_hwmon_flags |= I8K_HWMON_HAVE_FAN1;
682 /* Right fan attributes, if right fan is present */
683 err = i8k_get_fan_status(I8K_FAN_RIGHT);
685 i8k_hwmon_flags |= I8K_HWMON_HAVE_FAN2;
687 i8k_hwmon_dev = hwmon_device_register_with_groups(NULL, "i8k", NULL,
689 if (IS_ERR(i8k_hwmon_dev)) {
690 err = PTR_ERR(i8k_hwmon_dev);
691 i8k_hwmon_dev = NULL;
692 pr_err("hwmon registration failed (%d)\n", err);
698 struct i8k_config_data {
711 static const struct i8k_config_data i8k_config_data[] = {
712 [DELL_LATITUDE_D520] = {
714 .fan_max = I8K_FAN_TURBO,
716 [DELL_LATITUDE_E6540] = {
718 .fan_max = I8K_FAN_HIGH,
720 [DELL_PRECISION_490] = {
722 .fan_max = I8K_FAN_TURBO,
726 .fan_max = I8K_FAN_HIGH,
730 .fan_max = I8K_FAN_HIGH,
734 static struct dmi_system_id i8k_dmi_table[] __initdata = {
736 .ident = "Dell Inspiron",
738 DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer"),
739 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron"),
743 .ident = "Dell Latitude",
745 DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer"),
746 DMI_MATCH(DMI_PRODUCT_NAME, "Latitude"),
750 .ident = "Dell Inspiron 2",
752 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
753 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron"),
757 .ident = "Dell Latitude D520",
759 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
760 DMI_MATCH(DMI_PRODUCT_NAME, "Latitude D520"),
762 .driver_data = (void *)&i8k_config_data[DELL_LATITUDE_D520],
765 .ident = "Dell Latitude E6440",
767 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
768 DMI_MATCH(DMI_PRODUCT_NAME, "Latitude E6440"),
770 .driver_data = (void *)&i8k_config_data[DELL_LATITUDE_E6540],
773 .ident = "Dell Latitude E6540",
775 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
776 DMI_MATCH(DMI_PRODUCT_NAME, "Latitude E6540"),
778 .driver_data = (void *)&i8k_config_data[DELL_LATITUDE_E6540],
781 .ident = "Dell Latitude 2",
783 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
784 DMI_MATCH(DMI_PRODUCT_NAME, "Latitude"),
787 { /* UK Inspiron 6400 */
788 .ident = "Dell Inspiron 3",
790 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
791 DMI_MATCH(DMI_PRODUCT_NAME, "MM061"),
795 .ident = "Dell Inspiron 3",
797 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
798 DMI_MATCH(DMI_PRODUCT_NAME, "MP061"),
802 .ident = "Dell Precision 490",
804 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
805 DMI_MATCH(DMI_PRODUCT_NAME,
806 "Precision WorkStation 490"),
808 .driver_data = (void *)&i8k_config_data[DELL_PRECISION_490],
811 .ident = "Dell Precision",
813 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
814 DMI_MATCH(DMI_PRODUCT_NAME, "Precision"),
818 .ident = "Dell Vostro",
820 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
821 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro"),
825 .ident = "Dell XPS421",
827 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
828 DMI_MATCH(DMI_PRODUCT_NAME, "XPS L421X"),
832 .ident = "Dell Studio",
834 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
835 DMI_MATCH(DMI_PRODUCT_NAME, "Studio"),
837 .driver_data = (void *)&i8k_config_data[DELL_STUDIO],
840 .ident = "Dell XPS 13",
842 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
843 DMI_MATCH(DMI_PRODUCT_NAME, "XPS13"),
845 .driver_data = (void *)&i8k_config_data[DELL_XPS],
848 .ident = "Dell XPS M140",
850 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
851 DMI_MATCH(DMI_PRODUCT_NAME, "MXC051"),
853 .driver_data = (void *)&i8k_config_data[DELL_XPS],
858 MODULE_DEVICE_TABLE(dmi, i8k_dmi_table);
861 * Probe for the presence of a supported laptop.
863 static int __init i8k_probe(void)
865 const struct dmi_system_id *id;
868 * Get DMI information
870 if (!dmi_check_system(i8k_dmi_table)) {
871 if (!ignore_dmi && !force)
874 pr_info("not running on a supported Dell system.\n");
875 pr_info("vendor=%s, model=%s, version=%s\n",
876 i8k_get_dmi_data(DMI_SYS_VENDOR),
877 i8k_get_dmi_data(DMI_PRODUCT_NAME),
878 i8k_get_dmi_data(DMI_BIOS_VERSION));
881 strlcpy(bios_version, i8k_get_dmi_data(DMI_BIOS_VERSION),
882 sizeof(bios_version));
885 * Get SMM Dell signature
887 if (i8k_get_dell_signature(I8K_SMM_GET_DELL_SIG1) &&
888 i8k_get_dell_signature(I8K_SMM_GET_DELL_SIG2)) {
889 pr_err("unable to get SMM Dell signature\n");
894 i8k_fan_mult = fan_mult;
895 i8k_fan_max = fan_max ? : I8K_FAN_HIGH; /* Must not be 0 */
896 id = dmi_first_match(i8k_dmi_table);
897 if (id && id->driver_data) {
898 const struct i8k_config_data *conf = id->driver_data;
900 if (fan_mult == I8K_FAN_MULT && conf->fan_mult)
901 i8k_fan_mult = conf->fan_mult;
902 if (fan_max == I8K_FAN_HIGH && conf->fan_max)
903 i8k_fan_max = conf->fan_max;
905 i8k_pwm_mult = DIV_ROUND_UP(255, i8k_fan_max);
910 static int __init i8k_init(void)
912 struct proc_dir_entry *proc_i8k;
915 /* Are we running on an supported laptop? */
919 /* Register the proc entry */
920 proc_i8k = proc_create("i8k", 0, NULL, &i8k_fops);
924 err = i8k_init_hwmon();
926 goto exit_remove_proc;
931 remove_proc_entry("i8k", NULL);
935 static void __exit i8k_exit(void)
937 hwmon_device_unregister(i8k_hwmon_dev);
938 remove_proc_entry("i8k", NULL);
941 module_init(i8k_init);
942 module_exit(i8k_exit);