From patchwork Sat Sep 26 19:05:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 11801627 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B7486139A for ; Sat, 26 Sep 2020 19:15:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 75C80221E5 for ; Sat, 26 Sep 2020 19:15:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=rere.qmqm.pl header.i=@rere.qmqm.pl header.b="OW4w1Kqa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726183AbgIZTPU (ORCPT ); Sat, 26 Sep 2020 15:15:20 -0400 Received: from rere.qmqm.pl ([91.227.64.183]:59331 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729291AbgIZTPU (ORCPT ); Sat, 26 Sep 2020 15:15:20 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4BzJC25k2Jz2KH; Sat, 26 Sep 2020 21:05:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1601147134; bh=3INUmx9RND0JKy4nJpRHGKH4uognPLDDkFYP6+Ush4Y=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=OW4w1KqaCEwgGsbA6BvdeHm8d+WND9E5IK9grlMv2u1N0lbbEeTJ3u5RQUXI0baYF +/7EVkvkQguwj4K9Ptgg/rLDd7jixL0LnImXIEeKnGmixZ/bDk8bvdoUBQJwPGHaui u8jJUPlKUAgnRo75cQ/RP5EJOWhf3X3LY28ZVF0yxBOgidS3xpWPdzJnXipYslSa5U Kpbizm78taelA8KqY6nNn64K2YQcXIWMJrLILWXfpYIaHkqr9IhLzQvbIS9Sm4mHmu M8cZakGMSeHoGAACuuCX84GgJA1JmjQYq6+IeoawpkjGvSskdomOPzH7PJ+5xJeVx7 hpd+VYis206Zg== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.4 at mail Date: Sat, 26 Sep 2020 21:05:34 +0200 Message-Id: In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v4 1/2] power: bq25890: document IBAT compensation DT properties MIME-Version: 1.0 To: Angus Ainslie , Rob Herring , Sebastian Reichel , Yauhen Kharuzhy Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Document new properties for IBAT compensation feature. Signed-off-by: Michał Mirosław Reviewed-by: Rob Herring --- v2: initial version v4: renamed properties applying property-suffix --- Documentation/devicetree/bindings/power/supply/bq25890.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/power/supply/bq25890.txt b/Documentation/devicetree/bindings/power/supply/bq25890.txt index 3b4c69a7fa70..805040c6fff9 100644 --- a/Documentation/devicetree/bindings/power/supply/bq25890.txt +++ b/Documentation/devicetree/bindings/power/supply/bq25890.txt @@ -33,6 +33,10 @@ Optional properties: - ti,thermal-regulation-threshold: integer, temperature above which the charge current is lowered, to avoid overheating (in degrees Celsius). If omitted, the default setting will be used (120 degrees); +- ti,ibatcomp-micro-ohms: integer, value of a resistor in series with + the battery; +- ti,ibatcomp-clamp-microvolt: integer, maximum charging voltage adjustment due + to expected voltage drop on in-series resistor; Example: From patchwork Sat Sep 26 19:05:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 11801625 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EB4B892C for ; Sat, 26 Sep 2020 19:15:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD8AE221E5 for ; Sat, 26 Sep 2020 19:15:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=rere.qmqm.pl header.i=@rere.qmqm.pl header.b="hNGAkvK0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729443AbgIZTPU (ORCPT ); Sat, 26 Sep 2020 15:15:20 -0400 Received: from rere.qmqm.pl ([91.227.64.183]:55371 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726183AbgIZTPT (ORCPT ); Sat, 26 Sep 2020 15:15:19 -0400 X-Greylist: delayed 584 seconds by postgrey-1.27 at vger.kernel.org; Sat, 26 Sep 2020 15:15:19 EDT Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4BzJC30yhjz2KM; Sat, 26 Sep 2020 21:05:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1601147135; bh=A6FEbk0jOsce4uOG4hqYgXIH+C1qRtC4NLa/GQ9EAY0=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=hNGAkvK0zBV+8SNw0ZZPspmlwKmbKpnJ6JINGqy23i8riZDaSFAlqXbR7kAyARuEc 0Y5+UF6EPKqvchuFYmGoB9b1fMX0JvYHkwNJ/KulTqFHw3n+7n0s5FLyEkdsibII1H hmjB84wiuXGP6DZ6NAz4lqgaebMB4yNjCJZ8vGwyVu596cc8RiZ4Ew2p2xC59iWRqI oy0hZxAc18GiOURhWa0DrjKCeoGkLpFWbz7QJkIdRwmGQuaKv2B15TfUUfwwkPmbBR f4xykrzI8acqpaHzzZj3nAYL1hqlfxiGkwaFL6tULMdtiFhbq32/9Bt9OwlJCJZTCU nX2cmxAz1DnTw== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.4 at mail Date: Sat, 26 Sep 2020 21:05:34 +0200 Message-Id: <73bd1e2f62912bc97152078540f15fcf6438e6c1.1601146802.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v4 2/2] power: bq25890: support IBAT compensation MIME-Version: 1.0 To: Angus Ainslie , Rob Herring , Sebastian Reichel , Yauhen Kharuzhy Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add configuration for compensation of IBAT measuring resistor in series with the battery. Signed-off-by: Michał Mirosław --- v4: renamed properties applying property-suffix --- drivers/power/supply/bq25890_charger.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c index 77150667e36b..ab8398f935c5 100644 --- a/drivers/power/supply/bq25890_charger.c +++ b/drivers/power/supply/bq25890_charger.c @@ -83,6 +83,8 @@ struct bq25890_init_data { u8 boostf; /* boost frequency */ u8 ilim_en; /* enable ILIM pin */ u8 treg; /* thermal regulation threshold */ + u8 rbatcomp; /* IBAT sense resistor value */ + u8 vclamp; /* IBAT compensation voltage limit */ }; struct bq25890_state { @@ -258,6 +260,8 @@ enum bq25890_table_ids { TBL_VREG, TBL_BOOSTV, TBL_SYSVMIN, + TBL_VBATCOMP, + TBL_RBATCOMP, /* lookup tables */ TBL_TREG, @@ -299,6 +303,8 @@ static const union { [TBL_VREG] = { .rt = {3840000, 4608000, 16000} }, /* uV */ [TBL_BOOSTV] = { .rt = {4550000, 5510000, 64000} }, /* uV */ [TBL_SYSVMIN] = { .rt = {3000000, 3700000, 100000} }, /* uV */ + [TBL_VBATCOMP] ={ .rt = {0, 224000, 32000} }, /* uV */ + [TBL_RBATCOMP] ={ .rt = {0, 140000, 20000} }, /* uOhm */ /* lookup tables */ [TBL_TREG] = { .lt = {bq25890_treg_tbl, BQ25890_TREG_TBL_SIZE} }, @@ -648,7 +654,9 @@ static int bq25890_hw_init(struct bq25890_device *bq) {F_BOOSTI, bq->init_data.boosti}, {F_BOOSTF, bq->init_data.boostf}, {F_EN_ILIM, bq->init_data.ilim_en}, - {F_TREG, bq->init_data.treg} + {F_TREG, bq->init_data.treg}, + {F_BATCMP, bq->init_data.rbatcomp}, + {F_VCLAMP, bq->init_data.vclamp}, }; ret = bq25890_chip_reset(bq); @@ -859,11 +867,14 @@ static int bq25890_fw_read_u32_props(struct bq25890_device *bq) {"ti,boost-max-current", false, TBL_BOOSTI, &init->boosti}, /* optional properties */ - {"ti,thermal-regulation-threshold", true, TBL_TREG, &init->treg} + {"ti,thermal-regulation-threshold", true, TBL_TREG, &init->treg}, + {"ti,ibatcomp-micro-ohms", true, TBL_RBATCOMP, &init->rbatcomp}, + {"ti,ibatcomp-clamp-microvolt", true, TBL_VBATCOMP, &init->vclamp}, }; /* initialize data for optional properties */ init->treg = 3; /* 120 degrees Celsius */ + init->rbatcomp = init->vclamp = 0; /* IBAT compensation disabled */ for (i = 0; i < ARRAY_SIZE(props); i++) { ret = device_property_read_u32(bq->dev, props[i].name,