Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1108767pxb; Tue, 26 Oct 2021 02:58:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyM2ATdHtpb1sXpWbvZzwUzpxNBM3xqptiz6x/ziyh/zcvmjk/X+ej+m+7uo8IeEHdlTT2r X-Received: by 2002:a63:330f:: with SMTP id z15mr15082797pgz.42.1635242315831; Tue, 26 Oct 2021 02:58:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635242315; cv=none; d=google.com; s=arc-20160816; b=dFCtj5gxyqw4e/4dYrJOi0RkMaEwBbhZhXfoP6jZhF6XH9uG6EAZrZbANtzf9zEHNq XNqhHd4sI9Y9FvHN84MjrPhOvw9jUNr0Uie4YP7/sjO21MTrRd0bmYy5ioOO+z70fVn4 oi2syW9QGfLwBupgaATvzoVtkX8DRTw1kXdpxpSxYYbJfiojQmerIG8hxqK9MwugSUMN bCU9VsOnncOXGCzNbQSmOepzlONhCYFdu3BcF7GjD4BZBip1ZHeaFqgglZLMs8lGf2Fp iuep7ve6D+lKO7NlLs92mw8YH3SGb543feKf0/eMyVzXO2nplJIrUz+5qPK6QTeMMgur X7yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=7KThsVsJ0ORwtbbILrkIHcQVvOXxtniaD63wKOd53qk=; b=mMCMyxH38Jnxoi5M1GTUxmZDrkH9wQU8vOcdilzEbp+KVM7JFY/9kWvyXr85fV866w VMzr7lTZSb5cTFVyLL3xX4BWtkv7MzdBlNQ5GwwHwONAGzlMwk911QubDKFqql7xCAnM RZC+oYrQlrIcW7MJ6i0w+cTBP3P00yceSZJS/0SZigOKWHoWlNBog4E52DBPiXCRPxRC 3enr/FqJkdCJOmUWagwPzKM2tduBjphfYtFZvgTAYan0XkNegIdn+Fub+UCDqCK1OzuP Ih2hW4oeCN2SBM4kbCXUWjlWIZPAozh00bEg1LeoGczgk1pF3dhhM+Nkl7O64IA4SeH6 So2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nathanrossi.com header.s=google header.b=HnvJ4vvo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nathanrossi.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e12si33650031plh.126.2021.10.26.02.58.14; Tue, 26 Oct 2021 02:58:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nathanrossi.com header.s=google header.b=HnvJ4vvo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nathanrossi.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231860AbhJZH5P (ORCPT + 99 others); Tue, 26 Oct 2021 03:57:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232081AbhJZH5O (ORCPT ); Tue, 26 Oct 2021 03:57:14 -0400 Received: from mail-ua1-x933.google.com (mail-ua1-x933.google.com [IPv6:2607:f8b0:4864:20::933]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C0C5C061767 for ; Tue, 26 Oct 2021 00:54:51 -0700 (PDT) Received: by mail-ua1-x933.google.com with SMTP id x3so8165190uar.13 for ; Tue, 26 Oct 2021 00:54:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nathanrossi.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7KThsVsJ0ORwtbbILrkIHcQVvOXxtniaD63wKOd53qk=; b=HnvJ4vvoBGWPejDQnm/ceHOouktHbMPYb2NVqm8X890uLYuhTntSkXmPPrfeXPUxFf JaV8TxThiaayueFvWeFtc7E5kZRxffOdqIDgYnawrTS77/V2nCdJXJQLIW3UjwIUd5PK PoezPScg2qx0ovlwPBRS3QbxEwCQ3qQEE0n7miqUGqf+QRuID0gmWS+YmqKyowfwxUqa TEw0jBSG6oL3BH7IsdFPy1p7oHtarhL+e4cERUZMn/2Yb3w+zyUslD1AQ65WMu5jf422 sE1v6m683vV+buas/UyPtz8IEzH08wLrjA8XA0dX7DhXBLdMQl+RRmD3Mn7hKV3p6+JW XxFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7KThsVsJ0ORwtbbILrkIHcQVvOXxtniaD63wKOd53qk=; b=wc9jH3JQh/3iPGZM2CdrNPxGmWPo8+akFkOPzYJTf5IhKINO/EX0gQ6a7kiLXZP3Fv oTJa0V4tP0pRxAOunMMdUPsgwqPIVmQWsfZrbzEDbiEvR/k3IjxH4V5IEqcGxAK/Zk85 Vvh5ewtFjuV47KK2+kbRtn2iUoz5tRKl3TZuheGEBlomse6IdFyCy1x0OA5BXxitX6L5 6QWYR5pkMLuVfeKQkN8v0JrPSPwOlx67er1qIv4fxzykKkyRMBpEsPkN92vmlPgWGBrs zfjoxLwSxCEm6Dxq/pL0vG1yeL2Je1NU7JRHIeUf0MCM3+CRA1a2+vlYoMExgeKwFyLf nNbw== X-Gm-Message-State: AOAM530Jh+u4InjMSY4IkZR9fD5u+jXkJH1SBOPxxXm606lXSpvKDNUe UVYNNInMHN1Z/arHwFhH2fi7LS5oP7vA1TFZrPamYQ== X-Received: by 2002:a67:f1ca:: with SMTP id v10mr18800145vsm.55.1635234890581; Tue, 26 Oct 2021 00:54:50 -0700 (PDT) MIME-Version: 1.0 References: <20211025025805.618566-0-nathan@nathanrossi.com> <20211025025805.618566-2-nathan@nathanrossi.com> <7297bf4c-2f8e-f217-0153-c2224a1c56b3@roeck-us.net> <2f5aecd2-55a1-9382-46eb-f4ff48663b30@roeck-us.net> In-Reply-To: <2f5aecd2-55a1-9382-46eb-f4ff48663b30@roeck-us.net> From: Nathan Rossi Date: Tue, 26 Oct 2021 17:54:39 +1000 Message-ID: Subject: Re: [PATCH 2/2] hwmon: Driver for Texas Instruments INA238 To: Guenter Roeck Cc: linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Rossi , Jean Delvare , Jonathan Corbet Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 26 Oct 2021 at 01:45, Guenter Roeck wrote: > > On 10/24/21 11:27 PM, Nathan Rossi wrote: > [ ... ] > >> Is there reason to believe that the shunt register value needs to be visible > >> and writeable with sysfs attributes ? This is quite unusual nowadays. > >> If so, please provide a use case. > > > > I do not have a specific use case for being able to change the shunt > > resistor at run time. The only reason this behaviour is here is to > > mirror the api that is provided by the ina2xx driver. Since as you > > mention its unusual should I remove the write and leave the read? > > Being able to determine the resistor value is useful if manually using > > the shunt voltage. Though the shunt information could be obtained from > > the device tree node? > > > > Please drop the attribute. There is already probe noise displaying it, > and it is contained in the devicetree data. If there is a use case, > the attribute can always be added later. > > [ ... ] > > >> Those preinitializations make me wonder if there should be devicetree > >> properties for at least some of the data. > > > > Yes, I did consider adding configuration for the conversion time and > > sampling average as device tree properties. The existing ina2xx driver > > handles configuring sampling average via the "update_interval" sysfs > > attribute. Our use case does not require changing these at runtime so > > did not implement the update_interval and was unsure if changes to > > device tree bindings would make sense. Should these be device tree > > properties? If yes, should the other ina drivers be updated to support > > the properties? > > > > I wasn't specifically thinking about conversion time or sampling average, > but I do think it would be desirable to be able to configure all those > values via devicetree. The datasheet says "... allows for robust operation > in a variety of noisy environments", and that is definitely a system property. > ADCRANGE should also be configurable via devicetree. The same applies to MODE, I will add a property "ti,shunt-gain". Since the ina209, ina219, ina220 use the PGA term which is the actual function being provided, where ADCRANGE=0 is a /4 PGA for ina238 and the other devices have /1, /2, /4, /8. > but that would add some complexity so I am not sure if you'd want to get > into that (it would require per-channel entries in devicetree to be able > to enable/disable each channel). FWIW, you _could_ also do that with > standard sysfs attributes if you want to ({in,curr,temp}X_enable, or > hwmon_{temp,in,curr}_enable in the with_info API). That can also be added > later if needed, so there is no need to do it now if it is not required > for your use case. > > As for other ina drivers - that is a different question. I would not touch > those unless you have a use case (and a means to test the code). I'd also > consider it more important to convert those drivers to use the _with_info > API before implementing any other changes. There is also the added > complexity that we already have two drivers for those other chips (see > drivers/iio/adc/ina2xx-adc.c), and I'd rather have a better API > between IIO and HWMON and drop drivers/hwmon/ina2xx.c entirely than > making changes to it. > > Can you possibly send me a register dump for the INA238 ? That would > enable me to write a module test for the driver. Dump of registers below. Other notes, upper two bits are ignored so the address space wraps at 0x40, etc. The undocumented/unused registers between 0x11 and 0x3e are 0xffff. power on, before probe: 0x00: 0x0000 0x01: 0xfb68 0x02: 0x1000 0x03: 0xffff 0x04: 0x087c 0x05: 0x0e77 0x06: 0x0f10 0x07: 0x087c 0x08: 0x01eac3 0x09: 0xffff 0x10: 0x7ff0 0x11: 0xffff 0x3e: 0x5449 0x3f: 0x2381 after probe, actual state of device ~10mV shunt voltage, 20 mOhm shunt, ~12V bus, ~6W power, ~30C temperature 0x00: 0x0000 0x01: 0xfb6a 0x02: 0x4000 0x03: 0xffff 0x04: 0x087c 0x05: 0x0e77 0x06: 0x0f10 0x07: 0x087c 0x08: 0x01eac3 0x09: 0xffff 0x10: 0x7ff0 0x11: 0xffff 0x3e: 0x5449 0x3f: 0x2381 Thanks, Nathan