2 w83627hf.c - Part of lm_sensors, Linux kernel modules for hardware
4 Copyright (c) 1998 - 2003 Frodo Looijaard <frodol@dds.nl>,
5 Philip Edelbrock <phil@netroedge.com>,
6 and Mark Studebaker <mdsxyz123@yahoo.com>
7 Ported to 2.6 by Bernhard C. Schrenk <clemy@clemy.org>
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.
25 Supports following chips:
27 Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA
28 w83627hf 9 3 2 3 0x20 0x5ca3 no yes(LPC)
29 w83627thf 7 3 3 3 0x90 0x5ca3 no yes(LPC)
30 w83637hf 7 3 3 3 0x80 0x5ca3 no yes(LPC)
31 w83697hf 8 2 2 2 0x60 0x5ca3 no yes(LPC)
33 For other winbond chips, and for i2c support in the above chips,
36 Note: automatic ("cruise") fan control for 697, 637 & 627thf not
40 #include <linux/module.h>
41 #include <linux/init.h>
42 #include <linux/slab.h>
43 #include <linux/i2c.h>
44 #include <linux/i2c-sensor.h>
45 #include <linux/i2c-vid.h>
49 static int force_addr;
50 MODULE_PARM(force_addr, "i");
51 MODULE_PARM_DESC(force_addr,
52 "Initialize the base address of the sensors");
53 static int force_i2c = 0x1f;
54 MODULE_PARM(force_i2c, "i");
55 MODULE_PARM_DESC(force_i2c,
56 "Initialize the i2c address of the sensors");
58 /* Addresses to scan */
59 static unsigned short normal_i2c[] = { I2C_CLIENT_END };
60 static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
61 static unsigned int normal_isa[] = { 0, I2C_CLIENT_ISA_END };
62 static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
64 /* Insmod parameters */
65 SENSORS_INSMOD_4(w83627hf, w83627thf, w83697hf, w83637hf);
68 MODULE_PARM(init, "i");
69 MODULE_PARM_DESC(init, "Set to zero to bypass chip initialization");
71 /* modified from kernel/include/traps.c */
72 #define REG 0x2e /* The register to read/write */
73 #define DEV 0x07 /* Register: Logical device select */
74 #define VAL 0x2f /* The value to read/write */
76 /* logical device numbers for superio_select (below) */
77 #define W83627HF_LD_FDC 0x00
78 #define W83627HF_LD_PRT 0x01
79 #define W83627HF_LD_UART1 0x02
80 #define W83627HF_LD_UART2 0x03
81 #define W83627HF_LD_KBC 0x05
82 #define W83627HF_LD_CIR 0x06 /* w83627hf only */
83 #define W83627HF_LD_GAME 0x07
84 #define W83627HF_LD_MIDI 0x07
85 #define W83627HF_LD_GPIO1 0x07
86 #define W83627HF_LD_GPIO5 0x07 /* w83627thf only */
87 #define W83627HF_LD_GPIO2 0x08
88 #define W83627HF_LD_GPIO3 0x09
89 #define W83627HF_LD_GPIO4 0x09 /* w83627thf only */
90 #define W83627HF_LD_ACPI 0x0a
91 #define W83627HF_LD_HWM 0x0b
93 #define DEVID 0x20 /* Register: Device ID */
95 #define W83627THF_GPIO5_IOSR 0xf3 /* w83627thf only */
96 #define W83627THF_GPIO5_DR 0xf4 /* w83627thf only */
97 #define W83627THF_GPIO5_INVR 0xf5 /* w83627thf only */
100 superio_outb(int reg, int val)
114 superio_select(int ld)
133 #define W627_DEVID 0x52
134 #define W627THF_DEVID 0x82
135 #define W697_DEVID 0x60
136 #define W637_DEVID 0x70
137 #define WINB_ACT_REG 0x30
138 #define WINB_BASE_REG 0x60
139 /* Constants specified below */
141 /* Length of ISA address segment */
142 #define WINB_EXTENT 8
144 /* Where are the ISA address/data registers relative to the base address */
145 #define W83781D_ADDR_REG_OFFSET 5
146 #define W83781D_DATA_REG_OFFSET 6
148 /* The W83781D registers */
149 /* The W83782D registers for nr=7,8 are in bank 5 */
150 #define W83781D_REG_IN_MAX(nr) ((nr < 7) ? (0x2b + (nr) * 2) : \
151 (0x554 + (((nr) - 7) * 2)))
152 #define W83781D_REG_IN_MIN(nr) ((nr < 7) ? (0x2c + (nr) * 2) : \
153 (0x555 + (((nr) - 7) * 2)))
154 #define W83781D_REG_IN(nr) ((nr < 7) ? (0x20 + (nr)) : \
157 #define W83781D_REG_FAN_MIN(nr) (0x3a + (nr))
158 #define W83781D_REG_FAN(nr) (0x27 + (nr))
160 #define W83781D_REG_TEMP2_CONFIG 0x152
161 #define W83781D_REG_TEMP3_CONFIG 0x252
162 #define W83781D_REG_TEMP(nr) ((nr == 3) ? (0x0250) : \
163 ((nr == 2) ? (0x0150) : \
165 #define W83781D_REG_TEMP_HYST(nr) ((nr == 3) ? (0x253) : \
166 ((nr == 2) ? (0x153) : \
168 #define W83781D_REG_TEMP_OVER(nr) ((nr == 3) ? (0x255) : \
169 ((nr == 2) ? (0x155) : \
172 #define W83781D_REG_BANK 0x4E
174 #define W83781D_REG_CONFIG 0x40
175 #define W83781D_REG_ALARM1 0x41
176 #define W83781D_REG_ALARM2 0x42
177 #define W83781D_REG_ALARM3 0x450
179 #define W83781D_REG_IRQ 0x4C
180 #define W83781D_REG_BEEP_CONFIG 0x4D
181 #define W83781D_REG_BEEP_INTS1 0x56
182 #define W83781D_REG_BEEP_INTS2 0x57
183 #define W83781D_REG_BEEP_INTS3 0x453
185 #define W83781D_REG_VID_FANDIV 0x47
187 #define W83781D_REG_CHIPID 0x49
188 #define W83781D_REG_WCHIPID 0x58
189 #define W83781D_REG_CHIPMAN 0x4F
190 #define W83781D_REG_PIN 0x4B
192 #define W83781D_REG_VBAT 0x5D
194 #define W83627HF_REG_PWM1 0x5A
195 #define W83627HF_REG_PWM2 0x5B
196 #define W83627HF_REG_PWMCLK12 0x5C
198 #define W83627THF_REG_PWM1 0x01 /* 697HF and 637HF too */
199 #define W83627THF_REG_PWM2 0x03 /* 697HF and 637HF too */
200 #define W83627THF_REG_PWM3 0x11 /* 637HF too */
202 #define W83627THF_REG_VRM_OVT_CFG 0x18 /* 637HF too */
204 static const u8 regpwm_627hf[] = { W83627HF_REG_PWM1, W83627HF_REG_PWM2 };
205 static const u8 regpwm[] = { W83627THF_REG_PWM1, W83627THF_REG_PWM2,
206 W83627THF_REG_PWM3 };
207 #define W836X7HF_REG_PWM(type, nr) (((type) == w83627hf) ? \
208 regpwm_627hf[(nr) - 1] : regpwm[(nr) - 1])
210 #define W83781D_REG_I2C_ADDR 0x48
211 #define W83781D_REG_I2C_SUBADDR 0x4A
213 /* Sensor selection */
214 #define W83781D_REG_SCFG1 0x5D
215 static const u8 BIT_SCFG1[] = { 0x02, 0x04, 0x08 };
216 #define W83781D_REG_SCFG2 0x59
217 static const u8 BIT_SCFG2[] = { 0x10, 0x20, 0x40 };
218 #define W83781D_DEFAULT_BETA 3435
220 /* Conversions. Limit checking is only done on the TO_REG
221 variants. Note that you should be a bit careful with which arguments
222 these macros are called: arguments may be evaluated more than once.
223 Fixing this is just not worth it. */
224 #define IN_TO_REG(val) (SENSORS_LIMIT((((val) + 8)/16),0,255))
225 #define IN_FROM_REG(val) ((val) * 16)
227 static inline u8 FAN_TO_REG(long rpm, int div)
231 rpm = SENSORS_LIMIT(rpm, 1, 1000000);
232 return SENSORS_LIMIT((1350000 + rpm * div / 2) / (rpm * div), 1,
236 #define TEMP_MIN (-128000)
237 #define TEMP_MAX ( 127000)
239 /* TEMP: 0.001C/bit (-128C to +127C)
240 REG: 1C/bit, two's complement */
241 static u8 TEMP_TO_REG(int temp)
243 int ntemp = SENSORS_LIMIT(temp, TEMP_MIN, TEMP_MAX);
244 ntemp += (ntemp<0 ? -500 : 500);
245 return (u8)(ntemp / 1000);
248 static int TEMP_FROM_REG(u8 reg)
250 return (s8)reg * 1000;
253 #define FAN_FROM_REG(val,div) ((val)==0?-1:(val)==255?0:1350000/((val)*(div)))
255 #define PWM_TO_REG(val) (SENSORS_LIMIT((val),0,255))
257 #define BEEP_MASK_FROM_REG(val) (val)
258 #define BEEP_MASK_TO_REG(val) ((val) & 0xffffff)
259 #define BEEP_ENABLE_TO_REG(val) ((val)?1:0)
260 #define BEEP_ENABLE_FROM_REG(val) ((val)?1:0)
262 #define DIV_FROM_REG(val) (1 << (val))
264 static inline u8 DIV_TO_REG(long val)
267 val = SENSORS_LIMIT(val, 1, 128) >> 1;
268 for (i = 0; i < 6; i++) {
276 /* For each registered chip, we need to keep some data in memory. That
277 data is pointed to by w83627hf_list[NR]->data. The structure itself is
278 dynamically allocated, at the same time when a new client is allocated. */
279 struct w83627hf_data {
280 struct i2c_client client;
281 struct semaphore lock;
284 struct semaphore update_lock;
285 char valid; /* !=0 if following fields are valid */
286 unsigned long last_updated; /* In jiffies */
288 struct i2c_client *lm75; /* for secondary I2C addresses */
289 /* pointer to array of 2 subclients */
291 u8 in[9]; /* Register value */
292 u8 in_max[9]; /* Register value */
293 u8 in_min[9]; /* Register value */
294 u8 fan[3]; /* Register value */
295 u8 fan_min[3]; /* Register value */
297 u8 temp_max; /* Register value */
298 u8 temp_max_hyst; /* Register value */
299 u16 temp_add[2]; /* Register value */
300 u16 temp_max_add[2]; /* Register value */
301 u16 temp_max_hyst_add[2]; /* Register value */
302 u8 fan_div[3]; /* Register encoding, shifted right */
303 u8 vid; /* Register encoding, combined */
304 u32 alarms; /* Register encoding, combined */
305 u32 beep_mask; /* Register encoding, combined */
306 u8 beep_enable; /* Boolean */
307 u8 pwm[3]; /* Register value */
308 u8 pwmenable[3]; /* bool */
309 u16 sens[3]; /* 782D/783S only.
310 1 = pentium diode; 2 = 3904 diode;
311 3000-5000 = thermistor beta.
313 Other Betas unimplemented */
315 u8 vrm_ovt; /* Register value, 627thf & 637hf only */
319 static int w83627hf_attach_adapter(struct i2c_adapter *adapter);
320 static int w83627hf_detect(struct i2c_adapter *adapter, int address,
322 static int w83627hf_detach_client(struct i2c_client *client);
324 static int w83627hf_read_value(struct i2c_client *client, u16 register);
325 static int w83627hf_write_value(struct i2c_client *client, u16 register,
327 static struct w83627hf_data *w83627hf_update_device(struct device *dev);
328 static void w83627hf_init_client(struct i2c_client *client);
330 static struct i2c_driver w83627hf_driver = {
331 .owner = THIS_MODULE,
333 .id = I2C_DRIVERID_W83627HF,
334 .flags = I2C_DF_NOTIFY,
335 .attach_adapter = w83627hf_attach_adapter,
336 .detach_client = w83627hf_detach_client,
339 /* following are the sysfs callback functions */
340 #define show_in_reg(reg) \
341 static ssize_t show_##reg (struct device *dev, char *buf, int nr) \
343 struct w83627hf_data *data = w83627hf_update_device(dev); \
344 return sprintf(buf,"%ld\n", (long)IN_FROM_REG(data->reg[nr])); \
350 #define store_in_reg(REG, reg) \
352 store_in_##reg (struct device *dev, const char *buf, size_t count, int nr) \
354 struct i2c_client *client = to_i2c_client(dev); \
355 struct w83627hf_data *data = i2c_get_clientdata(client); \
358 val = simple_strtoul(buf, NULL, 10); \
359 data->in_##reg[nr] = IN_TO_REG(val); \
360 w83627hf_write_value(client, W83781D_REG_IN_##REG(nr), \
361 data->in_##reg[nr]); \
365 store_in_reg(MIN, min)
366 store_in_reg(MAX, max)
368 #define sysfs_in_offset(offset) \
370 show_regs_in_##offset (struct device *dev, char *buf) \
372 return show_in(dev, buf, 0x##offset); \
374 static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_regs_in_##offset, NULL);
376 #define sysfs_in_reg_offset(reg, offset) \
377 static ssize_t show_regs_in_##reg##offset (struct device *dev, char *buf) \
379 return show_in_##reg (dev, buf, 0x##offset); \
382 store_regs_in_##reg##offset (struct device *dev, \
383 const char *buf, size_t count) \
385 return store_in_##reg (dev, buf, count, 0x##offset); \
387 static DEVICE_ATTR(in##offset##_##reg, S_IRUGO| S_IWUSR, \
388 show_regs_in_##reg##offset, store_regs_in_##reg##offset);
390 #define sysfs_in_offsets(offset) \
391 sysfs_in_offset(offset) \
392 sysfs_in_reg_offset(min, offset) \
393 sysfs_in_reg_offset(max, offset)
404 /* use a different set of functions for in0 */
405 static ssize_t show_in_0(struct w83627hf_data *data, char *buf, u8 reg)
409 if ((data->vrm_ovt & 0x01) &&
410 (w83627thf == data->type || w83637hf == data->type))
412 /* use VRM9 calculation */
413 in0 = (long)((reg * 488 + 70000 + 50) / 100);
415 /* use VRM8 (standard) calculation */
416 in0 = (long)IN_FROM_REG(reg);
418 return sprintf(buf,"%ld\n", in0);
421 static ssize_t show_regs_in_0(struct device *dev, char *buf)
423 struct w83627hf_data *data = w83627hf_update_device(dev);
424 return show_in_0(data, buf, data->in[0]);
427 static ssize_t show_regs_in_min0(struct device *dev, char *buf)
429 struct w83627hf_data *data = w83627hf_update_device(dev);
430 return show_in_0(data, buf, data->in_min[0]);
433 static ssize_t show_regs_in_max0(struct device *dev, char *buf)
435 struct w83627hf_data *data = w83627hf_update_device(dev);
436 return show_in_0(data, buf, data->in_max[0]);
439 static ssize_t store_regs_in_min0(struct device *dev,
440 const char *buf, size_t count)
442 struct i2c_client *client = to_i2c_client(dev);
443 struct w83627hf_data *data = i2c_get_clientdata(client);
446 val = simple_strtoul(buf, NULL, 10);
447 if ((data->vrm_ovt & 0x01) &&
448 (w83627thf == data->type || w83637hf == data->type))
450 /* use VRM9 calculation */
451 data->in_min[0] = (u8)(((val * 100) - 70000 + 244) / 488);
453 /* use VRM8 (standard) calculation */
454 data->in_min[0] = IN_TO_REG(val);
456 w83627hf_write_value(client, W83781D_REG_IN_MIN(0), data->in_min[0]);
460 static ssize_t store_regs_in_max0(struct device *dev,
461 const char *buf, size_t count)
463 struct i2c_client *client = to_i2c_client(dev);
464 struct w83627hf_data *data = i2c_get_clientdata(client);
467 val = simple_strtoul(buf, NULL, 10);
468 if ((data->vrm_ovt & 0x01) &&
469 (w83627thf == data->type || w83637hf == data->type))
471 /* use VRM9 calculation */
472 data->in_max[0] = (u8)(((val * 100) - 70000 + 244) / 488);
474 /* use VRM8 (standard) calculation */
475 data->in_max[0] = IN_TO_REG(val);
477 w83627hf_write_value(client, W83781D_REG_IN_MAX(0), data->in_max[0]);
481 static DEVICE_ATTR(in0_input, S_IRUGO, show_regs_in_0, NULL);
482 static DEVICE_ATTR(in0_min, S_IRUGO | S_IWUSR,
483 show_regs_in_min0, store_regs_in_min0);
484 static DEVICE_ATTR(in0_max, S_IRUGO | S_IWUSR,
485 show_regs_in_max0, store_regs_in_max0);
487 #define device_create_file_in(client, offset) \
489 device_create_file(&client->dev, &dev_attr_in##offset##_input); \
490 device_create_file(&client->dev, &dev_attr_in##offset##_min); \
491 device_create_file(&client->dev, &dev_attr_in##offset##_max); \
494 #define show_fan_reg(reg) \
495 static ssize_t show_##reg (struct device *dev, char *buf, int nr) \
497 struct w83627hf_data *data = w83627hf_update_device(dev); \
498 return sprintf(buf,"%ld\n", \
499 FAN_FROM_REG(data->reg[nr-1], \
500 (long)DIV_FROM_REG(data->fan_div[nr-1]))); \
503 show_fan_reg(fan_min);
506 store_fan_min(struct device *dev, const char *buf, size_t count, int nr)
508 struct i2c_client *client = to_i2c_client(dev);
509 struct w83627hf_data *data = i2c_get_clientdata(client);
512 val = simple_strtoul(buf, NULL, 10);
513 data->fan_min[nr - 1] =
514 FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr - 1]));
515 w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr),
516 data->fan_min[nr - 1]);
521 #define sysfs_fan_offset(offset) \
522 static ssize_t show_regs_fan_##offset (struct device *dev, char *buf) \
524 return show_fan(dev, buf, 0x##offset); \
526 static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_regs_fan_##offset, NULL);
528 #define sysfs_fan_min_offset(offset) \
529 static ssize_t show_regs_fan_min##offset (struct device *dev, char *buf) \
531 return show_fan_min(dev, buf, 0x##offset); \
534 store_regs_fan_min##offset (struct device *dev, const char *buf, size_t count) \
536 return store_fan_min(dev, buf, count, 0x##offset); \
538 static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
539 show_regs_fan_min##offset, store_regs_fan_min##offset);
542 sysfs_fan_min_offset(1);
544 sysfs_fan_min_offset(2);
546 sysfs_fan_min_offset(3);
548 #define device_create_file_fan(client, offset) \
550 device_create_file(&client->dev, &dev_attr_fan##offset##_input); \
551 device_create_file(&client->dev, &dev_attr_fan##offset##_min); \
554 #define show_temp_reg(reg) \
555 static ssize_t show_##reg (struct device *dev, char *buf, int nr) \
557 struct w83627hf_data *data = w83627hf_update_device(dev); \
558 if (nr >= 2) { /* TEMP2 and TEMP3 */ \
559 return sprintf(buf,"%ld\n", \
560 (long)LM75_TEMP_FROM_REG(data->reg##_add[nr-2])); \
561 } else { /* TEMP1 */ \
562 return sprintf(buf,"%ld\n", (long)TEMP_FROM_REG(data->reg)); \
566 show_temp_reg(temp_max);
567 show_temp_reg(temp_max_hyst);
569 #define store_temp_reg(REG, reg) \
571 store_temp_##reg (struct device *dev, const char *buf, size_t count, int nr) \
573 struct i2c_client *client = to_i2c_client(dev); \
574 struct w83627hf_data *data = i2c_get_clientdata(client); \
577 val = simple_strtoul(buf, NULL, 10); \
579 if (nr >= 2) { /* TEMP2 and TEMP3 */ \
580 data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \
581 w83627hf_write_value(client, W83781D_REG_TEMP_##REG(nr), \
582 data->temp_##reg##_add[nr-2]); \
583 } else { /* TEMP1 */ \
584 data->temp_##reg = TEMP_TO_REG(val); \
585 w83627hf_write_value(client, W83781D_REG_TEMP_##REG(nr), \
591 store_temp_reg(OVER, max);
592 store_temp_reg(HYST, max_hyst);
594 #define sysfs_temp_offset(offset) \
596 show_regs_temp_##offset (struct device *dev, char *buf) \
598 return show_temp(dev, buf, 0x##offset); \
600 static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_regs_temp_##offset, NULL);
602 #define sysfs_temp_reg_offset(reg, offset) \
603 static ssize_t show_regs_temp_##reg##offset (struct device *dev, char *buf) \
605 return show_temp_##reg (dev, buf, 0x##offset); \
608 store_regs_temp_##reg##offset (struct device *dev, \
609 const char *buf, size_t count) \
611 return store_temp_##reg (dev, buf, count, 0x##offset); \
613 static DEVICE_ATTR(temp##offset##_##reg, S_IRUGO| S_IWUSR, \
614 show_regs_temp_##reg##offset, store_regs_temp_##reg##offset);
616 #define sysfs_temp_offsets(offset) \
617 sysfs_temp_offset(offset) \
618 sysfs_temp_reg_offset(max, offset) \
619 sysfs_temp_reg_offset(max_hyst, offset)
621 sysfs_temp_offsets(1);
622 sysfs_temp_offsets(2);
623 sysfs_temp_offsets(3);
625 #define device_create_file_temp(client, offset) \
627 device_create_file(&client->dev, &dev_attr_temp##offset##_input); \
628 device_create_file(&client->dev, &dev_attr_temp##offset##_max); \
629 device_create_file(&client->dev, &dev_attr_temp##offset##_max_hyst); \
633 show_vid_reg(struct device *dev, char *buf)
635 struct w83627hf_data *data = w83627hf_update_device(dev);
636 return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm));
638 static DEVICE_ATTR(in0_ref, S_IRUGO, show_vid_reg, NULL);
639 #define device_create_file_vid(client) \
640 device_create_file(&client->dev, &dev_attr_in0_ref)
643 show_vrm_reg(struct device *dev, char *buf)
645 struct w83627hf_data *data = w83627hf_update_device(dev);
646 return sprintf(buf, "%ld\n", (long) data->vrm);
649 store_vrm_reg(struct device *dev, const char *buf, size_t count)
651 struct i2c_client *client = to_i2c_client(dev);
652 struct w83627hf_data *data = i2c_get_clientdata(client);
655 val = simple_strtoul(buf, NULL, 10);
660 static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg);
661 #define device_create_file_vrm(client) \
662 device_create_file(&client->dev, &dev_attr_vrm)
665 show_alarms_reg(struct device *dev, char *buf)
667 struct w83627hf_data *data = w83627hf_update_device(dev);
668 return sprintf(buf, "%ld\n", (long) data->alarms);
670 static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL);
671 #define device_create_file_alarms(client) \
672 device_create_file(&client->dev, &dev_attr_alarms)
674 #define show_beep_reg(REG, reg) \
675 static ssize_t show_beep_##reg (struct device *dev, char *buf) \
677 struct w83627hf_data *data = w83627hf_update_device(dev); \
678 return sprintf(buf,"%ld\n", \
679 (long)BEEP_##REG##_FROM_REG(data->beep_##reg)); \
681 show_beep_reg(ENABLE, enable)
682 show_beep_reg(MASK, mask)
684 #define BEEP_ENABLE 0 /* Store beep_enable */
685 #define BEEP_MASK 1 /* Store beep_mask */
688 store_beep_reg(struct device *dev, const char *buf, size_t count,
691 struct i2c_client *client = to_i2c_client(dev);
692 struct w83627hf_data *data = i2c_get_clientdata(client);
695 val = simple_strtoul(buf, NULL, 10);
697 if (update_mask == BEEP_MASK) { /* We are storing beep_mask */
698 data->beep_mask = BEEP_MASK_TO_REG(val);
699 w83627hf_write_value(client, W83781D_REG_BEEP_INTS1,
700 data->beep_mask & 0xff);
701 w83627hf_write_value(client, W83781D_REG_BEEP_INTS3,
702 ((data->beep_mask) >> 16) & 0xff);
703 val2 = (data->beep_mask >> 8) & 0x7f;
704 } else { /* We are storing beep_enable */
706 w83627hf_read_value(client, W83781D_REG_BEEP_INTS2) & 0x7f;
707 data->beep_enable = BEEP_ENABLE_TO_REG(val);
710 w83627hf_write_value(client, W83781D_REG_BEEP_INTS2,
711 val2 | data->beep_enable << 7);
716 #define sysfs_beep(REG, reg) \
717 static ssize_t show_regs_beep_##reg (struct device *dev, char *buf) \
719 return show_beep_##reg(dev, buf); \
722 store_regs_beep_##reg (struct device *dev, const char *buf, size_t count) \
724 return store_beep_reg(dev, buf, count, BEEP_##REG); \
726 static DEVICE_ATTR(beep_##reg, S_IRUGO | S_IWUSR, \
727 show_regs_beep_##reg, store_regs_beep_##reg);
729 sysfs_beep(ENABLE, enable);
730 sysfs_beep(MASK, mask);
732 #define device_create_file_beep(client) \
734 device_create_file(&client->dev, &dev_attr_beep_enable); \
735 device_create_file(&client->dev, &dev_attr_beep_mask); \
739 show_fan_div_reg(struct device *dev, char *buf, int nr)
741 struct w83627hf_data *data = w83627hf_update_device(dev);
742 return sprintf(buf, "%ld\n",
743 (long) DIV_FROM_REG(data->fan_div[nr - 1]));
746 /* Note: we save and restore the fan minimum here, because its value is
747 determined in part by the fan divisor. This follows the principle of
748 least suprise; the user doesn't expect the fan minimum to change just
749 because the divisor changed. */
751 store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr)
753 struct i2c_client *client = to_i2c_client(dev);
754 struct w83627hf_data *data = i2c_get_clientdata(client);
759 min = FAN_FROM_REG(data->fan_min[nr],
760 DIV_FROM_REG(data->fan_div[nr]));
762 data->fan_div[nr] = DIV_TO_REG(simple_strtoul(buf, NULL, 10));
764 reg = (w83627hf_read_value(client, nr==2 ? W83781D_REG_PIN : W83781D_REG_VID_FANDIV)
765 & (nr==0 ? 0xcf : 0x3f))
766 | ((data->fan_div[nr] & 0x03) << (nr==0 ? 4 : 6));
767 w83627hf_write_value(client, nr==2 ? W83781D_REG_PIN : W83781D_REG_VID_FANDIV, reg);
769 reg = (w83627hf_read_value(client, W83781D_REG_VBAT)
771 | ((data->fan_div[nr] & 0x04) << (3 + nr));
772 w83627hf_write_value(client, W83781D_REG_VBAT, reg);
774 /* Restore fan_min */
775 data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
776 w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr+1), data->fan_min[nr]);
781 #define sysfs_fan_div(offset) \
782 static ssize_t show_regs_fan_div_##offset (struct device *dev, char *buf) \
784 return show_fan_div_reg(dev, buf, offset); \
787 store_regs_fan_div_##offset (struct device *dev, \
788 const char *buf, size_t count) \
790 return store_fan_div_reg(dev, buf, count, offset - 1); \
792 static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
793 show_regs_fan_div_##offset, store_regs_fan_div_##offset);
799 #define device_create_file_fan_div(client, offset) \
801 device_create_file(&client->dev, &dev_attr_fan##offset##_div); \
805 show_pwm_reg(struct device *dev, char *buf, int nr)
807 struct w83627hf_data *data = w83627hf_update_device(dev);
808 return sprintf(buf, "%ld\n", (long) data->pwm[nr - 1]);
812 store_pwm_reg(struct device *dev, const char *buf, size_t count, int nr)
814 struct i2c_client *client = to_i2c_client(dev);
815 struct w83627hf_data *data = i2c_get_clientdata(client);
818 val = simple_strtoul(buf, NULL, 10);
820 if (data->type == w83627thf) {
821 /* bits 0-3 are reserved in 627THF */
822 data->pwm[nr - 1] = PWM_TO_REG(val) & 0xf0;
823 w83627hf_write_value(client,
824 W836X7HF_REG_PWM(data->type, nr),
826 (w83627hf_read_value(client,
827 W836X7HF_REG_PWM(data->type, nr)) & 0x0f));
829 data->pwm[nr - 1] = PWM_TO_REG(val);
830 w83627hf_write_value(client,
831 W836X7HF_REG_PWM(data->type, nr),
838 #define sysfs_pwm(offset) \
839 static ssize_t show_regs_pwm_##offset (struct device *dev, char *buf) \
841 return show_pwm_reg(dev, buf, offset); \
844 store_regs_pwm_##offset (struct device *dev, const char *buf, size_t count) \
846 return store_pwm_reg(dev, buf, count, offset); \
848 static DEVICE_ATTR(fan##offset##_pwm, S_IRUGO | S_IWUSR, \
849 show_regs_pwm_##offset, store_regs_pwm_##offset);
855 #define device_create_file_pwm(client, offset) \
857 device_create_file(&client->dev, &dev_attr_fan##offset##_pwm); \
861 show_sensor_reg(struct device *dev, char *buf, int nr)
863 struct w83627hf_data *data = w83627hf_update_device(dev);
864 return sprintf(buf, "%ld\n", (long) data->sens[nr - 1]);
868 store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr)
870 struct i2c_client *client = to_i2c_client(dev);
871 struct w83627hf_data *data = i2c_get_clientdata(client);
874 val = simple_strtoul(buf, NULL, 10);
877 case 1: /* PII/Celeron diode */
878 tmp = w83627hf_read_value(client, W83781D_REG_SCFG1);
879 w83627hf_write_value(client, W83781D_REG_SCFG1,
880 tmp | BIT_SCFG1[nr - 1]);
881 tmp = w83627hf_read_value(client, W83781D_REG_SCFG2);
882 w83627hf_write_value(client, W83781D_REG_SCFG2,
883 tmp | BIT_SCFG2[nr - 1]);
884 data->sens[nr - 1] = val;
887 tmp = w83627hf_read_value(client, W83781D_REG_SCFG1);
888 w83627hf_write_value(client, W83781D_REG_SCFG1,
889 tmp | BIT_SCFG1[nr - 1]);
890 tmp = w83627hf_read_value(client, W83781D_REG_SCFG2);
891 w83627hf_write_value(client, W83781D_REG_SCFG2,
892 tmp & ~BIT_SCFG2[nr - 1]);
893 data->sens[nr - 1] = val;
895 case W83781D_DEFAULT_BETA: /* thermistor */
896 tmp = w83627hf_read_value(client, W83781D_REG_SCFG1);
897 w83627hf_write_value(client, W83781D_REG_SCFG1,
898 tmp & ~BIT_SCFG1[nr - 1]);
899 data->sens[nr - 1] = val;
902 dev_err(&client->dev,
903 "Invalid sensor type %ld; must be 1, 2, or %d\n",
904 (long) val, W83781D_DEFAULT_BETA);
911 #define sysfs_sensor(offset) \
912 static ssize_t show_regs_sensor_##offset (struct device *dev, char *buf) \
914 return show_sensor_reg(dev, buf, offset); \
917 store_regs_sensor_##offset (struct device *dev, const char *buf, size_t count) \
919 return store_sensor_reg(dev, buf, count, offset); \
921 static DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, \
922 show_regs_sensor_##offset, store_regs_sensor_##offset);
928 #define device_create_file_sensor(client, offset) \
930 device_create_file(&client->dev, &dev_attr_temp##offset##_type); \
934 /* This function is called when:
935 * w83627hf_driver is inserted (when this module is loaded), for each
937 * when a new adapter is inserted (and w83627hf_driver is still present) */
938 static int w83627hf_attach_adapter(struct i2c_adapter *adapter)
940 return i2c_detect(adapter, &addr_data, w83627hf_detect);
943 static int w83627hf_find(int *address)
948 val= superio_inb(DEVID);
949 if(val != W627_DEVID &&
950 val != W627THF_DEVID &&
957 superio_select(W83627HF_LD_HWM);
958 val = (superio_inb(WINB_BASE_REG) << 8) |
959 superio_inb(WINB_BASE_REG + 1);
960 *address = val & ~(WINB_EXTENT - 1);
961 if (*address == 0 && force_addr == 0) {
966 *address = force_addr; /* so detect will get called */
972 int w83627hf_detect(struct i2c_adapter *adapter, int address,
976 struct i2c_client *new_client;
977 struct w83627hf_data *data;
979 const char *client_name = "";
981 if (!i2c_is_isa_adapter(adapter)) {
987 address = force_addr & ~(WINB_EXTENT - 1);
989 if (!request_region(address, WINB_EXTENT, "w83627hf")) {
995 printk("w83627hf.o: forcing ISA address 0x%04X\n", address);
997 superio_select(W83627HF_LD_HWM);
998 superio_outb(WINB_BASE_REG, address >> 8);
999 superio_outb(WINB_BASE_REG+1, address & 0xff);
1004 val= superio_inb(DEVID);
1005 if(val == W627_DEVID)
1007 else if(val == W697_DEVID)
1009 else if(val == W627THF_DEVID)
1011 else if(val == W637_DEVID)
1014 dev_info(&adapter->dev,
1015 "Unsupported chip (dev_id=0x%02X).\n", val);
1019 superio_select(W83627HF_LD_HWM);
1020 if((val = 0x01 & superio_inb(WINB_ACT_REG)) == 0)
1021 superio_outb(WINB_ACT_REG, 1);
1024 /* OK. For now, we presume we have a valid client. We now create the
1025 client structure, even though we cannot fill it completely yet.
1026 But it allows us to access w83627hf_{read,write}_value. */
1028 if (!(data = kmalloc(sizeof(struct w83627hf_data), GFP_KERNEL))) {
1032 memset(data, 0, sizeof(struct w83627hf_data));
1034 new_client = &data->client;
1035 i2c_set_clientdata(new_client, data);
1036 new_client->addr = address;
1037 init_MUTEX(&data->lock);
1038 new_client->adapter = adapter;
1039 new_client->driver = &w83627hf_driver;
1040 new_client->flags = 0;
1043 if (kind == w83627hf) {
1044 client_name = "w83627hf";
1045 } else if (kind == w83627thf) {
1046 client_name = "w83627thf";
1047 } else if (kind == w83697hf) {
1048 client_name = "w83697hf";
1049 } else if (kind == w83637hf) {
1050 client_name = "w83637hf";
1053 /* Fill in the remaining client fields and put into the global list */
1054 strlcpy(new_client->name, client_name, I2C_NAME_SIZE);
1057 init_MUTEX(&data->update_lock);
1059 /* Tell the I2C layer a new client has arrived */
1060 if ((err = i2c_attach_client(new_client)))
1065 /* Initialize the chip */
1066 w83627hf_init_client(new_client);
1068 /* A few vars need to be filled upon startup */
1069 data->fan_min[0] = w83627hf_read_value(new_client, W83781D_REG_FAN_MIN(1));
1070 data->fan_min[1] = w83627hf_read_value(new_client, W83781D_REG_FAN_MIN(2));
1071 data->fan_min[2] = w83627hf_read_value(new_client, W83781D_REG_FAN_MIN(3));
1073 /* Register sysfs hooks */
1074 device_create_file_in(new_client, 0);
1075 if (kind != w83697hf)
1076 device_create_file_in(new_client, 1);
1077 device_create_file_in(new_client, 2);
1078 device_create_file_in(new_client, 3);
1079 device_create_file_in(new_client, 4);
1080 if (kind != w83627thf && kind != w83637hf) {
1081 device_create_file_in(new_client, 5);
1082 device_create_file_in(new_client, 6);
1084 device_create_file_in(new_client, 7);
1085 device_create_file_in(new_client, 8);
1087 device_create_file_fan(new_client, 1);
1088 device_create_file_fan(new_client, 2);
1089 if (kind != w83697hf)
1090 device_create_file_fan(new_client, 3);
1092 device_create_file_temp(new_client, 1);
1093 device_create_file_temp(new_client, 2);
1094 if (kind != w83697hf)
1095 device_create_file_temp(new_client, 3);
1097 if (kind != w83697hf)
1098 device_create_file_vid(new_client);
1100 if (kind != w83697hf)
1101 device_create_file_vrm(new_client);
1103 device_create_file_fan_div(new_client, 1);
1104 device_create_file_fan_div(new_client, 2);
1105 if (kind != w83697hf)
1106 device_create_file_fan_div(new_client, 3);
1108 device_create_file_alarms(new_client);
1110 device_create_file_beep(new_client);
1112 device_create_file_pwm(new_client, 1);
1113 device_create_file_pwm(new_client, 2);
1114 if (kind == w83627thf || kind == w83637hf)
1115 device_create_file_pwm(new_client, 3);
1117 device_create_file_sensor(new_client, 1);
1118 device_create_file_sensor(new_client, 2);
1119 if (kind != w83697hf)
1120 device_create_file_sensor(new_client, 3);
1127 release_region(address, WINB_EXTENT);
1132 static int w83627hf_detach_client(struct i2c_client *client)
1136 if ((err = i2c_detach_client(client))) {
1137 dev_err(&client->dev,
1138 "Client deregistration failed, client not detached.\n");
1142 release_region(client->addr, WINB_EXTENT);
1143 kfree(i2c_get_clientdata(client));
1150 ISA access must always be locked explicitly!
1151 We ignore the W83781D BUSY flag at this moment - it could lead to deadlocks,
1152 would slow down the W83781D access and should not be necessary.
1153 There are some ugly typecasts here, but the good news is - they should
1154 nowhere else be necessary! */
1155 static int w83627hf_read_value(struct i2c_client *client, u16 reg)
1157 struct w83627hf_data *data = i2c_get_clientdata(client);
1158 int res, word_sized;
1161 word_sized = (((reg & 0xff00) == 0x100)
1162 || ((reg & 0xff00) == 0x200))
1163 && (((reg & 0x00ff) == 0x50)
1164 || ((reg & 0x00ff) == 0x53)
1165 || ((reg & 0x00ff) == 0x55));
1167 outb_p(W83781D_REG_BANK,
1168 client->addr + W83781D_ADDR_REG_OFFSET);
1170 client->addr + W83781D_DATA_REG_OFFSET);
1172 outb_p(reg & 0xff, client->addr + W83781D_ADDR_REG_OFFSET);
1173 res = inb_p(client->addr + W83781D_DATA_REG_OFFSET);
1175 outb_p((reg & 0xff) + 1,
1176 client->addr + W83781D_ADDR_REG_OFFSET);
1178 (res << 8) + inb_p(client->addr +
1179 W83781D_DATA_REG_OFFSET);
1182 outb_p(W83781D_REG_BANK,
1183 client->addr + W83781D_ADDR_REG_OFFSET);
1184 outb_p(0, client->addr + W83781D_DATA_REG_OFFSET);
1190 static int w83627thf_read_gpio5(struct i2c_client *client)
1192 struct w83627hf_data *data = i2c_get_clientdata(client);
1197 superio_select(W83627HF_LD_GPIO5);
1198 res = superio_inb(W83627THF_GPIO5_DR);
1199 inv = superio_inb(W83627THF_GPIO5_INVR);
1205 static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value)
1207 struct w83627hf_data *data = i2c_get_clientdata(client);
1211 word_sized = (((reg & 0xff00) == 0x100)
1212 || ((reg & 0xff00) == 0x200))
1213 && (((reg & 0x00ff) == 0x53)
1214 || ((reg & 0x00ff) == 0x55));
1216 outb_p(W83781D_REG_BANK,
1217 client->addr + W83781D_ADDR_REG_OFFSET);
1219 client->addr + W83781D_DATA_REG_OFFSET);
1221 outb_p(reg & 0xff, client->addr + W83781D_ADDR_REG_OFFSET);
1224 client->addr + W83781D_DATA_REG_OFFSET);
1225 outb_p((reg & 0xff) + 1,
1226 client->addr + W83781D_ADDR_REG_OFFSET);
1228 outb_p(value & 0xff,
1229 client->addr + W83781D_DATA_REG_OFFSET);
1231 outb_p(W83781D_REG_BANK,
1232 client->addr + W83781D_ADDR_REG_OFFSET);
1233 outb_p(0, client->addr + W83781D_DATA_REG_OFFSET);
1239 /* Called when we have found a new W83781D. It should set limits, etc. */
1240 static void w83627hf_init_client(struct i2c_client *client)
1242 struct w83627hf_data *data = i2c_get_clientdata(client);
1244 int type = data->type;
1248 /* save this register */
1249 i = w83627hf_read_value(client, W83781D_REG_BEEP_CONFIG);
1250 /* Reset all except Watchdog values and last conversion values
1251 This sets fan-divs to 2, among others */
1252 w83627hf_write_value(client, W83781D_REG_CONFIG, 0x80);
1253 /* Restore the register and disable power-on abnormal beep.
1254 This saves FAN 1/2/3 input/output values set by BIOS. */
1255 w83627hf_write_value(client, W83781D_REG_BEEP_CONFIG, i | 0x80);
1256 /* Disable master beep-enable (reset turns it on).
1257 Individual beeps should be reset to off but for some reason
1258 disabling this bit helps some people not get beeped */
1259 w83627hf_write_value(client, W83781D_REG_BEEP_INTS2, 0);
1262 /* Minimize conflicts with other winbond i2c-only clients... */
1263 /* disable i2c subclients... how to disable main i2c client?? */
1264 /* force i2c address to relatively uncommon address */
1265 w83627hf_write_value(client, W83781D_REG_I2C_SUBADDR, 0x89);
1266 w83627hf_write_value(client, W83781D_REG_I2C_ADDR, force_i2c);
1268 /* Read VID only once */
1269 if (w83627hf == data->type || w83637hf == data->type) {
1270 int lo = w83627hf_read_value(client, W83781D_REG_VID_FANDIV);
1271 int hi = w83627hf_read_value(client, W83781D_REG_CHIPID);
1272 data->vid = (lo & 0x0f) | ((hi & 0x01) << 4);
1273 } else if (w83627thf == data->type) {
1274 data->vid = w83627thf_read_gpio5(client) & 0x1f;
1277 /* Read VRM & OVT Config only once */
1278 if (w83627thf == data->type || w83637hf == data->type) {
1280 w83627hf_read_value(client, W83627THF_REG_VRM_OVT_CFG);
1281 data->vrm = (data->vrm_ovt & 0x01) ? 90 : 82;
1283 /* Convert VID to voltage based on default VRM */
1284 data->vrm = DEFAULT_VRM;
1287 tmp = w83627hf_read_value(client, W83781D_REG_SCFG1);
1288 for (i = 1; i <= 3; i++) {
1289 if (!(tmp & BIT_SCFG1[i - 1])) {
1290 data->sens[i - 1] = W83781D_DEFAULT_BETA;
1292 if (w83627hf_read_value
1294 W83781D_REG_SCFG2) & BIT_SCFG2[i - 1])
1295 data->sens[i - 1] = 1;
1297 data->sens[i - 1] = 2;
1299 if ((type == w83697hf) && (i == 2))
1303 data->pwmenable[0] = 1;
1304 data->pwmenable[1] = 1;
1305 data->pwmenable[2] = 1;
1308 if (type == w83627hf) {
1309 /* enable PWM2 control (can't hurt since PWM reg
1310 should have been reset to 0xff) */
1311 w83627hf_write_value(client, W83627HF_REG_PWMCLK12,
1314 /* enable comparator mode for temp2 and temp3 so
1315 alarm indication will work correctly */
1316 i = w83627hf_read_value(client, W83781D_REG_IRQ);
1318 w83627hf_write_value(client, W83781D_REG_IRQ,
1322 /* Start monitoring */
1323 w83627hf_write_value(client, W83781D_REG_CONFIG,
1324 (w83627hf_read_value(client,
1325 W83781D_REG_CONFIG) & 0xf7)
1329 static struct w83627hf_data *w83627hf_update_device(struct device *dev)
1331 struct i2c_client *client = to_i2c_client(dev);
1332 struct w83627hf_data *data = i2c_get_clientdata(client);
1335 down(&data->update_lock);
1337 if ((jiffies - data->last_updated > HZ + HZ / 2) ||
1338 (jiffies < data->last_updated) || !data->valid) {
1339 for (i = 0; i <= 8; i++) {
1340 /* skip missing sensors */
1341 if (((data->type == w83697hf) && (i == 1)) ||
1342 ((data->type == w83627thf || data->type == w83637hf)
1343 && (i == 4 || i == 5)))
1346 w83627hf_read_value(client, W83781D_REG_IN(i));
1348 w83627hf_read_value(client,
1349 W83781D_REG_IN_MIN(i));
1351 w83627hf_read_value(client,
1352 W83781D_REG_IN_MAX(i));
1354 for (i = 1; i <= 3; i++) {
1356 w83627hf_read_value(client, W83781D_REG_FAN(i));
1357 data->fan_min[i - 1] =
1358 w83627hf_read_value(client,
1359 W83781D_REG_FAN_MIN(i));
1361 for (i = 1; i <= 3; i++) {
1362 u8 tmp = w83627hf_read_value(client,
1363 W836X7HF_REG_PWM(data->type, i));
1364 /* bits 0-3 are reserved in 627THF */
1365 if (data->type == w83627thf)
1367 data->pwm[i - 1] = tmp;
1369 (data->type == w83627hf || data->type == w83697hf))
1373 data->temp = w83627hf_read_value(client, W83781D_REG_TEMP(1));
1375 w83627hf_read_value(client, W83781D_REG_TEMP_OVER(1));
1376 data->temp_max_hyst =
1377 w83627hf_read_value(client, W83781D_REG_TEMP_HYST(1));
1379 w83627hf_read_value(client, W83781D_REG_TEMP(2));
1380 data->temp_max_add[0] =
1381 w83627hf_read_value(client, W83781D_REG_TEMP_OVER(2));
1382 data->temp_max_hyst_add[0] =
1383 w83627hf_read_value(client, W83781D_REG_TEMP_HYST(2));
1384 if (data->type != w83697hf) {
1386 w83627hf_read_value(client, W83781D_REG_TEMP(3));
1387 data->temp_max_add[1] =
1388 w83627hf_read_value(client, W83781D_REG_TEMP_OVER(3));
1389 data->temp_max_hyst_add[1] =
1390 w83627hf_read_value(client, W83781D_REG_TEMP_HYST(3));
1393 i = w83627hf_read_value(client, W83781D_REG_VID_FANDIV);
1394 data->fan_div[0] = (i >> 4) & 0x03;
1395 data->fan_div[1] = (i >> 6) & 0x03;
1396 if (data->type != w83697hf) {
1397 data->fan_div[2] = (w83627hf_read_value(client,
1398 W83781D_REG_PIN) >> 6) & 0x03;
1400 i = w83627hf_read_value(client, W83781D_REG_VBAT);
1401 data->fan_div[0] |= (i >> 3) & 0x04;
1402 data->fan_div[1] |= (i >> 4) & 0x04;
1403 if (data->type != w83697hf)
1404 data->fan_div[2] |= (i >> 5) & 0x04;
1406 w83627hf_read_value(client, W83781D_REG_ALARM1) |
1407 (w83627hf_read_value(client, W83781D_REG_ALARM2) << 8) |
1408 (w83627hf_read_value(client, W83781D_REG_ALARM3) << 16);
1409 i = w83627hf_read_value(client, W83781D_REG_BEEP_INTS2);
1410 data->beep_enable = i >> 7;
1411 data->beep_mask = ((i & 0x7f) << 8) |
1412 w83627hf_read_value(client, W83781D_REG_BEEP_INTS1) |
1413 w83627hf_read_value(client, W83781D_REG_BEEP_INTS3) << 16;
1414 data->last_updated = jiffies;
1418 up(&data->update_lock);
1423 static int __init sensors_w83627hf_init(void)
1427 if (w83627hf_find(&addr)) {
1430 normal_isa[0] = addr;
1432 return i2c_add_driver(&w83627hf_driver);
1435 static void __exit sensors_w83627hf_exit(void)
1437 i2c_del_driver(&w83627hf_driver);
1440 MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>, "
1441 "Philip Edelbrock <phil@netroedge.com>, "
1442 "and Mark Studebaker <mdsxyz123@yahoo.com>");
1443 MODULE_DESCRIPTION("W83627HF driver");
1444 MODULE_LICENSE("GPL");
1446 module_init(sensors_w83627hf_init);
1447 module_exit(sensors_w83627hf_exit);