2 * vt1211.c - driver for the VIA VT1211 Super-I/O chip integrated hardware
4 * Copyright (C) 2006 Juerg Haefliger <juergh@gmail.com>
6 * This driver is based on the driver for kernel 2.4 by Mark D. Studebaker
7 * and its port to kernel 2.6 by Lars Ekman.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
26 #include <linux/module.h>
27 #include <linux/init.h>
28 #include <linux/slab.h>
29 #include <linux/jiffies.h>
30 #include <linux/platform_device.h>
31 #include <linux/hwmon.h>
32 #include <linux/hwmon-sysfs.h>
33 #include <linux/hwmon-vid.h>
34 #include <linux/err.h>
35 #include <linux/mutex.h>
36 #include <linux/ioport.h>
37 #include <linux/acpi.h>
40 static int uch_config
= -1;
41 module_param(uch_config
, int, 0);
42 MODULE_PARM_DESC(uch_config
, "Initialize the universal channel configuration");
44 static int int_mode
= -1;
45 module_param(int_mode
, int, 0);
46 MODULE_PARM_DESC(int_mode
, "Force the temperature interrupt mode");
48 static unsigned short force_id
;
49 module_param(force_id
, ushort
, 0);
50 MODULE_PARM_DESC(force_id
, "Override the detected device ID");
52 static struct platform_device
*pdev
;
54 #define DRVNAME "vt1211"
56 /* ---------------------------------------------------------------------
59 * The sensors are defined as follows.
61 * Sensor Voltage Mode Temp Mode Notes (from the datasheet)
62 * -------- ------------ --------- --------------------------
63 * Reading 1 temp1 Intel thermal diode
64 * Reading 3 temp2 Internal thermal diode
65 * UCH1/Reading2 in0 temp3 NTC type thermistor
66 * UCH2 in1 temp4 +2.5V
70 * 3.3V in5 Internal VDD (+3.3V)
72 * --------------------------------------------------------------------- */
74 /* Voltages (in) numbered 0-5 (ix) */
75 #define VT1211_REG_IN(ix) (0x21 + (ix))
76 #define VT1211_REG_IN_MIN(ix) ((ix) == 0 ? 0x3e : 0x2a + 2 * (ix))
77 #define VT1211_REG_IN_MAX(ix) ((ix) == 0 ? 0x3d : 0x29 + 2 * (ix))
79 /* Temperatures (temp) numbered 0-6 (ix) */
80 static u8 regtemp
[] = {0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25};
81 static u8 regtempmax
[] = {0x39, 0x1d, 0x3d, 0x2b, 0x2d, 0x2f, 0x31};
82 static u8 regtemphyst
[] = {0x3a, 0x1e, 0x3e, 0x2c, 0x2e, 0x30, 0x32};
84 /* Fans numbered 0-1 (ix) */
85 #define VT1211_REG_FAN(ix) (0x29 + (ix))
86 #define VT1211_REG_FAN_MIN(ix) (0x3b + (ix))
87 #define VT1211_REG_FAN_DIV 0x47
89 /* PWMs numbered 0-1 (ix) */
90 /* Auto points numbered 0-3 (ap) */
91 #define VT1211_REG_PWM(ix) (0x60 + (ix))
92 #define VT1211_REG_PWM_CLK 0x50
93 #define VT1211_REG_PWM_CTL 0x51
94 #define VT1211_REG_PWM_AUTO_TEMP(ap) (0x55 - (ap))
95 #define VT1211_REG_PWM_AUTO_PWM(ix, ap) (0x58 + 2 * (ix) - (ap))
97 /* Miscellaneous registers */
98 #define VT1211_REG_CONFIG 0x40
99 #define VT1211_REG_ALARM1 0x41
100 #define VT1211_REG_ALARM2 0x42
101 #define VT1211_REG_VID 0x45
102 #define VT1211_REG_UCH_CONFIG 0x4a
103 #define VT1211_REG_TEMP1_CONFIG 0x4b
104 #define VT1211_REG_TEMP2_CONFIG 0x4c
106 /* In, temp & fan alarm bits */
107 static const u8 bitalarmin
[] = {11, 0, 1, 3, 8, 2, 9};
108 static const u8 bitalarmtemp
[] = {4, 15, 11, 0, 1, 3, 8};
109 static const u8 bitalarmfan
[] = {6, 7};
111 /* ---------------------------------------------------------------------
112 * Data structures and manipulation thereof
113 * --------------------------------------------------------------------- */
118 struct device
*hwmon_dev
;
120 struct mutex update_lock
;
121 char valid
; /* !=0 if following fields are valid */
122 unsigned long last_updated
; /* In jiffies */
124 /* Register values */
139 u8 pwm_auto_pwm
[2][4];
140 u8 vid
; /* Read once at init time */
142 u8 uch_config
; /* Read once at init time */
147 #define ISVOLT(ix, uch_config) ((ix) > 4 ? 1 : \
148 !(((uch_config) >> ((ix) + 2)) & 1))
151 #define ISTEMP(ix, uch_config) ((ix) < 2 ? 1 : \
152 ((uch_config) >> (ix)) & 1)
155 * in5 (ix = 5) is special. It's the internal 3.3V so it's scaled in the
156 * driver according to the VT1211 BIOS porting guide
158 #define IN_FROM_REG(ix, reg) ((reg) < 3 ? 0 : (ix) == 5 ? \
159 (((reg) - 3) * 15882 + 479) / 958 : \
160 (((reg) - 3) * 10000 + 479) / 958)
161 #define IN_TO_REG(ix, val) (clamp_val((ix) == 5 ? \
162 ((val) * 958 + 7941) / 15882 + 3 : \
163 ((val) * 958 + 5000) / 10000 + 3, 0, 255))
166 * temp1 (ix = 0) is an intel thermal diode which is scaled in user space.
167 * temp2 (ix = 1) is the internal temp diode so it's scaled in the driver
168 * according to some measurements that I took on an EPIA M10000.
169 * temp3-7 are thermistor based so the driver returns the voltage measured at
170 * the pin (range 0V - 2.2V).
172 #define TEMP_FROM_REG(ix, reg) ((ix) == 0 ? (reg) * 1000 : \
173 (ix) == 1 ? (reg) < 51 ? 0 : \
174 ((reg) - 51) * 1000 : \
175 ((253 - (reg)) * 2200 + 105) / 210)
176 #define TEMP_TO_REG(ix, val) clamp_val( \
177 ((ix) == 0 ? ((val) + 500) / 1000 : \
178 (ix) == 1 ? ((val) + 500) / 1000 + 51 : \
179 253 - ((val) * 210 + 1100) / 2200), 0, 255)
181 #define DIV_FROM_REG(reg) (1 << (reg))
183 #define RPM_FROM_REG(reg, div) (((reg) == 0) || ((reg) == 255) ? 0 : \
184 1310720 / (reg) / DIV_FROM_REG(div))
185 #define RPM_TO_REG(val, div) ((val) == 0 ? 255 : \
186 clamp_val((1310720 / (val) / \
187 DIV_FROM_REG(div)), 1, 254))
189 /* ---------------------------------------------------------------------
190 * Super-I/O constants and functions
191 * --------------------------------------------------------------------- */
194 * Configuration index port registers
195 * The vt1211 can live at 2 different addresses so we need to probe both
197 #define SIO_REG_CIP1 0x2e
198 #define SIO_REG_CIP2 0x4e
200 /* Configuration registers */
201 #define SIO_VT1211_LDN 0x07 /* logical device number */
202 #define SIO_VT1211_DEVID 0x20 /* device ID */
203 #define SIO_VT1211_DEVREV 0x21 /* device revision */
204 #define SIO_VT1211_ACTIVE 0x30 /* HW monitor active */
205 #define SIO_VT1211_BADDR 0x60 /* base I/O address */
206 #define SIO_VT1211_ID 0x3c /* VT1211 device ID */
208 /* VT1211 logical device numbers */
209 #define SIO_VT1211_LDN_HWMON 0x0b /* HW monitor */
211 static inline void superio_outb(int sio_cip
, int reg
, int val
)
214 outb(val
, sio_cip
+ 1);
217 static inline int superio_inb(int sio_cip
, int reg
)
220 return inb(sio_cip
+ 1);
223 static inline void superio_select(int sio_cip
, int ldn
)
225 outb(SIO_VT1211_LDN
, sio_cip
);
226 outb(ldn
, sio_cip
+ 1);
229 static inline int superio_enter(int sio_cip
)
231 if (!request_muxed_region(sio_cip
, 2, DRVNAME
))
240 static inline void superio_exit(int sio_cip
)
243 release_region(sio_cip
, 2);
246 /* ---------------------------------------------------------------------
248 * --------------------------------------------------------------------- */
250 static inline u8
vt1211_read8(struct vt1211_data
*data
, u8 reg
)
252 return inb(data
->addr
+ reg
);
255 static inline void vt1211_write8(struct vt1211_data
*data
, u8 reg
, u8 val
)
257 outb(val
, data
->addr
+ reg
);
260 static struct vt1211_data
*vt1211_update_device(struct device
*dev
)
262 struct vt1211_data
*data
= dev_get_drvdata(dev
);
265 mutex_lock(&data
->update_lock
);
267 /* registers cache is refreshed after 1 second */
268 if (time_after(jiffies
, data
->last_updated
+ HZ
) || !data
->valid
) {
270 data
->vid
= vt1211_read8(data
, VT1211_REG_VID
) & 0x1f;
272 /* voltage (in) registers */
273 for (ix
= 0; ix
< ARRAY_SIZE(data
->in
); ix
++) {
274 if (ISVOLT(ix
, data
->uch_config
)) {
275 data
->in
[ix
] = vt1211_read8(data
,
277 data
->in_min
[ix
] = vt1211_read8(data
,
278 VT1211_REG_IN_MIN(ix
));
279 data
->in_max
[ix
] = vt1211_read8(data
,
280 VT1211_REG_IN_MAX(ix
));
285 for (ix
= 0; ix
< ARRAY_SIZE(data
->temp
); ix
++) {
286 if (ISTEMP(ix
, data
->uch_config
)) {
287 data
->temp
[ix
] = vt1211_read8(data
,
289 data
->temp_max
[ix
] = vt1211_read8(data
,
291 data
->temp_hyst
[ix
] = vt1211_read8(data
,
296 /* fan & pwm registers */
297 for (ix
= 0; ix
< ARRAY_SIZE(data
->fan
); ix
++) {
298 data
->fan
[ix
] = vt1211_read8(data
,
300 data
->fan_min
[ix
] = vt1211_read8(data
,
301 VT1211_REG_FAN_MIN(ix
));
302 data
->pwm
[ix
] = vt1211_read8(data
,
305 val
= vt1211_read8(data
, VT1211_REG_FAN_DIV
);
306 data
->fan_div
[0] = (val
>> 4) & 3;
307 data
->fan_div
[1] = (val
>> 6) & 3;
308 data
->fan_ctl
= val
& 0xf;
310 val
= vt1211_read8(data
, VT1211_REG_PWM_CTL
);
311 data
->pwm_ctl
[0] = val
& 0xf;
312 data
->pwm_ctl
[1] = (val
>> 4) & 0xf;
314 data
->pwm_clk
= vt1211_read8(data
, VT1211_REG_PWM_CLK
);
316 /* pwm & temp auto point registers */
317 data
->pwm_auto_pwm
[0][1] = vt1211_read8(data
,
318 VT1211_REG_PWM_AUTO_PWM(0, 1));
319 data
->pwm_auto_pwm
[0][2] = vt1211_read8(data
,
320 VT1211_REG_PWM_AUTO_PWM(0, 2));
321 data
->pwm_auto_pwm
[1][1] = vt1211_read8(data
,
322 VT1211_REG_PWM_AUTO_PWM(1, 1));
323 data
->pwm_auto_pwm
[1][2] = vt1211_read8(data
,
324 VT1211_REG_PWM_AUTO_PWM(1, 2));
325 for (ix
= 0; ix
< ARRAY_SIZE(data
->pwm_auto_temp
); ix
++) {
326 data
->pwm_auto_temp
[ix
] = vt1211_read8(data
,
327 VT1211_REG_PWM_AUTO_TEMP(ix
));
330 /* alarm registers */
331 data
->alarms
= (vt1211_read8(data
, VT1211_REG_ALARM2
) << 8) |
332 vt1211_read8(data
, VT1211_REG_ALARM1
);
334 data
->last_updated
= jiffies
;
338 mutex_unlock(&data
->update_lock
);
343 /* ---------------------------------------------------------------------
344 * Voltage sysfs interfaces
346 * --------------------------------------------------------------------- */
348 #define SHOW_IN_INPUT 0
349 #define SHOW_SET_IN_MIN 1
350 #define SHOW_SET_IN_MAX 2
351 #define SHOW_IN_ALARM 3
353 static ssize_t
show_in(struct device
*dev
, struct device_attribute
*attr
,
356 struct vt1211_data
*data
= vt1211_update_device(dev
);
357 struct sensor_device_attribute_2
*sensor_attr_2
=
358 to_sensor_dev_attr_2(attr
);
359 int ix
= sensor_attr_2
->index
;
360 int fn
= sensor_attr_2
->nr
;
365 res
= IN_FROM_REG(ix
, data
->in
[ix
]);
367 case SHOW_SET_IN_MIN
:
368 res
= IN_FROM_REG(ix
, data
->in_min
[ix
]);
370 case SHOW_SET_IN_MAX
:
371 res
= IN_FROM_REG(ix
, data
->in_max
[ix
]);
374 res
= (data
->alarms
>> bitalarmin
[ix
]) & 1;
378 dev_dbg(dev
, "Unknown attr fetch (%d)\n", fn
);
381 return sprintf(buf
, "%d\n", res
);
384 static ssize_t
set_in(struct device
*dev
, struct device_attribute
*attr
,
385 const char *buf
, size_t count
)
387 struct vt1211_data
*data
= dev_get_drvdata(dev
);
388 struct sensor_device_attribute_2
*sensor_attr_2
=
389 to_sensor_dev_attr_2(attr
);
390 int ix
= sensor_attr_2
->index
;
391 int fn
= sensor_attr_2
->nr
;
395 err
= kstrtol(buf
, 10, &val
);
399 mutex_lock(&data
->update_lock
);
401 case SHOW_SET_IN_MIN
:
402 data
->in_min
[ix
] = IN_TO_REG(ix
, val
);
403 vt1211_write8(data
, VT1211_REG_IN_MIN(ix
), data
->in_min
[ix
]);
405 case SHOW_SET_IN_MAX
:
406 data
->in_max
[ix
] = IN_TO_REG(ix
, val
);
407 vt1211_write8(data
, VT1211_REG_IN_MAX(ix
), data
->in_max
[ix
]);
410 dev_dbg(dev
, "Unknown attr fetch (%d)\n", fn
);
412 mutex_unlock(&data
->update_lock
);
417 /* ---------------------------------------------------------------------
418 * Temperature sysfs interfaces
420 * --------------------------------------------------------------------- */
422 #define SHOW_TEMP_INPUT 0
423 #define SHOW_SET_TEMP_MAX 1
424 #define SHOW_SET_TEMP_MAX_HYST 2
425 #define SHOW_TEMP_ALARM 3
427 static ssize_t
show_temp(struct device
*dev
, struct device_attribute
*attr
,
430 struct vt1211_data
*data
= vt1211_update_device(dev
);
431 struct sensor_device_attribute_2
*sensor_attr_2
=
432 to_sensor_dev_attr_2(attr
);
433 int ix
= sensor_attr_2
->index
;
434 int fn
= sensor_attr_2
->nr
;
438 case SHOW_TEMP_INPUT
:
439 res
= TEMP_FROM_REG(ix
, data
->temp
[ix
]);
441 case SHOW_SET_TEMP_MAX
:
442 res
= TEMP_FROM_REG(ix
, data
->temp_max
[ix
]);
444 case SHOW_SET_TEMP_MAX_HYST
:
445 res
= TEMP_FROM_REG(ix
, data
->temp_hyst
[ix
]);
447 case SHOW_TEMP_ALARM
:
448 res
= (data
->alarms
>> bitalarmtemp
[ix
]) & 1;
452 dev_dbg(dev
, "Unknown attr fetch (%d)\n", fn
);
455 return sprintf(buf
, "%d\n", res
);
458 static ssize_t
set_temp(struct device
*dev
, struct device_attribute
*attr
,
459 const char *buf
, size_t count
)
461 struct vt1211_data
*data
= dev_get_drvdata(dev
);
462 struct sensor_device_attribute_2
*sensor_attr_2
=
463 to_sensor_dev_attr_2(attr
);
464 int ix
= sensor_attr_2
->index
;
465 int fn
= sensor_attr_2
->nr
;
469 err
= kstrtol(buf
, 10, &val
);
473 mutex_lock(&data
->update_lock
);
475 case SHOW_SET_TEMP_MAX
:
476 data
->temp_max
[ix
] = TEMP_TO_REG(ix
, val
);
477 vt1211_write8(data
, regtempmax
[ix
],
480 case SHOW_SET_TEMP_MAX_HYST
:
481 data
->temp_hyst
[ix
] = TEMP_TO_REG(ix
, val
);
482 vt1211_write8(data
, regtemphyst
[ix
],
483 data
->temp_hyst
[ix
]);
486 dev_dbg(dev
, "Unknown attr fetch (%d)\n", fn
);
488 mutex_unlock(&data
->update_lock
);
493 /* ---------------------------------------------------------------------
494 * Fan sysfs interfaces
496 * --------------------------------------------------------------------- */
498 #define SHOW_FAN_INPUT 0
499 #define SHOW_SET_FAN_MIN 1
500 #define SHOW_SET_FAN_DIV 2
501 #define SHOW_FAN_ALARM 3
503 static ssize_t
show_fan(struct device
*dev
, struct device_attribute
*attr
,
506 struct vt1211_data
*data
= vt1211_update_device(dev
);
507 struct sensor_device_attribute_2
*sensor_attr_2
=
508 to_sensor_dev_attr_2(attr
);
509 int ix
= sensor_attr_2
->index
;
510 int fn
= sensor_attr_2
->nr
;
515 res
= RPM_FROM_REG(data
->fan
[ix
], data
->fan_div
[ix
]);
517 case SHOW_SET_FAN_MIN
:
518 res
= RPM_FROM_REG(data
->fan_min
[ix
], data
->fan_div
[ix
]);
520 case SHOW_SET_FAN_DIV
:
521 res
= DIV_FROM_REG(data
->fan_div
[ix
]);
524 res
= (data
->alarms
>> bitalarmfan
[ix
]) & 1;
528 dev_dbg(dev
, "Unknown attr fetch (%d)\n", fn
);
531 return sprintf(buf
, "%d\n", res
);
534 static ssize_t
set_fan(struct device
*dev
, struct device_attribute
*attr
,
535 const char *buf
, size_t count
)
537 struct vt1211_data
*data
= dev_get_drvdata(dev
);
538 struct sensor_device_attribute_2
*sensor_attr_2
=
539 to_sensor_dev_attr_2(attr
);
540 int ix
= sensor_attr_2
->index
;
541 int fn
= sensor_attr_2
->nr
;
546 err
= kstrtoul(buf
, 10, &val
);
550 mutex_lock(&data
->update_lock
);
552 /* sync the data cache */
553 reg
= vt1211_read8(data
, VT1211_REG_FAN_DIV
);
554 data
->fan_div
[0] = (reg
>> 4) & 3;
555 data
->fan_div
[1] = (reg
>> 6) & 3;
556 data
->fan_ctl
= reg
& 0xf;
559 case SHOW_SET_FAN_MIN
:
560 data
->fan_min
[ix
] = RPM_TO_REG(val
, data
->fan_div
[ix
]);
561 vt1211_write8(data
, VT1211_REG_FAN_MIN(ix
),
564 case SHOW_SET_FAN_DIV
:
567 data
->fan_div
[ix
] = 0;
570 data
->fan_div
[ix
] = 1;
573 data
->fan_div
[ix
] = 2;
576 data
->fan_div
[ix
] = 3;
581 "fan div value %ld not supported. Choose one of 1, 2, 4, or 8.\n",
585 vt1211_write8(data
, VT1211_REG_FAN_DIV
,
586 ((data
->fan_div
[1] << 6) |
587 (data
->fan_div
[0] << 4) |
591 dev_dbg(dev
, "Unknown attr fetch (%d)\n", fn
);
595 mutex_unlock(&data
->update_lock
);
599 /* ---------------------------------------------------------------------
600 * PWM sysfs interfaces
602 * --------------------------------------------------------------------- */
605 #define SHOW_SET_PWM_ENABLE 1
606 #define SHOW_SET_PWM_FREQ 2
607 #define SHOW_SET_PWM_AUTO_CHANNELS_TEMP 3
609 static ssize_t
show_pwm(struct device
*dev
, struct device_attribute
*attr
,
612 struct vt1211_data
*data
= vt1211_update_device(dev
);
613 struct sensor_device_attribute_2
*sensor_attr_2
=
614 to_sensor_dev_attr_2(attr
);
615 int ix
= sensor_attr_2
->index
;
616 int fn
= sensor_attr_2
->nr
;
623 case SHOW_SET_PWM_ENABLE
:
624 res
= ((data
->pwm_ctl
[ix
] >> 3) & 1) ? 2 : 0;
626 case SHOW_SET_PWM_FREQ
:
627 res
= 90000 >> (data
->pwm_clk
& 7);
629 case SHOW_SET_PWM_AUTO_CHANNELS_TEMP
:
630 res
= (data
->pwm_ctl
[ix
] & 7) + 1;
634 dev_dbg(dev
, "Unknown attr fetch (%d)\n", fn
);
637 return sprintf(buf
, "%d\n", res
);
640 static ssize_t
set_pwm(struct device
*dev
, struct device_attribute
*attr
,
641 const char *buf
, size_t count
)
643 struct vt1211_data
*data
= dev_get_drvdata(dev
);
644 struct sensor_device_attribute_2
*sensor_attr_2
=
645 to_sensor_dev_attr_2(attr
);
646 int ix
= sensor_attr_2
->index
;
647 int fn
= sensor_attr_2
->nr
;
652 err
= kstrtoul(buf
, 10, &val
);
656 mutex_lock(&data
->update_lock
);
659 case SHOW_SET_PWM_ENABLE
:
660 /* sync the data cache */
661 reg
= vt1211_read8(data
, VT1211_REG_FAN_DIV
);
662 data
->fan_div
[0] = (reg
>> 4) & 3;
663 data
->fan_div
[1] = (reg
>> 6) & 3;
664 data
->fan_ctl
= reg
& 0xf;
665 reg
= vt1211_read8(data
, VT1211_REG_PWM_CTL
);
666 data
->pwm_ctl
[0] = reg
& 0xf;
667 data
->pwm_ctl
[1] = (reg
>> 4) & 0xf;
670 data
->pwm_ctl
[ix
] &= 7;
672 * disable SmartGuardian if both PWM outputs are
675 if ((data
->pwm_ctl
[ix
^ 1] & 1) == 0)
676 data
->fan_ctl
&= 0xe;
679 data
->pwm_ctl
[ix
] |= 8;
685 "pwm mode %ld not supported. Choose one of 0 or 2.\n",
689 vt1211_write8(data
, VT1211_REG_PWM_CTL
,
690 ((data
->pwm_ctl
[1] << 4) |
692 vt1211_write8(data
, VT1211_REG_FAN_DIV
,
693 ((data
->fan_div
[1] << 6) |
694 (data
->fan_div
[0] << 4) |
697 case SHOW_SET_PWM_FREQ
:
698 val
= 135000 / clamp_val(val
, 135000 >> 7, 135000);
699 /* calculate tmp = log2(val) */
701 for (val
>>= 1; val
> 0; val
>>= 1)
703 /* sync the data cache */
704 reg
= vt1211_read8(data
, VT1211_REG_PWM_CLK
);
705 data
->pwm_clk
= (reg
& 0xf8) | tmp
;
706 vt1211_write8(data
, VT1211_REG_PWM_CLK
, data
->pwm_clk
);
708 case SHOW_SET_PWM_AUTO_CHANNELS_TEMP
:
709 if (val
< 1 || val
> 7) {
712 "temp channel %ld not supported. Choose a value between 1 and 7.\n",
716 if (!ISTEMP(val
- 1, data
->uch_config
)) {
718 dev_warn(dev
, "temp channel %ld is not available.\n",
722 /* sync the data cache */
723 reg
= vt1211_read8(data
, VT1211_REG_PWM_CTL
);
724 data
->pwm_ctl
[0] = reg
& 0xf;
725 data
->pwm_ctl
[1] = (reg
>> 4) & 0xf;
726 data
->pwm_ctl
[ix
] = (data
->pwm_ctl
[ix
] & 8) | (val
- 1);
727 vt1211_write8(data
, VT1211_REG_PWM_CTL
,
728 ((data
->pwm_ctl
[1] << 4) | data
->pwm_ctl
[0]));
731 dev_dbg(dev
, "Unknown attr fetch (%d)\n", fn
);
735 mutex_unlock(&data
->update_lock
);
739 /* ---------------------------------------------------------------------
740 * PWM auto point definitions
743 * --------------------------------------------------------------------- */
746 * pwm[ix+1]_auto_point[ap+1]_temp mapping table:
747 * Note that there is only a single set of temp auto points that controls both
748 * PWM controllers. We still create 2 sets of sysfs files to make it look
749 * more consistent even though they map to the same registers.
751 * ix ap : description
752 * -------------------
753 * 0 0 : pwm1/2 off temperature (pwm_auto_temp[0])
754 * 0 1 : pwm1/2 low speed temperature (pwm_auto_temp[1])
755 * 0 2 : pwm1/2 high speed temperature (pwm_auto_temp[2])
756 * 0 3 : pwm1/2 full speed temperature (pwm_auto_temp[3])
757 * 1 0 : pwm1/2 off temperature (pwm_auto_temp[0])
758 * 1 1 : pwm1/2 low speed temperature (pwm_auto_temp[1])
759 * 1 2 : pwm1/2 high speed temperature (pwm_auto_temp[2])
760 * 1 3 : pwm1/2 full speed temperature (pwm_auto_temp[3])
763 static ssize_t
show_pwm_auto_point_temp(struct device
*dev
,
764 struct device_attribute
*attr
,
767 struct vt1211_data
*data
= vt1211_update_device(dev
);
768 struct sensor_device_attribute_2
*sensor_attr_2
=
769 to_sensor_dev_attr_2(attr
);
770 int ix
= sensor_attr_2
->index
;
771 int ap
= sensor_attr_2
->nr
;
773 return sprintf(buf
, "%d\n", TEMP_FROM_REG(data
->pwm_ctl
[ix
] & 7,
774 data
->pwm_auto_temp
[ap
]));
777 static ssize_t
set_pwm_auto_point_temp(struct device
*dev
,
778 struct device_attribute
*attr
,
779 const char *buf
, size_t count
)
781 struct vt1211_data
*data
= dev_get_drvdata(dev
);
782 struct sensor_device_attribute_2
*sensor_attr_2
=
783 to_sensor_dev_attr_2(attr
);
784 int ix
= sensor_attr_2
->index
;
785 int ap
= sensor_attr_2
->nr
;
790 err
= kstrtol(buf
, 10, &val
);
795 mutex_lock(&data
->update_lock
);
797 /* sync the data cache */
798 reg
= vt1211_read8(data
, VT1211_REG_PWM_CTL
);
799 data
->pwm_ctl
[0] = reg
& 0xf;
800 data
->pwm_ctl
[1] = (reg
>> 4) & 0xf;
802 data
->pwm_auto_temp
[ap
] = TEMP_TO_REG(data
->pwm_ctl
[ix
] & 7, val
);
803 vt1211_write8(data
, VT1211_REG_PWM_AUTO_TEMP(ap
),
804 data
->pwm_auto_temp
[ap
]);
805 mutex_unlock(&data
->update_lock
);
811 * pwm[ix+1]_auto_point[ap+1]_pwm mapping table:
812 * Note that the PWM auto points 0 & 3 are hard-wired in the VT1211 and can't
815 * ix ap : description
816 * -------------------
817 * 0 0 : pwm1 off (pwm_auto_pwm[0][0], hard-wired to 0)
818 * 0 1 : pwm1 low speed duty cycle (pwm_auto_pwm[0][1])
819 * 0 2 : pwm1 high speed duty cycle (pwm_auto_pwm[0][2])
820 * 0 3 : pwm1 full speed (pwm_auto_pwm[0][3], hard-wired to 255)
821 * 1 0 : pwm2 off (pwm_auto_pwm[1][0], hard-wired to 0)
822 * 1 1 : pwm2 low speed duty cycle (pwm_auto_pwm[1][1])
823 * 1 2 : pwm2 high speed duty cycle (pwm_auto_pwm[1][2])
824 * 1 3 : pwm2 full speed (pwm_auto_pwm[1][3], hard-wired to 255)
827 static ssize_t
show_pwm_auto_point_pwm(struct device
*dev
,
828 struct device_attribute
*attr
,
831 struct vt1211_data
*data
= vt1211_update_device(dev
);
832 struct sensor_device_attribute_2
*sensor_attr_2
=
833 to_sensor_dev_attr_2(attr
);
834 int ix
= sensor_attr_2
->index
;
835 int ap
= sensor_attr_2
->nr
;
837 return sprintf(buf
, "%d\n", data
->pwm_auto_pwm
[ix
][ap
]);
840 static ssize_t
set_pwm_auto_point_pwm(struct device
*dev
,
841 struct device_attribute
*attr
,
842 const char *buf
, size_t count
)
844 struct vt1211_data
*data
= dev_get_drvdata(dev
);
845 struct sensor_device_attribute_2
*sensor_attr_2
=
846 to_sensor_dev_attr_2(attr
);
847 int ix
= sensor_attr_2
->index
;
848 int ap
= sensor_attr_2
->nr
;
852 err
= kstrtoul(buf
, 10, &val
);
856 mutex_lock(&data
->update_lock
);
857 data
->pwm_auto_pwm
[ix
][ap
] = clamp_val(val
, 0, 255);
858 vt1211_write8(data
, VT1211_REG_PWM_AUTO_PWM(ix
, ap
),
859 data
->pwm_auto_pwm
[ix
][ap
]);
860 mutex_unlock(&data
->update_lock
);
865 /* ---------------------------------------------------------------------
866 * Miscellaneous sysfs interfaces (VRM, VID, name, and (legacy) alarms)
867 * --------------------------------------------------------------------- */
869 static ssize_t
show_vrm(struct device
*dev
, struct device_attribute
*attr
,
872 struct vt1211_data
*data
= dev_get_drvdata(dev
);
874 return sprintf(buf
, "%d\n", data
->vrm
);
877 static ssize_t
set_vrm(struct device
*dev
, struct device_attribute
*attr
,
878 const char *buf
, size_t count
)
880 struct vt1211_data
*data
= dev_get_drvdata(dev
);
884 err
= kstrtoul(buf
, 10, &val
);
896 static ssize_t
show_vid(struct device
*dev
, struct device_attribute
*attr
,
899 struct vt1211_data
*data
= dev_get_drvdata(dev
);
901 return sprintf(buf
, "%d\n", vid_from_reg(data
->vid
, data
->vrm
));
904 static ssize_t
show_name(struct device
*dev
,
905 struct device_attribute
*attr
, char *buf
)
907 struct vt1211_data
*data
= dev_get_drvdata(dev
);
909 return sprintf(buf
, "%s\n", data
->name
);
912 static ssize_t
show_alarms(struct device
*dev
,
913 struct device_attribute
*attr
, char *buf
)
915 struct vt1211_data
*data
= vt1211_update_device(dev
);
917 return sprintf(buf
, "%d\n", data
->alarms
);
920 /* ---------------------------------------------------------------------
921 * Device attribute structs
922 * --------------------------------------------------------------------- */
924 #define SENSOR_ATTR_IN(ix) \
925 { SENSOR_ATTR_2(in##ix##_input, S_IRUGO, \
926 show_in, NULL, SHOW_IN_INPUT, ix), \
927 SENSOR_ATTR_2(in##ix##_min, S_IRUGO | S_IWUSR, \
928 show_in, set_in, SHOW_SET_IN_MIN, ix), \
929 SENSOR_ATTR_2(in##ix##_max, S_IRUGO | S_IWUSR, \
930 show_in, set_in, SHOW_SET_IN_MAX, ix), \
931 SENSOR_ATTR_2(in##ix##_alarm, S_IRUGO, \
932 show_in, NULL, SHOW_IN_ALARM, ix) \
935 static struct sensor_device_attribute_2 vt1211_sysfs_in
[][4] = {
944 #define IN_UNIT_ATTRS(X) \
945 { &vt1211_sysfs_in[X][0].dev_attr.attr, \
946 &vt1211_sysfs_in[X][1].dev_attr.attr, \
947 &vt1211_sysfs_in[X][2].dev_attr.attr, \
948 &vt1211_sysfs_in[X][3].dev_attr.attr, \
952 static struct attribute
*vt1211_in_attr
[][5] = {
961 static const struct attribute_group vt1211_in_attr_group
[] = {
962 { .attrs
= vt1211_in_attr
[0] },
963 { .attrs
= vt1211_in_attr
[1] },
964 { .attrs
= vt1211_in_attr
[2] },
965 { .attrs
= vt1211_in_attr
[3] },
966 { .attrs
= vt1211_in_attr
[4] },
967 { .attrs
= vt1211_in_attr
[5] }
970 #define SENSOR_ATTR_TEMP(ix) \
971 { SENSOR_ATTR_2(temp##ix##_input, S_IRUGO, \
972 show_temp, NULL, SHOW_TEMP_INPUT, ix-1), \
973 SENSOR_ATTR_2(temp##ix##_max, S_IRUGO | S_IWUSR, \
974 show_temp, set_temp, SHOW_SET_TEMP_MAX, ix-1), \
975 SENSOR_ATTR_2(temp##ix##_max_hyst, S_IRUGO | S_IWUSR, \
976 show_temp, set_temp, SHOW_SET_TEMP_MAX_HYST, ix-1), \
977 SENSOR_ATTR_2(temp##ix##_alarm, S_IRUGO, \
978 show_temp, NULL, SHOW_TEMP_ALARM, ix-1) \
981 static struct sensor_device_attribute_2 vt1211_sysfs_temp
[][4] = {
991 #define TEMP_UNIT_ATTRS(X) \
992 { &vt1211_sysfs_temp[X][0].dev_attr.attr, \
993 &vt1211_sysfs_temp[X][1].dev_attr.attr, \
994 &vt1211_sysfs_temp[X][2].dev_attr.attr, \
995 &vt1211_sysfs_temp[X][3].dev_attr.attr, \
999 static struct attribute
*vt1211_temp_attr
[][5] = {
1009 static const struct attribute_group vt1211_temp_attr_group
[] = {
1010 { .attrs
= vt1211_temp_attr
[0] },
1011 { .attrs
= vt1211_temp_attr
[1] },
1012 { .attrs
= vt1211_temp_attr
[2] },
1013 { .attrs
= vt1211_temp_attr
[3] },
1014 { .attrs
= vt1211_temp_attr
[4] },
1015 { .attrs
= vt1211_temp_attr
[5] },
1016 { .attrs
= vt1211_temp_attr
[6] }
1019 #define SENSOR_ATTR_FAN(ix) \
1020 SENSOR_ATTR_2(fan##ix##_input, S_IRUGO, \
1021 show_fan, NULL, SHOW_FAN_INPUT, ix-1), \
1022 SENSOR_ATTR_2(fan##ix##_min, S_IRUGO | S_IWUSR, \
1023 show_fan, set_fan, SHOW_SET_FAN_MIN, ix-1), \
1024 SENSOR_ATTR_2(fan##ix##_div, S_IRUGO | S_IWUSR, \
1025 show_fan, set_fan, SHOW_SET_FAN_DIV, ix-1), \
1026 SENSOR_ATTR_2(fan##ix##_alarm, S_IRUGO, \
1027 show_fan, NULL, SHOW_FAN_ALARM, ix-1)
1029 #define SENSOR_ATTR_PWM(ix) \
1030 SENSOR_ATTR_2(pwm##ix, S_IRUGO, \
1031 show_pwm, NULL, SHOW_PWM, ix-1), \
1032 SENSOR_ATTR_2(pwm##ix##_enable, S_IRUGO | S_IWUSR, \
1033 show_pwm, set_pwm, SHOW_SET_PWM_ENABLE, ix-1), \
1034 SENSOR_ATTR_2(pwm##ix##_auto_channels_temp, S_IRUGO | S_IWUSR, \
1035 show_pwm, set_pwm, SHOW_SET_PWM_AUTO_CHANNELS_TEMP, ix-1)
1037 #define SENSOR_ATTR_PWM_FREQ(ix) \
1038 SENSOR_ATTR_2(pwm##ix##_freq, S_IRUGO | S_IWUSR, \
1039 show_pwm, set_pwm, SHOW_SET_PWM_FREQ, ix-1)
1041 #define SENSOR_ATTR_PWM_FREQ_RO(ix) \
1042 SENSOR_ATTR_2(pwm##ix##_freq, S_IRUGO, \
1043 show_pwm, NULL, SHOW_SET_PWM_FREQ, ix-1)
1045 #define SENSOR_ATTR_PWM_AUTO_POINT_TEMP(ix, ap) \
1046 SENSOR_ATTR_2(pwm##ix##_auto_point##ap##_temp, S_IRUGO | S_IWUSR, \
1047 show_pwm_auto_point_temp, set_pwm_auto_point_temp, \
1050 #define SENSOR_ATTR_PWM_AUTO_POINT_TEMP_RO(ix, ap) \
1051 SENSOR_ATTR_2(pwm##ix##_auto_point##ap##_temp, S_IRUGO, \
1052 show_pwm_auto_point_temp, NULL, \
1055 #define SENSOR_ATTR_PWM_AUTO_POINT_PWM(ix, ap) \
1056 SENSOR_ATTR_2(pwm##ix##_auto_point##ap##_pwm, S_IRUGO | S_IWUSR, \
1057 show_pwm_auto_point_pwm, set_pwm_auto_point_pwm, \
1060 #define SENSOR_ATTR_PWM_AUTO_POINT_PWM_RO(ix, ap) \
1061 SENSOR_ATTR_2(pwm##ix##_auto_point##ap##_pwm, S_IRUGO, \
1062 show_pwm_auto_point_pwm, NULL, \
1065 static struct sensor_device_attribute_2 vt1211_sysfs_fan_pwm
[] = {
1070 SENSOR_ATTR_PWM_FREQ(1),
1071 SENSOR_ATTR_PWM_FREQ_RO(2),
1072 SENSOR_ATTR_PWM_AUTO_POINT_TEMP(1, 1),
1073 SENSOR_ATTR_PWM_AUTO_POINT_TEMP(1, 2),
1074 SENSOR_ATTR_PWM_AUTO_POINT_TEMP(1, 3),
1075 SENSOR_ATTR_PWM_AUTO_POINT_TEMP(1, 4),
1076 SENSOR_ATTR_PWM_AUTO_POINT_TEMP_RO(2, 1),
1077 SENSOR_ATTR_PWM_AUTO_POINT_TEMP_RO(2, 2),
1078 SENSOR_ATTR_PWM_AUTO_POINT_TEMP_RO(2, 3),
1079 SENSOR_ATTR_PWM_AUTO_POINT_TEMP_RO(2, 4),
1080 SENSOR_ATTR_PWM_AUTO_POINT_PWM_RO(1, 1),
1081 SENSOR_ATTR_PWM_AUTO_POINT_PWM(1, 2),
1082 SENSOR_ATTR_PWM_AUTO_POINT_PWM(1, 3),
1083 SENSOR_ATTR_PWM_AUTO_POINT_PWM_RO(1, 4),
1084 SENSOR_ATTR_PWM_AUTO_POINT_PWM_RO(2, 1),
1085 SENSOR_ATTR_PWM_AUTO_POINT_PWM(2, 2),
1086 SENSOR_ATTR_PWM_AUTO_POINT_PWM(2, 3),
1087 SENSOR_ATTR_PWM_AUTO_POINT_PWM_RO(2, 4),
1090 static struct device_attribute vt1211_sysfs_misc
[] = {
1091 __ATTR(vrm
, S_IRUGO
| S_IWUSR
, show_vrm
, set_vrm
),
1092 __ATTR(cpu0_vid
, S_IRUGO
, show_vid
, NULL
),
1093 __ATTR(name
, S_IRUGO
, show_name
, NULL
),
1094 __ATTR(alarms
, S_IRUGO
, show_alarms
, NULL
),
1097 /* ---------------------------------------------------------------------
1098 * Device registration and initialization
1099 * --------------------------------------------------------------------- */
1101 static void vt1211_init_device(struct vt1211_data
*data
)
1104 data
->vrm
= vid_which_vrm();
1106 /* Read (and initialize) UCH config */
1107 data
->uch_config
= vt1211_read8(data
, VT1211_REG_UCH_CONFIG
);
1108 if (uch_config
> -1) {
1109 data
->uch_config
= (data
->uch_config
& 0x83) |
1111 vt1211_write8(data
, VT1211_REG_UCH_CONFIG
, data
->uch_config
);
1115 * Initialize the interrupt mode (if request at module load time).
1116 * The VT1211 implements 3 different modes for clearing interrupts:
1117 * 0: Clear INT when status register is read. Regenerate INT as long
1118 * as temp stays above hysteresis limit.
1119 * 1: Clear INT when status register is read. DON'T regenerate INT
1120 * until temp falls below hysteresis limit and exceeds hot limit
1122 * 2: Clear INT when temp falls below max limit.
1124 * The driver only allows to force mode 0 since that's the only one
1125 * that makes sense for 'sensors'
1127 if (int_mode
== 0) {
1128 vt1211_write8(data
, VT1211_REG_TEMP1_CONFIG
, 0);
1129 vt1211_write8(data
, VT1211_REG_TEMP2_CONFIG
, 0);
1132 /* Fill in some hard wired values into our data struct */
1133 data
->pwm_auto_pwm
[0][3] = 255;
1134 data
->pwm_auto_pwm
[1][3] = 255;
1137 static void vt1211_remove_sysfs(struct platform_device
*pdev
)
1139 struct device
*dev
= &pdev
->dev
;
1142 for (i
= 0; i
< ARRAY_SIZE(vt1211_in_attr_group
); i
++)
1143 sysfs_remove_group(&dev
->kobj
, &vt1211_in_attr_group
[i
]);
1145 for (i
= 0; i
< ARRAY_SIZE(vt1211_temp_attr_group
); i
++)
1146 sysfs_remove_group(&dev
->kobj
, &vt1211_temp_attr_group
[i
]);
1148 for (i
= 0; i
< ARRAY_SIZE(vt1211_sysfs_fan_pwm
); i
++) {
1149 device_remove_file(dev
,
1150 &vt1211_sysfs_fan_pwm
[i
].dev_attr
);
1152 for (i
= 0; i
< ARRAY_SIZE(vt1211_sysfs_misc
); i
++)
1153 device_remove_file(dev
, &vt1211_sysfs_misc
[i
]);
1156 static int vt1211_probe(struct platform_device
*pdev
)
1158 struct device
*dev
= &pdev
->dev
;
1159 struct vt1211_data
*data
;
1160 struct resource
*res
;
1163 data
= devm_kzalloc(dev
, sizeof(struct vt1211_data
), GFP_KERNEL
);
1167 res
= platform_get_resource(pdev
, IORESOURCE_IO
, 0);
1168 if (!devm_request_region(dev
, res
->start
, resource_size(res
),
1170 dev_err(dev
, "Failed to request region 0x%lx-0x%lx\n",
1171 (unsigned long)res
->start
, (unsigned long)res
->end
);
1174 data
->addr
= res
->start
;
1175 data
->name
= DRVNAME
;
1176 mutex_init(&data
->update_lock
);
1178 platform_set_drvdata(pdev
, data
);
1180 /* Initialize the VT1211 chip */
1181 vt1211_init_device(data
);
1183 /* Create sysfs interface files */
1184 for (i
= 0; i
< ARRAY_SIZE(vt1211_in_attr_group
); i
++) {
1185 if (ISVOLT(i
, data
->uch_config
)) {
1186 err
= sysfs_create_group(&dev
->kobj
,
1187 &vt1211_in_attr_group
[i
]);
1189 goto EXIT_DEV_REMOVE
;
1192 for (i
= 0; i
< ARRAY_SIZE(vt1211_temp_attr_group
); i
++) {
1193 if (ISTEMP(i
, data
->uch_config
)) {
1194 err
= sysfs_create_group(&dev
->kobj
,
1195 &vt1211_temp_attr_group
[i
]);
1197 goto EXIT_DEV_REMOVE
;
1200 for (i
= 0; i
< ARRAY_SIZE(vt1211_sysfs_fan_pwm
); i
++) {
1201 err
= device_create_file(dev
,
1202 &vt1211_sysfs_fan_pwm
[i
].dev_attr
);
1204 goto EXIT_DEV_REMOVE
;
1206 for (i
= 0; i
< ARRAY_SIZE(vt1211_sysfs_misc
); i
++) {
1207 err
= device_create_file(dev
,
1208 &vt1211_sysfs_misc
[i
]);
1210 goto EXIT_DEV_REMOVE
;
1213 /* Register device */
1214 data
->hwmon_dev
= hwmon_device_register(dev
);
1215 if (IS_ERR(data
->hwmon_dev
)) {
1216 err
= PTR_ERR(data
->hwmon_dev
);
1217 dev_err(dev
, "Class registration failed (%d)\n", err
);
1218 goto EXIT_DEV_REMOVE_SILENT
;
1224 dev_err(dev
, "Sysfs interface creation failed (%d)\n", err
);
1225 EXIT_DEV_REMOVE_SILENT
:
1226 vt1211_remove_sysfs(pdev
);
1230 static int vt1211_remove(struct platform_device
*pdev
)
1232 struct vt1211_data
*data
= platform_get_drvdata(pdev
);
1234 hwmon_device_unregister(data
->hwmon_dev
);
1235 vt1211_remove_sysfs(pdev
);
1240 static struct platform_driver vt1211_driver
= {
1244 .probe
= vt1211_probe
,
1245 .remove
= vt1211_remove
,
1248 static int __init
vt1211_device_add(unsigned short address
)
1250 struct resource res
= {
1252 .end
= address
+ 0x7f,
1253 .flags
= IORESOURCE_IO
,
1257 pdev
= platform_device_alloc(DRVNAME
, address
);
1260 pr_err("Device allocation failed (%d)\n", err
);
1264 res
.name
= pdev
->name
;
1265 err
= acpi_check_resource_conflict(&res
);
1269 err
= platform_device_add_resources(pdev
, &res
, 1);
1271 pr_err("Device resource addition failed (%d)\n", err
);
1275 err
= platform_device_add(pdev
);
1277 pr_err("Device addition failed (%d)\n", err
);
1284 platform_device_put(pdev
);
1289 static int __init
vt1211_find(int sio_cip
, unsigned short *address
)
1294 err
= superio_enter(sio_cip
);
1299 devid
= force_id
? force_id
: superio_inb(sio_cip
, SIO_VT1211_DEVID
);
1300 if (devid
!= SIO_VT1211_ID
)
1303 superio_select(sio_cip
, SIO_VT1211_LDN_HWMON
);
1305 if ((superio_inb(sio_cip
, SIO_VT1211_ACTIVE
) & 1) == 0) {
1306 pr_warn("HW monitor is disabled, skipping\n");
1310 *address
= ((superio_inb(sio_cip
, SIO_VT1211_BADDR
) << 8) |
1311 (superio_inb(sio_cip
, SIO_VT1211_BADDR
+ 1))) & 0xff00;
1312 if (*address
== 0) {
1313 pr_warn("Base address is not set, skipping\n");
1318 pr_info("Found VT1211 chip at 0x%04x, revision %u\n",
1319 *address
, superio_inb(sio_cip
, SIO_VT1211_DEVREV
));
1322 superio_exit(sio_cip
);
1326 static int __init
vt1211_init(void)
1329 unsigned short address
= 0;
1331 err
= vt1211_find(SIO_REG_CIP1
, &address
);
1333 err
= vt1211_find(SIO_REG_CIP2
, &address
);
1338 if ((uch_config
< -1) || (uch_config
> 31)) {
1340 pr_warn("Invalid UCH configuration %d. Choose a value between 0 and 31.\n",
1345 if ((int_mode
< -1) || (int_mode
> 0)) {
1347 pr_warn("Invalid interrupt mode %d. Only mode 0 is supported.\n",
1352 err
= platform_driver_register(&vt1211_driver
);
1356 /* Sets global pdev as a side effect */
1357 err
= vt1211_device_add(address
);
1359 goto EXIT_DRV_UNREGISTER
;
1363 EXIT_DRV_UNREGISTER
:
1364 platform_driver_unregister(&vt1211_driver
);
1369 static void __exit
vt1211_exit(void)
1371 platform_device_unregister(pdev
);
1372 platform_driver_unregister(&vt1211_driver
);
1375 MODULE_AUTHOR("Juerg Haefliger <juergh@gmail.com>");
1376 MODULE_DESCRIPTION("VT1211 sensors");
1377 MODULE_LICENSE("GPL");
1379 module_init(vt1211_init
);
1380 module_exit(vt1211_exit
);