Skip to content

max170xx: Battery gauge configuration

According to docs, max17055 requires some inputs to correctly configure its algorithm:

  • battery label capacity (DesignCap)
  • empty voltage (VEmpty)
  • charge voltage (VChg)
  • charge termination current (ICHGTerm)

It can also be configured in a more advanced way by providing it a full set of data about battery characteristics, but that's optional. The driver currently implements that full configuration path, but only when using platform data - there's no way to set it from device tree.

When setting the new config values, the gauge model has to be refreshed (Refresh bit in ModelCfg register). It shouldn't happen at every boot though since that doesn't allow the gauge to calibrate itself over time. It should only happen once after the gauge configuration has been reset (by taking the battery off). This can be done by checking the STATUS_POR_BIT in MAX17042_STATUS register, which is initially set after a gauge reset, and by unsetting it once the initial configuration is applied.

This should allow the gauge to start with a reasonable values and then actually learn to make the outputs more accurate over time.

TODO:

  • split into multiple commits
  • make sure other chips than max17055 aren't broken by this
  • recheck the termination current values
  • I guess the new device tree properties should be put into a new node representing the battery itself, since currently they specify behavior instead of describing hardware
Edited by Sebastian Krzyszkowiak

Merge request reports