2 sis5595.c - Part of lm_sensors, Linux kernel modules
3 for hardware monitoring
5 Copyright (C) 1998 - 2001 Frodo Looijaard <frodol@dds.nl>,
6 Kyösti Mälkki <kmalkki@cc.hut.fi>, and
7 Mark D. Studebaker <mdsxyz123@yahoo.com>
8 Ported to Linux 2.6 by Aurelien Jarno <aurelien@aurel32.net> with
9 the help of Jean Delvare <khali@linux-fr.org>
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 SiS southbridge has a LM78-like chip integrated on the same IC.
28 This driver is a customized copy of lm78.c
30 Supports following revisions:
31 Version PCI ID PCI Revision
32 1 1039/0008 AF or less
33 2 1039/0008 B0 or greater
35 Note: these chips contain a 0008 device which is incompatible with the
36 5595. We recognize these by the presence of the listed
37 "blacklist" PCI ID and refuse to load.
39 NOT SUPPORTED PCI ID BLACKLIST PCI ID
53 #include <linux/module.h>
54 #include <linux/slab.h>
55 #include <linux/ioport.h>
56 #include <linux/pci.h>
57 #include <linux/i2c.h>
58 #include <linux/i2c-isa.h>
59 #include <linux/hwmon.h>
60 #include <linux/err.h>
61 #include <linux/init.h>
62 #include <linux/jiffies.h>
63 #include <linux/mutex.h>
67 /* If force_addr is set to anything different from 0, we forcibly enable
68 the device at the given address. */
69 static u16 force_addr;
70 module_param(force_addr, ushort, 0);
71 MODULE_PARM_DESC(force_addr,
72 "Initialize the base address of the sensors");
75 Note that we can't determine the ISA address until we have initialized
77 static unsigned short address;
79 /* Many SIS5595 constants specified below */
81 /* Length of ISA address segment */
82 #define SIS5595_EXTENT 8
83 /* PCI Config Registers */
84 #define SIS5595_REVISION_REG 0x08
85 #define SIS5595_BASE_REG 0x68
86 #define SIS5595_PIN_REG 0x7A
87 #define SIS5595_ENABLE_REG 0x7B
89 /* Where are the ISA address/data registers relative to the base address */
90 #define SIS5595_ADDR_REG_OFFSET 5
91 #define SIS5595_DATA_REG_OFFSET 6
93 /* The SIS5595 registers */
94 #define SIS5595_REG_IN_MAX(nr) (0x2b + (nr) * 2)
95 #define SIS5595_REG_IN_MIN(nr) (0x2c + (nr) * 2)
96 #define SIS5595_REG_IN(nr) (0x20 + (nr))
98 #define SIS5595_REG_FAN_MIN(nr) (0x3b + (nr))
99 #define SIS5595_REG_FAN(nr) (0x28 + (nr))
101 /* On the first version of the chip, the temp registers are separate.
102 On the second version,
103 TEMP pin is shared with IN4, configured in PCI register 0x7A.
104 The registers are the same as well.
105 OVER and HYST are really MAX and MIN. */
108 #define SIS5595_REG_TEMP (( data->revision) >= REV2MIN) ? \
109 SIS5595_REG_IN(4) : 0x27
110 #define SIS5595_REG_TEMP_OVER (( data->revision) >= REV2MIN) ? \
111 SIS5595_REG_IN_MAX(4) : 0x39
112 #define SIS5595_REG_TEMP_HYST (( data->revision) >= REV2MIN) ? \
113 SIS5595_REG_IN_MIN(4) : 0x3a
115 #define SIS5595_REG_CONFIG 0x40
116 #define SIS5595_REG_ALARM1 0x41
117 #define SIS5595_REG_ALARM2 0x42
118 #define SIS5595_REG_FANDIV 0x47
120 /* Conversions. Limit checking is only done on the TO_REG
123 /* IN: mV, (0V to 4.08V)
125 static inline u8 IN_TO_REG(unsigned long val)
127 unsigned long nval = SENSORS_LIMIT(val, 0, 4080);
128 return (nval + 8) / 16;
130 #define IN_FROM_REG(val) ((val) * 16)
132 static inline u8 FAN_TO_REG(long rpm, int div)
136 return SENSORS_LIMIT((1350000 + rpm * div / 2) / (rpm * div), 1, 254);
139 static inline int FAN_FROM_REG(u8 val, int div)
141 return val==0 ? -1 : val==255 ? 0 : 1350000/(val*div);
144 /* TEMP: mC (-54.12C to +157.53C)
145 REG: 0.83C/bit + 52.12, two's complement */
146 static inline int TEMP_FROM_REG(s8 val)
148 return val * 830 + 52120;
150 static inline s8 TEMP_TO_REG(int val)
152 int nval = SENSORS_LIMIT(val, -54120, 157530) ;
153 return nval<0 ? (nval-5212-415)/830 : (nval-5212+415)/830;
156 /* FAN DIV: 1, 2, 4, or 8 (defaults to 2)
157 REG: 0, 1, 2, or 3 (respectively) (defaults to 1) */
158 static inline u8 DIV_TO_REG(int val)
160 return val==8 ? 3 : val==4 ? 2 : val==1 ? 0 : 1;
162 #define DIV_FROM_REG(val) (1 << (val))
164 /* For the SIS5595, we need to keep some data in memory. That
165 data is pointed to by sis5595_list[NR]->data. The structure itself is
166 dynamically allocated, at the time when the new sis5595 client is
168 struct sis5595_data {
169 struct i2c_client client;
170 struct class_device *class_dev;
173 struct mutex update_lock;
174 char valid; /* !=0 if following fields are valid */
175 unsigned long last_updated; /* In jiffies */
176 char maxins; /* == 3 if temp enabled, otherwise == 4 */
177 u8 revision; /* Reg. value */
179 u8 in[5]; /* Register value */
180 u8 in_max[5]; /* Register value */
181 u8 in_min[5]; /* Register value */
182 u8 fan[2]; /* Register value */
183 u8 fan_min[2]; /* Register value */
184 s8 temp; /* Register value */
185 s8 temp_over; /* Register value */
186 s8 temp_hyst; /* Register value */
187 u8 fan_div[2]; /* Register encoding, shifted right */
188 u16 alarms; /* Register encoding, combined */
191 static struct pci_dev *s_bridge; /* pointer to the (only) sis5595 */
193 static int sis5595_detect(struct i2c_adapter *adapter);
194 static int sis5595_detach_client(struct i2c_client *client);
196 static int sis5595_read_value(struct i2c_client *client, u8 reg);
197 static int sis5595_write_value(struct i2c_client *client, u8 reg, u8 value);
198 static struct sis5595_data *sis5595_update_device(struct device *dev);
199 static void sis5595_init_client(struct i2c_client *client);
201 static struct i2c_driver sis5595_driver = {
203 .owner = THIS_MODULE,
206 .attach_adapter = sis5595_detect,
207 .detach_client = sis5595_detach_client,
211 static ssize_t show_in(struct device *dev, char *buf, int nr)
213 struct sis5595_data *data = sis5595_update_device(dev);
214 return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr]));
217 static ssize_t show_in_min(struct device *dev, char *buf, int nr)
219 struct sis5595_data *data = sis5595_update_device(dev);
220 return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr]));
223 static ssize_t show_in_max(struct device *dev, char *buf, int nr)
225 struct sis5595_data *data = sis5595_update_device(dev);
226 return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr]));
229 static ssize_t set_in_min(struct device *dev, const char *buf,
230 size_t count, int nr)
232 struct i2c_client *client = to_i2c_client(dev);
233 struct sis5595_data *data = i2c_get_clientdata(client);
234 unsigned long val = simple_strtoul(buf, NULL, 10);
236 mutex_lock(&data->update_lock);
237 data->in_min[nr] = IN_TO_REG(val);
238 sis5595_write_value(client, SIS5595_REG_IN_MIN(nr), data->in_min[nr]);
239 mutex_unlock(&data->update_lock);
243 static ssize_t set_in_max(struct device *dev, const char *buf,
244 size_t count, int nr)
246 struct i2c_client *client = to_i2c_client(dev);
247 struct sis5595_data *data = i2c_get_clientdata(client);
248 unsigned long val = simple_strtoul(buf, NULL, 10);
250 mutex_lock(&data->update_lock);
251 data->in_max[nr] = IN_TO_REG(val);
252 sis5595_write_value(client, SIS5595_REG_IN_MAX(nr), data->in_max[nr]);
253 mutex_unlock(&data->update_lock);
257 #define show_in_offset(offset) \
259 show_in##offset (struct device *dev, struct device_attribute *attr, char *buf) \
261 return show_in(dev, buf, offset); \
263 static DEVICE_ATTR(in##offset##_input, S_IRUGO, \
264 show_in##offset, NULL); \
266 show_in##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
268 return show_in_min(dev, buf, offset); \
271 show_in##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \
273 return show_in_max(dev, buf, offset); \
275 static ssize_t set_in##offset##_min (struct device *dev, struct device_attribute *attr, \
276 const char *buf, size_t count) \
278 return set_in_min(dev, buf, count, offset); \
280 static ssize_t set_in##offset##_max (struct device *dev, struct device_attribute *attr, \
281 const char *buf, size_t count) \
283 return set_in_max(dev, buf, count, offset); \
285 static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
286 show_in##offset##_min, set_in##offset##_min); \
287 static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
288 show_in##offset##_max, set_in##offset##_max);
297 static ssize_t show_temp(struct device *dev, struct device_attribute *attr, char *buf)
299 struct sis5595_data *data = sis5595_update_device(dev);
300 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp));
303 static ssize_t show_temp_over(struct device *dev, struct device_attribute *attr, char *buf)
305 struct sis5595_data *data = sis5595_update_device(dev);
306 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over));
309 static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
311 struct i2c_client *client = to_i2c_client(dev);
312 struct sis5595_data *data = i2c_get_clientdata(client);
313 long val = simple_strtol(buf, NULL, 10);
315 mutex_lock(&data->update_lock);
316 data->temp_over = TEMP_TO_REG(val);
317 sis5595_write_value(client, SIS5595_REG_TEMP_OVER, data->temp_over);
318 mutex_unlock(&data->update_lock);
322 static ssize_t show_temp_hyst(struct device *dev, struct device_attribute *attr, char *buf)
324 struct sis5595_data *data = sis5595_update_device(dev);
325 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_hyst));
328 static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
330 struct i2c_client *client = to_i2c_client(dev);
331 struct sis5595_data *data = i2c_get_clientdata(client);
332 long val = simple_strtol(buf, NULL, 10);
334 mutex_lock(&data->update_lock);
335 data->temp_hyst = TEMP_TO_REG(val);
336 sis5595_write_value(client, SIS5595_REG_TEMP_HYST, data->temp_hyst);
337 mutex_unlock(&data->update_lock);
341 static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL);
342 static DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR,
343 show_temp_over, set_temp_over);
344 static DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR,
345 show_temp_hyst, set_temp_hyst);
348 static ssize_t show_fan(struct device *dev, char *buf, int nr)
350 struct sis5595_data *data = sis5595_update_device(dev);
351 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr],
352 DIV_FROM_REG(data->fan_div[nr])) );
355 static ssize_t show_fan_min(struct device *dev, char *buf, int nr)
357 struct sis5595_data *data = sis5595_update_device(dev);
358 return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan_min[nr],
359 DIV_FROM_REG(data->fan_div[nr])) );
362 static ssize_t set_fan_min(struct device *dev, const char *buf,
363 size_t count, int nr)
365 struct i2c_client *client = to_i2c_client(dev);
366 struct sis5595_data *data = i2c_get_clientdata(client);
367 unsigned long val = simple_strtoul(buf, NULL, 10);
369 mutex_lock(&data->update_lock);
370 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
371 sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]);
372 mutex_unlock(&data->update_lock);
376 static ssize_t show_fan_div(struct device *dev, char *buf, int nr)
378 struct sis5595_data *data = sis5595_update_device(dev);
379 return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr]) );
382 /* Note: we save and restore the fan minimum here, because its value is
383 determined in part by the fan divisor. This follows the principle of
384 least surprise; the user doesn't expect the fan minimum to change just
385 because the divisor changed. */
386 static ssize_t set_fan_div(struct device *dev, const char *buf,
387 size_t count, int nr)
389 struct i2c_client *client = to_i2c_client(dev);
390 struct sis5595_data *data = i2c_get_clientdata(client);
392 unsigned long val = simple_strtoul(buf, NULL, 10);
395 mutex_lock(&data->update_lock);
396 min = FAN_FROM_REG(data->fan_min[nr],
397 DIV_FROM_REG(data->fan_div[nr]));
398 reg = sis5595_read_value(client, SIS5595_REG_FANDIV);
401 case 1: data->fan_div[nr] = 0; break;
402 case 2: data->fan_div[nr] = 1; break;
403 case 4: data->fan_div[nr] = 2; break;
404 case 8: data->fan_div[nr] = 3; break;
406 dev_err(&client->dev, "fan_div value %ld not "
407 "supported. Choose one of 1, 2, 4 or 8!\n", val);
408 mutex_unlock(&data->update_lock);
414 reg = (reg & 0xcf) | (data->fan_div[nr] << 4);
417 reg = (reg & 0x3f) | (data->fan_div[nr] << 6);
420 sis5595_write_value(client, SIS5595_REG_FANDIV, reg);
422 FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
423 sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]);
424 mutex_unlock(&data->update_lock);
428 #define show_fan_offset(offset) \
429 static ssize_t show_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
431 return show_fan(dev, buf, offset - 1); \
433 static ssize_t show_fan_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
435 return show_fan_min(dev, buf, offset - 1); \
437 static ssize_t show_fan_##offset##_div (struct device *dev, struct device_attribute *attr, char *buf) \
439 return show_fan_div(dev, buf, offset - 1); \
441 static ssize_t set_fan_##offset##_min (struct device *dev, struct device_attribute *attr, \
442 const char *buf, size_t count) \
444 return set_fan_min(dev, buf, count, offset - 1); \
446 static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL);\
447 static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
448 show_fan_##offset##_min, set_fan_##offset##_min);
453 static ssize_t set_fan_1_div(struct device *dev, struct device_attribute *attr, const char *buf,
456 return set_fan_div(dev, buf, count, 0) ;
459 static ssize_t set_fan_2_div(struct device *dev, struct device_attribute *attr, const char *buf,
462 return set_fan_div(dev, buf, count, 1) ;
464 static DEVICE_ATTR(fan1_div, S_IRUGO | S_IWUSR,
465 show_fan_1_div, set_fan_1_div);
466 static DEVICE_ATTR(fan2_div, S_IRUGO | S_IWUSR,
467 show_fan_2_div, set_fan_2_div);
470 static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
472 struct sis5595_data *data = sis5595_update_device(dev);
473 return sprintf(buf, "%d\n", data->alarms);
475 static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
477 /* This is called when the module is loaded */
478 static int sis5595_detect(struct i2c_adapter *adapter)
482 struct i2c_client *new_client;
483 struct sis5595_data *data;
488 address = force_addr & ~(SIS5595_EXTENT - 1);
489 /* Reserve the ISA region */
490 if (!request_region(address, SIS5595_EXTENT,
491 sis5595_driver.driver.name)) {
496 dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n", address);
497 if (PCIBIOS_SUCCESSFUL !=
498 pci_write_config_word(s_bridge, SIS5595_BASE_REG, address))
500 if (PCIBIOS_SUCCESSFUL !=
501 pci_read_config_word(s_bridge, SIS5595_BASE_REG, &a))
503 if ((a & ~(SIS5595_EXTENT - 1)) != address)
504 /* doesn't work for some chips? */
508 if (PCIBIOS_SUCCESSFUL !=
509 pci_read_config_byte(s_bridge, SIS5595_ENABLE_REG, &val)) {
512 if ((val & 0x80) == 0) {
513 if (PCIBIOS_SUCCESSFUL !=
514 pci_write_config_byte(s_bridge, SIS5595_ENABLE_REG,
517 if (PCIBIOS_SUCCESSFUL !=
518 pci_read_config_byte(s_bridge, SIS5595_ENABLE_REG, &val))
520 if ((val & 0x80) == 0)
521 /* doesn't work for some chips! */
525 if (!(data = kzalloc(sizeof(struct sis5595_data), GFP_KERNEL))) {
530 new_client = &data->client;
531 new_client->addr = address;
532 mutex_init(&data->lock);
533 i2c_set_clientdata(new_client, data);
534 new_client->adapter = adapter;
535 new_client->driver = &sis5595_driver;
536 new_client->flags = 0;
538 /* Check revision and pin registers to determine whether 4 or 5 voltages */
539 pci_read_config_byte(s_bridge, SIS5595_REVISION_REG, &(data->revision));
540 /* 4 voltages, 1 temp */
542 if (data->revision >= REV2MIN) {
543 pci_read_config_byte(s_bridge, SIS5595_PIN_REG, &val);
545 /* 5 voltages, no temps */
549 /* Fill in the remaining client fields and put it into the global list */
550 strlcpy(new_client->name, "sis5595", I2C_NAME_SIZE);
553 mutex_init(&data->update_lock);
555 /* Tell the I2C layer a new client has arrived */
556 if ((err = i2c_attach_client(new_client)))
559 /* Initialize the SIS5595 chip */
560 sis5595_init_client(new_client);
562 /* A few vars need to be filled upon startup */
563 for (i = 0; i < 2; i++) {
564 data->fan_min[i] = sis5595_read_value(new_client,
565 SIS5595_REG_FAN_MIN(i));
568 /* Register sysfs hooks */
569 data->class_dev = hwmon_device_register(&new_client->dev);
570 if (IS_ERR(data->class_dev)) {
571 err = PTR_ERR(data->class_dev);
575 device_create_file(&new_client->dev, &dev_attr_in0_input);
576 device_create_file(&new_client->dev, &dev_attr_in0_min);
577 device_create_file(&new_client->dev, &dev_attr_in0_max);
578 device_create_file(&new_client->dev, &dev_attr_in1_input);
579 device_create_file(&new_client->dev, &dev_attr_in1_min);
580 device_create_file(&new_client->dev, &dev_attr_in1_max);
581 device_create_file(&new_client->dev, &dev_attr_in2_input);
582 device_create_file(&new_client->dev, &dev_attr_in2_min);
583 device_create_file(&new_client->dev, &dev_attr_in2_max);
584 device_create_file(&new_client->dev, &dev_attr_in3_input);
585 device_create_file(&new_client->dev, &dev_attr_in3_min);
586 device_create_file(&new_client->dev, &dev_attr_in3_max);
587 if (data->maxins == 4) {
588 device_create_file(&new_client->dev, &dev_attr_in4_input);
589 device_create_file(&new_client->dev, &dev_attr_in4_min);
590 device_create_file(&new_client->dev, &dev_attr_in4_max);
592 device_create_file(&new_client->dev, &dev_attr_fan1_input);
593 device_create_file(&new_client->dev, &dev_attr_fan1_min);
594 device_create_file(&new_client->dev, &dev_attr_fan1_div);
595 device_create_file(&new_client->dev, &dev_attr_fan2_input);
596 device_create_file(&new_client->dev, &dev_attr_fan2_min);
597 device_create_file(&new_client->dev, &dev_attr_fan2_div);
598 device_create_file(&new_client->dev, &dev_attr_alarms);
599 if (data->maxins == 3) {
600 device_create_file(&new_client->dev, &dev_attr_temp1_input);
601 device_create_file(&new_client->dev, &dev_attr_temp1_max);
602 device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst);
607 i2c_detach_client(new_client);
611 release_region(address, SIS5595_EXTENT);
616 static int sis5595_detach_client(struct i2c_client *client)
618 struct sis5595_data *data = i2c_get_clientdata(client);
621 hwmon_device_unregister(data->class_dev);
623 if ((err = i2c_detach_client(client)))
626 release_region(client->addr, SIS5595_EXTENT);
634 /* ISA access must be locked explicitly. */
635 static int sis5595_read_value(struct i2c_client *client, u8 reg)
639 struct sis5595_data *data = i2c_get_clientdata(client);
640 mutex_lock(&data->lock);
641 outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET);
642 res = inb_p(client->addr + SIS5595_DATA_REG_OFFSET);
643 mutex_unlock(&data->lock);
647 static int sis5595_write_value(struct i2c_client *client, u8 reg, u8 value)
649 struct sis5595_data *data = i2c_get_clientdata(client);
650 mutex_lock(&data->lock);
651 outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET);
652 outb_p(value, client->addr + SIS5595_DATA_REG_OFFSET);
653 mutex_unlock(&data->lock);
657 /* Called when we have found a new SIS5595. */
658 static void sis5595_init_client(struct i2c_client *client)
660 u8 config = sis5595_read_value(client, SIS5595_REG_CONFIG);
661 if (!(config & 0x01))
662 sis5595_write_value(client, SIS5595_REG_CONFIG,
663 (config & 0xf7) | 0x01);
666 static struct sis5595_data *sis5595_update_device(struct device *dev)
668 struct i2c_client *client = to_i2c_client(dev);
669 struct sis5595_data *data = i2c_get_clientdata(client);
672 mutex_lock(&data->update_lock);
674 if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
677 for (i = 0; i <= data->maxins; i++) {
679 sis5595_read_value(client, SIS5595_REG_IN(i));
681 sis5595_read_value(client,
682 SIS5595_REG_IN_MIN(i));
684 sis5595_read_value(client,
685 SIS5595_REG_IN_MAX(i));
687 for (i = 0; i < 2; i++) {
689 sis5595_read_value(client, SIS5595_REG_FAN(i));
691 sis5595_read_value(client,
692 SIS5595_REG_FAN_MIN(i));
694 if (data->maxins == 3) {
696 sis5595_read_value(client, SIS5595_REG_TEMP);
698 sis5595_read_value(client, SIS5595_REG_TEMP_OVER);
700 sis5595_read_value(client, SIS5595_REG_TEMP_HYST);
702 i = sis5595_read_value(client, SIS5595_REG_FANDIV);
703 data->fan_div[0] = (i >> 4) & 0x03;
704 data->fan_div[1] = i >> 6;
706 sis5595_read_value(client, SIS5595_REG_ALARM1) |
707 (sis5595_read_value(client, SIS5595_REG_ALARM2) << 8);
708 data->last_updated = jiffies;
712 mutex_unlock(&data->update_lock);
717 static struct pci_device_id sis5595_pci_ids[] = {
718 { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503) },
722 MODULE_DEVICE_TABLE(pci, sis5595_pci_ids);
724 static int blacklist[] __devinitdata = {
725 PCI_DEVICE_ID_SI_540,
726 PCI_DEVICE_ID_SI_550,
727 PCI_DEVICE_ID_SI_630,
728 PCI_DEVICE_ID_SI_645,
729 PCI_DEVICE_ID_SI_730,
730 PCI_DEVICE_ID_SI_735,
731 PCI_DEVICE_ID_SI_5511, /* 5513 chip has the 0008 device but
732 that ID shows up in other chips so we
733 use the 5511 ID for recognition */
734 PCI_DEVICE_ID_SI_5597,
735 PCI_DEVICE_ID_SI_5598,
738 static int __devinit sis5595_pci_probe(struct pci_dev *dev,
739 const struct pci_device_id *id)
744 for (i = blacklist; *i != 0; i++) {
746 dev = pci_get_device(PCI_VENDOR_ID_SI, *i, NULL);
748 dev_err(&dev->dev, "Looked for SIS5595 but found unsupported device %.4x\n", *i);
754 if (PCIBIOS_SUCCESSFUL !=
755 pci_read_config_word(dev, SIS5595_BASE_REG, &val))
758 address = val & ~(SIS5595_EXTENT - 1);
759 if (address == 0 && force_addr == 0) {
760 dev_err(&dev->dev, "Base address not set - upgrade BIOS or use force_addr=0xaddr\n");
764 s_bridge = pci_dev_get(dev);
765 if (i2c_isa_add_driver(&sis5595_driver)) {
766 pci_dev_put(s_bridge);
770 /* Always return failure here. This is to allow other drivers to bind
771 * to this pci device. We don't really want to have control over the
772 * pci device, we only wanted to read as few register values from it.
777 static struct pci_driver sis5595_pci_driver = {
779 .id_table = sis5595_pci_ids,
780 .probe = sis5595_pci_probe,
783 static int __init sm_sis5595_init(void)
785 return pci_register_driver(&sis5595_pci_driver);
788 static void __exit sm_sis5595_exit(void)
790 pci_unregister_driver(&sis5595_pci_driver);
791 if (s_bridge != NULL) {
792 i2c_isa_del_driver(&sis5595_driver);
793 pci_dev_put(s_bridge);
798 MODULE_AUTHOR("Aurelien Jarno <aurelien@aurel32.net>");
799 MODULE_DESCRIPTION("SiS 5595 Sensor device");
800 MODULE_LICENSE("GPL");
802 module_init(sm_sis5595_init);
803 module_exit(sm_sis5595_exit);