Changeset 379
- Timestamp:
- 04/11/99 18:12:36 (14 years ago)
- Location:
- lm-sensors/trunk/kernel
- Files:
-
- 3 modified
-
chips/sis5595.c (modified) (20 diffs)
-
include/compat.h (modified) (1 diff)
-
include/sensors.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/kernel/chips/sis5595.c
r333 r379 40 40 #include "compat.h" 41 41 42 /* Addresses to scan. 43 Note that we can't determine the ISA address until we have initialized 44 our module */ 45 static unsigned short normal_i2c[] = {SENSORS_I2C_END}; 46 static unsigned short normal_i2c_range[] = {SENSORS_I2C_END}; 47 static unsigned int normal_isa[] = {0x0000,SENSORS_ISA_END}; 48 static unsigned int normal_isa_range[] = {SENSORS_ISA_END}; 49 50 /* Insmod parameters */ 51 SENSORS_INSMOD_1(sis5595); 52 42 53 /* 43 SiS southbridge has lm78 integrated on the same IC,44 This drive sis a customized copy of lm78.c54 SiS southbridge has a LM78-like chip integrated on the same IC. 55 This driver is a customized copy of lm78.c 45 56 */ 46 57 47 /* Many LM78constants specified below */58 /* Many SIS5595 constants specified below */ 48 59 49 60 /* Length of ISA address segment */ 50 #define LM78_EXTENT 851 #define LM78_BASE_REG 0x6861 #define SIS5595_EXTENT 8 62 #define SIS5595_BASE_REG 0x68 52 63 53 64 /* 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 77 85 78 86 /* Conversions. Rounding is only done on the TO_REG variants. */ … … 98 106 #define TEMP_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*10) 99 107 100 #define VID_FROM_REG(val) ((val)==0x1f?0:(val)>=0x10?510-(val)*10:\101 (val)>=0x06?0:205-(val)*5)102 108 #define ALARMS_FROM_REG(val) (val) 103 109 … … 106 112 107 113 /* 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 154 144 155 145 #ifdef MODULE … … 162 152 some corners. */ 163 153 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 170 157 allocated. */ 171 struct lm78_data {158 struct sis5595_data { 172 159 struct semaphore lock; 173 160 int sysctl_id; 174 enum lm78_type type;175 161 176 162 struct semaphore update_lock; … … 178 164 unsigned long last_updated; /* In jiffies */ 179 165 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 */ 185 171 u8 temp; /* Register value */ 186 172 u8 temp_over; /* Register value */ 187 173 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 */ 191 176 }; 192 177 193 178 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, 179 static int sis5595_init(void); 180 static int sis5595_cleanup(void); 181 182 static int sis5595_attach_adapter(struct i2c_adapter *adapter); 183 static int sis5595_detect(struct i2c_adapter *adapter, int address, int kind); 184 static int sis5595_detach_client(struct i2c_client *client); 185 static int sis5595_command(struct i2c_client *client, unsigned int cmd, 205 186 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, 187 static void sis5595_inc_use (struct i2c_client *client); 188 static void sis5595_dec_use (struct i2c_client *client); 189 190 static int sis5595_read_value(struct i2c_client *client, u8 register); 191 static int sis5595_write_value(struct i2c_client *client, u8 register, u8 value); 192 static void sis5595_update_client(struct i2c_client *client); 193 static void sis5595_init_client(struct i2c_client *client); 194 static int sis5595_find_sis(int *address); 195 196 197 static void sis5595_in(struct i2c_client *client, int operation, int ctl_name, 216 198 int *nrels_mag, long *results); 217 static void lm78_fan(struct i2c_client *client, int operation, int ctl_name,199 static void sis5595_fan(struct i2c_client *client, int operation, int ctl_name, 218 200 int *nrels_mag, long *results); 219 static void lm78_temp(struct i2c_client *client, int operation, int ctl_name,201 static void sis5595_temp(struct i2c_client *client, int operation, int ctl_name, 220 202 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, 203 static void sis5595_alarms(struct i2c_client *client, int operation, int ctl_name, 224 204 int *nrels_mag, long *results); 225 static void lm78_fan_div(struct i2c_client *client, int operation, int ctl_name,205 static void sis5595_fan_div(struct i2c_client *client, int operation, int ctl_name, 226 206 int *nrels_mag, long *results); 227 207 228 /* I choose here for semi-static LM78allocation. Complete dynamic208 /* I choose here for semi-static SIS5595 allocation. Complete dynamic 229 209 allocation could also be used; the code needed for this would probably 230 210 take more memory than the datastructure takes now. */ 231 #define MAX_ LM78_NR 4232 static struct i2c_client * lm78_list[MAX_LM78_NR];211 #define MAX_SIS5595_NR 4 212 static struct i2c_client *sis5595_list[MAX_SIS5595_NR]; 233 213 234 214 /* The driver. I choose to use type i2c_driver, as at is identical to both 235 215 smbus_driver and isa_driver, and clients could be of either kind */ 236 static struct i2c_driver lm78_driver = {216 static struct i2c_driver sis5595_driver = { 237 217 /* name */ "SiS 5595", 238 218 /* id */ I2C_DRIVERID_SIS5595, 239 219 /* 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_use220 /* 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 245 225 }; 246 226 247 /* Used by lm78_init/cleanup */248 static int lm78_initialized = 0;227 /* Used by sis5595_init/cleanup */ 228 static int sis5595_initialized = 0; 249 229 250 230 /* 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; 252 232 though at first sight, you might think we could use a statically 253 233 allocated list, we need some way to get back to the parent - which 254 234 is done through one of the 'extra' fields which are initialized 255 235 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 }, 236 static 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 }, 285 255 { 0 } 286 256 }; 287 257 288 258 /* 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 { 259 int 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 */ 265 int sis5595_find_sis(int *address) 266 { 267 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,54)) 304 268 struct pci_dev *s_bridge; 269 #else 270 unsigned char SIS_bus, SIS_devfn; 271 #endif 305 272 u16 val; 306 273 … … 308 275 return -ENODEV; 309 276 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))); 312 280 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 314 286 return -ENODEV; 315 287 288 316 289 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)) 318 292 return -ENODEV; 319 293 … … 322 296 } 323 297 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); 298 int 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); 344 422 return 0; 345 }346 #endif347 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;414 423 415 424 /* OK, this is not exactly good programming practice, usually. But it is … … 417 426 418 427 ERROR4: 419 isa_detach_client(new_client);428 i2c_detach_client(new_client); 420 429 ERROR3: 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; 422 433 ERROR2: 423 kfree(new_client);434 release_region(address,SIS5595_EXTENT); 424 435 ERROR1: 425 release_region(address, LM78_EXTENT);426 436 kfree(new_client); 437 ERROR0: 427 438 return err; 428 439 } 429 440 430 /* Deregister and remove a LM78 client */ 431 int lm78_detach_isa(struct isa_client *client) 441 int sis5595_detach_client(struct i2c_client *client) 432 442 { 433 443 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]) 436 454 break; 437 if ( i == MAX_LM78_NR) {455 if ((i == MAX_SIS5595_NR)) { 438 456 printk("sis5595.o: Client to detach not found.\n"); 439 457 return -ENOENT; 440 458 } 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); 450 462 kfree(client); 463 451 464 return 0; 452 465 } 453 466 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 */ 468 int sis5595_command(struct i2c_client *client, unsigned int cmd, void *arg) 469 { 479 470 return 0; 480 471 } 481 472 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 497 473 /* Nothing here yet */ 498 void lm78_inc_use (struct i2c_client *client)474 void sis5595_inc_use (struct i2c_client *client) 499 475 { 500 476 #ifdef MODULE … … 504 480 505 481 /* Nothing here yet */ 506 void lm78_dec_use (struct i2c_client *client)482 void sis5595_dec_use (struct i2c_client *client) 507 483 { 508 484 #ifdef MODULE … … 515 491 There are some ugly typecasts here, but the good new is - they should 516 492 nowhere else be necessary! */ 517 int lm78_read_value(struct i2c_client *client, u8 reg)493 int sis5595_read_value(struct i2c_client *client, u8 reg) 518 494 { 519 495 int res; 520 496 521 497 down((struct semaphore *) (client->data)); 498 down(& (((struct sis5595_data *) (client->data)) -> lock)); 522 499 outb_p(reg,(((struct isa_client *) client)->isa_addr) + 523 LM78_ADDR_REG_OFFSET);500 SIS5595_ADDR_REG_OFFSET); 524 501 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)); 527 504 return res; 528 505 } … … 531 508 There are some ugly typecasts here, but the good new is - they should 532 509 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));510 int 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)); 539 516 return 0; 540 517 } 541 518 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. */ 520 void sis5595_init_client(struct i2c_client *client) 521 { 547 522 /* Reset all except Watchdog values and last conversion values 548 523 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)); 577 540 578 541 /* 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); 581 544 582 545 } 583 546 584 void lm78_update_client(struct i2c_client *client)585 { 586 struct lm78_data *data = client->data;547 void sis5595_update_client(struct i2c_client *client) 548 { 549 struct sis5595_data *data = client->data; 587 550 int i; 588 551 … … 593 556 594 557 #ifdef DEBUG 595 printk("Starting lm78update\n");558 printk("Starting sis5595 update\n"); 596 559 #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); 612 573 data->fan_div[0] = (i >> 4) & 0x03; 613 574 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); 618 576 data->last_updated = jiffies; 619 577 data->valid = 1; 620 621 data->fan_div[2] = 1;622 578 } 623 579 … … 639 595 good practice, but as long as you put less than about 5 values in results, 640 596 you can assume it is large enough. */ 641 void lm78_in(struct i2c_client *client, int operation, int ctl_name,597 void sis5595_in(struct i2c_client *client, int operation, int ctl_name, 642 598 int *nrels_mag, long *results) 643 599 { 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; 646 602 647 603 if (operation == SENSORS_PROC_REAL_INFO) 648 604 *nrels_mag = 2; 649 605 else if (operation == SENSORS_PROC_REAL_READ) { 650 lm78_update_client(client);606 sis5595_update_client(client); 651 607 results[0] = IN_FROM_REG(data->in_min[nr]); 652 608 results[1] = IN_FROM_REG(data->in_max[nr]); … … 656 612 if (*nrels_mag >= 1) { 657 613 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]); 659 615 } 660 616 if (*nrels_mag >= 2) { 661 617 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]); 663 619 } 664 620 } 665 621 } 666 622 667 void lm78_fan(struct i2c_client *client, int operation, int ctl_name,623 void sis5595_fan(struct i2c_client *client, int operation, int ctl_name, 668 624 int *nrels_mag, long *results) 669 625 { 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; 672 628 673 629 if (operation == SENSORS_PROC_REAL_INFO) 674 630 *nrels_mag = 0; 675 631 else if (operation == SENSORS_PROC_REAL_READ) { 676 lm78_update_client(client);632 sis5595_update_client(client); 677 633 results[0] = FAN_FROM_REG(data->fan_min[nr-1], 678 634 DIV_FROM_REG(data->fan_div[nr-1])); … … 684 640 data->fan_min[nr-1] = FAN_TO_REG(results[0], 685 641 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 648 void sis5595_temp(struct i2c_client *client, int operation, int ctl_name, 693 649 int *nrels_mag, long *results) 694 650 { 695 struct lm78_data *data = client->data;651 struct sis5595_data *data = client->data; 696 652 if (operation == SENSORS_PROC_REAL_INFO) 697 653 *nrels_mag = 1; 698 654 else if (operation == SENSORS_PROC_REAL_READ) { 699 lm78_update_client(client);655 sis5595_update_client(client); 700 656 results[0] = TEMP_FROM_REG(data->temp_over); 701 657 results[1] = TEMP_FROM_REG(data->temp_hyst); … … 705 661 if (*nrels_mag >= 1) { 706 662 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); 708 664 } 709 665 if (*nrels_mag >= 2) { 710 666 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 672 void sis5595_alarms(struct i2c_client *client, int operation, int ctl_name, 730 673 int *nrels_mag, long *results) 731 674 { 732 struct lm78_data *data = client->data;675 struct sis5595_data *data = client->data; 733 676 if (operation == SENSORS_PROC_REAL_INFO) 734 677 *nrels_mag = 0; 735 678 else if (operation == SENSORS_PROC_REAL_READ) { 736 lm78_update_client(client);679 sis5595_update_client(client); 737 680 results[0] = ALARMS_FROM_REG(data->alarms); 738 681 *nrels_mag = 1; … … 740 683 } 741 684 742 void lm78_fan_div(struct i2c_client *client, int operation, int ctl_name,685 void sis5595_fan_div(struct i2c_client *client, int operation, int ctl_name, 743 686 int *nrels_mag, long *results) 744 687 { 745 struct lm78_data *data = client->data;688 struct sis5595_data *data = client->data; 746 689 int old; 747 690 … … 749 692 *nrels_mag = 0; 750 693 else if (operation == SENSORS_PROC_REAL_READ) { 751 lm78_update_client(client);694 sis5595_update_client(client); 752 695 results[0] = DIV_FROM_REG(data->fan_div[0]); 753 696 results[1] = DIV_FROM_REG(data->fan_div[1]); 754 results[2] = 2; 755 *nrels_mag = 3; 697 *nrels_mag = 2; 756 698 } 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); 758 700 if (*nrels_mag >= 2) { 759 701 data->fan_div[1] = DIV_TO_REG(results[1]); … … 763 705 data->fan_div[0] = DIV_TO_REG(results[0]); 764 706 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 712 int 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 734 int sis5595_cleanup(void) 771 735 { 772 736 int res; 773 737 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))) { 792 740 printk("sis5595.o: Driver deregistration failed, module not removed.\n"); 793 741 return res; 794 742 } 795 lm78_initialized --;743 sis5595_initialized --; 796 744 } 797 745 return 0; … … 806 754 int init_module(void) 807 755 { 808 return lm78_init();756 return sis5595_init(); 809 757 } 810 758 811 759 int cleanup_module(void) 812 760 { 813 return lm78_cleanup();761 return sis5595_cleanup(); 814 762 } 815 763 -
lm-sensors/trunk/kernel/include/compat.h
r207 r379 64 64 #define pci_present pcibios_present 65 65 #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) 67 67 #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) 69 69 #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) 71 71 #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) 73 73 #else 74 74 #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) 76 76 #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) 78 78 #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) 80 80 #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) 82 82 #endif 83 83 -
lm-sensors/trunk/kernel/include/sensors.h
r360 r379 502 502 #define MAXI_ALARM_FAN3 0x4000 503 503 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 504 522 505 523 #define ICSPLL_SYSCTL1 1000
