[RFC PATCH v3 0/9] power: supply: Add some fuel-gauge logic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As usual, 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 simple-gauge for SOC estimation and CC correction

This RFC has received some testing under qemu, with recorded
battery-data and a dummy MFD driver converting the battery-data to
register-values for BD71815 PMIC driver. The testing has not really
covered a lot though. Some tests are also ran on a BeagleBoneBlack
connected to a real PMIC hwrdware - but unfortunately without a real
battery. So - this is still not tested too well.

Regarding the purpose of this RFC:

Patches 1 - 6
I hope that the patches which change the power-supply class for static
battery node information  could be properly reviewed and perhaps even
considered to be merged upstream. It'd be great if someone had the time
to test those in real HW to ensure existing stuff is not borked.
Especially the patches 4 and 6 might be of interest.

The patch 7:
This adds some simple fuel-gauge logic in kernel. I think this is
getting it's shape - but may have few hiccups left - and could benefit
from suggestions how to run the gauge thread. A few downstream setups do
use separate ROHM drivers for BD71815, BD71817, BD71827, BD71828 and
BD71879 which all contain similar fuel-gauge logic to what is implented
in simple-gauge. They poll the PMIC and compute the temperature/capacity
and zero-corrected "state of charge" and report that to the user-space.
Additionally those drivers 'calibrate' the CC based on OCV when battery
is relaxed - or when battery is fully charged. The patch 7 attempts to
make this logic generic and allows IC drivers to fill the IC specific
operations.

It is fair to say that I don't know the user-space software which is
utilizing the existing drivers - or why the SoC computation is
originally placed in-kernel. I can only assume the existing IC users
might have a bit wider smile if the SOC was reported by the kernel also
in the future.

Patches 8 and 9:
The patches 8 and 9 bring in IC level support for ROHM BD71815 and BD71828
PMIC charger IPs. It is also fairly trivial to extend the support to
ND71827 and BD71879 later. The state of these patches is not final yet,
I don't expect them to be thoroughly reviewed yet. They are provided to
give some more context.

Changelog RFC v3:
  - rename sw-gauge to simple-gauge
  batinfo:
     - kerneldoc fixes
     - add batinfo getters usable prior supply registration
     - Add constant battery aging degradation to batinfo
  simple-gauge:
      - use devm_add_action_or_reset
      - Rename to simple_gauge
      - Limit access to power_supply parameters
      - Introduce simple_gauge_drvdata
      - no need to show simple_gauge at config menu. Users should just SELECT it.
      - allow tristate
      - Add blocking 'iteration run' - loop.
      - updated the comment section
      - Fixed clamped SOC which was not updated
      - Small comment improvements
      - Don't allow negative CC after computing capacity corrections
      - Fix gauge looping when last client exits
 ROHM ic-drivers:
      - Updated BD71815 IRQ information
      - adapt to simple_gauge parameter changes
      - Initial BD71815 support
      - Use drvdata properly.
      - Sort includes
      - Prepare to provide dcin_collapse voltage from DT
      - clean unused defines
      - use OCV tables from batinfo if module params not given
      - do not directly call bd71827_voltage_to_capacity from calibration
        but use provided operation.
      - Mask the power-state from relax-condition on BD71815 as is done by
        the ROHM driver. REX state is used to do OCV => SOC conversion
        when battery is relaxed even if REX_CC was not used.
      - Clarify that we require either the module params or DT values for
        battery. Fail probe if parameters are not given.
      - Utilize degrade_cycle_uah aging degradation.
      - Get battery max and min values either as module parameters or from
        static battery node at DT.
      - Allow giving the zero correction threshold as a module param or
        compute it as 10% of "remaining battery voltage" based on max and
        min voltages given via DT.
      - Add proper MODULE_ALIAS
      - Implement VDR table reading from DT
      - Do not require fixed amount of battery parameters
      - Fix Coulomb Counter to uAh conversion
      - Fix endianess related warnings
      - clean-up comment
      - Avoid dividing by zero at VDR computation
      - Use the fwnode API instead of of_* API
      . don't assume 32bit int
      - Fix IC type prints
      - Fix the current sense resistor DT property *-ohm => *-ohms

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

---

Matti Vaittinen (9):
  dt-bindings: battery: Add temperature-capacity degradation table
  power: supply: add cap2ocv batinfo helper
  power: supply: Support DT originated temperature-capacity tables
  power: supply: Add batinfo getters usable prior supply registration
  power: supply: Add constant battery aging degradation to batinfo
  power: supply: Add batinfo functions for OCV to SOC with 0.1% accuracy
  power: supply: add simple-gauge for SOC estimation and CC correction
  mfd: bd71828, bd71815 prepare for power-supply support
  power: supply: Add bd718(15/27/28/78) charger driver

 .../bindings/power/supply/battery.yaml        |   19 +
 drivers/mfd/rohm-bd71828.c                    |   42 +-
 drivers/power/supply/Kconfig                  |   14 +
 drivers/power/supply/Makefile                 |    2 +
 drivers/power/supply/bd71827-power.c          | 2473 +++++++++++++++++
 drivers/power/supply/power_supply_core.c      |  449 ++-
 drivers/power/supply/simple-gauge.c           | 1303 +++++++++
 include/linux/mfd/rohm-bd71827.h              |  295 ++
 include/linux/mfd/rohm-bd71828.h              |   65 +
 include/linux/mfd/rohm-generic.h              |    2 +
 include/linux/power/simple_gauge.h            |  244 ++
 include/linux/power_supply.h                  |   41 +
 12 files changed, 4843 insertions(+), 106 deletions(-)
 create mode 100644 drivers/power/supply/bd71827-power.c
 create mode 100644 drivers/power/supply/simple-gauge.c
 create mode 100644 include/linux/mfd/rohm-bd71827.h
 create mode 100644 include/linux/power/simple_gauge.h

-- 
2.31.1


-- 
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND

~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =] 

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux