2019-07-26 15:51:16 +03:00
|
|
|
======================
|
2005-04-17 02:20:36 +04:00
|
|
|
SMBus Protocol Summary
|
|
|
|
======================
|
2008-05-11 22:37:05 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
The following is a summary of the SMBus protocol. It applies to
|
|
|
|
all revisions of the protocol (1.0, 1.1, and 2.0).
|
|
|
|
Certain protocol features which are not supported by
|
|
|
|
this package are briefly described at the end of this document.
|
|
|
|
|
|
|
|
Some adapters understand only the SMBus (System Management Bus) protocol,
|
|
|
|
which is a subset from the I2C protocol. Fortunately, many devices use
|
|
|
|
only the same subset, which makes it possible to put them on an SMBus.
|
2008-05-11 22:37:05 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
If you write a driver for some I2C device, please try to use the SMBus
|
|
|
|
commands if at all possible (if the device uses only that subset of the
|
|
|
|
I2C protocol). This makes it possible to use the device driver on both
|
|
|
|
SMBus adapters and I2C adapters (the SMBus command set is automatically
|
|
|
|
translated to I2C on I2C adapters, but plain I2C commands can not be
|
|
|
|
handled at all on most pure SMBus adapters).
|
|
|
|
|
2008-05-11 22:37:05 +04:00
|
|
|
Below is a list of SMBus protocol operations, and the functions executing
|
|
|
|
them. Note that the names used in the SMBus protocol specifications usually
|
|
|
|
don't match these function names. For some of the operations which pass a
|
|
|
|
single data byte, the functions using SMBus protocol operation names execute
|
|
|
|
a different protocol operation entirely.
|
|
|
|
|
2012-12-17 00:11:55 +04:00
|
|
|
Each transaction type corresponds to a functionality flag. Before calling a
|
|
|
|
transaction function, a device driver should always check (just once) for
|
|
|
|
the corresponding functionality flag to ensure that the underlying I2C
|
2020-01-29 18:19:36 +03:00
|
|
|
adapter supports the transaction in question. See :doc:`functionality` for
|
|
|
|
the details.
|
2012-12-17 00:11:55 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
Key to symbols
|
|
|
|
==============
|
|
|
|
|
2019-07-26 15:51:16 +03:00
|
|
|
=============== =============================================================
|
2020-01-29 18:19:38 +03:00
|
|
|
S Start condition
|
|
|
|
P Stop condition
|
|
|
|
Rd/Wr (1 bit) Read/Write bit. Rd equals 1, Wr equals 0.
|
|
|
|
A, NA (1 bit) Accept and reverse accept bit.
|
|
|
|
Addr (7 bits) I2C 7 bit address. Note that this can be expanded as usual to
|
2005-04-17 02:20:36 +04:00
|
|
|
get a 10 bit I2C address.
|
2020-01-29 18:19:38 +03:00
|
|
|
Comm (8 bits) Command byte, a data byte which often selects a register on
|
2005-04-17 02:20:36 +04:00
|
|
|
the device.
|
2020-01-29 18:19:38 +03:00
|
|
|
Data (8 bits) A plain data byte. Sometimes, I write DataLow, DataHigh
|
2005-04-17 02:20:36 +04:00
|
|
|
for 16 bit data.
|
2020-01-29 18:19:38 +03:00
|
|
|
Count (8 bits) A data byte containing the length of a block operation.
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2020-01-29 18:19:38 +03:00
|
|
|
[..] Data sent by I2C device, as opposed to data sent by the host
|
2019-07-26 15:51:16 +03:00
|
|
|
adapter.
|
|
|
|
=============== =============================================================
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
|
2008-07-15 00:38:23 +04:00
|
|
|
SMBus Quick Command
|
|
|
|
===================
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2019-07-26 15:51:16 +03:00
|
|
|
This sends a single bit to the device, at the place of the Rd/Wr bit::
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2019-07-26 15:51:16 +03:00
|
|
|
A Addr Rd/Wr [A] P
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-12-17 00:11:55 +04:00
|
|
|
Functionality flag: I2C_FUNC_SMBUS_QUICK
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-05-11 22:37:05 +04:00
|
|
|
SMBus Receive Byte: i2c_smbus_read_byte()
|
|
|
|
==========================================
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
This reads a single byte from a device, without specifying a device
|
|
|
|
register. Some devices are so simple that this interface is enough; for
|
|
|
|
others, it is a shorthand if you want to read the same register as in
|
2019-07-26 15:51:16 +03:00
|
|
|
the previous SMBus command::
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2019-07-26 15:51:16 +03:00
|
|
|
S Addr Rd [A] [Data] NA P
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-12-17 00:11:55 +04:00
|
|
|
Functionality flag: I2C_FUNC_SMBUS_READ_BYTE
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-05-11 22:37:05 +04:00
|
|
|
SMBus Send Byte: i2c_smbus_write_byte()
|
|
|
|
========================================
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-05-11 22:37:05 +04:00
|
|
|
This operation is the reverse of Receive Byte: it sends a single byte
|
|
|
|
to a device. See Receive Byte for more information.
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2019-07-26 15:51:16 +03:00
|
|
|
::
|
|
|
|
|
|
|
|
S Addr Wr [A] Data [A] P
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-12-17 00:11:55 +04:00
|
|
|
Functionality flag: I2C_FUNC_SMBUS_WRITE_BYTE
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-05-11 22:37:05 +04:00
|
|
|
SMBus Read Byte: i2c_smbus_read_byte_data()
|
|
|
|
============================================
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
This reads a single byte from a device, from a designated register.
|
2019-07-26 15:51:16 +03:00
|
|
|
The register is specified through the Comm byte::
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2019-07-26 15:51:16 +03:00
|
|
|
S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-12-17 00:11:55 +04:00
|
|
|
Functionality flag: I2C_FUNC_SMBUS_READ_BYTE_DATA
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-05-11 22:37:05 +04:00
|
|
|
SMBus Read Word: i2c_smbus_read_word_data()
|
|
|
|
============================================
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-05-11 22:37:05 +04:00
|
|
|
This operation is very like Read Byte; again, data is read from a
|
2005-04-17 02:20:36 +04:00
|
|
|
device, from a designated register that is specified through the Comm
|
2019-07-26 15:51:16 +03:00
|
|
|
byte. But this time, the data is a complete word (16 bits)::
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2019-07-26 15:51:16 +03:00
|
|
|
S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-12-17 00:11:55 +04:00
|
|
|
Functionality flag: I2C_FUNC_SMBUS_READ_WORD_DATA
|
|
|
|
|
2011-10-30 16:47:25 +04:00
|
|
|
Note the convenience function i2c_smbus_read_word_swapped is
|
|
|
|
available for reads where the two data bytes are the other way
|
|
|
|
around (not SMBus compliant, but very popular.)
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-05-11 22:37:05 +04:00
|
|
|
SMBus Write Byte: i2c_smbus_write_byte_data()
|
|
|
|
==============================================
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
This writes a single byte to a device, to a designated register. The
|
|
|
|
register is specified through the Comm byte. This is the opposite of
|
2008-05-11 22:37:05 +04:00
|
|
|
the Read Byte operation.
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2019-07-26 15:51:16 +03:00
|
|
|
::
|
|
|
|
|
|
|
|
S Addr Wr [A] Comm [A] Data [A] P
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-12-17 00:11:55 +04:00
|
|
|
Functionality flag: I2C_FUNC_SMBUS_WRITE_BYTE_DATA
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-05-11 22:37:05 +04:00
|
|
|
SMBus Write Word: i2c_smbus_write_word_data()
|
|
|
|
==============================================
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-05-11 22:37:05 +04:00
|
|
|
This is the opposite of the Read Word operation. 16 bits
|
2007-02-14 00:08:59 +03:00
|
|
|
of data is written to a device, to the designated register that is
|
2019-07-26 15:51:16 +03:00
|
|
|
specified through the Comm byte.::
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2019-07-26 15:51:16 +03:00
|
|
|
S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-12-17 00:11:55 +04:00
|
|
|
Functionality flag: I2C_FUNC_SMBUS_WRITE_WORD_DATA
|
|
|
|
|
2011-10-30 16:47:25 +04:00
|
|
|
Note the convenience function i2c_smbus_write_word_swapped is
|
|
|
|
available for writes where the two data bytes are the other way
|
|
|
|
around (not SMBus compliant, but very popular.)
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-11-19 15:01:42 +04:00
|
|
|
SMBus Process Call:
|
|
|
|
===================
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
This command selects a device register (through the Comm byte), sends
|
2019-07-26 15:51:16 +03:00
|
|
|
16 bits of data to it, and reads 16 bits of data in return::
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2019-07-26 15:51:16 +03:00
|
|
|
S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A]
|
|
|
|
S Addr Rd [A] [DataLow] A [DataHigh] NA P
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-12-17 00:11:55 +04:00
|
|
|
Functionality flag: I2C_FUNC_SMBUS_PROC_CALL
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-05-11 22:37:05 +04:00
|
|
|
SMBus Block Read: i2c_smbus_read_block_data()
|
|
|
|
==============================================
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2019-07-26 15:51:16 +03:00
|
|
|
This command reads a block of up to 32 bytes from a device, from a
|
2005-04-17 02:20:36 +04:00
|
|
|
designated register that is specified through the Comm byte. The amount
|
|
|
|
of data is specified by the device in the Count byte.
|
|
|
|
|
2019-07-26 15:51:16 +03:00
|
|
|
::
|
|
|
|
|
|
|
|
S Addr Wr [A] Comm [A]
|
|
|
|
S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-12-17 00:11:55 +04:00
|
|
|
Functionality flag: I2C_FUNC_SMBUS_READ_BLOCK_DATA
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-05-11 22:37:05 +04:00
|
|
|
SMBus Block Write: i2c_smbus_write_block_data()
|
|
|
|
================================================
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2019-07-26 15:51:16 +03:00
|
|
|
The opposite of the Block Read command, this writes up to 32 bytes to
|
2005-04-17 02:20:36 +04:00
|
|
|
a device, to a designated register that is specified through the
|
|
|
|
Comm byte. The amount of data is specified in the Count byte.
|
|
|
|
|
2019-07-26 15:51:16 +03:00
|
|
|
::
|
|
|
|
|
|
|
|
S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-12-17 00:11:55 +04:00
|
|
|
Functionality flag: I2C_FUNC_SMBUS_WRITE_BLOCK_DATA
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-05-11 22:37:05 +04:00
|
|
|
SMBus Block Write - Block Read Process Call
|
|
|
|
===========================================
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-05-11 22:37:05 +04:00
|
|
|
SMBus Block Write - Block Read Process Call was introduced in
|
|
|
|
Revision 2.0 of the specification.
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
This command selects a device register (through the Comm byte), sends
|
2019-07-26 15:51:16 +03:00
|
|
|
1 to 31 bytes of data to it, and reads 1 to 31 bytes of data in return::
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2019-07-26 15:51:16 +03:00
|
|
|
S Addr Wr [A] Comm [A] Count [A] Data [A] ...
|
|
|
|
S Addr Rd [A] [Count] A [Data] ... A P
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-12-17 00:11:55 +04:00
|
|
|
Functionality flag: I2C_FUNC_SMBUS_BLOCK_PROC_CALL
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
SMBus Host Notify
|
|
|
|
=================
|
|
|
|
|
|
|
|
This command is sent from a SMBus device acting as a master to the
|
|
|
|
SMBus host acting as a slave.
|
|
|
|
It is the same form as Write Word, with the command code replaced by the
|
|
|
|
alerting device's address.
|
|
|
|
|
2019-07-26 15:51:16 +03:00
|
|
|
::
|
|
|
|
|
|
|
|
[S] [HostAddr] [Wr] A [DevAddr] A [DataLow] A [DataHigh] A [P]
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2016-06-09 17:53:48 +03:00
|
|
|
This is implemented in the following way in the Linux kernel:
|
2019-07-26 15:51:16 +03:00
|
|
|
|
2016-10-13 15:10:40 +03:00
|
|
|
* I2C bus drivers which support SMBus Host Notify should report
|
|
|
|
I2C_FUNC_SMBUS_HOST_NOTIFY.
|
|
|
|
* I2C bus drivers trigger SMBus Host Notify by a call to
|
|
|
|
i2c_handle_smbus_host_notify().
|
|
|
|
* I2C drivers for devices which can trigger SMBus Host Notify will have
|
|
|
|
client->irq assigned to a Host Notify IRQ if noone else specified an other.
|
|
|
|
|
|
|
|
There is currently no way to retrieve the data parameter from the client.
|
2016-06-09 17:53:48 +03:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
Packet Error Checking (PEC)
|
|
|
|
===========================
|
2008-05-11 22:37:05 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
Packet Error Checking was introduced in Revision 1.1 of the specification.
|
|
|
|
|
2008-05-11 22:37:05 +04:00
|
|
|
PEC adds a CRC-8 error-checking byte to transfers using it, immediately
|
|
|
|
before the terminating STOP.
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
|
|
|
|
Address Resolution Protocol (ARP)
|
|
|
|
=================================
|
2008-05-11 22:37:05 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
The Address Resolution Protocol was introduced in Revision 2.0 of
|
|
|
|
the specification. It is a higher-layer protocol which uses the
|
|
|
|
messages above.
|
|
|
|
|
|
|
|
ARP adds device enumeration and dynamic address assignment to
|
|
|
|
the protocol. All ARP communications use slave address 0x61 and
|
|
|
|
require PEC checksums.
|
|
|
|
|
|
|
|
|
2010-03-02 14:23:42 +03:00
|
|
|
SMBus Alert
|
|
|
|
===========
|
|
|
|
|
|
|
|
SMBus Alert was introduced in Revision 1.0 of the specification.
|
|
|
|
|
|
|
|
The SMBus alert protocol allows several SMBus slave devices to share a
|
|
|
|
single interrupt pin on the SMBus master, while still allowing the master
|
|
|
|
to know which slave triggered the interrupt.
|
|
|
|
|
|
|
|
This is implemented the following way in the Linux kernel:
|
2019-07-26 15:51:16 +03:00
|
|
|
|
2010-03-02 14:23:42 +03:00
|
|
|
* I2C bus drivers which support SMBus alert should call
|
|
|
|
i2c_setup_smbus_alert() to setup SMBus alert support.
|
|
|
|
* I2C drivers for devices which can trigger SMBus alerts should implement
|
|
|
|
the optional alert() callback.
|
|
|
|
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
I2C Block Transactions
|
|
|
|
======================
|
2008-05-11 22:37:05 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
The following I2C block transactions are supported by the
|
|
|
|
SMBus layer and are described here for completeness.
|
2008-05-11 22:37:05 +04:00
|
|
|
They are *NOT* defined by the SMBus specification.
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
I2C block transactions do not limit the number of bytes transferred
|
|
|
|
but the SMBus layer places a limit of 32 bytes.
|
|
|
|
|
|
|
|
|
2008-05-11 22:37:05 +04:00
|
|
|
I2C Block Read: i2c_smbus_read_i2c_block_data()
|
|
|
|
================================================
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2019-07-26 15:51:16 +03:00
|
|
|
This command reads a block of bytes from a device, from a
|
|
|
|
designated register that is specified through the Comm byte::
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2019-07-26 15:51:16 +03:00
|
|
|
S Addr Wr [A] Comm [A]
|
|
|
|
S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-12-17 00:11:55 +04:00
|
|
|
Functionality flag: I2C_FUNC_SMBUS_READ_I2C_BLOCK
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
|
2008-05-11 22:37:05 +04:00
|
|
|
I2C Block Write: i2c_smbus_write_i2c_block_data()
|
|
|
|
==================================================
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2019-07-26 15:51:16 +03:00
|
|
|
The opposite of the Block Read command, this writes bytes to
|
2005-04-17 02:20:36 +04:00
|
|
|
a device, to a designated register that is specified through the
|
|
|
|
Comm byte. Note that command lengths of 0, 2, or more bytes are
|
|
|
|
supported as they are indistinguishable from data.
|
|
|
|
|
2019-07-26 15:51:16 +03:00
|
|
|
::
|
|
|
|
|
|
|
|
S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P
|
2012-12-17 00:11:55 +04:00
|
|
|
|
|
|
|
Functionality flag: I2C_FUNC_SMBUS_WRITE_I2C_BLOCK
|