Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1356418ybv; Thu, 13 Feb 2020 21:40:27 -0800 (PST) X-Google-Smtp-Source: APXvYqyJljBFJBjrIEtPwY4pCiVuUGKzsRD3ivW9xKO9PGMuvwiGxHhkvYbpZvm+DP6Qx92dHnW+ X-Received: by 2002:aca:ad11:: with SMTP id w17mr791674oie.85.1581658827758; Thu, 13 Feb 2020 21:40:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581658827; cv=none; d=google.com; s=arc-20160816; b=gF3LlaO2gejJ+kbzG+F4UiX9sv9+Uc0LC4QLwvLZ9uti/I6YIKOwH9v3zK9s8AwUgA CiXde/oOJrZjSkxyW5VmcEGaNXRxNJwD/CX49yVmPD5Z5nhahorafCcOgAwZBp965/Iw u4xD/WDobN0ZwOrQAmXa8k8KwW7lVSzaAsRzK03O+41tnVfLa5uIlr9BC+T/yCVzTa/6 TjSHAzQk8Kr2MADkhKfAfUfvwIwr5ORENtuluEYraeF4vHoAqV4jQLMfxyjf1r/3Wbs9 N+64klD8bnDqZxBdCLEuIkPls12570MKwka1Z4Y/0tr5nUGZV40F8mdNo0ceeHiZQItG IlAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=+tmH0kcp5YKexoO2OsIvb30KrHhpFBPYCCmsNiF0Z2M=; b=YBI+/i13ahjILPRNGnZ/1ivAYK4Ld5rTc7wW1HfENqOsRGwU/+KktZ7rHlwLn4So6k UtrYejhb/FGMQCq8ArC5xtzopbdPFLznCt1kmTf9+E+kIz/oTIrmduxq5v0S2rGmuZVK CexRzQTZsJdaXLfMiohIJG3Eaiq4wTHs4Oy7K4JsPpVMzgaYvId3mGsbY4+HQVOJpZlW OdxEdOHe5BHi8S4rFUoYMdUXz3u0tBLJc3yKjLx++7SJE4CA9HCIcQvRFa4ATf/dDfY0 wYPCY7N7moL4EbQzU92i56vaLqXhgjOZ09B/hIEExHui22TynSgYFObCeYarQLJ8To4c 6NSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sOwRCILM; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m67si2257552oib.117.2020.02.13.21.40.14; Thu, 13 Feb 2020 21:40:27 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sOwRCILM; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727965AbgBNFkF (ORCPT + 99 others); Fri, 14 Feb 2020 00:40:05 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:37457 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726092AbgBNFkF (ORCPT ); Fri, 14 Feb 2020 00:40:05 -0500 Received: by mail-pg1-f195.google.com with SMTP id z12so4378581pgl.4; Thu, 13 Feb 2020 21:40:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=+tmH0kcp5YKexoO2OsIvb30KrHhpFBPYCCmsNiF0Z2M=; b=sOwRCILM1p8O2wtjVPhO/hQ8+nBgen5mzy8MGJItP4r+QZdN54KTaxQdfIQPhQ99sT lVIesqm503sVov3jI2Qw7RUJ91e6vIUo7fF9cm4U0Hy+aicS67YJ+zZCk45eNdTQEtJA p17Ew4ckEW533lOichK7KIPWJ1PVXWihxa0X66U+3uSVEsDOa7pcZUjqEHt1illfqiH0 Sigvov6UYWn0V/5ImzqvgWJg6Z9bpqZOuzItplc30dJY4onAeNGODOi9lpvVhO0Ixp42 6hhNHCcpQ2kedklMm2iScEfrFb0NHkOMQfftpD3euOz6lyLLH/aWTpYgOxxXCiFLX2+L iYVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=+tmH0kcp5YKexoO2OsIvb30KrHhpFBPYCCmsNiF0Z2M=; b=f9vbZ30AUHl3waEUEbDLme5LjI83iztg8IAwSoDMfVu1ObLvAVjCjJme9gqYJbXPr7 JoM6P5gR91SdBbJ5Np2aomsmm9tPbBsW6/s3wrkoS6lCOs9N+GYZOiaA4nQSqeDkNBTI b7MHhvBu1IPgRH3rc+8qa8N7VWZyRtQmEuBcLqKoQtOngIvUEULpoN6IPtAA0Pm8LUiV WepMMuQnrZfVMVEQMsdy0qNmE/TUhbQGGtsUlCReA3cyJhXg7LWj0cY+ACrBUoZCxXLz DxP+CoyRNyq/PcZskRpWQ+Q/oVFhZQU45BJ0LWLUENSz+jInHZd6QMGtQi0h1h2YObHD FFww== X-Gm-Message-State: APjAAAXnKiG3fsOhgSm2reZDhfSaDsSL3iVOT2SkZHpTM6OpXiGajOnw 8R4xsPTfMuEOP6ZffEPIctM= X-Received: by 2002:a63:cd04:: with SMTP id i4mr1652725pgg.281.1581658805034; Thu, 13 Feb 2020 21:40:05 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id b24sm4974349pfo.84.2020.02.13.21.40.02 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 13 Feb 2020 21:40:04 -0800 (PST) From: Baolin Wang To: sre@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, baolin.wang7@gmail.com, zhang.lyra@gmail.com, orsonzhai@gmail.com Subject: [PATCH] power: supply: sc27xx: Add POWER_SUPPLY_PROP_CHARGE_NOW attribute Date: Fri, 14 Feb 2020 13:38:58 +0800 Message-Id: <33dba0929575461e38c2e17ac0cc4a8a4e46fa2f.1581658633.git.baolin.wang7@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the POWER_SUPPLY_PROP_CHARGE_NOW attribute to allow user to get current battery capacity (uAh) to do measurement. Signed-off-by: Baolin Wang --- drivers/power/supply/sc27xx_fuel_gauge.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/power/supply/sc27xx_fuel_gauge.c b/drivers/power/supply/sc27xx_fuel_gauge.c index 469c83f..a7c8a84 100644 --- a/drivers/power/supply/sc27xx_fuel_gauge.c +++ b/drivers/power/supply/sc27xx_fuel_gauge.c @@ -614,6 +614,17 @@ static int sc27xx_fgu_get_property(struct power_supply *psy, val->intval = data->total_cap * 1000; break; + case POWER_SUPPLY_PROP_CHARGE_NOW: + ret = sc27xx_fgu_get_clbcnt(data, &value); + if (ret) + goto error; + + value = DIV_ROUND_CLOSEST(value * 10, + 36 * SC27XX_FGU_SAMPLE_HZ); + val->intval = sc27xx_fgu_adc_to_current(data, value); + + break; + default: ret = -EINVAL; break; @@ -682,6 +693,7 @@ static int sc27xx_fgu_property_is_writeable(struct power_supply *psy, POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE, POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN, POWER_SUPPLY_PROP_CALIBRATE, + POWER_SUPPLY_PROP_CHARGE_NOW }; static const struct power_supply_desc sc27xx_fgu_desc = { -- 1.7.9.5