power: pm8921-bms: adjust for FCC calculation

When charging finishes with a full battery, the bms driver calculates
last_real_fcc. This parameter will be preserved between reboots.

Also the battery temperature when last_real_fcc is saved and
preserved between reboots along with last_real_fcc.

Since we are creating additional parameters whose set functions are
different from the others, move all of them to use module param with
accessor functions. Create macros to easily define accessor functions.
While at it change last_rbatt, last_ocv_uv parameters to be updated
only when a valid reading is available from the hardware or when the
userspace programs a new value.

When userspace updates the last_real_fcc and last_real_fcc_batt_temp
we create another adjusted table similar to fcc vs temperature filling up
its entries based on last_real_fcc and last_real_fcc_batt_temp. Note
that the ratios between FCCs at various temperatures are kept the same.

This new adjusted fcc vs temperature table reflects the fcc of the battery
more accurately and the algorithm is updated to use this table when
available. The scalingfactor is not used along with this adjusted table.

Change-Id: Ic1befd07b17fa16889e593fdec51021be4eeb1d5
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
1 file changed