| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | SMBus Protocol Summary | 
 | 2 | ====================== | 
| David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 3 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | The following is a summary of the SMBus protocol. It applies to | 
 | 5 | all revisions of the protocol (1.0, 1.1, and 2.0). | 
 | 6 | Certain protocol features which are not supported by | 
 | 7 | this package are briefly described at the end of this document. | 
 | 8 |  | 
 | 9 | Some adapters understand only the SMBus (System Management Bus) protocol, | 
 | 10 | which is a subset from the I2C protocol. Fortunately, many devices use | 
 | 11 | only the same subset, which makes it possible to put them on an SMBus. | 
| David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 12 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | If you write a driver for some I2C device, please try to use the SMBus | 
 | 14 | commands if at all possible (if the device uses only that subset of the | 
 | 15 | I2C protocol). This makes it possible to use the device driver on both | 
 | 16 | SMBus adapters and I2C adapters (the SMBus command set is automatically | 
 | 17 | translated to I2C on I2C adapters, but plain I2C commands can not be | 
 | 18 | handled at all on most pure SMBus adapters). | 
 | 19 |  | 
| David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 20 | Below is a list of SMBus protocol operations, and the functions executing | 
 | 21 | them.  Note that the names used in the SMBus protocol specifications usually | 
 | 22 | don't match these function names.  For some of the operations which pass a | 
 | 23 | single data byte, the functions using SMBus protocol operation names execute | 
 | 24 | a different protocol operation entirely. | 
 | 25 |  | 
| Jean Delvare | a168178 | 2012-12-16 21:11:55 +0100 | [diff] [blame] | 26 | Each transaction type corresponds to a functionality flag. Before calling a | 
 | 27 | transaction function, a device driver should always check (just once) for | 
 | 28 | the corresponding functionality flag to ensure that the underlying I2C | 
 | 29 | adapter supports the transaction in question. See | 
 | 30 | <file:Documentation/i2c/functionality> for the details. | 
 | 31 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 |  | 
 | 33 | Key to symbols | 
 | 34 | ============== | 
 | 35 |  | 
 | 36 | S     (1 bit) : Start bit | 
 | 37 | P     (1 bit) : Stop bit | 
 | 38 | Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0. | 
 | 39 | A, NA (1 bit) : Accept and reverse accept bit.  | 
 | 40 | Addr  (7 bits): I2C 7 bit address. Note that this can be expanded as usual to  | 
 | 41 |                 get a 10 bit I2C address. | 
 | 42 | Comm  (8 bits): Command byte, a data byte which often selects a register on | 
 | 43 |                 the device. | 
 | 44 | Data  (8 bits): A plain data byte. Sometimes, I write DataLow, DataHigh | 
 | 45 |                 for 16 bit data. | 
 | 46 | Count (8 bits): A data byte containing the length of a block operation. | 
 | 47 |  | 
 | 48 | [..]: Data sent by I2C device, as opposed to data sent by the host adapter. | 
 | 49 |  | 
 | 50 |  | 
| Jean Delvare | 67c2e66 | 2008-07-14 22:38:23 +0200 | [diff] [blame] | 51 | SMBus Quick Command | 
 | 52 | =================== | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 |  | 
 | 54 | This sends a single bit to the device, at the place of the Rd/Wr bit. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 |  | 
 | 56 | A Addr Rd/Wr [A] P | 
 | 57 |  | 
| Jean Delvare | a168178 | 2012-12-16 21:11:55 +0100 | [diff] [blame] | 58 | Functionality flag: I2C_FUNC_SMBUS_QUICK | 
 | 59 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 |  | 
| David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 61 | SMBus Receive Byte:  i2c_smbus_read_byte() | 
 | 62 | ========================================== | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 |  | 
 | 64 | This reads a single byte from a device, without specifying a device | 
 | 65 | register. Some devices are so simple that this interface is enough; for | 
 | 66 | others, it is a shorthand if you want to read the same register as in | 
 | 67 | the previous SMBus command. | 
 | 68 |  | 
 | 69 | S Addr Rd [A] [Data] NA P | 
 | 70 |  | 
