sis5595.c (fde0950903ce8cc38a91dd095280decceda2ff82) | sis5595.c (2d8672c5a6ba0d3f1d8d3ad61ef67868941364f0) |
---|---|
1/* 2 sis5595.c - Part of lm_sensors, Linux kernel modules 3 for hardware monitoring 4 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 --- 57 unchanged lines hidden (view full) --- 66 67/* If force_addr is set to anything different from 0, we forcibly enable 68 the device at the given address. */ 69static u16 force_addr; 70module_param(force_addr, ushort, 0); 71MODULE_PARM_DESC(force_addr, 72 "Initialize the base address of the sensors"); 73 | 1/* 2 sis5595.c - Part of lm_sensors, Linux kernel modules 3 for hardware monitoring 4 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 --- 57 unchanged lines hidden (view full) --- 66 67/* If force_addr is set to anything different from 0, we forcibly enable 68 the device at the given address. */ 69static u16 force_addr; 70module_param(force_addr, ushort, 0); 71MODULE_PARM_DESC(force_addr, 72 "Initialize the base address of the sensors"); 73 |
74/* Addresses to scan. | 74/* Device address |
75 Note that we can't determine the ISA address until we have initialized 76 our module */ | 75 Note that we can't determine the ISA address until we have initialized 76 our module */ |
77static unsigned short normal_i2c[] = { I2C_CLIENT_END }; 78static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END }; | 77static unsigned short address; |
79 | 78 |
80/* Insmod parameters */ 81SENSORS_INSMOD_1(sis5595); 82 | |
83/* Many SIS5595 constants specified below */ 84 85/* Length of ISA address segment */ 86#define SIS5595_EXTENT 8 87/* PCI Config Registers */ 88#define SIS5595_REVISION_REG 0x08 89#define SIS5595_BASE_REG 0x68 90#define SIS5595_PIN_REG 0x7A --- 98 unchanged lines hidden (view full) --- 189 s8 temp_over; /* Register value */ 190 s8 temp_hyst; /* Register value */ 191 u8 fan_div[2]; /* Register encoding, shifted right */ 192 u16 alarms; /* Register encoding, combined */ 193}; 194 195static struct pci_dev *s_bridge; /* pointer to the (only) sis5595 */ 196 | 79/* Many SIS5595 constants specified below */ 80 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 --- 98 unchanged lines hidden (view full) --- 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 */ 189}; 190 191static struct pci_dev *s_bridge; /* pointer to the (only) sis5595 */ 192 |
197static int sis5595_attach_adapter(struct i2c_adapter *adapter); 198static int sis5595_detect(struct i2c_adapter *adapter, int address, int kind); | 193static int sis5595_detect(struct i2c_adapter *adapter); |
199static int sis5595_detach_client(struct i2c_client *client); 200 201static int sis5595_read_value(struct i2c_client *client, u8 register); 202static int sis5595_write_value(struct i2c_client *client, u8 register, u8 value); 203static struct sis5595_data *sis5595_update_device(struct device *dev); 204static void sis5595_init_client(struct i2c_client *client); 205 206static struct i2c_driver sis5595_driver = { 207 .owner = THIS_MODULE, 208 .name = "sis5595", | 194static int sis5595_detach_client(struct i2c_client *client); 195 196static int sis5595_read_value(struct i2c_client *client, u8 register); 197static int sis5595_write_value(struct i2c_client *client, u8 register, u8 value); 198static struct sis5595_data *sis5595_update_device(struct device *dev); 199static void sis5595_init_client(struct i2c_client *client); 200 201static struct i2c_driver sis5595_driver = { 202 .owner = THIS_MODULE, 203 .name = "sis5595", |
209 .id = I2C_DRIVERID_SIS5595, 210 .flags = I2C_DF_NOTIFY, 211 .attach_adapter = sis5595_attach_adapter, | 204 .attach_adapter = sis5595_detect, |
212 .detach_client = sis5595_detach_client, 213}; 214 215/* 4 Voltages */ 216static ssize_t show_in(struct device *dev, char *buf, int nr) 217{ 218 struct sis5595_data *data = sis5595_update_device(dev); 219 return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr])); --- 255 unchanged lines hidden (view full) --- 475static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) 476{ 477 struct sis5595_data *data = sis5595_update_device(dev); 478 return sprintf(buf, "%d\n", data->alarms); 479} 480static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 481 482/* This is called when the module is loaded */ | 205 .detach_client = sis5595_detach_client, 206}; 207 208/* 4 Voltages */ 209static ssize_t show_in(struct device *dev, char *buf, int nr) 210{ 211 struct sis5595_data *data = sis5595_update_device(dev); 212 return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr])); --- 255 unchanged lines hidden (view full) --- 468static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) 469{ 470 struct sis5595_data *data = sis5595_update_device(dev); 471 return sprintf(buf, "%d\n", data->alarms); 472} 473static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 474 475/* This is called when the module is loaded */ |
483static int sis5595_attach_adapter(struct i2c_adapter *adapter) | 476static int sis5595_detect(struct i2c_adapter *adapter) |
484{ | 477{ |
485 if (!(adapter->class & I2C_CLASS_HWMON)) 486 return 0; 487 return i2c_detect(adapter, &addr_data, sis5595_detect); 488} 489 490int sis5595_detect(struct i2c_adapter *adapter, int address, int kind) 491{ | |
492 int err = 0; 493 int i; 494 struct i2c_client *new_client; 495 struct sis5595_data *data; 496 char val; 497 u16 a; 498 | 478 int err = 0; 479 int i; 480 struct i2c_client *new_client; 481 struct sis5595_data *data; 482 char val; 483 u16 a; 484 |
499 /* Make sure we are probing the ISA bus!! */ 500 if (!i2c_is_isa_adapter(adapter)) 501 goto exit; 502 | |
503 if (force_addr) 504 address = force_addr & ~(SIS5595_EXTENT - 1); 505 /* Reserve the ISA region */ 506 if (!request_region(address, SIS5595_EXTENT, sis5595_driver.name)) { 507 err = -EBUSY; 508 goto exit; 509 } 510 if (force_addr) { --- 126 unchanged lines hidden (view full) --- 637 hwmon_device_unregister(data->class_dev); 638 639 if ((err = i2c_detach_client(client))) { 640 dev_err(&client->dev, 641 "Client deregistration failed, client not detached.\n"); 642 return err; 643 } 644 | 485 if (force_addr) 486 address = force_addr & ~(SIS5595_EXTENT - 1); 487 /* Reserve the ISA region */ 488 if (!request_region(address, SIS5595_EXTENT, sis5595_driver.name)) { 489 err = -EBUSY; 490 goto exit; 491 } 492 if (force_addr) { --- 126 unchanged lines hidden (view full) --- 619 hwmon_device_unregister(data->class_dev); 620 621 if ((err = i2c_detach_client(client))) { 622 dev_err(&client->dev, 623 "Client deregistration failed, client not detached.\n"); 624 return err; 625 } 626 |
645 if (i2c_is_isa_client(client)) 646 release_region(client->addr, SIS5595_EXTENT); | 627 release_region(client->addr, SIS5595_EXTENT); |
647 648 kfree(data); 649 650 return 0; 651} 652 653 654/* ISA access must be locked explicitly. */ --- 100 unchanged lines hidden (view full) --- 755 PCI_DEVICE_ID_SI_5598, 756 0 }; 757 758static int __devinit sis5595_pci_probe(struct pci_dev *dev, 759 const struct pci_device_id *id) 760{ 761 u16 val; 762 int *i; | 628 629 kfree(data); 630 631 return 0; 632} 633 634 635/* ISA access must be locked explicitly. */ --- 100 unchanged lines hidden (view full) --- 736 PCI_DEVICE_ID_SI_5598, 737 0 }; 738 739static int __devinit sis5595_pci_probe(struct pci_dev *dev, 740 const struct pci_device_id *id) 741{ 742 u16 val; 743 int *i; |
763 int addr = 0; | |
764 765 for (i = blacklist; *i != 0; i++) { 766 struct pci_dev *dev; 767 dev = pci_get_device(PCI_VENDOR_ID_SI, *i, NULL); 768 if (dev) { 769 dev_err(&dev->dev, "Looked for SIS5595 but found unsupported device %.4x\n", *i); 770 pci_dev_put(dev); 771 return -ENODEV; 772 } 773 } 774 775 if (PCIBIOS_SUCCESSFUL != 776 pci_read_config_word(dev, SIS5595_BASE_REG, &val)) 777 return -ENODEV; 778 | 744 745 for (i = blacklist; *i != 0; i++) { 746 struct pci_dev *dev; 747 dev = pci_get_device(PCI_VENDOR_ID_SI, *i, NULL); 748 if (dev) { 749 dev_err(&dev->dev, "Looked for SIS5595 but found unsupported device %.4x\n", *i); 750 pci_dev_put(dev); 751 return -ENODEV; 752 } 753 } 754 755 if (PCIBIOS_SUCCESSFUL != 756 pci_read_config_word(dev, SIS5595_BASE_REG, &val)) 757 return -ENODEV; 758 |
779 addr = val & ~(SIS5595_EXTENT - 1); 780 if (addr == 0 && force_addr == 0) { | 759 address = val & ~(SIS5595_EXTENT - 1); 760 if (address == 0 && force_addr == 0) { |
781 dev_err(&dev->dev, "Base address not set - upgrade BIOS or use force_addr=0xaddr\n"); 782 return -ENODEV; 783 } | 761 dev_err(&dev->dev, "Base address not set - upgrade BIOS or use force_addr=0xaddr\n"); 762 return -ENODEV; 763 } |
784 if (force_addr) 785 addr = force_addr; /* so detect will get called */ | |
786 | 764 |
787 if (!addr) { | 765 if (!address) { |
788 dev_err(&dev->dev,"No SiS 5595 sensors found.\n"); 789 return -ENODEV; 790 } | 766 dev_err(&dev->dev,"No SiS 5595 sensors found.\n"); 767 return -ENODEV; 768 } |
791 normal_isa[0] = addr; | |
792 793 s_bridge = pci_dev_get(dev); 794 if (i2c_isa_add_driver(&sis5595_driver)) { 795 pci_dev_put(s_bridge); 796 s_bridge = NULL; 797 } 798 799 /* Always return failure here. This is to allow other drivers to bind --- 33 unchanged lines hidden --- | 769 770 s_bridge = pci_dev_get(dev); 771 if (i2c_isa_add_driver(&sis5595_driver)) { 772 pci_dev_put(s_bridge); 773 s_bridge = NULL; 774 } 775 776 /* Always return failure here. This is to allow other drivers to bind --- 33 unchanged lines hidden --- |