Changeset 379

Show
Ignore:
Timestamp:
04/11/99 18:12:36 (14 years ago)
Author:
frodo
Message:

Major SIS5595 overhaul

* sis5595.c now understand insmod parameters
* sis5595.c now uses sis5595_ prefix instead of lm78_ prefix
* sis5595.c now supports the correct subset of the LM78 features

(it only knows about 4 voltages, 2 fans and no vid)

* added SIS5595 defines to sensors.h
* fixed a small problem in compat.h

Location:
lm-sensors/trunk/kernel
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/kernel/chips/sis5595.c

    r333 r379  
    4040#include "compat.h" 
    4141 
     42/* Addresses to scan. 
     43   Note that we can't determine the ISA address until we have initialized 
     44   our module */ 
     45static unsigned short normal_i2c[] = {SENSORS_I2C_END}; 
     46static unsigned short normal_i2c_range[] = {SENSORS_I2C_END}; 
     47static unsigned int normal_isa[] = {0x0000,SENSORS_ISA_END}; 
     48static unsigned int normal_isa_range[] = {SENSORS_ISA_END}; 
     49 
     50/* Insmod parameters */ 
     51SENSORS_INSMOD_1(sis5595); 
     52 
    4253/* 
    43    SiS southbridge has lm78 integrated on the same IC, 
    44    This drives is a customized copy of lm78.c 
     54   SiS southbridge has a LM78-like chip integrated on the same IC. 
     55   This driver is a customized copy of lm78.c 
    4556*/ 
    4657 
    47 /* Many LM78 constants specified below */ 
     58/* Many SIS5595 constants specified below */ 
    4859 
    4960/* Length of ISA address segment */ 
    50 #define LM78_EXTENT 8 
    51 #define LM78_BASE_REG 0x68 
     61#define SIS5595_EXTENT 8 
     62#define SIS5595_BASE_REG 0x68 
    5263 
    5364/* Where are the ISA address/data registers relative to the base address */ 
    54 #define LM78_ADDR_REG_OFFSET 5 
    55 #define LM78_DATA_REG_OFFSET 6 
    56  
    57 /* The LM78 registers */ 
    58 #define LM78_REG_IN_MAX(nr) (0x2b + (nr) * 2) 
    59 #define LM78_REG_IN_MIN(nr) (0x2c + (nr) * 2) 
    60 #define LM78_REG_IN(nr) (0x20 + (nr)) 
    61  
    62 #define LM78_REG_FAN_MIN(nr) (0x3a + (nr)) 
    63 #define LM78_REG_FAN(nr) (0x27 + (nr)) 
    64  
    65 #define LM78_REG_TEMP 0x27 
    66 #define LM78_REG_TEMP_OVER 0x39 
    67 #define LM78_REG_TEMP_HYST 0x3a 
    68  
    69 #define LM78_REG_ALARM1 0x41 
    70 /* Not available in SiS 5595 
    71 #define LM78_REG_ALARM2 0x42 
    72 */ 
    73  
    74 #define LM78_REG_VID_FANDIV 0x47 
    75  
    76 #define LM78_REG_CONFIG 0x40 
     65#define SIS5595_ADDR_REG_OFFSET 5 
     66#define SIS5595_DATA_REG_OFFSET 6 
     67 
     68/* The SIS5595 registers */ 
     69#define SIS5595_REG_IN_MAX(nr) (0x2b + (nr) * 2) 
     70#define SIS5595_REG_IN_MIN(nr) (0x2c + (nr) * 2) 
     71#define SIS5595_REG_IN(nr) (0x20 + (nr)) 
     72 
     73#define SIS5595_REG_FAN_MIN(nr) (0x3a + (nr)) 
     74#define SIS5595_REG_FAN(nr) (0x27 + (nr)) 
     75 
     76#define SIS5595_REG_TEMP 0x27 
     77#define SIS5595_REG_TEMP_OVER 0x39 
     78#define SIS5595_REG_TEMP_HYST 0x3a 
     79 
     80#define SIS5595_REG_ALARM1 0x41 
     81 
     82#define SIS5595_REG_FANDIV 0x47 
     83 
     84#define SIS5595_REG_CONFIG 0x40 
    7785 
    7886/* Conversions. Rounding is only done on the TO_REG variants. */ 
     
    98106#define TEMP_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*10) 
    99107 
    100 #define VID_FROM_REG(val) ((val)==0x1f?0:(val)>=0x10?510-(val)*10:\ 
    101                            (val)>=0x06?0:205-(val)*5) 
    102108#define ALARMS_FROM_REG(val) (val) 
    103109 
     
    106112 
    107113/* Initial limits. To keep them sane, we use the 'standard' translation as 
    108    specified in the LM78 sheet. Use the config file to set better limits. */ 
    109 #define LM78_INIT_IN_0 (vid==350?280:vid) 
    110 #define LM78_INIT_IN_1 (vid==350?280:vid) 
    111 #define LM78_INIT_IN_2 330 
    112 #define LM78_INIT_IN_3 (((500)   * 100)/168) 
    113 #define LM78_INIT_IN_4 (((1200)  * 10)/38) 
    114 #define LM78_INIT_IN_5 (((-1200) * -604)/2100) 
    115 #define LM78_INIT_IN_6 (((-500)  * -604)/909) 
    116  
    117 #define LM78_INIT_IN_PERCENTAGE 10 
    118  
    119 #define LM78_INIT_IN_MIN_0 \ 
    120         (LM78_INIT_IN_0 - LM78_INIT_IN_0 * LM78_INIT_IN_PERCENTAGE / 100)  
    121 #define LM78_INIT_IN_MAX_0 \ 
    122         (LM78_INIT_IN_0 + LM78_INIT_IN_0 * LM78_INIT_IN_PERCENTAGE / 100)  
    123 #define LM78_INIT_IN_MIN_1 \ 
    124         (LM78_INIT_IN_1 - LM78_INIT_IN_1 * LM78_INIT_IN_PERCENTAGE / 100)  
    125 #define LM78_INIT_IN_MAX_1 \ 
    126         (LM78_INIT_IN_1 + LM78_INIT_IN_1 * LM78_INIT_IN_PERCENTAGE / 100)  
    127 #define LM78_INIT_IN_MIN_2 \ 
    128         (LM78_INIT_IN_2 - LM78_INIT_IN_2 * LM78_INIT_IN_PERCENTAGE / 100)  
    129 #define LM78_INIT_IN_MAX_2 \ 
    130         (LM78_INIT_IN_2 + LM78_INIT_IN_2 * LM78_INIT_IN_PERCENTAGE / 100)  
    131 #define LM78_INIT_IN_MIN_3 \ 
    132         (LM78_INIT_IN_3 - LM78_INIT_IN_3 * LM78_INIT_IN_PERCENTAGE / 100)  
    133 #define LM78_INIT_IN_MAX_3 \ 
    134         (LM78_INIT_IN_3 + LM78_INIT_IN_3 * LM78_INIT_IN_PERCENTAGE / 100)  
    135 #define LM78_INIT_IN_MIN_4 \ 
    136         (LM78_INIT_IN_4 - LM78_INIT_IN_4 * LM78_INIT_IN_PERCENTAGE / 100)  
    137 #define LM78_INIT_IN_MAX_4 \ 
    138         (LM78_INIT_IN_4 + LM78_INIT_IN_4 * LM78_INIT_IN_PERCENTAGE / 100)  
    139 #define LM78_INIT_IN_MIN_5 \ 
    140         (LM78_INIT_IN_5 - LM78_INIT_IN_5 * LM78_INIT_IN_PERCENTAGE / 100)  
    141 #define LM78_INIT_IN_MAX_5 \ 
    142         (LM78_INIT_IN_5 + LM78_INIT_IN_5 * LM78_INIT_IN_PERCENTAGE / 100)  
    143 #define LM78_INIT_IN_MIN_6 \ 
    144         (LM78_INIT_IN_6 - LM78_INIT_IN_6 * LM78_INIT_IN_PERCENTAGE / 100)  
    145 #define LM78_INIT_IN_MAX_6 \ 
    146         (LM78_INIT_IN_6 + LM78_INIT_IN_6 * LM78_INIT_IN_PERCENTAGE / 100)  
    147  
    148 #define LM78_INIT_FAN_MIN_1 3000 
    149 #define LM78_INIT_FAN_MIN_2 3000 
    150 #define LM78_INIT_FAN_MIN_3 3000 
    151  
    152 #define LM78_INIT_TEMP_OVER 600 
    153 #define LM78_INIT_TEMP_HYST 500 
     114   specified in the SIS5595 sheet. Use the config file to set better limits. */ 
     115#define SIS5595_INIT_IN_0 (((1200)  * 10)/38) 
     116#define SIS5595_INIT_IN_1 (((500)   * 100)/168) 
     117#define SIS5595_INIT_IN_2 330 
     118#define SIS5595_INIT_IN_3 250 
     119 
     120#define SIS5595_INIT_IN_PERCENTAGE 10 
     121 
     122#define SIS5595_INIT_IN_MIN_0 \ 
     123        (SIS5595_INIT_IN_0 - SIS5595_INIT_IN_0 * SIS5595_INIT_IN_PERCENTAGE / 100)  
     124#define SIS5595_INIT_IN_MAX_0 \ 
     125        (SIS5595_INIT_IN_0 + SIS5595_INIT_IN_0 * SIS5595_INIT_IN_PERCENTAGE / 100)  
     126#define SIS5595_INIT_IN_MIN_1 \ 
     127        (SIS5595_INIT_IN_1 - SIS5595_INIT_IN_1 * SIS5595_INIT_IN_PERCENTAGE / 100)  
     128#define SIS5595_INIT_IN_MAX_1 \ 
     129        (SIS5595_INIT_IN_1 + SIS5595_INIT_IN_1 * SIS5595_INIT_IN_PERCENTAGE / 100)  
     130#define SIS5595_INIT_IN_MIN_2 \ 
     131        (SIS5595_INIT_IN_2 - SIS5595_INIT_IN_2 * SIS5595_INIT_IN_PERCENTAGE / 100)  
     132#define SIS5595_INIT_IN_MAX_2 \ 
     133        (SIS5595_INIT_IN_2 + SIS5595_INIT_IN_2 * SIS5595_INIT_IN_PERCENTAGE / 100)  
     134#define SIS5595_INIT_IN_MIN_3 \ 
     135        (SIS5595_INIT_IN_3 - SIS5595_INIT_IN_3 * SIS5595_INIT_IN_PERCENTAGE / 100)  
     136#define SIS5595_INIT_IN_MAX_3 \ 
     137        (SIS5595_INIT_IN_3 + SIS5595_INIT_IN_3 * SIS5595_INIT_IN_PERCENTAGE / 100)  
     138 
     139#define SIS5595_INIT_FAN_MIN_1 3000 
     140#define SIS5595_INIT_FAN_MIN_2 3000 
     141 
     142#define SIS5595_INIT_TEMP_OVER 600 
     143#define SIS5595_INIT_TEMP_HYST 500 
    154144 
    155145#ifdef MODULE 
     
    162152   some corners. */ 
    163153 
    164 /* Types of chips supported */ 
    165 enum lm78_type { lm78 }; 
    166  
    167 /* For each registered LM78, we need to keep some data in memory. That 
    168    data is pointed to by lm78_list[NR]->data. The structure itself is 
    169    dynamically allocated, at the same time when a new lm78 client is 
     154/* For each registered SIS5595, we need to keep some data in memory. That 
     155   data is pointed to by sis5595_list[NR]->data. The structure itself is 
     156   dynamically allocated, at the same time when a new sis5595 client is 
    170157   allocated. */ 
    171 struct lm78_data { 
     158struct sis5595_data { 
    172159         struct semaphore lock; 
    173160         int sysctl_id; 
    174          enum lm78_type type; 
    175161 
    176162         struct semaphore update_lock; 
     
    178164         unsigned long last_updated; /* In jiffies */ 
    179165 
    180          u8 in[7];                   /* Register value */ 
    181          u8 in_max[7];               /* Register value */ 
    182          u8 in_min[7];               /* Register value */ 
    183          u8 fan[3];                  /* Register value */ 
    184          u8 fan_min[3];              /* Register value */ 
     166         u8 in[4];                   /* Register value */ 
     167         u8 in_max[4];               /* Register value */ 
     168         u8 in_min[4];               /* Register value */ 
     169         u8 fan[2];                  /* Register value */ 
     170         u8 fan_min[2];              /* Register value */ 
    185171         u8 temp;                    /* Register value */ 
    186172         u8 temp_over;               /* Register value */ 
    187173         u8 temp_hyst;               /* Register value */ 
    188          u8 fan_div[3];              /* Register encoding, shifted right */ 
    189          u8 vid;                     /* Register encoding, combined */ 
    190          u16 alarms;                 /* Register encoding, combined */ 
     174         u8 fan_div[2];              /* Register encoding, shifted right */ 
     175         u8 alarms;                 /* Register encoding, combined */ 
    191176}; 
    192177 
    193178 
    194 static int lm78_init(void); 
    195 static int lm78_cleanup(void); 
    196  
    197 static int lm78_attach_adapter(struct i2c_adapter *adapter); 
    198 static int lm78_detect_isa(struct isa_adapter *adapter); 
    199 static int lm78_detach_client(struct i2c_client *client); 
    200 static int lm78_detach_isa(struct isa_client *client); 
    201 static int lm78_new_client(struct i2c_adapter *adapter, 
    202                            struct i2c_client *new_client); 
    203 static void lm78_remove_client(struct i2c_client *client); 
    204 static int lm78_command(struct i2c_client *client, unsigned int cmd,  
     179static int sis5595_init(void); 
     180static int sis5595_cleanup(void); 
     181 
     182static int sis5595_attach_adapter(struct i2c_adapter *adapter); 
     183static int sis5595_detect(struct i2c_adapter *adapter, int address, int kind); 
     184static int sis5595_detach_client(struct i2c_client *client); 
     185static int sis5595_command(struct i2c_client *client, unsigned int cmd,  
    205186                        void *arg); 
    206 static void lm78_inc_use (struct i2c_client *client); 
    207 static void lm78_dec_use (struct i2c_client *client); 
    208  
    209 static int lm78_read_value(struct i2c_client *client, u8 register); 
    210 static int lm78_write_value(struct i2c_client *client, u8 register, u8 value); 
    211 static void lm78_update_client(struct i2c_client *client); 
    212 static void lm78_init_client(struct i2c_client *client); 
    213  
    214  
    215 static void lm78_in(struct i2c_client *client, int operation, int ctl_name, 
     187static void sis5595_inc_use (struct i2c_client *client); 
     188static void sis5595_dec_use (struct i2c_client *client); 
     189 
     190static int sis5595_read_value(struct i2c_client *client, u8 register); 
     191static int sis5595_write_value(struct i2c_client *client, u8 register, u8 value); 
     192static void sis5595_update_client(struct i2c_client *client); 
     193static void sis5595_init_client(struct i2c_client *client); 
     194static int sis5595_find_sis(int *address); 
     195 
     196 
     197static void sis5595_in(struct i2c_client *client, int operation, int ctl_name, 
    216198                    int *nrels_mag, long *results); 
    217 static void lm78_fan(struct i2c_client *client, int operation, int ctl_name, 
     199static void sis5595_fan(struct i2c_client *client, int operation, int ctl_name, 
    218200                     int *nrels_mag, long *results); 
    219 static void lm78_temp(struct i2c_client *client, int operation, int ctl_name, 
     201static void sis5595_temp(struct i2c_client *client, int operation, int ctl_name, 
    220202                      int *nrels_mag, long *results); 
    221 static void lm78_vid(struct i2c_client *client, int operation, int ctl_name, 
    222                      int *nrels_mag, long *results); 
    223 static void lm78_alarms(struct i2c_client *client, int operation, int ctl_name, 
     203static void sis5595_alarms(struct i2c_client *client, int operation, int ctl_name, 
    224204                        int *nrels_mag, long *results); 
    225 static void lm78_fan_div(struct i2c_client *client, int operation, int ctl_name, 
     205static void sis5595_fan_div(struct i2c_client *client, int operation, int ctl_name, 
    226206                         int *nrels_mag, long *results); 
    227207 
    228 /* I choose here for semi-static LM78 allocation. Complete dynamic 
     208/* I choose here for semi-static SIS5595 allocation. Complete dynamic 
    229209   allocation could also be used; the code needed for this would probably 
    230210   take more memory than the datastructure takes now. */ 
    231 #define MAX_LM78_NR 4 
    232 static struct i2c_client *lm78_list[MAX_LM78_NR]; 
     211#define MAX_SIS5595_NR 4 
     212static struct i2c_client *sis5595_list[MAX_SIS5595_NR]; 
    233213 
    234214/* The driver. I choose to use type i2c_driver, as at is identical to both 
    235215   smbus_driver and isa_driver, and clients could be of either kind */ 
    236 static struct i2c_driver lm78_driver = { 
     216static struct i2c_driver sis5595_driver = { 
    237217  /* name */            "SiS 5595", 
    238218  /* id */              I2C_DRIVERID_SIS5595, 
    239219  /* flags */           DF_NOTIFY, 
    240   /* attach_adapter */  &lm78_attach_adapter, 
    241   /* detach_client */   &lm78_detach_client, 
    242   /* command */         &lm78_command, 
    243   /* inc_use */         &lm78_inc_use, 
    244   /* dec_use */         &lm78_dec_use 
     220  /* attach_adapter */  &sis5595_attach_adapter, 
     221  /* detach_client */   &sis5595_detach_client, 
     222  /* command */         &sis5595_command, 
     223  /* inc_use */         &sis5595_inc_use, 
     224  /* dec_use */         &sis5595_dec_use 
    245225}; 
    246226 
    247 /* Used by lm78_init/cleanup */ 
    248 static int lm78_initialized = 0; 
     227/* Used by sis5595_init/cleanup */ 
     228static int sis5595_initialized = 0; 
    249229 
    250230/* The /proc/sys entries */ 
    251 /* These files are created for each detected LM78. This is just a template; 
     231/* These files are created for each detected SIS5595. This is just a template; 
    252232   though at first sight, you might think we could use a statically 
    253233   allocated list, we need some way to get back to the parent - which 
    254234   is done through one of the 'extra' fields which are initialized  
    255235   when a new copy is allocated. */ 
    256 static ctl_table lm78_dir_table_template[] = { 
    257   { LM78_SYSCTL_IN0, "in0", NULL, 0, 0644, NULL, &sensors_proc_real, 
    258     &sensors_sysctl_real, NULL, &lm78_in }, 
    259   { LM78_SYSCTL_IN1, "in1", NULL, 0, 0644, NULL, &sensors_proc_real, 
    260     &sensors_sysctl_real, NULL, &lm78_in }, 
    261   { LM78_SYSCTL_IN2, "in2", NULL, 0, 0644, NULL, &sensors_proc_real, 
    262     &sensors_sysctl_real, NULL, &lm78_in }, 
    263   { LM78_SYSCTL_IN3, "in3", NULL, 0, 0644, NULL, &sensors_proc_real, 
    264     &sensors_sysctl_real, NULL, &lm78_in }, 
    265   { LM78_SYSCTL_IN4, "in4", NULL, 0, 0644, NULL, &sensors_proc_real, 
    266     &sensors_sysctl_real, NULL, &lm78_in }, 
    267   { LM78_SYSCTL_IN5, "in5", NULL, 0, 0644, NULL, &sensors_proc_real, 
    268     &sensors_sysctl_real, NULL, &lm78_in }, 
    269   { LM78_SYSCTL_IN6, "in6", NULL, 0, 0644, NULL, &sensors_proc_real, 
    270     &sensors_sysctl_real, NULL, &lm78_in }, 
    271   { LM78_SYSCTL_FAN1, "fan1", NULL, 0, 0644, NULL, &sensors_proc_real, 
    272     &sensors_sysctl_real, NULL, &lm78_fan }, 
    273   { LM78_SYSCTL_FAN2, "fan2", NULL, 0, 0644, NULL, &sensors_proc_real, 
    274     &sensors_sysctl_real, NULL, &lm78_fan }, 
    275   { LM78_SYSCTL_FAN3, "fan3", NULL, 0, 0644, NULL, &sensors_proc_real, 
    276     &sensors_sysctl_real, NULL, &lm78_fan }, 
    277   { LM78_SYSCTL_TEMP, "temp", NULL, 0, 0644, NULL, &sensors_proc_real, 
    278     &sensors_sysctl_real, NULL, &lm78_temp }, 
    279   { LM78_SYSCTL_VID, "vid", NULL, 0, 0444, NULL, &sensors_proc_real, 
    280     &sensors_sysctl_real, NULL, &lm78_vid }, 
    281   { LM78_SYSCTL_FAN_DIV, "fan_div", NULL, 0, 0644, NULL, &sensors_proc_real, 
    282     &sensors_sysctl_real, NULL, &lm78_fan_div }, 
    283   { LM78_SYSCTL_ALARMS, "alarms", NULL, 0, 0444, NULL, &sensors_proc_real, 
    284     &sensors_sysctl_real, NULL, &lm78_alarms }, 
     236static ctl_table sis5595_dir_table_template[] = { 
     237  { SIS5595_SYSCTL_IN0, "in0", NULL, 0, 0644, NULL, &sensors_proc_real, 
     238    &sensors_sysctl_real, NULL, &sis5595_in }, 
     239  { SIS5595_SYSCTL_IN1, "in1", NULL, 0, 0644, NULL, &sensors_proc_real, 
     240    &sensors_sysctl_real, NULL, &sis5595_in }, 
     241  { SIS5595_SYSCTL_IN2, "in2", NULL, 0, 0644, NULL, &sensors_proc_real, 
     242    &sensors_sysctl_real, NULL, &sis5595_in }, 
     243  { SIS5595_SYSCTL_IN3, "in3", NULL, 0, 0644, NULL, &sensors_proc_real, 
     244    &sensors_sysctl_real, NULL, &sis5595_in }, 
     245  { SIS5595_SYSCTL_FAN1, "fan1", NULL, 0, 0644, NULL, &sensors_proc_real, 
     246    &sensors_sysctl_real, NULL, &sis5595_fan }, 
     247  { SIS5595_SYSCTL_FAN2, "fan2", NULL, 0, 0644, NULL, &sensors_proc_real, 
     248    &sensors_sysctl_real, NULL, &sis5595_fan }, 
     249  { SIS5595_SYSCTL_TEMP, "temp", NULL, 0, 0644, NULL, &sensors_proc_real, 
     250    &sensors_sysctl_real, NULL, &sis5595_temp }, 
     251  { SIS5595_SYSCTL_FAN_DIV, "fan_div", NULL, 0, 0644, NULL, &sensors_proc_real, 
     252    &sensors_sysctl_real, NULL, &sis5595_fan_div }, 
     253  { SIS5595_SYSCTL_ALARMS, "alarms", NULL, 0, 0444, NULL, &sensors_proc_real, 
     254    &sensors_sysctl_real, NULL, &sis5595_alarms }, 
    285255  { 0 } 
    286256}; 
    287257 
    288258/* This is called when the module is loaded */ 
    289 int lm78_attach_adapter(struct i2c_adapter *adapter) 
    290 { 
    291     return lm78_detect_isa((struct isa_adapter *) adapter); 
    292 } 
    293  
    294 /* This is called when the module is loaded */ 
    295 int lm78_detach_client(struct i2c_client *client) 
    296 { 
    297     return lm78_detach_isa((struct isa_client *) client); 
    298 } 
    299  
    300 /* Locate SiS bridge and correct base address for LM78 */ 
    301 #if LINUX_VERSION_CODE >= 0x020136 /* 2.1.54 */ 
    302 static int find_sis(int *address) 
    303 { 
     259int sis5595_attach_adapter(struct i2c_adapter *adapter) 
     260{ 
     261  return sensors_detect(adapter,&addr_data,sis5595_detect); 
     262} 
     263 
     264/* Locate SiS bridge and correct base address for SIS5595 */ 
     265int sis5595_find_sis(int *address) 
     266{ 
     267#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,54)) 
    304268  struct pci_dev *s_bridge; 
     269#else 
     270  unsigned char SIS_bus, SIS_devfn; 
     271#endif 
    305272  u16 val; 
    306273 
     
    308275    return -ENODEV; 
    309276 
    310   s_bridge = pci_find_device( 
    311                 PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503, NULL); 
     277#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,54)) 
     278  if (! (s_bridge = pci_find_device( 
     279                   PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503, NULL))); 
    312280                 
    313   if (! s_bridge) 
     281#else 
     282  if(pcibios_find_device( 
     283                PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503, 0, 
     284                &SIS_bus, &SIS_devfn)) 
     285#endif 
    314286    return -ENODEV; 
    315287 
     288 
    316289  if ( PCIBIOS_SUCCESSFUL != 
    317         pci_read_config_word(s_bridge, LM78_BASE_REG, &val)) 
     290        pci_read_config_word_united(s_bridge, SIS_bus, SIS_devfn,  
     291                                    SIS5595_BASE_REG, &val)) 
    318292    return -ENODEV; 
    319293                 
     
    322296} 
    323297 
    324 #else 
    325  
    326 static int find_sis(int *address) 
    327 { 
    328   unsigned char SIS_bus, SIS_devfn; 
    329   u16 val; 
    330    
    331   if (! pcibios_present()) 
    332     return -ENODEV; 
    333                  
    334   if(pcibios_find_device( 
    335                 PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503, 0, 
    336                 &SIS_bus, &SIS_devfn)) 
    337     return -ENODEV; 
    338          
    339   if ( PCIBIOS_SUCCESSFUL != 
    340     pcibios_read_config_word(SIS_bus, SIS_devfn, LM78_BASE_REG, &val)) 
    341     return -ENODEV; 
    342  
    343   *address = (val & 0xfff8); 
     298int sis5595_detect(struct i2c_adapter *adapter, int address, int kind) 
     299{ 
     300  int i; 
     301  struct i2c_client *new_client; 
     302  struct sis5595_data *data; 
     303  int err=0; 
     304  const char *type_name = ""; 
     305  const char *client_name = ""; 
     306 
     307  /* Make sure we are probing the ISA bus!! This is just a safety check 
     308     at this moment; sensors_detect really won't call us for I2C busses. */ 
     309#ifdef DEBUG 
     310  if (!i2c_is_isa_adapter(adapter)) { 
     311    printk("sis5595.o: sis5595_detect called for an I2C bus adapter?!?\n"); 
     312    return 0; 
     313  } 
     314#endif 
     315 
     316  if (check_region(address,SIS5595_EXTENT)) 
     317    goto ERROR0; 
     318 
     319  /* If this is the address as indicated by the SIS5595 chipset, we don't 
     320     do any futher probing */ 
     321  if ((kind < 0) && (address == normal_isa[0])) 
     322    kind = 0; 
     323 
     324  /* Probe whether there is anything available on this address. */ 
     325  if (kind < 0) { 
     326#define REALLY_SLOW_IO 
     327    /* We need the timeouts for at least some LM78-like chips. But only 
     328       if we read 'undefined' registers. */ 
     329    i = inb_p(address + 1); 
     330    if (inb_p(address + 2) != i) 
     331      goto ERROR0; 
     332    if (inb_p(address + 3) != i) 
     333      goto ERROR0; 
     334    if (inb_p(address + 7) != i) 
     335      goto ERROR0; 
     336#undef REALLY_SLOW_IO 
     337 
     338    /* Let's just hope nothing breaks here */ 
     339    i = inb_p(address + 5) & 0x7f; 
     340    outb_p(~i & 0x7f,address+5); 
     341    if ((inb_p(address + 5) & 0x7f) != (~i & 0x7f)) { 
     342      outb_p(i,address+5); 
     343      return 0; 
     344    } 
     345  } 
     346 
     347  /* OK. For now, we presume we have a valid client. We now create the 
     348     client structure, even though we cannot fill it completely yet. 
     349     But it allows us to access sis5595_{read,write}_value. */ 
     350 
     351  if (! (new_client = kmalloc(sizeof(struct isa_client) + 
     352                              sizeof(struct sis5595_data), 
     353                              GFP_KERNEL))) { 
     354    err = -ENOMEM; 
     355    goto ERROR0; 
     356  } 
     357 
     358  data = (struct sis5595_data *) (((struct isa_client *) new_client) + 1); 
     359  new_client->addr = 0; 
     360  ((struct isa_client *) new_client)->isa_addr = address; 
     361  data->lock = MUTEX; 
     362  new_client->data = data; 
     363  new_client->adapter = adapter; 
     364  new_client->driver = &sis5595_driver; 
     365 
     366  /* Now, we do the remaining detection. */ 
     367 
     368  if (kind < 0) { 
     369    if (sis5595_read_value(new_client,SIS5595_REG_CONFIG) & 0x80) 
     370      goto ERROR1; 
     371  } 
     372 
     373  /* Determine the chip type. */ 
     374  if (kind <= 0)  
     375    kind = sis5595; 
     376 
     377  if (kind == sis5595) { 
     378    type_name = "sis5595"; 
     379    client_name = "SIS5595 chip"; 
     380  } else { 
     381#ifdef DEBUG 
     382    printk("sis5595.o: Internal error: unknown kind (%d)?!?",kind); 
     383#endif 
     384    goto ERROR1; 
     385  } 
     386 
     387  /* Reserve the ISA region */ 
     388  request_region(address, SIS5595_EXTENT, type_name); 
     389 
     390  /* Fill in the remaining client fields and put it into the global list */ 
     391  strcpy(new_client->name,client_name); 
     392 
     393  for(i = 0; i < MAX_SIS5595_NR; i++) 
     394    if (! sis5595_list[i]) 
     395      break; 
     396  if (i == MAX_SIS5595_NR) { 
     397    printk("sis5595.o: No empty slots left, recompile and heighten " 
     398           "MAX_SIS5595_NR!\n"); 
     399    err = -ENOMEM; 
     400    goto ERROR2; 
     401  } 
     402  sis5595_list[i] = new_client; 
     403  new_client->id = i; 
     404  data->valid = 0; 
     405  data->update_lock = MUTEX; 
     406 
     407  /* Tell the I2C layer a new client has arrived */ 
     408  if ((err = i2c_attach_client(new_client))) 
     409    goto ERROR3; 
     410 
     411  /* Register a new directory entry with module sensors */ 
     412  if ((i = sensors_register_entry((struct i2c_client *) new_client, 
     413                                  type_name, 
     414                                  sis5595_dir_table_template)) < 0) { 
     415    err = i; 
     416    goto ERROR4; 
     417  } 
     418  data->sysctl_id = i; 
     419 
     420  /* Initialize the SIS5595 chip */ 
     421  sis5595_init_client(new_client); 
    344422  return 0; 
    345 } 
    346 #endif 
    347  
    348  
    349 /* Register and initialize lm78 it. */ 
    350 int lm78_detect_isa(struct isa_adapter *adapter) 
    351 { 
    352   int address = 0, err = 0; 
    353   struct isa_client *new_client; 
    354   enum lm78_type type; 
    355   const char *type_name; 
    356   const char *client_name; 
    357  
    358   /* OK, this is detection. */ 
    359  
    360   if ((err=find_sis(&address))) { 
    361     printk("SiS 5595 southbridge not found\n"); 
    362     return err; 
    363   }  
    364    
    365   if ( (err = check_region(address, LM78_EXTENT)) < 0 ) 
    366   { 
    367     printk("sis5595.o: IO 0x%x-0x%x already in use\n", 
    368             address, address + LM78_EXTENT); 
    369     return err; 
    370   } 
    371 /* 
    372   printk("sis5595.o: lm78 io base at 0x%4x\n", address); 
    373 */       
    374   type = lm78; 
    375   type_name = "sis5595"; 
    376   client_name = "SiS 5595 Sensor"; 
    377  
    378   request_region(address, LM78_EXTENT, type_name); 
    379  
    380   /* Allocate space for a new client structure */ 
    381   if (! (new_client = kmalloc(sizeof(struct isa_client) +  
    382                               sizeof(struct lm78_data), 
    383                              GFP_KERNEL))) 
    384   { 
    385     err=-ENOMEM; 
    386     goto ERROR1; 
    387   }  
    388  
    389   /* Fill the new client structure with data */ 
    390   new_client->data = (struct lm78_data *) (new_client + 1); 
    391   new_client->addr = 0; 
    392   strcpy(new_client->name,client_name); 
    393   ((struct lm78_data *) (new_client->data))->type = type; 
    394   new_client->isa_addr = address; 
    395   if ((err = lm78_new_client((struct i2c_adapter *) adapter, 
    396                              (struct i2c_client *) new_client))) 
    397     goto ERROR2; 
    398  
    399   /* Tell i2c-core a new client has arrived */ 
    400   if ((err = isa_attach_client(new_client))) 
    401     goto ERROR3; 
    402      
    403   /* Register a new directory entry with module sensors */ 
    404   if ((err = sensors_register_entry((struct i2c_client *) new_client, 
    405                                     type_name, 
    406                                     lm78_dir_table_template)) < 0) 
    407     goto ERROR4; 
    408   ((struct lm78_data *) (new_client->data)) -> sysctl_id = err; 
    409   err = 0; 
    410  
    411   /* Initialize the LM78 chip */ 
    412   lm78_init_client((struct i2c_client *) new_client); 
    413   return err; 
    414423 
    415424/* OK, this is not exactly good programming practice, usually. But it is 
     
    417426 
    418427ERROR4: 
    419     isa_detach_client(new_client); 
     428  i2c_detach_client(new_client); 
    420429ERROR3: 
    421     lm78_remove_client((struct i2c_client *) new_client); 
     430  for (i = 0; i < MAX_SIS5595_NR; i++) 
     431    if (new_client == sis5595_list[i]) 
     432      sis5595_list[i] = NULL; 
    422433ERROR2: 
    423     kfree(new_client); 
     434  release_region(address,SIS5595_EXTENT); 
    424435ERROR1: 
    425     release_region(address, LM78_EXTENT); 
    426  
     436  kfree(new_client); 
     437ERROR0: 
    427438  return err; 
    428439} 
    429440 
    430 /* Deregister and remove a LM78 client */ 
    431 int lm78_detach_isa(struct isa_client *client) 
     441int sis5595_detach_client(struct i2c_client *client) 
    432442{ 
    433443  int err,i; 
    434   for (i = 0; i < MAX_LM78_NR; i++) 
    435     if ((client == (struct isa_client *) (lm78_list[i]))) 
     444 
     445  sensors_deregister_entry(((struct sis5595_data *)(client->data))->sysctl_id); 
     446 
     447  if ((err = i2c_detach_client(client))) { 
     448    printk("sis5595.o: Client deregistration failed, client not detached.\n"); 
     449    return err; 
     450  } 
     451 
     452  for (i = 0; i < MAX_SIS5595_NR; i++) 
     453    if (client == sis5595_list[i]) 
    436454      break; 
    437   if (i == MAX_LM78_NR) { 
     455  if ((i == MAX_SIS5595_NR)) { 
    438456    printk("sis5595.o: Client to detach not found.\n"); 
    439457    return -ENOENT; 
    440458  } 
    441  
    442   sensors_deregister_entry(((struct lm78_data *)(client->data))->sysctl_id); 
    443  
    444   if ((err = isa_detach_client(client))) { 
    445     printk("sis5595.o: Client deregistration failed, client not detached.\n"); 
    446     return err; 
    447   } 
    448   lm78_remove_client((struct i2c_client *) client); 
    449   release_region(client->isa_addr,LM78_EXTENT); 
     459  sis5595_list[i] = NULL; 
     460 
     461  release_region(((struct isa_client *)client)->isa_addr,SIS5595_EXTENT); 
    450462  kfree(client); 
     463 
    451464  return 0; 
    452465} 
    453466 
    454 /* Find a free slot, and initialize most of the fields */ 
    455 int lm78_new_client(struct i2c_adapter *adapter, 
    456                     struct i2c_client *new_client) 
    457 { 
    458   int i; 
    459   struct lm78_data *data; 
    460  
    461   /* First, seek out an empty slot */ 
    462   for(i = 0; i < MAX_LM78_NR; i++) 
    463     if (! lm78_list[i]) 
    464       break; 
    465   if (i == MAX_LM78_NR) { 
    466     printk("sis5595.o: No empty slots left, recompile and heighten " 
    467            "MAX_LM78_NR!\n"); 
    468     return -ENOMEM; 
    469   } 
    470    
    471   lm78_list[i] = new_client; 
    472   new_client->id = i; 
    473   new_client->adapter = adapter; 
    474   new_client->driver = &lm78_driver; 
    475   data = new_client->data; 
    476   data->valid = 0; 
    477   data->lock = MUTEX; 
    478   data->update_lock = MUTEX; 
     467/* No commands defined yet */ 
     468int sis5595_command(struct i2c_client *client, unsigned int cmd, void *arg) 
     469{ 
    479470  return 0; 
    480471} 
    481472 
    482 /* Inverse of lm78_new_client */ 
    483 void lm78_remove_client(struct i2c_client *client) 
    484 { 
    485   int i; 
    486   for (i = 0; i < MAX_LM78_NR; i++) 
    487     if (client == lm78_list[i])  
    488       lm78_list[i] = NULL; 
    489 } 
    490  
    491 /* No commands defined yet */ 
    492 int lm78_command(struct i2c_client *client, unsigned int cmd, void *arg) 
    493 { 
    494   return 0; 
    495 } 
    496  
    497473/* Nothing here yet */ 
    498 void lm78_inc_use (struct i2c_client *client) 
     474void sis5595_inc_use (struct i2c_client *client) 
    499475{ 
    500476#ifdef MODULE 
     
    504480 
    505481/* Nothing here yet */ 
    506 void lm78_dec_use (struct i2c_client *client) 
     482void sis5595_dec_use (struct i2c_client *client) 
    507483{ 
    508484#ifdef MODULE 
     
    515491   There are some ugly typecasts here, but the good new is - they should 
    516492   nowhere else be necessary! */ 
    517 int lm78_read_value(struct i2c_client *client, u8 reg) 
     493int sis5595_read_value(struct i2c_client *client, u8 reg) 
    518494{ 
    519495    int res; 
    520496     
    521497    down((struct semaphore *) (client->data)); 
     498    down(& (((struct sis5595_data *) (client->data)) -> lock)); 
    522499    outb_p(reg,(((struct isa_client *) client)->isa_addr) +  
    523                LM78_ADDR_REG_OFFSET); 
     500               SIS5595_ADDR_REG_OFFSET); 
    524501    res = inb_p((((struct isa_client *) client)->isa_addr) +  
    525                 LM78_DATA_REG_OFFSET); 
    526     up((struct semaphore *) (client->data)); 
     502                SIS5595_DATA_REG_OFFSET); 
     503    up( & (((struct sis5595_data *) (client->data)) -> lock)); 
    527504    return res; 
    528505} 
     
    531508   There are some ugly typecasts here, but the good new is - they should 
    532509   nowhere else be necessary! */ 
    533 int lm78_write_value(struct i2c_client *client, u8 reg, u8 value) 
    534 { 
    535     down((struct semaphore *) (client->data)); 
    536     outb_p(reg,((struct isa_client *) client)->isa_addr + LM78_ADDR_REG_OFFSET); 
    537     outb_p(value,((struct isa_client *) client)->isa_addr + LM78_DATA_REG_OFFSET); 
    538     up((struct semaphore *) (client->data)); 
     510int sis5595_write_value(struct i2c_client *client, u8 reg, u8 value) 
     511{ 
     512    down(& (((struct sis5595_data *) (client->data)) -> lock)); 
     513    outb_p(reg,((struct isa_client *) client)->isa_addr + SIS5595_ADDR_REG_OFFSET); 
     514    outb_p(value,((struct isa_client *) client)->isa_addr + SIS5595_DATA_REG_OFFSET); 
     515    up( & (((struct sis5595_data *) (client->data)) -> lock)); 
    539516    return 0; 
    540517} 
    541518 
    542 /* Called when we have found a new LM78. It should set limits, etc. */ 
    543 void lm78_init_client(struct i2c_client *client) 
    544 { 
    545   int vid; 
    546  
     519/* Called when we have found a new SIS5595. It should set limits, etc. */ 
     520void sis5595_init_client(struct i2c_client *client) 
     521{ 
    547522  /* Reset all except Watchdog values and last conversion values 
    548523     This sets fan-divs to 2, among others */ 
    549   lm78_write_value(client,LM78_REG_CONFIG,0x80); 
    550  
    551   vid = lm78_read_value(client,LM78_REG_VID_FANDIV) & 0x0f; 
    552   vid |= 0x10; 
    553   vid = VID_FROM_REG(vid); 
    554  
    555   lm78_write_value(client,LM78_REG_IN_MIN(0),IN_TO_REG(LM78_INIT_IN_MIN_0)); 
    556   lm78_write_value(client,LM78_REG_IN_MAX(0),IN_TO_REG(LM78_INIT_IN_MAX_0)); 
    557   lm78_write_value(client,LM78_REG_IN_MIN(1),IN_TO_REG(LM78_INIT_IN_MIN_1)); 
    558   lm78_write_value(client,LM78_REG_IN_MAX(1),IN_TO_REG(LM78_INIT_IN_MAX_1)); 
    559   lm78_write_value(client,LM78_REG_IN_MIN(2),IN_TO_REG(LM78_INIT_IN_MIN_2)); 
    560   lm78_write_value(client,LM78_REG_IN_MAX(2),IN_TO_REG(LM78_INIT_IN_MAX_2)); 
    561   lm78_write_value(client,LM78_REG_IN_MIN(3),IN_TO_REG(LM78_INIT_IN_MIN_3)); 
    562   lm78_write_value(client,LM78_REG_IN_MAX(3),IN_TO_REG(LM78_INIT_IN_MAX_3)); 
    563   lm78_write_value(client,LM78_REG_IN_MIN(4),IN_TO_REG(LM78_INIT_IN_MIN_4)); 
    564   lm78_write_value(client,LM78_REG_IN_MAX(4),IN_TO_REG(LM78_INIT_IN_MAX_4)); 
    565   lm78_write_value(client,LM78_REG_IN_MIN(5),IN_TO_REG(LM78_INIT_IN_MIN_5)); 
    566   lm78_write_value(client,LM78_REG_IN_MAX(5),IN_TO_REG(LM78_INIT_IN_MAX_5)); 
    567   lm78_write_value(client,LM78_REG_IN_MIN(6),IN_TO_REG(LM78_INIT_IN_MIN_6)); 
    568   lm78_write_value(client,LM78_REG_IN_MAX(6),IN_TO_REG(LM78_INIT_IN_MAX_6)); 
    569   lm78_write_value(client,LM78_REG_FAN_MIN(1), 
    570                    FAN_TO_REG(LM78_INIT_FAN_MIN_1,2)); 
    571   lm78_write_value(client,LM78_REG_FAN_MIN(2), 
    572                    FAN_TO_REG(LM78_INIT_FAN_MIN_2,2)); 
    573   lm78_write_value(client,LM78_REG_FAN_MIN(3), 
    574                    FAN_TO_REG(LM78_INIT_FAN_MIN_3,2)); 
    575   lm78_write_value(client,LM78_REG_TEMP_OVER,TEMP_TO_REG(LM78_INIT_TEMP_OVER)); 
    576   lm78_write_value(client,LM78_REG_TEMP_HYST,TEMP_TO_REG(LM78_INIT_TEMP_HYST)); 
     524  sis5595_write_value(client,SIS5595_REG_CONFIG,0x80); 
     525 
     526  sis5595_write_value(client,SIS5595_REG_IN_MIN(0),IN_TO_REG(SIS5595_INIT_IN_MIN_0)); 
     527  sis5595_write_value(client,SIS5595_REG_IN_MAX(0),IN_TO_REG(SIS5595_INIT_IN_MAX_0)); 
     528  sis5595_write_value(client,SIS5595_REG_IN_MIN(1),IN_TO_REG(SIS5595_INIT_IN_MIN_1)); 
     529  sis5595_write_value(client,SIS5595_REG_IN_MAX(1),IN_TO_REG(SIS5595_INIT_IN_MAX_1)); 
     530  sis5595_write_value(client,SIS5595_REG_IN_MIN(2),IN_TO_REG(SIS5595_INIT_IN_MIN_2)); 
     531  sis5595_write_value(client,SIS5595_REG_IN_MAX(2),IN_TO_REG(SIS5595_INIT_IN_MAX_2)); 
     532  sis5595_write_value(client,SIS5595_REG_IN_MIN(3),IN_TO_REG(SIS5595_INIT_IN_MIN_3)); 
     533  sis5595_write_value(client,SIS5595_REG_IN_MAX(3),IN_TO_REG(SIS5595_INIT_IN_MAX_3)); 
     534  sis5595_write_value(client,SIS5595_REG_FAN_MIN(1), 
     535                   FAN_TO_REG(SIS5595_INIT_FAN_MIN_1,2)); 
     536  sis5595_write_value(client,SIS5595_REG_FAN_MIN(2), 
     537                   FAN_TO_REG(SIS5595_INIT_FAN_MIN_2,2)); 
     538  sis5595_write_value(client,SIS5595_REG_TEMP_OVER,TEMP_TO_REG(SIS5595_INIT_TEMP_OVER)); 
     539  sis5595_write_value(client,SIS5595_REG_TEMP_HYST,TEMP_TO_REG(SIS5595_INIT_TEMP_HYST)); 
    577540 
    578541  /* Start monitoring */ 
    579   lm78_write_value(client,LM78_REG_CONFIG, 
    580                    (lm78_read_value(client,LM78_REG_CONFIG) & 0xf7) | 0x01); 
     542  sis5595_write_value(client,SIS5595_REG_CONFIG, 
     543                   (sis5595_read_value(client,SIS5595_REG_CONFIG) & 0xf7) | 0x01); 
    581544   
    582545} 
    583546 
    584 void lm78_update_client(struct i2c_client *client) 
    585 { 
    586   struct lm78_data *data = client->data; 
     547void sis5595_update_client(struct i2c_client *client) 
     548{ 
     549  struct sis5595_data *data = client->data; 
    587550  int i; 
    588551 
     
    593556 
    594557#ifdef DEBUG 
    595     printk("Starting lm78 update\n"); 
     558    printk("Starting sis5595 update\n"); 
    596559#endif 
    597     for (i = 0; i <= 6; i++) { 
    598       data->in[i]     = lm78_read_value(client,LM78_REG_IN(i)); 
    599       data->in_min[i] = lm78_read_value(client,LM78_REG_IN_MIN(i)); 
    600       data->in_max[i] = lm78_read_value(client,LM78_REG_IN_MAX(i)); 
    601     } 
    602     for (i = 1; i <= 3; i++) { 
    603       data->fan[i-1] = lm78_read_value(client,LM78_REG_FAN(i)); 
    604       data->fan_min[i-1] = lm78_read_value(client,LM78_REG_FAN_MIN(i)); 
    605     } 
    606     data->temp = lm78_read_value(client,LM78_REG_TEMP); 
    607     data->temp_over = lm78_read_value(client,LM78_REG_TEMP_OVER); 
    608     data->temp_hyst = lm78_read_value(client,LM78_REG_TEMP_HYST); 
    609     i = lm78_read_value(client,LM78_REG_VID_FANDIV); 
    610     data->vid = i & 0x0f; 
    611     data->vid |= 0x10; 
     560    for (i = 0; i <= 3; i++) { 
     561      data->in[i]     = sis5595_read_value(client,SIS5595_REG_IN(i)); 
     562      data->in_min[i] = sis5595_read_value(client,SIS5595_REG_IN_MIN(i)); 
     563      data->in_max[i] = sis5595_read_value(client,SIS5595_REG_IN_MAX(i)); 
     564    } 
     565    for (i = 1; i <= 2; i++) { 
     566      data->fan[i-1] = sis5595_read_value(client,SIS5595_REG_FAN(i)); 
     567      data->fan_min[i-1] = sis5595_read_value(client,SIS5595_REG_FAN_MIN(i)); 
     568    } 
     569    data->temp = sis5595_read_value(client,SIS5595_REG_TEMP); 
     570    data->temp_over = sis5595_read_value(client,SIS5595_REG_TEMP_OVER); 
     571    data->temp_hyst = sis5595_read_value(client,SIS5595_REG_TEMP_HYST); 
     572    i = sis5595_read_value(client,SIS5595_REG_FANDIV); 
    612573    data->fan_div[0] = (i >> 4) & 0x03; 
    613574    data->fan_div[1] = i >> 6; 
    614     data->alarms = lm78_read_value(client,LM78_REG_ALARM1); 
    615 /* Not available in SiS 5595 
    616                  + (lm78_read_value(client,LM78_REG_ALARM2) << 8); 
    617 */ 
     575    data->alarms = sis5595_read_value(client,SIS5595_REG_ALARM1); 
    618576    data->last_updated = jiffies; 
    619577    data->valid = 1; 
    620  
    621     data->fan_div[2] = 1; 
    622578  } 
    623579 
     
    639595   good practice, but as long as you put less than about 5 values in results, 
    640596   you can assume it is large enough. */ 
    641 void lm78_in(struct i2c_client *client, int operation, int ctl_name,  
     597void sis5595_in(struct i2c_client *client, int operation, int ctl_name,  
    642598             int *nrels_mag, long *results) 
    643599{ 
    644   struct lm78_data *data = client->data; 
    645   int nr = ctl_name - LM78_SYSCTL_IN0; 
     600  struct sis5595_data *data = client->data; 
     601  int nr = ctl_name - SIS5595_SYSCTL_IN0; 
    646602 
    647603  if (operation == SENSORS_PROC_REAL_INFO) 
    648604    *nrels_mag = 2; 
    649605  else if (operation == SENSORS_PROC_REAL_READ) { 
    650     lm78_update_client(client); 
     606    sis5595_update_client(client); 
    651607    results[0] = IN_FROM_REG(data->in_min[nr]); 
    652608    results[1] = IN_FROM_REG(data->in_max[nr]); 
     
    656612      if (*nrels_mag >= 1) { 
    657613        data->in_min[nr] = IN_TO_REG(results[0]); 
    658         lm78_write_value(client,LM78_REG_IN_MIN(nr),data->in_min[nr]); 
     614        sis5595_write_value(client,SIS5595_REG_IN_MIN(nr),data->in_min[nr]); 
    659615      } 
    660616      if (*nrels_mag >= 2) { 
    661617        data->in_max[nr] = IN_TO_REG(results[1]); 
    662         lm78_write_value(client,LM78_REG_IN_MAX(nr),data->in_max[nr]); 
     618        sis5595_write_value(client,SIS5595_REG_IN_MAX(nr),data->in_max[nr]); 
    663619      } 
    664620  } 
    665621} 
    666622 
    667 void lm78_fan(struct i2c_client *client, int operation, int ctl_name, 
     623void sis5595_fan(struct i2c_client *client, int operation, int ctl_name, 
    668624              int *nrels_mag, long *results) 
    669625{ 
    670   struct lm78_data *data = client->data; 
    671   int nr = ctl_name - LM78_SYSCTL_FAN1 + 1; 
     626  struct sis5595_data *data = client->data; 
     627  int nr = ctl_name - SIS5595_SYSCTL_FAN1 + 1; 
    672628 
    673629  if (operation == SENSORS_PROC_REAL_INFO) 
    674630    *nrels_mag = 0; 
    675631  else if (operation == SENSORS_PROC_REAL_READ) { 
    676     lm78_update_client(client); 
     632    sis5595_update_client(client); 
    677633    results[0] = FAN_FROM_REG(data->fan_min[nr-1], 
    678634                 DIV_FROM_REG(data->fan_div[nr-1])); 
     
    684640      data->fan_min[nr-1] = FAN_TO_REG(results[0], 
    685641                            DIV_FROM_REG(data->fan_div[nr-1])); 
    686       lm78_write_value(client,LM78_REG_FAN_MIN(nr),data->fan_min[nr-1]); 
    687     } 
    688   } 
    689 } 
    690  
    691  
    692 void lm78_temp(struct i2c_client *client, int operation, int ctl_name, 
     642      sis5595_write_value(client,SIS5595_REG_FAN_MIN(nr),data->fan_min[nr-1]); 
     643    } 
     644  } 
     645} 
     646 
     647 
     648void sis5595_temp(struct i2c_client *client, int operation, int ctl_name, 
    693649               int *nrels_mag, long *results) 
    694650{ 
    695   struct lm78_data *data = client->data; 
     651  struct sis5595_data *data = client->data; 
    696652  if (operation == SENSORS_PROC_REAL_INFO) 
    697653    *nrels_mag = 1; 
    698654  else if (operation == SENSORS_PROC_REAL_READ) { 
    699     lm78_update_client(client); 
     655    sis5595_update_client(client); 
    700656    results[0] = TEMP_FROM_REG(data->temp_over); 
    701657    results[1] = TEMP_FROM_REG(data->temp_hyst); 
     
    705661    if (*nrels_mag >= 1) { 
    706662      data->temp_over = TEMP_TO_REG(results[0]); 
    707       lm78_write_value(client,LM78_REG_TEMP_OVER,data->temp_over); 
     663      sis5595_write_value(client,SIS5595_REG_TEMP_OVER,data->temp_over); 
    708664    } 
    709665    if (*nrels_mag >= 2) { 
    710666      data->temp_hyst = TEMP_TO_REG(results[1]); 
    711       lm78_write_value(client,LM78_REG_TEMP_HYST,data->temp_hyst); 
    712     } 
    713   } 
    714 } 
    715  
    716 void lm78_vid(struct i2c_client *client, int operation, int ctl_name, 
    717               int *nrels_mag, long *results) 
    718 { 
    719   struct lm78_data *data = client->data; 
    720   if (operation == SENSORS_PROC_REAL_INFO) 
    721     *nrels_mag = 2; 
    722   else if (operation == SENSORS_PROC_REAL_READ) { 
    723     lm78_update_client(client); 
    724     results[0] = VID_FROM_REG(data->vid); 
    725     *nrels_mag = 1; 
    726   } 
    727 } 
    728  
    729 void lm78_alarms(struct i2c_client *client, int operation, int ctl_name, 
     667      sis5595_write_value(client,SIS5595_REG_TEMP_HYST,data->temp_hyst); 
     668    } 
     669  } 
     670} 
     671 
     672void sis5595_alarms(struct i2c_client *client, int operation, int ctl_name, 
    730673                 int *nrels_mag, long *results) 
    731674{ 
    732   struct lm78_data *data = client->data; 
     675  struct sis5595_data *data = client->data; 
    733676  if (operation == SENSORS_PROC_REAL_INFO) 
    734677    *nrels_mag = 0; 
    735678  else if (operation == SENSORS_PROC_REAL_READ) { 
    736     lm78_update_client(client); 
     679    sis5595_update_client(client); 
    737680    results[0] = ALARMS_FROM_REG(data->alarms); 
    738681    *nrels_mag = 1; 
     
    740683} 
    741684 
    742 void lm78_fan_div(struct i2c_client *client, int operation, int ctl_name, 
     685void sis5595_fan_div(struct i2c_client *client, int operation, int ctl_name, 
    743686                  int *nrels_mag, long *results) 
    744687{ 
    745   struct lm78_data *data = client->data; 
     688  struct sis5595_data *data = client->data; 
    746689  int old; 
    747690 
     
    749692    *nrels_mag = 0; 
    750693  else if (operation == SENSORS_PROC_REAL_READ) { 
    751     lm78_update_client(client); 
     694    sis5595_update_client(client); 
    752695    results[0] = DIV_FROM_REG(data->fan_div[0]); 
    753696    results[1] = DIV_FROM_REG(data->fan_div[1]); 
    754     results[2] = 2; 
    755     *nrels_mag = 3; 
     697    *nrels_mag = 2; 
    756698  } else if (operation == SENSORS_PROC_REAL_WRITE) { 
    757     old = lm78_read_value(client,LM78_REG_VID_FANDIV); 
     699    old = sis5595_read_value(client,SIS5595_REG_FANDIV); 
    758700    if (*nrels_mag >= 2) { 
    759701      data->fan_div[1] = DIV_TO_REG(results[1]); 
     
    763705      data->fan_div[0] = DIV_TO_REG(results[0]); 
    764706      old = (old & 0xcf) | (data->fan_div[0] << 4); 
    765       lm78_write_value(client,LM78_REG_VID_FANDIV,old); 
    766     } 
    767   } 
    768 } 
    769  
    770 int lm78_init(void) 
     707      sis5595_write_value(client,SIS5595_REG_FANDIV,old); 
     708    } 
     709  } 
     710} 
     711 
     712int sis5595_init(void) 
     713{ 
     714  int res,addr; 
     715 
     716  printk("sis5595.o version %s (%s)\n",LM_VERSION,LM_DATE); 
     717  sis5595_initialized = 0; 
     718 
     719  if (sis5595_find_sis(&addr)) { 
     720    normal_isa[0] = SENSORS_ISA_END; 
     721    printk("sis5595.o: Warning: No SIS5595 southbridge found!\n"); 
     722  } else 
     723    normal_isa[0] = addr; 
     724 
     725  if ((res =i2c_add_driver(&sis5595_driver))) { 
     726    printk("sis5595.o: Driver registration failed, module not inserted.\n"); 
     727    sis5595_cleanup(); 
     728    return res; 
     729  } 
     730  sis5595_initialized ++; 
     731  return 0; 
     732} 
     733 
     734int sis5595_cleanup(void) 
    771735{ 
    772736  int res; 
    773737 
    774   printk("sis5595.o version %s (%s)\n",LM_VERSION,LM_DATE); 
    775   lm78_initialized = 0; 
    776  
    777   if ((res =i2c_add_driver(&lm78_driver))) { 
    778     printk("sis5595.o: Driver registration failed, module not inserted.\n"); 
    779     lm78_cleanup(); 
    780     return res; 
    781   } 
    782   lm78_initialized ++; 
    783   return 0; 
    784 } 
    785  
    786 int lm78_cleanup(void) 
    787 { 
    788   int res; 
    789  
    790   if (lm78_initialized >= 1) { 
    791     if ((res = i2c_del_driver(&lm78_driver))) { 
     738  if (sis5595_initialized >= 1) { 
     739    if ((res = i2c_del_driver(&sis5595_driver))) { 
    792740      printk("sis5595.o: Driver deregistration failed, module not removed.\n"); 
    793741      return res; 
    794742    } 
    795     lm78_initialized --; 
     743    sis5595_initialized --; 
    796744  } 
    797745  return 0; 
     
    806754int init_module(void) 
    807755{ 
    808   return lm78_init(); 
     756  return sis5595_init(); 
    809757} 
    810758 
    811759int cleanup_module(void) 
    812760{ 
    813   return lm78_cleanup(); 
     761  return sis5595_cleanup(); 
    814762} 
    815763 
  • lm-sensors/trunk/kernel/include/compat.h

    r207 r379  
    6464#define pci_present pcibios_present 
    6565#define pci_read_config_byte_united(device,bus,dev,com,res) \ 
    66                             pcibios_read_config_byte(bus,dev,com,res); 
     66                            pcibios_read_config_byte(bus,dev,com,res) 
    6767#define pci_read_config_word_united(device,bus,dev,com,res) \ 
    68                             pcibios_read_config_word(bus,dev,com,res); 
     68                            pcibios_read_config_word(bus,dev,com,res) 
    6969#define pci_write_config_byte_united(device,bus,dev,com,res) \ 
    70                             pcibios_write_config_byte(bus,dev,com,res); 
     70                            pcibios_write_config_byte(bus,dev,com,res) 
    7171#define pci_write_config_word_united(device,bus,dev,com,res) \ 
    72                             pcibios_write_config_word(bus,dev,com,res); 
     72                            pcibios_write_config_word(bus,dev,com,res) 
    7373#else 
    7474#define pci_read_config_byte_united(device,bus,dev,com,res) \ 
    75                             pci_read_config_byte(device,com,res); 
     75                            pci_read_config_byte(device,com,res) 
    7676#define pci_read_config_word_united(device,bus,dev,com,res) \ 
    77                             pci_read_config_word(device,com,res); 
     77                            pci_read_config_word(device,com,res) 
    7878#define pci_write_config_byte_united(device,bus,dev,com,res) \ 
    79                             pci_write_config_byte(device,com,res); 
     79                            pci_write_config_byte(device,com,res) 
    8080#define pci_write_config_word_united(device,bus,dev,com,res) \ 
    81                             pci_write_config_byte(device,com,res); 
     81                            pci_write_config_byte(device,com,res) 
    8282#endif 
    8383 
  • lm-sensors/trunk/kernel/include/sensors.h

    r360 r379  
    502502#define MAXI_ALARM_FAN3      0x4000 
    503503 
     504#define SIS5595_SYSCTL_IN0 1000  /* Volts * 100 */ 
     505#define SIS5595_SYSCTL_IN1 1001 
     506#define SIS5595_SYSCTL_IN2 1002 
     507#define SIS5595_SYSCTL_IN3 1003 
     508#define SIS5595_SYSCTL_FAN1 1101 /* Rotations/min */ 
     509#define SIS5595_SYSCTL_FAN2 1102 
     510#define SIS5595_SYSCTL_TEMP 1200 /* Degrees Celcius * 10 */ 
     511#define SIS5595_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ 
     512#define SIS5595_SYSCTL_ALARMS 2001 /* bitvector */ 
     513 
     514#define SIS5595_ALARM_IN0 0x01 
     515#define SIS5595_ALARM_IN1 0x02 
     516#define SIS5595_ALARM_IN2 0x04 
     517#define SIS5595_ALARM_IN3 0x08 
     518#define SIS5595_ALARM_TEMP 0x10 
     519#define SIS5595_ALARM_BTI 0x20 
     520#define SIS5595_ALARM_FAN1 0x40 
     521#define SIS5595_ALARM_FAN2 0x80 
    504522 
    505523#define ICSPLL_SYSCTL1 1000