Re: [PATCH 2/2] dt-bindings: iio: adc: document TS voltage in AXP PMICs

Linus Walleij
2021-12-05T01:02:53Z

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

> > 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.

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.

Yours,
Linus Walleij