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-sensor.h>
59 #include <linux/init.h>
63 /* If force_addr is set to anything different from 0, we forcibly enable
64 the device at the given address. */
65 static u16 force_addr;
66 module_param(force_addr, ushort, 0);
67 MODULE_PARM_DESC(force_addr,
68 "Initialize the base address of the sensors");
71 Note that we can't determine the ISA address until we have initialized
73 static unsigned short normal_i2c[] = { I2C_CLIENT_END };
74 static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END };
76 /* Insmod parameters */
77 SENSORS_INSMOD_1(sis5595);
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 semaphore lock;
172 struct semaphore update_lock;
173 char valid; /* !=0 if following fields are valid */
174 unsigned long last_updated; /* In jiffies */
175 char maxins; /* == 3 if temp enabled, otherwise == 4 */
176 u8 revision; /* Reg. value */
178 u8 in[5]; /* Register value */
179 u8 in_max[5]; /* Register value */
180 u8 in_min[5]; /* Register value */
181 u8 fan[2]; /* Register value */
182 u8 fan_min[2]; /* Register value */
183 s8 temp; /* Register value */
184 s8 temp_over; /* Register value */
185 s8 temp_hyst; /* Register value */
186 u8 fan_div[2]; /* Register encoding, shifted right */
187 u16 alarms; /* Register encoding, combined */
190 static struct pci_dev *s_bridge; /* pointer to the (only) sis5595 */
192 static int sis5595_attach_adapter(struct i2c_adapter *adapter);
193 static int sis5595_detect(struct i2c_adapter *adapter, int address, int kind);
194 static int sis5595_detach_client(struct i2c_client *client);
196 static int sis5595_read_value(struct i2c_client *client, u8 register);
197 static int sis5595_write_value(struct i2c_client *client, u8 register, 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 = {
202 .owner = THIS_MODULE,
204 .id = I2C_DRIVERID_SIS5595,
205 .flags = I2C_DF_NOTIFY,
206 .attach_adapter = sis5595_attach_adapter,
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 down(&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 up(&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 down(&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 up(&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 down(&data->update_lock);
316 data->temp_over = TEMP_TO_REG(val);
317 sis5595_write_value(client, SIS5595_REG_TEMP_OVER, data->temp_over);
318 up(&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 down(&data->update_lock);
335 data->temp_hyst = TEMP_TO_REG(val);
336 sis5595_write_value(client, SIS5595_REG_TEMP_HYST, data->temp_hyst);
337 up(&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 down(&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 up(&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 suprise; 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 down(&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 up(&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 up(&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_attach_adapter(struct i2c_adapter *adapter)
480 if (!(adapter->class & I2C_CLASS_HWMON))
482 return i2c_detect(adapter, &addr_data, sis5595_detect);
485 int sis5595_detect(struct i2c_adapter *adapter, int address, int kind)
489 struct i2c_client *new_client;
490 struct sis5595_data *data;
494 /* Make sure we are probing the ISA bus!! */
495 if (!i2c_is_isa_adapter(adapter))
499 address = force_addr & ~(SIS5595_EXTENT - 1);
500 /* Reserve the ISA region */
501 if (!request_region(address, SIS5595_EXTENT, sis5595_driver.name)) {
506 dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n", address);
507 if (PCIBIOS_SUCCESSFUL !=
508 pci_write_config_word(s_bridge, SIS5595_BASE_REG, address))
510 if (PCIBIOS_SUCCESSFUL !=
511 pci_read_config_word(s_bridge, SIS5595_BASE_REG, &a))
513 if ((a & ~(SIS5595_EXTENT - 1)) != address)
514 /* doesn't work for some chips? */
518 if (PCIBIOS_SUCCESSFUL !=
519 pci_read_config_byte(s_bridge, SIS5595_ENABLE_REG, &val)) {
522 if ((val & 0x80) == 0) {
523 if (PCIBIOS_SUCCESSFUL !=
524 pci_write_config_byte(s_bridge, SIS5595_ENABLE_REG,
527 if (PCIBIOS_SUCCESSFUL !=
528 pci_read_config_byte(s_bridge, SIS5595_ENABLE_REG, &val))
530 if ((val & 0x80) == 0)
531 /* doesn't work for some chips! */
535 if (!(data = kmalloc(sizeof(struct sis5595_data), GFP_KERNEL))) {
539 memset(data, 0, sizeof(struct sis5595_data));
541 new_client = &data->client;
542 new_client->addr = address;
543 init_MUTEX(&data->lock);
544 i2c_set_clientdata(new_client, data);
545 new_client->adapter = adapter;
546 new_client->driver = &sis5595_driver;
547 new_client->flags = 0;
549 /* Check revision and pin registers to determine whether 4 or 5 voltages */
550 pci_read_config_byte(s_bridge, SIS5595_REVISION_REG, &(data->revision));
551 /* 4 voltages, 1 temp */
553 if (data->revision >= REV2MIN) {
554 pci_read_config_byte(s_bridge, SIS5595_PIN_REG, &val);
556 /* 5 voltages, no temps */
560 /* Fill in the remaining client fields and put it into the global list */
561 strlcpy(new_client->name, "sis5595", I2C_NAME_SIZE);
564 init_MUTEX(&data->update_lock);
566 /* Tell the I2C layer a new client has arrived */
567 if ((err = i2c_attach_client(new_client)))
570 /* Initialize the SIS5595 chip */
571 sis5595_init_client(new_client);
573 /* A few vars need to be filled upon startup */
574 for (i = 0; i < 2; i++) {
575 data->fan_min[i] = sis5595_read_value(new_client,
576 SIS5595_REG_FAN_MIN(i));
579 /* Register sysfs hooks */
580 device_create_file(&new_client->dev, &dev_attr_in0_input);
581 device_create_file(&new_client->dev, &dev_attr_in0_min);
582 device_create_file(&new_client->dev, &dev_attr_in0_max);
583 device_create_file(&new_client->dev, &dev_attr_in1_input);
584 device_create_file(&new_client->dev, &dev_attr_in1_min);
585 device_create_file(&new_client->dev, &dev_attr_in1_max);
586 device_create_file(&new_client->dev, &dev_attr_in2_input);
587 device_create_file(&new_client->dev, &dev_attr_in2_min);
588 device_create_file(&new_client->dev, &dev_attr_in2_max);
589 device_create_file(&new_client->dev, &dev_attr_in3_input);
590 device_create_file(&new_client->dev, &dev_attr_in3_min);
591 device_create_file(&new_client->dev, &dev_attr_in3_max);
592 if (data->maxins == 4) {
593 device_create_file(&new_client->dev, &dev_attr_in4_input);
594 device_create_file(&new_client->dev, &dev_attr_in4_min);
595 device_create_file(&new_client->dev, &dev_attr_in4_max);
597 device_create_file(&new_client->dev, &dev_attr_fan1_input);
598 device_create_file(&new_client->dev, &dev_attr_fan1_min);
599 device_create_file(&new_client->dev, &dev_attr_fan1_div);
600 device_create_file(&new_client->dev, &dev_attr_fan2_input);
601 device_create_file(&new_client->dev, &dev_attr_fan2_min);
602 device_create_file(&new_client->dev, &dev_attr_fan2_div);
603 device_create_file(&new_client->dev, &dev_attr_alarms);
604 if (data->maxins == 3) {
605 device_create_file(&new_client->dev, &dev_attr_temp1_input);
606 device_create_file(&new_client->dev, &dev_attr_temp1_max);
607 device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst);
614 release_region(address, SIS5595_EXTENT);
619 static int sis5595_detach_client(struct i2c_client *client)
623 if ((err = i2c_detach_client(client))) {
624 dev_err(&client->dev,
625 "Client deregistration failed, client not detached.\n");
629 if (i2c_is_isa_client(client))
630 release_region(client->addr, SIS5595_EXTENT);
632 kfree(i2c_get_clientdata(client));
638 /* ISA access must be locked explicitly. */
639 static int sis5595_read_value(struct i2c_client *client, u8 reg)
643 struct sis5595_data *data = i2c_get_clientdata(client);
645 outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET);
646 res = inb_p(client->addr + SIS5595_DATA_REG_OFFSET);
651 static int sis5595_write_value(struct i2c_client *client, u8 reg, u8 value)
653 struct sis5595_data *data = i2c_get_clientdata(client);
655 outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET);
656 outb_p(value, client->addr + SIS5595_DATA_REG_OFFSET);
661 /* Called when we have found a new SIS5595. */
662 static void sis5595_init_client(struct i2c_client *client)
664 u8 config = sis5595_read_value(client, SIS5595_REG_CONFIG);
665 if (!(config & 0x01))
666 sis5595_write_value(client, SIS5595_REG_CONFIG,
667 (config & 0xf7) | 0x01);
670 static struct sis5595_data *sis5595_update_device(struct device *dev)
672 struct i2c_client *client = to_i2c_client(dev);
673 struct sis5595_data *data = i2c_get_clientdata(client);
676 down(&data->update_lock);
678 if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
681 for (i = 0; i <= data->maxins; i++) {
683 sis5595_read_value(client, SIS5595_REG_IN(i));
685 sis5595_read_value(client,
686 SIS5595_REG_IN_MIN(i));
688 sis5595_read_value(client,
689 SIS5595_REG_IN_MAX(i));
691 for (i = 0; i < 2; i++) {
693 sis5595_read_value(client, SIS5595_REG_FAN(i));
695 sis5595_read_value(client,
696 SIS5595_REG_FAN_MIN(i));
698 if (data->maxins == 3) {
700 sis5595_read_value(client, SIS5595_REG_TEMP);
702 sis5595_read_value(client, SIS5595_REG_TEMP_OVER);
704 sis5595_read_value(client, SIS5595_REG_TEMP_HYST);
706 i = sis5595_read_value(client, SIS5595_REG_FANDIV);
707 data->fan_div[0] = (i >> 4) & 0x03;
708 data->fan_div[1] = i >> 6;
710 sis5595_read_value(client, SIS5595_REG_ALARM1) |
711 (sis5595_read_value(client, SIS5595_REG_ALARM2) << 8);
712 data->last_updated = jiffies;
716 up(&data->update_lock);
721 static struct pci_device_id sis5595_pci_ids[] = {
722 { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503) },
726 MODULE_DEVICE_TABLE(pci, sis5595_pci_ids);
728 static int blacklist[] __devinitdata = {
729 PCI_DEVICE_ID_SI_540,
730 PCI_DEVICE_ID_SI_550,
731 PCI_DEVICE_ID_SI_630,
732 PCI_DEVICE_ID_SI_645,
733 PCI_DEVICE_ID_SI_730,
734 PCI_DEVICE_ID_SI_735,
735 PCI_DEVICE_ID_SI_5511, /* 5513 chip has the 0008 device but
736 that ID shows up in other chips so we
737 use the 5511 ID for recognition */
738 PCI_DEVICE_ID_SI_5597,
739 PCI_DEVICE_ID_SI_5598,
742 static int __devinit sis5595_pci_probe(struct pci_dev *dev,
743 const struct pci_device_id *id)
749 for (i = blacklist; *i != 0; i++) {
751 dev = pci_get_device(PCI_VENDOR_ID_SI, *i, NULL);
753 dev_err(&dev->dev, "Looked for SIS5595 but found unsupported device %.4x\n", *i);
759 if (PCIBIOS_SUCCESSFUL !=
760 pci_read_config_word(dev, SIS5595_BASE_REG, &val))
763 addr = val & ~(SIS5595_EXTENT - 1);
764 if (addr == 0 && force_addr == 0) {
765 dev_err(&dev->dev, "Base address not set - upgrade BIOS or use force_addr=0xaddr\n");
769 addr = force_addr; /* so detect will get called */
772 dev_err(&dev->dev,"No SiS 5595 sensors found.\n");
775 normal_isa[0] = addr;
777 s_bridge = pci_dev_get(dev);
778 if (i2c_add_driver(&sis5595_driver)) {
779 pci_dev_put(s_bridge);
783 /* Always return failure here. This is to allow other drivers to bind
784 * to this pci device. We don't really want to have control over the
785 * pci device, we only wanted to read as few register values from it.
790 static struct pci_driver sis5595_pci_driver = {
792 .id_table = sis5595_pci_ids,
793 .probe = sis5595_pci_probe,
796 static int __init sm_sis5595_init(void)
798 return pci_register_driver(&sis5595_pci_driver);
801 static void __exit sm_sis5595_exit(void)
803 pci_unregister_driver(&sis5595_pci_driver);
804 if (s_bridge != NULL) {
805 i2c_del_driver(&sis5595_driver);
806 pci_dev_put(s_bridge);
811 MODULE_AUTHOR("Aurelien Jarno <aurelien@aurel32.net>");
812 MODULE_DESCRIPTION("SiS 5595 Sensor device");
813 MODULE_LICENSE("GPL");
815 module_init(sm_sis5595_init);
816 module_exit(sm_sis5595_exit);