devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Evgeny Boger <boger@wirenboard.com>
To: Linus Walleij <linus.walleij@linaro.org>,
	Jonathan Cameron <jic23@kernel.org>
Cc: Sebastian Reichel <sebastian.reichel@collabora.com>,
	Quentin Schulz <foss+kernel@0leil.net>,
	Samuel Holland <samuel@sholland.org>,
	Maxime Ripard <maxime@cerno.tech>,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	Lars-Peter Clausen <lars@metafoo.de>,
	Chen-Yu Tsai <wens@csie.org>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	linux-sunxi@lists.linux.dev, linux-pm@vger.kernel.org
Subject: Re: [PATCH 2/2] dt-bindings: iio: adc: document TS voltage in AXP PMICs
Date: Sun, 5 Dec 2021 13:50:39 +0300	[thread overview]
Message-ID: <a45c37e5-caa3-e5e4-62d2-e2418ed95441@wirenboard.com> (raw)
In-Reply-To: <CACRpkdZ+WWz7JoyE3a1Ra8dx27YcHH6zRNcTmNJyX_vfcu0n7w@mail.gmail.com>

Hi Linus!

05.12.2021 04:02, Linus Walleij пишет:
> On Sat, Dec 4, 2021 at 4:21 PM Jonathan Cameron <jic23@kernel.org> 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)


  reply	other threads:[~2021-12-05 10:50 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-18 14:12 [PATCH 0/2] iio: adc: axp20x: add support for NTC thermistor Evgeny Boger
2021-11-18 14:12 ` [PATCH 1/2] iio:adc:axp20x: " Evgeny Boger
2021-11-22 10:48   ` Maxime Ripard
2021-12-01 10:11   ` Quentin Schulz
2021-12-01 10:42   ` Quentin Schulz
2021-11-18 14:12 ` [PATCH 2/2] dt-bindings: iio: adc: document TS voltage in AXP PMICs Evgeny Boger
2021-11-22 10:49   ` Maxime Ripard
2021-11-22 11:17     ` Evgeny Boger
2021-11-22 11:35       ` Samuel Holland
2021-11-22 11:51         ` Evgeny Boger
2021-11-29 23:58         ` Evgeny Boger
2021-12-01 10:03           ` Quentin Schulz
2021-12-01 11:02           ` Quentin Schulz
2021-12-01 15:45             ` Evgeny Boger
2021-12-03 20:47               ` Sebastian Reichel
2021-12-04 15:26                 ` Jonathan Cameron
2021-12-05  1:02                   ` Linus Walleij
2021-12-05 10:50                     ` Evgeny Boger [this message]
2021-12-05 19:46                       ` Linus Walleij
2021-11-29 23:10   ` Rob Herring
2021-12-04 15:28     ` Jonathan Cameron

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=a45c37e5-caa3-e5e4-62d2-e2418ed95441@wirenboard.com \
    --to=boger@wirenboard.com \
    --cc=devicetree@vger.kernel.org \
    --cc=foss+kernel@0leil.net \
    --cc=jernej.skrabec@gmail.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=maxime@cerno.tech \
    --cc=samuel@sholland.org \
    --cc=sebastian.reichel@collabora.com \
    --cc=wens@csie.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).