Changeset 790
- Timestamp:
- 04/15/00 19:21:12 (9 years ago)
- Files:
-
- lm-sensors/trunk/etc/sensors.conf.eg (modified) (4 diffs)
- lm-sensors/trunk/kernel/chips/maxilife.c (modified) (30 diffs)
- lm-sensors/trunk/kernel/include/sensors.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
lm-sensors/trunk/etc/sensors.conf.eg
r780 r790 426 426 set in6_max -5 * 0.95 427 427 428 429 428 chip "maxilife-cg-*" "maxilife-co-*" "maxilife-as-*" 430 429 … … 432 431 label fan2 "PCI Fan" 433 432 label fan3 "CPU Fan" 433 ignore fan4 434 434 435 435 label temp2 "PCI Temp" 436 436 label temp4 "HDD Temp" 437 437 label temp5 "CPU Temp" 438 ignore temp6 438 439 439 440 label vid1 "V+12" 441 ignore vid5 440 442 441 443 # vid1 need to be scaled by 6.337 other voltages … … 444 446 compute vid1 6.337*@ , @/6.337 445 447 446 447 448 chip "maxilife-cg-*" 448 449 449 # invalidtemp1450 ignore temp1 450 451 label temp3 "BX Temp" 451 452 452 453 label vid2 "Vcpu1" 453 454 label vid3 "Vcpu2" 454 # invalid vid4 455 455 ignore vid4 456 456 457 457 chip "maxilife-co-*" … … 464 464 label vid4 "VcacheL2" 465 465 466 467 466 chip "maxilife-as-*" 468 467 469 # invalidtemp1470 # invalidtemp3468 ignore temp1 469 ignore temp3 471 470 472 471 label vid2 "Vcpu" 473 # invalid vid3 474 # invalid vid4 475 472 ignore vid3 473 ignore vid4 474 475 chip "maxilife-nba-*" 476 477 label fan1 "CPU Fan" 478 label fan2 "PCI Fan" 479 label fan3 "HDD Fan" 480 label fan4 "Heat Sink Fan" 481 482 label temp1 "CPU 1 Temp" 483 label temp2 "CPU 2 Temp" 484 label temp3 "PCI/Ambient Temp" 485 label temp4 "HDD Temp" 486 label temp5 "Motherboard Temp" 487 label temp6 "CPU Reference Temp" 488 489 label vid1 "V+12" 490 label vid2 "Vcpu1" 491 label vid3 "Vcpu2" 492 label vid4 "VcacheL2" 493 label vid5 "V-12" 476 494 477 495 chip "via686a-*" lm-sensors/trunk/kernel/chips/maxilife.c
r707 r790 2 2 maxilife.c - Part of lm_sensors, Linux kernel modules for hardware 3 3 monitoring 4 Copyright (c) 1999 Fons Rademakers <Fons.Rademakers@cern.ch>4 Copyright (c) 1999-2000 Fons Rademakers <Fons.Rademakers@cern.ch> 5 5 6 6 This program is free software; you can redistribute it and/or modify … … 34 34 35 35 maxi_version=0 is the default 36 37 This version of MaxiLife is called MaxiLife'98 and has been 38 succeeded by MaxiLife'99, see below. 39 40 The new version of the driver also supports MaxiLife NBA (New BIOS 41 Architecture). This new MaxiLife controller provides a much cleaner 42 machine independent abstraction layer to the MaxiLife controller. 43 Instead of accessing directly registers (different for each revision) 44 one now accesses the sensors via unique mailbox tokens that do not 45 change between revisions. Also the quantities are already in physical 46 units (degrees, rpms, voltages, etc.) and don't need special conversion 47 formulas. This new MaxiLife is available on the new 2000 machines, 48 like the Kayak XU800 and XM600. This hardware is also autodetected. 36 49 */ 37 50 38 static const char *version_str = " 1.00 25/2/99Fons Rademakers";51 static const char *version_str = "2.00 29/2/2000 Fons Rademakers"; 39 52 40 53 … … 65 78 66 79 #undef AUTODETECT /* try to autodetect MaxiLife version */ 80 /*#define AUTODETECT*/ 67 81 #define NOWRITE /* don't allow writing to MaxiLife registers */ 68 82 69 70 /* The MaxiLife registers */ 83 #ifdef AUTODETECT 84 #include <linux/vmalloc.h> 85 #include <linux/ctype.h> 86 #endif 87 88 /* Addresses to scan */ 89 static unsigned short normal_i2c[] = { SENSORS_I2C_END }; 90 static unsigned short normal_i2c_range[] = { 0x10, 0x14, SENSORS_I2C_END }; 91 static unsigned int normal_isa[] = { SENSORS_ISA_END }; 92 static unsigned int normal_isa_range[] = { SENSORS_ISA_END }; 93 94 /* Insmod parameters */ 95 SENSORS_INSMOD_1(maxilife); 96 97 /* Macro definitions */ 98 #define LOW(MyWord) ((u8) (MyWord)) 99 #define HIGH(MyWord) ((u8) (((u16)(MyWord) >> 8) & 0xFF)) 100 101 /*----------------- MaxiLife'98 registers and conversion formulas ------------*/ 71 102 #define MAXI_REG_TEMP(nr) (0x60 + (nr)) 72 103 … … 89 120 90 121 #define MAXI_REG_BIOS_CTRL 0x2a 91 #define MAXI_REG_LED_STATE 0x9692 122 93 123 /* Conversions. Rounding and limit checking is only done on the TO_REG … … 98 128 /* 0xfe: fan off, 0xff: stopped (alarm) */ 99 129 /* 19531 / val * 60 == 1171860 / val */ 100 #define FAN_FROM_REG(val) ((val)==0xfe ? -1 : (val)==0xff ? 0: \130 #define FAN_FROM_REG(val) ((val)==0xfe ? 0 : (val)==0xff ? -1 : \ 101 131 (val)==0x00 ? -1 : (1171860 / (val))) 102 132 … … 119 149 #define ALARMS_FROM_REG(val) (val) 120 150 151 /*----------------- MaxiLife'99 mailbox and token definitions ----------------*/ 152 /* MaxiLife mailbox data register map */ 153 #define MAXI_REG_MBX_STATUS 0x5a 154 #define MAXI_REG_MBX_CMD 0x5b 155 #define MAXI_REG_MBX_TOKEN_H 0x5c 156 #define MAXI_REG_MBX_TOKEN_L 0x5d 157 #define MAXI_REG_MBX_DATA 0x60 158 159 /* Mailbox status register definition */ 160 #define MAXI_STAT_IDLE 0xff 161 #define MAXI_STAT_OK 0x00 162 #define MAXI_STAT_BUSY 0x0b 163 /* other values not used */ 164 165 /* Mailbox command register opcodes */ 166 #define MAXI_CMD_READ 0x02 167 #define MAXI_CMD_WRITE 0x03 168 /* other values not used */ 169 170 /* MaxiLife NBA Hardware monitoring tokens */ 171 172 /* Alarm tokens (0x1xxx) */ 173 #define MAXI_TOK_ALARM(nr) (0x1000 + (nr)) 174 #define MAXI_TOK_ALARM_EVENT 0x1000 175 #define MAXI_TOK_ALARM_FAN 0x1001 176 #define MAXI_TOK_ALARM_TEMP 0x1002 177 #define MAXI_TOK_ALARM_VID 0x1003 /* voltages */ 178 #define MAXI_TOK_ALARM_AVID 0x1004 /* additional voltages */ 179 #define MAXI_TOK_ALARM_PWR 0x1101 /* power supply glitch */ 180 181 /* Fan status tokens (0x20xx) */ 182 #define MAXI_TOK_FAN(nr) (0x2000 + (nr)) 183 #define MAXI_TOK_FAN_CPU 0x2000 184 #define MAXI_TOK_FAN_PCI 0x2001 185 #define MAXI_TOK_FAN_HDD 0x2002 /* hard disk bay fan */ 186 #define MAXI_TOK_FAN_SINK 0x2003 /* heatsink */ 187 188 /* Temperature status tokens (0x21xx) */ 189 #define MAXI_TOK_TEMP(nr) (0x2100 + (nr)) 190 #define MAXI_TOK_TEMP_CPU1 0x2100 191 #define MAXI_TOK_TEMP_CPU2 0x2101 192 #define MAXI_TOK_TEMP_PCI 0x2102 /* PCI/ambient temp */ 193 #define MAXI_TOK_TEMP_HDD 0x2103 /* hard disk bay temp */ 194 #define MAXI_TOK_TEMP_MEM 0x2104 /* mother board temp */ 195 #define MAXI_TOK_TEMP_CPU 0x2105 /* CPU reference temp */ 196 197 /* Voltage status tokens (0x22xx) */ 198 #define MAXI_TOK_VID(nr) (0x2200 + (nr)) 199 #define MAXI_TOK_VID_12 0x2200 /* +12 volt */ 200 #define MAXI_TOK_VID_CPU1 0x2201 /* cpu 1 voltage */ 201 #define MAXI_TOK_VID_CPU2 0x2202 /* cpu 2 voltage */ 202 #define MAXI_TOK_VID_L2 0x2203 /* level 2 cache voltage */ 203 #define MAXI_TOK_VID_M12 0x2204 /* -12 volt */ 204 205 /* Additive voltage status tokens (0x23xx) */ 206 #define MAXI_TOK_AVID(nr) (0x2300 + (nr)) 207 #define MAXI_TOK_AVID_15 0x2300 /* 1.5 volt */ 208 #define MAXI_TOK_AVID_18 0x2301 /* 1.8 volt */ 209 #define MAXI_TOK_AVID_25 0x2302 /* 2.5 volt */ 210 #define MAXI_TOK_AVID_33 0x2303 /* 3.3 volt */ 211 #define MAXI_TOK_AVID_5 0x2304 /* 5 volt */ 212 #define MAXI_TOK_AVID_M5 0x2305 /* -5 volt */ 213 #define MAXI_TOK_AVID_BAT 0x2306 /* battery voltage */ 214 215 /* Threshold tokens (0x3xxx) */ 216 #define MAXI_TOK_MIN(token) ((token) + 0x1000) 217 #define MAXI_TOK_MAX(token) ((token) + 0x1800) 218 219 /* LCD Panel (0x4xxx) */ 220 #define MAXI_TOK_LCD(nr) (0x4000 + (nr)) 221 #define MAXI_TOK_LCD_LINE1 0x4000 222 #define MAXI_TOK_LCD_LINE2 0x4001 223 #define MAXI_TOK_LCD_LINE3 0x4002 224 #define MAXI_TOK_LCD_LINE4 0x4003 225 226 /* 0xfe: fan off, 0xff: stopped (alarm) */ 227 /* or not available */ 228 #define FAN99_FROM_REG(val) ((val)==0xfe ? 0 : (val)==0xff ? -1 : ((val)*39)) 229 230 /* when no CPU2 temp is 127 (0x7f) */ 231 #define TEMP99_FROM_REG(val) ((val)==0x7f ? -1 : (val)==0xff ? -1 : (val)) 232 233 #define VID99_FROM_REG(nr,val) ((val)==0xff ? 0 : \ 234 (nr)==1 ? ((val) * 608) : \ 235 (nr)==2 ? ((val) * 160) : \ 236 (nr)==3 ? ((val) * 160) : \ 237 (nr)==4 ? (val) /* no formula spcified */ : \ 238 (nr)==5 ? ((val) * 823 - 149140) : 0) 239 240 121 241 #ifdef MODULE 122 242 extern int init_module(void); … … 128 248 (Dual Pentium II Slot 1, Deschutes/Klamath) 129 249 Cognac: HP KAYAK XU (Dual Xeon [Slot 2] 400/450 Mhz) 130 Ashaki: HP KAYAK XA (Pentium II Slot 1, monoprocessor) */ 131 132 enum maxi_type { cristal, cognac, ashaki }; 250 Ashaki: HP KAYAK XA (Pentium II Slot 1, monoprocessor) 251 NBA: New BIOS Architecture, Kayak XU800, XM600, ... */ 252 253 enum maxi_type { cristal, cognac, ashaki, nba }; 254 enum sensor_type { fan, temp, vid, pll, lcd, alarm }; 133 255 134 256 /* For each registered MaxiLife controller, we need to keep some data in … … 146 268 unsigned long last_updated; /* In jiffies */ 147 269 148 u8 fan[ 3]; /* Register value */149 u8 fan_min[ 3]; /* Register value */150 u8 fan_speed[ 3]; /* Register value */151 u8 fan_div[ 3]; /* Static value */152 u8 temp[ 5]; /* Register value */153 u8 temp_max[ 5]; /* Static value */154 u8 temp_hyst[ 5]; /* Static value */270 u8 fan[4]; /* Register value */ 271 u8 fan_min[4]; /* Register value */ 272 u8 fan_speed[4]; /* Register value */ 273 u8 fan_div[4]; /* Static value */ 274 u8 temp[6]; /* Register value */ 275 u8 temp_max[6]; /* Static value */ 276 u8 temp_hyst[6]; /* Static value */ 155 277 u8 pll; /* Register value */ 156 278 u8 pll_min; /* Register value */ 157 279 u8 pll_max; /* register value */ 158 u8 vid[4]; /* Register value */ 159 u8 vid_min[4]; /* Register value */ 160 u8 vid_max[4]; /* Register value */ 280 u8 vid[5]; /* Register value */ 281 u8 vid_min[5]; /* Register value */ 282 u8 vid_max[5]; /* Register value */ 283 u8 lcd[4][17]; /* Four LCD lines */ 161 284 u16 alarms; /* Register encoding, combined */ 162 285 }; … … 172 295 173 296 static int maxi_attach_adapter(struct i2c_adapter *adapter); 174 static int maxi_detect_smbus(struct i2c_adapter *adapter); 297 static int maxi_detect(struct i2c_adapter *adapter, int address, 298 unsigned short flags, int kind); 175 299 static int maxi_detach_client(struct i2c_client *client); 176 static int maxi_detach_smbus(struct i2c_client *client);177 static int maxi_new_client(struct i2c_adapter *adapter,178 struct i2c_client *new_client);179 static void maxi_remove_client(struct i2c_client *client);180 300 static int maxi_command(struct i2c_client *client, unsigned int cmd, 181 301 void *arg); … … 184 304 185 305 static int maxi_read_value(struct i2c_client *client, u8 register); 186 #ifndef NOWRITE 306 static int maxi_read_token(struct i2c_client *client, u16 token); 187 307 static int maxi_write_value(struct i2c_client *client, u8 register, 188 308 u8 value); 189 #endif 309 static int maxi_write_token_loop(struct i2c_client *client, u16 token, 310 u8 len, u8 * values); 311 190 312 static void maxi_update_client(struct i2c_client *client); 313 static void maxi99_update_client(struct i2c_client *client, 314 enum sensor_type sensor, int which); 191 315 static void maxi_init_client(struct i2c_client *client); 192 316 193 317 static void maxi_fan(struct i2c_client *client, int operation, 194 318 int ctl_name, int *nrels_mag, long *results); 319 static void maxi99_fan(struct i2c_client *client, int operation, 320 int ctl_name, int *nrels_mag, long *results); 195 321 static void maxi_temp(struct i2c_client *client, int operation, 196 322 int ctl_name, int *nrels_mag, long *results); 323 static void maxi99_temp(struct i2c_client *client, int operation, 324 int ctl_name, int *nrels_mag, long *results); 197 325 static void maxi_pll(struct i2c_client *client, int operation, 198 326 int ctl_name, int *nrels_mag, long *results); 199 327 static void maxi_vid(struct i2c_client *client, int operation, 200 328 int ctl_name, int *nrels_mag, long *results); 329 static void maxi99_vid(struct i2c_client *client, int operation, 330 int ctl_name, int *nrels_mag, long *results); 331 static void maxi_lcd(struct i2c_client *client, int operation, 332 int ctl_name, int *nrels_mag, long *results); 201 333 static void maxi_alarms(struct i2c_client *client, int operation, 202 334 int ctl_name, int *nrels_mag, long *results); 203 204 205 static int maxi_id = 0;206 335 207 336 /* The driver. I choose to use type i2c_driver, as at is identical to … … 220 349 /* Used by maxi_init/cleanup */ 221 350 static int __initdata maxi_initialized = 0; 351 352 static int maxi_id = 0; 222 353 223 354 /* Default firmware version. Use module option "maxi_version" … … 238 369 {MAXI_SYSCTL_FAN3, "fan3", NULL, 0, 0644, NULL, &sensors_proc_real, 239 370 &sensors_sysctl_real, NULL, &maxi_fan}, 371 {MAXI_SYSCTL_FAN4, "fan4", NULL, 0, 0644, NULL, &sensors_proc_real, 372 &sensors_sysctl_real, NULL, &maxi_fan}, 240 373 {MAXI_SYSCTL_TEMP1, "temp1", NULL, 0, 0644, NULL, &sensors_proc_real, 241 374 &sensors_sysctl_real, NULL, &maxi_temp}, … … 247 380 &sensors_sysctl_real, NULL, &maxi_temp}, 248 381 {MAXI_SYSCTL_TEMP5, "temp5", NULL, 0, 0644, NULL, &sensors_proc_real, 382 &sensors_sysctl_real, NULL, &maxi_temp}, 383 {MAXI_SYSCTL_TEMP6, "temp6", NULL, 0, 0644, NULL, &sensors_proc_real, 249 384 &sensors_sysctl_real, NULL, &maxi_temp}, 250 385 {MAXI_SYSCTL_PLL, "pll", NULL, 0, 0644, NULL, &sensors_proc_real, … … 258 393 {MAXI_SYSCTL_VID4, "vid4", NULL, 0, 0644, NULL, &sensors_proc_real, 259 394 &sensors_sysctl_real, NULL, &maxi_vid}, 395 {MAXI_SYSCTL_VID5, "vid5", NULL, 0, 0644, NULL, &sensors_proc_real, 396 &sensors_sysctl_real, NULL, &maxi_vid}, 397 {MAXI_SYSCTL_LCD1, "lcd1", NULL, 0, 0644, NULL, &sensors_proc_real, 398 &sensors_sysctl_real, NULL, &maxi_lcd}, 399 {MAXI_SYSCTL_LCD2, "lcd2", NULL, 0, 0644, NULL, &sensors_proc_real, 400 &sensors_sysctl_real, NULL, &maxi_lcd}, 401 {MAXI_SYSCTL_LCD3, "lcd3", NULL, 0, 0644, NULL, &sensors_proc_real, 402 &sensors_sysctl_real, NULL, &maxi_lcd}, 403 {MAXI_SYSCTL_LCD4, "lcd4", NULL, 0, 0644, NULL, &sensors_proc_real, 404 &sensors_sysctl_real, NULL, &maxi_lcd}, 260 405 {MAXI_SYSCTL_ALARMS, "alarms", NULL, 0, 0444, NULL, &sensors_proc_real, 261 406 &sensors_sysctl_real, NULL, &maxi_alarms}, … … 269 414 int maxi_attach_adapter(struct i2c_adapter *adapter) 270 415 { 271 if (i2c_is_isa_adapter(adapter)) 272 return 0; 273 else 274 return maxi_detect_smbus(adapter); 275 } 276 277 /* This function is called whenever a client should be removed: 278 - maxi_driver is removed (when this module is unloaded) 279 - when an adapter is removed which has a maxi client (and maxi_driver 280 is still present). */ 281 int maxi_detach_client(struct i2c_client *client) 282 { 283 return maxi_detach_smbus(client); 284 } 285 286 int maxi_detect_smbus(struct i2c_adapter *adapter) 287 { 288 #ifdef AUTODETECT 289 u8 biosctl; 290 #endif 291 int address, err; 416 return sensors_detect(adapter, &addr_data, maxi_detect); 417 } 418 419 /* This function is called by sensors_detect */ 420 int maxi_detect(struct i2c_adapter *adapter, int address, 421 unsigned short flags, int kind) 422 { 292 423 struct i2c_client *new_client; 424 struct maxi_data *data; 293 425 enum maxi_type type; 426 int i, j, err = 0; 294 427 const char *type_name, *client_name; 295 296 /* OK, this is no detection. I know. It will do for now, though. */297 err = 0;298 428 299 429 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 300 430 goto ERROR0; 301 431 302 for (address = 0x10; (!err) && (address <= 0x14); address++) { 303 304 /* Later on, we will keep a list of registered addresses for each 305 adapter, and check whether they are used here */ 306 307 /* Allocate space for a new client structure. To counter memory 308 fragmentation somewhat, we only do one kmalloc. */ 309 if (!(new_client = kmalloc(sizeof(struct i2c_client) + 310 sizeof(struct maxi_data), 311 GFP_KERNEL))) { 312 err = -ENOMEM; 313 continue; 314 } 315 316 /* Fill the new client structure with data */ 317 new_client->data = (struct maxi_data *) (new_client + 1); 318 new_client->addr = address; 319 new_client->flags = 0; 320 432 /* OK. For now, we presume we have a valid client. We now create the 433 client structure, even though we cannot fill it completely yet. 434 But it allows us to access maxi_{read,write}_value. */ 435 if (!(new_client = kmalloc(sizeof(struct i2c_client) + 436 sizeof(struct maxi_data), 437 GFP_KERNEL))) { 438 err = -ENOMEM; 439 goto ERROR0; 440 } 441 442 /* Fill the new client structure with data */ 443 data = (struct maxi_data *) (new_client + 1); 444 new_client->addr = address; 445 new_client->data = data; 446 new_client->adapter = adapter; 447 new_client->driver = &maxi_driver; 448 new_client->flags = 0; 449 450 /* Now we do the remaining detection. */ 451 if (kind < 0) { 321 452 if (i2c_smbus_read_byte_data 322 (new_client, MAXI_REG_ LED_STATE) < 0)453 (new_client, MAXI_REG_MBX_STATUS) < 0) 323 454 goto ERROR2; 324 455 } 456 457 /* Determine the chip type - only one kind supported */ 458 if (kind <= 0) 459 kind = maxilife; 460 461 if (kind == maxilife) { 462 /* Detect if the machine has a MaxiLife NBA controller. 463 The right way to perform this check is to do a read/modify/write 464 on register MbxStatus (5A): 465 - Read 5A (value 0 for non-NBA firmware, FF (MbxIdle on NBA-firmware) 466 - Write 55 on 5A, then read back 5A 467 Non-NBA firmware: value is 55 (reg 5A is a standard writable reg) 468 NBA firmaware: value is FF (write-protect on MbxStatus active) */ 469 int stat; 470 i2c_smbus_write_byte_data(new_client, MAXI_REG_MBX_STATUS, 471 0x55); 472 stat = 473 i2c_smbus_read_byte_data(new_client, 474 MAXI_REG_MBX_STATUS); 475 476 /*if (stat == MAXI_STAT_IDLE || stat == MAXI_STAT_OK) */ 477 if (stat != 0x55) 478 maxi_version = nba; 325 479 #ifdef AUTODETECT 326 /* The right way to get the platform info is to read the firmware 327 revision from serial EEPROM (addr=0x54), at offset 0x0045. 328 This is a string as: 329 "CG 00.04" -> Cristal [XU] / Geronimo [XAs] 330 "CO 00.03" -> Cognac [XU] 331 "AS 00.01" -> Ashaki [XA] */ 332 biosctl = 333 i2c_smbus_read_byte_data(new_client, 334 MAXI_REG_BIOS_CTRL); 335 i2c_smbus_write_byte_data(new_client, MAXI_REG_BIOS_CTRL, 336 biosctl | 4); 337 err = eeprom_read_byte_data(adapter, 0x54, 0x45); 338 i2c_smbus_write_byte_data(new_client, MAXI_REG_BIOS_CTRL, 339 biosctl); 480 else { 481 /* The right way to get the platform info is to read the firmware 482 revision from serial EEPROM (addr=0x54), at offset 0x0045. 483 This is a string as: 484 "CG 00.04" -> Cristal [XU] / Geronimo [XAs] 485 "CO 00.03" -> Cognac [XU] 486 "AS 00.01" -> Ashaki [XA] */ 487 #if 0 488 int biosctl; 489 biosctl = 490 i2c_smbus_read_byte_data(new_client, 491 MAXI_REG_BIOS_CTRL); 492 i2c_smbus_write_byte_data(new_client, 493 MAXI_REG_BIOS_CTRL, 494 biosctl | 4); 495 err = eeprom_read_byte_data(adapter, 0x54, 0x45); 496 i2c_smbus_write_byte_data(new_client, 497 MAXI_REG_BIOS_CTRL, 498 biosctl); 499 #endif 500 int i; 501 char *biosmem, *bm; 502 bm = biosmem = ioremap(0xe0000, 0x20000); 503 if (biosmem) { 504 printk("begin of bios search\n"); 505 for (i = 0; i < 0x20000; i++) { 506 if (*bm == 'C') { 507 char *s = bm; 508 while (s && isprint(*s)) { 509 printk("%c", *s); 510 s++; 511 } 512 printk("\n"); 513 if (!strncmp 514 (bm, "CG 00.04", 8)) { 515 maxi_version = 516 cristal; 517 printk 518 ("maxilife: found MaxiLife Rev CG 00.04\n"); 519 break; 520 } 521 if (!strncmp 522 (bm, "CO 00.03", 8)) { 523 maxi_version = 524 cognac; 525 printk 526 ("maxilife: found MaxiLife Rev CO 00.03\n"); 527 break; 528 } 529 } 530 if (*bm == 'A' && *(bm + 1) == 'S') { 531 char *s = bm; 532 while (s && isprint(*s)) { 533 printk("%c", *s); 534 s++; 535 } 536 printk("\n"); 537 if (!strncmp 538 (bm, "AS 00.01", 8)) { 539 maxi_version = 540 ashaki; 541 printk 542 ("maxilife: found MaxiLife Rev AS 00.01\n"); 543 break; 544 } 545 } 546 bm++; 547 } 548 printk("end of bios search\n"); 549 } else 550 printk("could not map bios memory\n"); 551 } 340 552 #endif 341 553 … … 358 570 printk 359 571 ("maxilife: HP KAYAK XA (Pentium II Slot 1, monoprocessor)\n"); 572 } else if (maxi_version == nba) { 573 type = nba; 574 type_name = "maxilife-nba"; 575 client_name = "HP MaxiLife NBA"; 576 printk("maxilife: HP KAYAK XU800/XM600\n"); 360 577 } else { 361 #if AUTODETECT578 #ifdef AUTODETECT 362 579 printk 363 580 ("maxilife: Warning: probed non-maxilife chip?!? (%x)\n", … … 370 587 goto ERROR2; 371 588 } 372 373 strcpy(new_client->name, client_name); 374 ((struct maxi_data *) (new_client->data))->type = type; 375 if ((err = maxi_new_client(adapter, new_client))) 376 goto ERROR2; 377 378 /* Tell i2c-core a new client has arrived */ 379 if ((err = i2c_attach_client(new_client))) 380 goto ERROR3; 381 382 /* Register a new directory entry with module sensors */ 383 if ((err = sensors_register_entry(new_client, type_name, 384 maxi_dir_table_template, 385 THIS_MODULE)) < 0) 386 goto ERROR4; 387 ((struct maxi_data *) (new_client->data))->sysctl_id = err; 388 err = 0; 389 390 /* Initialize the MaxiLife chip */ 391 maxi_init_client(new_client); 392 continue; 393 394 /* OK, this is not exactly good programming practice, usually. 395 But it is very code-efficient in this case. */ 396 ERROR4: 397 i2c_detach_client(new_client); 398 ERROR3: 399 maxi_remove_client(new_client); 400 ERROR2: 401 kfree(new_client); 402 } 589 } 590 591 /* Fill in the remaining client fields and put it into the global list */ 592 strcpy(new_client->name, client_name); 593 ((struct maxi_data *) (new_client->data))->type = type; 594 595 for (i = 0; i < 4; i++) 596 for (j = 0; j < 17; j++) 597 598 ((struct maxi_data *) (new_client->data))-> 599 lcd[i][j] = (u8) 0; 600 601 new_client->id = maxi_id++; 602 603 data->valid = 0; 604 init_MUTEX(&data->lock); 605 init_MUTEX(&data->update_lock); 606 607 /* Tell i2c-core that a new client has arrived */ 608 if ((err = i2c_attach_client(new_client))) 609 goto ERROR2; 610 611 /* Register a new directory entry with module sensors */ 612 if ((err = sensors_register_entry(new_client, type_name, 613 maxi_dir_table_template, 614 THIS_MODULE)) < 0) 615 goto ERROR4; 616 data->sysctl_id = err; 617 618 /* Initialize the MaxiLife chip */ 619 maxi_init_client(new_client); 620 return 0; 621 622 /* OK, this is not exactly good programming practice, usually. 623 But it is very code-efficient in this case. */ 624 ERROR4: 625 i2c_detach_client(new_client); 626 ERROR2: 627 kfree(new_client); 403 628 ERROR0: 404 629 return err; 405 630 } 406 631 407 int maxi_detach_smbus(struct i2c_client *client) 632 /* This function is called whenever a client should be removed: 633 - maxi_driver is removed (when this module is unloaded) 634 - when an adapter is removed which has a maxi client (and maxi_driver 635 is still present). */ 636 int maxi_detach_client(struct i2c_client *client) 408 637 { 409 638 int err; … … 417 646 return err; 418 647 } 419 maxi_remove_client(client);420 648 kfree(client); 421 649 return 0; 422 650 } 423 651 424 /* Find a free slot, and initialize most of the fields */425 int maxi_new_client(struct i2c_adapter *adapter,426 struct i2c_client *new_client)427 {428 struct maxi_data *data;429 430 new_client->id = maxi_id++;431 new_client->adapter = adapter;432 new_client->driver = &maxi_driver;433 data = new_client->data;434 data->valid = 0;435 init_MUTEX(&data->lock);436 init_MUTEX(&data->update_lock);437 return 0;438 }439 440 /* Inverse of maxi_new_client */441 void maxi_remove_client(struct i2c_client *client)442 {443 }444 445 652 /* No commands defined yet */ 446 653 int maxi_command(struct i2c_client *client, unsigned int cmd, void *arg) … … 466 673 467 674 468 /* Read byte from specified register . */675 /* Read byte from specified register (-1 in case of error, value otherwise). */ 469 676 int maxi_read_value(struct i2c_client *client, u8 reg) 470 677 { … … 472 679 } 473 680 474 #ifndef NOWRITE 475 /* Write byte to specified register. */ 681 /* Read the byte value for a MaxiLife token (-1 in case of error, value otherwise */ 682 int maxi_read_token(struct i2c_client *client, u16 token) 683 { 684 u8 lowToken, highToken; 685 int error, value; 686 687 lowToken = LOW(token); 688 highToken = HIGH(token); 689 690 /* Set mailbox status register to idle state. */ 691 error = 692 i2c_smbus_write_byte_data(client, MAXI_REG_MBX_STATUS, 693 MAXI_STAT_IDLE); 694 if (error < 0) 695 return error; 696 697 /* Check for mailbox idle state. */ 698 error = i2c_smbus_read_byte_data(client, MAXI_REG_MBX_STATUS); 699 if (error != MAXI_STAT_IDLE) 700 return -1; 701 702 /* Write the most significant byte of the token we want to read. */ 703 error = 704 i2c_smbus_write_byte_data(client, MAXI_REG_MBX_TOKEN_H, 705 highToken); 706 if (error < 0) 707 return error; 708 709 /* Write the least significant byte of the token we want to read. */ 710 error = 711 i2c_smbus_write_byte_data(client, MAXI_REG_MBX_TOKEN_L, 712 lowToken); 713 if (error < 0) 714 return error; 715 716 /* Write the read token opcode to the mailbox. */ 717 error = 718 i2c_smbus_write_byte_data(client, MAXI_REG_MBX_CMD, 719 MAXI_CMD_READ); 720 if (error < 0) 721 return error; 722 723 /* Check for transaction completion */ 724 do { 725 error = 726 i2c_smbus_read_byte_data(client, MAXI_REG_MBX_STATUS); 727 } while (error == MAXI_STAT_BUSY); 728 if (error != MAXI_STAT_OK) 729 return -1; 730 731 /* Read the value of the token. */ 732 value = i2c_smbus_read_byte_data(client, MAXI_REG_MBX_DATA); 733 if (value == -1) 734 return -1; 735 736 /* set mailbox status to idle to complete transaction. */ 737 error = 738 i2c_smbus_write_byte_data(client, MAXI_REG_MBX_STATUS, 739 MAXI_STAT_IDLE); 740 if (error < 0) 741 return error; 742 743 return value; 744 } 745 746 /* Write byte to specified register (-1 in case of error, 0 otherwise). */ 476 747 int maxi_write_value(struct i2c_client *client, u8 reg, u8 value) 477 748 { 478 749 return i2c_smbus_write_byte_data(client, reg, value); 479 750 } 480 #endif 751 752 /* Write a set of len byte values to MaxiLife token (-1 in case of error, 0 otherwise). */ 753 int maxi_write_token_loop(struct i2c_client *client, u16 token, u8 len, 754 u8 * values) 755 { 756 u8 lowToken, highToken, bCounter; 757 int error; 758 759 lowToken = LOW(token); 760 highToken = HIGH(token); 761 762 /* Set mailbox status register to idle state. */ 763 error = 764 i2c_smbus_write_byte_data(client, MAXI_REG_MBX_STATUS, 765 MAXI_STAT_IDLE); 766 if (error < 0) 767 return error; 768 769 /* Check for mailbox idle state. */ 770 error = i2c_smbus_read_byte_data(client, MAXI_REG_MBX_STATUS); 771 if (error != MAXI_STAT_IDLE) 772 return -1; 773 774 for (bCounter = 0; (bCounter < len && bCounter < 32); bCounter++) { 775 error = 776 i2c_smbus_write_byte_data(client, 777 (u8) (MAXI_REG_MBX_DATA + 778 bCounter), 779 values[bCounter]); 780 if (error < 0) 781 return error; 782 } 783 784 /* Write the most significant byte of the token we want to read. */ 785 error = 786 i2c_smbus_write_byte_data(client, MAXI_REG_MBX_TOKEN_H, 787 highToken); 788 if (error < 0) 789 return error; 790 791 /* Write the least significant byte of the token we want to read. */ 792 error = 793 i2c_smbus_write_byte_data(client, MAXI_REG_MBX_TOKEN_L, 794 lowToken); 795 if (error < 0) 796 return error; 797 798 /* Write the write token opcode to the mailbox. */ 799 error = 800 i2c_smbus_write_byte_data(client, MAXI_REG_MBX_CMD, 801 MAXI_CMD_WRITE); 802 if (error < 0) 803 return error; 804 805 /* Check for transaction completion */ 806 do { 807 error = 808 i2c_smbus_read_byte_data(client, MAXI_REG_MBX_STATUS); 809 } while (error == MAXI_STAT_BUSY); 810 if (error != MAXI_STAT_OK) 811 return -1; 812 813 /* set mailbox status to idle to complete transaction. */ 814 return i2c_smbus_write_byte_data(client, MAXI_REG_MBX_STATUS, 815 MAXI_STAT_IDLE); 816 } 481 817 482 818 /* Called when we have found a new MaxiLife. It should set limits, etc. */ 483 819 void maxi_init_client(struct i2c_client *client) 484 820 { 485 /* start with default settings */ 821 struct maxi_data *data = client->data; 822 823 if (data->type == nba) { 824 strcpy(data->lcd[2], " Linux MaxiLife"); 825 maxi_write_token_loop(client, MAXI_TOK_LCD(2), 826 strlen(data->lcd[2]) + 1, 827 data->lcd[2]); 828 } 486 829 } 487 830 … … 490 833 struct maxi_data *data = client->data; 491 834 int i; 835 836 if (data->type == nba) { 837 printk 838 ("maxi_update_client should never be called by nba\n"); 839 return; 840 } 492 841 493 842 down(&data->update_lock); … … 548 897 printk("maxilife: Unknown MaxiLife chip\n"); 549 898 } 899 data->temp[5] = 0; /* only used by MaxiLife'99 */ 900 data->temp_max[5] = 0; 901 data->temp_hyst[5] = 0; 550 902 551 903 for (i = 0; i < 3; i++) { … … 564 916 MAXI_REG_FAN_MIN(i)); 565 917 } 918 data->fan[3] = 0xff; /* only used by MaxiLife'99 */ 919 data->fan_speed[3] = 0; 920 data->fan_div[3] = 4; /* avoid possible /0 */ 921 data->fan_min[3] = 0; 566 922 567 923 data->pll = maxi_read_value(client, MAXI_REG_PLL);
