Merge "power: qpnp-fg: Add support for force loading battery data"
This commit is contained in:
commit
944b21a6a0
|
@ -308,7 +308,7 @@ static int64_t of_batterydata_convert_battery_id_kohm(int batt_id_uv,
|
|||
|
||||
struct device_node *of_batterydata_get_best_profile(
|
||||
const struct device_node *batterydata_container_node,
|
||||
const char *psy_name)
|
||||
const char *psy_name, const char *batt_type)
|
||||
{
|
||||
struct batt_ids batt_ids;
|
||||
struct device_node *node, *best_node = NULL;
|
||||
|
@ -336,17 +336,27 @@ struct device_node *of_batterydata_get_best_profile(
|
|||
* Find the battery data with a battery id resistor closest to this one
|
||||
*/
|
||||
for_each_child_of_node(batterydata_container_node, node) {
|
||||
rc = of_batterydata_read_batt_id_kohm(node,
|
||||
"qcom,batt-id-kohm",
|
||||
&batt_ids);
|
||||
if (rc)
|
||||
continue;
|
||||
for (i = 0; i < batt_ids.num; i++) {
|
||||
delta = abs(batt_ids.kohm[i] - batt_id_kohm);
|
||||
if (delta < best_delta || !best_node) {
|
||||
if (batt_type != NULL) {
|
||||
rc = of_property_read_string(node, "qcom,battery-type",
|
||||
&battery_type);
|
||||
if (!rc && strcmp(battery_type, batt_type) == 0) {
|
||||
best_node = node;
|
||||
best_delta = delta;
|
||||
best_id_kohm = batt_ids.kohm[i];
|
||||
best_id_kohm = batt_id_kohm;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
rc = of_batterydata_read_batt_id_kohm(node,
|
||||
"qcom,batt-id-kohm",
|
||||
&batt_ids);
|
||||
if (rc)
|
||||
continue;
|
||||
for (i = 0; i < batt_ids.num; i++) {
|
||||
delta = abs(batt_ids.kohm[i] - batt_id_kohm);
|
||||
if (delta < best_delta || !best_node) {
|
||||
best_node = node;
|
||||
best_delta = delta;
|
||||
best_id_kohm = batt_ids.kohm[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -175,6 +175,11 @@ module_param_named(
|
|||
first_est_dump, fg_est_dump, int, S_IRUSR | S_IWUSR
|
||||
);
|
||||
|
||||
static char *fg_batt_type;
|
||||
module_param_named(
|
||||
battery_type, fg_batt_type, charp, S_IRUSR | S_IWUSR
|
||||
);
|
||||
|
||||
struct fg_irq {
|
||||
int irq;
|
||||
unsigned long disabled;
|
||||
|
@ -1447,7 +1452,8 @@ wait:
|
|||
return 0;
|
||||
}
|
||||
|
||||
profile_node = of_batterydata_get_best_profile(batt_node, "bms");
|
||||
profile_node = of_batterydata_get_best_profile(batt_node, "bms",
|
||||
fg_batt_type);
|
||||
if (!profile_node) {
|
||||
pr_err("couldn't find profile handle\n");
|
||||
return -ENODATA;
|
||||
|
@ -1648,7 +1654,10 @@ wait:
|
|||
goto fail;
|
||||
}
|
||||
done:
|
||||
chip->batt_type = batt_type_str;
|
||||
if (fg_batt_type)
|
||||
chip->batt_type = fg_batt_type;
|
||||
else
|
||||
chip->batt_type = batt_type_str;
|
||||
chip->profile_loaded = true;
|
||||
chip->battery_missing = is_battery_missing(chip);
|
||||
if (chip->power_supply_registered)
|
||||
|
|
|
@ -43,13 +43,14 @@ int of_batterydata_read_data(struct device_node *container_node,
|
|||
* POWER_SUPPLY_RESISTANCE_ID value to be used to match
|
||||
* against the id resistances specified in the corresponding
|
||||
* battery data profiles.
|
||||
* @batt_type: Battery type which we want to force load the profile.
|
||||
*
|
||||
* This routine returns a device_node pointer to the closest match battery data
|
||||
* from device tree based on the battery id reading.
|
||||
*/
|
||||
struct device_node *of_batterydata_get_best_profile(
|
||||
struct device_node *batterydata_container_node,
|
||||
const char *psy_name);
|
||||
const char *psy_name, const char *batt_type);
|
||||
#else
|
||||
static inline int of_batterydata_read_data(struct device_node *container_node,
|
||||
struct bms_battery_data *batt_data,
|
||||
|
|
Loading…
Reference in New Issue