| Jean Delvare | a168178 | 2012-12-16 21:11:55 +0100 | [diff] [blame] | 71 | Functionality flag: I2C_FUNC_SMBUS_READ_BYTE | 
 | 72 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 |  | 
| David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 74 | SMBus Send Byte:  i2c_smbus_write_byte() | 
 | 75 | ======================================== | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 |  | 
| David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 77 | This operation is the reverse of Receive Byte: it sends a single byte | 
 | 78 | to a device.  See Receive Byte for more information. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 |  | 
 | 80 | S Addr Wr [A] Data [A] P | 
 | 81 |  | 
| Jean Delvare | a168178 | 2012-12-16 21:11:55 +0100 | [diff] [blame] | 82 | Functionality flag: I2C_FUNC_SMBUS_WRITE_BYTE | 
 | 83 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 |  | 
| David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 85 | SMBus Read Byte:  i2c_smbus_read_byte_data() | 
 | 86 | ============================================ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 |  | 
 | 88 | This reads a single byte from a device, from a designated register. | 
 | 89 | The register is specified through the Comm byte. | 
 | 90 |  | 
 | 91 | S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P | 
 | 92 |  | 
| Jean Delvare | a168178 | 2012-12-16 21:11:55 +0100 | [diff] [blame] | 93 | Functionality flag: I2C_FUNC_SMBUS_READ_BYTE_DATA | 
 | 94 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 |  | 
| David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 96 | SMBus Read Word:  i2c_smbus_read_word_data() | 
 | 97 | ============================================ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 |  | 
| David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 99 | This operation is very like Read Byte; again, data is read from a | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | device, from a designated register that is specified through the Comm | 
 | 101 | byte. But this time, the data is a complete word (16 bits). | 
 | 102 |  | 
 | 103 | S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P | 
 | 104 |  | 
| Jean Delvare | a168178 | 2012-12-16 21:11:55 +0100 | [diff] [blame] | 105 | Functionality flag: I2C_FUNC_SMBUS_READ_WORD_DATA | 
 | 106 |  | 
| Jonathan Cameron | 06a6784 | 2011-10-30 13:47:25 +0100 | [diff] [blame] | 107 | Note the convenience function i2c_smbus_read_word_swapped is | 
 | 108 | available for reads where the two data bytes are the other way | 
 | 109 | around (not SMBus compliant, but very popular.) | 
 | 110 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 |  | 
| David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 112 | SMBus Write Byte:  i2c_smbus_write_byte_data() | 
 | 113 | ============================================== | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 |  | 
 | 115 | This writes a single byte to a device, to a designated register. The | 
 | 116 | register is specified through the Comm byte. This is the opposite of | 
| David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 117 | the Read Byte operation. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 |  | 
 | 119 | S Addr Wr [A] Comm [A] Data [A] P | 
 | 120 |  | 
| Jean Delvare | a168178 | 2012-12-16 21:11:55 +0100 | [diff] [blame] | 121 | Functionality flag: I2C_FUNC_SMBUS_WRITE_BYTE_DATA | 
 | 122 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 |  | 
| David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 124 | SMBus Write Word:  i2c_smbus_write_word_data() | 
 | 125 | ============================================== | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 |  | 
| David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 127 | This is the opposite of the Read Word operation. 16 bits | 
| Mike Frysinger | 3f9a479 | 2007-02-13 22:08:59 +0100 | [diff] [blame] | 128 | of data is written to a device, to the designated register that is | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | specified through the Comm byte.  | 
 | 130 |  | 
 | 131 | S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P | 
 | 132 |  | 
