All of lore.kernel.org
 help / color / mirror / Atom feed
From: Trevor Woerner <twoerner@gmail.com>
To: kernelnewbies@kernelnewbies.org
Subject: are 1-wire devices "discoverable"?
Date: Sat, 13 Feb 2021 13:58:21 -0500	[thread overview]
Message-ID: <20210213185821.GA28820@localhost> (raw)

Hi,

I just watched the amazing device tree presentation recently done by Thomas
Petazzoni (from Bootlin) for ST[1]. During the presentation, which is
amazing, by the way ;-), Thomas describes the 1-wire protocol as not being
discoverable.

I was recently playing with the DS18B20 temperature sensor, which uses the
1-wire bus.[2] In fact, I was playing with a bunch of different temperature
sensors with a RaspberryPi, and then gave a talk at a local RaspberryPi Meetup
group that I regularly attend.[3]

My only experience with the 1-wire bus is with this one device, so maybe the
details of how the DS18B20 work are specific to the DS18B20 and not the way
1-wire devices work in general? But my (humble) conclusion is that the 1-wire
bus is discoverable (or at least quasi-discoverable).

It's true that you do need a device tree overlay to tell the kernel that you
want to use the 1-wire bus, and you have to tell the kernel which GPIO pin you
want to use as the 1 wire, but after that, attaching DS18B20 devices to a
running system works quite magically.[4]

Each DS18B20 has a unique 64-bit number burned into it, the first 8 bits
specify the device type (i.e. the DS18B20), the next 48 bits are a unique
serial number, and the last 8 bits are a CRC of the previous 56 bits. Due to
the inclusion of the 8-bit device type, when I plug a DS18B20 into my board,
the kernel automatically creates a sysfs entry for it with a "temperature"
file that I can read to obtain the temperature in Celcius.

I don't know if that qualifies as "discoverable"? It's certainly a lot more
discoverable than I2C or SPI, although maybe not quite as discoverable as,
say, PCI. Specifying the 1 wire is not discoverable, but plugging 1-wire
devices into my board is maybe something that could be described as
discoverable?

Best regards,
	Trevor

[1] https://www.youtube.com/watch?v=a9CZ1Uk3OYQ
[2] https://twoerner.blogspot.com/2020/12/temperature-readings-with-ds18b20-and.html
[3] https://twoerner.blogspot.com/2021/01/sensing-temperature-with-raspberrypi.html
[4] https://twoerner.blogspot.com/2020/12/multiple-ds18b20-temperature-probes.html

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

             reply	other threads:[~2021-02-13 18:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-13 18:58 Trevor Woerner [this message]
2021-03-19  1:14 ` are 1-wire devices "discoverable"? jim.cromie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210213185821.GA28820@localhost \
    --to=twoerner@gmail.com \
    --cc=kernelnewbies@kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.