Changeset 963

Show
Ignore:
Timestamp:
12/22/00 20:26:21 (12 years ago)
Author:
phil
Message:

(Phil) Wrapped Serverworks OSB4 support into i2c-piix4.c (briefly tested
on both platforms). LM87 support is very far along, and should work
for a majority of users, but some minor tweaks are still on the to-do list.

Location:
lm-sensors/trunk
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/kernel/busses/i2c-piix4.c

    r949 r963  
    3434 
    3535#include <linux/init.h> 
     36 
     37/* Note: Since the ServerWorks OSB4 SMBus host interface is identical 
     38         to the Intel PIIX4's, we only mention it during detection.   */ 
     39 
     40#ifndef PCI_DEVICE_ID_SERVERWORKS_OSB4 
     41#define PCI_DEVICE_ID_SERVERWORKS_OSB4 0x0200 
     42#endif 
     43 
     44#ifndef PCI_VENDOR_ID_SERVERWORKS 
     45#define PCI_VENDOR_ID_SERVERWORKS 0x01166 
     46#endif 
     47 
    3648 
    3749/* PIIX4 SMBus address offsets */ 
     
    130142static int __initdata piix4_initialized; 
    131143static unsigned short piix4_smba = 0; 
    132  
     144static kind = 0; 
    133145 
    134146/* Detect whether a PIIX4 can be found, and initialize it, where necessary. 
     
    150162        } 
    151163 
    152         /* Look for the PIIX4, function 3 */ 
    153         /* Note: we keep on searching until we have found 'function 3' */ 
     164        /* Look for the PIIX4, function 3 or Serverworks PSB4 func 0          */ 
     165        /* Note: we keep on searching until we have found the proper function */ 
    154166        PIIX4_dev = NULL; 
    155         do 
     167        PIIX4_dev = pci_find_device(PCI_VENDOR_ID_SERVERWORKS, 
     168                                    PCI_DEVICE_ID_SERVERWORKS_OSB4, 
     169                                    PIIX4_dev); 
     170        while (PIIX4_dev && (PCI_FUNC(PIIX4_dev->devfn) != 0)); 
     171        if (PIIX4_dev == NULL) { 
    156172                PIIX4_dev = pci_find_device(PCI_VENDOR_ID_INTEL, 
    157173                                            PCI_DEVICE_ID_INTEL_82371AB_3, 
    158174                                            PIIX4_dev); 
    159         while (PIIX4_dev && (PCI_FUNC(PIIX4_dev->devfn) != 3)); 
    160         if (PIIX4_dev == NULL) { 
    161                 printk 
    162                     ("i2c-piix4.o: Error: Can't detect PIIX4, function 3!\n"); 
    163                 error_return = -ENODEV; 
    164                 goto END; 
    165         } 
     175                while (PIIX4_dev && (PCI_FUNC(PIIX4_dev->devfn) != 3)); 
     176                if (PIIX4_dev == NULL) { 
     177                 printk 
     178                  ("i2c-piix4.o: Error: Can't detect PIIX4 function 3 nor OSB4 function 0!\n"); 
     179                 error_return = -ENODEV; 
     180                 goto END; 
     181                } else { kind=1; /* Intel PIIX4 found */ } 
     182        } else { kind=2; /* Serverworks OSB4 found */ } 
     183 
    166184 
    167185/* Determine the address of the SMBus areas */ 
     
    215233 
    216234        /* Everything is happy, let's grab the memory and set things up. */ 
    217         request_region(piix4_smba, 8, "piix4-smbus"); 
     235        request_region(piix4_smba, 8, kind==1?"piix4-smbus":"osb4-smbus"); 
    218236 
    219237#ifdef DEBUG 
     
    451469{ 
    452470        int res; 
    453         printk("i2c-piix4.o version %s (%s)\n", LM_VERSION, LM_DATE); 
    454 #ifdef DEBUG 
    455 /* PE- It might be good to make this a permanent part of the code! */ 
     471        printk("piix4.o version %s (%s)\n", LM_VERSION, LM_DATE); 
    456472        if (piix4_initialized) { 
    457473                printk 
     
    459475                return -EBUSY; 
    460476        } 
    461 #endif 
    462477        piix4_initialized = 0; 
    463478        if ((res = piix4_setup())) { 
     
    468483        } 
    469484        piix4_initialized++; 
    470         sprintf(piix4_adapter.name, "SMBus PIIX4 adapter at %04x", 
     485        sprintf(piix4_adapter.name, kind==1?"SMBus PIIX4 adapter at %04x":"SMBus OSB4 adapter at %04x", 
    471486                piix4_smba); 
    472487        if ((res = i2c_add_adapter(&piix4_adapter))) { 
  • lm-sensors/trunk/kernel/chips/lm87.c

    r958 r963  
    11/* 
    2     lm87.c - Part of lm_sensors, Linux kernel modules for hardware 
     2    LM87.c - Part of lm_sensors, Linux kernel modules for hardware 
    33             monitoring 
    44    Copyright (c) 2000  Frodo Looijaard <frodol@dds.nl> 
     
    3838#include <linux/init.h> 
    3939 
     40 
     41/*  Chip configuration settings.  These should be set to reflect 
     42the HARDWARE configuration of your chip.  By default (read: when all  
     43of these are left zero), this driver assumes that the configuration 
     44is the same as National's defaults for the Channel Mode register. 
     45 
     46Set to '1' the appropriate defines, as nessesary: 
     47 
     48 - External temp sensors 2 (possible second CPU temp) 
     49   This will disable the 2.5V and Vccp2 readings. 
     50   Ironicly, National decided that you can read the 
     51   temperature of a second CPU or it's core voltage, 
     52   but not both!  Comment out if FAULT is reported.  */ 
     53 
     54/* #define LM87_EXT2 1 */ 
     55 
     56/* Aux analog input. When enabled, the Fan 1 reading  
     57   will be disabled */ 
     58 
     59/* #define LM87_AIN1 1 */ 
     60 
     61/* Aux analog input 2. When enabled, the Fan 2 reading  
     62   will be disabled */ 
     63 
     64/* #define LM87_AIN2 1 */ 
     65 
     66/* Internal Vcc is 5V instead of 3.3V */ 
     67 
     68/* #define LM87_5V_VCC 1 */ 
     69 
     70/* That's the end of the hardware config defines.  I would have made 
     71   them insmod params, but it would be too much work. ;') */ 
     72 
     73 
    4074#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18)) || \ 
    4175    (LINUX_VERSION_CODE == KERNEL_VERSION(2,3,0)) 
     
    4983/* Addresses to scan */ 
    5084static unsigned short normal_i2c[] = { SENSORS_I2C_END }; 
    51 static unsigned short normal_i2c_range[] = { 0x2c, 0x2e, SENSORS_I2C_END }; 
     85static unsigned short normal_i2c_range[] = { 0x2c, 0x2f, SENSORS_I2C_END }; 
    5286static unsigned int normal_isa[] = { SENSORS_ISA_END }; 
    5387static unsigned int normal_isa_range[] = { SENSORS_ISA_END }; 
    5488 
    5589/* Insmod parameters */ 
    56 SENSORS_INSMOD_1(lm87); 
     90SENSORS_INSMOD_1(LM87); 
    5791 
    5892/* The following is the calculation for the register offset 
    5993 * for the monitored items minimum and maximum locations. 
    6094 */ 
    61 #define LM87_REG_IN_MAX(nr) (0x2b + (nr) * 2) 
    62 #define LM87_REG_IN_MIN(nr) (0x2c + (nr) * 2) 
     95#define LM87_REG_IN_MAX(nr) (0x2b + ((nr) * 2)) 
     96#define LM87_REG_IN_MIN(nr) (0x2c + ((nr) * 2)) 
    6397#define LM87_REG_IN(nr) (0x20 + (nr)) 
    64  
    65 #define AIN1     0 
    66 #define VCCP1    1 
    67 #define VCCP2    5 
    6898 
    6999/* Initial limits */ 
     
    84114 
    85115      /* These are all read-only */ 
    86 #define LM87_REG_2_5V_EXT_TEMP_2         0x20  /* front ambient for us */ 
    87 #define LM87_REG_VCCP1                   0x21  /* CPU core voltage */ 
     116#define LM87_REG_2_5V_EXT_TEMP_2         0x20 
     117#define LM87_REG_VCCP1                   0x21 
    88118#define LM87_REG_3_3V                    0x22   
    89119#define LM87_REG_5V                      0x23 
    90120#define LM87_REG_12V                     0x24 
    91121#define LM87_REG_VCCP2                   0x25 
    92 #define LM87_REG_EXT_TEMP_1              0x26  /* CPU temp for us */ 
     122#define LM87_REG_EXT_TEMP_1              0x26 
    93123#define LM87_REG_INT_TEMP                0x27  /* LM87 temp. */ 
    94 #define LM87_REG_FAN1_AIN1               0x28  /* this is AIN: 2.5V monitored */ 
     124#define LM87_REG_FAN1_AIN1               0x28 
    95125#define LM87_REG_FAN2_AIN2               0x29 
    96126 
    97127/* These are read/write */ 
     128#define LM87_REG_AIN1_LOW                0x1A 
     129#define LM87_REG_AIN2_LOW                0x1B 
    98130#define LM87_REG_2_5V_EXT_TEMP_2_HIGH    0x2B   
    99131#define LM87_REG_2_5V_EXT_TEMP_2_LOW     0x2C   
     
    112144#define LM87_REG_INT_TEMP_HIGH           0x39   
    113145#define LM87_REG_INT_TEMP_LOW            0x3A   
    114 #define LM87_REG_FAN1_AIN1_LIMIT         0x3B  /* 2.5V high limit */ 
     146#define LM87_REG_FAN1_AIN1_LIMIT         0x3B 
    115147#define LM87_REG_FAN2_AIN2_LIMIT         0x3C 
    116148#define LM87_REG_COMPANY_ID              0x3E  
     
    136168   these macros are called: arguments may be evaluated more than once. 
    137169   Fixing this is just not worth it. */ 
     170 
    138171#define IN_TO_REG(val,nr) (SENSORS_LIMIT(((val) & 0xff),0,255)) 
    139172#define IN_FROM_REG(val,nr) (val) 
     
    175208#define VID_FROM_REG(val) ((val)==0x1f?0:(val)>=0x10?510-(val)*10:\ 
    176209                           205-(val)*5) 
    177  
    178 #define LM87_INIT_IN_0 190 
    179 #define LM87_INIT_IN_1 190 
    180 #define LM87_INIT_IN_2 190 
    181 #define LM87_INIT_IN_3 190 
    182 #define LM87_INIT_IN_4 190 
    183 #define LM87_INIT_IN_5 190 
    184  
    185 #define LM87_INIT_IN_PERCENTAGE 10 
    186  
    187 /*********  2.5V monitoring limits **********/ 
    188 #define LM87_INIT_IN_MIN_0 \ 
    189         (LM87_INIT_IN_0 - ((LM87_INIT_IN_0 * LM87_INIT_IN_PERCENTAGE) / 100)) 
    190 #define LM87_INIT_IN_MAX_0 \ 
    191         (LM87_INIT_IN_0 + ((LM87_INIT_IN_0 * LM87_INIT_IN_PERCENTAGE) / 100)) 
    192  
    193 /*********  Vccp1 monitoring limits **********/ 
    194 #define LM87_INIT_IN_MIN_1 \ 
    195         (LM87_INIT_IN_1 - ((LM87_INIT_IN_1 * LM87_INIT_IN_PERCENTAGE) / 100)) 
    196 #define LM87_INIT_IN_MAX_1 \ 
    197         (LM87_INIT_IN_1 + ((LM87_INIT_IN_1 * LM87_INIT_IN_PERCENTAGE) / 100)) 
    198  
    199 /*********  3.3V monitoring limits **********/ 
    200 #define LM87_INIT_IN_MIN_2 \ 
    201         (LM87_INIT_IN_2 - ((LM87_INIT_IN_2 * LM87_INIT_IN_PERCENTAGE) / 100)) 
    202 #define LM87_INIT_IN_MAX_2 \ 
    203         (LM87_INIT_IN_2 + ((LM87_INIT_IN_2 * LM87_INIT_IN_PERCENTAGE) / 100)) 
    204  
    205 /*********  5V monitoring limits **********/ 
    206 #define LM87_INIT_IN_MIN_3 \ 
    207         (LM87_INIT_IN_3 - ((LM87_INIT_IN_3 * LM87_INIT_IN_PERCENTAGE) / 100)) 
    208 #define LM87_INIT_IN_MAX_3 \ 
    209         (LM87_INIT_IN_3 + ((LM87_INIT_IN_3 * LM87_INIT_IN_PERCENTAGE) / 100)) 
    210  
    211 /*********  12V monitoring limits **********/ 
    212 #define LM87_INIT_IN_MIN_4 \ 
    213         (LM87_INIT_IN_4 - ((LM87_INIT_IN_4 * LM87_INIT_IN_PERCENTAGE) / 100)) 
    214 #define LM87_INIT_IN_MAX_4 \ 
    215         (LM87_INIT_IN_4 + ((LM87_INIT_IN_4 * LM87_INIT_IN_PERCENTAGE) / 100)) 
    216  
    217 /*********  Vccp2 monitoring limits **********/ 
    218 #define LM87_INIT_IN_MIN_5 \ 
    219         (LM87_INIT_IN_5 - ((LM87_INIT_IN_5 * LM87_INIT_IN_PERCENTAGE) / 100)) 
    220 #define LM87_INIT_IN_MAX_5 \ 
    221         (LM87_INIT_IN_5 + ((LM87_INIT_IN_5 * LM87_INIT_IN_PERCENTAGE) / 100)) 
    222  
     210                            
    223211#define LM87_INIT_FAN_MIN 3000 
    224212 
    225213#define LM87_INIT_EXT_TEMP_MAX 600 
    226 #define LM87_INIT_EXT_TEMP_MIN 50 
     214#define LM87_INIT_EXT_TEMP_MIN 100 
    227215#define LM87_INIT_INT_TEMP_MAX 600 
    228 #define LM87_INIT_INT_TEMP_MIN 50 
     216#define LM87_INIT_INT_TEMP_MIN 100 
    229217 
    230218#ifdef MODULE 
     
    237225   dynamically allocated, at the same time when a new LM87 client is 
    238226   allocated. */ 
    239 struct lm87_data { 
     227struct LM87_data { 
    240228        int sysctl_id; 
    241229        enum chips type; 
     
    248236        u8  in_max[6];          /* Register value */ 
    249237        u8  in_min[6];          /* Register value */ 
    250         u8  fan[2];             /* Register value */ 
    251         u8  fan_min[2];         /* Register value */ 
    252         u8  fan_div[2];         /* Register encoding, shifted right */ 
    253         int front_amb_temp;     /* Temp, shifted right */ 
    254         int cpu_temp;           /* Temp, shifted right */ 
     238        u8  ain1;               /* Register value */ 
     239        u8  ain1_min;           /* Register value */ 
     240        u8  ain1_max;           /* Register value */ 
     241        u8  ain2;               /* Register value */ 
     242        u8  ain2_min;           /* Register value */ 
     243        u8  ain2_max;           /* Register value */ 
     244        u8  fan;                /* Register value */ 
     245        u8  fan_min;            /* Register value */ 
     246        u8  fan_div;            /* Register encoding, shifted right */ 
     247        u8  fan2;               /* Register value */ 
     248        u8  fan2_min;           /* Register value */ 
     249        u8  fan2_div;           /* Register encoding, shifted right */ 
     250        int ext2_temp;          /* Temp, shifted right */ 
     251        int ext_temp;           /* Temp, shifted right */ 
    255252        int int_temp;           /* Temp, shifted right */ 
    256         u8  cpu_temp_max;       /* Register value */ 
    257         u8  cpu_temp_min;       /* Register value */ 
    258         u8  front_amb_temp_max; /* Register value */ 
    259         u8  front_amb_temp_min; /* Register value */ 
     253        u8  ext_temp_max;       /* Register value */ 
     254        u8  ext_temp_min;       /* Register value */ 
     255        u8  ext2_temp_max;      /* Register value */ 
     256        u8  ext2_temp_min;      /* Register value */ 
    260257        u8  int_temp_max;       /* Register value */ 
    261258        u8  int_temp_min;       /* Register value */ 
     
    265262}; 
    266263 
    267  
    268264#ifdef MODULE 
    269265static 
     
    271267extern 
    272268#endif 
    273 int __init sensors_lm87_init(void); 
    274 static int __init lm87_cleanup(void); 
    275  
    276 static int lm87_attach_adapter(struct i2c_adapter *adapter); 
    277 static int lm87_detect(struct i2c_adapter *adapter, int address, 
     269int __init sensors_LM87_init(void); 
     270static int __init LM87_cleanup(void); 
     271 
     272static int LM87_attach_adapter(struct i2c_adapter *adapter); 
     273static int LM87_detect(struct i2c_adapter *adapter, int address, 
    278274                          unsigned short flags, int kind); 
    279 static int lm87_detach_client(struct i2c_client *client); 
    280 static int lm87_command(struct i2c_client *client, unsigned int cmd, 
     275static int LM87_detach_client(struct i2c_client *client); 
     276static int LM87_command(struct i2c_client *client, unsigned int cmd, 
    281277                           void *arg); 
    282 static void lm87_inc_use(struct i2c_client *client); 
    283 static void lm87_dec_use(struct i2c_client *client); 
    284  
    285 static int lm87_read_value(struct i2c_client *client, u8 register); 
    286 static int lm87_write_value(struct i2c_client *client, u8 register, 
     278static void LM87_inc_use(struct i2c_client *client); 
     279static void LM87_dec_use(struct i2c_client *client); 
     280 
     281static int LM87_read_value(struct i2c_client *client, u8 register); 
     282static int LM87_write_value(struct i2c_client *client, u8 register, 
    287283                               u8 value); 
    288 static void lm87_update_client(struct i2c_client *client); 
    289 static void lm87_init_client(struct i2c_client *client); 
    290  
    291  
    292 static void lm87_in(struct i2c_client *client, int operation, 
     284static void LM87_update_client(struct i2c_client *client); 
     285static void LM87_init_client(struct i2c_client *client); 
     286 
     287 
     288static void LM87_in(struct i2c_client *client, int operation, 
    293289                       int ctl_name, int *nrels_mag, long *results); 
    294 static void lm87_fan(struct i2c_client *client, int operation, 
     290static void LM87_ain(struct i2c_client *client, int operation, 
     291                       int ctl_name, int *nrels_mag, long *results); 
     292static void LM87_fan(struct i2c_client *client, int operation, 
    295293                        int ctl_name, int *nrels_mag, long *results); 
    296 static void lm87_temp(struct i2c_client *client, int operation, 
     294static void LM87_temp(struct i2c_client *client, int operation, 
    297295                         int ctl_name, int *nrels_mag, long *results); 
    298 static void lm87_alarms(struct i2c_client *client, int operation, 
     296static void LM87_alarms(struct i2c_client *client, int operation, 
    299297                           int ctl_name, int *nrels_mag, long *results); 
    300 static void lm87_fan_div(struct i2c_client *client, int operation, 
     298static void LM87_fan_div(struct i2c_client *client, int operation, 
    301299                            int ctl_name, int *nrels_mag, long *results); 
    302 static void lm87_analog_out(struct i2c_client *client, int operation, 
     300static void LM87_analog_out(struct i2c_client *client, int operation, 
    303301                               int ctl_name, int *nrels_mag, 
    304302                               long *results); 
    305 static void lm87_vid(struct i2c_client *client, int operation, 
     303static void LM87_vid(struct i2c_client *client, int operation, 
    306304                        int ctl_name, int *nrels_mag, long *results); 
    307305 
     
    309307   allocation could also be used; the code needed for this would probably 
    310308   take more memory than the datastructure takes now. */ 
    311 static int lm87_id = 0; 
    312  
    313 static struct i2c_driver lm87_driver = { 
     309static int LM87_id = 0; 
     310 
     311static struct i2c_driver LM87_driver = { 
    314312        /* name */          "LM87 sensor driver", 
    315313        /* id */             I2C_DRIVERID_LM87, 
    316314        /* flags */          I2C_DF_NOTIFY, 
    317         /* attach_adapter */ &lm87_attach_adapter, 
    318         /* detach_client */  &lm87_detach_client, 
    319         /* command */        &lm87_command, 
    320         /* inc_use */        &lm87_inc_use, 
    321         /* dec_use */        &lm87_dec_use 
     315        /* attach_adapter */ &LM87_attach_adapter, 
     316        /* detach_client */  &LM87_detach_client, 
     317        /* command */        &LM87_command, 
     318        /* inc_use */        &LM87_inc_use, 
     319        /* dec_use */        &LM87_dec_use 
    322320}; 
    323321 
    324 /* Used by lm87_init/cleanup */ 
    325 static int __initdata lm87_initialized = 0; 
     322/* Used by LM87_init/cleanup */ 
     323static int __initdata LM87_initialized = 0; 
    326324 
    327325/* The /proc/sys entries */ 
     
    332330   when a new copy is allocated. */ 
    333331 
    334 static ctl_table lm87_dir_table_template[] = { 
     332static ctl_table LM87_dir_table_template[] = { 
     333#ifdef LM87_AIN1 
     334        {LM87_SYSCTL_AIN1, "ain1", NULL, 0, 0644, NULL, &sensors_proc_real, 
     335          &sensors_sysctl_real, NULL, &LM87_ain}, 
     336#endif 
     337#ifdef LM87_AIN2 
     338        {LM87_SYSCTL_AIN2, "ain2", NULL, 0, 0644, NULL, &sensors_proc_real, 
     339          &sensors_sysctl_real, NULL, &LM87_ain}, 
     340#endif 
     341#ifndef LM87_EXT2 
    335342        {LM87_SYSCTL_IN0, "in0", NULL, 0, 0644, NULL, &sensors_proc_real, 
    336           &sensors_sysctl_real, NULL, &lm87_in}, 
     343          &sensors_sysctl_real, NULL, &LM87_in}, 
     344        {LM87_SYSCTL_IN5, "in5", NULL, 0, 0644, NULL, &sensors_proc_real, 
     345          &sensors_sysctl_real, NULL, &LM87_in}, 
     346#endif 
    337347        {LM87_SYSCTL_IN1, "in1", NULL, 0, 0644, NULL, &sensors_proc_real, 
    338           &sensors_sysctl_real, NULL, &lm87_in}, 
     348          &sensors_sysctl_real, NULL, &LM87_in}, 
    339349        {LM87_SYSCTL_IN2, "in2", NULL, 0, 0644, NULL, &sensors_proc_real, 
    340           &sensors_sysctl_real, NULL, &lm87_in}, 
     350          &sensors_sysctl_real, NULL, &LM87_in}, 
    341351        {LM87_SYSCTL_IN3, "in3", NULL, 0, 0644, NULL, &sensors_proc_real, 
    342           &sensors_sysctl_real, NULL, &lm87_in}, 
     352          &sensors_sysctl_real, NULL, &LM87_in}, 
    343353        {LM87_SYSCTL_IN4, "in4", NULL, 0, 0644, NULL, &sensors_proc_real, 
    344           &sensors_sysctl_real, NULL, &lm87_in}, 
    345         {LM87_SYSCTL_IN5, "in5", NULL, 0, 0644, NULL, &sensors_proc_real, 
    346           &sensors_sysctl_real, NULL, &lm87_in}, 
    347         {LM87_SYSCTL_FAN1, "fan1", NULL, 0, 0644, NULL, &sensors_proc_real, 
    348           &sensors_sysctl_real, NULL, &lm87_fan}, 
     354          &sensors_sysctl_real, NULL, &LM87_in}, 
     355#ifndef LM87_AIN1 
     356        {LM87_SYSCTL_FAN1, "fan", NULL, 0, 0644, NULL, &sensors_proc_real, 
     357          &sensors_sysctl_real, NULL, &LM87_fan}, 
     358        {LM87_SYSCTL_FAN_DIV, "fan_div", NULL, 0, 0644, NULL, &sensors_proc_real, 
     359          &sensors_sysctl_real, NULL, &LM87_fan_div}, 
     360#define LM87_FANDIV_FLAG 
     361#endif 
     362#ifndef LM87_AIN2 
    349363        {LM87_SYSCTL_FAN2, "fan2", NULL, 0, 0644, NULL, &sensors_proc_real, 
    350           &sensors_sysctl_real, NULL, &lm87_fan}, 
     364          &sensors_sysctl_real, NULL, &LM87_fan}, 
     365#ifndef LM87_FANDIV_FLAG 
     366        {LM87_SYSCTL_FAN_DIV, "fan_div", NULL, 0, 0644, NULL, &sensors_proc_real, 
     367          &sensors_sysctl_real, NULL, &LM87_fan_div}, 
     368#endif /* LM87_FANDIV_FLAG */ 
     369#endif /* LM87_AIN2 */ 
     370#ifdef LM87_EXT2 
     371        {LM87_SYSCTL_TEMP3, "temp3", NULL, 0, 0644, NULL, &sensors_proc_real, 
     372          &sensors_sysctl_real, NULL, &LM87_temp}, 
     373#endif 
     374        {LM87_SYSCTL_TEMP2, "temp2", NULL, 0, 0644, NULL, &sensors_proc_real, 
     375          &sensors_sysctl_real, NULL, &LM87_temp}, 
    351376        {LM87_SYSCTL_TEMP1, "temp1", NULL, 0, 0644, NULL, &sensors_proc_real, 
    352           &sensors_sysctl_real, NULL, &lm87_temp}, 
    353         {LM87_SYSCTL_TEMP2, "temp2", NULL, 0, 0644, NULL, &sensors_proc_real, 
    354           &sensors_sysctl_real, NULL, &lm87_temp}, 
    355         {LM87_SYSCTL_TEMP3, "temp3", NULL, 
    356           0, 0644, NULL, &sensors_proc_real, 
    357           &sensors_sysctl_real, NULL, &lm87_temp}, 
    358         {LM87_SYSCTL_FAN_DIV, "fan_div", NULL, 
    359           0, 0644, NULL, &sensors_proc_real, 
    360           &sensors_sysctl_real, NULL, &lm87_fan_div}, 
     377          &sensors_sysctl_real, NULL, &LM87_temp}, 
    361378        {LM87_SYSCTL_ALARMS, "alarms", NULL, 0, 0444, NULL, &sensors_proc_real, 
    362           &sensors_sysctl_real, NULL, &lm87_alarms}, 
    363         {LM87_SYSCTL_ANALOG_OUT, "analog_out", NULL, 
    364           0, 0644, NULL, &sensors_proc_real, 
    365           &sensors_sysctl_real, NULL, &lm87_analog_out}, 
     379          &sensors_sysctl_real, NULL, &LM87_alarms}, 
     380        {LM87_SYSCTL_ANALOG_OUT, "analog_out", NULL, 0, 0644, NULL, &sensors_proc_real, 
     381          &sensors_sysctl_real, NULL, &LM87_analog_out}, 
    366382        {LM87_SYSCTL_VID, "vid", NULL, 0, 0444, NULL, &sensors_proc_real, 
    367           &sensors_sysctl_real, NULL, &lm87_vid}, 
     383          &sensors_sysctl_real, NULL, &LM87_vid}, 
    368384        {0} 
    369385}; 
    370386 
    371 int lm87_attach_adapter(struct i2c_adapter *adapter) 
     387int LM87_attach_adapter(struct i2c_adapter *adapter) 
    372388{ 
    373389   int error; 
     
    382398   lm87_client_data.force            = addr_data.forces->force; 
    383399 
    384         error = i2c_probe(adapter, &lm87_client_data, lm87_detect); 
    385         sensors_detect(adapter, &addr_data, lm87_detect); 
     400        error = i2c_probe(adapter, &lm87_client_data, LM87_detect); 
     401        sensors_detect(adapter, &addr_data, LM87_detect); 
    386402 
    387403        return error; 
    388404} 
    389405 
    390 static int lm87_detect(struct i2c_adapter *adapter, int address, 
     406static int LM87_detect(struct i2c_adapter *adapter, int address, 
    391407                          unsigned short flags, int kind) 
    392408{ 
    393409        int i; 
    394410        struct i2c_client *new_client; 
    395         struct lm87_data *data; 
     411        struct LM87_data *data; 
    396412        int err = 0; 
    397413        const char *type_name = ""; 
     
    406422 
    407423        if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    408                                    sizeof(struct lm87_data), 
     424                                   sizeof(struct LM87_data), 
    409425                                   GFP_KERNEL))) { 
    410426                err = -ENOMEM; 
     
    412428        } 
    413429 
    414         data = (struct lm87_data *) (new_client + 1); 
     430        data = (struct LM87_data *) (new_client + 1); 
    415431        new_client->addr = address; 
    416432        new_client->data = data; 
    417433        new_client->adapter = adapter; 
    418         new_client->driver = &lm87_driver; 
     434        new_client->driver = &LM87_driver; 
    419435        new_client->flags = 0; 
    420436 
     
    422438 
    423439        if (kind < 0) { 
    424                 if (((lm87_read_value(new_client, LM87_REG_CONFIG) & 0x80) 
     440                if (((LM87_read_value(new_client, LM87_REG_CONFIG) & 0x80) 
    425441                     != 0x00) || 
    426                     (lm87_read_value(new_client, LM87_REG_COMPANY_ID) != 0x02)) 
     442                    (LM87_read_value(new_client, LM87_REG_COMPANY_ID) != 0x02)) 
    427443               goto ERROR1; 
    428444        } 
    429445 
    430         /* Fill in the remaining client fields and put into the global list */ 
     446        /* Fill in the remaining client fields and put it into the global list */ 
    431447        type_name = "lm87"; 
    432448        client_name = "LM87 chip"; 
     
    434450        data->type = kind; 
    435451 
    436         new_client->id = lm87_id++; 
     452        new_client->id = LM87_id++; 
    437453        data->valid = 0; 
    438454        init_MUTEX(&data->update_lock); 
     
    445461        if ((i = sensors_register_entry(new_client, 
    446462                                        type_name, 
    447                                         lm87_dir_table_template, 
     463                                        LM87_dir_table_template, 
    448464                                        THIS_MODULE)) < 0) { 
    449465                err = i; 
     
    453469 
    454470        /* Initialize the LM87 chip */ 
    455         lm87_init_client(new_client); 
     471        LM87_init_client(new_client); 
    456472        return 0; 
    457473 
     
    468484} 
    469485 
    470 int lm87_detach_client(struct i2c_client *client) 
     486int LM87_detach_client(struct i2c_client *client) 
    471487{ 
    472488        int err; 
    473489 
    474         sensors_deregister_entry(((struct lm87_data *) (client->data))-> 
     490        sensors_deregister_entry(((struct LM87_data *) (client->data))-> 
    475491                                 sysctl_id); 
    476492 
    477493        if ((err = i2c_detach_client(client))) { 
    478494                printk 
    479             ("lm87.o: Client deregistration failed, client not detached.\n"); 
     495                    ("LM87.o: Client deregistration failed, client not detached.\n"); 
    480496                return err; 
    481497        } 
     
    488504 
    489505/* No commands defined yet */ 
    490 int lm87_command(struct i2c_client *client, unsigned int cmd, void *arg) 
     506int LM87_command(struct i2c_client *client, unsigned int cmd, void *arg) 
    491507{ 
    492508        return 0; 
    493509} 
    494510 
    495 void lm87_inc_use(struct i2c_client *client) 
     511void LM87_inc_use(struct i2c_client *client) 
    496512{ 
    497513#ifdef MODULE 
     
    500516} 
    501517 
    502 void lm87_dec_use(struct i2c_client *client) 
     518void LM87_dec_use(struct i2c_client *client) 
    503519{ 
    504520#ifdef MODULE 
     
    507523} 
    508524 
    509 int lm87_read_value(struct i2c_client *client, u8 reg) 
     525int LM87_read_value(struct i2c_client *client, u8 reg) 
    510526{ 
    511527        return 0xFF & i2c_smbus_read_byte_data(client, reg); 
    512528} 
    513529 
    514 int lm87_write_value(struct i2c_client *client, u8 reg, u8 value) 
     530int LM87_write_value(struct i2c_client *client, u8 reg, u8 value) 
    515531{ 
    516532        return i2c_smbus_write_byte_data(client, reg, value); 
     
    518534 
    519535/* Called when we have found a new LM87. It should set limits, etc. */ 
    520 void lm87_init_client(struct i2c_client *client) 
    521 { 
     536void LM87_init_client(struct i2c_client *client) 
     537{ 
     538        long vid; 
     539 
    522540        /* Reset all except Watchdog values and last conversion values 
    523541           This sets fan-divs to 2, among others. This makes most other 
    524542           initializations unnecessary */ 
    525         lm87_write_value(client, LM87_REG_CONFIG, 0x80); 
     543        LM87_write_value(client, LM87_REG_CONFIG, 0x80); 
    526544 
    527545        /* Setup Channel Mode register for configuration of monitoring  
     546         * Default is 00000000b 
    528547         *      bit 0 - Configures Fan 1/AIN 1 input (1 = AIN) 
    529          *      bit 2 - Configures 2.5V/D2 input     (1 = 2nd Therm.)  
     548         *      bit 1 - Configures Fan 2/AIN 2 input (1 = AIN) 
     549         *      bit 2 - Configures 2.5V&Vccp2/D2 input (1 = 2nd Therm.)  
     550         *      bit 3 - Configures Vcc for 5V/3.3V reading (0 = 3.3V) 
     551         *      bit 4 - Configures IRQ0 Enable if = 1 
     552         *      bit 5 - Configures IRQ1 Enable if = 1 
     553         *      bit 6 - Configures IRQ2 Enable if = 1 
     554         *      bit 7 - Configures VID/IRQ input as interrupts if = 1 
    530555         */ 
    531         lm87_write_value(client, LM87_REG_CHANNEL_MODE, 0x05); 
    532  
    533  
    534         lm87_write_value(client, LM87_REG_IN_MIN(1), 
    535                             IN_TO_REG(LM87_INIT_IN_MIN_1, 1)); 
    536         lm87_write_value(client, LM87_REG_IN_MAX(1), 
    537                             IN_TO_REG(LM87_INIT_IN_MAX_1, 1)); 
    538         lm87_write_value(client, LM87_REG_IN_MIN(2), 
    539                             IN_TO_REG(LM87_INIT_IN_MIN_2, 2)); 
    540         lm87_write_value(client, LM87_REG_IN_MAX(2), 
    541                             IN_TO_REG(LM87_INIT_IN_MAX_2, 2)); 
    542         lm87_write_value(client, LM87_REG_IN_MIN(3), 
    543                             IN_TO_REG(LM87_INIT_IN_MIN_3, 3)); 
    544         lm87_write_value(client, LM87_REG_IN_MAX(3), 
    545                             IN_TO_REG(LM87_INIT_IN_MAX_3, 3)); 
    546         lm87_write_value(client, LM87_REG_IN_MIN(4), 
    547                             IN_TO_REG(LM87_INIT_IN_MIN_4, 4)); 
    548         lm87_write_value(client, LM87_REG_IN_MAX(4), 
    549                             IN_TO_REG(LM87_INIT_IN_MAX_4, 4)); 
    550         lm87_write_value(client, LM87_REG_IN_MIN(5), 
    551                             IN_TO_REG(LM87_INIT_IN_MIN_5, 5)); 
    552         lm87_write_value(client, LM87_REG_IN_MAX(5), 
    553                             IN_TO_REG(LM87_INIT_IN_MAX_5, 5)); 
    554  
    555         lm87_write_value(client, LM87_REG_EXT_TEMP_1_HIGH, 
     556 
     557/* I know, not clean, but it works. :'p */ 
     558        LM87_write_value(client, LM87_REG_CHANNEL_MODE, 
     559#ifdef LM87_AIN1 
     560 0x01 
     561#else 
     5620 
     563#endif 
     564 |  
     565#ifdef LM87_AIN2 
     566 0x02 
     567#else 
     5680 
     569#endif 
     570 | 
     571#ifdef LM87_EXT2 
     572 0x04 
     573#else 
     5740 
     575#endif 
     576 |  
     577#ifdef LM87_5V_VCC 
     5780x08 
     579#else    
     5800 
     581#endif 
     582        ); 
     583 
     584        /* Set IN (voltage) initial limits to sane values  +/- 5% */ 
     585        LM87_write_value(client, LM87_REG_IN_MIN(1),182); 
     586        LM87_write_value(client, LM87_REG_IN_MAX(1),202); 
     587        LM87_write_value(client, LM87_REG_IN_MIN(2),182); 
     588        LM87_write_value(client, LM87_REG_IN_MAX(2),202); 
     589        LM87_write_value(client, LM87_REG_IN_MIN(3),182); 
     590        LM87_write_value(client, LM87_REG_IN_MAX(3),202); 
     591        LM87_write_value(client, LM87_REG_IN_MIN(4),182); 
     592        LM87_write_value(client, LM87_REG_IN_MAX(4),202); 
     593 
     594        /* Set CPU core voltage limits relative to vid readings */ 
     595        vid = (LM87_read_value(client, LM87_REG_VID_FAN_DIV) & 0x0f) 
     596                    | ((LM87_read_value(client, LM87_REG_VID4) & 0x01) 
     597                    << 4 ); 
     598        if ((vid == 0x1f) || (vid == 0x0f)) { 
     599                vid = 0; 
     600        } else if (vid > 0x0f) { 
     601                vid = (1275 - ((vid - 0x10) * 25))/10; 
     602        } else { 
     603                vid = 200 - (vid * 5); 
     604        } 
     605        LM87_write_value(client, LM87_REG_IN_MIN(0), 
     606                (u8)(0x0FF & (((1920/270)*(vid*95))/1000) )); 
     607        LM87_write_value(client, LM87_REG_IN_MAX(0), 
     608                (u8)(0x0FF & (((1920/270)*(vid*105))/1000) )); 
     609        LM87_write_value(client, LM87_REG_IN_MIN(5), 
     610                (u8)(0x0FF & (((1920/270)*(vid*95))/1000) )); 
     611        LM87_write_value(client, LM87_REG_IN_MAX(5), 
     612                (u8)(0x0FF & (((1920/270)*(vid*105))/1000) )); 
     613 
     614        /* Set Temp initial limits to sane values */ 
     615        LM87_write_value(client, LM87_REG_EXT_TEMP_1_HIGH, 
    556616                            TEMP_LIMIT_TO_REG(LM87_INIT_EXT_TEMP_MAX)); 
    557         lm87_write_value(client, LM87_REG_EXT_TEMP_1_LOW, 
     617        LM87_write_value(client, LM87_REG_EXT_TEMP_1_LOW, 
    558618                            TEMP_LIMIT_TO_REG(LM87_INIT_EXT_TEMP_MIN)); 
    559         lm87_write_value(client, LM87_REG_2_5V_EXT_TEMP_2_HIGH, 
     619#ifdef LM87_EXT2 
     620        LM87_write_value(client, LM87_REG_2_5V_EXT_TEMP_2_HIGH, 
    560621                            TEMP_LIMIT_TO_REG(LM87_INIT_EXT_TEMP_MAX)); 
    561         lm87_write_value(client, LM87_REG_2_5V_EXT_TEMP_2_LOW, 
     622        LM87_write_value(client, LM87_REG_2_5V_EXT_TEMP_2_LOW, 
    562623                            TEMP_LIMIT_TO_REG(LM87_INIT_EXT_TEMP_MIN)); 
    563         lm87_write_value(client, LM87_REG_INT_TEMP_HIGH, 
     624#endif 
     625        LM87_write_value(client, LM87_REG_INT_TEMP_HIGH, 
    564626                            TEMP_LIMIT_TO_REG(LM87_INIT_INT_TEMP_MAX)); 
    565         lm87_write_value(client, LM87_REG_INT_TEMP_LOW, 
     627        LM87_write_value(client, LM87_REG_INT_TEMP_LOW, 
    566628                            TEMP_LIMIT_TO_REG(LM87_INIT_INT_TEMP_MIN)); 
    567629 
    568         lm87_write_value(client, LM87_REG_FAN1_AIN1_LIMIT, 
    569                             IN_TO_REG(LM87_INIT_IN_MAX_0, 0)); 
    570  
    571         lm87_write_value(client, LM87_REG_FAN2_AIN2_LIMIT, 
     630#ifndef LM87_AIN1 
     631        LM87_write_value(client, LM87_REG_FAN1_AIN1_LIMIT, 
    572632                            FAN_TO_REG(LM87_INIT_FAN_MIN, 2)); 
     633#endif 
     634#ifndef LM87_AIN2 
     635        LM87_write_value(client, LM87_REG_FAN2_AIN2_LIMIT, 
     636                            FAN_TO_REG(LM87_INIT_FAN_MIN, 2)); 
     637#endif 
    573638 
    574639        /* Start monitoring */ 
    575         lm87_write_value(client, LM87_REG_CONFIG, 0x01); 
    576 } 
    577  
    578 void lm87_update_client(struct i2c_client *client) 
    579 { 
    580         struct lm87_data *data = client->data; 
    581         u8 i; 
     640        LM87_write_value(client, LM87_REG_CONFIG, 0x01); 
     641} 
     642 
     643void LM87_update_client(struct i2c_client *client) 
     644{ 
     645        struct LM87_data *data = client->data; 
     646        int i; 
    582647 
    583648        down(&data->update_lock); 
     
    586651            (jiffies < data->last_updated)      ||  
    587652             !data->valid) { 
    588  
    589 #ifdef DEBUG 
    590                 printk("Starting LM87 update\n"); 
    591 #endif 
    592653                for (i = 0; i <= 5; i++) {   
    593                     /* Since we are using AIN 1 as our 2.5V monitoring, need to  
    594                      * accomodate with a hardcode 
    595                      * register address and we only get 
    596                      * to look at one threshold. 
    597                      */ 
    598                     if (i == 0) { 
    599                         data->in[i] =  
    600                             lm87_read_value(client, LM87_REG_FAN1_AIN1); 
    601                         data->in_min[i] = 0; 
    602                         data->in_max[i] =  
    603                             lm87_read_value(client, LM87_REG_FAN1_AIN1_LIMIT); 
    604                     } 
    605                     else { 
    606                         data->in[i] =  
    607                             lm87_read_value(client, LM87_REG_IN(i)); 
    608                         data->in_min[i] =  
    609                             lm87_read_value(client, 
    610                                                LM87_REG_IN_MIN(i)); 
    611                         data->in_max[i] =  
    612                             lm87_read_value(client, 
    613                                                LM87_REG_IN_MAX(i)); 
    614                     } 
    615                 } 
    616  
    617                 data->fan[0] = 
    618                     lm87_read_value(client, LM87_REG_FAN1_AIN1); 
    619                 data->fan_min[0] = 
    620                     lm87_read_value(client, LM87_REG_FAN1_AIN1_LIMIT); 
    621                 data->fan[1] = 
    622                     lm87_read_value(client, LM87_REG_FAN2_AIN2); 
    623                 data->fan_min[1] = 
    624                     lm87_read_value(client, LM87_REG_FAN2_AIN2_LIMIT); 
    625  
    626                 data->front_amb_temp = 
    627                     lm87_read_value(client, LM87_REG_2_5V_EXT_TEMP_2); 
    628                 data->cpu_temp = 
    629                     lm87_read_value(client, LM87_REG_EXT_TEMP_1); 
     654                 data->in[i] =  
     655                    LM87_read_value(client,LM87_REG_IN(i)); 
     656                 data->in_min[i] =  
     657                    LM87_read_value(client,LM87_REG_IN_MIN(i)); 
     658                 data->in_max[i] =  
     659                    LM87_read_value(client,LM87_REG_IN_MAX(i)); 
     660                } 
     661                 data->ain1 =  
     662                    LM87_read_value(client,LM87_REG_FAN1_AIN1); 
     663                 data->ain1_min = 
     664                    LM87_read_value(client,LM87_REG_AIN1_LOW); 
     665                 data->ain1_max = 
     666                    LM87_read_value(client,LM87_REG_FAN1_AIN1_LIMIT); 
     667                 data->ain2 =  
     668                    LM87_read_value(client,LM87_REG_FAN1_AIN1); 
     669                 data->ain2_min = 
     670                    LM87_read_value(client,LM87_REG_AIN2_LOW); 
     671                 data->ain2_max = 
     672                    LM87_read_value(client,LM87_REG_FAN2_AIN2_LIMIT); 
     673 
     674                data->fan = 
     675                    LM87_read_value(client, LM87_REG_FAN1_AIN1); 
     676                data->fan_min = 
     677                    LM87_read_value(client, LM87_REG_FAN1_AIN1_LIMIT); 
     678                data->fan2 = 
     679                    LM87_read_value(client, LM87_REG_FAN2_AIN2); 
     680                data->fan2_min = 
     681                    LM87_read_value(client, LM87_REG_FAN2_AIN2_LIMIT); 
     682 
     683                data->ext2_temp = 
     684                    LM87_read_value(client, LM87_REG_2_5V_EXT_TEMP_2); 
     685                data->ext_temp = 
     686                    LM87_read_value(client, LM87_REG_EXT_TEMP_1); 
    630687                data->int_temp = 
    631                     lm87_read_value(client, LM87_REG_INT_TEMP); 
    632  
    633                 data->front_amb_temp_max = 
    634                     lm87_read_value(client, LM87_REG_2_5V_EXT_TEMP_2_HIGH); 
    635                 data->front_amb_temp_min = 
    636                     lm87_read_value(client, LM87_REG_2_5V_EXT_TEMP_2_LOW); 
    637  
    638                 data->cpu_temp_max = 
    639                     lm87_read_value(client, LM87_REG_EXT_TEMP_1_HIGH); 
    640                 data->cpu_temp_min = 
    641                     lm87_read_value(client, LM87_REG_EXT_TEMP_1_LOW); 
     688                    LM87_read_value(client, LM87_REG_INT_TEMP); 
     689 
     690                data->ext2_temp_max = 
     691                    LM87_read_value(client, LM87_REG_2_5V_EXT_TEMP_2_HIGH); 
     692                data->ext2_temp_min = 
     693                    LM87_read_value(client, LM87_REG_2_5V_EXT_TEMP_2_LOW); 
     694 
     695                data->ext_temp_max = 
     696                    LM87_read_value(client, LM87_REG_EXT_TEMP_1_HIGH); 
     697                data->ext_temp_min = 
     698                    LM87_read_value(client, LM87_REG_EXT_TEMP_1_LOW); 
    642699 
    643700                data->int_temp_max = 
    644                     lm87_read_value(client, LM87_REG_INT_TEMP_HIGH); 
     701                    LM87_read_value(client, LM87_REG_INT_TEMP_HIGH); 
    645702                data->int_temp_min = 
    646                     lm87_read_value(client, LM87_REG_INT_TEMP_LOW); 
    647  
    648                 i = lm87_read_value(client, LM87_REG_VID_FAN_DIV); 
    649                 data->fan_div[0] = (i >> 4) & 0x03; 
    650                 data->fan_div[1] = (i >> 6) & 0x03; 
     703                    LM87_read_value(client, LM87_REG_INT_TEMP_LOW); 
     704 
     705                i = LM87_read_value(client, LM87_REG_VID_FAN_DIV); 
     706                data->fan_div = (i >> 4) & 0x03; 
     707                data->fan2_div = (i >> 6) & 0x03; 
    651708                data->vid = i & 0x0f; 
    652709                data->vid |= 
    653                     (lm87_read_value(client, LM87_REG_VID4) & 0x01) 
     710                    (LM87_read_value(client, LM87_REG_VID4) & 0x01) 
    654711                    << 4; 
    655  
    656712                data->alarms = 
    657                     lm87_read_value(client, 
    658                                        LM87_REG_INT1_STAT) + 
    659                     (lm87_read_value(client, LM87_REG_INT2_STAT) << 
     713                    LM87_read_value(client, LM87_REG_INT1_STAT) + 
     714                    (LM87_read_value(client, LM87_REG_INT2_STAT) << 
    660715                     8); 
    661716                data->analog_out = 
    662                     lm87_read_value(client, LM87_REG_ANALOG_OUT); 
     717                    LM87_read_value(client, LM87_REG_ANALOG_OUT); 
    663718                data->last_updated = jiffies; 
    664719                data->valid = 1; 
    665720        } 
    666  
    667721        up(&data->update_lock); 
    668722} 
     
    682736   good practice, but as long as you put less than about 5 values in results, 
    683737   you can assume it is large enough. */ 
    684 void lm87_in(struct i2c_client *client, int operation, int ctl_name, 
     738void LM87_in(struct i2c_client *client, int operation, int ctl_name, 
    685739                int *nrels_mag, long *results) 
    686740{ 
    687  
    688         /************************************************************ 
    689          * These values represent 2.5V, Vccp1, 3.3V, 5V, 12V & Vccp2 
    690          *   The 2.5V is 50% sampled for our application, so check 
    691          *   against 1.25V value. 
    692          ************************************************************/ 
    693         int scales[6] = { 260, 200, 344, 520, 1250, 260 }; 
    694  
    695         struct lm87_data *data = client->data; 
     741        long scales[6] = { 270, 100,  
     742#ifdef LM87_5V_VCC 
     743500, 
     744#else 
     745330, 
     746#endif 
     747                500, 1200, 270 }; 
     748 
     749        struct LM87_data *data = client->data; 
    696750        int nr = ctl_name - LM87_SYSCTL_IN0; 
    697751 
     
    699753                *nrels_mag = 2; 
    700754        else if (operation == SENSORS_PROC_REAL_READ) { 
    701                 lm87_update_client(client); 
    702  
     755                LM87_update_client(client); 
    703756                results[0] = 
    704                     IN_FROM_REG(data->in_min[nr], nr) * scales[nr] / 192; 
     757                    ((long)data->in_min[nr] * scales[nr]) / 192; 
    705758                results[1] = 
    706                     IN_FROM_REG(data->in_max[nr], nr) * scales[nr] / 192; 
    707   
    708                 if (nr == AIN1) { 
    709                    results[2] = ((data->in[nr] * 10) * 98) / 1000; 
    710                 } 
    711                 else if (nr == VCCP1 || nr == VCCP2) { 
    712                    results[2] = ((data->in[nr] * 10) * 141) / 1000; 
    713                 } 
    714                 else { 
    715                    results[2] = 
    716                        IN_FROM_REG(data->in[nr], nr) * scales[nr] / 192; 
    717                 } 
    718  
     759                    ((long)data->in_max[nr] * scales[nr]) / 192; 
     760                results[2] = 
     761                    ((long)data->in[nr] * scales[nr]) / 192; 
    719762                *nrels_mag = 3; 
    720763        } else if (operation == SENSORS_PROC_REAL_WRITE) { 
    721764                if (*nrels_mag >= 1) { 
    722765                        data->in_min[nr] = 
    723                             IN_TO_REG((results[0] * 192) / scales[nr], nr); 
    724                         lm87_write_value(client, LM87_REG_IN_MIN(nr), 
     766                            (results[0] * 192) / scales[nr]; 
     767                        LM87_write_value(client, LM87_REG_IN_MIN(nr), 
    725768                                            data->in_min[nr]); 
    726769                } 
    727770                if (*nrels_mag >= 2) { 
    728771                        data->in_max[nr] = 
    729                             IN_TO_REG((results[1] * 192) / scales[nr], nr); 
    730                         lm87_write_value(client, LM87_REG_IN_MAX(nr), 
     772                            (results[1] * 192) / scales[nr]; 
     773                        LM87_write_value(client, LM87_REG_IN_MAX(nr), 
    731774                                            data->in_max[nr]); 
    732775                } 
     
    734777} 
    735778 
    736 void lm87_fan(struct i2c_client *client, int operation, int ctl_name, 
    737                  int *nrels_mag, long *results) 
    738 { 
    739         struct lm87_data *data = client->data; 
    740         int nr = ctl_name - LM87_SYSCTL_FAN1 + 1; 
     779void LM87_ain(struct i2c_client *client, int operation, int ctl_name, 
     780                int *nrels_mag, long *results) 
     781{ 
     782        struct LM87_data *data = client->data; 
    741783 
    742784        if (operation == SENSORS_PROC_REAL_INFO) 
    743785                *nrels_mag = 0; 
    744786        else if (operation == SENSORS_PROC_REAL_READ) { 
    745                 lm87_update_client(client); 
    746                 results[0] = FAN_FROM_REG(data->fan_min[nr-1], 
    747                                           DIV_FROM_REG(data->fan_div[nr-1])); 
    748                 results[1] = FAN_FROM_REG(data->fan[nr-1],  
    749                                           DIV_FROM_REG(data->fan_div[nr-1])); 
     787                LM87_update_client(client); 
     788                if (ctl_name == LM87_SYSCTL_AIN1) { 
     789                 results[0] = data->ain1_min; 
     790                 results[1] = data->ain1_max; 
     791                 results[2] = data->ain1; 
     792                } else { 
     793                 results[0] = data->ain2_min; 
     794                 results[1] = data->ain2_max; 
     795                 results[2] = data->ain2; 
     796                } 
     797                *nrels_mag = 3; 
     798        } else if (operation == SENSORS_PROC_REAL_WRITE) { 
     799                if (*nrels_mag >= 1) { 
     800                 if (ctl_name == LM87_SYSCTL_AIN1) { 
     801                        data->ain1_min = results[0]; 
     802                        LM87_write_value(client, LM87_REG_AIN1_LOW, 
     803                                            data->ain1_min); 
     804                 } else { 
     805                        data->ain2_min = results[0]; 
     806                        LM87_write_value(client, LM87_REG_AIN2_LOW, 
     807                                            data->ain2_min); 
     808                 } 
     809                } 
     810                if (*nrels_mag >= 2) { 
     811                 if (ctl_name == LM87_SYSCTL_AIN1) { 
     812                        data->ain1_max = results[1]; 
     813                        LM87_write_value(client, LM87_REG_FAN1_AIN1_LIMIT, 
     814                                            data->ain1_max); 
     815                 } else { 
     816                        data->ain2_max = results[1]; 
     817                        LM87_write_value(client, LM87_REG_FAN2_AIN2_LIMIT, 
     818                                            data->ain2_max); 
     819                 } 
     820                } 
     821        } 
     822} 
     823 
     824 
     825void LM87_fan(struct i2c_client *client, int operation, int ctl_name, 
     826                 int *nrels_mag, long *results) 
     827{ 
     828        struct LM87_data *data = client->data; 
     829        int nr = ctl_name - LM87_SYSCTL_FAN1; 
     830 
     831        if (operation == SENSORS_PROC_REAL_INFO) 
     832                *nrels_mag = 0; 
     833        else if (operation == SENSORS_PROC_REAL_READ) { 
     834                LM87_update_client(client); 
     835                if (ctl_name == LM87_SYSCTL_FAN1) { 
     836                 results[0] = FAN_FROM_REG(data->fan_min, 
     837                                          DIV_FROM_REG(data->fan_div)); 
     838                 results[1] = FAN_FROM_REG(data->fan,  
     839                                         DIV_FROM_REG(data->fan_div)); 
     840                } else { 
     841                 results[0] = FAN_FROM_REG(data->fan2_min, 
     842                                          DIV_FROM_REG(data->fan2_div)); 
     843                 results[1] = FAN_FROM_REG(data->fan2,  
     844                                         DIV_FROM_REG(data->fan2_div)); 
     845                } 
    750846                *nrels_mag = 2; 
    751847        } else if (operation == SENSORS_PROC_REAL_WRITE) { 
    752848                if (*nrels_mag >= 0) { 
    753                         data->fan_min[nr-1] = FAN_TO_REG(results[0], 
     849                        if (ctl_name == LM87_SYSCTL_FAN1) { 
     850                         data->fan_min = FAN_TO_REG(results[0], 
    754851                                                   DIV_FROM_REG 
    755                                                    (data->fan_div[nr-1])); 
    756                         lm87_write_value(client, (nr == 2) ? 
    757                            LM87_REG_FAN2_AIN2_LIMIT : LM87_REG_FAN1_AIN1_LIMIT, 
    758                                             data->fan_min[nr-1]); 
    759                 } 
    760         } 
    761 } 
    762  
    763  
    764 void lm87_temp(struct i2c_client *client, int operation, int ctl_name, 
     852                                                   (data->fan_div)); 
     853                         LM87_write_value(client, LM87_REG_FAN1_AIN1_LIMIT, 
     854                                            data->fan_min); 
     855                        } else { 
     856                         data->fan2_min = FAN_TO_REG(results[0], 
     857                                                   DIV_FROM_REG 
     858                                                   (data->fan2_div)); 
     859                         LM87_write_value(client, LM87_REG_FAN2_AIN2_LIMIT, 
     860                                            data->fan2_min); 
     861                        } 
     862                } 
     863        } 
     864} 
     865 
     866 
     867void LM87_temp(struct i2c_client *client, int operation, int ctl_name, 
    765868                  int *nrels_mag, long *results) 
    766869{ 
    767         struct lm87_data *data = client->data; 
     870        struct LM87_data *data = client->data; 
    768871 
    769872        if (operation == SENSORS_PROC_REAL_INFO) 
     
    771874        else if (operation == SENSORS_PROC_REAL_READ)  
    772875        { 
    773            lm87_update_client(client); 
     876           LM87_update_client(client); 
    774877 
    775878           /* find out which temp. is being requested */ 
    776879           if (ctl_name == LM87_SYSCTL_TEMP3)  
    777880           { 
    778                 results[0] = TEMP_LIMIT_FROM_REG(data->front_amb_temp_max); 
    779                 results[1] = TEMP_LIMIT_FROM_REG(data->front_amb_temp_min); 
    780                 results[2] = TEMP_FROM_REG(data->front_amb_temp); 
     881                results[0] = TEMP_LIMIT_FROM_REG(data->ext2_temp_max); 
     882                results[1] = TEMP_LIMIT_FROM_REG(data->ext2_temp_min); 
     883                results[2] = TEMP_FROM_REG(data->ext2_temp); 
    781884           } 
    782885           else if(ctl_name == LM87_SYSCTL_TEMP2) 
    783886           { 
    784                 results[0] = TEMP_LIMIT_FROM_REG(data->cpu_temp_max); 
    785                 results[1] = TEMP_LIMIT_FROM_REG(data->cpu_temp_min); 
    786                 results[2] = TEMP_FROM_REG(data->cpu_temp); 
     887                results[0] = TEMP_LIMIT_FROM_REG(data->ext_temp_max); 
     888                results[1] = TEMP_LIMIT_FROM_REG(data->ext_temp_min); 
     889                results[2] = TEMP_FROM_REG(data->ext_temp); 
    787890           } 
    788891           else if(ctl_name == LM87_SYSCTL_TEMP1) 
     
    796899                if (*nrels_mag >= 1) { 
    797900                   if (ctl_name == LM87_SYSCTL_TEMP3) { 
    798                         data->front_amb_temp_max = 
    799                                              TEMP_LIMIT_TO_REG(results[0]); 
    800                         lm87_write_value(client, LM87_REG_2_5V_EXT_TEMP_2_HIGH, 
    801                                             data->front_amb_temp_max); 
     901                        data->ext2_temp_max = TEMP_LIMIT_TO_REG(results[0]); 
     902                        LM87_write_value(client, LM87_REG_2_5V_EXT_TEMP_2_HIGH, 
     903                                            data->ext2_temp_max); 
    802904                   } 
    803905                   if (ctl_name == LM87_SYSCTL_TEMP2) { 
    804                         data->cpu_temp_max = TEMP_LIMIT_TO_REG(results[0]); 
    805                         lm87_write_value(client, LM87_REG_EXT_TEMP_1_HIGH, 
     906                        data->ext_temp_max = TEMP_LIMIT_TO_REG(results[0]); 
     907                        LM87_write_value(client, LM87_REG_EXT_TEMP_1_HIGH, 
    806908                                            data->int_temp_max); 
    807909                   } 
    808910                   if (ctl_name == LM87_SYSCTL_TEMP1) { 
    809911                        data->int_temp_max = TEMP_LIMIT_TO_REG(results[0]); 
    810                         lm87_write_value(client, LM87_REG_INT_TEMP_HIGH, 
     912                        LM87_write_value(client, LM87_REG_INT_TEMP_HIGH, 
    811913                                            data->int_temp_max); 
    812914                   } 
     
    814916                if (*nrels_mag >= 2) { 
    815917                   if (ctl_name == LM87_SYSCTL_TEMP3) { 
    816                         data->front_amb_temp_min = 
    817                                           TEMP_LIMIT_TO_REG(results[0]); 
    818                         lm87_write_value(client, LM87_REG_2_5V_EXT_TEMP_2_LOW, 
    819                                             data->front_amb_temp_min); 
     918                        data->ext2_temp_min = TEMP_LIMIT_TO_REG(results[1]); 
     919                        LM87_write_value(client, LM87_REG_2_5V_EXT_TEMP_2_LOW, 
     920                                            data->ext2_temp_min); 
    820921                   } 
    821922                   if (ctl_name == LM87_SYSCTL_TEMP2) { 
    822                         data->cpu_temp_min = TEMP_LIMIT_TO_REG(results[0]); 
    823                         lm87_write_value(client, LM87_REG_EXT_TEMP_1_LOW, 
     923                        data->ext_temp_min = TEMP_LIMIT_TO_REG(results[1]); 
     924                        LM87_write_value(client, LM87_REG_EXT_TEMP_1_LOW, 
    824925                                            data->int_temp_min); 
    825926                   } 
    826927                   if (ctl_name == LM87_SYSCTL_TEMP1) { 
    827928                        data->int_temp_min = TEMP_LIMIT_TO_REG(results[1]); 
    828                         lm87_write_value(client, LM87_REG_INT_TEMP_LOW, 
     929                        LM87_write_value(client, LM87_REG_INT_TEMP_LOW, 
    829930                                            data->int_temp_min); 
    830931                   } 
     
    833934} 
    834935 
    835 void lm87_alarms(struct i2c_client *client, int operation, int ctl_name, 
     936void LM87_alarms(struct i2c_client *client, int operation, int ctl_name, 
    836937                    int *nrels_mag, long *results) 
    837938{ 
    838         struct lm87_data *data = client->data; 
     939        struct LM87_data *data = client->data; 
    839940        if (operation == SENSORS_PROC_REAL_INFO) 
    840941                *nrels_mag = 0; 
    841942        else if (operation == SENSORS_PROC_REAL_READ) { 
    842                 lm87_update_client(client); 
     943                LM87_update_client(client); 
    843944                results[0] = ALARMS_FROM_REG(data->alarms); 
    844945                *nrels_mag = 1; 
     
    846947} 
    847948 
    848 void lm87_fan_div(struct i2c_client *client, int operation, 
     949void LM87_fan_div(struct i2c_client *client, int operation, 
    849950                     int ctl_name, int *nrels_mag, long *results) 
    850951{ 
    851         struct lm87_data *data = client->data; 
     952/* This gets a little hairy depending on the hardware config */ 
     953 
     954        struct LM87_data *data = client->data; 
    852955        int old; 
    853956 
     
    855958                *nrels_mag = 0; 
    856959        else if (operation == SENSORS_PROC_REAL_READ) { 
    857                 lm87_update_client(client); 
    858                 results[0] = DIV_FROM_REG(data->fan_div[0]); 
    859                 results[1] = DIV_FROM_REG(data->fan_div[1]); 
     960                LM87_update_client(client); 
     961#ifndef LM87_AIN1 
     962                results[0] = DIV_FROM_REG(data->fan_div); 
     963# ifndef LM87_AIN2 
     964                results[1] = DIV_FROM_REG(data->fan2_div); 
    860965                *nrels_mag = 2; 
     966# else 
     967                *nrels_mag = 1; 
     968# endif 
     969#else /* Must be referring to fan 2 */ 
     970                results[0] = DIV_FROM_REG(data->fan2_div); 
     971                *nrels_mag = 1; 
     972#endif 
    861973        } else if (operation == SENSORS_PROC_REAL_WRITE) { 
    862                 old = lm87_read_value(client, LM87_REG_VID_FAN_DIV); 
     974                old = LM87_read_value(client, LM87_REG_VID_FAN_DIV); 
     975/* Note: it's OK to change fan2 div even if fan2 isn't enabled */ 
     976#ifndef LM87_AIN1 
    863977                if (*nrels_mag >= 2) { 
    864                         data->fan_div[1] = DIV_TO_REG(results[1]); 
    865                         old = (old & 0x3f) | (data->fan_div[1] << 6); 
     978                        data->fan2_div = DIV_TO_REG(results[1]); 
     979                        old = (old & 0x3f) | (data->fan2_div << 6); 
    866980                } 
    867981                if (*nrels_mag >= 1) { 
    868                         data->fan_div[0] = DIV_TO_REG(results[0]); 
    869                         old = (old & 0xcf) | (data->fan_div[0] << 4); 
    870                         lm87_write_value(client, LM87_REG_VID_FAN_DIV, old); 
    871                 } 
    872         } 
    873 } 
    874  
    875 void lm87_analog_out(struct i2c_client *client, int operation, 
     982                        data->fan_div = DIV_TO_REG(results[0]); 
     983                        old = (old & 0xcf) | (data->fan_div << 4); 
     984                        LM87_write_value(client, LM87_REG_VID_FAN_DIV, old); 
     985                } 
     986#else /* Must be referring to fan 2 */ 
     987                if (*nrels_mag >= 1) { 
     988                        data->fan2_div = DIV_TO_REG(results[0]); 
     989                        old = (old & 0xcf) | (data->fan2_div << 6); 
     990                        LM87_write_value(client, LM87_REG_VID_FAN_DIV, old); 
     991                } 
     992#endif 
     993        } 
     994} 
     995 
     996void LM87_analog_out(struct i2c_client *client, int operation, 
    876997                        int ctl_name, int *nrels_mag, long *results) 
    877998{ 
    878         struct lm87_data *data = client->data; 
     999        struct LM87_data *data = client->data; 
    8791000 
    8801001        if (operation == SENSORS_PROC_REAL_INFO) 
    8811002                *nrels_mag = 0; 
    8821003        else if (operation == SENSORS_PROC_REAL_READ) { 
    883                 lm87_update_client(client); 
     1004                LM87_update_client(client); 
    8841005                results[0] = data->analog_out; 
    8851006                *nrels_mag = 1; 
     
    8871008                if (*nrels_mag >= 1) { 
    8881009                        data->analog_out = results[0]; 
    889                         lm87_write_value(client, LM87_REG_ANALOG_OUT, 
     1010                        LM87_write_value(client, LM87_REG_ANALOG_OUT, 
    8901011                                            data->analog_out); 
    8911012                } 
     
    8931014} 
    8941015 
    895 void lm87_vid(struct i2c_client *client, int operation, int ctl_name, 
     1016void LM87_vid(struct i2c_client *client, int operation, int ctl_name, 
    8961017                 int *nrels_mag, long *results) 
    8971018{ 
    898         struct lm87_data *data = client->data; 
    899  
     1019        struct LM87_data *data = client->data; 
    9001020 
    9011021        if (operation == SENSORS_PROC_REAL_INFO) 
    9021022                *nrels_mag = 2; 
    9031023        else if (operation == SENSORS_PROC_REAL_READ) { 
    904                 lm87_update_client(client); 
     1024                LM87_update_client(client); 
    9051025                results[0] = VID_FROM_REG(data->vid); 
    906                 *nrels_mag = 1; 
    907         } 
    908 } 
    909  
    910 int __init sensors_lm87_init(void) 
     1026        *nrels_mag = 1; 
     1027        } 
     1028} 
     1029 
     1030int __init sensors_LM87_init(void) 
    9111031{ 
    9121032        int res; 
    9131033 
    914         printk("lm87.o version %s (%s)\n", LM_VERSION, LM_DATE); 
    915         lm87_initialized = 0; 
    916  
    917         if ((res = i2c_add_driver(&lm87_driver))) { 
     1034        printk("LM87.o version %s (%s)\n", LM_VERSION, LM_DATE); 
     1035        LM87_initialized = 0; 
     1036 
     1037        if ((res = i2c_add_driver(&LM87_driver))) { 
    9181038                printk 
    919                 ("lm87.o: Driver registration failed, module not inserted.\n"); 
    920                 lm87_cleanup(); 
     1039                    ("LM87.o: Driver registration failed, module not inserted.\n"); 
     1040                LM87_cleanup(); 
    9211041                return res; 
    9221042        } 
    923         lm87_initialized++; 
     1043        LM87_initialized++; 
    9241044        return 0; 
    9251045} 
    9261046 
    927 int __init lm87_cleanup(void) 
     1047int __init LM87_cleanup(void) 
    9281048{ 
    9291049        int res; 
    9301050 
    931         if (lm87_initialized >= 1) { 
    932                 if ((res = i2c_del_driver(&lm87_driver))) { 
     1051        if (LM87_initialized >= 1) { 
     1052                if ((res = i2c_del_driver(&LM87_driver))) { 
    9331053                        printk 
    934                ("lm87.o: Driver deregistration failed, module not removed.\n"); 
     1054                            ("LM87.o: Driver deregistration failed, module not removed.\n"); 
    9351055                        return res; 
    9361056                } 
    937                 lm87_initialized--; 
     1057                LM87_initialized--; 
    9381058        } 
    9391059        return 0; 
     
    9451065 
    9461066MODULE_AUTHOR 
    947     ("Frodo Looijaard <frodol@dds.nl>, Philip Edelbrock <phil@netroedge.com>,  
     1067    ("Frodo Looijaard <frodol@dds.nl>, 
     1068      Philip Edelbrock <phil@netroedge.com>,  
     1069      Mark Studebaker <mdsxyz123@yahoo.com>, 
    9481070      and Stephen Rousset <stephen.rousset@rocketlogix.com>"); 
    9491071 
    950 MODULE_DESCRIPTION("lm87 driver"); 
     1072MODULE_DESCRIPTION("LM87 driver"); 
    9511073 
    9521074int init_module(void) 
    9531075{ 
    954         return sensors_lm87_init(); 
     1076        return sensors_LM87_init(); 
    9551077} 
    9561078 
    9571079int cleanup_module(void) 
    9581080{ 
    959         return lm87_cleanup(); 
     1081        return LM87_cleanup(); 
    9601082} 
    9611083 
  • lm-sensors/trunk/kernel/include/sensors.h

    r953 r963  
    757757#define LM87_SYSCTL_IN4        1004 
    758758#define LM87_SYSCTL_IN5        1005 
    759 #define LM87_SYSCTL_FAN1       1101 
    760 #define LM87_SYSCTL_FAN2       1102 
    761 #define LM87_SYSCTL_TEMP1      1250 /* Degrees Celcius * 100 */ 
    762 #define LM87_SYSCTL_TEMP2      1251 /* Degrees Celcius * 100 */ 
    763 #define LM87_SYSCTL_TEMP3      1252 /* Degrees Celcius * 100 */ 
     759#define LM87_SYSCTL_AIN1       1006 
     760#define LM87_SYSCTL_AIN2       1007 
     761#define LM87_SYSCTL_FAN1       1102 
     762#define LM87_SYSCTL_FAN2       1103 
     763#define LM87_SYSCTL_TEMP1  1250 /* Degrees Celcius * 100 */ 
     764#define LM87_SYSCTL_TEMP2   1251 /* Degrees Celcius * 100 */ 
     765#define LM87_SYSCTL_TEMP3   1252 /* Degrees Celcius * 100 */ 
    764766#define LM87_SYSCTL_FAN_DIV    2000 /* 1, 2, 4 or 8 */ 
    765767#define LM87_SYSCTL_ALARMS     2001 /* bitvector */ 
     
    767769#define LM87_SYSCTL_VID        2003 
    768770 
    769 #define LM87_ALARM_IN0      0x0001 
    770 #define LM87_ALARM_IN1      0x0002 
    771 #define LM87_ALARM_IN2      0x0004 
    772 #define LM87_ALARM_IN3      0x0008 
    773 #define LM87_ALARM_IN4      0x0100 
    774 #define LM87_ALARM_IN5      0x0200 
    775 #define LM87_ALARM_TEMP1    0x0010 
    776 #define LM87_ALARM_TEMP2    0x4020  /* include D1 fault */ 
    777 #define LM87_ALARM_TEMP3    0x8001  /* include D2 fault */ 
    778 #define LM87_ALARM_FAN1     0x0040 
    779 #define LM87_ALARM_FAN2     0x0080 
    780 #define LM87_ALARM_CHAS     0x1000 
     771#define LM87_ALARM_IN0          0x0001 
     772#define LM87_ALARM_IN1          0x0002 
     773#define LM87_ALARM_IN2          0x0004 
     774#define LM87_ALARM_IN3          0x0008 
     775#define LM87_ALARM_TEMP1        0x0010 
     776#define LM87_ALARM_TEMP2        0x0020 
     777#define LM87_ALARM_TEMP3        0x0020 /* same?? */ 
     778#define LM87_ALARM_FAN1         0x0040 
     779#define LM87_ALARM_FAN2         0x0080 
     780#define LM87_ALARM_IN4          0x0100 
     781#define LM87_ALARM_IN5          0x0200 
     782#define LM87_ALARM_RESERVED1    0x0400 
     783#define LM87_ALARM_RESERVED2    0x0800 
     784#define LM87_ALARM_CHAS         0x1000 
     785#define LM87_ALARM_THERM_SIG    0x2000 
     786#define LM87_ALARM_TEMP2_FAULT  0x4000 
     787#define LM87_ALARM_TEMP3_FAULT 0x08000 
    781788 
    782789#define PCF8574_SYSCTL_STAT 1000 
  • lm-sensors/trunk/lib/chips.c

    r953 r963  
    17781778  {  
    17791779    { SENSORS_LM87_IN0, "2.5V", SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, 
    1780                         SENSORS_MODE_R, LM87_SYSCTL_IN0, VALUE(2), 2 }, 
     1780                        SENSORS_MODE_R, LM87_SYSCTL_IN0, VALUE(3), 2 }, 
    17811781    { SENSORS_LM87_IN1, "Vccp1", SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, 
    17821782                        SENSORS_MODE_R, LM87_SYSCTL_IN1, VALUE(3), 2 }, 
     
    17891789    { SENSORS_LM87_IN5, "Vccp2", SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, 
    17901790                        SENSORS_MODE_R, LM87_SYSCTL_IN5, VALUE(3), 2 }, 
     1791    { SENSORS_LM87_AIN1, "AIN1", SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, 
     1792                        SENSORS_MODE_R, LM87_SYSCTL_AIN1, VALUE(3), 0 }, 
     1793    { SENSORS_LM87_AIN2, "AIN2", SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, 
     1794                        SENSORS_MODE_R, LM87_SYSCTL_AIN2, VALUE(3), 0 }, 
    17911795    { SENSORS_LM87_IN0_MIN, "AmbTemp_min", SENSORS_LM87_IN0,  
    17921796                        SENSORS_LM87_IN0, SENSORS_MODE_RW,  
     
    18071811                        SENSORS_LM87_IN5, SENSORS_MODE_RW,  
    18081812                        LM87_SYSCTL_IN5, VALUE(1), 2 }, 
     1813    { SENSORS_LM87_AIN1_MIN, "AIN1_min", SENSORS_LM87_AIN1,  
     1814                        SENSORS_LM87_AIN1, SENSORS_MODE_RW,  
     1815                        LM87_SYSCTL_AIN1, VALUE(1), 0 }, 
     1816    { SENSORS_LM87_AIN2_MIN, "AIN2_min", SENSORS_LM87_AIN2,  
     1817                        SENSORS_LM87_AIN2, SENSORS_MODE_RW,  
     1818                        LM87_SYSCTL_AIN2, VALUE(1), 0 }, 
    18091819    { SENSORS_LM87_IN0_MAX, "AmbTemp_max", SENSORS_LM87_IN0,  
    18101820                        SENSORS_LM87_IN0, SENSORS_MODE_RW, 
     
    18251835                        SENSORS_LM87_IN5, SENSORS_MODE_RW,  
    18261836                        LM87_SYSCTL_IN5, VALUE(2), 2 }, 
     1837    { SENSORS_LM87_AIN1_MAX, "AIN1_max", SENSORS_LM87_AIN1,  
     1838                        SENSORS_LM87_AIN1, SENSORS_MODE_RW,  
     1839                        LM87_SYSCTL_AIN1, VALUE(2), 0 }, 
     1840    { SENSORS_LM87_AIN2_MAX, "AIN2_max", SENSORS_LM87_AIN2,  
     1841                        SENSORS_LM87_AIN2, SENSORS_MODE_RW,  
     1842                        LM87_SYSCTL_AIN2, VALUE(2), 0 }, 
    18271843    { SENSORS_LM87_FAN1, "fan1", SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, 
    18281844                        SENSORS_MODE_R, LM87_SYSCTL_FAN1, VALUE(2), 0 }, 
     
    18351851                        SENSORS_LM87_FAN2, SENSORS_MODE_RW,  
    18361852                        LM87_SYSCTL_FAN2, VALUE(1), 0 }, 
    1837     { SENSORS_LM87_TEMP3, "temp3", SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, 
     1853    { SENSORS_LM87_TEMP3, "CPU2 Temp", SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, 
    18381854                         SENSORS_MODE_R, LM87_SYSCTL_TEMP3, VALUE(3), 1 }, 
    18391855    { SENSORS_LM87_TEMP2, "CPU Temp", SENSORS_NO_MAPPING, SENSORS_NO_MAPPING,  
     
    18611877    { SENSORS_LM87_VID, "vid", SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, 
    18621878                         SENSORS_MODE_R, LM87_SYSCTL_VID, VALUE(1), 2 }, 
     1879/* Ho hum, this will be wrong if fan1 is disabled, but fan2 isn't.. fix?? */ 
    18631880    { SENSORS_LM87_FAN1_DIV, "fan_div", SENSORS_LM87_FAN1,  
    18641881                         SENSORS_NO_MAPPING, SENSORS_MODE_RW,  
  • lm-sensors/trunk/lib/chips.h

    r953 r963  
    829829#define SENSORS_LM87_IN4              5 /* R */ 
    830830#define SENSORS_LM87_IN5              6 /* R */ 
     831#define SENSORS_LM87_AIN1             7 /* R */ 
     832#define SENSORS_LM87_AIN2             8 /* R */ 
    831833#define SENSORS_LM87_IN0_MIN         11 /* RW */ 
    832834#define SENSORS_LM87_IN1_MIN         12 /* RW */ 
     
    835837#define SENSORS_LM87_IN4_MIN         15 /* RW */ 
    836838#define SENSORS_LM87_IN5_MIN         16 /* RW */ 
     839#define SENSORS_LM87_AIN1_MIN        17 /* RW */ 
     840#define SENSORS_LM87_AIN2_MIN        18 /* RW */ 
    837841#define SENSORS_LM87_IN0_MAX         21 /* RW */ 
    838842#define SENSORS_LM87_IN1_MAX         22 /* RW */ 
     
    841845#define SENSORS_LM87_IN4_MAX         25 /* RW */ 
    842846#define SENSORS_LM87_IN5_MAX         26 /* RW */ 
     847#define SENSORS_LM87_AIN1_MAX        27 /* RW */ 
     848#define SENSORS_LM87_AIN2_MAX        28 /* RW */ 
    843849#define SENSORS_LM87_FAN1            31 /* R */ 
    844850#define SENSORS_LM87_FAN2            32 /* R */ 
  • lm-sensors/trunk/prog/sensors/chips.c

    r959 r963  
    13631363    printf("ERROR: Can't get IN5 data!\n"); 
    13641364  free_the_label(&label); 
     1365  if (!sensors_get_label_and_valid(*name,SENSORS_LM87_AIN1,&label,&valid) && 
     1366      !sensors_get_feature(*name,SENSORS_LM87_AIN1,&cur) && 
     1367      !sensors_get_feature(*name,SENSORS_LM87_AIN1_MIN,&min) && 
     1368      !sensors_get_feature(*name,SENSORS_LM87_AIN1_MAX,&max)) { 
     1369    if (valid) { 
     1370      print_label(label,10); 
     1371      printf("%+6.2f V  (min = %+6.2f V, max = %+6.2f V)   %s\n", 
     1372             cur,min,max,alarms&LM87_ALARM_FAN1?"ALARM":""); 
     1373    } 
     1374  } else 
     1375    printf("ERROR: Can't get AIN1 data!\n"); 
     1376  free_the_label(&label); 
     1377  if (!sensors_get_label_and_valid(*name,SENSORS_LM87_AIN2,&label,&valid) && 
     1378      !sensors_get_feature(*name,SENSORS_LM87_AIN2,&cur) && 
     1379      !sensors_get_feature(*name,SENSORS_LM87_AIN2_MIN,&min) && 
     1380      !sensors_get_feature(*name,SENSORS_LM87_AIN2_MAX,&max)) { 
     1381    if (valid) { 
     1382      print_label(label,10); 
     1383      printf("%+6.2f V  (min = %+6.2f V, max = %+6.2f V)   %s\n", 
     1384             cur,min,max,alarms&LM87_ALARM_FAN2?"ALARM":""); 
     1385    } 
     1386  } else 
     1387    printf("ERROR: Can't get AIN2 data!\n"); 
     1388  free_the_label(&label); 
    13651389 
    13661390  if (!sensors_get_label_and_valid(*name,SENSORS_LM87_FAN1,&label,&valid) && 
     
    13961420      print_label(label,10); 
    13971421      print_temp_info( cur, max, min, MINMAX ); 
    1398       printf(" %s\n", alarms&LM87_ALARM_TEMP1?"ALARM":""); 
     1422      printf(" %s%s\n", alarms&LM87_ALARM_TEMP1?"ALARM":"", 
     1423        alarms&LM87_ALARM_THERM_SIG?" THERM#":""); 
    13991424    } 
    14001425  } else 
     
    14091434      print_label(label,10); 
    14101435      print_temp_info( cur, max, min, MINMAX ); 
    1411       printf(" %s\n", alarms&LM87_ALARM_TEMP2?"ALARM":""); 
     1436      printf(" %s%s\n", alarms&LM87_ALARM_TEMP2?"ALARM":"", 
     1437        alarms&LM87_ALARM_TEMP2_FAULT?" FAULT":""); 
    14121438    } 
    14131439  } else 
     
    14221448      print_label(label,10); 
    14231449      print_temp_info( cur, max, min, MINMAX ); 
    1424       printf(" %s\n", alarms&LM87_ALARM_TEMP3?"ALARM":""); 
     1450      printf(" %s%s\n", alarms&LM87_ALARM_TEMP3?"ALARM":"", 
     1451        alarms&LM87_ALARM_TEMP3_FAULT?" FAULT":""); 
    14251452    } 
    14261453  } else