Commit Graph

14 Commits

Author SHA1 Message Date
Subbaraman Narayanamurthy f0cbe745aa of_batterydata: Improve the selection of battery profile
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>
2014-11-20 16:28:57 -08:00
Subbaraman Narayanamurthy 2771cbc61b power: qpnp-fg: Add support for force loading battery data
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>
2014-10-22 13:53:15 -07:00
Linux Build Service Account ebb4cfa240 Merge "of_batterydata: add qcom,batt-id-range-pct support" 2014-08-10 04:10:19 -07:00
David Keitel b76d26fa7f of_batterydata: add qcom,batt-id-range-pct support
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>
2014-08-07 00:19:26 -07:00
Anirudh Ghayal d667521234 of_batterydata: Fix NULL pointer access
Make sure that the property pointer is accessed
only if its valid.

Change-Id: I94f79440cf4903e3e719162eac8c56dd1b4c0764
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
2014-08-06 19:23:52 +05:30
David Keitel 53478aac6e of_batterydata: add of_batterydata_get_best_profile API
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>
2014-07-29 17:47:20 -07:00
Anirudh Ghayal 2399ea65fe power: batterydata: Add the ibat vs temp vs ACC lookup table
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>
2014-04-29 09:46:51 +05:30
Anirudh Ghayal f3facca0c8 ARM: dts: msm: Add battery-type DT property
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>
2013-12-24 16:43:46 +05:30
Wu Fenglin c9c6f2fb9f of: batterydata: fix a typo on flat-ocv-threshold-uv property reading
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>
2013-11-19 11:49:25 +08:00
Xiaozhe Shi c6da3ea239 of: batterydata: add a kernel log if battery data is loaded
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>
2013-09-30 14:50:27 -07:00
Xiaozhe Shi 18d5d63d29 of_batterydata: Fix possible divide by 0 conditions
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>
2013-09-05 14:54:32 -07:00
Xu Kai 239e49cc2c of: batterydata: support batt-id-kohm array
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>
2013-09-04 17:28:46 -07:00
Xiaozhe Shi 7be9af3017 of: batterydata: remove return from macro.
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>
2013-09-04 17:13:51 -07:00
Xiaozhe Shi 5346956160 of: batterydata: Introduce DT support for battery data
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>
2013-09-04 17:11:19 -07:00