From patchwork Mon Jan 15 10:33:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 124501 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp624687lje; Mon, 15 Jan 2018 02:38:05 -0800 (PST) X-Google-Smtp-Source: ACJfBouNPteX/87U0WecJ//5tqOcMRS+pHwiNyIYL8tu8Mzp3eUA4p+p08DVO6e0POyXIkC/AlUH X-Received: by 10.98.74.133 with SMTP id c5mr19341852pfj.188.1516012685346; Mon, 15 Jan 2018 02:38:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516012685; cv=none; d=google.com; s=arc-20160816; b=grmQPPduPmHqf0eGSKmhYPOQUIC00SGMcILZ9yyMfc/8P6UY2lJ5SBPT6YVoP5/8TJ qoNeFBxJ6nPnNWcqYne9i3nCm+Pu5NBJT92IYGOSE8A+azHI5dCRgx1ClZW07DjW7UhX Z4STSz8Wq5XwM3ok5iz4LdfgyZzQHUvdSMLe5reHNicqnMArc+4ieUOXznyNjCSlVspG DlFfiVHa8lpbaB8EK4k6bEaokWTyGdUa6vEPEBPVzHLbXA4LNSavQhTu7/McCdQx5mgC pGrS+LJHKRfXYWoe8VVPeAVyK+qn1lPQrWguG3Y/MqqJ3nAAlK0ZMMJszNun94bOsL2W lDLg== 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:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=xs0eQbGktTuM4vW6p+zBFFlqwVfPxj8JkGBhj43xH1c=; b=Eg/VeUKCQP4P9IExNwnwCyIFniPYEg3aY9zq/Gm4hMgfc/KzyyjcdKTNz5kl+vJ3Ul oHzhXlLEoxqkBI8u1xATE6nAxikBU7oKocALZ+1+vruNwNT2AHI/OUJtkb4QbtVMZB8R XU/1TiWg/IiqfG06Wi8Zb+639wo1WEI9yeBeel+7ZxX/6gSsKpbqZAKkgRccEIn9Lutu B8UePupdw7G0lL1v22yl0GwBrm8UnHThHoFynkw7WOCSyw0A2T3QTIalsnoYskyYGqPi 5qDS2Y05+X8AgrXzqIxk4MVig3sS+FYpCh+QlxSF45qeiswkfh8TFG6yv5i6e4XDnudv n/Mw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 v11si13932899plz.285.2018.01.15.02.38.05; Mon, 15 Jan 2018 02:38:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754698AbeAOKiC (ORCPT + 11 others); Mon, 15 Jan 2018 05:38:02 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:43909 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755347AbeAOKfN (ORCPT ); Mon, 15 Jan 2018 05:35:13 -0500 Received: by mail.free-electrons.com (Postfix, from userid 110) id 96DAB20888; Mon, 15 Jan 2018 11:35:09 +0100 (CET) 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 261F720889; Mon, 15 Jan 2018 11:34:53 +0100 (CET) From: Quentin Schulz To: jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, robh+dt@kernel.org, mark.rutland@arm.com, wens@csie.org, sre@kernel.org, linux@armlinux.org.uk, maxime.ripard@free-electrons.com, lee.jones@linaro.org Cc: linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, thomas.petazzoni@free-electrons.com, linux-sunxi@googlegroups.com, julian.calaby@gmail.com, Quentin Schulz Subject: [PATCH v3 12/16] power: supply: axp20x_battery: add support for AXP813 Date: Mon, 15 Jan 2018 11:33:46 +0100 Message-Id: <42b2e555083abbab43e48362175dc9c2eeeedf3c.1516012352.git-series.quentin.schulz@free-electrons.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The X-Powers AXP813 PMIC has got some slight differences from AXP20X/AXP22X PMICs: - the maximum voltage supplied by the PMIC is 4.35 instead of 4.36/4.24 for AXP20X/AXP22X, - the constant charge current formula is different, It also has a bit to tell whether the battery percentage returned by the PMIC is valid. Signed-off-by: Quentin Schulz --- drivers/power/supply/axp20x_battery.c | 42 ++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+) -- git-series 0.9.1 diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply/axp20x_battery.c index d73c78f..e75fa90 100644 --- a/drivers/power/supply/axp20x_battery.c +++ b/drivers/power/supply/axp20x_battery.c @@ -49,6 +49,8 @@ #define AXP22X_CHRG_CTRL1_TGT_4_22V (1 << 5) #define AXP22X_CHRG_CTRL1_TGT_4_24V (3 << 5) +#define AXP813_CHRG_CTRL1_TGT_4_35V (3 << 5) + #define AXP20X_CHRG_CTRL1_TGT_CURR GENMASK(3, 0) #define AXP20X_V_OFF_MASK GENMASK(2, 0) @@ -133,6 +135,35 @@ static int axp22x_battery_get_max_voltage(struct axp20x_batt_ps *axp20x_batt, return 0; } +static int axp813_battery_get_max_voltage(struct axp20x_batt_ps *axp20x_batt, + int *val) +{ + int ret, reg; + + ret = regmap_read(axp20x_batt->regmap, AXP20X_CHRG_CTRL1, ®); + if (ret) + return ret; + + switch (reg & AXP20X_CHRG_CTRL1_TGT_VOLT) { + case AXP20X_CHRG_CTRL1_TGT_4_1V: + *val = 4100000; + break; + case AXP20X_CHRG_CTRL1_TGT_4_15V: + *val = 4150000; + break; + case AXP20X_CHRG_CTRL1_TGT_4_2V: + *val = 4200000; + break; + case AXP813_CHRG_CTRL1_TGT_4_35V: + *val = 4350000; + break; + default: + return -EINVAL; + } + + return 0; +} + static int axp20x_get_constant_charge_current(struct axp20x_batt_ps *axp, int *val) { @@ -491,6 +522,14 @@ struct axp_data axp221_data = { .set_max_voltage = axp22x_battery_set_max_voltage, }; +struct axp_data axp813_data = { + .ccc_scale = 200000, + .ccc_offset = 200000, + .has_fg_valid = true, + .get_max_voltage = axp813_battery_get_max_voltage, + .set_max_voltage = axp20x_battery_set_max_voltage, +}; + static const struct of_device_id axp20x_battery_ps_id[] = { { .compatible = "x-powers,axp209-battery-power-supply", @@ -498,6 +537,9 @@ static const struct of_device_id axp20x_battery_ps_id[] = { }, { .compatible = "x-powers,axp221-battery-power-supply", .data = (void *)&axp221_data, + }, { + .compatible = "x-powers,axp813-battery-power-supply", + .data = (void *)&axp813_data, }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, axp20x_battery_ps_id); From patchwork Mon Jan 15 10:33:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 124499 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp624444lje; Mon, 15 Jan 2018 02:37:08 -0800 (PST) X-Google-Smtp-Source: ACJfBotln7FZsdup3x5e4DtiZnsKSSkZL+4Y9Ki9045NqIUjApplRmDXk9UTRfbffP9x/hhP5Bmy X-Received: by 10.99.191.15 with SMTP id v15mr2135647pgf.216.1516012628291; Mon, 15 Jan 2018 02:37:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516012628; cv=none; d=google.com; s=arc-20160816; b=i7yLlFwPYaQ/ypyxk7aNsnj1rKX+9lcaqa4091mZETE2I8RnxXv6ngXMAxo1DvZC1Z e0ZKP3DqcOGA/GtVt5qlKwowiAa4GToHPemHHiE0ArOYAyqYlTv7CwZswQuo8KmItUfi vpnUPqk+Og6GWd7L/SdbORxPO4L+sz0Op87aGq1zixioRvcieEP3g3ZT4PsMzfLrZEYI mw8FSQrrdilC2roMcVRwAe0Br0MewuWvXp2BFBbRCe6k1gkBtCjqLX0L3voAozoIRdf2 BGoBq5GFpsWcsZmyiY2HwXAeSv9K0MbquQ5DIPXH2eAkuKwj4rl+nACuAmsL276MQJaB FU1g== 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:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=VfT2pjDbdrwW7MKboL40oIJyb3y1OZuB+HVFAg8JjII=; b=hVkfG5IsXfUe0n0QB8Ht96D8WzQvJ/QvRMAXon6Z58k7vNYsOeLstlC5wZBhg7wFqR f1sMlkNqD4cSZfJbxV4IN1ZLAO/0vMTeXDQdVE3nzIgzqq3f5iIYPbDmZ1ENYmH/fr3u 8aIzhO5ipom3XoTrcQUevi9w43l5BY6IMQPHHMqJ/Klxmg1jK+cKQ8EQ/tRBiyUasxyd ZtunRaTvy5bgyAe1CD688v0Bsio6dz48pyJlR5tdkR2aQCdEYCyYLQn3Z+6SbQQicM++ c2k46iIh8gHGcZald8ntlr7CR/W39cAar2ISUiF6MOqTyil90wAnIlhbKL91ApXKQL4Q FpnQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 d3si20594707pll.797.2018.01.15.02.37.08; Mon, 15 Jan 2018 02:37:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932943AbeAOKhF (ORCPT + 11 others); Mon, 15 Jan 2018 05:37:05 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:43911 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755349AbeAOKfN (ORCPT ); Mon, 15 Jan 2018 05:35:13 -0500 Received: by mail.free-electrons.com (Postfix, from userid 110) id 0E3862088B; Mon, 15 Jan 2018 11:35:10 +0100 (CET) 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 1318D2088C; Mon, 15 Jan 2018 11:34:54 +0100 (CET) From: Quentin Schulz To: jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, robh+dt@kernel.org, mark.rutland@arm.com, wens@csie.org, sre@kernel.org, linux@armlinux.org.uk, maxime.ripard@free-electrons.com, lee.jones@linaro.org Cc: linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, thomas.petazzoni@free-electrons.com, linux-sunxi@googlegroups.com, julian.calaby@gmail.com, Quentin Schulz Subject: [PATCH v3 14/16] ARM: dtsi: axp81x: add battery power supply subnode Date: Mon, 15 Jan 2018 11:33:48 +0100 Message-Id: <9c045de8dcee9a71803978855762e272efdc41d3.1516012352.git-series.quentin.schulz@free-electrons.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The X-Powers AXP81X PMIC exposes battery supply various data such as the battery status (charging, discharging, full, dead), current max limit, current current, battery capacity (in percentage), voltage max and min limits, current voltage, and battery capacity (in Ah). This adds the battery power supply subnode for AXP81X PMIC. Signed-off-by: Quentin Schulz --- arch/arm/boot/dts/axp81x.dtsi | 5 +++++ 1 file changed, 5 insertions(+) -- git-series 0.9.1 Acked-by: Chen-Yu Tsai diff --git a/arch/arm/boot/dts/axp81x.dtsi b/arch/arm/boot/dts/axp81x.dtsi index 6b5e7bc..1b05c7f 100644 --- a/arch/arm/boot/dts/axp81x.dtsi +++ b/arch/arm/boot/dts/axp81x.dtsi @@ -69,6 +69,11 @@ }; }; + battery_power_supply: battery-power-supply { + compatible = "x-powers,axp813-battery-power-supply"; + status = "disabled"; + }; + regulators { /* Default work frequency for buck regulators */ x-powers,dcdc-freq = <3000>;