From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.0 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7AFC2C433E0 for ; Sat, 13 Feb 2021 18:58:54 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D3EBA64E3F for ; Sat, 13 Feb 2021 18:58:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D3EBA64E3F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94) (envelope-from ) id 1lB07g-0000t8-T7; Sat, 13 Feb 2021 13:58:28 -0500 Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1lB07f-0000t3-UT for kernelnewbies@kernelnewbies.org; Sat, 13 Feb 2021 13:58:27 -0500 Received: by mail-qk1-x72d.google.com with SMTP id q85so2896722qke.8 for ; Sat, 13 Feb 2021 10:58:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=9D8hyiGfT2LlcCSOHEVca4S4gbsdZ1wr7RbFM9T6YZU=; b=DtJbPNr24SJ2v+NHF+6MD+m5ZNysX8VVDHjA6zVUKkzMSW+vDmWKHqO6tgPvkKWlz/ lXdPK+1vNBLcqm+m+6zBBYz4s2c2XyjAvfW3dIql0ZpP1zHC6QZyX0W3rtRDqHgPwbnu pmCnCw0sPmGL6qqBkpkdq3DP3Ba4batgfl9CeuC7FrlSl4ijIkcfqrW2vJ1xoD5TMo7f iBePxO6zx+ee5DiUL6Y0FIkPWS0AiKxNQFsi7FKClME1zORQaS2WXQAe4TqB5xA77+UM yha6p/pMhGMhQ6Q+xEUZ1mTG/yOdBVtriXHsMOqwI1CZzHEyedLwcs1rCGMEw9hi6VEh RadQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=9D8hyiGfT2LlcCSOHEVca4S4gbsdZ1wr7RbFM9T6YZU=; b=ddicGxwzaxc4qJCC+qI+Fl8XMtLksUQbsuaUk1G/R7KzwODcduIbu0y08pBVeWH8X+ wD6gs+Nca8J7yIRqJ4qHsG4jBRR/3WsXmZlt5HSAdh3AuUQWDOAl8SllmUkrrhIM3jMY oklkLHzGT3vrv81K+CKWLdYvN/+y2D1KdQKz1nPQiQsSyJe2fMD+wsSfw9AI/rNF+2AZ F3FpNE4fFgF3wHcUrnkb56WKT7zds82xn5hh9DMzsZXWshWId06er8LiguSHvEw1CXMm QzlGWr69YlGYmu6AkQ64DkdJiUg80DUH9mgIhvPBHK8Uy/jMk5zMzfocHmryM61q6Ob9 gK8w== X-Gm-Message-State: AOAM531KenOyXguGluGHtpUXmLs+9WJjMb+VU0H2v08YMTKJp00jr+Zq BoL5GOykgE0ZRHqd3G02uB7176Es6qucfw== X-Google-Smtp-Source: ABdhPJxNjz1msdl/JlNpJX4dGx4OS8FO2AeN2DDVJIvZNXWBJHObZF9+Wz3JJbsnuuiVw8XVk28ywQ== X-Received: by 2002:a37:6c1:: with SMTP id 184mr1132653qkg.65.1613242703946; Sat, 13 Feb 2021 10:58:23 -0800 (PST) Received: from localhost (pppoe-209-91-167-254.vianet.ca. [209.91.167.254]) by smtp.gmail.com with ESMTPSA id 18sm7685646qtw.70.2021.02.13.10.58.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Feb 2021 10:58:23 -0800 (PST) Date: Sat, 13 Feb 2021 13:58:21 -0500 From: Trevor Woerner To: kernelnewbies@kernelnewbies.org Subject: are 1-wire devices "discoverable"? Message-ID: <20210213185821.GA28820@localhost> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org 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