From patchwork Tue Mar 1 12:42:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 547453 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91046C433FE for ; Tue, 1 Mar 2022 12:45:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234433AbiCAMpk (ORCPT ); Tue, 1 Mar 2022 07:45:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232420AbiCAMpk (ORCPT ); Tue, 1 Mar 2022 07:45:40 -0500 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 086919858D for ; Tue, 1 Mar 2022 04:44:59 -0800 (PST) Received: by mail-lf1-x12b.google.com with SMTP id j15so26603416lfe.11 for ; Tue, 01 Mar 2022 04:44:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0tcocVIkOCPzGpdROFxsT753ixUhU49aJwL/lTfVMnE=; b=w91vKAjBFIRcEvV6z4viPzJGw/HeDfSabkwGFg+aYoqHuXu+1EvckKwJJjX+csDTw0 yMg8Y9kvQ9RnAmLGH0hbmR7iLG6Qj1Xv7tG3mDrfT0mJT7QoCGlgpQ0H1cLL54tWTOOl erJPikXXEXWEDk5XQGX8tonfaz3XOm4ZS+ZOijXQdO5QfghbnWyyR7AzCZ6uwBSltnor wdGC26klIYokwRFcVrROlxBFQK+rlriQDjk4QzkgoTHccqVvPEitYH8qV/VgJG20YrD5 +CJpgK/hAR10EgRG3fJPDXODqgxPH9fOI27FhkJY5gomuz3sszVWKhnkzJMe1W7rqE+N zQHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0tcocVIkOCPzGpdROFxsT753ixUhU49aJwL/lTfVMnE=; b=cIAF4e1TixF0HXHaB5eEp/LAtUKFeYHKgeqmeLM+YLj1ZixyEuGrgzKSMfsBecZhXa iUgI7U28DIW+a8C2ES3UDCPYbim9Bga5+vPrURF9B6a0kRviawSTveKuwvA/m68GOD0Z lYgoaMc4jo0n3ZykWMQh0ZjYW29cW+aVAq/W+1eNM1WjbIdZTbZJWX/bDYPHdSFTaou1 0oULoXJb6p1S0F2jA97og/NG2/SU2k4Cn3d9dfJLabTbZyIseEs4YrmKmw4vkkRGgJlp kx9W984fG6yYA/Atd9LsUuGVBUvYWkC2DkWOn+fKLCkO201UGbSPcHau9v5/PiSQspfU gcmw== X-Gm-Message-State: AOAM530Zib1GV//hoMxQ10K8tes3adt55MO7JPs0oH55bVz6UeeQZY0a Ssv97zKHOhrB/No9Fla0MP9CGUX0B5DPQRPj X-Google-Smtp-Source: ABdhPJxuR8BW7zJzU3NkoFvhDb41wtZFnU6P8ZHcbvkhrBRzoeuktbhrDPZs4FOuYq8nwc0PAT3JXQ== X-Received: by 2002:ac2:5492:0:b0:43f:1c2e:b04c with SMTP id t18-20020ac25492000000b0043f1c2eb04cmr16373479lfk.502.1646138697407; Tue, 01 Mar 2022 04:44:57 -0800 (PST) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id g18-20020a19ee12000000b00443af3721f2sm1467944lfb.237.2022.03.01.04.44.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Mar 2022 04:44:57 -0800 (PST) From: Linus Walleij To: Sebastian Reichel , Marcus Cooper Cc: linux-pm@vger.kernel.org, Matti Vaittinen , Linus Walleij , devicetree@vger.kernel.org Subject: [PATCH 1/2] dt-bindings: power: supply: ab8500_fg: Add line impedance Date: Tue, 1 Mar 2022 13:42:53 +0100 Message-Id: <20220301124254.2338270-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org To improve the inner resistance measurement of the battery we need to account for the line impedance of the connector to the battery. Cc: devicetree@vger.kernel.org Signed-off-by: Linus Walleij Acked-by: Rob Herring --- .../bindings/power/supply/stericsson,ab8500-fg.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/power/supply/stericsson,ab8500-fg.yaml b/Documentation/devicetree/bindings/power/supply/stericsson,ab8500-fg.yaml index 54ac42a9d354..2ce408a7c0ae 100644 --- a/Documentation/devicetree/bindings/power/supply/stericsson,ab8500-fg.yaml +++ b/Documentation/devicetree/bindings/power/supply/stericsson,ab8500-fg.yaml @@ -25,6 +25,11 @@ properties: $ref: /schemas/types.yaml#/definitions/phandle deprecated: true + line-impedance-micro-ohms: + description: The line impedance between the battery and the + AB8500 inputs, to compensate for this when determining internal + resistance. + interrupts: maxItems: 5 From patchwork Tue Mar 1 12:42:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 547736 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEE7AC433F5 for ; Tue, 1 Mar 2022 12:45:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232420AbiCAMpw (ORCPT ); Tue, 1 Mar 2022 07:45:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234809AbiCAMpw (ORCPT ); Tue, 1 Mar 2022 07:45:52 -0500 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26DA88D6AC for ; Tue, 1 Mar 2022 04:45:11 -0800 (PST) Received: by mail-lf1-x130.google.com with SMTP id bu29so26763106lfb.0 for ; Tue, 01 Mar 2022 04:45:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8dogCVIaGLNn7gaQQX6eAeL47siMQWDzUECuKLHBWVE=; b=FOfMeL4HppckZVBWJ6QRjSghKNOJz+yPIwRljMLCTS4qDx73iAqBdNqB4kG0oMftxR dyQ63t4CPLw4hTAuGSy+4KrPpIJuTni+zgtjXdZSYlQ+mf41bisXq2JzbGk2rgEaHzYX mfgaMoQKuQjkJbkaZVCv1i4U7EUvyz6teW1+xrDV95MryYLemk76xrOKE/p1Xy6LDm2V cYytVHn5v8d1loYwOBbgR/pg76jnhOaTRZqT0b7l4KtD4656A5TzMmxfQCSBKSadzkJW oMXzld5z0zb6/iFHLmhud1Wi7hsfMXiYglqcL5kd/zXTvNT8iCJKMGqvmQUMSZPmLxuy 79ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8dogCVIaGLNn7gaQQX6eAeL47siMQWDzUECuKLHBWVE=; b=J5beEa5i1abja5q+uIEbtvFGyVjJvFNx+/BFhEf++55DgrP2RW3kTIhZsqZFCGYarS aqicdhwnkHTxAdb16BUbqIMRlJvd/92GltfblMPGhXePhA0elCCixdvN90lXvTWQb4er pA2BBTTep74t5VMgtjddjCwWvozQiMEC4leSNQuD2dLI4ZiM5d4aottkAD9CNlY2VZSR pUx2pF2fZxqNm0k3JzDDSFDJNPO/2x3W81N/c9EEswvdQCZXC0ZNbQeqrHlAXF8hKE6M 9+9IXwdCElfAwY8QdlQEM5e9yAKNgIGGwUpCe20mjGZWROYqCOgDzWWxTTZu6YkGTjqL /Q2w== X-Gm-Message-State: AOAM533N9QHfpePxSvNzPxg1/8CAhEmdLO64LVKxPVeYR01sNHbqoGwN u3Ra393Q6wReyXISkEDS+8Qwng== X-Google-Smtp-Source: ABdhPJzny9U8oWNrLuiII2AWsMf6ub28jbnBXkWVIP+l5yYA4iH2F58Bgxm+/SqYDRHewd2tRQcOOA== X-Received: by 2002:ac2:521c:0:b0:443:2ef2:d690 with SMTP id a28-20020ac2521c000000b004432ef2d690mr15391241lfl.258.1646138709497; Tue, 01 Mar 2022 04:45:09 -0800 (PST) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id g18-20020a19ee12000000b00443af3721f2sm1467944lfb.237.2022.03.01.04.45.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Mar 2022 04:45:09 -0800 (PST) From: Linus Walleij To: Sebastian Reichel , Marcus Cooper Cc: linux-pm@vger.kernel.org, Matti Vaittinen , Linus Walleij Subject: [PATCH 2/2] power: supply: ab8500_fg: Account for line impedance Date: Tue, 1 Mar 2022 13:42:54 +0100 Message-Id: <20220301124254.2338270-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220301124254.2338270-1-linus.walleij@linaro.org> References: <20220301124254.2338270-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org We add the line impedance to the inner resistance determined from the battery voltage or other means to improve the capacity estimations. Signed-off-by: Linus Walleij --- drivers/power/supply/ab8500_fg.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c index 1abe10c7ff2a..3ae8086907de 100644 --- a/drivers/power/supply/ab8500_fg.c +++ b/drivers/power/supply/ab8500_fg.c @@ -213,6 +213,7 @@ struct ab8500_fg { int init_cnt; int low_bat_cnt; int nbr_cceoc_irq_cnt; + u32 line_impedance_uohm; bool recovery_needed; bool high_curr_mode; bool init_capacity; @@ -910,6 +911,9 @@ static int ab8500_fg_battery_resistance(struct ab8500_fg *di, int vbat_uncomp_uv resistance = bi->factory_internal_resistance_uohm / 1000; } + /* Compensate for line impedance */ + resistance += (di->line_impedance_uohm / 1000); + dev_dbg(di->dev, "%s Temp: %d battery internal resistance: %d" " fg resistance %d, total: %d (mOhm)\n", __func__, di->bat_temp, resistance, di->bm->fg_res / 10, @@ -3098,6 +3102,11 @@ static int ab8500_fg_probe(struct platform_device *pdev) return ret; } + if (!of_property_read_u32(dev->of_node, "line-impedance-micro-ohms", + &di->line_impedance_uohm)) + dev_info(dev, "line impedance: %u uOhm\n", + di->line_impedance_uohm); + psy_cfg.supplied_to = supply_interface; psy_cfg.num_supplicants = ARRAY_SIZE(supply_interface); psy_cfg.drv_data = di;