From patchwork Mon Apr 20 03:42:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 11498031 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ECFE16CA for ; Mon, 20 Apr 2020 03:42:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D450121D82 for ; Mon, 20 Apr 2020 03:42:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="J8mJAyZa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726036AbgDTDmb (ORCPT ); Sun, 19 Apr 2020 23:42:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725865AbgDTDmb (ORCPT ); Sun, 19 Apr 2020 23:42:31 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC2A7C061A0C; Sun, 19 Apr 2020 20:42:29 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id w11so4383511pga.12; Sun, 19 Apr 2020 20:42:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=H9mqHilgo/Uld+P9kdUGuC1VtwvkHSgSfi4WjXEiHdw=; b=J8mJAyZaHhfIkN737Ii55LTQM5Pzzi8PJGPO5Kokt5CiPDuXK9md3Yc1zhAyjf7iM+ K6FZSb0aKApvgtJ1QOHT7r4E1nONIP6jkoQbX+7tHaaf51uiwiaDLpEewctYNu8LNF8Q rX7jo91SOSf992AjZetK427WtYjWGBBzs8EbNcRQ+hf4OOB3+nPga1hEvV+r0UGkJmG0 BwNGUfm1MF40KnR78Q9nLZcH9qUPt3T/jwdJTRwTBsUmvso0860Wwrc3maok+KrBQqgN YbJTq416JujB4qXwVi9MXDewokimSXmKEWJrAxi90S+5atdbWr7wQQzB2Rs/jamuhoFp Q6/A== 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=H9mqHilgo/Uld+P9kdUGuC1VtwvkHSgSfi4WjXEiHdw=; b=NfRjqxgsxIcL8gv7+9I3sfZoh8KAcyWFbIM1Lk7lrZiB7m94o820THQJftMQlXb9rY 1sEICri5nTDmZGrvrUqxLVXk6aWYxMtizPFfwrXPr/IhD5d/vGkuSEj2dYwogYaxUbuI Mx7ekHJ+l5r98n9tSeZqZXV1d5+nSADK3ZCRjmtFkK3k1Kk9WjHmtJj0SjDU/gYR4uA7 8ZMzKTH77nHJEW2rM5wbcxR67NhscMChkxHfndmQcylaJFn2gGnZcs+a/1qrY57lJV0l vg9nZJUFkDTz9eZil1cnbpz/JMayqUQ4j66qKaZPj+d3oXNF10mI9cmRDQndjD8SKStX RZHQ== X-Gm-Message-State: AGi0PuYxVi8UflBUc1tvqF2PEbnuCtZvlGchemmwqnnX+f65rSsYOUk5 8YnG9Qnuao6ulisaYv/D/siB1r4kLts= X-Google-Smtp-Source: APiQypKu/gOsQ9EaCme/dDviV4AkJq9fT5CbA1/lkIWypGw0ImHcwZFKHo21FB7BDKXnhuRUQ4PrNw== X-Received: by 2002:aa7:808e:: with SMTP id v14mr6166402pff.168.1587354149160; Sun, 19 Apr 2020 20:42:29 -0700 (PDT) Received: from localhost.localdomain ([45.135.186.129]) by smtp.gmail.com with ESMTPSA id d21sm12467660pjs.3.2020.04.19.20.42.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2020 20:42:28 -0700 (PDT) From: Baolin Wang To: sre@kernel.org Cc: baolin.wang7@gmail.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, yuanjiang.yu@unisoc.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] power: supply: sc27xx: Set 'no_thermal' flag for SC27xx fuel gauge Date: Mon, 20 Apr 2020 11:42:04 +0800 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Yuanjiang Yu There is no thermal zone should be created for the SC27XX FGU power supply, thus set the 'no_thermal' flag as true. Signed-off-by: Yuanjiang Yu Signed-off-by: Baolin Wang --- drivers/power/supply/sc27xx_fuel_gauge.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/power/supply/sc27xx_fuel_gauge.c b/drivers/power/supply/sc27xx_fuel_gauge.c index a7c8a8453db1..9dcd55f1d9f3 100644 --- a/drivers/power/supply/sc27xx_fuel_gauge.c +++ b/drivers/power/supply/sc27xx_fuel_gauge.c @@ -705,6 +705,7 @@ static const struct power_supply_desc sc27xx_fgu_desc = { .set_property = sc27xx_fgu_set_property, .external_power_changed = sc27xx_fgu_external_power_changed, .property_is_writeable = sc27xx_fgu_property_is_writeable, + .no_thermal = true, }; static void sc27xx_fgu_adjust_cap(struct sc27xx_fgu_data *data, int cap) From patchwork Mon Apr 20 03:42:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 11498033 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1777B1667 for ; Mon, 20 Apr 2020 03:42:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F2A3A22240 for ; Mon, 20 Apr 2020 03:42:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fVgABpYD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726116AbgDTDme (ORCPT ); Sun, 19 Apr 2020 23:42:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725865AbgDTDmd (ORCPT ); Sun, 19 Apr 2020 23:42:33 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9A77C061A0C; Sun, 19 Apr 2020 20:42:33 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id f8so3456028plt.2; Sun, 19 Apr 2020 20:42:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=OLaM6Qu6tx9wARiWQDaw8WtmOfSiQlnO4zEaooNM6j0=; b=fVgABpYDIFpulLjWXtcFz+P5Pyc2BObkCqXc42k8zU5gZSVjLqIWsJTp/OI2ZoVWm4 Xkr0wscWh/pXYYraltinY460aUXQqUp13SqABCcAzld1aWSeBRZWjbk3NUjDwiT9VpaB AjSP4Ngzk2uas6Mro4daKqLyQDHAVDoXFr0MOllaKQyyg66S7MjyhDsenBUNVDM+HkST aDuaw5DH0s4pTya4Bak9XTnZEDc2BGl2L5BFQ4YVEYEKzL2UZcy/Dw3zYSgqgpaHKn1s 4/hqcSBbLh6CeHrY0YYFUHfLJ8ZsraGls/l5RCNspwusf/rRLubri0fdaFtvHSz3qi4A szWw== 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=OLaM6Qu6tx9wARiWQDaw8WtmOfSiQlnO4zEaooNM6j0=; b=OidBQKH1RkZgB/xgP2tOPQOXgsePHyHA+aImwJaTFjgkW9LobcrWwuYG8E8pgMILKG GvkuVy1KzsjWtWeKu4hfgbM9y3a1rgVU+eReS2/mx4iHWrNpT7MymLFwmtyGRWpHBEMT u/MtTUFtZbQSLXj2Cg786HoVWm6gFr70+j/6WExyo40JNy54Kpkj7Ub6We1I+4zgaEzC DavoXhVZ90ebi45l6vb5gHYRyXmH9l4Q6LPtJAY2RkylCUuudBW5T8GMCeHGmrorlJBj zG8Jlrm1gibrl1Mep1x2FmjIBdA40HBCgGH9Ea+6Usd5fdZX/4CmHKwalbOxXltpxns+ pp/A== X-Gm-Message-State: AGi0PuaXI0Qj+cRzCNjpplchMYRPh5+6nfiPCkTjyZ8K3AIq1jJ4nYot 7ZvJI03FxxYegDVstXnFihI= X-Google-Smtp-Source: APiQypLS0wLw9k9ccJRTnZb2qw34t9alZqR0SmMnF/oMyER23ILtnZD+YDYXuRIhj0tqZruIbxa0iA== X-Received: by 2002:a17:902:561:: with SMTP id 88mr15393475plf.78.1587354153418; Sun, 19 Apr 2020 20:42:33 -0700 (PDT) Received: from localhost.localdomain ([45.135.186.129]) by smtp.gmail.com with ESMTPSA id d21sm12467660pjs.3.2020.04.19.20.42.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2020 20:42:32 -0700 (PDT) From: Baolin Wang To: sre@kernel.org Cc: baolin.wang7@gmail.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, yuanjiang.yu@unisoc.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] power: supply: sc27xx: Allow to change the battery full capacity Date: Mon, 20 Apr 2020 11:42:05 +0800 Message-Id: <88115ce628cda05d5c4961e364bb1204dbfeb03a.1587353854.git.baolin.wang7@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Yuanjiang Yu The battery full capacity can be affected by the temperature or the servicing time or other factors, so some platforms will track the real battery full capacity in charger manager service. Thus we should allow to change the battery full capacity by setting the 'POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN' property as writeable. Signed-off-by: Yuanjiang Yu Signed-off-by: Baolin Wang --- drivers/power/supply/sc27xx_fuel_gauge.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/sc27xx_fuel_gauge.c b/drivers/power/supply/sc27xx_fuel_gauge.c index 9dcd55f1d9f3..5970d4a78016 100644 --- a/drivers/power/supply/sc27xx_fuel_gauge.c +++ b/drivers/power/supply/sc27xx_fuel_gauge.c @@ -656,6 +656,11 @@ static int sc27xx_fgu_set_property(struct power_supply *psy, ret = 0; break; + case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: + data->total_cap = val->intval / 1000; + ret = 0; + break; + default: ret = -EINVAL; } @@ -676,7 +681,8 @@ static int sc27xx_fgu_property_is_writeable(struct power_supply *psy, enum power_supply_property psp) { return psp == POWER_SUPPLY_PROP_CAPACITY || - psp == POWER_SUPPLY_PROP_CALIBRATE; + psp == POWER_SUPPLY_PROP_CALIBRATE || + psp == POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN; } static enum power_supply_property sc27xx_fgu_props[] = { From patchwork Mon Apr 20 03:42:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 11498035 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 38CFB112C for ; Mon, 20 Apr 2020 03:42:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1F72F2223D for ; Mon, 20 Apr 2020 03:42:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Bk6/BCTV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726234AbgDTDmi (ORCPT ); Sun, 19 Apr 2020 23:42:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725865AbgDTDmi (ORCPT ); Sun, 19 Apr 2020 23:42:38 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25606C061A0C; Sun, 19 Apr 2020 20:42:38 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id d24so3444722pll.8; Sun, 19 Apr 2020 20:42:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=JPkmqM71b4rRcya2ozpKiJUdZzbf1Gon6Qti46oIwaA=; b=Bk6/BCTVD1ZAHzejtmXrV3+jLdv6LQkBP0LYPnF4Ucp/a3qndVwhWy1ZtQeE0MS/qw weUC89nR/sjUffGzE2w9oQOgdca+na1G0unMsg/EatfVOT8vTf2UHF7Urtr1jJyxTSvB TSWWnpjvrmfGxJ/oxz3gipUNLFIV/jRJ6LksBykOdGAFp7wv0amXK4b/tr7yRFVwS93m ShRAirVTdO6NVHnwGsqPRZJBDOgn4fKQmzA0yChLEFJkb1wJWPJQJiA7Bx1Cg0ZnrV2N o/qQjVuFUR2lK9v69ccI2HoTenb6vOaXc1BIytS+BIdECiHAiNoc/7kfyPUA1bxqFnyA tlMQ== 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=JPkmqM71b4rRcya2ozpKiJUdZzbf1Gon6Qti46oIwaA=; b=cPjAWV9b2HvdnypNQIJr/nU4T51SC+w/yOfvhClj7POUjbNwsO5sL3ZEmnXtdHKE56 i1x9OJDQc7T/I11J8PK8jp8BkU1lucxpf0WTd9/m4v5d5RJFfqYUqWrw1VJoM3W16mh6 4Ow9atCf+uB4E4bkEXQAW4YjhUKnMz8EHdTsuMjdAIvwuG2C3vbJX3XhPYlTEjGru+zW zrDWyk9J//mAtqhFtRN5GbGeKkTiexvbkIzLZcYqAuGWn22Oli2/A2eSjRN2Lz7fNzhW Jke3pMDRO80W41luCFtXBE53YqdajPOMM3HDTZJ/vmNPWCjQtQ7Co2ozxqzFMKxiBbOR BeKQ== X-Gm-Message-State: AGi0Pubk6FhE87WLQoZnWMTSTprz9tpX5PsM3lwIZgXqmClZ5E24CsRE pa1gvU58YqP4NPczyZVTGak= X-Google-Smtp-Source: APiQypI33jIQSddwQUXo9j6helHzRk1c5D1UbVoCy7dqJrqCVAYsxAnBOMj17HR/KQXa1HNADfhY2w== X-Received: by 2002:a17:902:690b:: with SMTP id j11mr15468699plk.145.1587354157716; Sun, 19 Apr 2020 20:42:37 -0700 (PDT) Received: from localhost.localdomain ([45.135.186.129]) by smtp.gmail.com with ESMTPSA id d21sm12467660pjs.3.2020.04.19.20.42.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2020 20:42:37 -0700 (PDT) From: Baolin Wang To: sre@kernel.org Cc: baolin.wang7@gmail.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, yuanjiang.yu@unisoc.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] power: supply: sc27xx: Add CURRENT_NOW/VOLTAGE_NOW properties support Date: Mon, 20 Apr 2020 11:42:06 +0800 Message-Id: <0e3fe8941e93d520fafa69282bd0d717d203d541.1587353854.git.baolin.wang7@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Yuanjiang Yu Add new properties to get present current and voltage of the fuel gauge. Signed-off-by: Yuanjiang Yu Signed-off-by: Baolin Wang --- drivers/power/supply/sc27xx_fuel_gauge.c | 60 +++++++++++++++++++++++- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/sc27xx_fuel_gauge.c b/drivers/power/supply/sc27xx_fuel_gauge.c index 5970d4a78016..82d0c64ef269 100644 --- a/drivers/power/supply/sc27xx_fuel_gauge.c +++ b/drivers/power/supply/sc27xx_fuel_gauge.c @@ -42,6 +42,8 @@ #define SC27XX_FGU_USER_AREA_SET 0xa0 #define SC27XX_FGU_USER_AREA_CLEAR 0xa4 #define SC27XX_FGU_USER_AREA_STATUS 0xa8 +#define SC27XX_FGU_VOLTAGE_BUF 0xd0 +#define SC27XX_FGU_CURRENT_BUF 0xf0 #define SC27XX_WRITE_SELCLB_EN BIT(0) #define SC27XX_FGU_CLBCNT_MASK GENMASK(15, 0) @@ -376,6 +378,44 @@ static int sc27xx_fgu_get_clbcnt(struct sc27xx_fgu_data *data, int *clb_cnt) return 0; } +static int sc27xx_fgu_get_vol_now(struct sc27xx_fgu_data *data, int *val) +{ + int ret; + u32 vol; + + ret = regmap_read(data->regmap, data->base + SC27XX_FGU_VOLTAGE_BUF, + &vol); + if (ret) + return ret; + + /* + * It is ADC values reading from registers which need to convert to + * corresponding voltage values. + */ + *val = sc27xx_fgu_adc_to_voltage(data, vol); + + return 0; +} + +static int sc27xx_fgu_get_cur_now(struct sc27xx_fgu_data *data, int *val) +{ + int ret; + u32 cur; + + ret = regmap_read(data->regmap, data->base + SC27XX_FGU_CURRENT_BUF, + &cur); + if (ret) + return ret; + + /* + * It is ADC values reading from registers which need to convert to + * corresponding current values. + */ + *val = sc27xx_fgu_adc_to_current(data, cur - SC27XX_FGU_CUR_BASIC_ADC); + + return 0; +} + static int sc27xx_fgu_get_capacity(struct sc27xx_fgu_data *data, int *cap) { int ret, cur_clbcnt, delta_clbcnt, delta_cap, temp; @@ -577,7 +617,7 @@ static int sc27xx_fgu_get_property(struct power_supply *psy, val->intval = value; break; - case POWER_SUPPLY_PROP_VOLTAGE_NOW: + case POWER_SUPPLY_PROP_VOLTAGE_AVG: ret = sc27xx_fgu_get_vbat_vol(data, &value); if (ret) goto error; @@ -601,7 +641,6 @@ static int sc27xx_fgu_get_property(struct power_supply *psy, val->intval = value; break; - case POWER_SUPPLY_PROP_CURRENT_NOW: case POWER_SUPPLY_PROP_CURRENT_AVG: ret = sc27xx_fgu_get_current(data, &value); if (ret) @@ -625,6 +664,22 @@ static int sc27xx_fgu_get_property(struct power_supply *psy, break; + case POWER_SUPPLY_PROP_VOLTAGE_NOW: + ret = sc27xx_fgu_get_vol_now(data, &value); + if (ret) + goto error; + + val->intval = value * 1000; + break; + + case POWER_SUPPLY_PROP_CURRENT_NOW: + ret = sc27xx_fgu_get_cur_now(data, &value); + if (ret) + goto error; + + val->intval = value * 1000; + break; + default: ret = -EINVAL; break; @@ -694,6 +749,7 @@ static enum power_supply_property sc27xx_fgu_props[] = { POWER_SUPPLY_PROP_CAPACITY, POWER_SUPPLY_PROP_VOLTAGE_NOW, POWER_SUPPLY_PROP_VOLTAGE_OCV, + POWER_SUPPLY_PROP_VOLTAGE_AVG, POWER_SUPPLY_PROP_CURRENT_NOW, POWER_SUPPLY_PROP_CURRENT_AVG, POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE, From patchwork Mon Apr 20 03:42:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 11498037 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 55766913 for ; Mon, 20 Apr 2020 03:42:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3DD0522202 for ; Mon, 20 Apr 2020 03:42:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="X1n6Hw6N" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726318AbgDTDmo (ORCPT ); Sun, 19 Apr 2020 23:42:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725865AbgDTDmn (ORCPT ); Sun, 19 Apr 2020 23:42:43 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 770F2C061A0C; Sun, 19 Apr 2020 20:42:43 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id p8so4396778pgi.5; Sun, 19 Apr 2020 20:42:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=ZmbaW0s8Lq0BUJ+PzKbYmuUcRhk4c92Bhfoij2xYNoI=; b=X1n6Hw6NGwunwRUFC8MS5sgsDvf+q1ReIeXVsUF9L8rYueYTn3fRNsWomjcoA+iycy UTDC+Eisl6twcaiAfokSULe3KhXCbznTjVwr9Tex8wBOizSbAUDY3SUaLJ4t/clnErF1 LwLbSIDX8186Wa+MVr/Ik81Zku1VmzspRSSsGxegUPuEfFRaLlK9sf/Yp/zFmn8DPCg4 BrnrqDt+neG1aiQ7JukwCO0eS1H81flPSXT15KZ7X69r2kTjjIyygAJ4xJWaZbiIvOMm 3NtCoIG9D28BETa5128w8K+uV1oX0KQPSvnaNlcZ0Q+GHTVY2tXzuQT8Q3jBXqZhZw19 ZHoQ== 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=ZmbaW0s8Lq0BUJ+PzKbYmuUcRhk4c92Bhfoij2xYNoI=; b=sEk/GHJ6pMTuWTqIzJekyD8v9bSR7vM/rjs4e26fnTnMPskqsqkGgF9RgoO4rO2yBQ lFm232uLJF2mh1zFCWXMzdacdGYLNei3CLoU1XymiutpDN0TMpensTAGb0awaMs/IT2T BzvgrNctr2s3a5dJXUTdci+XwhKbwTojGDIXK5OmRNatuJ2ADK9YVjorIYBUIubt2hjU 64nzkWwLewaT90o8PJzFrsrpwbPcp5I/l+TouvOb4muiDhQSj7Zckkyb/s/3Mdm8zIxF iqFN3qmcvNArls2WmKqeUg27steRR6jok8KFXfU3Yal92fCa7yVISILulpAPSD3CCqUT 0/mQ== X-Gm-Message-State: AGi0PuZ1kzEaadiw/fLLwlurv3oogo4IuNHQtNLcCTZbEUIDbzGgDuV6 gGmcrxx4S7PyhATcMt1CLvk= X-Google-Smtp-Source: APiQypIYBAbgEjbWQ2GmqE9f6ikPln1mzkS9bKK8nNsHkjcPnusoaFvQ3lbb206N41PS5j5zjR+vkA== X-Received: by 2002:a63:4e1d:: with SMTP id c29mr14964791pgb.235.1587354162133; Sun, 19 Apr 2020 20:42:42 -0700 (PDT) Received: from localhost.localdomain ([45.135.186.129]) by smtp.gmail.com with ESMTPSA id d21sm12467660pjs.3.2020.04.19.20.42.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2020 20:42:41 -0700 (PDT) From: Baolin Wang To: sre@kernel.org Cc: baolin.wang7@gmail.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, yuanjiang.yu@unisoc.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] power: supply: sc27xx: Add boot voltage support Date: Mon, 20 Apr 2020 11:42:07 +0800 Message-Id: <098bc90ca87402ba08cec6df81fe3465eeb10e00.1587353854.git.baolin.wang7@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Yuanjiang Yu Add new property to allow to get the voltage measured during boot time. Signed-off-by: Yuanjiang Yu Signed-off-by: Baolin Wang --- drivers/power/supply/sc27xx_fuel_gauge.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/power/supply/sc27xx_fuel_gauge.c b/drivers/power/supply/sc27xx_fuel_gauge.c index 82d0c64ef269..be42e814ea34 100644 --- a/drivers/power/supply/sc27xx_fuel_gauge.c +++ b/drivers/power/supply/sc27xx_fuel_gauge.c @@ -84,6 +84,7 @@ * @init_clbcnt: the initial coulomb counter * @max_volt: the maximum constant input voltage in millivolt * @min_volt: the minimum drained battery voltage in microvolt + * @boot_volt: the voltage measured during boot in microvolt * @table_len: the capacity table length * @resist_table_len: the resistance table length * @cur_1000ma_adc: ADC value corresponding to 1000 mA @@ -109,6 +110,7 @@ struct sc27xx_fgu_data { int init_clbcnt; int max_volt; int min_volt; + int boot_volt; int table_len; int resist_table_len; int cur_1000ma_adc; @@ -321,6 +323,7 @@ static int sc27xx_fgu_get_boot_capacity(struct sc27xx_fgu_data *data, int *cap) volt = sc27xx_fgu_adc_to_voltage(data, volt); ocv = volt * 1000 - oci * data->internal_resist; + data->boot_volt = ocv; /* * Parse the capacity table to look up the correct capacity percent @@ -680,6 +683,10 @@ static int sc27xx_fgu_get_property(struct power_supply *psy, val->intval = value * 1000; break; + case POWER_SUPPLY_PROP_VOLTAGE_BOOT: + val->intval = data->boot_volt; + break; + default: ret = -EINVAL; break; @@ -750,6 +757,7 @@ static enum power_supply_property sc27xx_fgu_props[] = { POWER_SUPPLY_PROP_VOLTAGE_NOW, POWER_SUPPLY_PROP_VOLTAGE_OCV, POWER_SUPPLY_PROP_VOLTAGE_AVG, + POWER_SUPPLY_PROP_VOLTAGE_BOOT, POWER_SUPPLY_PROP_CURRENT_NOW, POWER_SUPPLY_PROP_CURRENT_AVG, POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE,