• Cyrille Pitchen's avatar
    i2c: at91: add support for new alternative command mode · 0ef6f321
    Cyrille Pitchen authored
    The alternative command mode was introduced to simplify the transmission
    of STOP conditions and to solve timing and latency issues around them.
    
    This mode relies on a new register, the Alternative Command Register,
    which must be set at the same time as the Master Mode Register. This new
    register was designed to allow simple setup of basic combined transactions
    built from up to two unitary transactions.
    
    Indeed, the ACR is split into two areas, which describe one unitary
    transaction each. Each area is filled with Data Length 8bit counter, a
    Direction and a PEC Request bit. The PEC bit is only used in SMBus mode
    and is not supported by this driver yet. Also when using alternative
    command mode, the MREAD bit from the Master Mode Register is ignored.
    Instead the Direction bits from ACR are used to setup the direction, read
    or write, of each unitary transaction. Finally the 8bit counters must
    filled with the data length of their respective transaction. Then if only
    one transaction is to be used, the data length of the second one must be
    set to zero. At the moment, this driver uses only the first transaction.
    
    In addition to MMR and ACR, the Control Register also need to be written
    to enable the alternative command mode. That's the purpose of its ACMEN
    bit, which stands for Alternative Command Mode Enable.
    
    Note that the alternative command mode is compatible with the use of the
    Internal Address Register. So combined transactions for eeprom read are
    actually implemented with the Internal Address Register. This register is
    written with up to 3 bytes, which are the internal address sent to the
    slave through the first write transaction. Then the first area of the ACR
    describe the write transaction to follow, which carries the data to be
    read from the eeprom. The second area of the ACR is not used so its Data
    Length 8bit counter is cleared.
    
    For each byte sent or received by the device, the Data Length 8bit counter
    is decremented. When it reaches 0, a STOP condition is automatically sent.
    Signed-off-by: default avatarCyrille Pitchen <cyrille.pitchen@atmel.com>
    Acked-by: default avatarLudovic Desroches <ludovic.desroches@atmel.com>
    Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
    0ef6f321
i2c-at91.c 27.9 KB