smbus-protocol 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. SMBus Protocol Summary
  2. ======================
  3. The following is a summary of the SMBus protocol. It applies to
  4. all revisions of the protocol (1.0, 1.1, and 2.0).
  5. Certain protocol features which are not supported by
  6. this package are briefly described at the end of this document.
  7. Some adapters understand only the SMBus (System Management Bus) protocol,
  8. which is a subset from the I2C protocol. Fortunately, many devices use
  9. only the same subset, which makes it possible to put them on an SMBus.
  10. If you write a driver for some I2C device, please try to use the SMBus
  11. commands if at all possible (if the device uses only that subset of the
  12. I2C protocol). This makes it possible to use the device driver on both
  13. SMBus adapters and I2C adapters (the SMBus command set is automatically
  14. translated to I2C on I2C adapters, but plain I2C commands can not be
  15. handled at all on most pure SMBus adapters).
  16. Below is a list of SMBus protocol operations, and the functions executing
  17. them. Note that the names used in the SMBus protocol specifications usually
  18. don't match these function names. For some of the operations which pass a
  19. single data byte, the functions using SMBus protocol operation names execute
  20. a different protocol operation entirely.
  21. Each transaction type corresponds to a functionality flag. Before calling a
  22. transaction function, a device driver should always check (just once) for
  23. the corresponding functionality flag to ensure that the underlying I2C
  24. adapter supports the transaction in question. See
  25. <file:Documentation/i2c/functionality> for the details.
  26. Key to symbols
  27. ==============
  28. S (1 bit) : Start bit
  29. P (1 bit) : Stop bit
  30. Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0.
  31. A, NA (1 bit) : Accept and reverse accept bit.
  32. Addr (7 bits): I2C 7 bit address. Note that this can be expanded as usual to
  33. get a 10 bit I2C address.
  34. Comm (8 bits): Command byte, a data byte which often selects a register on
  35. the device.
  36. Data (8 bits): A plain data byte. Sometimes, I write DataLow, DataHigh
  37. for 16 bit data.
  38. Count (8 bits): A data byte containing the length of a block operation.
  39. [..]: Data sent by I2C device, as opposed to data sent by the host adapter.
  40. SMBus Quick Command
  41. ===================
  42. This sends a single bit to the device, at the place of the Rd/Wr bit.
  43. A Addr Rd/Wr [A] P
  44. Functionality flag: I2C_FUNC_SMBUS_QUICK
  45. SMBus Receive Byte: i2c_smbus_read_byte()
  46. ==========================================
  47. This reads a single byte from a device, without specifying a device
  48. register. Some devices are so simple that this interface is enough; for
  49. others, it is a shorthand if you want to read the same register as in
  50. the previous SMBus command.
  51. S Addr Rd [A] [Data] NA P
  52. Functionality flag: I2C_FUNC_SMBUS_READ_BYTE
  53. SMBus Send Byte: i2c_smbus_write_byte()
  54. ========================================
  55. This operation is the reverse of Receive Byte: it sends a single byte
  56. to a device. See Receive Byte for more information.
  57. S Addr Wr [A] Data [A] P
  58. Functionality flag: I2C_FUNC_SMBUS_WRITE_BYTE
  59. SMBus Read Byte: i2c_smbus_read_byte_data()
  60. ============================================
  61. This reads a single byte from a device, from a designated register.
  62. The register is specified through the Comm byte.
  63. S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P
  64. Functionality flag: I2C_FUNC_SMBUS_READ_BYTE_DATA
  65. SMBus Read Word: i2c_smbus_read_word_data()
  66. ============================================
  67. This operation is very like Read Byte; again, data is read from a
  68. device, from a designated register that is specified through the Comm
  69. byte. But this time, the data is a complete word (16 bits).
  70. S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P
  71. Functionality flag: I2C_FUNC_SMBUS_READ_WORD_DATA
  72. Note the convenience function i2c_smbus_read_word_swapped is
  73. available for reads where the two data bytes are the other way
  74. around (not SMBus compliant, but very popular.)
  75. SMBus Write Byte: i2c_smbus_write_byte_data()
  76. ==============================================
  77. This writes a single byte to a device, to a designated register. The
  78. register is specified through the Comm byte. This is the opposite of
  79. the Read Byte operation.
  80. S Addr Wr [A] Comm [A] Data [A] P
  81. Functionality flag: I2C_FUNC_SMBUS_WRITE_BYTE_DATA
  82. SMBus Write Word: i2c_smbus_write_word_data()
  83. ==============================================
  84. This is the opposite of the Read Word operation. 16 bits
  85. of data is written to a device, to the designated register that is
  86. specified through the Comm byte.
  87. S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P
  88. Functionality flag: I2C_FUNC_SMBUS_WRITE_WORD_DATA
  89. Note the convenience function i2c_smbus_write_word_swapped is
  90. available for writes where the two data bytes are the other way
  91. around (not SMBus compliant, but very popular.)
  92. SMBus Process Call:
  93. ===================
  94. This command selects a device register (through the Comm byte), sends
  95. 16 bits of data to it, and reads 16 bits of data in return.
  96. S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A]
  97. S Addr Rd [A] [DataLow] A [DataHigh] NA P
  98. Functionality flag: I2C_FUNC_SMBUS_PROC_CALL
  99. SMBus Block Read: i2c_smbus_read_block_data()
  100. ==============================================
  101. This command reads a block of up to 32 bytes from a device, from a
  102. designated register that is specified through the Comm byte. The amount
  103. of data is specified by the device in the Count byte.
  104. S Addr Wr [A] Comm [A]
  105. S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P
  106. Functionality flag: I2C_FUNC_SMBUS_READ_BLOCK_DATA
  107. SMBus Block Write: i2c_smbus_write_block_data()
  108. ================================================
  109. The opposite of the Block Read command, this writes up to 32 bytes to
  110. a device, to a designated register that is specified through the
  111. Comm byte. The amount of data is specified in the Count byte.
  112. S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P
  113. Functionality flag: I2C_FUNC_SMBUS_WRITE_BLOCK_DATA
  114. SMBus Block Write - Block Read Process Call
  115. ===========================================
  116. SMBus Block Write - Block Read Process Call was introduced in
  117. Revision 2.0 of the specification.
  118. This command selects a device register (through the Comm byte), sends
  119. 1 to 31 bytes of data to it, and reads 1 to 31 bytes of data in return.
  120. S Addr Wr [A] Comm [A] Count [A] Data [A] ...
  121. S Addr Rd [A] [Count] A [Data] ... A P
  122. Functionality flag: I2C_FUNC_SMBUS_BLOCK_PROC_CALL
  123. SMBus Host Notify
  124. =================
  125. This command is sent from a SMBus device acting as a master to the
  126. SMBus host acting as a slave.
  127. It is the same form as Write Word, with the command code replaced by the
  128. alerting device's address.
  129. [S] [HostAddr] [Wr] A [DevAddr] A [DataLow] A [DataHigh] A [P]
  130. Packet Error Checking (PEC)
  131. ===========================
  132. Packet Error Checking was introduced in Revision 1.1 of the specification.
  133. PEC adds a CRC-8 error-checking byte to transfers using it, immediately
  134. before the terminating STOP.
  135. Address Resolution Protocol (ARP)
  136. =================================
  137. The Address Resolution Protocol was introduced in Revision 2.0 of
  138. the specification. It is a higher-layer protocol which uses the
  139. messages above.
  140. ARP adds device enumeration and dynamic address assignment to
  141. the protocol. All ARP communications use slave address 0x61 and
  142. require PEC checksums.
  143. SMBus Alert
  144. ===========
  145. SMBus Alert was introduced in Revision 1.0 of the specification.
  146. The SMBus alert protocol allows several SMBus slave devices to share a
  147. single interrupt pin on the SMBus master, while still allowing the master
  148. to know which slave triggered the interrupt.
  149. This is implemented the following way in the Linux kernel:
  150. * I2C bus drivers which support SMBus alert should call
  151. i2c_setup_smbus_alert() to setup SMBus alert support.
  152. * I2C drivers for devices which can trigger SMBus alerts should implement
  153. the optional alert() callback.
  154. I2C Block Transactions
  155. ======================
  156. The following I2C block transactions are supported by the
  157. SMBus layer and are described here for completeness.
  158. They are *NOT* defined by the SMBus specification.
  159. I2C block transactions do not limit the number of bytes transferred
  160. but the SMBus layer places a limit of 32 bytes.
  161. I2C Block Read: i2c_smbus_read_i2c_block_data()
  162. ================================================
  163. This command reads a block of bytes from a device, from a
  164. designated register that is specified through the Comm byte.
  165. S Addr Wr [A] Comm [A]
  166. S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P
  167. Functionality flag: I2C_FUNC_SMBUS_READ_I2C_BLOCK
  168. I2C Block Write: i2c_smbus_write_i2c_block_data()
  169. ==================================================
  170. The opposite of the Block Read command, this writes bytes to
  171. a device, to a designated register that is specified through the
  172. Comm byte. Note that command lengths of 0, 2, or more bytes are
  173. supported as they are indistinguishable from data.
  174. S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P
  175. Functionality flag: I2C_FUNC_SMBUS_WRITE_I2C_BLOCK