0001 ================
0002 The I2C Protocol
0003 ================
0004
0005 This document is an overview of the basic I2C transactions and the kernel
0006 APIs to perform them.
0007
0008 Key to symbols
0009 ==============
0010
0011 =============== =============================================================
0012 S Start condition
0013 P Stop condition
0014 Rd/Wr (1 bit) Read/Write bit. Rd equals 1, Wr equals 0.
0015 A, NA (1 bit) Acknowledge (ACK) and Not Acknowledge (NACK) bit
0016 Addr (7 bits) I2C 7 bit address. Note that this can be expanded to
0017 get a 10 bit I2C address.
0018 Data (8 bits) A plain data byte.
0019
0020 [..] Data sent by I2C device, as opposed to data sent by the
0021 host adapter.
0022 =============== =============================================================
0023
0024
0025 Simple send transaction
0026 =======================
0027
0028 Implemented by i2c_master_send()::
0029
0030 S Addr Wr [A] Data [A] Data [A] ... [A] Data [A] P
0031
0032
0033 Simple receive transaction
0034 ==========================
0035
0036 Implemented by i2c_master_recv()::
0037
0038 S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P
0039
0040
0041 Combined transactions
0042 =====================
0043
0044 Implemented by i2c_transfer().
0045
0046 They are just like the above transactions, but instead of a stop
0047 condition P a start condition S is sent and the transaction continues.
0048 An example of a byte read, followed by a byte write::
0049
0050 S Addr Rd [A] [Data] NA S Addr Wr [A] Data [A] P
0051
0052
0053 Modified transactions
0054 =====================
0055
0056 The following modifications to the I2C protocol can also be generated by
0057 setting these flags for I2C messages. With the exception of I2C_M_NOSTART, they
0058 are usually only needed to work around device issues:
0059
0060 I2C_M_IGNORE_NAK:
0061 Normally message is interrupted immediately if there is [NA] from the
0062 client. Setting this flag treats any [NA] as [A], and all of
0063 message is sent.
0064 These messages may still fail to SCL lo->hi timeout.
0065
0066 I2C_M_NO_RD_ACK:
0067 In a read message, master A/NA bit is skipped.
0068
0069 I2C_M_NOSTART:
0070 In a combined transaction, no 'S Addr Wr/Rd [A]' is generated at some
0071 point. For example, setting I2C_M_NOSTART on the second partial message
0072 generates something like::
0073
0074 S Addr Rd [A] [Data] NA Data [A] P
0075
0076 If you set the I2C_M_NOSTART variable for the first partial message,
0077 we do not generate Addr, but we do generate the start condition S.
0078 This will probably confuse all other clients on your bus, so don't
0079 try this.
0080
0081 This is often used to gather transmits from multiple data buffers in
0082 system memory into something that appears as a single transfer to the
0083 I2C device but may also be used between direction changes by some
0084 rare devices.
0085
0086 I2C_M_REV_DIR_ADDR:
0087 This toggles the Rd/Wr flag. That is, if you want to do a write, but
0088 need to emit an Rd instead of a Wr, or vice versa, you set this
0089 flag. For example::
0090
0091 S Addr Rd [A] Data [A] Data [A] ... [A] Data [A] P
0092
0093 I2C_M_STOP:
0094 Force a stop condition (P) after the message. Some I2C related protocols
0095 like SCCB require that. Normally, you really don't want to get interrupted
0096 between the messages of one transfer.