From patchwork Thu May 11 13:42:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 99652 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp738684qge; Thu, 11 May 2017 06:43:16 -0700 (PDT) X-Received: by 10.84.238.9 with SMTP id u9mr558220plk.126.1494510195942; Thu, 11 May 2017 06:43:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494510195; cv=none; d=google.com; s=arc-20160816; b=sXsguoUUhT649CZ7mFtqJOz1VYXBnjO7mrajKxE0L4qGwMzez3D3UorrfVa0xwJeRV NRm482UfQJ0UKZvAoVRM1X9QZo9kHx4o9XhTV9ONh7pbZoLdscn7HdhRAUxvQdh1ws7H AICogcEWEpVcRvLOi1uE5TkfauznaMOhDUr0kdjCpjhvkr5EE33jzqElZ0h619j+BXB2 vJ12/Fu7/dXBwCCyIu959DQIvm4kbfJHNRIXC3kiwkJN/mp4lLwR0OF5khb1sJLBFnrH IryM1vMGJ9bwaQLca7K+5RyXLrpUAmPQ9ipkQ7ek14Y0Z7P5nODzfCtPzV0hxGb3SNZE 3ArQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=zrj6MFFZgz7589P+4hhm+SaNRijZ9mtqLgLIazC99nA=; b=GgqRmeFoj5/BrXzmCUSTWAfhKDGkm8x2TkMnnwxILhKqf3ED1JPq1LZaIUDESZOyJz 5hHbvtrPuiFLCaP9008z12SKbOx8ek6ddZpPdAZAVz+EFnI0TPZ3KSNDZDLbgexI2CCZ OIEETyec3zDmnYY8W975KLhVmSSGao6E/4TOHwt/Y4C7gDt1/zZ0rSqmabdtWAOMa3gi /xqhCr8gjF+vEnNMNNwL+6gAt29OQLPGXwRqYcLP1Z6ixh+kqqYuh7urmKvpO4znUmR+ dwFZTB2JFSp4bd7g9Cz3K0Et9Zfbz5PC102T6/LnxmJeXIVAO9GerAcYtexL6N+DtTSJ Sy3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z61si185061plb.68.2017.05.11.06.43.14; Thu, 11 May 2017 06:43:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932474AbdEKNmq (ORCPT + 25 others); Thu, 11 May 2017 09:42:46 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:34111 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755566AbdEKNmm (ORCPT ); Thu, 11 May 2017 09:42:42 -0400 Received: by mail.free-electrons.com (Postfix, from userid 110) id 773DC21D45; Thu, 11 May 2017 15:42:40 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 36A4320F67; Thu, 11 May 2017 15:42:40 +0200 (CEST) From: Quentin Schulz To: sre@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, wens@csie.org Cc: Quentin Schulz , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, liam@networkimprov.net, thomas.petazzoni@free-electrons.com, linux-sunxi@googlegroups.com Subject: [PATCH 1/4] power: supply: axp20x_battery: add support for DT battery Date: Thu, 11 May 2017 15:42:17 +0200 Message-Id: <20170511134221.5569-2-quentin.schulz@free-electrons.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170511134221.5569-1-quentin.schulz@free-electrons.com> References: <20170511134221.5569-1-quentin.schulz@free-electrons.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds support in X-Powers AXP20X and AXP22X battery driver for a fixed battery in DT. It will take the minimum supported voltage by the battery as defined in the battery DT node and set the V_OFF register to this value, telling the system to shut down if the supplied power is below this value. Signed-off-by: Quentin Schulz --- drivers/power/supply/axp20x_battery.c | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.11.0 diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply/axp20x_battery.c index 5d29b2eab8fc..66f530541735 100644 --- a/drivers/power/supply/axp20x_battery.c +++ b/drivers/power/supply/axp20x_battery.c @@ -433,6 +433,7 @@ static int axp20x_power_probe(struct platform_device *pdev) { struct axp20x_batt_ps *axp20x_batt; struct power_supply_config psy_cfg = {}; + struct power_supply_battery_info info; if (!of_device_is_available(pdev->dev.of_node)) return -ENODEV; @@ -484,6 +485,15 @@ static int axp20x_power_probe(struct platform_device *pdev) return PTR_ERR(axp20x_batt->batt); } + if (!power_supply_get_battery_info(axp20x_batt->batt, &info)) { + int vmin = info.voltage_min_design_uv; + + if (vmin > 0 && axp20x_set_voltage_min_design(axp20x_batt, + vmin)) + dev_err(&pdev->dev, + "couldn't set voltage_min_design\n"); + } + return 0; } From patchwork Thu May 11 13:42:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 99651 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp738659qge; Thu, 11 May 2017 06:43:13 -0700 (PDT) X-Received: by 10.98.26.203 with SMTP id a194mr489222pfa.10.1494510193414; Thu, 11 May 2017 06:43:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494510193; cv=none; d=google.com; s=arc-20160816; b=k5rPuhepXuKV5IrOdfNhQzEhyMtB6YwxlE/mz/e9YPZ3l5HSN1rQxTfAmQcusZbq3m vX+KBi+DzPE5udzrCOwdTlw1r1Ys1GN7F55EpfwWxiPP1Six3skx0vjSrqrcHOU49lLk g0XvlptN+k0nJ9bcW2KYcstiUIeb+lP3RfFdhqZUJLhDLGNziGZNKukWZDxbAoyhXTEn ZXki8xETMKnP+Ch0QZrRQv0vQzBQ2NphfANBe89oO5sKEafSzPeHWMVcTB1ffeo/Rjk8 qxNzkYVDvLEEZIMhWhri6Ph0e7uPyXf2Y8f8/kONAZwMjAKY/eHs0m43gfdRdfGfRR49 j0ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=N0+YbwZf5nFLn7pBMXtBExG22M236K9+vdrQlYJDXSc=; b=Q9hfnb8ikny1MN7fqhx2AZtixcfX00tx7Qn2c1k+JGYGXA0mNcU8OtrpADcM+tM8B9 DTYrs8d5BjhQ264bZrDtCBNFUvKvH1p/yDbqNpSV/IUJzYt5r4iwbq/MpqPj5xL88Pb0 5ymgxZv748WiD8fWH+zdMJfPNvBVw7l2zo7Oo263KBC3OVOcQTyGX3atDNcKivAEjyYw DlopRuVTft6akoV8PsLa4fsvVsr80lnvBWB4w9hc1YEV/vQywM7/tqUHA0yBa9EAvBVu uk+KvDpVaESqs1rw6xFL7Tmq/2XMq3DB8gzl7nnS+ZmzEhq0Fvyazl/OQCNfZuG8Nzdv QkYg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n190si189817pga.80.2017.05.11.06.43.13; Thu, 11 May 2017 06:43:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932631AbdEKNms (ORCPT + 25 others); Thu, 11 May 2017 09:42:48 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:34117 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755686AbdEKNmm (ORCPT ); Thu, 11 May 2017 09:42:42 -0400 Received: by mail.free-electrons.com (Postfix, from userid 110) id B40DD21FF1; Thu, 11 May 2017 15:42:40 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 747F920E09; Thu, 11 May 2017 15:42:40 +0200 (CEST) From: Quentin Schulz To: sre@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, wens@csie.org Cc: Quentin Schulz , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, liam@networkimprov.net, thomas.petazzoni@free-electrons.com, linux-sunxi@googlegroups.com Subject: [PATCH 2/4] dt-bindings: power: battery: add constant-charge-current-max-microamp property Date: Thu, 11 May 2017 15:42:18 +0200 Message-Id: <20170511134221.5569-3-quentin.schulz@free-electrons.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170511134221.5569-1-quentin.schulz@free-electrons.com> References: <20170511134221.5569-1-quentin.schulz@free-electrons.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds the constant-charge-current-max-microamp property to the list of optional properties of the battery. The constant charge current is critical for batteries as they can't handle all charge currents. Signed-off-by: Quentin Schulz --- Documentation/devicetree/bindings/power/supply/battery.txt | 2 ++ 1 file changed, 2 insertions(+) -- 2.11.0 Acked-by: Rob Herring diff --git a/Documentation/devicetree/bindings/power/supply/battery.txt b/Documentation/devicetree/bindings/power/supply/battery.txt index 63a7028d1434..12c1abc93a90 100644 --- a/Documentation/devicetree/bindings/power/supply/battery.txt +++ b/Documentation/devicetree/bindings/power/supply/battery.txt @@ -12,6 +12,7 @@ Optional Properties: - voltage-min-design-microvolt: drained battery voltage - energy-full-design-microwatt-hours: battery design energy - charge-full-design-microamp-hours: battery design capacity + - constant-charge-current-max-microamp: battery maximum constant charge current Batteries must be referenced by chargers and/or fuel-gauges using a phandle. The phandle's property should be named @@ -24,6 +25,7 @@ Example: voltage-min-design-microvolt = <3200000>; energy-full-design-microwatt-hours = <5290000>; charge-full-design-microamp-hours = <1430000>; + constant-charge-current-max-microamp = <300000>; }; charger: charger@11 { From patchwork Thu May 11 13:42:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 99650 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp738657qge; Thu, 11 May 2017 06:43:13 -0700 (PDT) X-Received: by 10.99.104.69 with SMTP id d66mr394711pgc.93.1494510193006; Thu, 11 May 2017 06:43:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494510193; cv=none; d=google.com; s=arc-20160816; b=Kb+A4OOX8qrq//uTsZem7jtSeVYsCCafPp1TZZx6Xx/2wQfN6oGIC7rLxh5wwFYMAE p7PCbr5v4OhM2mKL7fF7Yn8bxmFow6cFD6EEqRT9mlQlWEByHp/dcMFmTPsp0a5qn82m x3w7mSV4X3efaBoyMcJN4S+hLb5LNhL7i/V4LjiBtOGINEpj1v+aHyiqaaU/Mc2M6Nw/ KEvIoDJkQw0DcBgbwsEx4TX/xfM8+aWRARnD0viB3Ty6inGF2pVUURy2IJMENrcCnr6n 2Jy6rwOyDVfrPKa9lD9WctVoH8deux3wB+ZVYRpNOr7ONrEQGgixVEtNlX0v5KSh7CCg JuPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=jED6WrsZRKqZIQRouz5kXWj3CTSZkvKrW3NFJDW6G80=; b=MYvzTUsPbMXx5NiCb/mcJ2P18BTo7pMKQYzmLEOMh1PZjA7cQ8iBSUKm2vRlz7LcLU gqY1bu0hqn8zuQGjPo3z9JJvi1jn8ixZAgyUJRTcD0Ez7vXngak+D/1STV3hyZw82zoo 84Gl44ESSqsyb44u35D2OaPRkRe6fh9xGqfpmdFnzg1HWSRAmIOHO1sjXA5lyGhN4Z3E u3QZ1/l+xhO33vs7mSDuCep4p97wYZo0Ty/K6P68zCCbm1eadGsvEwLOf5O1tso3IcSY JS+ZDz/sf2+QH3e/jobuZZ+iy3dC+C2Ja1rpRfJp2ATZiQkpa+wbRlzKj61fvlX+J/nt hvXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n190si189817pga.80.2017.05.11.06.43.12; Thu, 11 May 2017 06:43:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932717AbdEKNmt (ORCPT + 25 others); Thu, 11 May 2017 09:42:49 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:34123 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755741AbdEKNmm (ORCPT ); Thu, 11 May 2017 09:42:42 -0400 Received: by mail.free-electrons.com (Postfix, from userid 110) id EBFCA21FF2; Thu, 11 May 2017 15:42:40 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id AC9C420F67; Thu, 11 May 2017 15:42:40 +0200 (CEST) From: Quentin Schulz To: sre@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, wens@csie.org Cc: Quentin Schulz , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, liam@networkimprov.net, thomas.petazzoni@free-electrons.com, linux-sunxi@googlegroups.com Subject: [PATCH 3/4] power: supply: power_supply_core: add constant-charge-current optional property Date: Thu, 11 May 2017 15:42:19 +0200 Message-Id: <20170511134221.5569-4-quentin.schulz@free-electrons.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170511134221.5569-1-quentin.schulz@free-electrons.com> References: <20170511134221.5569-1-quentin.schulz@free-electrons.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds the constant-charge-current property to the list of optional properties for the battery. The constant charge current is critical for batteries as they can't handle all charge currents. Signed-off-by: Quentin Schulz --- drivers/power/supply/power_supply_core.c | 3 +++ include/linux/power_supply.h | 1 + 2 files changed, 4 insertions(+) -- 2.11.0 diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index 5019bdee0f0b..23887739c95c 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -508,6 +508,7 @@ int power_supply_get_battery_info(struct power_supply *psy, info->energy_full_design_uwh = -EINVAL; info->charge_full_design_uah = -EINVAL; info->voltage_min_design_uv = -EINVAL; + info->constant_charge_current_max_ua = -EINVAL; if (!psy->of_node) { dev_warn(&psy->dev, "%s currently only supports devicetree\n", @@ -537,6 +538,8 @@ int power_supply_get_battery_info(struct power_supply *psy, &info->charge_full_design_uah); of_property_read_u32(battery_np, "voltage-min-design-microvolt", &info->voltage_min_design_uv); + of_property_read_u32(battery_np, "constant-charge-current-max-microamp", + &info->constant_charge_current_max_ua); return 0; } diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index e84f1d31d987..6f9c28187caf 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -301,6 +301,7 @@ struct power_supply_battery_info { int energy_full_design_uwh; /* microWatt-hours */ int charge_full_design_uah; /* microAmp-hours */ int voltage_min_design_uv; /* microVolts */ + int constant_charge_current_max_ua; /* microAmps */ }; extern struct atomic_notifier_head power_supply_notifier;