axppmic803, more sensors

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

axppmic803, more sensors

Krystian Lewandowski-2
Hi,

I'm trying to improve Pinebook experience on OpenBSD. I added a few more
sensors to axppmic 803.

I have two boards I tested this patch on:
- Pinebook: axppmic0 at sxirsb0 addr 0x3a3: AXP803
$ sysctl hw.sensors.axppmic0
hw.sensors.axppmic0.temp0=42.55 degC
hw.sensors.axppmic0.volt0=3.85 VDC (battery voltage)
hw.sensors.axppmic0.current0=0.00 A (battery charging current)
hw.sensors.axppmic0.current1=0.98 A (battery discharging current)
hw.sensors.axppmic0.amphour0=0.00 Ah (battery maximum capacity), WARNING
hw.sensors.axppmic0.amphour1=0.00 Ah (battery current capacity), WARNING
hw.sensors.axppmic0.indicator0=Off (ACIN)
hw.sensors.axppmic0.indicator1=Off (VBUS)
hw.sensors.axppmic0.indicator2=On (battery present), OK
hw.sensors.axppmic0.indicator3=Off (battery charging)
hw.sensors.axppmic0.percent0=74.00% (battery percent), OK


- A64+: axppmic0 at sxirsb0 addr 0x3a3: AXP803
$ sysctl hw.sensors.axppmic0
hw.sensors.axppmic0.temp0=49.14 degC
hw.sensors.axppmic0.volt0=0.00 VDC (battery voltage)
hw.sensors.axppmic0.current0=0.00 A (battery charging current)
hw.sensors.axppmic0.current1=0.00 A (battery discharging current)
hw.sensors.axppmic0.amphour0=0.00 Ah (battery maximum capacity), WARNING
hw.sensors.axppmic0.amphour1=0.00 Ah (battery current capacity), WARNING
hw.sensors.axppmic0.indicator0=On (ACIN), OK
hw.sensors.axppmic0.indicator1=Off (VBUS)
hw.sensors.axppmic0.indicator2=Off (battery present)
hw.sensors.axppmic0.indicator3=Off (battery charging)
hw.sensors.axppmic0.percent0=100.00% (battery percent), WARNING

Unfortunately, I wasn't able to test hw.sensors.axppmic0.amphours.

WARNING is presented when specific bit for given field marks the value as
invalid - this follow existing implementation.

And hw.sensors.axppmic0.percent0 also sets WARN and CRIT when "warn" and
"shut" thresholds are met.

--
Krystian

sys_dev_fdt_axppmic.c.patch (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: axppmic803, more sensors

Mark Kettenis
> Date: Thu, 8 Aug 2019 18:32:04 +0200
> From: Krystian Lewandowski <[hidden email]>
>
> Hi,
>
> I'm trying to improve Pinebook experience on OpenBSD. I added a few more
> sensors to axppmic 803.
>
> I have two boards I tested this patch on:
> - Pinebook: axppmic0 at sxirsb0 addr 0x3a3: AXP803
> $ sysctl hw.sensors.axppmic0
> hw.sensors.axppmic0.temp0=42.55 degC
> hw.sensors.axppmic0.volt0=3.85 VDC (battery voltage)
> hw.sensors.axppmic0.current0=0.00 A (battery charging current)
> hw.sensors.axppmic0.current1=0.98 A (battery discharging current)
> hw.sensors.axppmic0.amphour0=0.00 Ah (battery maximum capacity), WARNING
> hw.sensors.axppmic0.amphour1=0.00 Ah (battery current capacity), WARNING
> hw.sensors.axppmic0.indicator0=Off (ACIN)
> hw.sensors.axppmic0.indicator1=Off (VBUS)
> hw.sensors.axppmic0.indicator2=On (battery present), OK
> hw.sensors.axppmic0.indicator3=Off (battery charging)
> hw.sensors.axppmic0.percent0=74.00% (battery percent), OK
>
>
> - A64+: axppmic0 at sxirsb0 addr 0x3a3: AXP803
> $ sysctl hw.sensors.axppmic0
> hw.sensors.axppmic0.temp0=49.14 degC
> hw.sensors.axppmic0.volt0=0.00 VDC (battery voltage)
> hw.sensors.axppmic0.current0=0.00 A (battery charging current)
> hw.sensors.axppmic0.current1=0.00 A (battery discharging current)
> hw.sensors.axppmic0.amphour0=0.00 Ah (battery maximum capacity), WARNING
> hw.sensors.axppmic0.amphour1=0.00 Ah (battery current capacity), WARNING
> hw.sensors.axppmic0.indicator0=On (ACIN), OK
> hw.sensors.axppmic0.indicator1=Off (VBUS)
> hw.sensors.axppmic0.indicator2=Off (battery present)
> hw.sensors.axppmic0.indicator3=Off (battery charging)
> hw.sensors.axppmic0.percent0=100.00% (battery percent), WARNING
>
> Unfortunately, I wasn't able to test hw.sensors.axppmic0.amphours.
>
> WARNING is presented when specific bit for given field marks the value as
> invalid - this follow existing implementation.
>
> And hw.sensors.axppmic0.percent0 also sets WARN and CRIT when "warn" and
> "shut" thresholds are met.

Hi Krystian,

Thanks for submitting this diff.  I don't have a pinebook myself so I
couldn't test the battery monitoring part of the PMIC when I wrote the
driver.

The downside of the approach you've taken is that the battery sensors
show up on all boards, even those that don't support a battery to be
connected.

Looking at the latest Linux device trees I noticed that there is a
"battery-power-supply" sub-node.  It would be nice if we could enable
the battery sensors only if that sub-node is present and not diabled.
Downside is that this means you'll need a fairly bleeding-edge device
tree for these sensors to show up.

With that in mind, it probably makes sense to structure the driver in
a slightly different way, keeping the battery sensors in a separate
array.  I'm currently playing a little bit with that to see what would
work best.