Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1387499lqg; Sun, 3 Mar 2024 07:44:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVphGuT827vs6CigSjfAborHD1+egrT4M2MNYso7Kkl6hx20gotcGVUna4LwGG8gX++xB3dS7Co8vkANNBO/yeH3g4eMlLSLw/dLIjV0Q== X-Google-Smtp-Source: AGHT+IGjIoPMgZiVhEfDynzxHWeMCEle/NY4T072gsow8EQy0cqWpowxgM5I6KAZKFbPDEsB3TaH X-Received: by 2002:a05:6a21:1014:b0:1a1:39a7:b87 with SMTP id nk20-20020a056a21101400b001a139a70b87mr4794558pzb.49.1709480689112; Sun, 03 Mar 2024 07:44:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709480689; cv=pass; d=google.com; s=arc-20160816; b=xhubIKgwA1gsmgXYoYK+T34jpCbexOBq36r7dsEoVCtmIr1tEfU8ZrSvP3yhu10+uJ C83j2tnHABVPUZSeeB/fdeAHXVeVU/9sQQiTwZvYU4AqTiARCLgAP2NEikY79it41oPV ZLB9q350qQ5w8c9nTP16daR55dUZBZMjEdqn6lXD4mj5qqYjHslQh+0TCVBVBuDD1wck G/wIKWWqzKXwtl8dw1Ef9rjpjB6+rdvcu1ZLhuRgjLd8DbatPjTf9f2WcmaDmjlEHaAX 4d3JennAc5TkFDH/hDc1bL8Vg50rg8zn1SbxeO+bcHDKHyPhfxiVZruEBNvNNkrGBax4 PGrQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=20xmk/5xBU9kGmFvofK5ObWS5VMArh5eFVXJOsXttaQ=; fh=dENBTHx7kJ0jlNJaErTJ7Ld+rhETTNznjDk+Wc/4RaE=; b=dxp7xGT2AKUyqfkTcfsnVU+T2P1BYlyHgQgpE2c85cM3IcKlaW0rCCBjaxFsHSOzx+ sKzUKVwzHq6ITWprRoU9gbbqytU0qtTccIgm3W/J3eai/YtqZfXcCNCXkMOWFfOpfRoj ywkjwVSzNVLsDXLkfBaPqFEc8TehBdwkcU7ihnEZG4ukKLVDjiHZVnoKdLgLAiiROI5P kXVVJywhVlhIKwIgzNzK8KyFE5DmbeNKUtO/18tTxuC8gLBVmexchZNl1L8oKHNt30F9 7JbJKEQYp07lOkzhARU+sIh21kasr3r7aZoqiPqUo/AnA6QxsSzM7Qw+F1WnPXp1+5Zv tvzw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=qSBoFGGm; arc=pass (i=1 spf=pass spfdomain=weissschuh.net dkim=pass dkdomain=weissschuh.net); spf=pass (google.com: domain of linux-kernel+bounces-89801-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89801-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id q138-20020a632a90000000b005dc477d69ddsi7082372pgq.25.2024.03.03.07.44.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Mar 2024 07:44:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89801-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=qSBoFGGm; arc=pass (i=1 spf=pass spfdomain=weissschuh.net dkim=pass dkdomain=weissschuh.net); spf=pass (google.com: domain of linux-kernel+bounces-89801-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89801-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 8419CB22F93 for ; Sun, 3 Mar 2024 15:32:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BDA1C67E93; Sun, 3 Mar 2024 15:31:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="qSBoFGGm" Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 9941E5A107; Sun, 3 Mar 2024 15:31:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709479893; cv=none; b=ik2hEOg8TGy26MmcESy3uWbPHMa3DvgxnFhdp3oM5GrCgQJObfHsoyh3oXAfhT+GDzlEPxoUTqnU9wGzYDuV6ZB0x9DN+XzLLGJ9PvhlfnPbLkSjEyqn1Akw9Odo8Z3q3HxA6UZNEK2CIcr3l+ODKeDaRX4cMIxUPPDQImjIFdo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709479893; c=relaxed/simple; bh=7Y+sg6xU/tnRXb7nijX/qTcZu9YebnvPyPbqD2+B3oc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LFEqHrQbs5HVUddafAtxPkvg+kErF6/cRJdMRJciNjMIp+ck15Ia/n1xFxv8PNY6IFDdlGCOQIx83254RLoOf2VFKUOys8PkzPbJKkD2/SPpxhpAp10p6yGBIWQGaOP0oJ5JSlRclrb/B8tfCOhxPZ0LKNC6Mdwu4MURdqnFUQo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=qSBoFGGm; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1709479880; bh=7Y+sg6xU/tnRXb7nijX/qTcZu9YebnvPyPbqD2+B3oc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=qSBoFGGmRDRvcBmdFarxZfB6CRYQi137tHupqZF9EWxtpaBPBOwUoC20rfFZAO/uq pJbuKtX5zxcrYjLkLSpk1H2LjNfHk8piSbazm+d9J8uytHCANIyC/iG6CuMc2ej277 kQDEZaI7GJu14tYkKHbt++UDSxhVe5rlTdqWUyHs= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 03 Mar 2024 16:31:13 +0100 Subject: [PATCH v2 1/4] power: supply: mm8013: fix "not charging" detection Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20240303-power_supply-charge_behaviour_prop-v2-1-8ebb0a7c2409@weissschuh.net> References: <20240303-power_supply-charge_behaviour_prop-v2-0-8ebb0a7c2409@weissschuh.net> In-Reply-To: <20240303-power_supply-charge_behaviour_prop-v2-0-8ebb0a7c2409@weissschuh.net> To: Sebastian Reichel , Hans de Goede , Konrad Dybcio Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Sebastian Reichel , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1709479879; l=2437; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=7Y+sg6xU/tnRXb7nijX/qTcZu9YebnvPyPbqD2+B3oc=; b=IQvGhFBz5UJ3o+kOa80uOHlJwACcG9eD17Q1U+K31JZAr2mT1CIU5BeoN15u290SdZ83ox6S8 N2XHc5u5mhOBfFp7yyPtJNSJ8C2Q7UBqtgG6bVtYx1hrhLL4x7i1Zam X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The charge_behaviours property is meant as a control-knob that can be changed by the user. Page 23 of [0] which documents the flag CHG_INH as follows: CHG_INH : Charge Inhibit When the current is more than or equal to charge threshold current, charge inhibit temperature (upper/lower limit) :1 charge permission temperature or the current is less than charge threshold current :0 So this is pure read-only information which is better represented as POWER_SUPPLY_STATUS_NOT_CHARGING. [0] https://product.minebeamitsumi.com/en/product/category/ics/battery/fuel_gauge/parts/download/__icsFiles/afieldfile/2023/07/12/1_download_01_12.pdf Signed-off-by: Thomas Weißschuh --- drivers/power/supply/mm8013.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/power/supply/mm8013.c b/drivers/power/supply/mm8013.c index caa272b03564..20c1651ca38e 100644 --- a/drivers/power/supply/mm8013.c +++ b/drivers/power/supply/mm8013.c @@ -71,7 +71,6 @@ static int mm8013_checkdevice(struct mm8013_chip *chip) static enum power_supply_property mm8013_battery_props[] = { POWER_SUPPLY_PROP_CAPACITY, - POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR, POWER_SUPPLY_PROP_CHARGE_FULL, POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, POWER_SUPPLY_PROP_CHARGE_NOW, @@ -103,16 +102,6 @@ static int mm8013_get_property(struct power_supply *psy, val->intval = regval; break; - case POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR: - ret = regmap_read(chip->regmap, REG_FLAGS, ®val); - if (ret < 0) - return ret; - - if (regval & MM8013_FLAG_CHG_INH) - val->intval = POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE; - else - val->intval = POWER_SUPPLY_CHARGE_BEHAVIOUR_AUTO; - break; case POWER_SUPPLY_PROP_CHARGE_FULL: ret = regmap_read(chip->regmap, REG_FULL_CHARGE_CAPACITY, ®val); if (ret < 0) @@ -187,6 +176,8 @@ static int mm8013_get_property(struct power_supply *psy, if (regval & MM8013_FLAG_DSG) val->intval = POWER_SUPPLY_STATUS_DISCHARGING; + else if (regval & MM8013_FLAG_CHG_INH) + val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; else if (regval & MM8013_FLAG_CHG) val->intval = POWER_SUPPLY_STATUS_CHARGING; else if (regval & MM8013_FLAG_FC) -- 2.44.0