mbox series

[RFC,v2,0/6] power: supply: Add some fuel-gauge logic

Message ID cover.1607085199.git.matti.vaittinen@fi.rohmeurope.com
Headers show
Series power: supply: Add some fuel-gauge logic | expand

Message

Vaittinen, Matti Dec. 4, 2020, 12:39 p.m. UTC
Sorry again folks - I picked you as recipients just because I assumed
you could have something to say in here. Again, please let me know
if you wish to be dropped from CC if this gets any further.

power: supply: add sw-gauge for SOC estimation and CC correction

This RFC has still not been properly tested in HW - even if I
actually managed to run the iteration at some point of development :)
So still no accurate review or any kind of final acceptance is asked. I
am hoping to get some opinions/guidance regarding this :) All help is
highly appreciated! "The thing" for which I would like to get the
initial feedback is in patch 2 - rest of the patches give some context
to it :)

I have couple of ROHM PMIC drivers for devices with battery charger
and coulomb counter in device. Some users have asked me if these
drivers could be added upstream - and I actually think it would help
people. While evaluating these drivers I saw they do implement
some fuel-gauging/CC correcting logic - which might be useful for
other similar ICs. Hence I am wondering if I should try pulling the
logic out of IC drivers to power-supply core while leaving just IC
specific code in drivers. This RFC is first result for pulling the
logic out of drivers.

In other words, this is an early state RFC for adding some
fuel-gauge logic to power-supply core. I am overall asking if this
kind of functionality would be welcome in power-supply core, and if
yes - then I would like to get some overall direction for this.
I am for example wondering if this should be added as a own entity
which uses power-supply class underneath (in a way this RFC
introduces it) - or if it should be meld in existing power-supply
class.  But there's no point in pondering this if this kind of
functionality has no chance being accepted :)

Is this seen as potentially useful feature which should be
in-kernel? (I think this has it's place in-kernel as HW details
like coulomb-counter adjustment should really not be something
user-space should care. Another reason is that few low-power
embedded devices actually do periodical wake-up from suspend/
other low-power states just to do CC adjustment - even though
the wake-up costs some power. If this is ever to be supported
by mainline kernel - then waking up the whole user-space just
to do this CC adjustment iteration is not preferable. But that
wake-up is not covered by this RFC, it is just one motvation
behind putting this in-kernel - where it in my opinion would be
better to be generic and available for all ICs than written in
each IC specific driver).

Oh, please let me know if you wish to see some more documentation,
I can try adding something in Documentation folder too.

Changelog RFC v2:
 - lots of logic fixes.
 - rechecked units
 - changed low-voltage correction to capacity correction
 - added first draft of IC driver which could use the swgauge

Patch 1:
 - Adds cap2ocv helper (should be reworked to allow 0.1% accuracy for cap)
Patch 2:
 - Add the swgauge (better name would be nice). The main thing in this
   RFC
Patch 3, 4:
 - bring in some charger register descriptions etc for the driver
Patch 5:
 - add charger driver for ROHM BD718(27/28/78) PMICs as an example
Patch 6:
 - fix the device ID

---

Matti Vaittinen (6):
  power: supply: add cap2ocv batinfo helper
  power: supply: add sw-gauge for SOC estimation and CC correction
  mfd: prepare to support BD718xx-charger
  mfd: add BD71827 header
  power: supply: Add bd718(27/28/78) charger driver
  MFD: bd71828: differentiate bd71828 and bd71827 chargers

 drivers/mfd/rohm-bd71828.c                  |    2 +-
 drivers/power/supply/Kconfig                |   18 +
 drivers/power/supply/Makefile               |    2 +
 drivers/power/supply/bd71827-power.c        | 2162 +++++++++++++++++++
 drivers/power/supply/power_supply_core.c    |   51 +
 drivers/power/supply/power_supply_swgauge.c | 1025 +++++++++
 include/linux/mfd/rohm-bd71827.h            |  295 +++
 include/linux/mfd/rohm-bd71828.h            |   65 +
 include/linux/mfd/rohm-generic.h            |    2 +
 include/linux/power/sw_gauge.h              |  225 ++
 include/linux/power_supply.h                |   11 +
 11 files changed, 3857 insertions(+), 1 deletion(-)
 create mode 100644 drivers/power/supply/bd71827-power.c
 create mode 100644 drivers/power/supply/power_supply_swgauge.c
 create mode 100644 include/linux/mfd/rohm-bd71827.h
 create mode 100644 include/linux/power/sw_gauge.h


base-commit: 09162bc32c880a791c6c0668ce0745cf7958f576