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: 9721533 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C86D6603F8 for ; Thu, 11 May 2017 13:43:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF1D328673 for ; Thu, 11 May 2017 13:43:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3B4728668; Thu, 11 May 2017 13:43:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EB472866D for ; Thu, 11 May 2017 13:43:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932217AbdEKNmn (ORCPT ); Thu, 11 May 2017 09:42:43 -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) 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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(+) 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; }