From patchwork Sat Sep 19 14:04:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 256741 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB300C43465 for ; Sat, 19 Sep 2020 14:04:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 98BAC2344C for ; Sat, 19 Sep 2020 14:04:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600524274; bh=ugAs2y4rZlA6vZBj2bhkYKT3elTk+a0JzAZleLgQ7w0=; h=From:To:Subject:Date:In-Reply-To:References:List-ID:From; b=XmuXAREeRHEf8QO1LIOZaEhOOZzbWApKJj3woohxFP3B4m2solvjJYPibULYy/4tK 7pYmt0DBDQkzsNUiDWOuURrvCC8hMdcjbi7cI+vHdS1lM2ccGco7fvAeOioR87ywM0 ttwT9fxn+epOxNYaXzNgFLP7EtsXUrHIcxU/w7Ww= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726481AbgISOEd (ORCPT ); Sat, 19 Sep 2020 10:04:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:41144 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726159AbgISOEd (ORCPT ); Sat, 19 Sep 2020 10:04:33 -0400 Received: from localhost.localdomain (unknown [194.230.155.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A48BC21741; Sat, 19 Sep 2020 14:04:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600524272; bh=ugAs2y4rZlA6vZBj2bhkYKT3elTk+a0JzAZleLgQ7w0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=O7Xt1G1aXZoEJT23mm564dFtIebvpZ71szGK1T/F1LRl9PWZD2F3RTYT7uap/vdAf Lv7mm3niKqVeX4pSH8o1qUT6PoeiC39dA4g7fxeczrpGwCttWJWaNyBxnCObiiIOgK tV7ieoIqzJUySy4S7eLfwaGfnPWM+qCVNwZqPyBg= From: Krzysztof Kozlowski To: Sebastian Reichel , Rob Herring , =?utf-8?q?Pali_Roh=C3=A1r?= , Dan Murphy , Krzysztof Kozlowski , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/6] dt-bindings: power: bq27xxx: add bq34z100 Date: Sat, 19 Sep 2020 16:04:13 +0200 Message-Id: <20200919140418.3705-2-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200919140418.3705-1-krzk@kernel.org> References: <20200919140418.3705-1-krzk@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add compatible for bq34z100 charger. Signed-off-by: Krzysztof Kozlowski Acked-by: Rob Herring --- Documentation/devicetree/bindings/power/supply/bq27xxx.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml b/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml index 82f682705f44..45beefccf31a 100644 --- a/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml +++ b/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml @@ -51,6 +51,7 @@ properties: - ti,bq27621 - ti,bq27z561 - ti,bq28z610 + - ti,bq34z100 reg: maxItems: 1 From patchwork Sat Sep 19 14:04:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 256740 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9242C43463 for ; Sat, 19 Sep 2020 14:04:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 885412344C for ; Sat, 19 Sep 2020 14:04:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600524286; bh=22njGzYbgVLmqZwKMutr7y/CtPsY/fcDoav/iUVMvtk=; h=From:To:Subject:Date:In-Reply-To:References:List-ID:From; b=wQmlsM2HjLfZEpfrXHav3Z4JQZWjjUL1UMXca5A6kSfhD+hPpwfiBTZMgzC8ySdpA SyRt6Ax6QPUZ0/BEZwr6EKvAai9GA8CMVi9U8WZuThqklWwLUN7Sl9oPV2YTbRP6F5 5JmvSpAznAucwukUmkeVftImsMuRboen3FmWr938= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726532AbgISOEm (ORCPT ); Sat, 19 Sep 2020 10:04:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:41428 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726510AbgISOEi (ORCPT ); Sat, 19 Sep 2020 10:04:38 -0400 Received: from localhost.localdomain (unknown [194.230.155.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5376821D43; Sat, 19 Sep 2020 14:04:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600524278; bh=22njGzYbgVLmqZwKMutr7y/CtPsY/fcDoav/iUVMvtk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=H+vLyMxeyYECtqIstFTAEVcYMVxLLUGWmOnDIg4GXGuxFW1vJxBK098ltm2HfV7v+ nQ9BqSeEW4/Vsnns7z8JsXZyHJfY9q2EXB+FhB6V+oyQahkyUDfPFm1QZQJHntoAkH MeqNgQbLVvrXMjLeiVL5mFjgLL0x8/YQREYywY2s= From: Krzysztof Kozlowski To: Sebastian Reichel , Rob Herring , =?utf-8?q?Pali_Roh=C3=A1r?= , Dan Murphy , Krzysztof Kozlowski , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/6] power: supply: bq27xxx: adjust whitespace and use BIT() for bitflags Date: Sat, 19 Sep 2020 16:04:15 +0200 Message-Id: <20200919140418.3705-4-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200919140418.3705-1-krzk@kernel.org> References: <20200919140418.3705-1-krzk@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org BIT() is a preferred way to toggle bit-like flags: no problems with 32/64 bit systems, less chances for mistakes. Remove also unneeded whitespace. Signed-off-by: Krzysztof Kozlowski --- drivers/power/supply/bq27xxx_battery.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c index 65806f668b1f..e971af43dd45 100644 --- a/drivers/power/supply/bq27xxx_battery.c +++ b/drivers/power/supply/bq27xxx_battery.c @@ -76,7 +76,7 @@ /* BQ27Z561 has different layout for Flags register */ #define BQ27Z561_FLAG_FDC BIT(4) /* Battery fully discharged */ -#define BQ27Z561_FLAG_FC BIT(5) /* Battery fully charged */ +#define BQ27Z561_FLAG_FC BIT(5) /* Battery fully charged */ #define BQ27Z561_FLAG_DIS_CH BIT(6) /* Battery is discharging */ /* control register params */ @@ -847,13 +847,14 @@ static struct bq27xxx_dm_reg bq27621_dm_regs[] = { #define bq27z561_dm_regs 0 #define bq28z610_dm_regs 0 - -#define BQ27XXX_O_ZERO 0x00000001 -#define BQ27XXX_O_OTDC 0x00000002 /* has OTC/OTD overtemperature flags */ -#define BQ27XXX_O_UTOT 0x00000004 /* has OT overtemperature flag */ -#define BQ27XXX_O_CFGUP 0x00000008 -#define BQ27XXX_O_RAM 0x00000010 -#define BQ27Z561_O_BITS 0x00000020 +#define bq34z100_dm_regs 0 + +#define BQ27XXX_O_ZERO BIT(0) +#define BQ27XXX_O_OTDC BIT(1) /* has OTC/OTD overtemperature flags */ +#define BQ27XXX_O_UTOT BIT(2) /* has OT overtemperature flag */ +#define BQ27XXX_O_CFGUP BIT(3) +#define BQ27XXX_O_RAM BIT(4) +#define BQ27Z561_O_BITS BIT(5) #define BQ27XXX_DATA(ref, key, opt) { \ .opts = (opt), \ From patchwork Sat Sep 19 14:04:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 256739 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B9E4C43464 for ; Sat, 19 Sep 2020 14:04:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 42CC421741 for ; Sat, 19 Sep 2020 14:04:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600524292; bh=kH3ZX6jeXwk/tHvglsarvks10HBChwFrU/V3tKKYUOU=; h=From:To:Subject:Date:In-Reply-To:References:List-ID:From; b=2vtyjJpTBoPsympRcl/bVHEPEG9+495w6Ja7AL0P3WwTVqFb+JmUjgE1/AA5Ilz4Q h/5duZJuNhNCoPIQbMTU9nUAJ/ItxAGxysj7dWAPvDyXDE2HapOeSaP+6MdE2wCxC3 EvXeAYmn2Bx5KaBjMklcBl+HdkijyWDf94cEBQ/s= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726559AbgISOEu (ORCPT ); Sat, 19 Sep 2020 10:04:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:41660 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726510AbgISOEo (ORCPT ); Sat, 19 Sep 2020 10:04:44 -0400 Received: from localhost.localdomain (unknown [194.230.155.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 16DCD23119; Sat, 19 Sep 2020 14:04:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600524284; bh=kH3ZX6jeXwk/tHvglsarvks10HBChwFrU/V3tKKYUOU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ue4+QOG3wNMeX7yYWHgrkDGIKStnysxXBBrrecwSHI9KGslPyav2lfuWcItKJvfgk 49XNYT1v2e2mPUxCfL8FmeA2GKzvrkOlF2K5oD2szoDEYQkJEUAxuUK7AFNz3bWKlw 6N6jW8kPnUg7R/alm8Hc6rBS4vogfqSo0tdCAV/Y= From: Krzysztof Kozlowski To: Sebastian Reichel , Rob Herring , =?utf-8?q?Pali_Roh=C3=A1r?= , Dan Murphy , Krzysztof Kozlowski , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/6] power: supply: bq27xxx: add separate flag for capacity inaccurate Date: Sat, 19 Sep 2020 16:04:17 +0200 Message-Id: <20200919140418.3705-6-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200919140418.3705-1-krzk@kernel.org> References: <20200919140418.3705-1-krzk@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org bq27000, bq27010 and upcoming bq34z100 have a Capacity Inaccurate flag. However except this similarity, bq34z100 is quite different than bq27000/bq27010, so flag BQ27XXX_O_ZERO cannot be reused here. Add a new bit flag describing this capability. No functional change for bq27000 and bq27010. Signed-off-by: Krzysztof Kozlowski --- drivers/power/supply/bq27xxx_battery.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c index 88cdad0ecb08..cda03e1f9586 100644 --- a/drivers/power/supply/bq27xxx_battery.c +++ b/drivers/power/supply/bq27xxx_battery.c @@ -856,6 +856,7 @@ static struct bq27xxx_dm_reg bq27621_dm_regs[] = { #define BQ27XXX_O_RAM BIT(4) #define BQ27Z561_O_BITS BIT(5) #define BQ27XXX_O_SOC_SI BIT(6) /* SoC is single register */ +#define BQ27XXX_O_HAS_CI BIT(7) /* has Capacity Inaccurate flag */ #define BQ27XXX_DATA(ref, key, opt) { \ .opts = (opt), \ @@ -873,8 +874,8 @@ static struct { enum power_supply_property *props; size_t props_size; } bq27xxx_chip_data[] = { - [BQ27000] = BQ27XXX_DATA(bq27000, 0 , BQ27XXX_O_ZERO | BQ27XXX_O_SOC_SI), - [BQ27010] = BQ27XXX_DATA(bq27010, 0 , BQ27XXX_O_ZERO | BQ27XXX_O_SOC_SI), + [BQ27000] = BQ27XXX_DATA(bq27000, 0 , BQ27XXX_O_ZERO | BQ27XXX_O_SOC_SI | BQ27XXX_O_HAS_CI), + [BQ27010] = BQ27XXX_DATA(bq27010, 0 , BQ27XXX_O_ZERO | BQ27XXX_O_SOC_SI | BQ27XXX_O_HAS_CI), [BQ2750X] = BQ27XXX_DATA(bq2750x, 0 , BQ27XXX_O_OTDC), [BQ2751X] = BQ27XXX_DATA(bq2751x, 0 , BQ27XXX_O_OTDC), [BQ2752X] = BQ27XXX_DATA(bq2752x, 0 , BQ27XXX_O_OTDC), @@ -1659,7 +1660,7 @@ static int bq27xxx_battery_read_health(struct bq27xxx_device_info *di) void bq27xxx_battery_update(struct bq27xxx_device_info *di) { struct bq27xxx_reg_cache cache = {0, }; - bool has_ci_flag = di->opts & BQ27XXX_O_ZERO; + bool has_ci_flag = di->opts & BQ27XXX_O_HAS_CI; bool has_singe_flag = di->opts & BQ27XXX_O_ZERO; cache.flags = bq27xxx_read(di, BQ27XXX_REG_FLAGS, has_singe_flag);