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/hwmon.h>
60 #include <linux/err.h>
61 #include <linux/init.h>
62 #include <linux/jiffies.h>
66 /* If force_addr is set to anything different from 0, we forcibly enable
67 the device at the given address. */
68 static u16 force_addr;
69 module_param(force_addr, ushort, 0);
70 MODULE_PARM_DESC(force_addr,
71 "Initialize the base address of the sensors");
74 Note that we can't determine the ISA address until we have initialized
76 static unsigned short normal_i2c[] = { I2C_CLIENT_END };
77 static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END };
79 /* Insmod parameters */
80 SENSORS_INSMOD_1(sis5595);
82 /* Many SIS5595 constants specified below */
84 /* Length of ISA address segment */
85 #define SIS5595_EXTENT 8
86 /* PCI Config Registers */
87 #define SIS5595_REVISION_REG 0x08
88 #define SIS5595_BASE_REG 0x68
89 #define SIS5595_PIN_REG 0x7A
90 #define SIS5595_ENABLE_REG 0x7B
92 /* Where are the ISA address/data registers relative to the base address */
93 #define SIS5595_ADDR_REG_OFFSET 5
94 #define SIS5595_DATA_REG_OFFSET 6
96 /* The SIS5595 registers */
97 #define SIS5595_REG_IN_MAX(nr) (0x2b + (nr) * 2)
98 #define SIS5595_REG_IN_MIN(nr) (0x2c + (nr) * 2)
99 #define SIS5595_REG_IN(nr) (0x20 + (nr))
101 #define SIS5595_REG_FAN_MIN(nr) (0x3b + (nr))
102 #define SIS5595_REG_FAN(nr) (0x28 + (nr))
104 /* On the first version of the chip, the temp registers are separate.
105 On the second version,
106 TEMP pin is shared with IN4, configured in PCI register 0x7A.
107 The registers are the same as well.
108 OVER and HYST are really MAX and MIN. */
111 #define SIS5595_REG_TEMP (( data->revision) >= REV2MIN) ? \
112 SIS5595_REG_IN(4) : 0x27
113 #define SIS5595_REG_TEMP_OVER (( data->revision) >= REV2MIN) ? \
114 SIS5595_REG_IN_MAX(4) : 0x39
115 #define SIS5595_REG_TEMP_HYST (( data->revision) >= REV2MIN) ? \
116 SIS5595_REG_IN_MIN(4) : 0x3a
118 #define SIS5595_REG_CONFIG 0x40
119 #define SIS5595_REG_ALARM1 0x41
120 #define SIS5595_REG_ALARM2 0x42
121 #define SIS5595_REG_FANDIV 0x47
123 /* Conversions. Limit checking is only done on the TO_REG
126 /* IN: mV, (0V to 4.08V)
128 static inline u8 IN_TO_REG(unsigned long val)
130 unsigned long nval = SENSORS_LIMIT(val, 0, 4080);
131 return (nval + 8) / 16;
133 #define IN_FROM_REG(val) ((val) * 16)
135 static inline u8 FAN_TO_REG(long rpm, int div)
139 return SENSORS_LIMIT((1350000 + rpm * div / 2) / (rpm * div), 1, 254);
142 static inline int FAN_FROM_REG(u8 val, int div)
144 return val==0 ? -1 : val==255 ? 0 : 1350000/(val*div);
147 /* TEMP: mC (-54.12C to +157.53C)
148 REG: 0.83C/bit + 52.12, two's complement */
149 static inline int TEMP_FROM_REG(s8 val)
151 return val * 830 + 52120;
153 static inline s8 TEMP_TO_REG(int val)
155 int nval = SENSORS_LIMIT(val, -54120, 157530) ;
156 return nval<0 ? (nval-5212-415)/830 : (nval-5212+415)/830;
159 /* FAN DIV: 1, 2, 4, or 8 (defaults to 2)
160 REG: 0, 1, 2, or 3 (respectively) (defaults to 1) */
161 static inline u8 DIV_TO_REG(int val)
163 return val==8 ? 3 : val==4 ? 2 : val==1 ? 0 : 1;
165 #define DIV_FROM_REG(val) (1 << (val))
167 /* For the SIS5595, we need to keep some data in memory. That
168 data is pointed to by sis5595_list[NR]->data. The structure itself is
169 dynamically allocated, at the time when the new sis5595 client is
171 struct sis5595_data {
172 struct i2c_client client;
173 struct class_device *class_dev;
174 struct semaphore lock;
176 struct semaphore update_lock;
177 char valid; /* !=0 if following fields are valid */
178 unsigned long last_updated; /* In jiffies */
179 char maxins; /* == 3 if temp enabled, otherwise == 4 */
180 u8 revision; /* Reg. value */
182 u8 in[5]; /* Register value */
183 u8 in_max[5]; /* Register value */
184 u8 in_min[5]; /* Register value */
185 u8 fan[2]; /* Register value */
186 u8 fan_min[2]; /* Register value */
187 s8 temp; /* Register value */
188 s8 temp_over; /* Register value */
189 s8 temp_hyst; /* Register value */
190 u8 fan_div[2]; /* Register encoding, shifted right */
191 u16 alarms; /* Register encoding, combined */
194 static struct pci_dev *s_bridge; /* pointer to the (only) sis5595 */
196 static int sis5595_attach_adapter(struct i2c_adapter *adapter);
197 static int sis5595_detect(struct i2c_adapter *adapter, int address, int kind);
198 static int sis5595_detach_client(struct i2c_client *client);
200 static int sis5595_read_value(struct i2c_client *client, u8 register);
201 static int sis5595_write_value(struct i2c_client *client, u8 register, u8 value);
202 static struct sis5595_data *sis5595_update_device(struct device *dev);
203 static void sis5595_init_client(struct i2c_client *client);
205 static struct i2c_driver sis5595_driver = {
206 .owner = THIS_MODULE,
208 .id = I2C_DRIVERID_SIS5595,
209 .flags = I2C_DF_NOTIFY,
210 .attach_adapter = sis5595_attach_adapter,
211 .detach_client = sis5595_detach_client,
215 static ssize_t show_in(struct device *dev, char *buf, int nr)
217 struct sis5595_data *data = sis5595_update_device(dev);
218 return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr]));
221 static ssize_t show_in_min(struct device *dev, char *buf, int nr)
223 struct sis5595_data *data = sis5595_update_device(dev);
224 return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr]));
227 static ssize_t show_in_max(struct device *dev, char *buf, int nr)
229 struct sis5595_data *data = sis5595_update_device(dev);
230 return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr]));
233 static ssize_t set_in_min(struct device *dev, const char *buf,
234 size_t count, int nr)
236 struct i2c_client *client = to_i2c_client(dev);
237 struct sis5595_data *data = i2c_get_clientdata(client);
238 unsigned long val = simple_strtoul(buf, NULL, 10);
240 down(&data->update_lock);
241 data->in_min[nr] = IN_TO_REG(val);
242 sis5595_write_value(client, SIS5595_REG_IN_MIN(nr), data->in_min[nr]);
243 up(&data->update_lock);
247 static ssize_t set_in_max(struct device *dev, const char *buf,
248 size_t count, int nr)
250 struct i2c_client *client = to_i2c_client(dev);
251 struct sis5595_data *data = i2c_get_clientdata(client);
252 unsigned long val = simple_strtoul(buf, NULL, 10);
254 down(&data->update_lock);
255 data->in_max[nr] = IN_TO_REG(val);
256 sis5595_write_value(client, SIS5595_REG_IN_MAX(nr), data->in_max[nr]);
257 up(&data->update_lock);
261 #define show_in_offset(offset) \
263 show_in##offset (struct device *dev, struct device_attribute *attr, char *buf) \
265 return show_in(dev, buf, offset); \
267 static DEVICE_ATTR(in##offset##_input, S_IRUGO, \
268 show_in##offset, NULL); \
270 show_in##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
272 return show_in_min(dev, buf, offset); \
275 show_in##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \
277 return show_in_max(dev, buf, offset); \
279 static ssize_t set_in##offset##_min (struct device *dev, struct device_attribute *attr, \
280 const char *buf, size_t count) \
282 return set_in_min(dev, buf, count, offset); \
284 static ssize_t set_in##offset##_max (struct device *dev, struct device_attribute *attr, \
285 const char *buf, size_t count) \
287 return set_in_max(dev, buf, count, offset); \
289 static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
290 show_in##offset##_min, set_in##offset##_min); \
291 static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
292 show_in##offset##_max, set_in##offset##_max);
301 static ssize_t show_temp(struct device *dev, struct device_attribute *attr, char *buf)
303 struct sis5595_data *data = sis5595_update_device(dev);
304 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp));
307 static ssize_t show_temp_over(struct device *dev, struct device_attribute *attr, char *buf)
309 struct sis5595_data *data = sis5595_update_device(dev);
310 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over));
313 static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
315 struct i2c_client *client = to_i2c_client(dev);
316 struct sis5595_data *data = i2c_get_clientdata(client);
317 long val = simple_strtol(buf, NULL, 10);
319 down(&data->update_lock);
320 data->temp_over = TEMP_TO_REG(val);
321 sis5595_write_value(client, SIS5595_REG_TEMP_OVER, data->temp_over);
322 up(&data->update_lock);
326 static ssize_t show_temp_hyst(struct device *dev, struct device_attribute *attr, char *buf)
328 struct sis5595_data *data = sis5595_update_device(dev);
329 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_hyst));
332 static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
334 struct i2c_client *client = to_i2c_client(dev);
335 struct sis5595_data *data = i2c_get_clientdata(client);
336 long val = simple_strtol(buf, NULL, 10);
338 down(&data->update_lock);
339 data->temp_hyst = TEMP_TO_REG(val);
340 sis5595_write_value(client, SIS5595_REG_TEMP_HYST, data->temp_hyst);
341 up(&data->update_lock);
345 static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL);
346 static DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR,
347 show_temp_over, set_temp_over);
348 static DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR,
349 show_temp_hyst, set_temp_hyst);
352 static ssize_t show_fan(struct device *dev, char *buf, int nr)
354 struct sis5595_data *data = sis5595_update_device(dev);
355 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr],
356 DIV_FROM_REG(data->fan_div[nr])) );
359 static ssize_t show_fan_min(struct device *dev, char *buf, int nr)
361 struct sis5595_data *data = sis5595_update_device(dev);
362 return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan_min[nr],
363 DIV_FROM_REG(data->fan_div[nr])) );
366 static ssize_t set_fan_min(struct device *dev, const char *buf,
367 size_t count, int nr)
369 struct i2c_client *client = to_i2c_client(dev);
370 struct sis5595_data *data = i2c_get_clientdata(client);
371 unsigned long val = simple_strtoul(buf, NULL, 10);
373 down(&data->update_lock);
374 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
375 sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]);
376 up(&data->update_lock);
380 static ssize_t show_fan_div(struct device *dev, char *buf, int nr)
382 struct sis5595_data *data = sis5595_update_device(dev);
383 return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr]) );
386 /* Note: we save and restore the fan minimum here, because its value is
387 determined in part by the fan divisor. This follows the principle of
388 least suprise; the user doesn't expect the fan minimum to change just
389 because the divisor changed. */
390 static ssize_t set_fan_div(struct device *dev, const char *buf,
391 size_t count, int nr)
393 struct i2c_client *client = to_i2c_client(dev);
394 struct sis5595_data *data = i2c_get_clientdata(client);
396 unsigned long val = simple_strtoul(buf, NULL, 10);
399 down(&data->update_lock);
400 min = FAN_FROM_REG(data->fan_min[nr],
401 DIV_FROM_REG(data->fan_div[nr]));
402 reg = sis5595_read_value(client, SIS5595_REG_FANDIV);
405 case 1: data->fan_div[nr] = 0; break;
406 case 2: data->fan_div[nr] = 1; break;
407 case 4: data->fan_div[nr] = 2; break;
408 case 8: data->fan_div[nr] = 3; break;
410 dev_err(&client->dev, "fan_div value %ld not "
411 "supported. Choose one of 1, 2, 4 or 8!\n", val);
412 up(&data->update_lock);
418 reg = (reg & 0xcf) | (data->fan_div[nr] << 4);
421 reg = (reg & 0x3f) | (data->fan_div[nr] << 6);
424 sis5595_write_value(client, SIS5595_REG_FANDIV, reg);
426 FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
427 sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]);
428 up(&data->update_lock);
432 #define show_fan_offset(offset) \
433 static ssize_t show_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
435 return show_fan(dev, buf, offset - 1); \
437 static ssize_t show_fan_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
439 return show_fan_min(dev, buf, offset - 1); \
441 static ssize_t show_fan_##offset##_div (struct device *dev, struct device_attribute *attr, char *buf) \
443 return show_fan_div(dev, buf, offset - 1); \
445 static ssize_t set_fan_##offset##_min (struct device *dev, struct device_attribute *attr, \
446 const char *buf, size_t count) \
448 return set_fan_min(dev, buf, count, offset - 1); \
450 static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL);\
451 static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
452 show_fan_##offset##_min, set_fan_##offset##_min);
457 static ssize_t set_fan_1_div(struct device *dev, struct device_attribute *attr, const char *buf,
460 return set_fan_div(dev, buf, count, 0) ;
463 static ssize_t set_fan_2_div(struct device *dev, struct device_attribute *attr, const char *buf,
466 return set_fan_div(dev, buf, count, 1) ;
468 static DEVICE_ATTR(fan1_div, S_IRUGO | S_IWUSR,
469 show_fan_1_div, set_fan_1_div);
470 static DEVICE_ATTR(fan2_div, S_IRUGO | S_IWUSR,
471 show_fan_2_div, set_fan_2_div);
474 static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
476 struct sis5595_data *data = sis5595_update_device(dev);
477 return sprintf(buf, "%d\n", data->alarms);
479 static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
481 /* This is called when the module is loaded */
482 static int sis5595_attach_adapter(struct i2c_adapter *adapter)
484 if (!(adapter->class & I2C_CLASS_HWMON))
486 return i2c_detect(adapter, &addr_data, sis5595_detect);
489 int sis5595_detect(struct i2c_adapter *adapter, int address, int kind)
493 struct i2c_client *new_client;
494 struct sis5595_data *data;
498 /* Make sure we are probing the ISA bus!! */
499 if (!i2c_is_isa_adapter(adapter))
503 address = force_addr & ~(SIS5595_EXTENT - 1);
504 /* Reserve the ISA region */
505 if (!request_region(address, SIS5595_EXTENT, sis5595_driver.name)) {
510 dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n", address);
511 if (PCIBIOS_SUCCESSFUL !=
512 pci_write_config_word(s_bridge, SIS5595_BASE_REG, address))
514 if (PCIBIOS_SUCCESSFUL !=
515 pci_read_config_word(s_bridge, SIS5595_BASE_REG, &a))
517 if ((a & ~(SIS5595_EXTENT - 1)) != address)
518 /* doesn't work for some chips? */
522 if (PCIBIOS_SUCCESSFUL !=
523 pci_read_config_byte(s_bridge, SIS5595_ENABLE_REG, &val)) {
526 if ((val & 0x80) == 0) {
527 if (PCIBIOS_SUCCESSFUL !=
528 pci_write_config_byte(s_bridge, SIS5595_ENABLE_REG,
531 if (PCIBIOS_SUCCESSFUL !=
532 pci_read_config_byte(s_bridge, SIS5595_ENABLE_REG, &val))
534 if ((val & 0x80) == 0)
535 /* doesn't work for some chips! */
539 if (!(data = kmalloc(sizeof(struct sis5595_data), GFP_KERNEL))) {
543 memset(data, 0, sizeof(struct sis5595_data));
545 new_client = &data->client;
546 new_client->addr = address;
547 init_MUTEX(&data->lock);
548 i2c_set_clientdata(new_client, data);
549 new_client->adapter = adapter;
550 new_client->driver = &sis5595_driver;
551 new_client->flags = 0;
553 /* Check revision and pin registers to determine whether 4 or 5 voltages */
554 pci_read_config_byte(s_bridge, SIS5595_REVISION_REG, &(data->revision));
555 /* 4 voltages, 1 temp */
557 if (data->revision >= REV2MIN) {
558 pci_read_config_byte(s_bridge, SIS5595_PIN_REG, &val);
560 /* 5 voltages, no temps */
564 /* Fill in the remaining client fields and put it into the global list */
565 strlcpy(new_client->name, "sis5595", I2C_NAME_SIZE);
568 init_MUTEX(&data->update_lock);
570 /* Tell the I2C layer a new client has arrived */
571 if ((err = i2c_attach_client(new_client)))
574 /* Initialize the SIS5595 chip */
575 sis5595_init_client(new_client);
577 /* A few vars need to be filled upon startup */
578 for (i = 0; i < 2; i++) {
579 data->fan_min[i] = sis5595_read_value(new_client,
580 SIS5595_REG_FAN_MIN(i));
583 /* Register sysfs hooks */
584 data->class_dev = hwmon_device_register(&new_client->dev);
585 if (IS_ERR(data->class_dev)) {
586 err = PTR_ERR(data->class_dev);
590 device_create_file(&new_client->dev, &dev_attr_in0_input);
591 device_create_file(&new_client->dev, &dev_attr_in0_min);
592 device_create_file(&new_client->dev, &dev_attr_in0_max);
593 device_create_file(&new_client->dev, &dev_attr_in1_input);
594 device_create_file(&new_client->dev, &dev_attr_in1_min);
595 device_create_file(&new_client->dev, &dev_attr_in1_max);
596 device_create_file(&new_client->dev, &dev_attr_in2_input);
597 device_create_file(&new_client->dev, &dev_attr_in2_min);
598 device_create_file(&new_client->dev, &dev_attr_in2_max);
599 device_create_file(&new_client->dev, &dev_attr_in3_input);
600 device_create_file(&new_client->dev, &dev_attr_in3_min);
601 device_create_file(&new_client->dev, &dev_attr_in3_max);
602 if (data->maxins == 4) {
603 device_create_file(&new_client->dev, &dev_attr_in4_input);
604 device_create_file(&new_client->dev, &dev_attr_in4_min);
605 device_create_file(&new_client->dev, &dev_attr_in4_max);
607 device_create_file(&new_client->dev, &dev_attr_fan1_input);
608 device_create_file(&new_client->dev, &dev_attr_fan1_min);
609 device_create_file(&new_client->dev, &dev_attr_fan1_div);
610 device_create_file(&new_client->dev, &dev_attr_fan2_input);
611 device_create_file(&new_client->dev, &dev_attr_fan2_min);
612 device_create_file(&new_client->dev, &dev_attr_fan2_div);
613 device_create_file(&new_client->dev, &dev_attr_alarms);
614 if (data->maxins == 3) {
615 device_create_file(&new_client->dev, &dev_attr_temp1_input);
616 device_create_file(&new_client->dev, &dev_attr_temp1_max);
617 device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst);
622 i2c_detach_client(new_client);
626 release_region(address, SIS5595_EXTENT);
631 static int sis5595_detach_client(struct i2c_client *client)
633 struct sis5595_data *data = i2c_get_clientdata(client);
636 hwmon_device_unregister(data->class_dev);
638 if ((err = i2c_detach_client(client))) {
639 dev_err(&client->dev,
640 "Client deregistration failed, client not detached.\n");
644 if (i2c_is_isa_client(client))
645 release_region(client->addr, SIS5595_EXTENT);
653 /* ISA access must be locked explicitly. */
654 static int sis5595_read_value(struct i2c_client *client, u8 reg)
658 struct sis5595_data *data = i2c_get_clientdata(client);
660 outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET);
661 res = inb_p(client->addr + SIS5595_DATA_REG_OFFSET);
666 static int sis5595_write_value(struct i2c_client *client, u8 reg, u8 value)
668 struct sis5595_data *data = i2c_get_clientdata(client);
670 outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET);
671 outb_p(value, client->addr + SIS5595_DATA_REG_OFFSET);
676 /* Called when we have found a new SIS5595. */
677 static void sis5595_init_client(struct i2c_client *client)
679 u8 config = sis5595_read_value(client, SIS5595_REG_CONFIG);
680 if (!(config & 0x01))
681 sis5595_write_value(client, SIS5595_REG_CONFIG,
682 (config & 0xf7) | 0x01);
685 static struct sis5595_data *sis5595_update_device(struct device *dev)
687 struct i2c_client *client = to_i2c_client(dev);
688 struct sis5595_data *data = i2c_get_clientdata(client);
691 down(&data->update_lock);
693 if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
696 for (i = 0; i <= data->maxins; i++) {
698 sis5595_read_value(client, SIS5595_REG_IN(i));
700 sis5595_read_value(client,
701 SIS5595_REG_IN_MIN(i));
703 sis5595_read_value(client,
704 SIS5595_REG_IN_MAX(i));
706 for (i = 0; i < 2; i++) {
708 sis5595_read_value(client, SIS5595_REG_FAN(i));
710 sis5595_read_value(client,
711 SIS5595_REG_FAN_MIN(i));
713 if (data->maxins == 3) {
715 sis5595_read_value(client, SIS5595_REG_TEMP);
717 sis5595_read_value(client, SIS5595_REG_TEMP_OVER);
719 sis5595_read_value(client, SIS5595_REG_TEMP_HYST);
721 i = sis5595_read_value(client, SIS5595_REG_FANDIV);
722 data->fan_div[0] = (i >> 4) & 0x03;
723 data->fan_div[1] = i >> 6;
725 sis5595_read_value(client, SIS5595_REG_ALARM1) |
726 (sis5595_read_value(client, SIS5595_REG_ALARM2) << 8);
727 data->last_updated = jiffies;
731 up(&data->update_lock);
736 static struct pci_device_id sis5595_pci_ids[] = {
737 { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503) },
741 MODULE_DEVICE_TABLE(pci, sis5595_pci_ids);
743 static int blacklist[] __devinitdata = {
744 PCI_DEVICE_ID_SI_540,
745 PCI_DEVICE_ID_SI_550,
746 PCI_DEVICE_ID_SI_630,
747 PCI_DEVICE_ID_SI_645,
748 PCI_DEVICE_ID_SI_730,
749 PCI_DEVICE_ID_SI_735,
750 PCI_DEVICE_ID_SI_5511, /* 5513 chip has the 0008 device but
751 that ID shows up in other chips so we
752 use the 5511 ID for recognition */
753 PCI_DEVICE_ID_SI_5597,
754 PCI_DEVICE_ID_SI_5598,
757 static int __devinit sis5595_pci_probe(struct pci_dev *dev,
758 const struct pci_device_id *id)
764 for (i = blacklist; *i != 0; i++) {
766 dev = pci_get_device(PCI_VENDOR_ID_SI, *i, NULL);
768 dev_err(&dev->dev, "Looked for SIS5595 but found unsupported device %.4x\n", *i);
774 if (PCIBIOS_SUCCESSFUL !=
775 pci_read_config_word(dev, SIS5595_BASE_REG, &val))
778 addr = val & ~(SIS5595_EXTENT - 1);
779 if (addr == 0 && force_addr == 0) {
780 dev_err(&dev->dev, "Base address not set - upgrade BIOS or use force_addr=0xaddr\n");
784 addr = force_addr; /* so detect will get called */
787 dev_err(&dev->dev,"No SiS 5595 sensors found.\n");
790 normal_isa[0] = addr;
792 s_bridge = pci_dev_get(dev);
793 if (i2c_add_driver(&sis5595_driver)) {
794 pci_dev_put(s_bridge);
798 /* Always return failure here. This is to allow other drivers to bind
799 * to this pci device. We don't really want to have control over the
800 * pci device, we only wanted to read as few register values from it.
805 static struct pci_driver sis5595_pci_driver = {
807 .id_table = sis5595_pci_ids,
808 .probe = sis5595_pci_probe,
811 static int __init sm_sis5595_init(void)
813 return pci_register_driver(&sis5595_pci_driver);
816 static void __exit sm_sis5595_exit(void)
818 pci_unregister_driver(&sis5595_pci_driver);
819 if (s_bridge != NULL) {
820 i2c_del_driver(&sis5595_driver);
821 pci_dev_put(s_bridge);
826 MODULE_AUTHOR("Aurelien Jarno <aurelien@aurel32.net>");
827 MODULE_DESCRIPTION("SiS 5595 Sensor device");
828 MODULE_LICENSE("GPL");
830 module_init(sm_sis5595_init);
831 module_exit(sm_sis5595_exit);