Changeset 3392

Show
Ignore:
Timestamp:
09/27/99 18:30:01 (9 years ago)
Author:
frodo
Message:

Better 10-bit addresses support

* 10-bit addresses are now passes just like 7-bit addresses; we had to

enlarge address fields to 16 bits at some places. A single bit in
client->flags now determines whether this is a 10-bit address

* i2c-dev now supports the 10-bit IOCTL again
* Documentation updates

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • i2c/trunk/doc/dev-interface

    r3377 r3392  
    7878(see also i2c-dev.h and i2c.h): 
    7979 
    80 ioctl(file,I2C_SLAVE,__u8 addr) 
     80ioctl(file,I2C_SLAVE,u16 addr) 
    8181  Change slave address. The address is passed in the 7 lower bits of the 
    82   argument (except for 10 bit addresses, pass the 8 lower bits in this 
     82  argument (except for 10 bit addresses, passed in the 10 lower bits in this 
    8383  case). 
    8484 
    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! 
     85ioctl(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. 
    8988 
    9089Other values are NOT supported at this moment, except for I2C_SMBUS, 
  • i2c/trunk/doc/writing-clients

    r3391 r3392  
    375375detection just fails for this address, return 0. 
    376376 
     377For now, you can ignore the `flags' parameter. It is there for future use. 
     378 
    377379  /* Unique ID allocation */ 
    378380  static int foo_id = 0; 
    379381 
    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) 
    381384  { 
    382385    int err = 0; 
     
    708711------------------- 
    709712 
    710   extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u8 addr,  
     713  extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u16 addr,  
    711714                             unsigned short flags, 
    712715                             char read_write, u8 command, int size, 
  • i2c/trunk/kernel/i2c-algo-bit.c

    r3388 r3392  
    443443        if ( (flags & I2C_M_TEN)  ) {  
    444444                /* a ten bit address */ 
    445                 addr = 0xf0 | ( flags & I2C_M_TENMASK ); 
     445                addr = 0xf0 | (( msg->addr >> 7) & 0x03); 
    446446                DEB2(printk("addr0: %d\n",addr)); 
    447447                /* try extended address code...*/ 
     
    452452                } 
    453453                /* the remaining 8 bit address */ 
    454                 ret = i2c_outb(i2c_adap,msg->addr); 
     454                ret = i2c_outb(i2c_adap,msg->addr & 0x7f); 
    455455                if (ret != 1) { 
    456456                        printk("died at 2nd address code.\n"); 
  • i2c/trunk/kernel/i2c-algo-pcf.c

    r3388 r3392  
    384384        if ( (flags & I2C_M_TEN)  ) {  
    385385                /* a ten bit address */ 
    386                addr = 0xf0 | ( flags & I2C_M_TENMASK ); 
     386                addr = 0xf0 | (( msg->addr >> 7) & 0x03); 
    387387                DEB2(printk("addr0: %d\n",addr)); 
    388388                /* try extended address code...*/ 
     
    393393                } 
    394394                /* the remaining 8 bit address */ 
    395                 i2c_outb(adap,msg->addr); 
     395                i2c_outb(adap,msg->addr & 0x7f); 
    396396/* Status check comes here */ 
    397397                if (ret != 1) { 
  • i2c/trunk/kernel/i2c-core.c

    r3391 r3392  
    753753        if (client->adapter->algo->master_xfer) { 
    754754                msg.addr   = client->addr; 
    755                 msg.flags = client->flags & ( I2C_M_TEN|I2C_M_TENMASK )
     755                msg.flags = client->flags & I2C_M_TEN
    756756                msg.len = count; 
    757757                (const char *)msg.buf = buf; 
     
    782782        if (client->adapter->algo->master_xfer) { 
    783783                msg.addr   = client->addr; 
    784                 msg.flags = client->flags & ( I2C_M_TEN|I2C_M_TENMASK )
     784                msg.flags = client->flags & I2C_M_TEN
    785785                msg.flags |= I2C_M_RD; 
    786786                msg.len = count; 
     
    10791079/* Simulate a SMBus command using the i2c protocol  
    10801080   No checking of parameters is done!  */ 
    1081 static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u8 addr,  
     1081static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,  
    10821082                                   unsigned short flags, 
    10831083                                   char read_write, u8 command, int size,  
     
    11781178 
    11791179 
    1180 s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u8 addr, unsigned short flags, 
     1180s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags, 
    11811181                   char read_write, u8 command, int size,  
    11821182                   union i2c_smbus_data * data) 
  • i2c/trunk/kernel/i2c-dev.c

    r3391 r3392  
    277277  switch ( cmd ) { 
    278278    case I2C_SLAVE: 
    279       if (arg > 0x7f
     279      if ((arg > 0x3ff) || (((client->flags & I2C_M_TEN) == 0) && arg > 0x7f)
    280280        return -EINVAL; 
    281281      client->addr = arg; 
    282282      return 0; 
    283283    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; 
    286289    case I2C_SMBUS: 
    287290      if (! arg) { 
  • i2c/trunk/kernel/i2c.h

    r3391 r3392  
    8989 */ 
    9090struct i2c_msg { 
    91         unsigned char addr;   /* slave address                        */ 
     91        u16 addr;     /* slave address                        */ 
    9292        unsigned short flags;            
    9393#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      0x12 
    96 #define I2C_M_TEN2      0x14 
    97 #define I2C_M_TEN3      0x16 
    98 #define I2C_M_TENMASK   0x06 
    9994#define I2C_M_RD        0x01 
    10095#if 0 
     
    111106   Note that we use i2c_adapter here, because you do not need a specific 
    112107   smbus adapter to call this function. */ 
    113 extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u8 addr,  
     108extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u16 addr,  
    114109                           unsigned short flags, 
    115110                           char read_write, u8 command, int size, 
     
    194189                                        /* addresses are stored in the  */ 
    195190                                        /* _LOWER_ 7 bits of this char  */ 
    196                                         /* 10 bit addresses use the full*/ 
    197                                         /* 8 bits & the flags like in   */ 
    198                                         /* i2c_msg                      */ 
    199191        /* addr: unsigned int to make lm_sensors i2c-isa adapter work 
    200192           more cleanly. It does not take any more memory space, due to 
     
    222214        int (*master_xfer)(struct i2c_adapter *adap,struct i2c_msg msgs[],  
    223215                           int num); 
    224         int (*smbus_xfer) (struct i2c_adapter *adap, u8 addr,  
     216        int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr,  
    225217                           unsigned short flags, char read_write, 
    226218                           u8 command, int size, union i2c_smbus_data * data); 
     
    437429/* this is for i2c-dev.c        */ 
    438430#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   */ 
    445433 
    446434#define I2C_ACK_TEST    0x0710  /* See if a slave is at a specific adress */