From patchwork Sun May 3 15:21:10 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: 201189 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=-6.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=ham 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 A8223C47259 for ; Sun, 3 May 2020 15:21:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E74E24953 for ; Sun, 3 May 2020 15:21:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=rere.qmqm.pl header.i=@rere.qmqm.pl header.b="iPkQ/FLZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728872AbgECPVw (ORCPT ); Sun, 3 May 2020 11:21:52 -0400 Received: from rere.qmqm.pl ([91.227.64.183]:51302 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728595AbgECPVN (ORCPT ); Sun, 3 May 2020 11:21:13 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 49FV7V4cPmzJf; Sun, 3 May 2020 17:21:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1588519270; bh=mKRZQCnghprUjuua4YgNrBV4tEAzgIfaruToSEdSL8Q=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=iPkQ/FLZt0ykL0C0STfJW+MwNu2UkDUGr4OQ6JlSyUelkoC4xqpzSnNFV9/O2rSuL VpVMo3SAaD9wZHXIHicqatX/+9KlUNiAqV61sgnRyuonVnDUZcJd0mPcruQ+XN2ym3 /4x+QfaU89Of/NgvDIZ1DQvRvLoKwciO+vTFPe/5Nxe/HO0OjShhFdk2UKlHl1adkS 3t0HVeYcmo5n7krhUhsq+iLmUYGxM+kQyWHSYGbJHB4rZBHSoLgx5QDrWANi3VJ2bF /PFK/8jh1IirzAtd3Q9f9Junk6m8OH/FHP+igF7ru3dlPPkRveQ7JoYam7VDBozhIS XubhkFsOchIlg== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.2 at mail Date: Sun, 03 May 2020 17:21:10 +0200 Message-Id: In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v2 02/11] power: bq25890: simplify chip name property getter MIME-Version: 1.0 To: Rob Herring , Sebastian Reichel Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Driver rejects unknown chips early in the probe(), so when bq25890_power_supply_get_property() is made reachable, bq->chip_version will already be set to correct value - there is no need to check it again. Signed-off-by: Michał Mirosław --- drivers/power/supply/bq25890_charger.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c index c642519ef7b2..f9f29edadddc 100644 --- a/drivers/power/supply/bq25890_charger.c +++ b/drivers/power/supply/bq25890_charger.c @@ -32,6 +32,13 @@ enum bq25890_chip_version { BQ25896, }; +static const char *const bq25890_chip_name[] = { + "BQ25890", + "BQ25892", + "BQ25895", + "BQ25896", +}; + enum bq25890_fields { F_EN_HIZ, F_EN_ILIM, F_IILIM, /* Reg00 */ F_BHOT, F_BCOLD, F_VINDPM_OFS, /* Reg01 */ @@ -400,17 +407,7 @@ static int bq25890_power_supply_get_property(struct power_supply *psy, break; case POWER_SUPPLY_PROP_MODEL_NAME: - if (bq->chip_version == BQ25890) - val->strval = "BQ25890"; - else if (bq->chip_version == BQ25892) - val->strval = "BQ25892"; - else if (bq->chip_version == BQ25895) - val->strval = "BQ25895"; - else if (bq->chip_version == BQ25896) - val->strval = "BQ25896"; - else - val->strval = "UNKNOWN"; - + val->strval = bq25890_chip_name[bq->chip_version]; break; case POWER_SUPPLY_PROP_ONLINE: From patchwork Sun May 3 15:21:12 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: 201190 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=-6.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS 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 12189C47258 for ; Sun, 3 May 2020 15:21:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA0EB24955 for ; Sun, 3 May 2020 15:21:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=rere.qmqm.pl header.i=@rere.qmqm.pl header.b="AEeTte93" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728838AbgECPVk (ORCPT ); Sun, 3 May 2020 11:21:40 -0400 Received: from rere.qmqm.pl ([91.227.64.183]:27795 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728706AbgECPVP (ORCPT ); Sun, 3 May 2020 11:21:15 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 49FV7X6YLPzrB; Sun, 3 May 2020 17:21:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1588519273; bh=CtdnXaW3M9J6/3+oqZVerhtAMCemduwcslAGnqFReTw=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=AEeTte93WKS/0qvl8ztsPhc0rzYLe3cAQXqzsiWa3GE8ChbGHXHAheLr8MGpCupwe wFbfobROysFQ7hb9vmTF/btBWTQZrMD4feNxBJwf8Noecbcvkl59DVbUZXaidcmt5d L4ENHvR+wSi4TrEP9j54sCI26BCBbAjYAAskbjl5caLckSg2uEPvhFus1QTcXPhL5y v5u2V3MkiSAYTu9QssmP+fnq07SqCQzEH0U/LjYo8yb5j8BJb6euuBoUeIOubXGJ4c KMHS1F7k6WWWE/IzXONciD3JM55NIg9VUnHoW4duXmioXREXF7jczyFE8OvPSQcs3y F/3Q84C9k0FGQ== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.2 at mail Date: Sun, 03 May 2020 17:21:12 +0200 Message-Id: <9b3bd77de9cfef8af8f8ab76270b46599f9e5ab1.1588517058.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v2 07/11] power: bq25890: implement CHARGE_TYPE property MIME-Version: 1.0 To: Rob Herring , Sebastian Reichel Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Report charging type based on recently read state. Signed-off-by: Michał Mirosław --- drivers/power/supply/bq25890_charger.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c index e4368d01396a..ad0901fdceb6 100644 --- a/drivers/power/supply/bq25890_charger.c +++ b/drivers/power/supply/bq25890_charger.c @@ -429,6 +429,18 @@ static int bq25890_power_supply_get_property(struct power_supply *psy, break; + case POWER_SUPPLY_PROP_CHARGE_TYPE: + if (!state.online || state.chrg_status == STATUS_NOT_CHARGING || + state.chrg_status == STATUS_TERMINATION_DONE) + val->intval = POWER_SUPPLY_CHARGE_TYPE_NONE; + else if (state.chrg_status == STATUS_PRE_CHARGING) + val->intval = POWER_SUPPLY_CHARGE_TYPE_STANDARD; + else if (state.chrg_status == STATUS_FAST_CHARGING) + val->intval = POWER_SUPPLY_CHARGE_TYPE_FAST; + else /* unreachable */ + val->intval = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN; + break; + case POWER_SUPPLY_PROP_MANUFACTURER: val->strval = BQ25890_MANUFACTURER; break; @@ -670,6 +682,7 @@ static const enum power_supply_property bq25890_power_supply_props[] = { POWER_SUPPLY_PROP_MANUFACTURER, POWER_SUPPLY_PROP_MODEL_NAME, POWER_SUPPLY_PROP_STATUS, + POWER_SUPPLY_PROP_CHARGE_TYPE, POWER_SUPPLY_PROP_ONLINE, POWER_SUPPLY_PROP_HEALTH, POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT, From patchwork Sun May 3 15:21:13 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: 201191 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=-6.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=ham 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 80535C47259 for ; Sun, 3 May 2020 15:21:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 57FF320836 for ; Sun, 3 May 2020 15:21:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=rere.qmqm.pl header.i=@rere.qmqm.pl header.b="RopMzqEd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728836AbgECPVk (ORCPT ); Sun, 3 May 2020 11:21:40 -0400 Received: from rere.qmqm.pl ([91.227.64.183]:59391 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728709AbgECPVP (ORCPT ); Sun, 3 May 2020 11:21:15 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 49FV7Y2NWdzBc; Sun, 3 May 2020 17:21:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1588519273; bh=j/RXM+fNBpI5abZHjWXnC0UL+wj8lzgTO3a3XRS4VRU=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=RopMzqEdt2k3EhVrpoxZUHP+e7++yDN2QM8vDrySiLubm8gTIHh8LmmjY5PeAV+Jh X4gOFPG/P9M8/qaaomk0YcuR+AKXLvi2610zUsvV+JPl26cOAiU5RPoLTSAH3V4vii kXu3nSgEam2KBZ5MqCxMtNzDE9vihUpRgK4NL3Xxhgl9BIXh+b0o8Vb1MYajl8bH2O FqVYpZZJyxIIGmCDXqVQ7wPej5ctZFHv4YulbkgijbBYLN/SN+Bh19jTRe4UOAqxUF CtgcixercNi0WIKqtM7fuYjs17bA40NS1sSYFuZwh/FsSBYdZCP/ybA2U8GV4ZLHUn iT7MRDOuC6v3Q== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.2 at mail Date: Sun, 03 May 2020 17:21:13 +0200 Message-Id: In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v2 08/11] power: bq25890: implement PRECHARGE_CURRENT property MIME-Version: 1.0 To: Rob Herring , Sebastian Reichel Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Report configured precharge current. Signed-off-by: Michał Mirosław --- drivers/power/supply/bq25890_charger.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c index ad0901fdceb6..b48685009048 100644 --- a/drivers/power/supply/bq25890_charger.c +++ b/drivers/power/supply/bq25890_charger.c @@ -497,6 +497,10 @@ static int bq25890_power_supply_get_property(struct power_supply *psy, val->intval = bq25890_find_val(bq->init_data.vreg, TBL_VREG); break; + case POWER_SUPPLY_PROP_PRECHARGE_CURRENT: + val->intval = bq25890_find_val(bq->init_data.iprechg, TBL_ITERM); + break; + case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT: val->intval = bq25890_find_val(bq->init_data.iterm, TBL_ITERM); break; @@ -689,6 +693,7 @@ static const enum power_supply_property bq25890_power_supply_props[] = { POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX, POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE, POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX, + POWER_SUPPLY_PROP_PRECHARGE_CURRENT, POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT, POWER_SUPPLY_PROP_VOLTAGE_NOW, }; From patchwork Sun May 3 15:21:13 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: 201193 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=-6.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS 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 E678FC28CBC for ; Sun, 3 May 2020 15:21:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C64F020836 for ; Sun, 3 May 2020 15:21:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=rere.qmqm.pl header.i=@rere.qmqm.pl header.b="XdOrHPWZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728784AbgECPVT (ORCPT ); Sun, 3 May 2020 11:21:19 -0400 Received: from rere.qmqm.pl ([91.227.64.183]:44073 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728731AbgECPVR (ORCPT ); Sun, 3 May 2020 11:21:17 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 49FV7Y5Y3YzGj; Sun, 3 May 2020 17:21:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1588519273; bh=gRqyNiKmpXtCcJah85qRJb4ZmdxMMi1xeLY32RUkzmw=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=XdOrHPWZRiIUVwKr8xqvyDxjKdLqwZ+yKi0xARn1bSUANXrFnGLH5Csiov+g3DrhB mqlqKgdQltrnzTA4OmGXpVB8iUdMMoyoEDvykwEObBmVmdiC2J+qZVtg4La4NFpMNu VLgXt7D2+x8NMdzNHVjSFICQULOmeoHesXIeOtxlIKMCxDrQJ/0+RhvacfkL7qctsU +9eEmFoRZNSPCnU4q/kR7mg5yph3cQClBotymVBl1QDYzx0j124ncNvpX+Mb+nae2P ZZIEptvTnKe33SoYloW7t/fa6B2ymTIHTvtAVbIkg1Y3HdVnsz949//5PNj41sXDl8 CAajXGp1bvnrw== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.2 at mail Date: Sun, 03 May 2020 17:21:13 +0200 Message-Id: <48d71a9b286e688ce8155449f62dc8fe0da39f17.1588517058.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v2 09/11] power: bq25890: implement INPUT_CURRENT_LIMIT property MIME-Version: 1.0 To: Rob Herring , Sebastian Reichel Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Report REG00.IINLIM value as INPUT_CURRENT_LIMIT property. Signed-off-by: Michał Mirosław --- drivers/power/supply/bq25890_charger.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c index b48685009048..87c5832e23d3 100644 --- a/drivers/power/supply/bq25890_charger.c +++ b/drivers/power/supply/bq25890_charger.c @@ -254,6 +254,7 @@ enum bq25890_table_ids { /* range tables */ TBL_ICHG, TBL_ITERM, + TBL_IILIM, TBL_VREG, TBL_BOOSTV, TBL_SYSVMIN, @@ -294,6 +295,7 @@ static const union { /* TODO: BQ25896 has max ICHG 3008 mA */ [TBL_ICHG] = { .rt = {0, 5056000, 64000} }, /* uA */ [TBL_ITERM] = { .rt = {64000, 1024000, 64000} }, /* uA */ + [TBL_IILIM] = { .rt = {50000, 3200000, 50000} }, /* uA */ [TBL_VREG] = { .rt = {3840000, 4608000, 16000} }, /* uV */ [TBL_BOOSTV] = { .rt = {4550000, 5510000, 64000} }, /* uV */ [TBL_SYSVMIN] = { .rt = {3000000, 3700000, 100000} }, /* uV */ @@ -505,6 +507,14 @@ static int bq25890_power_supply_get_property(struct power_supply *psy, val->intval = bq25890_find_val(bq->init_data.iterm, TBL_ITERM); break; + case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT: + ret = bq25890_field_read(bq, F_IILIM); + if (ret < 0) + return ret; + + val->intval = bq25890_find_val(ret, TBL_IILIM); + break; + case POWER_SUPPLY_PROP_VOLTAGE_NOW: ret = bq25890_field_read(bq, F_SYSV); /* read measured value */ if (ret < 0) @@ -695,6 +705,7 @@ static const enum power_supply_property bq25890_power_supply_props[] = { POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX, POWER_SUPPLY_PROP_PRECHARGE_CURRENT, POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT, + POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, POWER_SUPPLY_PROP_VOLTAGE_NOW, };