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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C482C433FE for ; Sun, 5 Dec 2021 10:50:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233018AbhLEKyM (ORCPT ); Sun, 5 Dec 2021 05:54:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233015AbhLEKyL (ORCPT ); Sun, 5 Dec 2021 05:54:11 -0500 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0825BC061714 for ; Sun, 5 Dec 2021 02:50:44 -0800 (PST) Received: by mail-lj1-x22a.google.com with SMTP id 207so15258136ljf.10 for ; Sun, 05 Dec 2021 02:50:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wirenboard-com.20210112.gappssmtp.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=2s+VwgSqLqvkFO3wYIggCnaS4ihJvSlM944/U7Hrs1s=; b=w4yffush2DrvoU77h+0CwkxMF1i8hvsyKLfm2H7bf0L12rO234gPgRH1JTP+PWwmVX IrRQHEt/dlwQ3oJxrTPxabG6Nqhuhw5cm3vZ+9cmXbLvyCkp4y+wbwiIddyI15euUTFs LMuqpdFUVSNRJPqIqepb9CH9R44jlxkk34RFEstj3iHfB+qGb8uFWkpGmlRj9m42eDwr dUe3w1EcHZeJGtHlcR2r1gLsSuCSADB/Y3jbWR5ih2b2OUM6Bm+8TgfEkrBuOXbST3xf woULq9moiOe66Ur4zmyspBwWquWhiF0VGj77Zly3JHAn4/x7+Rf6yBanROBd7ZhfdOhS CtqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=2s+VwgSqLqvkFO3wYIggCnaS4ihJvSlM944/U7Hrs1s=; b=UHliqeHoAQqDONhf3MecvSiqinYoxzWClQZ+LCy6XhAtIE+lBHB/wStjw9ujJfy2xC xqEb63rXJdyf6cx7ab2mjIHB8H+1v7vAPB1WXNUIYdnZ171w5ksgvcccmBSkMMxCXV6C dtaPeVfF2gxMw0qPH+HR8N4U93gyxJz2n4/HJkqQJ/FV38jrKgDmroEZG20hj2FWA4Rh i5XX/iXx7m03f3FG/CwW6VDAO2Ll+Ca0W25eBNGBs9phi6aWBoteWZqfUk1Mwb/AEP5S 3jTMnkfRl/SfCrkpwtrBqyvnPkuCsGmfKuD+7Uq5IgMpvV7DbnxZO8fkyzzE9MWD+cn1 +4rw== X-Gm-Message-State: AOAM5334PO9/wK6+D86kYzuAkcHN4JGqQC4bJuHKgyItCLUFW0Wehnp4 bN3qayIOuzSxx/H0cpgEI237cA== X-Google-Smtp-Source: ABdhPJxfihr3Fi6TaU5fQnGybICickaoNBBFCHrcjLqorb6H7LfDDlD/mDM1RkbUqZoMHrjNTsUiFQ== X-Received: by 2002:a2e:7216:: with SMTP id n22mr28842986ljc.44.1638701442018; Sun, 05 Dec 2021 02:50:42 -0800 (PST) Received: from [192.168.1.213] (81.5.99.121.dhcp.mipt-telecom.ru. [81.5.99.121]) by smtp.googlemail.com with ESMTPSA id h6sm1046507lfv.202.2021.12.05.02.50.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 05 Dec 2021 02:50:41 -0800 (PST) Subject: Re: [PATCH 2/2] dt-bindings: iio: adc: document TS voltage in AXP PMICs To: Linus Walleij , Jonathan Cameron Cc: Sebastian Reichel , Quentin Schulz , Samuel Holland , Maxime Ripard , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, Lars-Peter Clausen , Chen-Yu Tsai , Jernej Skrabec , linux-sunxi@lists.linux.dev, linux-pm@vger.kernel.org References: <20211118141233.247907-1-boger@wirenboard.com> <20211118141233.247907-3-boger@wirenboard.com> <20211122104915.zism6uadgwxjz5d2@gilmour> <35630e89-4988-a6a9-b801-0e9e44419684@sholland.org> <206c2a66-42b9-7e07-66c3-6007b010c996@wirenboard.com> <20211201110241.kts5caycdmzqtp3i@fiqs> <4fd167ed-d5dc-358a-00f5-6590f4c20a68@wirenboard.com> <20211203204754.2ucaiiwyrvbtwgbz@earth.universe> <20211204152621.4f15b3d0@jic23-huawei> From: Evgeny Boger Message-ID: Date: Sun, 5 Dec 2021 13:50:39 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Hi Linus! 05.12.2021 04:02, Linus Walleij пишет: > On Sat, Dec 4, 2021 at 4:21 PM Jonathan Cameron wrote: > >> If we were going to do something like this, I'd see the battery as a >> consumer of the the temperature measurement from the NTC (might also consume other >> things from axp directly). So it should be >> >> Temperature / events flow. >> >> battery <---temperature----- NTC driver <--Voltage---- axp > That's the idea. > > I think the battery will get a handle on a thermal zone and then > you get the temperature from that. > >> Threshold configuration flow >> >> battery --temp thresh-----> NTC driver ---volt thres--> axp > I don't understand this so not commenting. > >>>> Personally, I think better approach with NTCs is to place the >>>> resistance-temperature tables for bunch of models to .dtsi >>>> files, describe the thermistor node in DT and then make all drivers (hwmon >>>> NTC, iio-afe, this one) to use this data in the same way >>>> it's done with monitored-battery node. > The DT maintainers are not happy about the device tree being used > as a general data container. The rule of thumb is that things that are > configurable should be in the device tree, things which are hard data > from a datasheet should be in a struct in the driver, and the compatible > string tells you which data to use. > > For an NTC the resistance-to-temperature is a clear case of data from > a datasheet and should not be in the device tree but in a table in > the kernel. > >> Agreed those tables would be needed whatever the solution. We might >> stick to 'standard' tables for simple cases but someone will always wire >> a circuit up that does something we haven't thought of. > What we usually do is model the wiring in the device tree like we (I) have > already done with much pain in: > Documentation/devicetree/bindings/hwmon/ntc-thermistor.yaml Earlier in this thread I mentioned our use case with AXP221s: we ended up wiring 10k NTC in series with 12k fixed resistance. The only reason was to work around poorly-designed AXP NTC detection "feature", which would turn off protection whenever the voltage on TS pin drops below 0.2V. How would you suggest to handle such a wiring? > >>> Linus W. recently sent a series for NTC support in power-supply >>> core, please synchronize with him (added to Cc): >>> >>> https://lore.kernel.org/linux-pm/20211122234141.3356340-1-linus.walleij@linaro.org/ > For the type of battery described in > Documentation/devicetree/bindings/power/supply/battery.yaml > a thermistor node inside the battery will be needed and then code > added to the power management core to spawn a OF-based > platform device from that. > > battery: battery { > compatible = "simple-battery"; > > ntc-resistor { > ... > }; > }; > > For the Samsung batteries my plan is to spawn a platform device from inside the > Samsung battery driver and add pull-down resistor value and > compatible using software nodes from within the kernel. In this example, the ntc-resistor node will be handled by current NTC hwmon driver, right? Frankly, I'm quite confused about hwmon vs iio choice in this case. Wouldn't it be better to use iio here, say, by extending iio-afe? > > Since I already have the compatible of the battery itself, I know > which thermistor this is and how it is mounted with an ID resistor > as pull-down and Samsung batteries can just hardcode that from the > kernel without > modeling the resistor in the device tree at all. As for pull-down it's the same for AXP, the only difference is there will be fixed injection current instead. But you still need to describe the particular NTC model in device tree, right? > > Yours, > Linus Walleij -- С уважением, Евгений Богер / Evgeny Boger CTO, Wiren Board Team https://wirenboard.com/ru +7 495 150 66 19 (# 33)