From patchwork Sun Jul 9 02:16:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Breck X-Patchwork-Id: 9831591 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DD6EA602BD for ; Sun, 9 Jul 2017 02:17:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6A27251F4 for ; Sun, 9 Jul 2017 02:17:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB7BB2656B; Sun, 9 Jul 2017 02:17:43 +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=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 4DD71251F4 for ; Sun, 9 Jul 2017 02:17:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751856AbdGICRm (ORCPT ); Sat, 8 Jul 2017 22:17:42 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:34685 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751654AbdGICRm (ORCPT ); Sat, 8 Jul 2017 22:17:42 -0400 Received: by mail-pg0-f66.google.com with SMTP id j186so8546812pge.1 for ; Sat, 08 Jul 2017 19:17:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=nBt9G9o/6X/RJ9olowcmAnihrFUlYfjkHnDaPiED9Sw=; b=QlTkI94IZ7a47JlDFLmpNtnCBlgncD5NR06BWyiqcXhi4ekQkZTB1IA2lXyWtY2mIx IVOKd6lLqNjdFXaCs3EOVbmsTGDyyoa4O8qesLOEGVl10dib5PFOceQHB8bWCaVlT3sx xdNImTzEEH1Kr3oWkc60hpPGOfySHcT+USgPtLDVxBldiLIEG0gT9wHphPfmJbijzUpc CP4efuVI+pQjOMcRISp3SVixKnn2XED8Fi3Ef/3sB4qhRSkQR8v9qvm87hcYu+BVTI1R h/spEwlpH2EWQyUVcfk6hQzF27DNv1s88rH+kkS4wLF6wO/ORbK25TN+x+nth0hGX69J +rzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=nBt9G9o/6X/RJ9olowcmAnihrFUlYfjkHnDaPiED9Sw=; b=gzbFROi16Luhmu0y4RZbHN8t2+unTVLckJ6N+LLX25Aw6DU86EfED6fAwZVioMClXV zqIALbQ2XyWD7ofrQKE6I/80ydY9GaTR/fJbVh0fJGyaFfUbv3oIQOXtzTHLxLB+oM2x wjqV/l6zftkukXawggIrDcH+VDRnB6JD2HE+AvD9Gdtgfs0ShsBYJIjcX7rVzcxzpnRm 2M/qmP29Hgd2wJ6QY6mX5kTmLGm7/glbe59PeMXF7yNb/tpCX4Ywz31ZcD3PZAC8RayC vmhCdWBL7Fsb6IfOz/aWwEa1RT9wSNbAbr3K/a1dK/AWCTW/KvJvJbmw2mfhopHH5fhp Flqg== X-Gm-Message-State: AIVw112yv/bU1OsGIOjT9hJoayuTFr4qFdGJl0Hz1hN8UScmlAWIF6JX n1CsY4sHBNAyYGI62d4= X-Received: by 10.99.123.74 with SMTP id k10mr8265589pgn.226.1499566661348; Sat, 08 Jul 2017 19:17:41 -0700 (PDT) Received: from localhost.localdomain (c-73-223-93-234.hsd1.ca.comcast.net. [73.223.93.234]) by smtp.gmail.com with ESMTPSA id h184sm14994026pge.66.2017.07.08.19.17.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 08 Jul 2017 19:17:40 -0700 (PDT) From: Liam Breck To: Sebastian Reichel , =?UTF-8?q?Pali=20Roh=C3=A1r?= , linux-pm@vger.kernel.org Cc: Paul Kocialkowski , Liam Breck Subject: [RFC v1 4/6] power: supply: bq27xxx: Add chip data options for cfgupdate & ram-only Date: Sat, 8 Jul 2017 19:16:58 -0700 Message-Id: <20170709021700.14354-5-liam@networkimprov.net> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20170709021700.14354-1-liam@networkimprov.net> References: <20170709021700.14354-1-liam@networkimprov.net> 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 From: Liam Breck Add BQ27XXX_O_CFGUP & _O_RAM for use in bq27xxx_chip_data[n].opts Replace related uses of di->chip == BQ27nnn with (BQ27XXX_O_XYZ & di->opts) No functional changes to the driver. Signed-off-by: Liam Breck --- drivers/power/supply/bq27xxx_battery.c | 22 +++++++++++----------- include/linux/power/bq27xxx_battery.h | 1 - 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c index 0bd46fae..5d3893a9 100644 --- a/drivers/power/supply/bq27xxx_battery.c +++ b/drivers/power/supply/bq27xxx_battery.c @@ -871,6 +871,9 @@ static struct bq27xxx_dm_reg bq27621_dm_regs[] = { #define bq27621_dm_regs 0 #endif +#define BQ27XXX_O_CFGUP 0x00000001 +#define BQ27XXX_O_RAM 0x00000002 + #define BQ27XXX_DATA(ref, act, key, opt) { \ .opts = (opt), \ .acts_like = act, \ @@ -909,10 +912,10 @@ static struct { [BQ27546] = BQ27XXX_DATA(546, BQ27541, 0, 0), [BQ27742] = BQ27XXX_DATA(742, BQ27541, 0, 0), [BQ27545] = BQ27XXX_DATA(545, 0, 0x04143672, 0), - [BQ27421] = BQ27XXX_DATA(421, 0, 0x80008000, 0), - [BQ27425] = BQ27XXX_DATA(425, BQ27421, 0x04143672, 0), - [BQ27441] = BQ27XXX_DATA(441, BQ27421, 0x80008000, 0), - [BQ27621] = BQ27XXX_DATA(621, BQ27421, 0x80008000, 0), + [BQ27421] = BQ27XXX_DATA(421, 0, 0x80008000, BQ27XXX_O_CFGUP | BQ27XXX_O_RAM), + [BQ27425] = BQ27XXX_DATA(425, BQ27421, 0x04143672, BQ27XXX_O_CFGUP), + [BQ27441] = BQ27XXX_DATA(441, BQ27421, 0x80008000, BQ27XXX_O_CFGUP | BQ27XXX_O_RAM), + [BQ27621] = BQ27XXX_DATA(621, BQ27421, 0x80008000, BQ27XXX_O_CFGUP | BQ27XXX_O_RAM), }; static DEFINE_MUTEX(bq27xxx_list_lock); @@ -1196,9 +1199,9 @@ static void bq27xxx_battery_update_dm_block(struct bq27xxx_device_info *di, } #ifdef CONFIG_BATTERY_BQ27XXX_DT_UPDATES_NVM - if (!di->ram_chip && !bq27xxx_dt_to_nvm) { + if (!(BQ27XXX_O_RAM & di->opts) && !bq27xxx_dt_to_nvm) { #else - if (!di->ram_chip) { + if (!(BQ27XXX_O_RAM & di->opts)) { #endif /* devicetree and NVM differ; defer to NVM */ dev_warn(di->dev, "%s has %u; update to %u disallowed " @@ -1266,7 +1269,7 @@ static inline int bq27xxx_battery_soft_reset(struct bq27xxx_device_info *di) static int bq27xxx_battery_write_dm_block(struct bq27xxx_device_info *di, struct bq27xxx_dm_buf *buf) { - bool cfgup = di->chip == BQ27421; /* assume related chips need cfgupdate */ + bool cfgup = BQ27XXX_O_CFGUP & di->opts; int ret; if (!buf->dirty) @@ -1365,7 +1368,7 @@ static void bq27xxx_battery_set_config(struct bq27xxx_device_info *di, bq27xxx_battery_seal(di); - if (updated && di->chip != BQ27421) { /* not a cfgupdate chip, so reset */ + if (updated && !(BQ27XXX_O_CFGUP & di->opts)) { bq27xxx_write(di, BQ27XXX_REG_CTRL, BQ27XXX_RESET, false); BQ27XXX_MSLEEP(300); /* reset time is not documented */ } @@ -1993,9 +1996,6 @@ int bq27xxx_battery_setup(struct bq27xxx_device_info *di) di->unseal_key = bq27xxx_chip_data[di->chip].unseal_key; di->dm_regs = bq27xxx_chip_data[di->chip].dm_regs; di->opts = bq27xxx_chip_data[di->chip].opts; - di->ram_chip = di->chip == BQ27421 || - di->chip == BQ27441 || - di->chip == BQ27621; psy_desc = devm_kzalloc(di->dev, sizeof(*psy_desc), GFP_KERNEL); if (!psy_desc) diff --git a/include/linux/power/bq27xxx_battery.h b/include/linux/power/bq27xxx_battery.h index 77fe94f1..8a8a3f61 100644 --- a/include/linux/power/bq27xxx_battery.h +++ b/include/linux/power/bq27xxx_battery.h @@ -71,7 +71,6 @@ struct bq27xxx_device_info { struct device *dev; int id; enum bq27xxx_chip chip; - bool ram_chip; u32 opts; const char *name; struct bq27xxx_dm_reg *dm_regs;