f2fs: Provide a splice-read wrapper
[linux-block.git] / Documentation / i2c / i2c-protocol.rst
CommitLineData
f6fcefa1
LC
1================
2The I2C Protocol
3================
ccf988b6 4
9bbebdf7
LC
5This document is an overview of the basic I2C transactions and the kernel
6APIs to perform them.
1da177e4
LT
7
8Key to symbols
9==============
10
ccf988b6 11=============== =============================================================
02622c88
LC
12S Start condition
13P Stop condition
14Rd/Wr (1 bit) Read/Write bit. Rd equals 1, Wr equals 0.
db0d7424 15A, NA (1 bit) Acknowledge (ACK) and Not Acknowledge (NACK) bit
24d129d4 16Addr (7 bits) I2C 7 bit address. Note that this can be expanded to
1da177e4 17 get a 10 bit I2C address.
0721ceee 18Data (8 bits) A plain data byte.
1da177e4 19
02622c88 20[..] Data sent by I2C device, as opposed to data sent by the
ccf988b6
MCC
21 host adapter.
22=============== =============================================================
1da177e4
LT
23
24
25Simple send transaction
ccf988b6 26=======================
1da177e4 27
ca5dbb02 28Implemented by i2c_master_send()::
1da177e4
LT
29
30 S Addr Wr [A] Data [A] Data [A] ... [A] Data [A] P
31
32
33Simple receive transaction
ccf988b6 34==========================
1da177e4 35
ca5dbb02 36Implemented by i2c_master_recv()::
1da177e4
LT
37
38 S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P
39
40
41Combined transactions
ccf988b6 42=====================
1da177e4 43
ca5dbb02 44Implemented by i2c_transfer().
1da177e4 45
f954731d
LC
46They are just like the above transactions, but instead of a stop
47condition P a start condition S is sent and the transaction continues.
48An example of a byte read, followed by a byte write::
1da177e4
LT
49
50 S Addr Rd [A] [Data] NA S Addr Wr [A] Data [A] P
51
52
53Modified transactions
54=====================
55
9f02fba8 56The following modifications to the I2C protocol can also be generated by
2f07c05f 57setting these flags for I2C messages. With the exception of I2C_M_NOSTART, they
9f02fba8 58are usually only needed to work around device issues:
1da177e4 59
9f02fba8
WS
60I2C_M_IGNORE_NAK:
61 Normally message is interrupted immediately if there is [NA] from the
62 client. Setting this flag treats any [NA] as [A], and all of
63 message is sent.
64 These messages may still fail to SCL lo->hi timeout.
65
66I2C_M_NO_RD_ACK:
67 In a read message, master A/NA bit is skipped.
68
69I2C_M_NOSTART:
1da177e4
LT
70 In a combined transaction, no 'S Addr Wr/Rd [A]' is generated at some
71 point. For example, setting I2C_M_NOSTART on the second partial message
ccf988b6
MCC
72 generates something like::
73
1da177e4 74 S Addr Rd [A] [Data] NA Data [A] P
ccf988b6 75
1da177e4 76 If you set the I2C_M_NOSTART variable for the first partial message,
f954731d
LC
77 we do not generate Addr, but we do generate the start condition S.
78 This will probably confuse all other clients on your bus, so don't
79 try this.
1da177e4 80
14674e70
MB
81 This is often used to gather transmits from multiple data buffers in
82 system memory into something that appears as a single transfer to the
83 I2C device but may also be used between direction changes by some
84 rare devices.
85
9f02fba8 86I2C_M_REV_DIR_ADDR:
1da177e4
LT
87 This toggles the Rd/Wr flag. That is, if you want to do a write, but
88 need to emit an Rd instead of a Wr, or vice versa, you set this
ccf988b6
MCC
89 flag. For example::
90
1da177e4
LT
91 S Addr Rd [A] Data [A] Data [A] ... [A] Data [A] P
92
9f02fba8
WS
93I2C_M_STOP:
94 Force a stop condition (P) after the message. Some I2C related protocols
95 like SCCB require that. Normally, you really don't want to get interrupted
96 between the messages of one transfer.