Currently, the best battery profile is selected only based on the
profile which has the lowest delta from the battery id. For
example, if there are two profiles and if the second one has
lowest delta with the battery id, it would get selected as best
profile. However, the selection may not go through as that
profile can be outside the range. First profile whose battery id
delta is greater than the second profile but still in the valid
range will not be selected because the second profile was given
the precedence.
Fix this problem by validating whether the battery id of the
profile is within range and update the best profile based on
that.
CRs-Fixed: 755238
Change-Id: Ife0ad0e4d68d8e096328e1e1e6a3abfd73ab7408
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
Currently we support loading battery profile data based on the
best matching profile. If there are 2 battery profiles with the
same battery id, then the profile which is defined first will be
loaded. Provide a module parameter "qpnp_fg.battery_type" so that
the user can force load a battery profile data.
Change-Id: Ie3f0fc31a09b8173db9236109b4e019473f00288
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
The optional qcom,batt-id-range-pct property will
be used to determine a valid range for a given qcom,batt-id-kohm.
This option puts a boundary on the closest match found by
of_batterydata_get_best_profile.
The advantage of this is to prevent loading battery profiles
based on battery ID resistance values which are too far off from
qcom,batt-id-kohm and thus leading to undesirable configuration
for battery related properties.
Change-Id: I9d27550c73ef626f08428d05a23354e6fd91eb20
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
Make sure that the property pointer is accessed
only if its valid.
Change-Id: I94f79440cf4903e3e719162eac8c56dd1b4c0764
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
This function simply queries POWER_SUPPLY_PROP_RESISTANCE_ID
from via the power supply framework for a given power supply.
It will find the closest matching profile contained within
batterydata_container_node which is matched via the
qcom,batt-id-kohm property.
Change-Id: I15a34b784cc23809df4db2deb583bd6c40bd182b
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
The ACC (apparent charge capacity) of the battery is a function
of the Ibat (battery current) and temperature. The ACC is used
to determine the UUC (unusable capacity of the battery).
Add the logic to parse the ibat_vs_temp_vs_acc lookup table
when specified in the battery profile.
CRs-Fixed: 639623
Change-Id: I7e2a5ae04014d88787a2050941a68832d73c3425
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
The battery-type property is a string which indicates
the type of battery. Add this property for all the batterydata.
Change-Id: I832cb222e96f1d7131761be0ab2a454404884705
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
This typo cause flat_ocv_threshold_uv value can't be read correctly,
and make adjust_soc() assign a wrong value to correction_limit_uv in
bms driver.
Change-Id: Ifc00c63070281e3adfafd3f10559f2660644af90
Signed-off-by: Wu Fenglin <fenglinw@codeaurora.org>
Add a single pr_info line to the of_batterydata load function
to print out what batterydata is loaded, if any. This will help
debug batterydata issues where it's difficult to tell what is the
currently loaded battery profile.
Change-Id: Ieeda37f82c09f9778d34ebad7cac7885e71cd64a
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
If the Battery ID is either short circuited or floating, the
batterydata loading may cause a divide by 0 warning when calculating
the Battery ID resistance.
Fix this by checking for 0 denominators before doing the divisions
and returning 0 kOhms for the Battery ID resistance.
Change-Id: Ia631d8bdbdf6be838c7cfe2ea9601da9dea45636
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
The ID resistance of some battery modules goes across several
ranges, this implementation uses an array to support multiple
IDs for one battery module.
Change-Id: I402c04e18865077b07115ba2e909ccbf74909791
Signed-off-by: Xu Kai <kaixu@codeaurora.org>
According to the kernel coding style guide, returns in macros should
be avoided. Remove them from the OF_PROP_READ macro in the
of_batterydata driver.
Change-Id: I2654bc3ce3910cb83c5222d1d1a3a698b697a6d7
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
Add the of_batterydata driver to parse device tree battery data.
Battery data contains battery profile information and is used by the
charger and the BMS drivers.
Change-Id: Ibe03800be0d51e82194c9385c6348c5a6c92711d
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>