From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A88B16F84F; Wed, 2 Oct 2024 13:27:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727875675; cv=none; b=tCYo/G345JELQ0xbk7W3i08uV8l7KVMahre5i92vxncmwmH+JdLotFetizM1TZcZuYU1Pqlm2tC+VKPTSP9Nfpmiua1N4GAwZS27R9jhGUBYSXCzuYQJ/It46p0Fyx2S7f3Ox3Ek2Ug1/kqr4GYATvmXavMVe9rclAPPj9/cRgM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727875675; c=relaxed/simple; bh=fUCf49a+zYVbid/Z2vcWtVE9YpkPepgQPMJp1o7pa6w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c7cADK+S4qr6zd2RjYpLX1KF5/uilO5gNNVvO4gIcGfIv7Tcjo8r1uf16/NhSUfCqx48pUyJIlEgOAnGlU5stJWMpxWF7ZW+ZHwrw/tpA+nQkFO1ZtIdQPdLFKB4M6UMvJKg4dkjqd2g+b/jrRQYh+7D/NH8jeA+ZGE3MTWJ6RU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=2p+tpphZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="2p+tpphZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2477CC4CECD; Wed, 2 Oct 2024 13:27:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1727875675; bh=fUCf49a+zYVbid/Z2vcWtVE9YpkPepgQPMJp1o7pa6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2p+tpphZxvJl9DyP0U8Tu851tTLk8/Nirt+Ze/RqqWuvu9E8GT/MytnP7xQjp3Rx/ DTzRgAYeU/lnh1jizSmIIwLnDc09zRvG/2jScrgLCpi/kbhGNUUPB1OrGI6wjJOexw jPbN9gfAeG0h1fMRKygaupN24h9YMXflNEI69IDc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Artur Weber , Henrik Grimler , Krzysztof Kozlowski , Sebastian Reichel , Sasha Levin Subject: [PATCH 6.11 181/695] power: supply: max17042_battery: Fix SOC threshold calc w/ no current sense Date: Wed, 2 Oct 2024 14:52:59 +0200 Message-ID: <20241002125829.696254025@linuxfoundation.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241002125822.467776898@linuxfoundation.org> References: <20241002125822.467776898@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.11-stable review patch. If anyone has any objections, please let me know. ------------------ From: Artur Weber [ Upstream commit 3a3acf839b2cedf092bdd1ff65b0e9895df1656b ] Commit 223a3b82834f ("power: supply: max17042_battery: use VFSOC for capacity when no rsns") made it so that capacity on systems without current sensing would be read from VFSOC instead of RepSOC. However, the SOC threshold calculation still read RepSOC to get the SOC regardless of the current sensing option state. Fix this by applying the same conditional to determine which register should be read. This also seems to be the intended behavior as per the datasheet - SOC alert config value in MiscCFG on setups without current sensing is set to a value of 0b11, indicating SOC alerts being generated based on VFSOC, instead of 0b00 which indicates SOC alerts being generated based on RepSOC. This fixes an issue on the Galaxy S3/Midas boards, where the alert interrupt would be constantly retriggered, causing high CPU usage on idle (around ~12%-15%). Fixes: e5f3872d2044 ("max17042: Add support for signalling change in SOC") Signed-off-by: Artur Weber Reviewed-by: Henrik Grimler Reviewed-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20240817-max17042-soc-threshold-fix-v1-1-72b45899c3cc@gmail.com Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin --- drivers/power/supply/max17042_battery.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c index e7d37e422c3f6..496c3e1f2ee6d 100644 --- a/drivers/power/supply/max17042_battery.c +++ b/drivers/power/supply/max17042_battery.c @@ -853,7 +853,10 @@ static void max17042_set_soc_threshold(struct max17042_chip *chip, u16 off) /* program interrupt thresholds such that we should * get interrupt for every 'off' perc change in the soc */ - regmap_read(map, MAX17042_RepSOC, &soc); + if (chip->pdata->enable_current_sense) + regmap_read(map, MAX17042_RepSOC, &soc); + else + regmap_read(map, MAX17042_VFSOC, &soc); soc >>= 8; soc_tr = (soc + off) << 8; if (off < soc) -- 2.43.0