Changeset 3428

Show
Ignore:
Timestamp:
01/09/00 17:00:48 (9 years ago)
Author:
frodo
Message:

Petr's patches and more

* Removed compile warning about /* use
* Added I2C_M_NOSTART and I2C_M_REV_DIR_ADDR flags
* Added I2C_FUNC_PROTOCOL_MANGLING flag corresponding to both flags above
* Added support for these flags for bit and pcf algorithms
* Documented the flags within doc/i2c-protocol

Files:

Legend:

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

    r3384 r3428  
    4545 
    4646  S Addr Rd [A] [Data] NA S Addr Wr [A] Data [A] P 
     47 
     48 
     49Modified transactions 
     50===================== 
     51 
     52We have found some I2C devices that needs the following modifications: 
     53 
     54  Flag I2C_M_NOSTART:  
     55    In a combined transaction, no 'S Addr' is generated at some point. 
     56    For example, setting I2C_M_NOSTART on the second partial message 
     57    generateds something like: 
     58      S Addr Rd [A] [Data] NA Wr [A] Data [A] P 
     59    If you set the I2C_M_NOSTART variable for the first partial message, 
     60    we do not generate Addr, but we do generate the startbit S. This will 
     61    probably confuse all other clients on your bus, so don't try this. 
     62 
     63  Flags I2C_M_REV_DIR_ADDR 
     64    This toggles the Rd/Wr flag. That is, if you want to do a write, but 
     65    need to emit an Rd instead of a Wr, or vice versa, you set this 
     66    flag. For example: 
     67      S Addr Rd [A] Data [A] Data [A] ... [A] Data [A] P 
     68                       
  • i2c/trunk/doc/pcf

    r3314 r3428  
    2424VERSIONS 
    2525======== 
     26 
     2720000109 (Frodo Looijaard, frodol@dds.nl) 
     28----------------------------------------- 
     29 
     30- Hopefully fixed the horribly broken pcf_xfer function 
     31- Added I2C_M_NOSTART and I2C_M_REV_DIR_ADDR support 
    2632 
    273319990218 
  • i2c/trunk/kernel/i2c-algo-bit.c

    r3421 r3428  
    487487                if (flags & I2C_M_RD ) 
    488488                        addr |= 1; 
     489                if (flags & I2C_M_REV_DIR_ADDR ) 
     490                        addr ^= 1; 
    489491                ret = try_address(i2c_adap, addr, retries); 
    490492                if (ret!=1) { 
     
    506508        for (i=0;i<num;i++) { 
    507509                pmsg = &msgs[i]; 
    508                 ret = bit_doAddress(i2c_adap,pmsg,i2c_adap->retries); 
    509                 if (ret != 0) { 
    510                         DEB2(printk("i2c-algo-bit.o: NAK from device adr %#2x msg #%d\n" 
    511                                ,msgs[i].addr,i)); 
    512                         return (ret<0) ? ret : -EREMOTEIO; 
     510                if (!(pmsg->flags & I2C_M_NOSTART)) { 
     511                        if (i) { 
     512                                i2c_repstart(adap); 
     513                        } 
     514                        ret = bit_doAddress(i2c_adap,pmsg,i2c_adap->retries); 
     515                        if (ret != 0) { 
     516                                DEB2(printk("i2c-algo-bit.o: NAK from device adr %#2x msg #%d\n" 
     517                                       ,msgs[i].addr,i)); 
     518                                return (ret<0) ? ret : -EREMOTEIO; 
     519                        } 
    513520                } 
    514521                if (pmsg->flags & I2C_M_RD ) { 
     
    527534                        } 
    528535                } 
    529                 if (i<num-1) { 
    530                         i2c_repstart(adap); 
    531                 } 
    532536        } 
    533537        i2c_stop(adap); 
     
    543547static u32 bit_func(struct i2c_adapter *adap) 
    544548{ 
    545         return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR; 
     549        return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR |  
     550               I2C_FUNC_PROTOCOL_MANGLING; 
    546551} 
    547552 
  • i2c/trunk/kernel/i2c-algo-pcf.c

    r3421 r3428  
    413413        } else {                /* normal 7bit address  */ 
    414414                addr = ( msg->addr << 1 ); 
    415                 if (flags & I2C_M_RD ) 
    416                         addr |= 1; 
     415                if (flags & I2C_M_RD ) 
     416                        addr |= 1; 
     417                if (flags & I2C_M_REV_DIR_ADDR ) 
     418                        addr ^= 1; 
    417419                i2c_outb(adap, addr); 
    418420        } 
     
    424426                    int num) 
    425427{ 
    426    struct i2c_algo_pcf_data *adap = i2c_adap->algo_data; 
    427    struct i2c_msg *pmsg; 
    428    int i, ret, timeout, status; 
    429  
    430    timeout = wait_for_bb(adap); 
    431    if (timeout) { 
    432       DEB2(printk("i2c-algo-pcf.o: Timeout waiting for BB in pcf_xfer\n");) 
    433       return -EIO; 
    434    } 
    435    pmsg = &msgs[0]; 
    436    ret = pcf_doAddress(adap, pmsg, i2c_adap->retries); 
    437    i2c_start(adap); 
    438  
    439    for (i=0; i<num; i++) { 
    440       DEB3(printk("i2c-algo-pcf.o: Msg %d, addr=0x%x, flags=0x%x, len=%d\n", 
    441                   i, msgs[i].addr, msgs[i].flags, msgs[i].len);) 
    442       timeout = wait_for_pin(adap, &status); 
    443       if (timeout) { 
    444          DEB2(printk("i2c-algo-pcf.o: Timeout waiting for PIN(1) in pcf_xfer\n");) 
    445          i2c_stop(adap); 
    446          return (-EREMOTEIO); 
    447       } 
    448       if (status & I2C_PCF_LRB) { 
    449          i2c_stop(adap); 
    450          DEB2(printk("i2c-algo-pcf.o: NAK from device adr %#2x msg #%d\n" 
    451                                ,msgs[i].addr,i)); 
    452          return -EREMOTEIO; 
    453       } 
    454       if (pmsg->flags & I2C_M_RD ) { 
    455          /* read bytes into buffer*/ 
    456          ret = pcf_readbytes(i2c_adap, pmsg->buf, pmsg->len); 
    457          DEB2(printk("i2c-algo-pcf.o: read %d bytes.\n",ret)); 
    458       } else { 
    459          /* write bytes from buffer */ 
    460          ret = pcf_sendbytes(i2c_adap, pmsg->buf, pmsg->len); 
    461          DEB2(printk("i2c-algo-pcf.o: wrote %d bytes.\n",ret)); 
    462       } 
    463       if (i == (num-1)) { 
    464          i2c_stop(adap);          
    465       } 
    466       else { 
    467          i2c_repstart(adap); 
    468       } 
    469       if (pmsg->flags & I2C_M_RD ) { 
    470          pmsg->buf[pmsg->len-1] =  i2c_inb(adap); 
    471       } 
    472       if (i != (num-1)) { 
    473          pmsg = &msgs[0]; 
    474          ret = pcf_doAddress(adap, pmsg, i2c_adap->retries); 
    475          timeout = wait_for_pin(adap, &status); 
    476          if (timeout) { 
    477             DEB2(printk("i2c-algo-pcf.o: Timeout waiting for PIN(2) in pcf_xfer\n");) 
    478             return (-EREMOTEIO); 
    479          } 
    480          if (status & I2C_PCF_LRB) { 
    481             i2c_stop(adap); 
    482             DEB2(printk("i2c-algo-pcf.o: No LRB(2) in pcf_xfer\n");) 
    483             return (-EREMOTEIO); 
    484          } 
    485       } 
    486    } 
    487    return (num); 
    488 
    489  
     428        struct i2c_algo_pcf_data *adap = i2c_adap->algo_data; 
     429        struct i2c_msg *pmsg; 
     430        int i, ret, timeout, status; 
     431 
     432        timeout = wait_for_bb(adap); 
     433        if (timeout) { 
     434                DEB2(printk("i2c-algo-pcf.o: Timeout waiting for BB in pcf_xfer\n");) 
     435                return -EIO; 
     436        } 
     437        i2c_start(adap); 
     438 
     439        for (i=0; i<num; i++) { 
     440                pmsg = &msgs[i]; 
     441                if (!(pmsg->flags & I2C_M_NOSTART)) { 
     442                        if (i) { 
     443                                i2c_repstart(adap); 
     444                        } 
     445                        ret = pcf_doAddress(adap, pmsg, i2c_adap->retries); 
     446                        timeout = wait_for_pin(adap, &status); 
     447                        if (timeout) { 
     448                        DEB2(printk("i2c-algo-pcf.o: Timeout waiting for PIN(1) in pcf_xfer\n");) 
     449                        return (-EREMOTEIO); 
     450                        } 
     451                        if (status & I2C_PCF_LRB) { 
     452                        i2c_stop(adap); 
     453                        DEB2(printk("i2c-algo-pcf.o: No LRB(1) in pcf_xfer\n");) 
     454                        return (-EREMOTEIO); 
     455                        } 
     456                } 
     457                DEB3(printk("i2c-algo-pcf.o: Msg %d, addr=0x%x, flags=0x%x, len=%d\n", 
     458                        i, msgs[i].addr, msgs[i].flags, msgs[i].len);) 
     459                if (pmsg->flags & I2C_M_RD ) { 
     460                        /* read bytes into buffer*/ 
     461                        ret = pcf_readbytes(i2c_adap, pmsg->buf, pmsg->len); 
     462                        DEB2(printk("i2c-algo-pcf.o: read %d bytes.\n",ret)); 
     463                } else { 
     464                        /* write bytes from buffer */ 
     465                        ret = pcf_sendbytes(i2c_adap, pmsg->buf, pmsg->len); 
     466                        DEB2(printk("i2c-algo-pcf.o: wrote %d bytes.\n",ret)); 
     467                } 
     468        } 
     469        i2c_stop(adap);   
     470        return (num); 
     471
    490472 
    491473static int algo_control(struct i2c_adapter *adapter,  
     
    497479static u32 pcf_func(struct i2c_adapter *adap) 
    498480{ 
    499         return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR; 
     481        return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR |  
     482               I2C_FUNC_PROTOCOL_MANGLING;  
    500483} 
    501484 
  • i2c/trunk/kernel/i2c-elv.c

    r3421 r3428  
    1717    along with this program; if not, write to the Free Software 
    1818    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                */ 
    19 /* -------------------------------------------------------------------------  
     19/* ------------------------------------------------------------------------- */ 
    2020 
    2121/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even 
  • i2c/trunk/kernel/i2c-philips-par.c

    r3421 r3428  
    1717    along with this program; if not, write to the Free Software 
    1818    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                */ 
    19 /* -------------------------------------------------------------------------  
     19/* ------------------------------------------------------------------------- */  
    2020 
    2121/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even 
  • i2c/trunk/kernel/i2c-velleman.c

    r3421 r3428  
    1717    along with this program; if not, write to the Free Software 
    1818    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                */ 
    19 /* -------------------------------------------------------------------------  
     19/* ------------------------------------------------------------------------- */ 
    2020 
    2121/* $Id$ */ 
  • i2c/trunk/kernel/i2c.h

    r3421 r3428  
    9595#define I2C_M_TEN       0x10    /* we have a ten bit chip address       */ 
    9696#define I2C_M_RD        0x01 
     97#define I2C_M_NOSTART   0x4000 
     98#define I2C_M_REV_DIR_ADDR      0x2000 
    9799#if 0 
    98100#define I2C_M_PROBE     0x20 
     
    364366#define I2C_FUNC_I2C                    0x00000001 
    365367#define I2C_FUNC_10BIT_ADDR             0x00000002 
     368#define I2C_FUNC_PROTOCOL_MANGLING      0x00000004 /* I2C_M_{RD,NOSTART} */ 
    366369#define I2C_FUNC_SMBUS_QUICK            0x00010000  
    367370#define I2C_FUNC_SMBUS_READ_BYTE        0x00020000