1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Chapter 10. I2C and SMBus Subsystem</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Linux Device Drivers"><link rel="up" href="index.html" title="Linux Device Drivers"><link rel="prev" href="API-spi-write-then-read.html" title="spi_write_then_read"><link rel="next" href="API-struct-i2c-driver.html" title="struct i2c_driver"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 10. I<sup>2</sup>C and SMBus Subsystem</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-spi-write-then-read.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="API-struct-i2c-driver.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="i2c"></a>Chapter 10. I<sup>2</sup>C and SMBus Subsystem</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="refentrytitle"><a href="API-struct-i2c-driver.html"><span class="phrase">struct i2c_driver</span></a></span><span class="refpurpose"> — 2 represent an I2C device driver 3 </span></dt><dt><span class="refentrytitle"><a href="API-struct-i2c-client.html"><span class="phrase">struct i2c_client</span></a></span><span class="refpurpose"> — 4 represent an I2C slave device 5 </span></dt><dt><span class="refentrytitle"><a href="API-struct-i2c-board-info.html"><span class="phrase">struct i2c_board_info</span></a></span><span class="refpurpose"> — 6 template for device creation 7 </span></dt><dt><span class="refentrytitle"><a href="API-I2C-BOARD-INFO.html"><span class="phrase">I2C_BOARD_INFO</span></a></span><span class="refpurpose"> — 8 macro used to list an i2c device and its address 9 </span></dt><dt><span class="refentrytitle"><a href="API-struct-i2c-algorithm.html"><span class="phrase">struct i2c_algorithm</span></a></span><span class="refpurpose"> — 10 represent I2C transfer method 11 </span></dt><dt><span class="refentrytitle"><a href="API-struct-i2c-bus-recovery-info.html"><span class="phrase">struct i2c_bus_recovery_info</span></a></span><span class="refpurpose"> — 12 I2C bus recovery information 13 </span></dt><dt><span class="refentrytitle"><a href="API-struct-i2c-adapter-quirks.html"><span class="phrase">struct i2c_adapter_quirks</span></a></span><span class="refpurpose"> — 14 describe flaws of an i2c adapter 15 </span></dt><dt><span class="refentrytitle"><a href="API-module-i2c-driver.html"><span class="phrase">module_i2c_driver</span></a></span><span class="refpurpose"> — 16 Helper macro for registering a I2C driver 17 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-register-board-info.html"><span class="phrase">i2c_register_board_info</span></a></span><span class="refpurpose"> — 18 statically declare I2C devices 19 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-verify-client.html"><span class="phrase">i2c_verify_client</span></a></span><span class="refpurpose"> — 20 return parameter as i2c_client, or NULL 21 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-lock-adapter.html"><span class="phrase">i2c_lock_adapter</span></a></span><span class="refpurpose"> — 22 Get exclusive access to an I2C bus segment 23 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-unlock-adapter.html"><span class="phrase">i2c_unlock_adapter</span></a></span><span class="refpurpose"> — 24 Release exclusive access to an I2C bus segment 25 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-new-device.html"><span class="phrase">i2c_new_device</span></a></span><span class="refpurpose"> — 26 instantiate an i2c device 27 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-unregister-device.html"><span class="phrase">i2c_unregister_device</span></a></span><span class="refpurpose"> — 28 reverse effect of <code class="function">i2c_new_device</code> 29 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-new-dummy.html"><span class="phrase">i2c_new_dummy</span></a></span><span class="refpurpose"> — 30 return a new i2c device bound to a dummy driver 31 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-verify-adapter.html"><span class="phrase">i2c_verify_adapter</span></a></span><span class="refpurpose"> — 32 return parameter as i2c_adapter or NULL 33 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-add-adapter.html"><span class="phrase">i2c_add_adapter</span></a></span><span class="refpurpose"> — 34 declare i2c adapter, use dynamic bus number 35 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-add-numbered-adapter.html"><span class="phrase">i2c_add_numbered_adapter</span></a></span><span class="refpurpose"> — 36 declare i2c adapter, use static bus number 37 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-del-adapter.html"><span class="phrase">i2c_del_adapter</span></a></span><span class="refpurpose"> — 38 unregister I2C adapter 39 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-del-driver.html"><span class="phrase">i2c_del_driver</span></a></span><span class="refpurpose"> — 40 unregister I2C driver 41 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-use-client.html"><span class="phrase">i2c_use_client</span></a></span><span class="refpurpose"> — 42 increments the reference count of the i2c client structure 43 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-release-client.html"><span class="phrase">i2c_release_client</span></a></span><span class="refpurpose"> — 44 release a use of the i2c client structure 45 </span></dt><dt><span class="refentrytitle"><a href="API---i2c-transfer.html"><span class="phrase">__i2c_transfer</span></a></span><span class="refpurpose"> — 46 unlocked flavor of i2c_transfer 47 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-transfer.html"><span class="phrase">i2c_transfer</span></a></span><span class="refpurpose"> — 48 execute a single or combined I2C message 49 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-master-send.html"><span class="phrase">i2c_master_send</span></a></span><span class="refpurpose"> — 50 issue a single I2C message in master transmit mode 51 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-master-recv.html"><span class="phrase">i2c_master_recv</span></a></span><span class="refpurpose"> — 52 issue a single I2C message in master receive mode 53 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-smbus-read-byte.html"><span class="phrase">i2c_smbus_read_byte</span></a></span><span class="refpurpose"> — 54 SMBus <span class="quote">“<span class="quote">receive byte</span>”</span> protocol 55 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-smbus-write-byte.html"><span class="phrase">i2c_smbus_write_byte</span></a></span><span class="refpurpose"> — 56 SMBus <span class="quote">“<span class="quote">send byte</span>”</span> protocol 57 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-smbus-read-byte-data.html"><span class="phrase">i2c_smbus_read_byte_data</span></a></span><span class="refpurpose"> — 58 SMBus <span class="quote">“<span class="quote">read byte</span>”</span> protocol 59 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-smbus-write-byte-data.html"><span class="phrase">i2c_smbus_write_byte_data</span></a></span><span class="refpurpose"> — 60 SMBus <span class="quote">“<span class="quote">write byte</span>”</span> protocol 61 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-smbus-read-word-data.html"><span class="phrase">i2c_smbus_read_word_data</span></a></span><span class="refpurpose"> — 62 SMBus <span class="quote">“<span class="quote">read word</span>”</span> protocol 63 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-smbus-write-word-data.html"><span class="phrase">i2c_smbus_write_word_data</span></a></span><span class="refpurpose"> — 64 SMBus <span class="quote">“<span class="quote">write word</span>”</span> protocol 65 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-smbus-read-block-data.html"><span class="phrase">i2c_smbus_read_block_data</span></a></span><span class="refpurpose"> — 66 SMBus <span class="quote">“<span class="quote">block read</span>”</span> protocol 67 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-smbus-write-block-data.html"><span class="phrase">i2c_smbus_write_block_data</span></a></span><span class="refpurpose"> — 68 SMBus <span class="quote">“<span class="quote">block write</span>”</span> protocol 69 </span></dt><dt><span class="refentrytitle"><a href="API-i2c-smbus-xfer.html"><span class="phrase">i2c_smbus_xfer</span></a></span><span class="refpurpose"> — 70 execute SMBus protocol operations 71 </span></dt></dl></div><p> 72 I<sup>2</sup>C (or without fancy typography, "I2C") 73 is an acronym for the "Inter-IC" bus, a simple bus protocol which is 74 widely used where low data rate communications suffice. 75 Since it's also a licensed trademark, some vendors use another 76 name (such as "Two-Wire Interface", TWI) for the same bus. 77 I2C only needs two signals (SCL for clock, SDA for data), conserving 78 board real estate and minimizing signal quality issues. 79 Most I2C devices use seven bit addresses, and bus speeds of up 80 to 400 kHz; there's a high speed extension (3.4 MHz) that's not yet 81 found wide use. 82 I2C is a multi-master bus; open drain signaling is used to 83 arbitrate between masters, as well as to handshake and to 84 synchronize clocks from slower clients. 85 </p><p> 86 The Linux I2C programming interfaces support only the master 87 side of bus interactions, not the slave side. 88 The programming interface is structured around two kinds of driver, 89 and two kinds of device. 90 An I2C "Adapter Driver" abstracts the controller hardware; it binds 91 to a physical device (perhaps a PCI device or platform_device) and 92 exposes a <span class="structname">struct i2c_adapter</span> representing 93 each I2C bus segment it manages. 94 On each I2C bus segment will be I2C devices represented by a 95 <span class="structname">struct i2c_client</span>. Those devices will 96 be bound to a <span class="structname">struct i2c_driver</span>, 97 which should follow the standard Linux driver model. 98 (At this writing, a legacy model is more widely used.) 99 There are functions to perform various I2C protocol operations; at 100 this writing all such functions are usable only from task context. 101 </p><p> 102 The System Management Bus (SMBus) is a sibling protocol. Most SMBus 103 systems are also I2C conformant. The electrical constraints are 104 tighter for SMBus, and it standardizes particular protocol messages 105 and idioms. Controllers that support I2C can also support most 106 SMBus operations, but SMBus controllers don't support all the protocol 107 options that an I2C controller will. 108 There are functions to perform various SMBus protocol operations, 109 either using I2C primitives or by issuing SMBus commands to 110 i2c_adapter devices which don't support those I2C operations. 111 </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-spi-write-then-read.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="API-struct-i2c-driver.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">spi_write_then_read</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span class="phrase">struct i2c_driver</span></td></tr></table></div></body></html> 112