Skip to content

Commit 83d031c

Browse files
hubpavcarlescufi
authored andcommitted
drivers: w1: Make 1-Wire Skip ROM cmd. optional
For systems with a true dynamic 1-Wire nature, the 1-Wire devices cannot be defined in the DeviceTree (the number of slaves in the system is not known during the build time). In other words, there are no pre-defined 1-Wire devices on the bus in DeviceTree, and thus the slave_count variable is always zero. That means the skip_rom functionality will always be called even if there are multiple devices connected to the bus. This commit allows the user to override this original behavior and avoid the skip_rom call by ignoring the slave count variable. Also, this work preserves full backward compatibility. Signed-off-by: Pavel Hübner <[email protected]>
1 parent 9988067 commit 83d031c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

drivers/w1/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,17 @@ config W1_NET
5353
help
5454
Enable 1-wire network layer
5555

56+
config W1_NET_FORCE_MULTIDROP_ADDRESSING
57+
bool "Force 1-Wire multidrop addressing"
58+
depends on W1_NET
59+
help
60+
This option will ignore the number of 1-Wire
61+
slave devices defined in the DTS. Specifically,
62+
this option avoids the SKIP ROM command,
63+
which is otherwise used in case of a single
64+
1-Wire slave on the bus. In most cases, enabling
65+
this option is not needed, yet it is essential
66+
if multiple 1-Wire devices unspecified in the
67+
DTS are interfaced.
68+
5669
endif # W1

drivers/w1/w1_net.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ int w1_skip_rom(const struct device *dev, const struct w1_slave_config *config)
346346

347347
static int reset_select(const struct device *dev, const struct w1_slave_config *config)
348348
{
349-
if (w1_get_slave_count(dev) > 1) {
349+
if (IS_ENABLED(CONFIG_W1_NET_FORCE_MULTIDROP_ADDRESSING) || w1_get_slave_count(dev) > 1) {
350350
return match_rom(dev, config);
351351
}
352352

0 commit comments

Comments
 (0)