| Jean Delvare | a168178 | 2012-12-16 21:11:55 +0100 | [diff] [blame] | 133 | Functionality flag: I2C_FUNC_SMBUS_WRITE_WORD_DATA | 
 | 134 |  | 
| Jonathan Cameron | 06a6784 | 2011-10-30 13:47:25 +0100 | [diff] [blame] | 135 | Note the convenience function i2c_smbus_write_word_swapped is | 
 | 136 | available for writes where the two data bytes are the other way | 
 | 137 | around (not SMBus compliant, but very popular.) | 
 | 138 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 |  | 
| Tushar Behera | c811093 | 2012-11-19 16:31:42 +0530 | [diff] [blame] | 140 | SMBus Process Call: | 
 | 141 | =================== | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 |  | 
 | 143 | This command selects a device register (through the Comm byte), sends | 
 | 144 | 16 bits of data to it, and reads 16 bits of data in return. | 
 | 145 |  | 
 | 146 | S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A]  | 
 | 147 |                              S Addr Rd [A] [DataLow] A [DataHigh] NA P | 
 | 148 |  | 
| Jean Delvare | a168178 | 2012-12-16 21:11:55 +0100 | [diff] [blame] | 149 | Functionality flag: I2C_FUNC_SMBUS_PROC_CALL | 
 | 150 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 |  | 
| David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 152 | SMBus Block Read:  i2c_smbus_read_block_data() | 
 | 153 | ============================================== | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 |  | 
 | 155 | This command reads a block of up to 32 bytes from a device, from a  | 
 | 156 | designated register that is specified through the Comm byte. The amount | 
 | 157 | of data is specified by the device in the Count byte. | 
 | 158 |  | 
 | 159 | S Addr Wr [A] Comm [A]  | 
 | 160 |            S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P | 
 | 161 |  | 
| Jean Delvare | a168178 | 2012-12-16 21:11:55 +0100 | [diff] [blame] | 162 | Functionality flag: I2C_FUNC_SMBUS_READ_BLOCK_DATA | 
 | 163 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 |  | 
| David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 165 | SMBus Block Write:  i2c_smbus_write_block_data() | 
 | 166 | ================================================ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 |  | 
 | 168 | The opposite of the Block Read command, this writes up to 32 bytes to  | 
 | 169 | a device, to a designated register that is specified through the | 
 | 170 | Comm byte. The amount of data is specified in the Count byte. | 
 | 171 |  | 
 | 172 | S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P | 
 | 173 |  | 
| Jean Delvare | a168178 | 2012-12-16 21:11:55 +0100 | [diff] [blame] | 174 | Functionality flag: I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | 
 | 175 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 |  | 
| David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 177 | SMBus Block Write - Block Read Process Call | 
 | 178 | =========================================== | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 |  | 
| David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 180 | SMBus Block Write - Block Read Process Call was introduced in | 
 | 181 | Revision 2.0 of the specification. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 |  | 
 | 183 | This command selects a device register (through the Comm byte), sends | 
 | 184 | 1 to 31 bytes of data to it, and reads 1 to 31 bytes of data in return. | 
 | 185 |  | 
 | 186 | S Addr Wr [A] Comm [A] Count [A] Data [A] ... | 
 | 187 |                              S Addr Rd [A] [Count] A [Data] ... A P | 
 | 188 |  | 
| Jean Delvare | a168178 | 2012-12-16 21:11:55 +0100 | [diff] [blame] | 189 | Functionality flag: I2C_FUNC_SMBUS_BLOCK_PROC_CALL | 
 | 190 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 |  | 
 | 192 | SMBus Host Notify | 
 | 193 | ================= | 
 | 194 |  | 
 | 195 | This command is sent from a SMBus device acting as a master to the | 
 | 196 | SMBus host acting as a slave. | 
 | 197 | It is the same form as Write Word, with the command code replaced by the | 
 | 198 | alerting device's address. | 
 | 199 |  | 
 | 200 | [S] [HostAddr] [Wr] A [DevAddr] A [DataLow] A [DataHigh] A [P] | 
 | 201 |  | 
 | 202 |  | 
 | 203 | Packet Error Checking (PEC) | 
 | 204 | =========================== | 
