Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / drivers / hwmon / adm1025.c
blob04346fb4368e9394f41411fe583c32f1dad7f7db
1 /*
2 * adm1025.c
4 * Copyright (C) 2000 Chen-Yuan Wu <gwu@esoft.com>
5 * Copyright (C) 2003-2004 Jean Delvare <khali@linux-fr.org>
7 * The ADM1025 is a sensor chip made by Analog Devices. It reports up to 6
8 * voltages (including its own power source) and up to two temperatures
9 * (its own plus up to one external one). Voltages are scaled internally
10 * (which is not the common way) with ratios such that the nominal value
11 * of each voltage correspond to a register value of 192 (which means a
12 * resolution of about 0.5% of the nominal value). Temperature values are
13 * reported with a 1 deg resolution and a 3 deg accuracy. Complete
14 * datasheet can be obtained from Analog's website at:
15 * http://www.analog.com/Analog_Root/productPage/productHome/0,2121,ADM1025,00.html
17 * This driver also supports the ADM1025A, which differs from the ADM1025
18 * only in that it has "open-drain VID inputs while the ADM1025 has
19 * on-chip 100k pull-ups on the VID inputs". It doesn't make any
20 * difference for us.
22 * This driver also supports the NE1619, a sensor chip made by Philips.
23 * That chip is similar to the ADM1025A, with a few differences. The only
24 * difference that matters to us is that the NE1619 has only two possible
25 * addresses while the ADM1025A has a third one. Complete datasheet can be
26 * obtained from Philips's website at:
27 * http://www.semiconductors.philips.com/pip/NE1619DS.html
29 * Since the ADM1025 was the first chipset supported by this driver, most
30 * comments will refer to this chipset, but are actually general and
31 * concern all supported chipsets, unless mentioned otherwise.
33 * This program is free software; you can redistribute it and/or modify
34 * it under the terms of the GNU General Public License as published by
35 * the Free Software Foundation; either version 2 of the License, or
36 * (at your option) any later version.
38 * This program is distributed in the hope that it will be useful,
39 * but WITHOUT ANY WARRANTY; without even the implied warranty of
40 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41 * GNU General Public License for more details.
43 * You should have received a copy of the GNU General Public License
44 * along with this program; if not, write to the Free Software
45 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
48 #include <linux/module.h>
49 #include <linux/init.h>
50 #include <linux/slab.h>
51 #include <linux/jiffies.h>
52 #include <linux/i2c.h>
53 #include <linux/hwmon.h>
54 #include <linux/hwmon-sysfs.h>
55 #include <linux/hwmon-vid.h>
56 #include <linux/err.h>
57 #include <linux/mutex.h>
60 * Addresses to scan
61 * ADM1025 and ADM1025A have three possible addresses: 0x2c, 0x2d and 0x2e.
62 * NE1619 has two possible addresses: 0x2c and 0x2d.
65 <<<<<<< HEAD:drivers/hwmon/adm1025.c
66 static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
67 =======
68 static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
69 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/hwmon/adm1025.c
72 * Insmod parameters
75 I2C_CLIENT_INSMOD_2(adm1025, ne1619);
78 * The ADM1025 registers
81 #define ADM1025_REG_MAN_ID 0x3E
82 #define ADM1025_REG_CHIP_ID 0x3F
83 #define ADM1025_REG_CONFIG 0x40
84 #define ADM1025_REG_STATUS1 0x41
85 #define ADM1025_REG_STATUS2 0x42
86 #define ADM1025_REG_IN(nr) (0x20 + (nr))
87 #define ADM1025_REG_IN_MAX(nr) (0x2B + (nr) * 2)
88 #define ADM1025_REG_IN_MIN(nr) (0x2C + (nr) * 2)
89 #define ADM1025_REG_TEMP(nr) (0x26 + (nr))
90 #define ADM1025_REG_TEMP_HIGH(nr) (0x37 + (nr) * 2)
91 #define ADM1025_REG_TEMP_LOW(nr) (0x38 + (nr) * 2)
92 #define ADM1025_REG_VID 0x47
93 #define ADM1025_REG_VID4 0x49
96 * Conversions and various macros
97 * The ADM1025 uses signed 8-bit values for temperatures.
100 static const int in_scale[6] = { 2500, 2250, 3300, 5000, 12000, 3300 };
102 #define IN_FROM_REG(reg,scale) (((reg) * (scale) + 96) / 192)
103 #define IN_TO_REG(val,scale) ((val) <= 0 ? 0 : \
104 (val) * 192 >= (scale) * 255 ? 255 : \
105 ((val) * 192 + (scale)/2) / (scale))
107 #define TEMP_FROM_REG(reg) ((reg) * 1000)
108 #define TEMP_TO_REG(val) ((val) <= -127500 ? -128 : \
109 (val) >= 126500 ? 127 : \
110 (((val) < 0 ? (val)-500 : (val)+500) / 1000))
113 * Functions declaration
116 static int adm1025_attach_adapter(struct i2c_adapter *adapter);
117 static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind);
118 static void adm1025_init_client(struct i2c_client *client);
119 static int adm1025_detach_client(struct i2c_client *client);
120 static struct adm1025_data *adm1025_update_device(struct device *dev);
123 * Driver data (common to all clients)
126 static struct i2c_driver adm1025_driver = {
127 .driver = {
128 .name = "adm1025",
130 .attach_adapter = adm1025_attach_adapter,
131 .detach_client = adm1025_detach_client,
135 * Client data (each client gets its own)
138 struct adm1025_data {
139 struct i2c_client client;
140 struct device *hwmon_dev;
141 struct mutex update_lock;
142 char valid; /* zero until following fields are valid */
143 unsigned long last_updated; /* in jiffies */
145 u8 in[6]; /* register value */
146 u8 in_max[6]; /* register value */
147 u8 in_min[6]; /* register value */
148 s8 temp[2]; /* register value */
149 s8 temp_min[2]; /* register value */
150 s8 temp_max[2]; /* register value */
151 u16 alarms; /* register values, combined */
152 u8 vid; /* register values, combined */
153 u8 vrm;
157 * Sysfs stuff
160 static ssize_t
161 show_in(struct device *dev, struct device_attribute *attr, char *buf)
163 int index = to_sensor_dev_attr(attr)->index;
164 struct adm1025_data *data = adm1025_update_device(dev);
165 return sprintf(buf, "%u\n", IN_FROM_REG(data->in[index],
166 in_scale[index]));
169 static ssize_t
170 show_in_min(struct device *dev, struct device_attribute *attr, char *buf)
172 int index = to_sensor_dev_attr(attr)->index;
173 struct adm1025_data *data = adm1025_update_device(dev);
174 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[index],
175 in_scale[index]));
178 static ssize_t
179 show_in_max(struct device *dev, struct device_attribute *attr, char *buf)
181 int index = to_sensor_dev_attr(attr)->index;
182 struct adm1025_data *data = adm1025_update_device(dev);
183 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[index],
184 in_scale[index]));
187 static ssize_t
188 show_temp(struct device *dev, struct device_attribute *attr, char *buf)
190 int index = to_sensor_dev_attr(attr)->index;
191 struct adm1025_data *data = adm1025_update_device(dev);
192 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[index]));
195 static ssize_t
196 show_temp_min(struct device *dev, struct device_attribute *attr, char *buf)
198 int index = to_sensor_dev_attr(attr)->index;
199 struct adm1025_data *data = adm1025_update_device(dev);
200 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[index]));
203 static ssize_t
204 show_temp_max(struct device *dev, struct device_attribute *attr, char *buf)
206 int index = to_sensor_dev_attr(attr)->index;
207 struct adm1025_data *data = adm1025_update_device(dev);
208 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[index]));
211 static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
212 const char *buf, size_t count)
214 int index = to_sensor_dev_attr(attr)->index;
215 struct i2c_client *client = to_i2c_client(dev);
216 struct adm1025_data *data = i2c_get_clientdata(client);
217 long val = simple_strtol(buf, NULL, 10);
219 mutex_lock(&data->update_lock);
220 data->in_min[index] = IN_TO_REG(val, in_scale[index]);
221 i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MIN(index),
222 data->in_min[index]);
223 mutex_unlock(&data->update_lock);
224 return count;
227 static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
228 const char *buf, size_t count)
230 int index = to_sensor_dev_attr(attr)->index;
231 struct i2c_client *client = to_i2c_client(dev);
232 struct adm1025_data *data = i2c_get_clientdata(client);
233 long val = simple_strtol(buf, NULL, 10);
235 mutex_lock(&data->update_lock);
236 data->in_max[index] = IN_TO_REG(val, in_scale[index]);
237 i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MAX(index),
238 data->in_max[index]);
239 mutex_unlock(&data->update_lock);
240 return count;
243 #define set_in(offset) \
244 static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \
245 show_in, NULL, offset); \
246 static SENSOR_DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \
247 show_in_min, set_in_min, offset); \
248 static SENSOR_DEVICE_ATTR(in##offset##_max, S_IWUSR | S_IRUGO, \
249 show_in_max, set_in_max, offset)
250 set_in(0);
251 set_in(1);
252 set_in(2);
253 set_in(3);
254 set_in(4);
255 set_in(5);
257 static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
258 const char *buf, size_t count)
260 int index = to_sensor_dev_attr(attr)->index;
261 struct i2c_client *client = to_i2c_client(dev);
262 struct adm1025_data *data = i2c_get_clientdata(client);
263 long val = simple_strtol(buf, NULL, 10);
265 mutex_lock(&data->update_lock);
266 data->temp_min[index] = TEMP_TO_REG(val);
267 i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_LOW(index),
268 data->temp_min[index]);
269 mutex_unlock(&data->update_lock);
270 return count;
273 static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
274 const char *buf, size_t count)
276 int index = to_sensor_dev_attr(attr)->index;
277 struct i2c_client *client = to_i2c_client(dev);
278 struct adm1025_data *data = i2c_get_clientdata(client);
279 long val = simple_strtol(buf, NULL, 10);
281 mutex_lock(&data->update_lock);
282 data->temp_max[index] = TEMP_TO_REG(val);
283 i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_HIGH(index),
284 data->temp_max[index]);
285 mutex_unlock(&data->update_lock);
286 return count;
289 #define set_temp(offset) \
290 static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
291 show_temp, NULL, offset - 1); \
292 static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \
293 show_temp_min, set_temp_min, offset - 1); \
294 static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \
295 show_temp_max, set_temp_max, offset - 1)
296 set_temp(1);
297 set_temp(2);
299 static ssize_t
300 show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
302 struct adm1025_data *data = adm1025_update_device(dev);
303 return sprintf(buf, "%u\n", data->alarms);
305 static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
307 static ssize_t
308 show_alarm(struct device *dev, struct device_attribute *attr, char *buf)
310 int bitnr = to_sensor_dev_attr(attr)->index;
311 struct adm1025_data *data = adm1025_update_device(dev);
312 return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1);
314 static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0);
315 static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1);
316 static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2);
317 static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3);
318 static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 8);
319 static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 9);
320 static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 5);
321 static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 4);
322 static SENSOR_DEVICE_ATTR(temp1_fault, S_IRUGO, show_alarm, NULL, 14);
324 static ssize_t
325 show_vid(struct device *dev, struct device_attribute *attr, char *buf)
327 struct adm1025_data *data = adm1025_update_device(dev);
328 return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm));
330 static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);
332 static ssize_t
333 show_vrm(struct device *dev, struct device_attribute *attr, char *buf)
335 struct adm1025_data *data = dev_get_drvdata(dev);
336 return sprintf(buf, "%u\n", data->vrm);
338 static ssize_t set_vrm(struct device *dev, struct device_attribute *attr,
339 const char *buf, size_t count)
341 struct adm1025_data *data = dev_get_drvdata(dev);
342 data->vrm = simple_strtoul(buf, NULL, 10);
343 return count;
345 static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm);
348 * Real code
351 static int adm1025_attach_adapter(struct i2c_adapter *adapter)
353 if (!(adapter->class & I2C_CLASS_HWMON))
354 return 0;
355 return i2c_probe(adapter, &addr_data, adm1025_detect);
358 static struct attribute *adm1025_attributes[] = {
359 &sensor_dev_attr_in0_input.dev_attr.attr,
360 &sensor_dev_attr_in1_input.dev_attr.attr,
361 &sensor_dev_attr_in2_input.dev_attr.attr,
362 &sensor_dev_attr_in3_input.dev_attr.attr,
363 &sensor_dev_attr_in5_input.dev_attr.attr,
364 &sensor_dev_attr_in0_min.dev_attr.attr,
365 &sensor_dev_attr_in1_min.dev_attr.attr,
366 &sensor_dev_attr_in2_min.dev_attr.attr,
367 &sensor_dev_attr_in3_min.dev_attr.attr,
368 &sensor_dev_attr_in5_min.dev_attr.attr,
369 &sensor_dev_attr_in0_max.dev_attr.attr,
370 &sensor_dev_attr_in1_max.dev_attr.attr,
371 &sensor_dev_attr_in2_max.dev_attr.attr,
372 &sensor_dev_attr_in3_max.dev_attr.attr,
373 &sensor_dev_attr_in5_max.dev_attr.attr,
374 &sensor_dev_attr_in0_alarm.dev_attr.attr,
375 &sensor_dev_attr_in1_alarm.dev_attr.attr,
376 &sensor_dev_attr_in2_alarm.dev_attr.attr,
377 &sensor_dev_attr_in3_alarm.dev_attr.attr,
378 &sensor_dev_attr_in5_alarm.dev_attr.attr,
379 &sensor_dev_attr_temp1_input.dev_attr.attr,
380 &sensor_dev_attr_temp2_input.dev_attr.attr,
381 &sensor_dev_attr_temp1_min.dev_attr.attr,
382 &sensor_dev_attr_temp2_min.dev_attr.attr,
383 &sensor_dev_attr_temp1_max.dev_attr.attr,
384 &sensor_dev_attr_temp2_max.dev_attr.attr,
385 &sensor_dev_attr_temp1_alarm.dev_attr.attr,
386 &sensor_dev_attr_temp2_alarm.dev_attr.attr,
387 &sensor_dev_attr_temp1_fault.dev_attr.attr,
388 &dev_attr_alarms.attr,
389 &dev_attr_cpu0_vid.attr,
390 &dev_attr_vrm.attr,
391 NULL
394 static const struct attribute_group adm1025_group = {
395 .attrs = adm1025_attributes,
398 static struct attribute *adm1025_attributes_in4[] = {
399 &sensor_dev_attr_in4_input.dev_attr.attr,
400 &sensor_dev_attr_in4_min.dev_attr.attr,
401 &sensor_dev_attr_in4_max.dev_attr.attr,
402 &sensor_dev_attr_in4_alarm.dev_attr.attr,
403 NULL
406 static const struct attribute_group adm1025_group_in4 = {
407 .attrs = adm1025_attributes_in4,
411 * The following function does more than just detection. If detection
412 * succeeds, it also registers the new chip.
414 static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind)
416 struct i2c_client *client;
417 struct adm1025_data *data;
418 int err = 0;
419 const char *name = "";
420 u8 config;
422 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
423 goto exit;
425 if (!(data = kzalloc(sizeof(struct adm1025_data), GFP_KERNEL))) {
426 err = -ENOMEM;
427 goto exit;
430 client = &data->client;
431 i2c_set_clientdata(client, data);
432 client->addr = address;
433 client->adapter = adapter;
434 client->driver = &adm1025_driver;
437 * Now we do the remaining detection. A negative kind means that
438 * the driver was loaded with no force parameter (default), so we
439 * must both detect and identify the chip. A zero kind means that
440 * the driver was loaded with the force parameter, the detection
441 * step shall be skipped. A positive kind means that the driver
442 * was loaded with the force parameter and a given kind of chip is
443 * requested, so both the detection and the identification steps
444 * are skipped.
446 config = i2c_smbus_read_byte_data(client, ADM1025_REG_CONFIG);
447 if (kind < 0) { /* detection */
448 if ((config & 0x80) != 0x00
449 || (i2c_smbus_read_byte_data(client,
450 ADM1025_REG_STATUS1) & 0xC0) != 0x00
451 || (i2c_smbus_read_byte_data(client,
452 ADM1025_REG_STATUS2) & 0xBC) != 0x00) {
453 dev_dbg(&adapter->dev,
454 "ADM1025 detection failed at 0x%02x.\n",
455 address);
456 goto exit_free;
460 if (kind <= 0) { /* identification */
461 u8 man_id, chip_id;
463 man_id = i2c_smbus_read_byte_data(client, ADM1025_REG_MAN_ID);
464 chip_id = i2c_smbus_read_byte_data(client, ADM1025_REG_CHIP_ID);
466 if (man_id == 0x41) { /* Analog Devices */
467 if ((chip_id & 0xF0) == 0x20) { /* ADM1025/ADM1025A */
468 kind = adm1025;
470 } else
471 if (man_id == 0xA1) { /* Philips */
472 if (address != 0x2E
473 && (chip_id & 0xF0) == 0x20) { /* NE1619 */
474 kind = ne1619;
478 if (kind <= 0) { /* identification failed */
479 dev_info(&adapter->dev,
480 "Unsupported chip (man_id=0x%02X, "
481 "chip_id=0x%02X).\n", man_id, chip_id);
482 goto exit_free;
486 if (kind == adm1025) {
487 name = "adm1025";
488 } else if (kind == ne1619) {
489 name = "ne1619";
492 /* We can fill in the remaining client fields */
493 strlcpy(client->name, name, I2C_NAME_SIZE);
494 mutex_init(&data->update_lock);
496 /* Tell the I2C layer a new client has arrived */
497 if ((err = i2c_attach_client(client)))
498 goto exit_free;
500 /* Initialize the ADM1025 chip */
501 adm1025_init_client(client);
503 /* Register sysfs hooks */
504 if ((err = sysfs_create_group(&client->dev.kobj, &adm1025_group)))
505 goto exit_detach;
507 /* Pin 11 is either in4 (+12V) or VID4 */
508 if (!(config & 0x20)) {
509 if ((err = sysfs_create_group(&client->dev.kobj,
510 &adm1025_group_in4)))
511 goto exit_remove;
514 data->hwmon_dev = hwmon_device_register(&client->dev);
515 if (IS_ERR(data->hwmon_dev)) {
516 err = PTR_ERR(data->hwmon_dev);
517 goto exit_remove;
520 return 0;
522 exit_remove:
523 sysfs_remove_group(&client->dev.kobj, &adm1025_group);
524 sysfs_remove_group(&client->dev.kobj, &adm1025_group_in4);
525 exit_detach:
526 i2c_detach_client(client);
527 exit_free:
528 kfree(data);
529 exit:
530 return err;
533 static void adm1025_init_client(struct i2c_client *client)
535 u8 reg;
536 struct adm1025_data *data = i2c_get_clientdata(client);
537 int i;
539 data->vrm = vid_which_vrm();
542 * Set high limits
543 * Usually we avoid setting limits on driver init, but it happens
544 * that the ADM1025 comes with stupid default limits (all registers
545 * set to 0). In case the chip has not gone through any limit
546 * setting yet, we better set the high limits to the max so that
547 * no alarm triggers.
549 for (i=0; i<6; i++) {
550 reg = i2c_smbus_read_byte_data(client,
551 ADM1025_REG_IN_MAX(i));
552 if (reg == 0)
553 i2c_smbus_write_byte_data(client,
554 ADM1025_REG_IN_MAX(i),
555 0xFF);
557 for (i=0; i<2; i++) {
558 reg = i2c_smbus_read_byte_data(client,
559 ADM1025_REG_TEMP_HIGH(i));
560 if (reg == 0)
561 i2c_smbus_write_byte_data(client,
562 ADM1025_REG_TEMP_HIGH(i),
563 0x7F);
567 * Start the conversions
569 reg = i2c_smbus_read_byte_data(client, ADM1025_REG_CONFIG);
570 if (!(reg & 0x01))
571 i2c_smbus_write_byte_data(client, ADM1025_REG_CONFIG,
572 (reg&0x7E)|0x01);
575 static int adm1025_detach_client(struct i2c_client *client)
577 struct adm1025_data *data = i2c_get_clientdata(client);
578 int err;
580 hwmon_device_unregister(data->hwmon_dev);
581 sysfs_remove_group(&client->dev.kobj, &adm1025_group);
582 sysfs_remove_group(&client->dev.kobj, &adm1025_group_in4);
584 if ((err = i2c_detach_client(client)))
585 return err;
587 kfree(data);
588 return 0;
591 static struct adm1025_data *adm1025_update_device(struct device *dev)
593 struct i2c_client *client = to_i2c_client(dev);
594 struct adm1025_data *data = i2c_get_clientdata(client);
596 mutex_lock(&data->update_lock);
598 if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
599 int i;
601 dev_dbg(&client->dev, "Updating data.\n");
602 for (i=0; i<6; i++) {
603 data->in[i] = i2c_smbus_read_byte_data(client,
604 ADM1025_REG_IN(i));
605 data->in_min[i] = i2c_smbus_read_byte_data(client,
606 ADM1025_REG_IN_MIN(i));
607 data->in_max[i] = i2c_smbus_read_byte_data(client,
608 ADM1025_REG_IN_MAX(i));
610 for (i=0; i<2; i++) {
611 data->temp[i] = i2c_smbus_read_byte_data(client,
612 ADM1025_REG_TEMP(i));
613 data->temp_min[i] = i2c_smbus_read_byte_data(client,
614 ADM1025_REG_TEMP_LOW(i));
615 data->temp_max[i] = i2c_smbus_read_byte_data(client,
616 ADM1025_REG_TEMP_HIGH(i));
618 data->alarms = i2c_smbus_read_byte_data(client,
619 ADM1025_REG_STATUS1)
620 | (i2c_smbus_read_byte_data(client,
621 ADM1025_REG_STATUS2) << 8);
622 data->vid = (i2c_smbus_read_byte_data(client,
623 ADM1025_REG_VID) & 0x0f)
624 | ((i2c_smbus_read_byte_data(client,
625 ADM1025_REG_VID4) & 0x01) << 4);
627 data->last_updated = jiffies;
628 data->valid = 1;
631 mutex_unlock(&data->update_lock);
633 return data;
636 static int __init sensors_adm1025_init(void)
638 return i2c_add_driver(&adm1025_driver);
641 static void __exit sensors_adm1025_exit(void)
643 i2c_del_driver(&adm1025_driver);
646 MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");
647 MODULE_DESCRIPTION("ADM1025 driver");
648 MODULE_LICENSE("GPL");
650 module_init(sensors_adm1025_init);
651 module_exit(sensors_adm1025_exit);