From patchwork Mon Dec 17 02:52:27 2018 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: 10732679 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 49295746 for ; Mon, 17 Dec 2018 02:52:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3426929CF7 for ; Mon, 17 Dec 2018 02:52:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 25D8929CF8; Mon, 17 Dec 2018 02:52:30 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 C6C4229CDB for ; Mon, 17 Dec 2018 02:52:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726347AbeLQCw2 (ORCPT ); Sun, 16 Dec 2018 21:52:28 -0500 Received: from rere.qmqm.pl ([91.227.64.183]:15428 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731256AbeLQCw2 (ORCPT ); Sun, 16 Dec 2018 21:52:28 -0500 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 43J5J52sLnz8Z; Mon, 17 Dec 2018 03:51:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1545015061; bh=VfIYIOTzxWGB9s1rj+codWEwRlfQK+mROmPj/OXqoCs=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=nuVsyzwS7cIb44MFl3L5BIuS3/NR/8U/BYEd7+YpYR7ozhR2svsj8l2hJniP1QFl0 DUO+GkS2Mt8yFm0ebhwQLm1HwMDd93dl1ze2tgwlzS8KAsqWHwkfgPs7unON5uRiVi ebngtVyZQ8UvLIvpvJWZF6BLhBmXhTYidJ8Nx27E63U1O8tnyF0vIp1kzfha913+uz /wT9vwWQjDTp1D0QMCZNZWOeRVpM37XdKtRGJ+eZTc8Qsg7OOuqtYCNCMefLR36Wpw XlEqKv58ubOyzID0pkMV3SRMNEaRxDjYyL6BFEmYsrlvxCK8YBE/qabLXhB8E14VWM GeJF8iSQvqOWg== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.100.2 at mail Date: Mon, 17 Dec 2018 03:52:27 +0100 Message-Id: <63add1fcf261eda715a3d9ffb3d43692ae1aec7d.1545014442.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH 1/3] power: supply: bq25890: fix BAT_COMP field definition MIME-Version: 1.0 To: linux-pm@vger.kernel.org Cc: Sebastian Reichel , Laurentiu Palcu 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 According to datasheet, BAT_COMP field spans bits 5-7. The rest of the code seems to assume this already. Fixes: 4aeae9cb0dad ("power_supply: Add support for TI BQ25890 charger chip") Signed-off-by: Michał Mirosław --- drivers/power/supply/bq25890_charger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c index 8e2c41ded171..db66f38d6b04 100644 --- a/drivers/power/supply/bq25890_charger.c +++ b/drivers/power/supply/bq25890_charger.c @@ -181,7 +181,7 @@ static const struct reg_field bq25890_reg_fields[] = { [F_CHG_TMR] = REG_FIELD(0x07, 1, 2), [F_JEITA_ISET] = REG_FIELD(0x07, 0, 0), /* REG08 */ - [F_BATCMP] = REG_FIELD(0x08, 6, 7), + [F_BATCMP] = REG_FIELD(0x08, 5, 7), [F_VCLAMP] = REG_FIELD(0x08, 2, 4), [F_TREG] = REG_FIELD(0x08, 0, 1), /* REG09 */ From patchwork Mon Dec 17 02:52:27 2018 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: 10732685 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 290BA746 for ; Mon, 17 Dec 2018 02:52:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F46E29CDB for ; Mon, 17 Dec 2018 02:52:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 13CF029CF0; Mon, 17 Dec 2018 02:52:31 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 AA9D329CDB for ; Mon, 17 Dec 2018 02:52:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726287AbeLQCwa (ORCPT ); Sun, 16 Dec 2018 21:52:30 -0500 Received: from rere.qmqm.pl ([91.227.64.183]:50125 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731260AbeLQCw3 (ORCPT ); Sun, 16 Dec 2018 21:52:29 -0500 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 43J5J551nBzMy; Mon, 17 Dec 2018 03:51:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1545015061; bh=gsuyRNATvcY+AiX3OuQh0oQfCict15tV1nUV7tiYIhw=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=MsdLqlCTP4sqGVwKyAZRQoQ/aQn+yXFedmVxhsWNgSRgJPmJ2IREJ4upEHaicQR4w FmtcGSmV3KC2BDHSacVv2gEAStaWMiJ6Zmee2VkvJtxVSrzXYBJSob7y8JW1Idqaib ctsUSxh3k6wCBzHQBfH4ul7Lf1EAAwNeuEP7t9SYUQ6cBB5wE6J8jEeReEqqe2Wx+J CTA9lOVIXgzkD3MwEJ5FrXciyKSItVcNVJq9npNfYuipUxCTmsuqdXimT8GrB73pfz nGzvNNTMlPd5/OJ0WP9BonaXhkze8CvKhSOBPPJjf/JHvekuslEBk0XIYIHnpsXeo+ g5KXPxApNK2tg== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.100.2 at mail Date: Mon, 17 Dec 2018 03:52:27 +0100 Message-Id: <5b86085ab672eca5fdef13f7fde27dce066eb0b6.1545014442.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH 2/3] power: supply: bq25890: support BQ25896 MIME-Version: 1.0 To: linux-pm@vger.kernel.org Cc: Sebastian Reichel , Laurentiu Palcu 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 BQ25896 differs only slightly from BQ25890/2. Add the required ID and two additional fields from datasheet. Signed-off-by: Michał Mirosław --- drivers/power/supply/bq25890_charger.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c index db66f38d6b04..a8b2d939cfcd 100644 --- a/drivers/power/supply/bq25890_charger.c +++ b/drivers/power/supply/bq25890_charger.c @@ -32,13 +32,15 @@ #define BQ25890_IRQ_PIN "bq25890_irq" #define BQ25890_ID 3 +#define BQ25896_ID 0 enum bq25890_fields { F_EN_HIZ, F_EN_ILIM, F_IILIM, /* Reg00 */ F_BHOT, F_BCOLD, F_VINDPM_OFS, /* Reg01 */ F_CONV_START, F_CONV_RATE, F_BOOSTF, F_ICO_EN, F_HVDCP_EN, F_MAXC_EN, F_FORCE_DPM, F_AUTO_DPDM_EN, /* Reg02 */ - F_BAT_LOAD_EN, F_WD_RST, F_OTG_CFG, F_CHG_CFG, F_SYSVMIN, /* Reg03 */ + F_BAT_LOAD_EN, F_WD_RST, F_OTG_CFG, F_CHG_CFG, + F_SYSVMIN, F_MIN_VBAT, /* Reg03 */ F_PUMPX_EN, F_ICHG, /* Reg04 */ F_IPRECHG, F_ITERM, /* Reg05 */ F_VREG, F_BATLOWV, F_VRECHG, /* Reg06 */ @@ -47,7 +49,7 @@ enum bq25890_fields { F_BATCMP, F_VCLAMP, F_TREG, /* Reg08 */ F_FORCE_ICO, F_TMR2X_EN, F_BATFET_DIS, F_JEITA_VSET, F_BATFET_DLY, F_BATFET_RST_EN, F_PUMPX_UP, F_PUMPX_DN, /* Reg09 */ - F_BOOSTV, F_BOOSTI, /* Reg0A */ + F_BOOSTV, F_PFM_DIS, F_BOOSTI, /* Reg0A */ F_VBUS_STAT, F_CHG_STAT, F_PG_STAT, F_SDP_STAT, F_VSYS_STAT, /* Reg0B */ F_WD_FAULT, F_BOOST_FAULT, F_CHG_FAULT, F_BAT_FAULT, F_NTC_FAULT, /* Reg0C */ @@ -163,6 +165,7 @@ static const struct reg_field bq25890_reg_fields[] = { [F_OTG_CFG] = REG_FIELD(0x03, 5, 5), [F_CHG_CFG] = REG_FIELD(0x03, 4, 4), [F_SYSVMIN] = REG_FIELD(0x03, 1, 3), + [F_MIN_VBAT] = REG_FIELD(0x03, 0, 0), /* REG04 */ [F_PUMPX_EN] = REG_FIELD(0x04, 7, 7), [F_ICHG] = REG_FIELD(0x04, 0, 6), @@ -195,6 +198,7 @@ static const struct reg_field bq25890_reg_fields[] = { [F_PUMPX_DN] = REG_FIELD(0x09, 0, 0), /* REG0A */ [F_BOOSTV] = REG_FIELD(0x0A, 4, 7), + [F_PFM_DIS] = REG_FIELD(0x0A, 3, 3), [F_BOOSTI] = REG_FIELD(0x0A, 0, 2), /* REG0B */ [F_VBUS_STAT] = REG_FIELD(0x0B, 5, 7), @@ -840,9 +844,11 @@ static int bq25890_probe(struct i2c_client *client, return bq->chip_id; } - if (bq->chip_id != BQ25890_ID) { + if (bq->chip_id != BQ25890_ID && bq->chip_id != BQ25896_ID) { dev_err(dev, "Chip with ID=%d, not supported!\n", bq->chip_id); return -ENODEV; + } else { + dev_info(dev, "Chip ID %d, rev %d\n", bq->chip_id, bq25890_field_read(bq, F_DEV_REV)); } if (!dev->platform_data) { From patchwork Mon Dec 17 02:52:27 2018 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: 10732683 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 80655184E for ; Mon, 17 Dec 2018 02:52:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75EC329CDB for ; Mon, 17 Dec 2018 02:52:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A1A829CE3; Mon, 17 Dec 2018 02:52:30 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 1C7B429CF0 for ; Mon, 17 Dec 2018 02:52:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726285AbeLQCw3 (ORCPT ); Sun, 16 Dec 2018 21:52:29 -0500 Received: from rere.qmqm.pl ([91.227.64.183]:41399 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726287AbeLQCw3 (ORCPT ); Sun, 16 Dec 2018 21:52:29 -0500 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 43J5J606JszVB; Mon, 17 Dec 2018 03:51:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1545015062; bh=D8kXtGaFc4kxA/LxmicHHRoj9W79pKYyoZtNcg3qoXg=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=CQJw6gJQwHpYdpOd0UlfOt+f4m6f65nwt0P/PX1VUjpmFsJglolqZIcQaToAzKEHf tV48d33ONx0c+/0lwFHbVkKPvsdBvSRR1+3Vk0B1xPwEeiqTLVkAAMS8UWYyelo1d3 uIpHc7181yu6C72C26opNHnr2VAtjYlYjbucsXpnF+in5UesBoTK3yQaRu5epJ6xmQ MyYOArETsi3eU5qr/MhXKBGmyhxJcEJxDqGyfCBbQwqUDVLji+Sg30Az2SCOIvzatJ C760Oiw0+NjiZevowV7MgBGqDQU3r24VwutoxlU3HgvjV8L62NH8c7/RaTMEWT5+93 ltNHhVVsqPT1g== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.100.2 at mail Date: Mon, 17 Dec 2018 03:52:27 +0100 Message-Id: In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH 3/3] power: supply: bq25890: show max charge current/voltage as configured MIME-Version: 1.0 To: linux-pm@vger.kernel.org Cc: Sebastian Reichel , Laurentiu Palcu 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 Use firmware-provided limits for POWER_SUPPLY_*_MAX properties instead of chip max values. This will reflect the battery limits as those are the important ones. Signed-off-by: Michał Mirosław --- drivers/power/supply/bq25890_charger.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c index a8b2d939cfcd..f998738fa239 100644 --- a/drivers/power/supply/bq25890_charger.c +++ b/drivers/power/supply/bq25890_charger.c @@ -432,7 +432,7 @@ static int bq25890_power_supply_get_property(struct power_supply *psy, break; case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: - val->intval = bq25890_tables[TBL_ICHG].rt.max; + val->intval = bq25890_find_val(bq->init_data.ichg, TBL_ICHG); break; case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: @@ -450,7 +450,7 @@ static int bq25890_power_supply_get_property(struct power_supply *psy, break; case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX: - val->intval = bq25890_tables[TBL_VREG].rt.max; + val->intval = bq25890_find_val(bq->init_data.vreg, TBL_VREG); break; case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT: