ksphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget!/translations/zh_CN/w1/w1-genericmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget!/translations/zh_TW/w1/w1-genericmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget!/translations/it_IT/w1/w1-genericmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget!/translations/ja_JP/w1/w1-genericmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget!/translations/ko_KR/w1/w1-genericmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget!/translations/sp_SP/w1/w1-genericmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(h)Introduction to the 1-wire (w1) subsystemh]h)Introduction to the 1-wire (w1) subsystem}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhh;/var/lib/git/docbuild/linux/Documentation/w1/w1-generic.rsthKubh paragraph)}(hsThe 1-wire bus is a simple master-slave bus that communicates via a single signal wire (plus ground, so two wires).h]hsThe 1-wire bus is a simple master-slave bus that communicates via a single signal wire (plus ground, so two wires).}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hDevices communicate on the bus by pulling the signal to ground via an open drain output and by sampling the logic level of the signal line.h]hDevices communicate on the bus by pulling the signal to ground via an open drain output and by sampling the logic level of the signal line.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(h^The w1 subsystem provides the framework for managing w1 masters and communication with slaves.h]h^The w1 subsystem provides the framework for managing w1 masters and communication with slaves.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhhhubh)}(hAAll w1 slave devices must be connected to a w1 bus master device.h]hAAll w1 slave devices must be connected to a w1 bus master device.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hExample w1 master devices:h]hExample w1 master devices:}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh block_quote)}(h- DS9490 usb device - W1-over-GPIO - DS2482 (i2c to w1 bridge) - Emulated devices, such as a RS232 converter, parallel port adapter, etc h]h bullet_list)}(hhh](h list_item)}(hDS9490 usb deviceh]h)}(hjh]hDS9490 usb device}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h W1-over-GPIOh]h)}(hj%h]h W1-over-GPIO}(hj'hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj#ubah}(h]h ]h"]h$]h&]uh1j hjubj )}(hDS2482 (i2c to w1 bridge)h]h)}(hj<h]hDS2482 (i2c to w1 bridge)}(hj>hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj:ubah}(h]h ]h"]h$]h&]uh1j hjubj )}(hIEmulated devices, such as a RS232 converter, parallel port adapter, etc h]h)}(hGEmulated devices, such as a RS232 converter, parallel port adapter, etch]hGEmulated devices, such as a RS232 converter, parallel port adapter, etc}(hjUhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjQubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]bullet-uh1jhhhKhjubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hhh](h)}(hWhat does the w1 subsystem do?h]hWhat does the w1 subsystem do?}(hjzhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjwhhhhhKubh)}(hNWhen a w1 master driver registers with the w1 subsystem, the following occurs:h]hNWhen a w1 master driver registers with the w1 subsystem, the following occurs:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjwhhubj)}(hk- sysfs entries for that w1 master are created - the w1 bus is periodically searched for new slave devices h]j)}(hhh](j )}(h,sysfs entries for that w1 master are createdh]h)}(hjh]h,sysfs entries for that w1 master are created}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j hjubj )}(h:the w1 bus is periodically searched for new slave devices h]h)}(h9the w1 bus is periodically searched for new slave devicesh]h9the w1 bus is periodically searched for new slave devices}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]jojpuh1jhhhKhjubah}(h]h ]h"]h$]h&]uh1hhhhKhjwhhubh)}(hXWhen a device is found on the bus, w1 core tries to load the driver for its family and check if it is loaded. If so, the family driver is attached to the slave. If there is no driver for the family, default one is assigned, which allows to perform almost any kind of operations. Each logical operation is a transaction in nature, which can contain several (two or one) low-level operations. Let's see how one can read EEPROM context: 1. one must write control buffer, i.e. buffer containing command byte and two byte address. At this step bus is reset and appropriate device is selected using either W1_SKIP_ROM or W1_MATCH_ROM command. Then provided control buffer is being written to the wire. 2. reading. This will issue reading eeprom response.h]hXWhen a device is found on the bus, w1 core tries to load the driver for its family and check if it is loaded. If so, the family driver is attached to the slave. If there is no driver for the family, default one is assigned, which allows to perform almost any kind of operations. Each logical operation is a transaction in nature, which can contain several (two or one) low-level operations. Let’s see how one can read EEPROM context: 1. one must write control buffer, i.e. buffer containing command byte and two byte address. At this step bus is reset and appropriate device is selected using either W1_SKIP_ROM or W1_MATCH_ROM command. Then provided control buffer is being written to the wire. 2. reading. This will issue reading eeprom response.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hjwhhubh)}(hIt is possible that between 1. and 2. w1 master thread will reset bus for searching and slave device will be even removed, but in this case 0xff will be read, since no device was selected.h]hIt is possible that between 1. and 2. w1 master thread will reset bus for searching and slave device will be even removed, but in this case 0xff will be read, since no device was selected.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK,hjwhhubeh}(h]what-does-the-w1-subsystem-doah ]h"]what does the w1 subsystem do?ah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hW1 device familiesh]hW1 device families}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK2ubh)}(hISlave devices are handled by a driver written for a family of w1 devices.h]hISlave devices are handled by a driver written for a family of w1 devices.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK4hjhhubh)}(hgA family driver populates a struct w1_family_ops (see w1_family.h) and registers with the w1 subsystem.h]hgA family driver populates a struct w1_family_ops (see w1_family.h) and registers with the w1 subsystem.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK6hjhhubh)}(hCurrent family drivers:h]hCurrent family drivers:}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK9hjhhubhdefinition_list)}(hhh](hdefinition_list_item)}(hw1_therm - (ds18?20 thermal sensor family driver) provides temperature reading function which is bound to ->rbin() method of the above w1_family_ops structure. h](hterm)}(hw1_thermh]hw1_therm}(hjDhhhNhNubah}(h]h ]h"]h$]h&]uh1jBhhhK>hj>ubh definition)}(hhh]j)}(hhh]j )}(h(ds18?20 thermal sensor family driver) provides temperature reading function which is bound to ->rbin() method of the above w1_family_ops structure. h]h)}(h(ds18?20 thermal sensor family driver) provides temperature reading function which is bound to ->rbin() method of the above w1_family_ops structure.h]h(ds18?20 thermal sensor family driver) provides temperature reading function which is bound to ->rbin() method of the above w1_family_ops structure.}(hj^hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKubeh}(h]h ]h"]h$]h&]uh1j<hhhK>hj9ubj=)}(hJw1_smem - driver for simple 64bit memory cell provides ID reading method. h](jC)}(hw1_smemh]hw1_smem}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jBhhhKAhjubjS)}(hhh]j)}(hhh]j )}(h@driver for simple 64bit memory cell provides ID reading method. h]h)}(h?driver for simple 64bit memory cell provides ID reading method.h]h?driver for simple 64bit memory cell provides ID reading method.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKAhjubah}(h]h ]h"]h$]h&]uh1j hjubah}(h]h ]h"]h$]h&]jojpuh1jhhhKAhjubah}(h]h ]h"]h$]h&]uh1jRhjubeh}(h]h ]h"]h$]h&]uh1j<hhhKAhj9hhubeh}(h]h ]h"]h$]h&]uh1j7hjhhhNhNubh)}(h>You can call above methods by reading appropriate sysfs files.h]h>You can call above methods by reading appropriate sysfs files.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKChjhhubeh}(h]w1-device-familiesah ]h"]w1 device familiesah$]h&]uh1hhhhhhhhK2ubh)}(hhh](h)}(h/What does a w1 master driver need to implement?h]h/What does a w1 master driver need to implement?}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKGubh)}(hCThe driver for w1 bus master must provide at minimum two functions.h]hCThe driver for w1 bus master must provide at minimum two functions.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKIhjhhubh)}(h|Emulated devices must provide the ability to set the output signal level (write_bit) and sample the signal level (read_bit).h]h|Emulated devices must provide the ability to set the output signal level (write_bit) and sample the signal level (read_bit).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKKhjhhubh)}(hDevices that support the 1-wire natively must provide the ability to write and sample a bit (touch_bit) and reset the bus (reset_bus).h]hDevices that support the 1-wire natively must provide the ability to write and sample a bit (touch_bit) and reset the bus (reset_bus).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKNhjhhubh)}(hMost hardware provides higher-level functions that offload w1 handling. See struct w1_bus_master definition in w1.h for details.h]hMost hardware provides higher-level functions that offload w1 handling. See struct w1_bus_master definition in w1.h for details.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKQhjhhubeh}(h].what-does-a-w1-master-driver-need-to-implementah ]h"]/what does a w1 master driver need to implement?ah$]h&]uh1hhhhhhhhKGubh)}(hhh](h)}(hw1 master sysfs interfaceh]hw1 master sysfs interface}(hj6hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj3hhhhhKVubhtable)}(hhh]htgroup)}(hhh](hcolspec)}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jNhjKubjO)}(hhh]h}(h]h ]h"]h$]h&]colwidthK5uh1jNhjKubhtbody)}(hhh](hrow)}(hhh](hentry)}(hhh]h)}(hh]h}(hjshhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKYhjpubah}(h]h ]h"]h$]h&]uh1jnhjkubjo)}(hhh]h)}(h;A directory for a found device. The format is family-serialh]h;A directory for a found device. The format is family-serial}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKYhjubah}(h]h ]h"]h$]h&]uh1jnhjkubeh}(h]h ]h"]h$]h&]uh1jihjfubjj)}(hhh](jo)}(hhh]h)}(hbush]hbus}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK[hjubah}(h]h ]h"]h$]h&]uh1jnhjubjo)}(hhh]h)}(h (standard) symlink to the w1 bush]h (standard) symlink to the w1 bus}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK[hjubah}(h]h ]h"]h$]h&]uh1jnhjubeh}(h]h ]h"]h$]h&]uh1jihjfubjj)}(hhh](jo)}(hhh]h)}(hdriverh]hdriver}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK\hjubah}(h]h ]h"]h$]h&]uh1jnhjubjo)}(hhh]h)}(h#(standard) symlink to the w1 driverh]h#(standard) symlink to the w1 driver}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK\hjubah}(h]h ]h"]h$]h&]uh1jnhjubeh}(h]h ]h"]h$]h&]uh1jihjfubjj)}(hhh](jo)}(hhh]h)}(h w1_master_addh]h w1_master_add}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK]hjubah}(h]h ]h"]h$]h&]uh1jnhjubjo)}(hhh]h)}(h%(rw) manually register a slave deviceh]h%(rw) manually register a slave device}(hj/hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK]hj,ubah}(h]h ]h"]h$]h&]uh1jnhjubeh}(h]h ]h"]h$]h&]uh1jihjfubjj)}(hhh](jo)}(hhh]h)}(hw1_master_attemptsh]hw1_master_attempts}(hjOhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK^hjLubah}(h]h ]h"]h$]h&]uh1jnhjIubjo)}(hhh]h)}(h/(ro) the number of times a search was attemptedh]h/(ro) the number of times a search was attempted}(hjfhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK^hjcubah}(h]h ]h"]h$]h&]uh1jnhjIubeh}(h]h ]h"]h$]h&]uh1jihjfubjj)}(hhh](jo)}(hhh]h)}(hw1_master_max_slave_counth]hw1_master_max_slave_count}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK_hjubah}(h]h ]h"]h$]h&]uh1jnhjubjo)}(hhh]h)}(h5(rw) maximum number of slaves to search for at a timeh]h5(rw) maximum number of slaves to search for at a time}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK_hjubah}(h]h ]h"]h$]h&]uh1jnhjubeh}(h]h ]h"]h$]h&]uh1jihjfubjj)}(hhh](jo)}(hhh]h)}(hw1_master_nameh]hw1_master_name}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK`hjubah}(h]h ]h"]h$]h&]uh1jnhjubjo)}(hhh]h)}(h,(ro) the name of the device (w1_bus_masterX)h]h,(ro) the name of the device (w1_bus_masterX)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK`hjubah}(h]h ]h"]h$]h&]uh1jnhjubeh}(h]h ]h"]h$]h&]uh1jihjfubjj)}(hhh](jo)}(hhh]h)}(hw1_master_pulluph]hw1_master_pullup}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKahjubah}(h]h ]h"]h$]h&]uh1jnhjubjo)}(hhh]h)}(h+(rw) 5V strong pullup 0 enabled, 1 disabledh]h+(rw) 5V strong pullup 0 enabled, 1 disabled}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKahjubah}(h]h ]h"]h$]h&]uh1jnhjubeh}(h]h ]h"]h$]h&]uh1jihjfubjj)}(hhh](jo)}(hhh]h)}(hw1_master_removeh]hw1_master_remove}(hj+hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKbhj(ubah}(h]h ]h"]h$]h&]uh1jnhj%ubjo)}(hhh]h)}(h#(rw) manually remove a slave deviceh]h#(rw) manually remove a slave device}(hjBhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKbhj?ubah}(h]h ]h"]h$]h&]uh1jnhj%ubeh}(h]h ]h"]h$]h&]uh1jihjfubjj)}(hhh](jo)}(hhh]h)}(hw1_master_searchh]hw1_master_search}(hjbhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKchj_ubah}(h]h ]h"]h$]h&]uh1jnhj\ubjo)}(hhh]h)}(h>(rw) the number of searches left to do, -1=continual (default)h]h>(rw) the number of searches left to do, -1=continual (default)}(hjyhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKchjvubah}(h]h ]h"]h$]h&]uh1jnhj\ubeh}(h]h ]h"]h$]h&]uh1jihjfubjj)}(hhh](jo)}(hhh]h)}(hw1_master_slave_counth]hw1_master_slave_count}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKehjubah}(h]h ]h"]h$]h&]uh1jnhjubjo)}(hhh]h)}(h(ro) the number of slaves foundh]h(ro) the number of slaves found}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKehjubah}(h]h ]h"]h$]h&]uh1jnhjubeh}(h]h ]h"]h$]h&]uh1jihjfubjj)}(hhh](jo)}(hhh]h)}(hw1_master_slavesh]hw1_master_slaves}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKfhjubah}(h]h ]h"]h$]h&]uh1jnhjubjo)}(hhh]h)}(h*(ro) the names of the slaves, one per lineh]h*(ro) the names of the slaves, one per line}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKfhjubah}(h]h ]h"]h$]h&]uh1jnhjubeh}(h]h ]h"]h$]h&]uh1jihjfubjj)}(hhh](jo)}(hhh]h)}(hw1_master_timeouth]hw1_master_timeout}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKghjubah}(h]h ]h"]h$]h&]uh1jnhjubjo)}(hhh]h)}(h*(ro) the delay in seconds between searchesh]h*(ro) the delay in seconds between searches}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKghjubah}(h]h ]h"]h$]h&]uh1jnhjubeh}(h]h ]h"]h$]h&]uh1jihjfubjj)}(hhh](jo)}(hhh]h)}(hw1_master_timeout_ush]hw1_master_timeout_us}(hj>hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhj;ubah}(h]h ]h"]h$]h&]uh1jnhj8ubjo)}(hhh]h)}(h/(ro) the delay in microseconds between searchesh]h/(ro) the delay in microseconds between searches}(hjUhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhjRubah}(h]h ]h"]h$]h&]uh1jnhj8ubeh}(h]h ]h"]h$]h&]uh1jihjfubeh}(h]h ]h"]h$]h&]uh1jdhjKubeh}(h]h ]h"]h$]h&]colsKuh1jIhjFubah}(h]h ]h"]h$]h&]uh1jDhj3hhhhhNubh)}(hXIf you have a w1 bus that never changes (you don't add or remove devices), you can set the module parameter search_count to a small positive number for an initially small number of bus searches. Alternatively it could be set to zero, then manually add the slave device serial numbers by w1_master_add device file. The w1_master_add and w1_master_remove files generally only make sense when searching is disabled, as a search will redetect manually removed devices that are present and timeout manually added devices that aren't on the bus.h]hX!If you have a w1 bus that never changes (you don’t add or remove devices), you can set the module parameter search_count to a small positive number for an initially small number of bus searches. Alternatively it could be set to zero, then manually add the slave device serial numbers by w1_master_add device file. The w1_master_add and w1_master_remove files generally only make sense when searching is disabled, as a search will redetect manually removed devices that are present and timeout manually added devices that aren’t on the bus.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKkhj3hhubh)}(hX'Bus searches occur at an interval, specified as a sum of timeout and timeout_us module parameters (either of which may be 0) for as long as w1_master_search remains greater than 0 or is -1. Each search attempt decrements w1_master_search by 1 (down to 0) and increments w1_master_attempts by 1.h]hX'Bus searches occur at an interval, specified as a sum of timeout and timeout_us module parameters (either of which may be 0) for as long as w1_master_search remains greater than 0 or is -1. Each search attempt decrements w1_master_search by 1 (down to 0) and increments w1_master_attempts by 1.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKthj3hhubeh}(h]w1-master-sysfs-interfaceah ]h"]w1 master sysfs interfaceah$]h&]uh1hhhhhhhhKVubh)}(hhh](h)}(hw1 slave sysfs interfaceh]hw1 slave sysfs interface}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK{ubjE)}(hhh]jJ)}(hhh](jO)}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jNhjubjO)}(hhh]h}(h]h ]h"]h$]h&]colwidthK