pc87360.c (fde0950903ce8cc38a91dd095280decceda2ff82) | pc87360.c (2d8672c5a6ba0d3f1d8d3ad61ef67868941364f0) |
---|---|
1/* 2 * pc87360.c - Part of lm_sensors, Linux kernel modules 3 * for hardware monitoring 4 * Copyright (C) 2004 Jean Delvare <khali@linux-fr.org> 5 * 6 * Copied from smsc47m1.c: 7 * Copyright (C) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com> 8 * --- 25 unchanged lines hidden (view full) --- 34 */ 35 36#include <linux/module.h> 37#include <linux/init.h> 38#include <linux/slab.h> 39#include <linux/jiffies.h> 40#include <linux/i2c.h> 41#include <linux/i2c-isa.h> | 1/* 2 * pc87360.c - Part of lm_sensors, Linux kernel modules 3 * for hardware monitoring 4 * Copyright (C) 2004 Jean Delvare <khali@linux-fr.org> 5 * 6 * Copied from smsc47m1.c: 7 * Copyright (C) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com> 8 * --- 25 unchanged lines hidden (view full) --- 34 */ 35 36#include <linux/module.h> 37#include <linux/init.h> 38#include <linux/slab.h> 39#include <linux/jiffies.h> 40#include <linux/i2c.h> 41#include <linux/i2c-isa.h> |
42#include <linux/i2c-sensor.h> | |
43#include <linux/i2c-vid.h> 44#include <linux/hwmon.h> 45#include <linux/err.h> 46#include <asm/io.h> 47 | 42#include <linux/i2c-vid.h> 43#include <linux/hwmon.h> 44#include <linux/err.h> 45#include <asm/io.h> 46 |
48static unsigned short normal_i2c[] = { I2C_CLIENT_END }; 49static unsigned int normal_isa[] = { 0, I2C_CLIENT_ISA_END }; 50static struct i2c_force_data forces[] = {{ NULL }}; | |
51static u8 devid; | 47static u8 devid; |
52static unsigned int extra_isa[3]; | 48static unsigned short address; 49static unsigned short extra_isa[3]; |
53static u8 confreg[4]; 54 55enum chips { any_chip, pc87360, pc87363, pc87364, pc87365, pc87366 }; | 50static u8 confreg[4]; 51 52enum chips { any_chip, pc87360, pc87363, pc87364, pc87365, pc87366 }; |
56static struct i2c_address_data addr_data = { 57 .normal_i2c = normal_i2c, 58 .normal_isa = normal_isa, 59 .forces = forces, 60}; | |
61 62static int init = 1; 63module_param(init, int, 0); 64MODULE_PARM_DESC(init, 65 "Chip initialization level:\n" 66 " 0: None\n" 67 "*1: Forcibly enable internal voltage and temperature channels, except in9\n" 68 " 2: Forcibly enable all voltage and temperature channels, except in9\n" --- 154 unchanged lines hidden (view full) --- 223 u8 temp_status[3]; /* Register value */ 224 u8 temp_alarms; /* Register value, masked */ 225}; 226 227/* 228 * Functions declaration 229 */ 230 | 53 54static int init = 1; 55module_param(init, int, 0); 56MODULE_PARM_DESC(init, 57 "Chip initialization level:\n" 58 " 0: None\n" 59 "*1: Forcibly enable internal voltage and temperature channels, except in9\n" 60 " 2: Forcibly enable all voltage and temperature channels, except in9\n" --- 154 unchanged lines hidden (view full) --- 215 u8 temp_status[3]; /* Register value */ 216 u8 temp_alarms; /* Register value, masked */ 217}; 218 219/* 220 * Functions declaration 221 */ 222 |
231static int pc87360_attach_adapter(struct i2c_adapter *adapter); 232static int pc87360_detect(struct i2c_adapter *adapter, int address, int kind); | 223static int pc87360_detect(struct i2c_adapter *adapter); |
233static int pc87360_detach_client(struct i2c_client *client); 234 235static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank, 236 u8 reg); 237static void pc87360_write_value(struct pc87360_data *data, u8 ldi, u8 bank, 238 u8 reg, u8 value); 239static void pc87360_init_client(struct i2c_client *client, int use_thermistors); 240static struct pc87360_data *pc87360_update_device(struct device *dev); 241 242/* 243 * Driver data (common to all clients) 244 */ 245 246static struct i2c_driver pc87360_driver = { 247 .owner = THIS_MODULE, 248 .name = "pc87360", | 224static int pc87360_detach_client(struct i2c_client *client); 225 226static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank, 227 u8 reg); 228static void pc87360_write_value(struct pc87360_data *data, u8 ldi, u8 bank, 229 u8 reg, u8 value); 230static void pc87360_init_client(struct i2c_client *client, int use_thermistors); 231static struct pc87360_data *pc87360_update_device(struct device *dev); 232 233/* 234 * Driver data (common to all clients) 235 */ 236 237static struct i2c_driver pc87360_driver = { 238 .owner = THIS_MODULE, 239 .name = "pc87360", |
249 .flags = I2C_DF_NOTIFY, 250 .attach_adapter = pc87360_attach_adapter, | 240 .attach_adapter = pc87360_detect, |
251 .detach_client = pc87360_detach_client, 252}; 253 254/* 255 * Sysfs stuff 256 */ 257 258static ssize_t set_fan_min(struct device *dev, const char *buf, --- 372 unchanged lines hidden (view full) --- 631 return sprintf(buf, "%u\n", data->temp_alarms); 632} 633static DEVICE_ATTR(alarms_temp, S_IRUGO, show_temp_alarms, NULL); 634 635/* 636 * Device detection, registration and update 637 */ 638 | 241 .detach_client = pc87360_detach_client, 242}; 243 244/* 245 * Sysfs stuff 246 */ 247 248static ssize_t set_fan_min(struct device *dev, const char *buf, --- 372 unchanged lines hidden (view full) --- 621 return sprintf(buf, "%u\n", data->temp_alarms); 622} 623static DEVICE_ATTR(alarms_temp, S_IRUGO, show_temp_alarms, NULL); 624 625/* 626 * Device detection, registration and update 627 */ 628 |
639static int pc87360_attach_adapter(struct i2c_adapter *adapter) | 629static int pc87360_find(int sioaddr, u8 *devid, unsigned short *addresses) |
640{ | 630{ |
641 return i2c_detect(adapter, &addr_data, pc87360_detect); 642} 643 644static int pc87360_find(int sioaddr, u8 *devid, int *address) 645{ | |
646 u16 val; 647 int i; 648 int nrdev; /* logical device count */ 649 650 /* No superio_enter */ 651 652 /* Identify device */ 653 val = superio_inb(sioaddr, DEVID); --- 28 unchanged lines hidden (view full) --- 682 val = (superio_inb(sioaddr, BASE) << 8) 683 | superio_inb(sioaddr, BASE + 1); 684 if (!val) { 685 printk(KERN_INFO "pc87360: Base address not set for " 686 "device 0x%02x\n", logdev[i]); 687 continue; 688 } 689 | 631 u16 val; 632 int i; 633 int nrdev; /* logical device count */ 634 635 /* No superio_enter */ 636 637 /* Identify device */ 638 val = superio_inb(sioaddr, DEVID); --- 28 unchanged lines hidden (view full) --- 667 val = (superio_inb(sioaddr, BASE) << 8) 668 | superio_inb(sioaddr, BASE + 1); 669 if (!val) { 670 printk(KERN_INFO "pc87360: Base address not set for " 671 "device 0x%02x\n", logdev[i]); 672 continue; 673 } 674 |
690 address[i] = val; | 675 addresses[i] = val; |
691 692 if (i==0) { /* Fans */ 693 confreg[0] = superio_inb(sioaddr, 0xF0); 694 confreg[1] = superio_inb(sioaddr, 0xF1); 695 696#ifdef DEBUG 697 printk(KERN_DEBUG "pc87360: Fan 1: mon=%d " 698 "ctrl=%d inv=%d\n", (confreg[0]>>2)&1, --- 27 unchanged lines hidden (view full) --- 726 } 727 } 728 } 729 730 superio_exit(sioaddr); 731 return 0; 732} 733 | 676 677 if (i==0) { /* Fans */ 678 confreg[0] = superio_inb(sioaddr, 0xF0); 679 confreg[1] = superio_inb(sioaddr, 0xF1); 680 681#ifdef DEBUG 682 printk(KERN_DEBUG "pc87360: Fan 1: mon=%d " 683 "ctrl=%d inv=%d\n", (confreg[0]>>2)&1, --- 27 unchanged lines hidden (view full) --- 711 } 712 } 713 } 714 715 superio_exit(sioaddr); 716 return 0; 717} 718 |
734/* We don't really care about the address. 735 Read from extra_isa instead. */ 736int pc87360_detect(struct i2c_adapter *adapter, int address, int kind) | 719static int pc87360_detect(struct i2c_adapter *adapter) |
737{ 738 int i; 739 struct i2c_client *new_client; 740 struct pc87360_data *data; 741 int err = 0; 742 const char *name = "pc87360"; 743 int use_thermistors = 0; 744 | 720{ 721 int i; 722 struct i2c_client *new_client; 723 struct pc87360_data *data; 724 int err = 0; 725 const char *name = "pc87360"; 726 int use_thermistors = 0; 727 |
745 if (!i2c_is_isa_adapter(adapter)) 746 return -ENODEV; 747 | |
748 if (!(data = kmalloc(sizeof(struct pc87360_data), GFP_KERNEL))) 749 return -ENOMEM; 750 memset(data, 0x00, sizeof(struct pc87360_data)); 751 752 new_client = &data->client; 753 i2c_set_clientdata(new_client, data); 754 new_client->addr = address; 755 init_MUTEX(&data->lock); --- 573 unchanged lines hidden (view full) --- 1329 printk(KERN_WARNING "pc87360: PC8736x not detected, " 1330 "module not inserted.\n"); 1331 return -ENODEV; 1332 } 1333 1334 /* Arbitrarily pick one of the addresses */ 1335 for (i = 0; i < 3; i++) { 1336 if (extra_isa[i] != 0x0000) { | 728 if (!(data = kmalloc(sizeof(struct pc87360_data), GFP_KERNEL))) 729 return -ENOMEM; 730 memset(data, 0x00, sizeof(struct pc87360_data)); 731 732 new_client = &data->client; 733 i2c_set_clientdata(new_client, data); 734 new_client->addr = address; 735 init_MUTEX(&data->lock); --- 573 unchanged lines hidden (view full) --- 1309 printk(KERN_WARNING "pc87360: PC8736x not detected, " 1310 "module not inserted.\n"); 1311 return -ENODEV; 1312 } 1313 1314 /* Arbitrarily pick one of the addresses */ 1315 for (i = 0; i < 3; i++) { 1316 if (extra_isa[i] != 0x0000) { |
1337 normal_isa[0] = extra_isa[i]; | 1317 address = extra_isa[i]; |
1338 break; 1339 } 1340 } 1341 | 1318 break; 1319 } 1320 } 1321 |
1342 if (normal_isa[0] == 0x0000) { | 1322 if (address == 0x0000) { |
1343 printk(KERN_WARNING "pc87360: No active logical device, " 1344 "module not inserted.\n"); 1345 return -ENODEV; 1346 } 1347 1348 return i2c_isa_add_driver(&pc87360_driver); 1349} 1350 --- 12 unchanged lines hidden --- | 1323 printk(KERN_WARNING "pc87360: No active logical device, " 1324 "module not inserted.\n"); 1325 return -ENODEV; 1326 } 1327 1328 return i2c_isa_add_driver(&pc87360_driver); 1329} 1330 --- 12 unchanged lines hidden --- |