From patchwork Tue Nov 16 12:27:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 12622295 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2215C433EF for ; Tue, 16 Nov 2021 12:27:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D083F61882 for ; Tue, 16 Nov 2021 12:27:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236082AbhKPMaX (ORCPT ); Tue, 16 Nov 2021 07:30:23 -0500 Received: from mail-lf1-f50.google.com ([209.85.167.50]:37670 "EHLO mail-lf1-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236114AbhKPMaN (ORCPT ); Tue, 16 Nov 2021 07:30:13 -0500 Received: by mail-lf1-f50.google.com with SMTP id c32so52765827lfv.4; Tue, 16 Nov 2021 04:27:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=aalC5ofyXPHijBiHsgoqrQ/kcLW/eBv0HeQgHcvpoB4=; b=sUsbHyFqbILu2PLv6BuodPqDxhACAzW4ZqAdWF2IoTZ0iMLu9NWj2LWGkjSi/lmDYw RPXcbpTd+OhJhPOXv6vEZa8tX+QtzX9xwJcMcIWdB5qziqQQGVxusVyH4kBQTKtbk2kG utphzmrhi/r0fBEgxRrn0hlv5eKxXIcNfhz0RYVrPqtZfIik67gimWqIKDgooYuREkCc wpTDuaNG2n3NiCR6hYwRdqrWaBDri2VEu7Y0c4TVgw/cOxLwMm/SXJKSoB2h6PnBnz8G ZRjli3lxTUMwaPHEjUo1a47xO5P5oR91dlpZYO2VzBeAHRECg4/JgpfxSocaBXoLT5tz Jadg== X-Gm-Message-State: AOAM531ahVOnqPdnrgX+JYDmB9MxdU5fMHob5E8poZDZDWyWZ41mfaqT qOAIvljqsI1NEpFbv/1d9ng= X-Google-Smtp-Source: ABdhPJyulYjgXMfFelFdLJhLdwJWeX4lZBvTVo8ytXzSPMqyLcKBq8uKSLyz09uWLSILfxHjBI/hkQ== X-Received: by 2002:a05:6512:3f87:: with SMTP id x7mr6109171lfa.5.1637065634734; Tue, 16 Nov 2021 04:27:14 -0800 (PST) Received: from fedora (dc73szyyyyyyyyyyyyycy-3.rev.dnainternet.fi. [2001:14ba:16ee:fa00::4]) by smtp.gmail.com with ESMTPSA id t15sm1745407lfp.181.2021.11.16.04.27.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 04:27:14 -0800 (PST) Date: Tue, 16 Nov 2021 14:27:07 +0200 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Sebastian Reichel , Rob Herring , Matti Vaittinen , Lee Jones , Linus Walleij , rostokus@gmail.com, fan.chen@mediatek.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-power@fi.rohmeurope.com Subject: [RFC PATCH v3 5/9] power: supply: Add constant battery aging degradation to batinfo Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Few batteries can be modelled to degrade at constant rate for each increased cycle. Add degradation constant for such simple model to batinfo. Signed-off-by: Matti Vaittinen --- RFCv3: New patch --- drivers/power/supply/power_supply_core.c | 3 +++ include/linux/power_supply.h | 1 + 2 files changed, 4 insertions(+) diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index 47176ed2570b..ebc961b5aa45 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -639,6 +639,7 @@ int power_supply_dev_get_battery_info(struct device *dev, info->resist_table = NULL; info->temp_dgrd_values = 0; info->temp_dgrd = NULL; + info->degrade_cycle_uah = 0; for (index = 0; index < POWER_SUPPLY_OCV_TEMP_MAX; index++) { info->ocv_table[index] = NULL; @@ -689,6 +690,8 @@ int power_supply_dev_get_battery_info(struct device *dev, dev_warn(dev, "%s unknown battery type\n", value); } + fwnode_property_read_u32(battery_node, "degrade-cycle-microamp-hours", + &info->degrade_cycle_uah); fwnode_property_read_u32(battery_node, "energy-full-design-microwatt-hours", &info->energy_full_design_uwh); fwnode_property_read_u32(battery_node, "charge-full-design-microamp-hours", diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index ef7db73a5bd1..c5118265b3ab 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -403,6 +403,7 @@ struct power_supply_battery_info { int resist_table_size; int temp_dgrd_values; struct power_supply_temp_degr *temp_dgrd; + int degrade_cycle_uah; }; extern struct atomic_notifier_head power_supply_notifier;