3ssphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget%/translations/zh_CN/i2c/functionalitymodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget%/translations/zh_TW/i2c/functionalitymodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget%/translations/it_IT/i2c/functionalitymodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget%/translations/ja_JP/i2c/functionalitymodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget%/translations/ko_KR/i2c/functionalitymodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget%/translations/sp_SP/i2c/functionalitymodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(hI2C/SMBus Functionalityh]hI2C/SMBus Functionality}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhh?/var/lib/git/docbuild/linux/Documentation/i2c/functionality.rsthKubh)}(hhh](h)}(h INTRODUCTIONh]h INTRODUCTION}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh paragraph)}(hXBecause not every I2C or SMBus adapter implements everything in the I2C specifications, a client can not trust that everything it needs is implemented when it is given the option to attach to an adapter: the client needs some way to check whether an adapter has the needed functionality.h]hXBecause not every I2C or SMBus adapter implements everything in the I2C specifications, a client can not trust that everything it needs is implemented when it is given the option to attach to an adapter: the client needs some way to check whether an adapter has the needed functionality.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubeh}(h] introductionah ]h"] introductionah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hFUNCTIONALITY CONSTANTSh]hFUNCTIONALITY CONSTANTS}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh)}(hYFor the most up-to-date list of functionality constants, please check !h]hYFor the most up-to-date list of functionality constants, please check !}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh block_quote)}(hX=============================== ============================================== I2C_FUNC_I2C Plain i2c-level commands (Pure SMBus adapters typically can not do these) I2C_FUNC_10BIT_ADDR Handles the 10-bit address extensions I2C_FUNC_PROTOCOL_MANGLING Knows about the I2C_M_IGNORE_NAK, I2C_M_REV_DIR_ADDR and I2C_M_NO_RD_ACK flags (which modify the I2C protocol!) I2C_FUNC_NOSTART Can skip repeated start sequence I2C_FUNC_SMBUS_QUICK Handles the SMBus write_quick command I2C_FUNC_SMBUS_READ_BYTE Handles the SMBus read_byte command I2C_FUNC_SMBUS_WRITE_BYTE Handles the SMBus write_byte command I2C_FUNC_SMBUS_READ_BYTE_DATA Handles the SMBus read_byte_data command I2C_FUNC_SMBUS_WRITE_BYTE_DATA Handles the SMBus write_byte_data command I2C_FUNC_SMBUS_READ_WORD_DATA Handles the SMBus read_word_data command I2C_FUNC_SMBUS_WRITE_WORD_DATA Handles the SMBus write_byte_data command I2C_FUNC_SMBUS_PROC_CALL Handles the SMBus process_call command I2C_FUNC_SMBUS_READ_BLOCK_DATA Handles the SMBus read_block_data command I2C_FUNC_SMBUS_WRITE_BLOCK_DATA Handles the SMBus write_block_data command I2C_FUNC_SMBUS_READ_I2C_BLOCK Handles the SMBus read_i2c_block_data command I2C_FUNC_SMBUS_WRITE_I2C_BLOCK Handles the SMBus write_i2c_block_data command =============================== ============================================== h]htable)}(hhh]htgroup)}(hhh](hcolspec)}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jhj ubj)}(hhh]h}(h]h ]h"]h$]h&]colwidthK.uh1jhj ubhtbody)}(hhh](hrow)}(hhh](hentry)}(hhh]h)}(h I2C_FUNC_I2Ch]h I2C_FUNC_I2C}(hj4hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj1ubah}(h]h ]h"]h$]h&]uh1j/hj,ubj0)}(hhh]h)}(hIPlain i2c-level commands (Pure SMBus adapters typically can not do these)h]hIPlain i2c-level commands (Pure SMBus adapters typically can not do these)}(hjKhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjHubah}(h]h ]h"]h$]h&]uh1j/hj,ubeh}(h]h ]h"]h$]h&]uh1j*hj'ubj+)}(hhh](j0)}(hhh]h)}(hI2C_FUNC_10BIT_ADDRh]hI2C_FUNC_10BIT_ADDR}(hjkhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhubah}(h]h ]h"]h$]h&]uh1j/hjeubj0)}(hhh]h)}(h%Handles the 10-bit address extensionsh]h%Handles the 10-bit address extensions}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j/hjeubeh}(h]h ]h"]h$]h&]uh1j*hj'ubj+)}(hhh](j0)}(hhh]h)}(hI2C_FUNC_PROTOCOL_MANGLINGh]hI2C_FUNC_PROTOCOL_MANGLING}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j/hjubj0)}(hhh]h)}(hoKnows about the I2C_M_IGNORE_NAK, I2C_M_REV_DIR_ADDR and I2C_M_NO_RD_ACK flags (which modify the I2C protocol!)h]hoKnows about the I2C_M_IGNORE_NAK, I2C_M_REV_DIR_ADDR and I2C_M_NO_RD_ACK flags (which modify the I2C protocol!)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j/hjubeh}(h]h ]h"]h$]h&]uh1j*hj'ubj+)}(hhh](j0)}(hhh]h)}(hI2C_FUNC_NOSTARTh]hI2C_FUNC_NOSTART}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j/hjubj0)}(hhh]h)}(h Can skip repeated start sequenceh]h Can skip repeated start sequence}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j/hjubeh}(h]h ]h"]h$]h&]uh1j*hj'ubj+)}(hhh](j0)}(hhh]h)}(hI2C_FUNC_SMBUS_QUICKh]hI2C_FUNC_SMBUS_QUICK}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1j/hj ubj0)}(hhh]h)}(h%Handles the SMBus write_quick commandh]h%Handles the SMBus write_quick command}(hj'hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj$ubah}(h]h ]h"]h$]h&]uh1j/hj ubeh}(h]h ]h"]h$]h&]uh1j*hj'ubj+)}(hhh](j0)}(hhh]h)}(hI2C_FUNC_SMBUS_READ_BYTEh]hI2C_FUNC_SMBUS_READ_BYTE}(hjGhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjDubah}(h]h ]h"]h$]h&]uh1j/hjAubj0)}(hhh]h)}(h#Handles the SMBus read_byte commandh]h#Handles the SMBus read_byte command}(hj^hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj[ubah}(h]h ]h"]h$]h&]uh1j/hjAubeh}(h]h ]h"]h$]h&]uh1j*hj'ubj+)}(hhh](j0)}(hhh]h)}(hI2C_FUNC_SMBUS_WRITE_BYTEh]hI2C_FUNC_SMBUS_WRITE_BYTE}(hj~hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj{ubah}(h]h ]h"]h$]h&]uh1j/hjxubj0)}(hhh]h)}(h$Handles the SMBus write_byte commandh]h$Handles the SMBus write_byte command}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j/hjxubeh}(h]h ]h"]h$]h&]uh1j*hj'ubj+)}(hhh](j0)}(hhh]h)}(hI2C_FUNC_SMBUS_READ_BYTE_DATAh]hI2C_FUNC_SMBUS_READ_BYTE_DATA}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hjubah}(h]h ]h"]h$]h&]uh1j/hjubj0)}(hhh]h)}(h(Handles the SMBus read_byte_data commandh]h(Handles the SMBus read_byte_data command}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hjubah}(h]h ]h"]h$]h&]uh1j/hjubeh}(h]h ]h"]h$]h&]uh1j*hj'ubj+)}(hhh](j0)}(hhh]h)}(hI2C_FUNC_SMBUS_WRITE_BYTE_DATAh]hI2C_FUNC_SMBUS_WRITE_BYTE_DATA}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK!hjubah}(h]h ]h"]h$]h&]uh1j/hjubj0)}(hhh]h)}(h)Handles the SMBus write_byte_data commandh]h)Handles the SMBus write_byte_data command}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK!hjubah}(h]h ]h"]h$]h&]uh1j/hjubeh}(h]h ]h"]h$]h&]uh1j*hj'ubj+)}(hhh](j0)}(hhh]h)}(hI2C_FUNC_SMBUS_READ_WORD_DATAh]hI2C_FUNC_SMBUS_READ_WORD_DATA}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK"hj ubah}(h]h ]h"]h$]h&]uh1j/hjubj0)}(hhh]h)}(h(Handles the SMBus read_word_data commandh]h(Handles the SMBus read_word_data command}(hj:hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK"hj7ubah}(h]h ]h"]h$]h&]uh1j/hjubeh}(h]h ]h"]h$]h&]uh1j*hj'ubj+)}(hhh](j0)}(hhh]h)}(hI2C_FUNC_SMBUS_WRITE_WORD_DATAh]hI2C_FUNC_SMBUS_WRITE_WORD_DATA}(hjZhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK#hjWubah}(h]h ]h"]h$]h&]uh1j/hjTubj0)}(hhh]h)}(h)Handles the SMBus write_byte_data commandh]h)Handles the SMBus write_byte_data command}(hjqhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK#hjnubah}(h]h ]h"]h$]h&]uh1j/hjTubeh}(h]h ]h"]h$]h&]uh1j*hj'ubj+)}(hhh](j0)}(hhh]h)}(hI2C_FUNC_SMBUS_PROC_CALLh]hI2C_FUNC_SMBUS_PROC_CALL}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK$hjubah}(h]h ]h"]h$]h&]uh1j/hjubj0)}(hhh]h)}(h&Handles the SMBus process_call commandh]h&Handles the SMBus process_call command}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK$hjubah}(h]h ]h"]h$]h&]uh1j/hjubeh}(h]h ]h"]h$]h&]uh1j*hj'ubj+)}(hhh](j0)}(hhh]h)}(hI2C_FUNC_SMBUS_READ_BLOCK_DATAh]hI2C_FUNC_SMBUS_READ_BLOCK_DATA}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK%hjubah}(h]h ]h"]h$]h&]uh1j/hjubj0)}(hhh]h)}(h)Handles the SMBus read_block_data commandh]h)Handles the SMBus read_block_data command}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK%hjubah}(h]h ]h"]h$]h&]uh1j/hjubeh}(h]h ]h"]h$]h&]uh1j*hj'ubj+)}(hhh](j0)}(hhh]h)}(hI2C_FUNC_SMBUS_WRITE_BLOCK_DATAh]hI2C_FUNC_SMBUS_WRITE_BLOCK_DATA}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK&hjubah}(h]h ]h"]h$]h&]uh1j/hjubj0)}(hhh]h)}(h*Handles the SMBus write_block_data commandh]h*Handles the SMBus write_block_data command}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK&hjubah}(h]h ]h"]h$]h&]uh1j/hjubeh}(h]h ]h"]h$]h&]uh1j*hj'ubj+)}(hhh](j0)}(hhh]h)}(hI2C_FUNC_SMBUS_READ_I2C_BLOCKh]hI2C_FUNC_SMBUS_READ_I2C_BLOCK}(hj6hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK'hj3ubah}(h]h ]h"]h$]h&]uh1j/hj0ubj0)}(hhh]h)}(h-Handles the SMBus read_i2c_block_data commandh]h-Handles the SMBus read_i2c_block_data command}(hjMhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK'hjJubah}(h]h ]h"]h$]h&]uh1j/hj0ubeh}(h]h ]h"]h$]h&]uh1j*hj'ubj+)}(hhh](j0)}(hhh]h)}(hI2C_FUNC_SMBUS_WRITE_I2C_BLOCKh]hI2C_FUNC_SMBUS_WRITE_I2C_BLOCK}(hjmhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK(hjjubah}(h]h ]h"]h$]h&]uh1j/hjgubj0)}(hhh]h)}(h.Handles the SMBus write_i2c_block_data commandh]h.Handles the SMBus write_i2c_block_data command}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK(hjubah}(h]h ]h"]h$]h&]uh1j/hjgubeh}(h]h ]h"]h$]h&]uh1j*hj'ubeh}(h]h ]h"]h$]h&]uh1j%hj ubeh}(h]h ]h"]h$]h&]colsKuh1j hjubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hLA few combinations of the above flags are also defined for your convenience:h]hLA few combinations of the above flags are also defined for your convenience:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK+hhhhubj)}(hX========================= ====================================== I2C_FUNC_SMBUS_BYTE Handles the SMBus read_byte and write_byte commands I2C_FUNC_SMBUS_BYTE_DATA Handles the SMBus read_byte_data and write_byte_data commands I2C_FUNC_SMBUS_WORD_DATA Handles the SMBus read_word_data and write_word_data commands I2C_FUNC_SMBUS_BLOCK_DATA Handles the SMBus read_block_data and write_block_data commands I2C_FUNC_SMBUS_I2C_BLOCK Handles the SMBus read_i2c_block_data and write_i2c_block_data commands I2C_FUNC_SMBUS_EMUL Handles all SMBus commands that can be emulated by a real I2C adapter (using the transparent emulation layer) ========================= ====================================== h]j)}(hhh]j )}(hhh](j)}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jhjubj)}(hhh]h}(h]h ]h"]h$]h&]colwidthK&uh1jhjubj&)}(hhh](j+)}(hhh](j0)}(hhh]h)}(hI2C_FUNC_SMBUS_BYTEh]hI2C_FUNC_SMBUS_BYTE}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK.hjubah}(h]h ]h"]h$]h&]uh1j/hjubj0)}(hhh]h)}(h3Handles the SMBus read_byte and write_byte commandsh]h3Handles the SMBus read_byte and write_byte commands}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK.hjubah}(h]h ]h"]h$]h&]uh1j/hjubeh}(h]h ]h"]h$]h&]uh1j*hjubj+)}(hhh](j0)}(hhh]h)}(hI2C_FUNC_SMBUS_BYTE_DATAh]hI2C_FUNC_SMBUS_BYTE_DATA}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK0hj ubah}(h]h ]h"]h$]h&]uh1j/hjubj0)}(hhh]h)}(h=Handles the SMBus read_byte_data and write_byte_data commandsh]h=Handles the SMBus read_byte_data and write_byte_data commands}(hj:hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK0hj7ubah}(h]h ]h"]h$]h&]uh1j/hjubeh}(h]h ]h"]h$]h&]uh1j*hjubj+)}(hhh](j0)}(hhh]h)}(hI2C_FUNC_SMBUS_WORD_DATAh]hI2C_FUNC_SMBUS_WORD_DATA}(hjZhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK2hjWubah}(h]h ]h"]h$]h&]uh1j/hjTubj0)}(hhh]h)}(h=Handles the SMBus read_word_data and write_word_data commandsh]h=Handles the SMBus read_word_data and write_word_data commands}(hjqhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK2hjnubah}(h]h ]h"]h$]h&]uh1j/hjTubeh}(h]h ]h"]h$]h&]uh1j*hjubj+)}(hhh](j0)}(hhh]h)}(hI2C_FUNC_SMBUS_BLOCK_DATAh]hI2C_FUNC_SMBUS_BLOCK_DATA}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK4hjubah}(h]h ]h"]h$]h&]uh1j/hjubj0)}(hhh]h)}(h?Handles the SMBus read_block_data and write_block_data commandsh]h?Handles the SMBus read_block_data and write_block_data commands}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK4hjubah}(h]h ]h"]h$]h&]uh1j/hjubeh}(h]h ]h"]h$]h&]uh1j*hjubj+)}(hhh](j0)}(hhh]h)}(hI2C_FUNC_SMBUS_I2C_BLOCKh]hI2C_FUNC_SMBUS_I2C_BLOCK}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK6hjubah}(h]h ]h"]h$]h&]uh1j/hjubj0)}(hhh]h)}(hGHandles the SMBus read_i2c_block_data and write_i2c_block_data commandsh]hGHandles the SMBus read_i2c_block_data and write_i2c_block_data commands}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK6hjubah}(h]h ]h"]h$]h&]uh1j/hjubeh}(h]h ]h"]h$]h&]uh1j*hjubj+)}(hhh](j0)}(hhh]h)}(hI2C_FUNC_SMBUS_EMULh]hI2C_FUNC_SMBUS_EMUL}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK8hjubah}(h]h ]h"]h$]h&]uh1j/hjubj0)}(hhh]h)}(hmHandles all SMBus commands that can be emulated by a real I2C adapter (using the transparent emulation layer)h]hmHandles all SMBus commands that can be emulated by a real I2C adapter (using the transparent emulation layer)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK8hjubah}(h]h ]h"]h$]h&]uh1j/hjubeh}(h]h ]h"]h$]h&]uh1j*hjubeh}(h]h ]h"]h$]h&]uh1j%hjubeh}(h]h ]h"]h$]h&]colsKuh1j hjubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1hhhhK-hhhhubh)}(hgIn kernel versions prior to 3.5 I2C_FUNC_NOSTART was implemented as part of I2C_FUNC_PROTOCOL_MANGLING.h]hgIn kernel versions prior to 3.5 I2C_FUNC_NOSTART was implemented as part of I2C_FUNC_PROTOCOL_MANGLING.}(hjIhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK=hhhhubeh}(h]functionality-constantsah ]h"]functionality constantsah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hADAPTER IMPLEMENTATIONh]hADAPTER IMPLEMENTATION}(hjbhhhNhNubah}(h]h ]h"]h$]h&]uh1hhj_hhhhhKBubh)}(hWhen you write a new adapter driver, you will have to implement a function callback ``functionality``. Typical implementations are given below.h](hTWhen you write a new adapter driver, you will have to implement a function callback }(hjphhhNhNubhliteral)}(h``functionality``h]h functionality}(hjzhhhNhNubah}(h]h ]h"]h$]h&]uh1jxhjpubh*. Typical implementations are given below.}(hjphhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKDhj_hhubh)}(h~A typical SMBus-only adapter would list all the SMBus transactions it supports. This example comes from the i2c-piix4 driver::h]h}A typical SMBus-only adapter would list all the SMBus transactions it supports. This example comes from the i2c-piix4 driver:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKHhj_hhubh literal_block)}(hstatic u32 piix4_func(struct i2c_adapter *adapter) { return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BLOCK_DATA; }h]hstatic u32 piix4_func(struct i2c_adapter *adapter) { return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BLOCK_DATA; }}hjsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1jhhhKKhj_hhubh)}(hNA typical full-I2C adapter would use the following (from the i2c-pxa driver)::h]hMA typical full-I2C adapter would use the following (from the i2c-pxa driver):}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKRhj_hhubj)}(hostatic u32 i2c_pxa_functionality(struct i2c_adapter *adap) { return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; }h]hostatic u32 i2c_pxa_functionality(struct i2c_adapter *adap) { return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; }}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKUhj_hhubh)}(hXI2C_FUNC_SMBUS_EMUL includes all the SMBus transactions (with the addition of I2C block transactions) which i2c-core can emulate using I2C_FUNC_I2C without any help from the adapter driver. The idea is to let the client drivers check for the support of SMBus functions without having to care whether the said functions are implemented in hardware by the adapter, or emulated in software by i2c-core on top of an I2C adapter.h]hXI2C_FUNC_SMBUS_EMUL includes all the SMBus transactions (with the addition of I2C block transactions) which i2c-core can emulate using I2C_FUNC_I2C without any help from the adapter driver. The idea is to let the client drivers check for the support of SMBus functions without having to care whether the said functions are implemented in hardware by the adapter, or emulated in software by i2c-core on top of an I2C adapter.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKZhj_hhubeh}(h]adapter-implementationah ]h"]adapter implementationah$]h&]uh1hhhhhhhhKBubh)}(hhh](h)}(hCLIENT CHECKINGh]hCLIENT CHECKING}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKdubh)}(hBefore a client tries to attach to an adapter, or even do tests to check whether one of the devices it supports is present on an adapter, it should check whether the needed functionality is present. The typical way to do this is (from the lm75 driver)::h]hBefore a client tries to attach to an adapter, or even do tests to check whether one of the devices it supports is present on an adapter, it should check whether the needed functionality is present. The typical way to do this is (from the lm75 driver):}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKfhjhhubj)}(hstatic int lm75_detect(...) { (...) if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) goto exit; (...) }h]hstatic int lm75_detect(...) { (...) if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) goto exit; (...) }}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKkhjhhubh)}(hX=Here, the lm75 driver checks if the adapter can do both SMBus byte data and SMBus word data transactions. If not, then the driver won't work on this adapter and there's no point in going on. If the check above is successful, then the driver knows that it can call the following functions: i2c_smbus_read_byte_data(), i2c_smbus_write_byte_data(), i2c_smbus_read_word_data() and i2c_smbus_write_word_data(). As a rule of thumb, the functionality constants you test for with i2c_check_functionality() should match exactly the i2c_smbus_* functions which you driver is calling.h]hXAHere, the lm75 driver checks if the adapter can do both SMBus byte data and SMBus word data transactions. If not, then the driver won’t work on this adapter and there’s no point in going on. If the check above is successful, then the driver knows that it can call the following functions: i2c_smbus_read_byte_data(), i2c_smbus_write_byte_data(), i2c_smbus_read_word_data() and i2c_smbus_write_word_data(). As a rule of thumb, the functionality constants you test for with i2c_check_functionality() should match exactly the i2c_smbus_* functions which you driver is calling.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKthjhhubh)}(hXNote that the check above doesn't tell whether the functionalities are implemented in hardware by the underlying adapter or emulated in software by i2c-core. Client drivers don't have to care about this, as i2c-core will transparently implement SMBus transactions on top of I2C adapters.h]hX#Note that the check above doesn’t tell whether the functionalities are implemented in hardware by the underlying adapter or emulated in software by i2c-core. Client drivers don’t have to care about this, as i2c-core will transparently implement SMBus transactions on top of I2C adapters.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK~hjhhubeh}(h]client-checkingah ]h"]client checkingah$]h&]uh1hhhhhhhhKdubh)}(hhh](h)}(hCHECKING THROUGH /DEVh]hCHECKING THROUGH /DEV}(hj8hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj5hhhhhKubh)}(hXIf you try to access an adapter from a userspace program, you will have to use the /dev interface. You will still have to check whether the functionality you need is supported, of course. This is done using the I2C_FUNCS ioctl. An example, adapted from the i2cdetect program, is below::h]hXIf you try to access an adapter from a userspace program, you will have to use the /dev interface. You will still have to check whether the functionality you need is supported, of course. This is done using the I2C_FUNCS ioctl. An example, adapted from the i2cdetect program, is below:}(hjFhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj5hhubj)}(hXint file; if (file = open("/dev/i2c-0", O_RDWR) < 0) { /* Some kind of error handling */ exit(1); } if (ioctl(file, I2C_FUNCS, &funcs) < 0) { /* Some kind of error handling */ exit(1); } if (!(funcs & I2C_FUNC_SMBUS_QUICK)) { /* Oops, the needed functionality (SMBus write_quick function) is not available! */ exit(1); } /* Now it is safe to use the SMBus write_quick command */h]hXint file; if (file = open("/dev/i2c-0", O_RDWR) < 0) { /* Some kind of error handling */ exit(1); } if (ioctl(file, I2C_FUNCS, &funcs) < 0) { /* Some kind of error handling */ exit(1); } if (!(funcs & I2C_FUNC_SMBUS_QUICK)) { /* Oops, the needed functionality (SMBus write_quick function) is not available! */ exit(1); } /* Now it is safe to use the SMBus write_quick command */}hjTsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhj5hhubeh}(h]checking-through-devah ]h"]checking through /devah$]h&]uh1hhhhhhhhKubeh}(h]i2c-smbus-functionalityah ]h"]i2c/smbus functionalityah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksj/footnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjerror_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(jojlhhj\jYjjj2j/jgjdu nametypes}(joh݉j\jj2jguh}(jlhhhjYhjj_j/jjdj5u footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.