From patchwork Wed Jul 31 10:00:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 170130 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp3802667ile; Wed, 31 Jul 2019 03:00:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQ4StmhUOjgxYnw/N+G6xkB+HqJAQYsopAYhhJNIbMcx9tB/wMUNHLDk34EoIUFrlpA4Lc X-Received: by 2002:a62:7994:: with SMTP id u142mr47202031pfc.39.1564567257278; Wed, 31 Jul 2019 03:00:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564567257; cv=none; d=google.com; s=arc-20160816; b=R9dVsARxQXsDN31O0Q7u/M/oynnF8NIlkct+XXXqnnbBumilcViwRkvzr+w9wHJKv8 pzCiB6h2YnovZOc/cDGZN9er+5Nw/pZBSZtVttCz3ZJRKb1maQ5/lyjonPe+i0pHqj/v xgw5RB7KKowkx0YhS4zKznlfmY0Mzb+UH8rpH1bJsupuJ2w3a8AxPHhoHLPZPoTR/ESV aC29FLLZDyFGp+3xfuOj4/Dl+zb/I3No9JFs0cWW0p+QTTYt1wR6S9yUgowxwC7DsCVk oG/kxWfREWHaxH24PnGIvrqqUAjMLoS/N0m15QyhFDvUKvyll37kikj2lOXEG7YMm66h kkaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=MmBOwwNeN+W1dC0nmIPZG6LtIHwgJLZWSo5QrSMSqcg=; b=r3Xn8NiE2aDxagQ2AEG4gxSAPFU7zI5Z5+iEJhqE0kZE9otEBJ8+cTXRuW/PZjzkO5 Amgr9AcJMXSyIjhnDXUuY3k5wtsecn2LogG22fmomA9vqmX1vSaIDbzOU2y7zvpOuQkd BGsxEUEwQ62pAhPa9gi1buPg3xZjCXe1EXVdVvW8Ph184prMFIP/rfLJ/qvhXWEncXwl DCkUIi366eodmM7r0z6WZlI1zvLxtPLKB65q5VJsjUoeWz6PJyBILWBV36VwTeJ7WfLK 6+yDDKF2D3+O7Of6ovaPtfQGd6lDzseRBfrpYqLn+ov3wLiZB5Q8hr1HI3sAPJjtRYc4 eJmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F2cmNKe8; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h3si32613928pld.32.2019.07.31.03.00.56; Wed, 31 Jul 2019 03:00:57 -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; dkim=pass header.i=@linaro.org header.s=google header.b=F2cmNKe8; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387666AbfGaKAz (ORCPT + 29 others); Wed, 31 Jul 2019 06:00:55 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:43724 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387644AbfGaKAy (ORCPT ); Wed, 31 Jul 2019 06:00:54 -0400 Received: by mail-pf1-f195.google.com with SMTP id i189so31588857pfg.10 for ; Wed, 31 Jul 2019 03:00:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=MmBOwwNeN+W1dC0nmIPZG6LtIHwgJLZWSo5QrSMSqcg=; b=F2cmNKe82FILmNf5yBHDnTc0fv/W9P8ElxWyX9nD9eNEddHhrjcVcMripReHGh+S0v tSNdYbOTYj5QQBmbdLKklAfAnbsGhNRFF8O/+LB3M71Jf26oCbFHGBxBwHSsBhGdqxyA +KxTVK8klRgp4/pNwu9f2ux4WWomzu+suJyXaCfOMITmKuJ2rNjMgyJNtefNtQk/6Ced +G4XQdEfuvog8fX/p/pcnavzvF0fv3pGjJxnKPAJzsT26oHgPzE1HZaAb08cu8XimFcy Ot89rgQl1jDKVtz6fQ/61d+80sPzURiNrw0u2ctVaFEOZ6aLQg8LP6zliTaQ5zR/CcnX jBig== 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:in-reply-to :references:in-reply-to:references; bh=MmBOwwNeN+W1dC0nmIPZG6LtIHwgJLZWSo5QrSMSqcg=; b=oJJgog/3Nl65Yhhtrn3VADu/DS59/JHmDVQG9IqFv2Ko7sPycdxLeT4AztUmFeh5wC U/Hu8WQZT68Rx/g9w8mqKmFUDnDyLwpmqS6h94s7OGlmENtLfk1E84uBvHda920rB8NY j3n7pZAmLCHNgCd2KTY9jGIqow1d6dnPb3vhDBi6aJPCBDyN4NzNTZCUmz/3HFmd7e0V CiLWPfpHDi0Frd7lUs5oxg3FyUNSxk3I2XSyj07n93J+tEe0zHHaEyIG0+JD7FeSHqvk MClYsNpVP6hXbXKzpUw3mJm+G7rRoCRZ2WT/SG5JP1Xsht9gCSwnWaAmvcvrKUY5x55w VH/A== X-Gm-Message-State: APjAAAWdMCrLHr3t/2UQaVTkDpFcSjYCAOVcXcyVOtdfqmQm6c1qBh9m XckZapi0b2fIHqBxT5QvCcMl8Q== X-Received: by 2002:a63:d555:: with SMTP id v21mr90143798pgi.179.1564567253116; Wed, 31 Jul 2019 03:00:53 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id m6sm68611352pfb.151.2019.07.31.03.00.50 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 31 Jul 2019 03:00:52 -0700 (PDT) From: Baolin Wang To: sre@kernel.org Cc: orsonzhai@gmail.com, zhang.lyra@gmail.com, yuanjiang.yu@unisoc.com, baolin.wang@linaro.org, vincent.guittot@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/6] power: supply: sc27xx: Add POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN attribute Date: Wed, 31 Jul 2019 18:00:23 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yuanjiang Yu Add POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN attribute to provide the battery's design capacity for charger manager to calculate the charging counter. Signed-off-by: Yuanjiang Yu Signed-off-by: Baolin Wang --- drivers/power/supply/sc27xx_fuel_gauge.c | 5 +++++ 1 file changed, 5 insertions(+) -- 1.7.9.5 diff --git a/drivers/power/supply/sc27xx_fuel_gauge.c b/drivers/power/supply/sc27xx_fuel_gauge.c index 24895cc..2fe97ae 100644 --- a/drivers/power/supply/sc27xx_fuel_gauge.c +++ b/drivers/power/supply/sc27xx_fuel_gauge.c @@ -587,6 +587,10 @@ static int sc27xx_fgu_get_property(struct power_supply *psy, val->intval = value * 1000; break; + case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: + val->intval = data->total_cap * 1000; + break; + default: ret = -EINVAL; break; @@ -644,6 +648,7 @@ static int sc27xx_fgu_property_is_writeable(struct power_supply *psy, POWER_SUPPLY_PROP_CURRENT_NOW, POWER_SUPPLY_PROP_CURRENT_AVG, POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE, + POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN, }; static const struct power_supply_desc sc27xx_fgu_desc = { From patchwork Wed Jul 31 10:00:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 170131 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp3802721ile; Wed, 31 Jul 2019 03:01:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqxa0zU6pUDlYusWM9J0pfQj5ilJl8wVdYHnSqAajt31qrUCctyXUMMDePN9Xt3INHR7SIKh X-Received: by 2002:a17:902:9a07:: with SMTP id v7mr12170669plp.245.1564567260302; Wed, 31 Jul 2019 03:01:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564567260; cv=none; d=google.com; s=arc-20160816; b=bu2tseTdP0ko4SwFpco0+IMU0zC9yTX9dDckbfbONulqqwxUzDchOv2TXjvNFn+36O 6AFMNVe+hlRdrR22ELIe9tWXamNK3UBvQjM4YFqkc2bX7yFby3yne44nOvuL0ZoFfCSt pXDdtcUhFGblhjAUAC7dyCNwYS2Kh5tkYrh8vH3MwuESkJf2Feu1vQLTS4Qx1pQRUrWG UWC+zPqRnhpV5CH5B6w4KWTCcmeA9RfEaTi0G7pEb5H3rIHqvM+khcD5h58aNV3uSgZP i7Y6RHPimjZ4l+Ta3GhbLfZwE6kUAv41eGJ9m6Ce5biQ7JP0CY1o567oFSwzOwlS6M0x NrxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=i+zcdOKM4uEsoBGbIg99q0zdIYp2a4lDHZin2ZyV6Ts=; b=ly6OzN2Vsh7FQH+Z/GzRUwujpkoHYJTkgE/ybeWpsb3+kBeI2Eg7LpltSwQsY8Z7jf 2mLN/dgoyAJ94aTCBomGV68uFULaS252Cc0uMJxKLnen4IcO7WCjIwsRx7Ge+FisBsS8 CTK3D4LWa8IG3UzqW/bx1/KS+T/HFqjW6wwpMTRZec6x97MY2F7OOVz0XtP4Pu4RhMWd H3ZJDdoMPR7UvnY/7WBGOFLb63eU5ZCEpzGQXNHMPgcAGuDbEsKa3xoMo+psu+3jlpAn 4BM1uuw1iBBqz8OEkAyBSum3g1TIY/4KjYmq/f9/98s0aw88HTk+uU28mGcTgdJ9CwOS JHow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H77GUufa; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h3si32613928pld.32.2019.07.31.03.01.00; Wed, 31 Jul 2019 03:01:00 -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; dkim=pass header.i=@linaro.org header.s=google header.b=H77GUufa; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387680AbfGaKA6 (ORCPT + 29 others); Wed, 31 Jul 2019 06:00:58 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:42731 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387668AbfGaKA4 (ORCPT ); Wed, 31 Jul 2019 06:00:56 -0400 Received: by mail-pl1-f196.google.com with SMTP id ay6so30306301plb.9 for ; Wed, 31 Jul 2019 03:00:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=i+zcdOKM4uEsoBGbIg99q0zdIYp2a4lDHZin2ZyV6Ts=; b=H77GUufatg+2unukyfaUu5mIxtf9dK45weuozY3ifgIb2dgL2u+aeUCplrl82Pq2sP b2RX+7J/p/p2zmCozRuWIf8QArtB5MJKTKSI2W5+wf5MGGRL9fquoTMXWRZQeETW5oNG 9AyOc2po9ajcww/AZ4Gk49nuuQezsh8pG3bp8pmqo6iV+urV4s2bkTAOF5lSjIztR9Cu qZOES5sOtvdtqd4j4eaANh/hLCDVHh9kULIB9iwNmy8npgfW4MWuOq18H202bivWBtxy ONuRYh2HtoahAfiLP7XBvyHSsMKGMpLWD+kd5UMYrtfkNLBu6fIixasyARHKZFxhCrrX zrUw== 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:in-reply-to :references:in-reply-to:references; bh=i+zcdOKM4uEsoBGbIg99q0zdIYp2a4lDHZin2ZyV6Ts=; b=Et4jQxKHUAf2I83SRjq5Im+G2zNztOhUOg0TNz0mp4CSU6Qu0ctmU7C50/JuayBik/ GKvGUPreuGGXSWu4Zfi0S6PC12dX6cggU74h7hEEaxm1/y6XkfTwEo/caGaT7pywZvC2 BLZUvIjapPAdXxzlWbuzR9K0cg33qnWIQRlwW8xeFMwof7fuiX/+i5EFrJU0HMWRU4NO RIFNjJjYe7DwdDJP4mbwVbJmIX91M51KxP6N8icDmWizJhEy5i82KG7B+ILJLPlcLu9g PQPWrIzEIyQQ/egm5f5PPwhiMZoIy5CvwSTwfa7sozKsAit9LLUB/gGmmfEci9f8d52i 5HQg== X-Gm-Message-State: APjAAAUDjeaCIGGzideARV/CRzsrZ3YvPOht/mW/oanTutT/OGpyqz0y lYPjqZZchByvAPL5c8JpIqtf8Q== X-Received: by 2002:a17:902:4401:: with SMTP id k1mr96016005pld.193.1564567255904; Wed, 31 Jul 2019 03:00:55 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id m6sm68611352pfb.151.2019.07.31.03.00.53 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 31 Jul 2019 03:00:55 -0700 (PDT) From: Baolin Wang To: sre@kernel.org Cc: orsonzhai@gmail.com, zhang.lyra@gmail.com, yuanjiang.yu@unisoc.com, baolin.wang@linaro.org, vincent.guittot@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/6] power: supply: sc27xx: Fix conditon to enable the FGU interrupt Date: Wed, 31 Jul 2019 18:00:24 +0800 Message-Id: <84abc5a002dcc29e51bf6525aee0ca2aace8e30a.1564566425.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yuanjiang Yu We should allow to enable FGU interrupt to adjust the battery capacity, when charging status is POWER_SUPPLY_STATUS_DISCHARGING. Signed-off-by: Yuanjiang Yu Signed-off-by: Baolin Wang --- drivers/power/supply/sc27xx_fuel_gauge.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 1.7.9.5 diff --git a/drivers/power/supply/sc27xx_fuel_gauge.c b/drivers/power/supply/sc27xx_fuel_gauge.c index 2fe97ae..ca7b73e 100644 --- a/drivers/power/supply/sc27xx_fuel_gauge.c +++ b/drivers/power/supply/sc27xx_fuel_gauge.c @@ -1098,7 +1098,8 @@ static int sc27xx_fgu_suspend(struct device *dev) * If we are charging, then no need to enable the FGU interrupts to * adjust the battery capacity. */ - if (status != POWER_SUPPLY_STATUS_NOT_CHARGING) + if (status != POWER_SUPPLY_STATUS_NOT_CHARGING && + status != POWER_SUPPLY_STATUS_DISCHARGING) return 0; ret = regmap_update_bits(data->regmap, data->base + SC27XX_FGU_INT_EN, From patchwork Wed Jul 31 10:00:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 170134 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp3802980ile; Wed, 31 Jul 2019 03:01:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqxLoHJxVrCOvj7zFPshaYGY93KpW+tTTqklNKQgsPsNie6mM1pU8X+RzKjVSlEpZI+xvezT X-Received: by 2002:a62:7641:: with SMTP id r62mr46230527pfc.35.1564567270352; Wed, 31 Jul 2019 03:01:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564567270; cv=none; d=google.com; s=arc-20160816; b=bJF+0aaN9Ni6ia2twgo8sCpEXtWNBegojJHdYhlh//jSC+C+h6B2gl86IVLtLtTIMr DVFfjqC7fi6uEhahGzZeEgwX4fqiSQqboIDZDi8uaGsCUrxhdXZ4VeJ0QwJMGEASZcqz eV3waG+/ZvAUtFGTYsQ+EtrrWfL3nzYloliExOC8jotq/pWHiw15U38h7KfuzreZsoLR 2q5FVgsI4O6WI3LE9nTgcUPLrKVNLBGdqo86kMVt36YSL40R94LkS8wmUN2eyK3KJmaJ 0KT+kPv2IkLKsXkI4AHkElaKDHv3RAzHwWk88QUoJwxKs/RnPyJV43GYbIi+BAJvD6Do VS7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=hT++od96JIv4ERj/5q43A9sdV6GV4nXuETH/GErjU/I=; b=GCQbGr63u3d5zjs7XntjessSyNthzzSnlnFtTJ5aFd4pNlinHa4fmxUbL+y5/qlmaH djM5PMTvdK7zRofCs3Stp9mWBStjsLkEdOsA38lP5r0TFt8+k1HbGU+z2ChWiA92qni0 m1wk6Chm94yEWAvYNI2SH+f34wLm2+31ZNzXV1dvv7hPqlBraTThfQnd3900PQ4UOCFE nAm+hkN/BEGyre33XkvGsLQcPbj7eNBEWT+fxkywYsh+oqDlE3ipVbCtZY7j4WztBhkd M3AaSY26H3u1UieApw0YbgLhlUzG0OW0d6MQXX49xYM3pgg/LY9YgXcgiImQREaaZc1B imIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kIXAp4Mz; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g1si29366795plg.353.2019.07.31.03.01.10; Wed, 31 Jul 2019 03:01:10 -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; dkim=pass header.i=@linaro.org header.s=google header.b=kIXAp4Mz; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728994AbfGaKBI (ORCPT + 29 others); Wed, 31 Jul 2019 06:01:08 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:44545 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387667AbfGaKBE (ORCPT ); Wed, 31 Jul 2019 06:01:04 -0400 Received: by mail-pg1-f196.google.com with SMTP id i18so31716009pgl.11 for ; Wed, 31 Jul 2019 03:01:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=hT++od96JIv4ERj/5q43A9sdV6GV4nXuETH/GErjU/I=; b=kIXAp4MzviR01IRWqe7+ak4T/tIj/IFNOIOhRvpjmPe4Iky3tFm/wfi5mHwn+pc5DK BQr4/V2CGVXy3LsdNBMhg93+PTiKMQhTlHIm5KoA1US4OPQS9jfABuFeaTh5gnT+r2aX nIoi4PywtlKhdVqSZOj3IKK1NvCelqy/7qMhasvUnDLoaz2EMKpUZIxxfyXFzAraP4Ox iKncbdTOLXT99eGgIOaUMIJJzvIoi2zdT+fSBRWqENUmT/UezZtf8dIF2BK3IICY2HN+ D695VleypTnWA8Je1k4uXVgjgWZ8D8GJiwdlybFBgC7IWA4KSWK3FBUq7x1kMW9XG3xw eB2A== 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:in-reply-to :references:in-reply-to:references; bh=hT++od96JIv4ERj/5q43A9sdV6GV4nXuETH/GErjU/I=; b=rpPxLIO1cUaaoCWS1GHhA9ISQGI2USoYIuY52GoUD57ombqHBgEHrBuEyutMeoYqwj WR595MiSDW4QcPBF+ILVWzQyaTOY4/Or4YHvRmPl8O4khxGKRAW2lKUzWeOH86Ah800I ba02eg3gzPY06iYz21kgv1ebgbF5sO4kNUAgfjiNvgA8iOLTVdC4eLJqK1Ocdm8sKemr 2Z4IP16KZd+n5zCKKFAjX4cPsOhwCJMBMbK9g/4lb9403khmUMFcB1tKUdkEVF14lj+U 1MOKEMGX0N8ggoo5loM0QUc5FQFq8F8zdK8T3nemFKSK6b7k2l8SCIQB4te9k4xikXUR 9yaw== X-Gm-Message-State: APjAAAUZcWhUKk5RBB/5I9TMPGw6NLNbdAyvsMz0PWeQAuruHj86Gb50 CrFRF0xH55V0RFSDNKJAnBnsyQ== X-Received: by 2002:aa7:8acb:: with SMTP id b11mr44975412pfd.109.1564567263283; Wed, 31 Jul 2019 03:01:03 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id m6sm68611352pfb.151.2019.07.31.03.01.00 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 31 Jul 2019 03:01:02 -0700 (PDT) From: Baolin Wang To: sre@kernel.org Cc: orsonzhai@gmail.com, zhang.lyra@gmail.com, yuanjiang.yu@unisoc.com, baolin.wang@linaro.org, vincent.guittot@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/6] power: supply: sc27xx: Make sure the alarm capacity is larger than 0 Date: Wed, 31 Jul 2019 18:00:27 +0800 Message-Id: <5c3bb516c6020410a932c12eb2481fd75c34b7fe.1564566425.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yuanjiang Yu We must make sure the alarm capacity is larger than 0, to help to calibrate the low battery capacity. Signed-off-by: Yuanjiang Yu Signed-off-by: Baolin Wang --- drivers/power/supply/sc27xx_fuel_gauge.c | 2 ++ 1 file changed, 2 insertions(+) -- 1.7.9.5 diff --git a/drivers/power/supply/sc27xx_fuel_gauge.c b/drivers/power/supply/sc27xx_fuel_gauge.c index f670131..fa85f40 100644 --- a/drivers/power/supply/sc27xx_fuel_gauge.c +++ b/drivers/power/supply/sc27xx_fuel_gauge.c @@ -915,6 +915,8 @@ static int sc27xx_fgu_hw_init(struct sc27xx_fgu_data *data) data->alarm_cap = power_supply_ocv2cap_simple(data->cap_table, data->table_len, data->min_volt); + if (!data->alarm_cap) + data->alarm_cap += 1; power_supply_put_battery_info(data->battery, &info); From patchwork Wed Jul 31 10:00:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 170135 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp3803077ile; Wed, 31 Jul 2019 03:01:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8R3wW/aQmnr5afQs3rAnUxNIKkPOzGvOgjpHerFGdhFMcpGX6Xxo5YxMEyXob1smSwc2T X-Received: by 2002:a17:902:788f:: with SMTP id q15mr121734916pll.236.1564567274243; Wed, 31 Jul 2019 03:01:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564567274; cv=none; d=google.com; s=arc-20160816; b=t89CmFhqGkYmCgDyI6MJ6VOu2yEzcVaEy41W1sJjdRacqGwZ5W31HSHNiktjehwNeM TlJYxmh4BDU1mlqJN3/6R6I8V/7BaNllA4rS0WlmM1d9DhmpxS1OnGvfOg9fRF4ezvbb 9LONblDi3BsiRTDX6YhqJnJFcczD/Jg7mJ1DeLz383ovXfYkvyeXtx8hoJRTXNo6MUtE CrMx6MMiwgkxZLP0PdRFVrTOvwSjcBhNEvb54GyPmWeLA4MipqkMnWkhyYyLAMF7CAuM nbVFuuF80baeSbMvA8gcfs0mSUK9F3xIjQiWSd0n0Z7N5M/YSkQZY54TnDTLdeREvr82 4uhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=XF5mZ6TSVo4eSNdQwLP31itinD3L/9CCtkqFjn0djlU=; b=FgsHnNHtTNE4vr4SeKYzWLH67w+iFsMRFktY5vDOiCYlAzkPjAHK9vd8KRQ3uBVUXk sR+43yBuzesAe4yE8foSUW33TP0KAhoqzRC0ybzw7UozLuHSEzQXXLdombGER+PGKGUt pglbxaP1KoLlBsK6+Us3UBdBkOKbnaT6iziHQCfcEwl3q5eEPKwhW6IxDEJCDd18qCRQ b8XYdjGtBZtaoLzz6GGCyf67vXd+4IKCQGwv1Ls/P7Rr6obDRbnzjv5xxCZlBGBRFfst zJzkzV0twTi1x0BApo7EiiXZmAKef/CrB6OCfNn2mXptDPFpIsi9CSRJQkLYAbXJcux/ AgiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UHCfglol; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o191si14209900pfg.192.2019.07.31.03.01.13; Wed, 31 Jul 2019 03:01:14 -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; dkim=pass header.i=@linaro.org header.s=google header.b=UHCfglol; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729103AbfGaKBM (ORCPT + 29 others); Wed, 31 Jul 2019 06:01:12 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:37793 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387723AbfGaKBG (ORCPT ); Wed, 31 Jul 2019 06:01:06 -0400 Received: by mail-pl1-f195.google.com with SMTP id b3so30290771plr.4 for ; Wed, 31 Jul 2019 03:01:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=XF5mZ6TSVo4eSNdQwLP31itinD3L/9CCtkqFjn0djlU=; b=UHCfglolFc+DiKNqu28PP7eW3FZEIuVvD/ZAL0ARBydSmw5J1AvOi7RqECGvzy6OyG JjznumgXnMlrgA+kEdFEsntSef0+YnGvMTLpX+q4IecNPm57QuzzIsAAWnE3sBhklwoQ aYzQ3bw8+p+ZPNrOrSDamq+nkI+kJfTvuVAL4kdLH6lmo3FnsURjQaFVeGvWtuV/dx7M Oesx0zR11jotI5yl8mxyz374bO4ddYQKkHky0Sx447WMBTRl/sKaHqp16dEOPi1Tzgev 2vBnBHlc0ZsG6mTdF49WwAunGzn3pS9UeqSoQFADQK3GU6s/SIfyzE1ni8WGsDTjD2ek FFBg== 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:in-reply-to :references:in-reply-to:references; bh=XF5mZ6TSVo4eSNdQwLP31itinD3L/9CCtkqFjn0djlU=; b=SqgLMFaVoEKXq8CGcvdq9Qqvs05KeWz/ye3Bs4anGpy583Zh0oWieaaSoeDv7oyLSa XYFMoaAYSBRDme6mAduO6RPEP1en0y8lhqMXrKGD53c2dLDrwdzpWWCEf67cW2LYfJgB NU3X2MDJTvuozZlSHx+H11CNrjb+u5GJH5ry5AbR1jtRW174hRxdMesL7JVSy9eE925i sWmknuUVrkm/Bk5XXOpRnxujwm6MbbphtrpSBrPEPh3uLL8Yjx9WnO8J+etY25Ptq1s9 B93GZm5xFRU/vPLSGd/qccdtJYio4eFwzYlwwkg9uboyHU6STU/0YVuCIAiAIT4AGuWQ F0Ww== X-Gm-Message-State: APjAAAVDfkK/l4DUPtA1yrz1SxNRb+ksAo6Dx+HstGIH09HUmlLcwAJx 5M2Nyn9k6Ig0FcRp+OAzlCCcgA== X-Received: by 2002:a17:902:a514:: with SMTP id s20mr113281631plq.162.1564567265611; Wed, 31 Jul 2019 03:01:05 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id m6sm68611352pfb.151.2019.07.31.03.01.03 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 31 Jul 2019 03:01:05 -0700 (PDT) From: Baolin Wang To: sre@kernel.org Cc: orsonzhai@gmail.com, zhang.lyra@gmail.com, yuanjiang.yu@unisoc.com, baolin.wang@linaro.org, vincent.guittot@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/6] power: supply: sc27xx: Add POWER_SUPPLY_PROP_CALIBRATE attribute Date: Wed, 31 Jul 2019 18:00:28 +0800 Message-Id: <554dd7e2ef4f3c5247322d8b185607748144b1e6.1564566425.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yuanjiang Yu Add the 'POWER_SUPPLY_PROP_CALIBRATE' attribute to allow chareger manager to calibrate the battery capacity. Signed-off-by: Yuanjiang Yu Signed-off-by: Baolin Wang --- drivers/power/supply/sc27xx_fuel_gauge.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) -- 1.7.9.5 diff --git a/drivers/power/supply/sc27xx_fuel_gauge.c b/drivers/power/supply/sc27xx_fuel_gauge.c index fa85f40..6363c48 100644 --- a/drivers/power/supply/sc27xx_fuel_gauge.c +++ b/drivers/power/supply/sc27xx_fuel_gauge.c @@ -111,6 +111,7 @@ struct sc27xx_fgu_data { static int sc27xx_fgu_cap_to_clbcnt(struct sc27xx_fgu_data *data, int capacity); static void sc27xx_fgu_capacity_calibration(struct sc27xx_fgu_data *data, int cap, int int_mode); +static void sc27xx_fgu_adjust_cap(struct sc27xx_fgu_data *data, int cap); static const char * const sc27xx_charger_supply_name[] = { "sc2731_charger", @@ -610,17 +611,25 @@ static int sc27xx_fgu_set_property(struct power_supply *psy, struct sc27xx_fgu_data *data = power_supply_get_drvdata(psy); int ret; - if (psp != POWER_SUPPLY_PROP_CAPACITY) - return -EINVAL; - mutex_lock(&data->lock); - ret = sc27xx_fgu_save_last_cap(data, val->intval); + switch (psp) { + case POWER_SUPPLY_PROP_CAPACITY: + ret = sc27xx_fgu_save_last_cap(data, val->intval); + if (ret < 0) + dev_err(data->dev, "failed to save battery capacity\n"); + break; - mutex_unlock(&data->lock); + case POWER_SUPPLY_PROP_CALIBRATE: + sc27xx_fgu_adjust_cap(data, val->intval); + ret = 0; + break; - if (ret < 0) - dev_err(data->dev, "failed to save battery capacity\n"); + default: + ret = -EINVAL; + } + + mutex_unlock(&data->lock); return ret; } @@ -635,7 +644,8 @@ static void sc27xx_fgu_external_power_changed(struct power_supply *psy) static int sc27xx_fgu_property_is_writeable(struct power_supply *psy, enum power_supply_property psp) { - return psp == POWER_SUPPLY_PROP_CAPACITY; + return psp == POWER_SUPPLY_PROP_CAPACITY || + psp == POWER_SUPPLY_PROP_CALIBRATE; } static enum power_supply_property sc27xx_fgu_props[] = { @@ -651,6 +661,7 @@ static int sc27xx_fgu_property_is_writeable(struct power_supply *psy, POWER_SUPPLY_PROP_CURRENT_AVG, POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE, POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN, + POWER_SUPPLY_PROP_CALIBRATE, }; static const struct power_supply_desc sc27xx_fgu_desc = {