| David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 205 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | Packet Error Checking was introduced in Revision 1.1 of the specification. | 
 | 207 |  | 
| David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 208 | PEC adds a CRC-8 error-checking byte to transfers using it, immediately | 
 | 209 | before the terminating STOP. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 |  | 
 | 211 |  | 
 | 212 | Address Resolution Protocol (ARP) | 
 | 213 | ================================= | 
| David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 214 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | The Address Resolution Protocol was introduced in Revision 2.0 of | 
 | 216 | the specification. It is a higher-layer protocol which uses the | 
 | 217 | messages above. | 
 | 218 |  | 
 | 219 | ARP adds device enumeration and dynamic address assignment to | 
 | 220 | the protocol. All ARP communications use slave address 0x61 and | 
 | 221 | require PEC checksums. | 
 | 222 |  | 
 | 223 |  | 
| Jean Delvare | b5527a7 | 2010-03-02 12:23:42 +0100 | [diff] [blame] | 224 | SMBus Alert | 
 | 225 | =========== | 
 | 226 |  | 
 | 227 | SMBus Alert was introduced in Revision 1.0 of the specification. | 
 | 228 |  | 
 | 229 | The SMBus alert protocol allows several SMBus slave devices to share a | 
 | 230 | single interrupt pin on the SMBus master, while still allowing the master | 
 | 231 | to know which slave triggered the interrupt. | 
 | 232 |  | 
 | 233 | This is implemented the following way in the Linux kernel: | 
 | 234 | * I2C bus drivers which support SMBus alert should call | 
 | 235 |   i2c_setup_smbus_alert() to setup SMBus alert support. | 
 | 236 | * I2C drivers for devices which can trigger SMBus alerts should implement | 
 | 237 |   the optional alert() callback. | 
 | 238 |  | 
 | 239 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | I2C Block Transactions | 
 | 241 | ====================== | 
| David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 242 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | The following I2C block transactions are supported by the | 
 | 244 | SMBus layer and are described here for completeness. | 
| David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 245 | They are *NOT* defined by the SMBus specification. | 
 | 246 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | I2C block transactions do not limit the number of bytes transferred | 
 | 248 | but the SMBus layer places a limit of 32 bytes. | 
 | 249 |  | 
 | 250 |  | 
| David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 251 | I2C Block Read:  i2c_smbus_read_i2c_block_data() | 
 | 252 | ================================================ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 |  | 
 | 254 | This command reads a block of bytes from a device, from a  | 
 | 255 | designated register that is specified through the Comm byte. | 
 | 256 |  | 
 | 257 | S Addr Wr [A] Comm [A]  | 
 | 258 |            S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P | 
 | 259 |  | 
| Jean Delvare | a168178 | 2012-12-16 21:11:55 +0100 | [diff] [blame] | 260 | Functionality flag: I2C_FUNC_SMBUS_READ_I2C_BLOCK | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 |  | 
 | 262 |  | 
| David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 263 | I2C Block Write:  i2c_smbus_write_i2c_block_data() | 
 | 264 | ================================================== | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 |  | 
 | 266 | The opposite of the Block Read command, this writes bytes to  | 
 | 267 | a device, to a designated register that is specified through the | 
 | 268 | Comm byte. Note that command lengths of 0, 2, or more bytes are | 
 | 269 | supported as they are indistinguishable from data. | 
 | 270 |  | 
 | 271 | S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P | 
| Jean Delvare | a168178 | 2012-12-16 21:11:55 +0100 | [diff] [blame] | 272 |  | 
 | 273 | Functionality flag: I2C_FUNC_SMBUS_WRITE_I2C_BLOCK |