Changeset 40
- Timestamp:
- 12/06/98 16:21:29 (14 years ago)
- Location:
- lm-sensors/trunk
- Files:
-
- 4 modified
-
kernel/busses/i2c-piix4.c (modified) (10 diffs)
-
kernel/chips/lm75.c (modified) (2 diffs)
-
src/lm75.c (modified) (2 diffs)
-
src/piix4.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/kernel/busses/i2c-piix4.c
r39 r40 62 62 #define MAX_TIMEOUT 500 63 63 #define ENABLE_INT9 0 64 65 /* PIIX4 constants */ 66 #define PIIX4_QUICK 0x00 67 #define PIIX4_BYTE 0x04 68 #define PIIX4_BYTE_DATA 0x08 69 #define PIIX4_WORD_DATA 0x0C 70 #define PIIX4_BLOCK_DATA 0x14 71 64 72 65 73 static int piix4_init(void); … … 205 213 int timeout=0; 206 214 215 #ifdef DEBUG 216 printk("piix4.o: Transaction: CNT=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, " 217 "DAT1=%02x\n", 218 inb_p(SMBHSTCNT),inb_p(SMBHSTCMD),inb_p(SMBHSTADD),inb_p(SMBHSTDAT0), 219 inb_p(SMBHSTDAT1)); 220 #endif 221 207 222 /* Make sure the SMBus host is ready to start transmitting */ 208 223 if ((temp = inb_p(SMBHSTSTS)) != 0x00) { 209 224 #ifdef DEBUG 210 printk("piix4.o: SMBus busy (%02x). Resetting... ",temp);225 printk("piix4.o: SMBus busy (%02x). Resetting... \n",temp); 211 226 #endif 212 227 outb_p(temp, SMBHSTSTS); … … 226 241 outb_p(inb(SMBHSTCNT) | 0x040, SMBHSTCNT); 227 242 228 /* Wait for a fraction of a second! (See PIIX4 docs errata) */ 229 piix4_do_pause(1); 230 231 /* Poll Host_busy bit */ 232 temp=inb_p(SMBHSTSTS) & 0x01; 233 while (temp & (timeout++ < MAX_TIMEOUT)) { 234 /* Wait for a while and try again*/ 243 /* We will always wait for a fraction of a second! (See PIIX4 docs errata) */ 244 do { 235 245 piix4_do_pause(1); 236 temp = inb_p(SMBHSTSTS) & 0x01;237 } 246 temp=inb_p(SMBHSTSTS); 247 } while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT)); 238 248 239 249 /* If the SMBus is still busy, we give up */ … … 245 255 } 246 256 247 temp = inb_p(SMBHSTSTS); 248 249 if (temp & 0x10) { 257 if (temp & 0x10) { 250 258 result = -1; 251 259 #ifdef DEBUG … … 285 293 int i,len; 286 294 287 outb_p((size & 0x1C) + (ENABLE_INT9 & 1), SMBHSTCNT);288 289 295 switch(size) { 296 case SMBUS_PROC_CALL: 297 printk("piix4.o: SMBUS_PROC_CALL not supported!\n"); 298 return -1; 290 299 case SMBUS_QUICK: 291 300 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD); 301 size = PIIX4_QUICK; 292 302 break; 293 303 case SMBUS_BYTE: … … 295 305 if (read_write == SMBUS_WRITE) 296 306 outb_p(command, SMBHSTCMD); 307 size = PIIX4_BYTE; 297 308 break; 298 309 case SMBUS_BYTE_DATA: … … 301 312 if (read_write == SMBUS_WRITE) 302 313 outb_p(data->byte,SMBHSTDAT0); 314 size = PIIX4_BYTE_DATA; 303 315 break; 304 316 case SMBUS_WORD_DATA: … … 309 321 outb_p((data->word & 0xff00) >> 8,SMBHSTDAT1); 310 322 } 323 size = PIIX4_WORD_DATA; 311 324 break; 312 325 case SMBUS_BLOCK_DATA: … … 323 336 for (i = 1; i <= len; i ++) 324 337 outb_p(data->block[i],SMBBLKDAT); 325 break;326 338 } 327 } 339 size = PIIX4_BLOCK_DATA; 340 break; 341 } 342 343 outb_p((size & 0x1C) + (ENABLE_INT9 & 1), SMBHSTCNT); 328 344 329 345 if (piix4_transaction()) /* Error in transaction */ 330 346 return -1; 331 347 332 333 if ((read_write == SMBUS_WRITE) || (size == SMBUS_QUICK)) 348 if ((read_write == SMBUS_WRITE) || (size == PIIX4_QUICK)) 334 349 return 0; 335 350 336 351 337 352 switch(size) { 338 case SMBUS_BYTE: /* Where is the result put? I assume here it is in353 case PIIX4_BYTE: /* Where is the result put? I assume here it is in 339 354 SMBHSTDAT0 but it might just as well be in the 340 355 SMBHSTCMD. No clue in the docs */ … … 342 357 data->byte = inb_p(SMBHSTDAT0); 343 358 break; 344 case SMBUS_BYTE_DATA:359 case PIIX4_BYTE_DATA: 345 360 data->byte = inb_p(SMBHSTDAT0); 346 361 break; 347 case SMBUS_WORD_DATA:362 case PIIX4_WORD_DATA: 348 363 data->word = inb_p(SMBHSTDAT0) + (inb_p(SMBHSTDAT1) << 8); 349 364 break; 350 case SMBUS_BLOCK_DATA:365 case PIIX4_BLOCK_DATA: 351 366 data->block[0] = inb_p(SMBHSTDAT0); 352 367 i = inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */ -
lm-sensors/trunk/kernel/chips/lm75.c
r39 r40 123 123 adapter, and check whether they are used here */ 124 124 125 if (smbus_read_byte_data(adapter,address,LM75_REG_CONF) == 0xff)125 if (smbus_read_byte_data(adapter,address,LM75_REG_CONF) < 0) 126 126 continue; 127 127 … … 168 168 goto ERROR3; 169 169 data->sysctl_id = err; 170 err = 0; 170 171 171 172 /* Initialize the LM75 chip */ -
lm-sensors/trunk/src/lm75.c
r39 r40 123 123 adapter, and check whether they are used here */ 124 124 125 if (smbus_read_byte_data(adapter,address,LM75_REG_CONF) == 0xff)125 if (smbus_read_byte_data(adapter,address,LM75_REG_CONF) < 0) 126 126 continue; 127 127 … … 168 168 goto ERROR3; 169 169 data->sysctl_id = err; 170 err = 0; 170 171 171 172 /* Initialize the LM75 chip */ -
lm-sensors/trunk/src/piix4.c
r39 r40 62 62 #define MAX_TIMEOUT 500 63 63 #define ENABLE_INT9 0 64 65 /* PIIX4 constants */ 66 #define PIIX4_QUICK 0x00 67 #define PIIX4_BYTE 0x04 68 #define PIIX4_BYTE_DATA 0x08 69 #define PIIX4_WORD_DATA 0x0C 70 #define PIIX4_BLOCK_DATA 0x14 71 64 72 65 73 static int piix4_init(void); … … 205 213 int timeout=0; 206 214 215 #ifdef DEBUG 216 printk("piix4.o: Transaction: CNT=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, " 217 "DAT1=%02x\n", 218 inb_p(SMBHSTCNT),inb_p(SMBHSTCMD),inb_p(SMBHSTADD),inb_p(SMBHSTDAT0), 219 inb_p(SMBHSTDAT1)); 220 #endif 221 207 222 /* Make sure the SMBus host is ready to start transmitting */ 208 223 if ((temp = inb_p(SMBHSTSTS)) != 0x00) { 209 224 #ifdef DEBUG 210 printk("piix4.o: SMBus busy (%02x). Resetting... ",temp);225 printk("piix4.o: SMBus busy (%02x). Resetting... \n",temp); 211 226 #endif 212 227 outb_p(temp, SMBHSTSTS); … … 226 241 outb_p(inb(SMBHSTCNT) | 0x040, SMBHSTCNT); 227 242 228 /* Wait for a fraction of a second! (See PIIX4 docs errata) */ 229 piix4_do_pause(1); 230 231 /* Poll Host_busy bit */ 232 temp=inb_p(SMBHSTSTS) & 0x01; 233 while (temp & (timeout++ < MAX_TIMEOUT)) { 234 /* Wait for a while and try again*/ 243 /* We will always wait for a fraction of a second! (See PIIX4 docs errata) */ 244 do { 235 245 piix4_do_pause(1); 236 temp = inb_p(SMBHSTSTS) & 0x01;237 } 246 temp=inb_p(SMBHSTSTS); 247 } while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT)); 238 248 239 249 /* If the SMBus is still busy, we give up */ … … 245 255 } 246 256 247 temp = inb_p(SMBHSTSTS); 248 249 if (temp & 0x10) { 257 if (temp & 0x10) { 250 258 result = -1; 251 259 #ifdef DEBUG … … 285 293 int i,len; 286 294 287 outb_p((size & 0x1C) + (ENABLE_INT9 & 1), SMBHSTCNT);288 289 295 switch(size) { 296 case SMBUS_PROC_CALL: 297 printk("piix4.o: SMBUS_PROC_CALL not supported!\n"); 298 return -1; 290 299 case SMBUS_QUICK: 291 300 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD); 301 size = PIIX4_QUICK; 292 302 break; 293 303 case SMBUS_BYTE: … … 295 305 if (read_write == SMBUS_WRITE) 296 306 outb_p(command, SMBHSTCMD); 307 size = PIIX4_BYTE; 297 308 break; 298 309 case SMBUS_BYTE_DATA: … … 301 312 if (read_write == SMBUS_WRITE) 302 313 outb_p(data->byte,SMBHSTDAT0); 314 size = PIIX4_BYTE_DATA; 303 315 break; 304 316 case SMBUS_WORD_DATA: … … 309 321 outb_p((data->word & 0xff00) >> 8,SMBHSTDAT1); 310 322 } 323 size = PIIX4_WORD_DATA; 311 324 break; 312 325 case SMBUS_BLOCK_DATA: … … 323 336 for (i = 1; i <= len; i ++) 324 337 outb_p(data->block[i],SMBBLKDAT); 325 break;326 338 } 327 } 339 size = PIIX4_BLOCK_DATA; 340 break; 341 } 342 343 outb_p((size & 0x1C) + (ENABLE_INT9 & 1), SMBHSTCNT); 328 344 329 345 if (piix4_transaction()) /* Error in transaction */ 330 346 return -1; 331 347 332 333 if ((read_write == SMBUS_WRITE) || (size == SMBUS_QUICK)) 348 if ((read_write == SMBUS_WRITE) || (size == PIIX4_QUICK)) 334 349 return 0; 335 350 336 351 337 352 switch(size) { 338 case SMBUS_BYTE: /* Where is the result put? I assume here it is in353 case PIIX4_BYTE: /* Where is the result put? I assume here it is in 339 354 SMBHSTDAT0 but it might just as well be in the 340 355 SMBHSTCMD. No clue in the docs */ … … 342 357 data->byte = inb_p(SMBHSTDAT0); 343 358 break; 344 case SMBUS_BYTE_DATA:359 case PIIX4_BYTE_DATA: 345 360 data->byte = inb_p(SMBHSTDAT0); 346 361 break; 347 case SMBUS_WORD_DATA:362 case PIIX4_WORD_DATA: 348 363 data->word = inb_p(SMBHSTDAT0) + (inb_p(SMBHSTDAT1) << 8); 349 364 break; 350 case SMBUS_BLOCK_DATA:365 case PIIX4_BLOCK_DATA: 351 366 data->block[0] = inb_p(SMBHSTDAT0); 352 367 i = inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */
