Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp678674pxb; Tue, 5 Apr 2022 18:26:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwA7Djcmbo/l8UXyjDxZwBG+1xqinW5mweY5pUG6aYk0bY1/3y8xvfC20546QFhDBvSY6Z7 X-Received: by 2002:a17:906:6a81:b0:6da:d7e5:4fa with SMTP id p1-20020a1709066a8100b006dad7e504famr6229999ejr.223.1649208366035; Tue, 05 Apr 2022 18:26:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649208366; cv=none; d=google.com; s=arc-20160816; b=RVwaqbRO26ONDIY4Xo8oydo9Em58CBY7ZW/5Bgw7h9UV6wpUkUI/KWX6/DIlg0gyyh OPr8vCvtwpASdkvkKDD8xmAAqAGR1SkMCbGQvC3vRgyXj8Z7PjkSSx2YfYJK+750Lyw2 W6bJFY95qS/EkKDKNmB9hirpbbgxDL7Lm4XTFRsQVIZsBuNms7ZRnLzMgjGb+/7EOsDR z7L2Ic2cqNE7bnj0yuB9fbJ8/NcbyMIsqecCIcFXiWAgY/EBJhiKR4DtyDhi39xNQSXo gYgRgHFdqDqb5N+rDt+HzWbL56VY2EPBu5a0K5kXX+Ktgzvo1aK2Z4aSAvnRD+Kxr0Ko VaAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=g4SwPFeoI7mNLcOIN89WikGMKIEwBZVxGqlJbzRyJfo=; b=N0zgG6ADSfH+fROZ3mKNJN3G6QF1PYnWuD5oOoo8VyaEW1dFi6VTEjdXk+eS/YTcfY FQvFCIbGGX0wt76ffXu6J+043wcsa/iM9RjEmjBHVdqUCygXckD5XYtTO0lq8fxDodU4 A4z1Cpa3APWWN2SvQsrTkhFcNxxscIB6VaVRsjf3D9Kvk2v74ne4GE0mF4OCa+uamCSt 4ooxaOMu1VOvtzkRAmRLseAz8cYv4twhZ2Qfgm4qT+WhNMzFAW585KPjVlCCDzhH1/9v N09qzsYZHgNAOakDmQmK8H788jW6kuMajvTyjUMImOsQm/MfKTu7QmKNujUbY0SX2QiX PzEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Tfb33VJY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b19-20020a1709063f9300b006df76385edbsi10352965ejj.891.2022.04.05.18.25.41; Tue, 05 Apr 2022 18:26:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Tfb33VJY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384496AbiDEM1g (ORCPT + 99 others); Tue, 5 Apr 2022 08:27:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235573AbiDEIQP (ORCPT ); Tue, 5 Apr 2022 04:16:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A3721CFEC; Tue, 5 Apr 2022 01:03:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EA2016167A; Tue, 5 Apr 2022 08:03:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1F5EC385A2; Tue, 5 Apr 2022 08:03:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649145814; bh=oBueRlGnsA+SB0G09LAGMW5kSeGEyH/mD0Q4eBI8Owk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tfb33VJYW5O0sHCdK3bPBdJdwadjwIT0rNhnFwXBk9Ye6rzBQZwsJPImI4IJXaULz K1kdQ4fK5+WjN+dqPi/VhzRo1BYRFd2dv1+/9Xhbfy67a/v9IYDhpdEEYrYvv0q0eX TOCdAVjg2aTjei/T7eQX9VQs5RhbIu6gIAmdN6pU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Linus Walleij , Sebastian Reichel , Sasha Levin Subject: [PATCH 5.17 0538/1126] power: supply: ab8500: Swap max and overvoltage Date: Tue, 5 Apr 2022 09:21:25 +0200 Message-Id: <20220405070423.423986849@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Linus Walleij [ Upstream commit d662a7df36e1edc65eaf166ec1c8527ce9d088ea ] We should terminate charging when we reach the voltage_max_design_uv not overvoltage_limit_uv, this is an abuse of that struct member. The overvoltage limit is actually not configurable on the AB8500, it is fixed to 4.75 V so drop a comment about that in the code. Fixes: 2a5f41830aad ("power: supply: ab8500: Standardize voltages") Signed-off-by: Linus Walleij Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin --- drivers/power/supply/ab8500_bmdata.c | 8 +++----- drivers/power/supply/ab8500_chargalg.c | 2 +- drivers/power/supply/ab8500_fg.c | 8 +++++++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/power/supply/ab8500_bmdata.c b/drivers/power/supply/ab8500_bmdata.c index 7ae95f537580..9a8334a65de1 100644 --- a/drivers/power/supply/ab8500_bmdata.c +++ b/drivers/power/supply/ab8500_bmdata.c @@ -188,13 +188,11 @@ int ab8500_bm_of_probe(struct power_supply *psy, * fall back to safe defaults. */ if ((bi->voltage_min_design_uv < 0) || - (bi->voltage_max_design_uv < 0) || - (bi->overvoltage_limit_uv < 0)) { + (bi->voltage_max_design_uv < 0)) { /* Nominal voltage is 3.7V for unknown batteries */ bi->voltage_min_design_uv = 3700000; - bi->voltage_max_design_uv = 3700000; - /* Termination voltage (overcharge limit) 4.05V */ - bi->overvoltage_limit_uv = 4050000; + /* Termination voltage 4.05V */ + bi->voltage_max_design_uv = 4050000; } if (bi->constant_charge_current_max_ua < 0) diff --git a/drivers/power/supply/ab8500_chargalg.c b/drivers/power/supply/ab8500_chargalg.c index c4a2fe07126c..bcf85ae6828e 100644 --- a/drivers/power/supply/ab8500_chargalg.c +++ b/drivers/power/supply/ab8500_chargalg.c @@ -802,7 +802,7 @@ static void ab8500_chargalg_end_of_charge(struct ab8500_chargalg *di) if (di->charge_status == POWER_SUPPLY_STATUS_CHARGING && di->charge_state == STATE_NORMAL && !di->maintenance_chg && (di->batt_data.volt_uv >= - di->bm->bi->overvoltage_limit_uv || + di->bm->bi->voltage_max_design_uv || di->events.usb_cv_active || di->events.ac_cv_active) && di->batt_data.avg_curr_ua < di->bm->bi->charge_term_current_ua && diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c index b0919a6a6587..236fd9f9d6f1 100644 --- a/drivers/power/supply/ab8500_fg.c +++ b/drivers/power/supply/ab8500_fg.c @@ -2263,7 +2263,13 @@ static int ab8500_fg_init_hw_registers(struct ab8500_fg *di) { int ret; - /* Set VBAT OVV threshold */ + /* + * Set VBAT OVV (overvoltage) threshold to 4.75V (typ) this is what + * the hardware supports, nothing else can be configured in hardware. + * See this as an "outer limit" where the charger will certainly + * shut down. Other (lower) overvoltage levels need to be implemented + * in software. + */ ret = abx500_mask_and_set_register_interruptible(di->dev, AB8500_CHARGER, AB8500_BATT_OVV, -- 2.34.1