From patchwork Thu Sep 27 07:26:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 147680 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1653306lji; Thu, 27 Sep 2018 00:27:51 -0700 (PDT) X-Google-Smtp-Source: ACcGV62fTHpW0um0Vu/07PNyvspiYhBxA3P9E4kFBiZtUwRYRvMq0i/Mk1sLXD0eLS2pISAgcyG5 X-Received: by 2002:a62:e511:: with SMTP id n17-v6mr9833743pff.210.1538033271319; Thu, 27 Sep 2018 00:27:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538033271; cv=none; d=google.com; s=arc-20160816; b=qKMlsIEomy9lW1yZk/cppCkukLY2nHEIHGuBGr0W5pPcOPOwNejy2mH6MCMxVMYRY9 B9eKV9KNk/mNyYAeisVzHlOHVaIro4MF8HsT4lDLm8K4BpJOZAQfWhfS7Vpo0TyG7qTL VoZJrI9RcpmoqgvVu1u0fYjwZcZC3z4G3xBw4geWOmMTG8FT/T1422x2TCcPm+PVst0W 5y27bvjO5DSrtnwakjbSGl1P9ODrghGhGiOY2k4jGTzkTs72neC6Nk5GhWqAMTfazL7Q YlGWA+Nwu1yiqHxWzzubLrC0NPw+HZ92mLPaL7eKwykX9betyj44JCiY8PiGrjUCOL8Q qfXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=4VmbNGK4/Krdl0b5VErXgThoZu7vAXm7F8ofWNw+h+Y=; b=0d8ubOPRhFEH6XMGWTNPUJwP0JuEzECGemlYMbOwAOJNmVCm57eqdSwekY9zDdRUFr FSteKD5tih9GrqwK5N5ZaBvbQhVQyg6z4zGQDdmmPl3dhyslaPf/mnOCjTFX3Yd3v7cr U+H40fWQMfph96N6tGxcr0wDIsJatrsiqxZTEWFI8RDklFE8/U03Bt6wruVmGRSHD8Z6 1cOtug69u2//WIT5ABUC3DqfH8QqFXClFKiixFLVey+kidRQp184w+aT7vty+ts54Ls1 rirlAonzvhAwCi+lTZYJWRyJqwSk3lDOB02p5jm42otWh3/YrHMGc9qGP4ApnMzZ0YMO niRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GBXWaozF; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i126-v6si1300620pgd.332.2018.09.27.00.27.51; Thu, 27 Sep 2018 00:27:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GBXWaozF; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726953AbeI0Nol (ORCPT + 6 others); Thu, 27 Sep 2018 09:44:41 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:37954 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726948AbeI0Nok (ORCPT ); Thu, 27 Sep 2018 09:44:40 -0400 Received: by mail-pg1-f193.google.com with SMTP id r77-v6so1267587pgr.5 for ; Thu, 27 Sep 2018 00:27:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=4VmbNGK4/Krdl0b5VErXgThoZu7vAXm7F8ofWNw+h+Y=; b=GBXWaozFl12GA1q1cUTlGwVVR+P0Bb8rD8e8VxrtYN36gA3qiFLOgYiO/JVNs2yMPI riJ4mt5JHP2UxRFqFGo2rJSzUkvbsTO3aL0VTLwbm1NPFGoWANNv6aVH+bvGFtwhtcDp nUVEh8RdqvoBYUYA/KEC7suEcSxCJdyevAYnc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=4VmbNGK4/Krdl0b5VErXgThoZu7vAXm7F8ofWNw+h+Y=; b=PhAL8Xf2ogEk2q+g0fAIX7MhrZC/kfPahn53YVzShPHRMrQlyBcvzhLII/s4VIfRNR zL4CY+eIXP6YNMWNT6nyl1wem7ddaDwd1zp2NWm3ibrfO1QBWrRSwhmut1YMkdJrtVlQ 7TmwG3a05LpyQDnOwqqA7nBBvB+3JU/G1f8T93ZP8FZq5aYK1Xq8ZHfA7qkAmIB3mj1y PdfV/8mscEOZUkPtqyum9lWwwTyIA3kP0RjrCCDgLVZGj9pT2faqu8dEDg6VLBJZQeHv Nj61UhtY67VHDRGC5XqJpcDBvcbHtJHWSmgLbTOEdexrJjEDJa+o7FUMY1exAAASl/nG HfEw== X-Gm-Message-State: ABuFfohIiaJVhjZsGaYDWDfAkF4iw+MwHDLRbgWr72q7/8EsLNlLWtpj 2Jz0wyQHdbcaj2kIbfjPdw/Vpg== X-Received: by 2002:a62:7788:: with SMTP id s130-v6mr9859304pfc.189.1538033269467; Thu, 27 Sep 2018 00:27:49 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id h12-v6sm1835018pfo.135.2018.09.27.00.27.44 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Sep 2018 00:27:48 -0700 (PDT) From: Baolin Wang To: sre@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, yuanjiang.yu@unisoc.com, baolin.wang@linaro.org, broonie@kernel.org, ctatlor97@gmail.com, linus.walleij@linaro.org Subject: [PATCH v3 1/4] power: supply: core: Introduce one property to present the battery internal resistance Date: Thu, 27 Sep 2018 15:26:54 +0800 Message-Id: <2787f18a0366576959557d05112a069dca982269.1538033078.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The internal resistance of a battery is not a constant in its life cycle, this varies over the age of the battery or temperature and so on. But we just want use one constant battery internal resistance to estimate the battery capacity. Thus this patch introduces one property to present the battery factory internal resistance for battery information. Signed-off-by: Baolin Wang --- Changes from v2: - Rename the property. - Improve the commit message. Changes from v1: - New patch in v2. --- .../devicetree/bindings/power/supply/battery.txt | 2 ++ drivers/power/supply/power_supply_core.c | 3 +++ include/linux/power_supply.h | 1 + 3 files changed, 6 insertions(+) -- 1.7.9.5 diff --git a/Documentation/devicetree/bindings/power/supply/battery.txt b/Documentation/devicetree/bindings/power/supply/battery.txt index f4d3b4a..938d027 100644 --- a/Documentation/devicetree/bindings/power/supply/battery.txt +++ b/Documentation/devicetree/bindings/power/supply/battery.txt @@ -22,6 +22,7 @@ Optional Properties: - charge-term-current-microamp: current for charge termination phase - constant-charge-current-max-microamp: maximum constant input current - constant-charge-voltage-max-microvolt: maximum constant input voltage + - factory-internal-resistance-micro-ohms: battery factory internal resistance Battery properties are named, where possible, for the corresponding elements in enum power_supply_property, defined in @@ -42,6 +43,7 @@ Example: charge-term-current-microamp = <128000>; constant-charge-current-max-microamp = <900000>; constant-charge-voltage-max-microvolt = <4200000>; + factory-internal-resistance-micro-ohms = <250000>; }; charger: charger@11 { diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index e853618..307e0995 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -579,6 +579,7 @@ int power_supply_get_battery_info(struct power_supply *psy, info->charge_term_current_ua = -EINVAL; info->constant_charge_current_max_ua = -EINVAL; info->constant_charge_voltage_max_uv = -EINVAL; + info->factory_internal_resistance_uohm = -EINVAL; if (!psy->of_node) { dev_warn(&psy->dev, "%s currently only supports devicetree\n", @@ -616,6 +617,8 @@ int power_supply_get_battery_info(struct power_supply *psy, &info->constant_charge_current_max_ua); of_property_read_u32(battery_np, "constant_charge_voltage_max_microvolt", &info->constant_charge_voltage_max_uv); + of_property_read_u32(battery_np, "factory-internal-resistance-micro-ohms", + &info->factory_internal_resistance_uohm); return 0; } diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index f807691..d089566 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -326,6 +326,7 @@ struct power_supply_battery_info { int charge_term_current_ua; /* microAmps */ int constant_charge_current_max_ua; /* microAmps */ int constant_charge_voltage_max_uv; /* microVolts */ + int factory_internal_resistance_uohm; /* microOhms */ }; extern struct atomic_notifier_head power_supply_notifier;