Changeset 3392
- Timestamp:
- 09/27/99 18:30:01 (9 years ago)
- Files:
-
- i2c/trunk/doc/dev-interface (modified) (1 diff)
- i2c/trunk/doc/writing-clients (modified) (2 diffs)
- i2c/trunk/kernel/i2c-algo-bit.c (modified) (2 diffs)
- i2c/trunk/kernel/i2c-algo-pcf.c (modified) (2 diffs)
- i2c/trunk/kernel/i2c-core.c (modified) (4 diffs)
- i2c/trunk/kernel/i2c-dev.c (modified) (1 diff)
- i2c/trunk/kernel/i2c.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
i2c/trunk/doc/dev-interface
r3377 r3392 78 78 (see also i2c-dev.h and i2c.h): 79 79 80 ioctl(file,I2C_SLAVE, __u8addr)80 ioctl(file,I2C_SLAVE,u16 addr) 81 81 Change slave address. The address is passed in the 7 lower bits of the 82 argument (except for 10 bit addresses, pass the 8lower bits in this82 argument (except for 10 bit addresses, passed in the 10 lower bits in this 83 83 case). 84 84 85 ioctl(file,I2C_TENBIT,__s8 addr_hi) 86 Select ten bit addresses, and set the two high bits of the address (by 87 passing them in the low two bits of addr_hi). Passing a negative 88 value will reset to 7 bit addresses. NOT FULLY SUPPORTED! 85 ioctl(file,I2C_TENBIT,u8 select) 86 Selects ten bit addresses if select not equals 0, selects normal 7 bit 87 addresses if select equals 0. 89 88 90 89 Other values are NOT supported at this moment, except for I2C_SMBUS, i2c/trunk/doc/writing-clients
r3391 r3392 375 375 detection just fails for this address, return 0. 376 376 377 For now, you can ignore the `flags' parameter. It is there for future use. 378 377 379 /* Unique ID allocation */ 378 380 static int foo_id = 0; 379 381 380 int foo_detect_client(struct i2c_adapter *adapter, int address, int kind) 382 int foo_detect_client(struct i2c_adapter *adapter, int address, 383 unsigned short flags, int kind) 381 384 { 382 385 int err = 0; … … 708 711 ------------------- 709 712 710 extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u 8addr,713 extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u16 addr, 711 714 unsigned short flags, 712 715 char read_write, u8 command, int size, i2c/trunk/kernel/i2c-algo-bit.c
r3388 r3392 443 443 if ( (flags & I2C_M_TEN) ) { 444 444 /* a ten bit address */ 445 addr = 0xf0 | ( flags & I2C_M_TENMASK);445 addr = 0xf0 | (( msg->addr >> 7) & 0x03); 446 446 DEB2(printk("addr0: %d\n",addr)); 447 447 /* try extended address code...*/ … … 452 452 } 453 453 /* the remaining 8 bit address */ 454 ret = i2c_outb(i2c_adap,msg->addr );454 ret = i2c_outb(i2c_adap,msg->addr & 0x7f); 455 455 if (ret != 1) { 456 456 printk("died at 2nd address code.\n"); i2c/trunk/kernel/i2c-algo-pcf.c
r3388 r3392 384 384 if ( (flags & I2C_M_TEN) ) { 385 385 /* a ten bit address */ 386 addr = 0xf0 | ( flags & I2C_M_TENMASK);386 addr = 0xf0 | (( msg->addr >> 7) & 0x03); 387 387 DEB2(printk("addr0: %d\n",addr)); 388 388 /* try extended address code...*/ … … 393 393 } 394 394 /* the remaining 8 bit address */ 395 i2c_outb(adap,msg->addr );395 i2c_outb(adap,msg->addr & 0x7f); 396 396 /* Status check comes here */ 397 397 if (ret != 1) { i2c/trunk/kernel/i2c-core.c
r3391 r3392 753 753 if (client->adapter->algo->master_xfer) { 754 754 msg.addr = client->addr; 755 msg.flags = client->flags & ( I2C_M_TEN|I2C_M_TENMASK );755 msg.flags = client->flags & I2C_M_TEN; 756 756 msg.len = count; 757 757 (const char *)msg.buf = buf; … … 782 782 if (client->adapter->algo->master_xfer) { 783 783 msg.addr = client->addr; 784 msg.flags = client->flags & ( I2C_M_TEN|I2C_M_TENMASK );784 msg.flags = client->flags & I2C_M_TEN; 785 785 msg.flags |= I2C_M_RD; 786 786 msg.len = count; … … 1079 1079 /* Simulate a SMBus command using the i2c protocol 1080 1080 No checking of parameters is done! */ 1081 static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u 8addr,1081 static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, 1082 1082 unsigned short flags, 1083 1083 char read_write, u8 command, int size, … … 1178 1178 1179 1179 1180 s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u 8addr, unsigned short flags,1180 s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags, 1181 1181 char read_write, u8 command, int size, 1182 1182 union i2c_smbus_data * data) i2c/trunk/kernel/i2c-dev.c
r3391 r3392 277 277 switch ( cmd ) { 278 278 case I2C_SLAVE: 279 if ( arg > 0x7f)279 if ((arg > 0x3ff) || (((client->flags & I2C_M_TEN) == 0) && arg > 0x7f)) 280 280 return -EINVAL; 281 281 client->addr = arg; 282 282 return 0; 283 283 case I2C_TENBIT: 284 printk("i2c-dev.o: ioctl I2C_TENBIT not (yet) supported!\n"); 285 return -EINVAL; 284 if (arg) 285 client->flags |= I2C_M_TEN; 286 else 287 client->flags &= ~I2C_M_TEN; 288 return 0; 286 289 case I2C_SMBUS: 287 290 if (! arg) { i2c/trunk/kernel/i2c.h
r3391 r3392 89 89 */ 90 90 struct i2c_msg { 91 u nsigned charaddr; /* slave address */91 u16 addr; /* slave address */ 92 92 unsigned short flags; 93 93 #define I2C_M_TEN 0x10 /* we have a ten bit chip address */ 94 #define I2C_M_TEN0 0x10 /* herein lie the first 2 bits */95 #define I2C_M_TEN1 0x1296 #define I2C_M_TEN2 0x1497 #define I2C_M_TEN3 0x1698 #define I2C_M_TENMASK 0x0699 94 #define I2C_M_RD 0x01 100 95 #if 0 … … 111 106 Note that we use i2c_adapter here, because you do not need a specific 112 107 smbus adapter to call this function. */ 113 extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u 8addr,108 extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u16 addr, 114 109 unsigned short flags, 115 110 char read_write, u8 command, int size, … … 194 189 /* addresses are stored in the */ 195 190 /* _LOWER_ 7 bits of this char */ 196 /* 10 bit addresses use the full*/197 /* 8 bits & the flags like in */198 /* i2c_msg */199 191 /* addr: unsigned int to make lm_sensors i2c-isa adapter work 200 192 more cleanly. It does not take any more memory space, due to … … 222 214 int (*master_xfer)(struct i2c_adapter *adap,struct i2c_msg msgs[], 223 215 int num); 224 int (*smbus_xfer) (struct i2c_adapter *adap, u 8addr,216 int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr, 225 217 unsigned short flags, char read_write, 226 218 u8 command, int size, union i2c_smbus_data * data); … … 437 429 /* this is for i2c-dev.c */ 438 430 #define I2C_SLAVE 0x0703 /* Change slave address */ 439 /* Attn.: Slave address is 7 bits long, */ 440 /* these are to be passed as the */ 441 /* lowest 7 bits in the arg. */ 442 /* for 10-bit addresses pass lower 8bits*/ 443 #define I2C_TENBIT 0x0704 /* with 0-3 as arg to this call */ 444 /* a value <0 resets to 7 bits */ 431 /* Attn.: Slave address is 7 or 10 bits */ 432 #define I2C_TENBIT 0x0704 /* 0 for 7 bit addrs, != 0 for 10 bit */ 445 433 446 434 #define I2C_ACK_TEST 0x0710 /* See if a slave is at a specific adress */
