2 gl520sm.c - Part of lm_sensors, Linux kernel modules for hardware
4 Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>,
5 Kyösti Mälkki <kmalkki@cc.hut.fi>
6 Copyright (c) 2005 Maarten Deprez <maartendeprez@users.sourceforge.net>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <linux/module.h>
25 #include <linux/init.h>
26 #include <linux/slab.h>
27 #include <linux/jiffies.h>
28 #include <linux/i2c.h>
29 #include <linux/hwmon.h>
30 #include <linux/hwmon-vid.h>
31 #include <linux/err.h>
32 #include <linux/mutex.h>
33 #include <linux/sysfs.h>
35 /* Type of the extra sensor */
36 static unsigned short extra_sensor_type;
37 module_param(extra_sensor_type, ushort, 0);
38 MODULE_PARM_DESC(extra_sensor_type, "Type of extra sensor (0=autodetect, 1=temperature, 2=voltage)");
40 /* Addresses to scan */
41 static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END };
43 /* Insmod parameters */
44 I2C_CLIENT_INSMOD_1(gl520sm);
46 /* Many GL520 constants specified below
47 One of the inputs can be configured as either temp or voltage.
48 That's why _TEMP2 and _IN4 access the same register
51 /* The GL520 registers */
52 #define GL520_REG_CHIP_ID 0x00
53 #define GL520_REG_REVISION 0x01
54 #define GL520_REG_CONF 0x03
55 #define GL520_REG_MASK 0x11
57 #define GL520_REG_VID_INPUT 0x02
59 static const u8 GL520_REG_IN_INPUT[] = { 0x15, 0x14, 0x13, 0x0d, 0x0e };
60 static const u8 GL520_REG_IN_LIMIT[] = { 0x0c, 0x09, 0x0a, 0x0b };
61 static const u8 GL520_REG_IN_MIN[] = { 0x0c, 0x09, 0x0a, 0x0b, 0x18 };
62 static const u8 GL520_REG_IN_MAX[] = { 0x0c, 0x09, 0x0a, 0x0b, 0x17 };
64 static const u8 GL520_REG_TEMP_INPUT[] = { 0x04, 0x0e };
65 static const u8 GL520_REG_TEMP_MAX[] = { 0x05, 0x17 };
66 static const u8 GL520_REG_TEMP_MAX_HYST[] = { 0x06, 0x18 };
68 #define GL520_REG_FAN_INPUT 0x07
69 #define GL520_REG_FAN_MIN 0x08
70 #define GL520_REG_FAN_DIV 0x0f
71 #define GL520_REG_FAN_OFF GL520_REG_FAN_DIV
73 #define GL520_REG_ALARMS 0x12
74 #define GL520_REG_BEEP_MASK 0x10
75 #define GL520_REG_BEEP_ENABLE GL520_REG_CONF
78 * Function declarations
81 static int gl520_attach_adapter(struct i2c_adapter *adapter);
82 static int gl520_detect(struct i2c_adapter *adapter, int address, int kind);
83 static void gl520_init_client(struct i2c_client *client);
84 static int gl520_detach_client(struct i2c_client *client);
85 static int gl520_read_value(struct i2c_client *client, u8 reg);
86 static int gl520_write_value(struct i2c_client *client, u8 reg, u16 value);
87 static struct gl520_data *gl520_update_device(struct device *dev);
90 static struct i2c_driver gl520_driver = {
94 .attach_adapter = gl520_attach_adapter,
95 .detach_client = gl520_detach_client,
100 struct i2c_client client;
101 struct device *hwmon_dev;
102 struct mutex update_lock;
103 char valid; /* zero until the following fields are valid */
104 unsigned long last_updated; /* in jiffies */
108 u8 in_input[5]; /* [0] = VVD */
109 u8 in_min[5]; /* [0] = VDD */
110 u8 in_max[5]; /* [0] = VDD */
129 #define sysfs_r(type, n, item, reg) \
130 static ssize_t get_##type##item (struct gl520_data *, char *, int); \
131 static ssize_t get_##type##n##item (struct device *, struct device_attribute *attr, char *); \
132 static ssize_t get_##type##n##item (struct device *dev, struct device_attribute *attr, char *buf) \
134 struct gl520_data *data = gl520_update_device(dev); \
135 return get_##type##item(data, buf, (n)); \
138 #define sysfs_w(type, n, item, reg) \
139 static ssize_t set_##type##item (struct i2c_client *, struct gl520_data *, const char *, size_t, int, int); \
140 static ssize_t set_##type##n##item (struct device *, struct device_attribute *attr, const char *, size_t); \
141 static ssize_t set_##type##n##item (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \
143 struct i2c_client *client = to_i2c_client(dev); \
144 struct gl520_data *data = i2c_get_clientdata(client); \
145 return set_##type##item(client, data, buf, count, (n), reg); \
148 #define sysfs_rw_n(type, n, item, reg) \
149 sysfs_r(type, n, item, reg) \
150 sysfs_w(type, n, item, reg) \
151 static DEVICE_ATTR(type##n##item, S_IRUGO | S_IWUSR, get_##type##n##item, set_##type##n##item);
153 #define sysfs_ro_n(type, n, item, reg) \
154 sysfs_r(type, n, item, reg) \
155 static DEVICE_ATTR(type##n##item, S_IRUGO, get_##type##n##item, NULL);
157 #define sysfs_rw(type, item, reg) \
158 sysfs_r(type, 0, item, reg) \
159 sysfs_w(type, 0, item, reg) \
160 static DEVICE_ATTR(type##item, S_IRUGO | S_IWUSR, get_##type##0##item, set_##type##0##item);
162 #define sysfs_ro(type, item, reg) \
163 sysfs_r(type, 0, item, reg) \
164 static DEVICE_ATTR(type##item, S_IRUGO, get_##type##0##item, NULL);
167 #define sysfs_vid(n) \
168 sysfs_ro_n(cpu, n, _vid, GL520_REG_VID_INPUT)
170 #define sysfs_in(n) \
171 sysfs_ro_n(in, n, _input, GL520_REG_IN_INPUT[n]) \
172 sysfs_rw_n(in, n, _min, GL520_REG_IN_MIN[n]) \
173 sysfs_rw_n(in, n, _max, GL520_REG_IN_MAX[n])
175 #define sysfs_fan(n) \
176 sysfs_ro_n(fan, n, _input, GL520_REG_FAN_INPUT) \
177 sysfs_rw_n(fan, n, _min, GL520_REG_FAN_MIN) \
178 sysfs_rw_n(fan, n, _div, GL520_REG_FAN_DIV)
180 #define sysfs_fan_off(n) \
181 sysfs_rw_n(fan, n, _off, GL520_REG_FAN_OFF)
183 #define sysfs_temp(n) \
184 sysfs_ro_n(temp, n, _input, GL520_REG_TEMP_INPUT[(n) - 1]) \
185 sysfs_rw_n(temp, n, _max, GL520_REG_TEMP_MAX[(n) - 1]) \
186 sysfs_rw_n(temp, n, _max_hyst, GL520_REG_TEMP_MAX_HYST[(n) - 1])
188 #define sysfs_alarms() \
189 sysfs_ro(alarms, , GL520_REG_ALARMS) \
190 sysfs_rw(beep_enable, , GL520_REG_BEEP_ENABLE) \
191 sysfs_rw(beep_mask, , GL520_REG_BEEP_MASK)
212 static ssize_t get_cpu_vid(struct gl520_data *data, char *buf, int n)
214 return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm));
217 #define VDD_FROM_REG(val) (((val)*95+2)/4)
218 #define VDD_TO_REG(val) (SENSORS_LIMIT((((val)*4+47)/95),0,255))
220 #define IN_FROM_REG(val) ((val)*19)
221 #define IN_TO_REG(val) (SENSORS_LIMIT((((val)+9)/19),0,255))
223 static ssize_t get_in_input(struct gl520_data *data, char *buf, int n)
225 u8 r = data->in_input[n];
228 return sprintf(buf, "%d\n", VDD_FROM_REG(r));
230 return sprintf(buf, "%d\n", IN_FROM_REG(r));
233 static ssize_t get_in_min(struct gl520_data *data, char *buf, int n)
235 u8 r = data->in_min[n];
238 return sprintf(buf, "%d\n", VDD_FROM_REG(r));
240 return sprintf(buf, "%d\n", IN_FROM_REG(r));
243 static ssize_t get_in_max(struct gl520_data *data, char *buf, int n)
245 u8 r = data->in_max[n];
248 return sprintf(buf, "%d\n", VDD_FROM_REG(r));
250 return sprintf(buf, "%d\n", IN_FROM_REG(r));
253 static ssize_t set_in_min(struct i2c_client *client, struct gl520_data *data, const char *buf, size_t count, int n, int reg)
255 long v = simple_strtol(buf, NULL, 10);
258 mutex_lock(&data->update_lock);
268 gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0xff) | r);
270 gl520_write_value(client, reg, r);
272 mutex_unlock(&data->update_lock);
276 static ssize_t set_in_max(struct i2c_client *client, struct gl520_data *data, const char *buf, size_t count, int n, int reg)
278 long v = simple_strtol(buf, NULL, 10);
286 mutex_lock(&data->update_lock);
291 gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0xff00) | (r << 8));
293 gl520_write_value(client, reg, r);
295 mutex_unlock(&data->update_lock);
299 #define DIV_FROM_REG(val) (1 << (val))
300 #define FAN_FROM_REG(val,div) ((val)==0 ? 0 : (480000/((val) << (div))))
301 #define FAN_TO_REG(val,div) ((val)<=0?0:SENSORS_LIMIT((480000 + ((val) << ((div)-1))) / ((val) << (div)), 1, 255));
303 static ssize_t get_fan_input(struct gl520_data *data, char *buf, int n)
305 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_input[n - 1], data->fan_div[n - 1]));
308 static ssize_t get_fan_min(struct gl520_data *data, char *buf, int n)
310 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[n - 1], data->fan_div[n - 1]));
313 static ssize_t get_fan_div(struct gl520_data *data, char *buf, int n)
315 return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[n - 1]));
318 static ssize_t get_fan_off(struct gl520_data *data, char *buf, int n)
320 return sprintf(buf, "%d\n", data->fan_off);
323 static ssize_t set_fan_min(struct i2c_client *client, struct gl520_data *data, const char *buf, size_t count, int n, int reg)
325 unsigned long v = simple_strtoul(buf, NULL, 10);
328 mutex_lock(&data->update_lock);
329 r = FAN_TO_REG(v, data->fan_div[n - 1]);
330 data->fan_min[n - 1] = r;
333 gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0xff00) | (r << 8));
335 gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0xff) | r);
337 data->beep_mask = gl520_read_value(client, GL520_REG_BEEP_MASK);
338 if (data->fan_min[n - 1] == 0)
339 data->alarm_mask &= (n == 1) ? ~0x20 : ~0x40;
341 data->alarm_mask |= (n == 1) ? 0x20 : 0x40;
342 data->beep_mask &= data->alarm_mask;
343 gl520_write_value(client, GL520_REG_BEEP_MASK, data->beep_mask);
345 mutex_unlock(&data->update_lock);
349 static ssize_t set_fan_div(struct i2c_client *client, struct gl520_data *data, const char *buf, size_t count, int n, int reg)
351 unsigned long v = simple_strtoul(buf, NULL, 10);
355 case 1: r = 0; break;
356 case 2: r = 1; break;
357 case 4: r = 2; break;
358 case 8: r = 3; break;
360 dev_err(&client->dev, "fan_div value %ld not supported. Choose one of 1, 2, 4 or 8!\n", v);
364 mutex_lock(&data->update_lock);
365 data->fan_div[n - 1] = r;
368 gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0xc0) | (r << 6));
370 gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x30) | (r << 4));
372 mutex_unlock(&data->update_lock);
376 static ssize_t set_fan_off(struct i2c_client *client, struct gl520_data *data, const char *buf, size_t count, int n, int reg)
378 u8 r = simple_strtoul(buf, NULL, 10)?1:0;
380 mutex_lock(&data->update_lock);
382 gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x0c) | (r << 2));
383 mutex_unlock(&data->update_lock);
387 #define TEMP_FROM_REG(val) (((val) - 130) * 1000)
388 #define TEMP_TO_REG(val) (SENSORS_LIMIT(((((val)<0?(val)-500:(val)+500) / 1000)+130),0,255))
390 static ssize_t get_temp_input(struct gl520_data *data, char *buf, int n)
392 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_input[n - 1]));
395 static ssize_t get_temp_max(struct gl520_data *data, char *buf, int n)
397 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[n - 1]));
400 static ssize_t get_temp_max_hyst(struct gl520_data *data, char *buf, int n)
402 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max_hyst[n - 1]));
405 static ssize_t set_temp_max(struct i2c_client *client, struct gl520_data *data, const char *buf, size_t count, int n, int reg)
407 long v = simple_strtol(buf, NULL, 10);
409 mutex_lock(&data->update_lock);
410 data->temp_max[n - 1] = TEMP_TO_REG(v);
411 gl520_write_value(client, reg, data->temp_max[n - 1]);
412 mutex_unlock(&data->update_lock);
416 static ssize_t set_temp_max_hyst(struct i2c_client *client, struct gl520_data *data, const char *buf, size_t count, int n, int reg)
418 long v = simple_strtol(buf, NULL, 10);
420 mutex_lock(&data->update_lock);
421 data->temp_max_hyst[n - 1] = TEMP_TO_REG(v);
422 gl520_write_value(client, reg, data->temp_max_hyst[n - 1]);
423 mutex_unlock(&data->update_lock);
427 static ssize_t get_alarms(struct gl520_data *data, char *buf, int n)
429 return sprintf(buf, "%d\n", data->alarms);
432 static ssize_t get_beep_enable(struct gl520_data *data, char *buf, int n)
434 return sprintf(buf, "%d\n", data->beep_enable);
437 static ssize_t get_beep_mask(struct gl520_data *data, char *buf, int n)
439 return sprintf(buf, "%d\n", data->beep_mask);
442 static ssize_t set_beep_enable(struct i2c_client *client, struct gl520_data *data, const char *buf, size_t count, int n, int reg)
444 u8 r = simple_strtoul(buf, NULL, 10)?0:1;
446 mutex_lock(&data->update_lock);
447 data->beep_enable = !r;
448 gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x04) | (r << 2));
449 mutex_unlock(&data->update_lock);
453 static ssize_t set_beep_mask(struct i2c_client *client, struct gl520_data *data, const char *buf, size_t count, int n, int reg)
455 u8 r = simple_strtoul(buf, NULL, 10);
457 mutex_lock(&data->update_lock);
458 r &= data->alarm_mask;
460 gl520_write_value(client, reg, r);
461 mutex_unlock(&data->update_lock);
465 static struct attribute *gl520_attributes[] = {
466 &dev_attr_cpu0_vid.attr,
468 &dev_attr_in0_input.attr,
469 &dev_attr_in0_min.attr,
470 &dev_attr_in0_max.attr,
471 &dev_attr_in1_input.attr,
472 &dev_attr_in1_min.attr,
473 &dev_attr_in1_max.attr,
474 &dev_attr_in2_input.attr,
475 &dev_attr_in2_min.attr,
476 &dev_attr_in2_max.attr,
477 &dev_attr_in3_input.attr,
478 &dev_attr_in3_min.attr,
479 &dev_attr_in3_max.attr,
481 &dev_attr_fan1_input.attr,
482 &dev_attr_fan1_min.attr,
483 &dev_attr_fan1_div.attr,
484 &dev_attr_fan1_off.attr,
485 &dev_attr_fan2_input.attr,
486 &dev_attr_fan2_min.attr,
487 &dev_attr_fan2_div.attr,
489 &dev_attr_temp1_input.attr,
490 &dev_attr_temp1_max.attr,
491 &dev_attr_temp1_max_hyst.attr,
493 &dev_attr_alarms.attr,
494 &dev_attr_beep_enable.attr,
495 &dev_attr_beep_mask.attr,
499 static const struct attribute_group gl520_group = {
500 .attrs = gl520_attributes,
503 static struct attribute *gl520_attributes_opt[] = {
504 &dev_attr_in4_input.attr,
505 &dev_attr_in4_min.attr,
506 &dev_attr_in4_max.attr,
508 &dev_attr_temp2_input.attr,
509 &dev_attr_temp2_max.attr,
510 &dev_attr_temp2_max_hyst.attr,
514 static const struct attribute_group gl520_group_opt = {
515 .attrs = gl520_attributes_opt,
523 static int gl520_attach_adapter(struct i2c_adapter *adapter)
525 if (!(adapter->class & I2C_CLASS_HWMON))
527 return i2c_probe(adapter, &addr_data, gl520_detect);
530 static int gl520_detect(struct i2c_adapter *adapter, int address, int kind)
532 struct i2c_client *client;
533 struct gl520_data *data;
536 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
537 I2C_FUNC_SMBUS_WORD_DATA))
540 /* OK. For now, we presume we have a valid client. We now create the
541 client structure, even though we cannot fill it completely yet.
542 But it allows us to access gl520_{read,write}_value. */
544 if (!(data = kzalloc(sizeof(struct gl520_data), GFP_KERNEL))) {
549 client = &data->client;
550 i2c_set_clientdata(client, data);
551 client->addr = address;
552 client->adapter = adapter;
553 client->driver = &gl520_driver;
555 /* Determine the chip type. */
557 if ((gl520_read_value(client, GL520_REG_CHIP_ID) != 0x20) ||
558 ((gl520_read_value(client, GL520_REG_REVISION) & 0x7f) != 0x00) ||
559 ((gl520_read_value(client, GL520_REG_CONF) & 0x80) != 0x00)) {
560 dev_dbg(&client->dev, "Unknown chip type, skipping\n");
565 /* Fill in the remaining client fields */
566 strlcpy(client->name, "gl520sm", I2C_NAME_SIZE);
567 mutex_init(&data->update_lock);
569 /* Tell the I2C layer a new client has arrived */
570 if ((err = i2c_attach_client(client)))
573 /* Initialize the GL520SM chip */
574 gl520_init_client(client);
576 /* Register sysfs hooks */
577 if ((err = sysfs_create_group(&client->dev.kobj, &gl520_group)))
580 if (data->two_temps) {
581 if ((err = device_create_file(&client->dev,
582 &dev_attr_temp2_input))
583 || (err = device_create_file(&client->dev,
584 &dev_attr_temp2_max))
585 || (err = device_create_file(&client->dev,
586 &dev_attr_temp2_max_hyst)))
587 goto exit_remove_files;
589 if ((err = device_create_file(&client->dev,
590 &dev_attr_in4_input))
591 || (err = device_create_file(&client->dev,
593 || (err = device_create_file(&client->dev,
595 goto exit_remove_files;
599 data->hwmon_dev = hwmon_device_register(&client->dev);
600 if (IS_ERR(data->hwmon_dev)) {
601 err = PTR_ERR(data->hwmon_dev);
602 goto exit_remove_files;
608 sysfs_remove_group(&client->dev.kobj, &gl520_group);
609 sysfs_remove_group(&client->dev.kobj, &gl520_group_opt);
611 i2c_detach_client(client);
619 /* Called when we have found a new GL520SM. */
620 static void gl520_init_client(struct i2c_client *client)
622 struct gl520_data *data = i2c_get_clientdata(client);
625 conf = oldconf = gl520_read_value(client, GL520_REG_CONF);
627 data->alarm_mask = 0xff;
628 data->vrm = vid_which_vrm();
630 if (extra_sensor_type == 1)
632 else if (extra_sensor_type == 2)
634 data->two_temps = !(conf & 0x10);
636 /* If IRQ# is disabled, we can safely force comparator mode */
640 /* Enable monitoring if needed */
644 gl520_write_value(client, GL520_REG_CONF, conf);
646 gl520_update_device(&(client->dev));
648 if (data->fan_min[0] == 0)
649 data->alarm_mask &= ~0x20;
650 if (data->fan_min[1] == 0)
651 data->alarm_mask &= ~0x40;
653 data->beep_mask &= data->alarm_mask;
654 gl520_write_value(client, GL520_REG_BEEP_MASK, data->beep_mask);
657 static int gl520_detach_client(struct i2c_client *client)
659 struct gl520_data *data = i2c_get_clientdata(client);
662 hwmon_device_unregister(data->hwmon_dev);
663 sysfs_remove_group(&client->dev.kobj, &gl520_group);
664 sysfs_remove_group(&client->dev.kobj, &gl520_group_opt);
666 if ((err = i2c_detach_client(client)))
674 /* Registers 0x07 to 0x0c are word-sized, others are byte-sized
675 GL520 uses a high-byte first convention */
676 static int gl520_read_value(struct i2c_client *client, u8 reg)
678 if ((reg >= 0x07) && (reg <= 0x0c))
679 return swab16(i2c_smbus_read_word_data(client, reg));
681 return i2c_smbus_read_byte_data(client, reg);
684 static int gl520_write_value(struct i2c_client *client, u8 reg, u16 value)
686 if ((reg >= 0x07) && (reg <= 0x0c))
687 return i2c_smbus_write_word_data(client, reg, swab16(value));
689 return i2c_smbus_write_byte_data(client, reg, value);
693 static struct gl520_data *gl520_update_device(struct device *dev)
695 struct i2c_client *client = to_i2c_client(dev);
696 struct gl520_data *data = i2c_get_clientdata(client);
699 mutex_lock(&data->update_lock);
701 if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) {
703 dev_dbg(&client->dev, "Starting gl520sm update\n");
705 data->alarms = gl520_read_value(client, GL520_REG_ALARMS);
706 data->beep_mask = gl520_read_value(client, GL520_REG_BEEP_MASK);
707 data->vid = gl520_read_value(client, GL520_REG_VID_INPUT) & 0x1f;
709 for (i = 0; i < 4; i++) {
710 data->in_input[i] = gl520_read_value(client,
711 GL520_REG_IN_INPUT[i]);
712 val = gl520_read_value(client, GL520_REG_IN_LIMIT[i]);
713 data->in_min[i] = val & 0xff;
714 data->in_max[i] = (val >> 8) & 0xff;
717 val = gl520_read_value(client, GL520_REG_FAN_INPUT);
718 data->fan_input[0] = (val >> 8) & 0xff;
719 data->fan_input[1] = val & 0xff;
721 val = gl520_read_value(client, GL520_REG_FAN_MIN);
722 data->fan_min[0] = (val >> 8) & 0xff;
723 data->fan_min[1] = val & 0xff;
725 data->temp_input[0] = gl520_read_value(client,
726 GL520_REG_TEMP_INPUT[0]);
727 data->temp_max[0] = gl520_read_value(client,
728 GL520_REG_TEMP_MAX[0]);
729 data->temp_max_hyst[0] = gl520_read_value(client,
730 GL520_REG_TEMP_MAX_HYST[0]);
732 val = gl520_read_value(client, GL520_REG_FAN_DIV);
733 data->fan_div[0] = (val >> 6) & 0x03;
734 data->fan_div[1] = (val >> 4) & 0x03;
735 data->fan_off = (val >> 2) & 0x01;
737 data->alarms &= data->alarm_mask;
739 val = gl520_read_value(client, GL520_REG_CONF);
740 data->beep_enable = !((val >> 2) & 1);
742 /* Temp1 and Vin4 are the same input */
743 if (data->two_temps) {
744 data->temp_input[1] = gl520_read_value(client,
745 GL520_REG_TEMP_INPUT[1]);
746 data->temp_max[1] = gl520_read_value(client,
747 GL520_REG_TEMP_MAX[1]);
748 data->temp_max_hyst[1] = gl520_read_value(client,
749 GL520_REG_TEMP_MAX_HYST[1]);
751 data->in_input[4] = gl520_read_value(client,
752 GL520_REG_IN_INPUT[4]);
753 data->in_min[4] = gl520_read_value(client,
754 GL520_REG_IN_MIN[4]);
755 data->in_max[4] = gl520_read_value(client,
756 GL520_REG_IN_MAX[4]);
759 data->last_updated = jiffies;
763 mutex_unlock(&data->update_lock);
769 static int __init sensors_gl520sm_init(void)
771 return i2c_add_driver(&gl520_driver);
774 static void __exit sensors_gl520sm_exit(void)
776 i2c_del_driver(&gl520_driver);
780 MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>, "
781 "Kyösti Mälkki <kmalkki@cc.hut.fi>, "
782 "Maarten Deprez <maartendeprez@users.sourceforge.net>");
783 MODULE_DESCRIPTION("GL520SM driver");
784 MODULE_LICENSE("GPL");
786 module_init(sensors_gl520sm_init);
787 module_exit(sensors_gl520sm_exit);