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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | |
| 27 | Key to symbols |
| 28 | ============== |
| 29 | |
| 30 | S (1 bit) : Start bit |
| 31 | P (1 bit) : Stop bit |
| 32 | Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0. |
| 33 | A, NA (1 bit) : Accept and reverse accept bit. |
| 34 | Addr (7 bits): I2C 7 bit address. Note that this can be expanded as usual to |
| 35 | get a 10 bit I2C address. |
| 36 | Comm (8 bits): Command byte, a data byte which often selects a register on |
| 37 | the device. |
| 38 | Data (8 bits): A plain data byte. Sometimes, I write DataLow, DataHigh |
| 39 | for 16 bit data. |
| 40 | Count (8 bits): A data byte containing the length of a block operation. |
| 41 | |
| 42 | [..]: Data sent by I2C device, as opposed to data sent by the host adapter. |
| 43 | |
| 44 | |
Jean Delvare | 67c2e66 | 2008-07-14 22:38:23 +0200 | [diff] [blame] | 45 | SMBus Quick Command |
| 46 | =================== |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
| 48 | 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] | 49 | |
| 50 | A Addr Rd/Wr [A] P |
| 51 | |
| 52 | |
David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 53 | SMBus Receive Byte: i2c_smbus_read_byte() |
| 54 | ========================================== |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | |
| 56 | This reads a single byte from a device, without specifying a device |
| 57 | register. Some devices are so simple that this interface is enough; for |
| 58 | others, it is a shorthand if you want to read the same register as in |
| 59 | the previous SMBus command. |
| 60 | |
| 61 | S Addr Rd [A] [Data] NA P |
| 62 | |
| 63 | |
David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 64 | SMBus Send Byte: i2c_smbus_write_byte() |
| 65 | ======================================== |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | |
David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 67 | This operation is the reverse of Receive Byte: it sends a single byte |
| 68 | to a device. See Receive Byte for more information. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
| 70 | S Addr Wr [A] Data [A] P |
| 71 | |
| 72 | |
David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 73 | SMBus Read Byte: i2c_smbus_read_byte_data() |
| 74 | ============================================ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | |
| 76 | This reads a single byte from a device, from a designated register. |
| 77 | The register is specified through the Comm byte. |
| 78 | |
| 79 | S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P |
| 80 | |
| 81 | |
David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 82 | SMBus Read Word: i2c_smbus_read_word_data() |
| 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 | 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] | 86 | device, from a designated register that is specified through the Comm |
| 87 | byte. But this time, the data is a complete word (16 bits). |
| 88 | |
| 89 | S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P |
| 90 | |
| 91 | |
David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 92 | SMBus Write Byte: i2c_smbus_write_byte_data() |
| 93 | ============================================== |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | |
| 95 | This writes a single byte to a device, to a designated register. The |
| 96 | register is specified through the Comm byte. This is the opposite of |
David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 97 | the Read Byte operation. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | |
| 99 | S Addr Wr [A] Comm [A] Data [A] P |
| 100 | |
| 101 | |
David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 102 | SMBus Write Word: i2c_smbus_write_word_data() |
| 103 | ============================================== |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | |
David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 105 | This is the opposite of the Read Word operation. 16 bits |
Mike Frysinger | 3f9a479 | 2007-02-13 22:08:59 +0100 | [diff] [blame] | 106 | 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] | 107 | specified through the Comm byte. |
| 108 | |
| 109 | S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P |
| 110 | |
| 111 | |
Prakash Mortha | 596c88f | 2008-10-14 17:30:06 +0200 | [diff] [blame] | 112 | SMBus Process Call: i2c_smbus_process_call() |
| 113 | ============================================= |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | |
| 115 | This command selects a device register (through the Comm byte), sends |
| 116 | 16 bits of data to it, and reads 16 bits of data in return. |
| 117 | |
| 118 | S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] |
| 119 | S Addr Rd [A] [DataLow] A [DataHigh] NA P |
| 120 | |
| 121 | |
David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 122 | SMBus Block Read: i2c_smbus_read_block_data() |
| 123 | ============================================== |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | |
| 125 | This command reads a block of up to 32 bytes from a device, from a |
| 126 | designated register that is specified through the Comm byte. The amount |
| 127 | of data is specified by the device in the Count byte. |
| 128 | |
| 129 | S Addr Wr [A] Comm [A] |
| 130 | S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P |
| 131 | |
| 132 | |
David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 133 | SMBus Block Write: i2c_smbus_write_block_data() |
| 134 | ================================================ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | |
| 136 | The opposite of the Block Read command, this writes up to 32 bytes to |
| 137 | a device, to a designated register that is specified through the |
| 138 | Comm byte. The amount of data is specified in the Count byte. |
| 139 | |
| 140 | S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P |
| 141 | |
| 142 | |
David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 143 | SMBus Block Write - Block Read Process Call |
| 144 | =========================================== |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | |
David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 146 | SMBus Block Write - Block Read Process Call was introduced in |
| 147 | Revision 2.0 of the specification. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | |
| 149 | This command selects a device register (through the Comm byte), sends |
| 150 | 1 to 31 bytes of data to it, and reads 1 to 31 bytes of data in return. |
| 151 | |
| 152 | S Addr Wr [A] Comm [A] Count [A] Data [A] ... |
| 153 | S Addr Rd [A] [Count] A [Data] ... A P |
| 154 | |
| 155 | |
| 156 | SMBus Host Notify |
| 157 | ================= |
| 158 | |
| 159 | This command is sent from a SMBus device acting as a master to the |
| 160 | SMBus host acting as a slave. |
| 161 | It is the same form as Write Word, with the command code replaced by the |
| 162 | alerting device's address. |
| 163 | |
| 164 | [S] [HostAddr] [Wr] A [DevAddr] A [DataLow] A [DataHigh] A [P] |
| 165 | |
| 166 | |
| 167 | Packet Error Checking (PEC) |
| 168 | =========================== |
David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 169 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | Packet Error Checking was introduced in Revision 1.1 of the specification. |
| 171 | |
David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 172 | PEC adds a CRC-8 error-checking byte to transfers using it, immediately |
| 173 | before the terminating STOP. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | |
| 175 | |
| 176 | Address Resolution Protocol (ARP) |
| 177 | ================================= |
David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 178 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | The Address Resolution Protocol was introduced in Revision 2.0 of |
| 180 | the specification. It is a higher-layer protocol which uses the |
| 181 | messages above. |
| 182 | |
| 183 | ARP adds device enumeration and dynamic address assignment to |
| 184 | the protocol. All ARP communications use slave address 0x61 and |
| 185 | require PEC checksums. |
| 186 | |
| 187 | |
Jean Delvare | b5527a7 | 2010-03-02 12:23:42 +0100 | [diff] [blame] | 188 | SMBus Alert |
| 189 | =========== |
| 190 | |
| 191 | SMBus Alert was introduced in Revision 1.0 of the specification. |
| 192 | |
| 193 | The SMBus alert protocol allows several SMBus slave devices to share a |
| 194 | single interrupt pin on the SMBus master, while still allowing the master |
| 195 | to know which slave triggered the interrupt. |
| 196 | |
| 197 | This is implemented the following way in the Linux kernel: |
| 198 | * I2C bus drivers which support SMBus alert should call |
| 199 | i2c_setup_smbus_alert() to setup SMBus alert support. |
| 200 | * I2C drivers for devices which can trigger SMBus alerts should implement |
| 201 | the optional alert() callback. |
| 202 | |
| 203 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | I2C Block Transactions |
| 205 | ====================== |
David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 206 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | The following I2C block transactions are supported by the |
| 208 | SMBus layer and are described here for completeness. |
David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 209 | They are *NOT* defined by the SMBus specification. |
| 210 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | I2C block transactions do not limit the number of bytes transferred |
| 212 | but the SMBus layer places a limit of 32 bytes. |
| 213 | |
| 214 | |
David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 215 | I2C Block Read: i2c_smbus_read_i2c_block_data() |
| 216 | ================================================ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | |
| 218 | This command reads a block of bytes from a device, from a |
| 219 | designated register that is specified through the Comm byte. |
| 220 | |
| 221 | S Addr Wr [A] Comm [A] |
| 222 | S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P |
| 223 | |
| 224 | |
| 225 | I2C Block Read (2 Comm bytes) |
| 226 | ============================= |
| 227 | |
| 228 | This command reads a block of bytes from a device, from a |
| 229 | designated register that is specified through the two Comm bytes. |
| 230 | |
| 231 | S Addr Wr [A] Comm1 [A] Comm2 [A] |
| 232 | S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P |
| 233 | |
| 234 | |
David Brownell | 1a31a88 | 2008-05-11 20:37:05 +0200 | [diff] [blame] | 235 | I2C Block Write: i2c_smbus_write_i2c_block_data() |
| 236 | ================================================== |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | |
| 238 | The opposite of the Block Read command, this writes bytes to |
| 239 | a device, to a designated register that is specified through the |
| 240 | Comm byte. Note that command lengths of 0, 2, or more bytes are |
| 241 | supported as they are indistinguishable from data. |
| 242 | |
| 243 | S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P |