From 5b8c5bca158083fa5558d192b0eb5497e667b364 Mon Sep 17 00:00:00 2001 From: liuyc20 Date: Sat, 9 Oct 2021 11:15:33 +0800 Subject: [PATCH] power: cw2217 fg add fcc/fcc_design info add fcc/fcc_design info to charge policy. Change-Id: I3db04ae158538c1a8761938a7863e31226ba647d Signed-off-by: liuyc20 Reviewed-on: https://gerrit.mot.com/2086300 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Huosheng Liao Submit-Approved: Jira Key --- .../cw2217b_fg_mmi/cw2217B_fuel_gauge_base.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/power/cw2217b_fg_mmi/cw2217B_fuel_gauge_base.c b/drivers/power/cw2217b_fg_mmi/cw2217B_fuel_gauge_base.c index d67cb118d95c..6b36528fb83b 100644 --- a/drivers/power/cw2217b_fg_mmi/cw2217B_fuel_gauge_base.c +++ b/drivers/power/cw2217b_fg_mmi/cw2217B_fuel_gauge_base.c @@ -125,6 +125,8 @@ struct cw_battery { int cycle; int soh; int fw_version; + int fcc_design; + int fcc; #if 0 long stb_current; #endif @@ -762,7 +764,6 @@ static int cw_parse_dts(struct cw_battery *cw_bat) struct device_node *np = cw_bat->client->dev.of_node; struct device_node *batt_profile_node = NULL; int rc; - int i = 0; batt_profile_node = cw_get_profile_by_serialnumber(np); if (!batt_profile_node) @@ -772,6 +773,10 @@ static int cw_parse_dts(struct cw_battery *cw_bat) if (rc < 0) cw_info("error,get profile_info fail from dts,exit \n"); + rc = of_property_read_u32(batt_profile_node, "fcc_design", &cw_bat->fcc_design); + if (rc < 0) + cw_info("error,get fcc_design,exit \n"); + return rc; } @@ -832,6 +837,12 @@ static int cw_battery_get_property(struct power_supply *psy, case POWER_SUPPLY_PROP_TECHNOLOGY: val->intval = POWER_SUPPLY_TECHNOLOGY_LION; break; + case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: + val->intval = cw_bat->fcc_design; + break; + case POWER_SUPPLY_PROP_CHARGE_FULL: + val->intval = (cw_bat->fcc_design * cw_bat->soh)/100; + break; case POWER_SUPPLY_PROP_TEMP: val->intval = cw_bat->temp; break; @@ -851,6 +862,8 @@ static enum power_supply_property cw_battery_properties[] = { POWER_SUPPLY_PROP_VOLTAGE_NOW, POWER_SUPPLY_PROP_CURRENT_NOW, POWER_SUPPLY_PROP_TECHNOLOGY, + POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, + POWER_SUPPLY_PROP_CHARGE_FULL, POWER_SUPPLY_PROP_TEMP, }; #endif