Received: by 10.213.65.68 with SMTP id h4csp219883imn; Fri, 23 Mar 2018 03:11:08 -0700 (PDT) X-Google-Smtp-Source: AG47ELsi11gYQuyMznE5/ABR1ZLVElOPIRcFlXRGvqmiiHY7MLBA5ry9sVPmWCJg/2kdGEw2tQF/ X-Received: by 10.98.80.5 with SMTP id e5mr9686289pfb.131.1521799868493; Fri, 23 Mar 2018 03:11:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521799868; cv=none; d=google.com; s=arc-20160816; b=QHk5TWD/7r2AUhTKexUHcImS78LQwUPqqCiq82o1lZxDz0zGzbMiqVI2PRUC6E/Jal IguZHz/Fve06WJvMeIO6AS4lS7/Wew0jfoWbFwuYH4Qw+8HzeIM9g9EZafB/MDmYz3p4 dsU2xG+hb+zbRhVFY5Sdds0aFjTmyzXU7Qjf7zly7Dt5ystLvIp6vW7IbWWNlQCOLs/X YI4ZSIkuI1fDnOE7hiMKS61c0alL6z5olQwhUyT9NTM8TN+shuvBYyjI7jnfMh1Vn2wC fYTI7KpKeB3NaelIF7sKXNm1W722Miua6t1moF6UsvY9tyNG0s44pxNDv7NaBbDEZeQm U3OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=2v3/xjMXXUmxKKOAbJ43wZLXCNDs3mNxMzCTPRNR07w=; b=PUkqfQpXr2Yr2WS/zIksgQinGCb4BI8EV/X9BdetXOfug6glxe3OqWxQuFcy6QqPGQ YYvIXCqNAsyC5aNTYffUbBKcRpf0BmZaSmP4zQv9Uo+z546kKBSj++WoqcDrDHf6zes0 L3rYsRVmfRHwZ/HdtPduzyPlNh9Bvz21T09E2G+2XOCszWxJtAr7mkcdZjrwbwVo3wsX r1pSUOW1Q8QEe23yeoYLIPoIAsoUhWuAqxbKC1uOnljzNWj8CoVFTxQFjfT8ghxhUpbT or+c7gaWGuwhrdKtUhMOiedx71uDdXbkqiNfyGJbkRoaNmJ2HpGMeOozagZnBjFAlHaT ESqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 66si6476674pfo.231.2018.03.23.03.10.54; Fri, 23 Mar 2018 03:11:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932597AbeCWKJ6 (ORCPT + 99 others); Fri, 23 Mar 2018 06:09:58 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:42306 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932539AbeCWKJx (ORCPT ); Fri, 23 Mar 2018 06:09:53 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 0BEE3FC9; Fri, 23 Mar 2018 10:09:52 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liam Breck , Tony Lindgren , Hans de Goede , Sebastian Reichel , Sasha Levin Subject: [PATCH 4.9 111/177] power: supply: bq24190_charger: Add disable-reset device-property Date: Fri, 23 Mar 2018 10:53:59 +0100 Message-Id: <20180323094210.163452732@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094205.090519271@linuxfoundation.org> References: <20180323094205.090519271@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hans de Goede [ Upstream commit 6cf62a3b97e78ba41d31390e59a1ddc98a9e3622 ] Allow platform-code to disable the reset on probe and suspend/resume by setting a "disable-reset" boolean device property on the device. There are several reasons why the platform-code may want to disable the reset on probe and suspend/resume: 1) Resetting the charger should never be necessary it should always have sane values programmed. If it is running with invalid values while we are not running (system turned off or suspended) there is a big problem as that may lead to overcharging the battery. 2) The reset in suspend() is meant to put the charger back into default mode, but this is not necessary and not a good idea. If the charger has been programmed with a higher max charge_current / charge_voltage then putting it back in default-mode will reset those to the safe power-on defaults, leading to slower charging, or charging to a lower voltage (and thus not using the full capacity) while suspended which is undesirable. Reprogramming the max charge_current / charge_voltage after the reset will not help here as that will put the charger back in host mode and start the i2c watchdog if the host then does not do anything for 40s (iow if we're suspended for more then 40s) the watchdog expires resetting the device to default-mode, including resetting all the registers to there safe power-on defaults. So the only way to keep using custom charge settings while suspending is to keep the charger in its normal running state with the i2c watchdog disabled. This is fine as the charger will still automatically switch from constant current to constant voltage and stop charging when the battery is full. 3) Besides never being necessary resetting the charger also causes problems on systems where the charge voltage limit is set higher then the reset value, if this is the case and the charger is reset while charging and the battery voltage is between the 2 voltages, then about half the time the charger gets confused and claims to be charging (REG08 contains 0x64) but in reality the charger has decoupled itself from VBUS (Q1 off) and is drawing 0A from VBUS, leaving the system running from the battery. This last problem is happening on a GPD-win mini PC with a bq24292i charger chip combined with a max17047 fuel-gauge and a LiHV battery. I've checked and TI does not list any errata for the bq24292i which could explain this (there are no errata at all). Cc: Liam Breck Cc: Tony Lindgren Signed-off-by: Hans de Goede Acked-by: Liam Breck Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/power/supply/bq24190_charger.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/power/supply/bq24190_charger.c +++ b/drivers/power/supply/bq24190_charger.c @@ -506,6 +506,9 @@ static int bq24190_register_reset(struct int ret, limit = 100; u8 v; + if (device_property_read_bool(bdi->dev, "disable-reset")) + return 0; + /* Reset the registers */ ret = bq24190_write_mask(bdi, BQ24190_REG_POC, BQ24190_REG_POC_RESET_MASK,