Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp747627ybk; Wed, 13 May 2020 12:00:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcpkBQlR08b6lyCzm99IHZi/urC9HBqIH4lwbjOotzALyr2ZSl9voTrhun46mye9AbS09r X-Received: by 2002:aa7:c1c5:: with SMTP id d5mr935187edp.183.1589396447413; Wed, 13 May 2020 12:00:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589396447; cv=none; d=google.com; s=arc-20160816; b=SAJkRmR00gRjsrbOyO/rk/zceZOEOw4XPaGina8GK2M5SBYYDJMN6EDwTKsZaivsA4 1oON9QPqboSO5m8EqmwZuIYn6VCBbumlpzjce4IxKQWZz+2Z4JAQKcySplGTSQU7k64U 4b8JIFGlynHctfmfrQOdQLUMtt3aRk/+Imb+EwHVXarHM9nsNxeiMBu6Yd611rJ1sgub XJFtuqZW4jhV3FJ/jctYSosmPkEMf7ddnIRvjwYg/p/rPjBj2+Moqc6KIP61OW4tCv5+ ivy6JnEXPLzX6Q3Rjx6ebbRYTtHbjgycfT7AscQ54MnAOHYR2AwBmPwblhwEH2YgjWMY +sPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=wMemuriddNOk979dcKKIkLPf48suBOWTyu2Rz686I/o=; b=S+0jwbibYbV8XGa3KsGt6FBWoQKcpAftNwXELmZ9AOh3Y4muozyqrJEBh4kCNCs2pw yV4kRZVc8ivs6HUiERFl4/Z5uW0juKkUA0XelCZlLl5WaeVWTYkUYaEHrmx0XZETBAGe 2aSn21nmE87l5tmQ5zxaIgUyShDVJm5fGG1ZtLbpa1LZdz7zm2oU651LexGdSqsJ/voV DPHGQXcfNUqfbbwhho7msol+RxUwyVAhqDvCTp/TfHNnDnjbsKEu6o5FVtJbR0B2AqdI PPOygTy9cZyFZW5lxWgI3KLM4RUz1GUo+TkviTTZeF+mE0eLlOUoOJI3GtHMR0TsCU1o B1eQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s8si356566eji.349.2020.05.13.12.00.23; Wed, 13 May 2020 12:00:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390561AbgEMS5f (ORCPT + 99 others); Wed, 13 May 2020 14:57:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S2390392AbgEMS4f (ORCPT ); Wed, 13 May 2020 14:56:35 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B762C061A0E; Wed, 13 May 2020 11:56:35 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 51D7C2A28F6 Received: by jupiter.universe (Postfix, from userid 1000) id 7D6D4480107; Wed, 13 May 2020 20:56:29 +0200 (CEST) From: Sebastian Reichel To: Sebastian Reichel , Rob Herring , Greg Kroah-Hartman , "Rafael J . Wysocki" Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@collabora.com, Sebastian Reichel Subject: [PATCHv1 09/19] power: supply: sbs-battery: add POWER_SUPPLY_PROP_CURRENT_AVG support Date: Wed, 13 May 2020 20:56:05 +0200 Message-Id: <20200513185615.508236-10-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200513185615.508236-1-sebastian.reichel@collabora.com> References: <20200513185615.508236-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Expose averaged current information, which is part of the SBS standard and should be supported by all batteries. Signed-off-by: Sebastian Reichel --- drivers/power/supply/sbs-battery.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c index ab774d491269..611a11385496 100644 --- a/drivers/power/supply/sbs-battery.c +++ b/drivers/power/supply/sbs-battery.c @@ -25,7 +25,8 @@ enum { REG_MANUFACTURER_DATA, REG_TEMPERATURE, REG_VOLTAGE, - REG_CURRENT, + REG_CURRENT_NOW, + REG_CURRENT_AVG, REG_MAX_ERR, REG_CAPACITY, REG_TIME_TO_EMPTY, @@ -92,8 +93,10 @@ static const struct chip_data { SBS_DATA(POWER_SUPPLY_PROP_TEMP, 0x08, 0, 65535), [REG_VOLTAGE] = SBS_DATA(POWER_SUPPLY_PROP_VOLTAGE_NOW, 0x09, 0, 20000), - [REG_CURRENT] = + [REG_CURRENT_NOW] = SBS_DATA(POWER_SUPPLY_PROP_CURRENT_NOW, 0x0A, -32768, 32767), + [REG_CURRENT_AVG] = + SBS_DATA(POWER_SUPPLY_PROP_CURRENT_AVG, 0x0B, -32768, 32767), [REG_MAX_ERR] = SBS_DATA(POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN, 0x0c, 0, 100), [REG_CAPACITY] = @@ -142,6 +145,7 @@ static enum power_supply_property sbs_properties[] = { POWER_SUPPLY_PROP_CYCLE_COUNT, POWER_SUPPLY_PROP_VOLTAGE_NOW, POWER_SUPPLY_PROP_CURRENT_NOW, + POWER_SUPPLY_PROP_CURRENT_AVG, POWER_SUPPLY_PROP_CAPACITY, POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN, POWER_SUPPLY_PROP_TEMP, @@ -324,7 +328,7 @@ static int sbs_status_correct(struct i2c_client *client, int *intval) { int ret; - ret = sbs_read_word_data(client, sbs_data[REG_CURRENT].addr); + ret = sbs_read_word_data(client, sbs_data[REG_CURRENT_NOW].addr); if (ret < 0) return ret; @@ -521,6 +525,7 @@ static void sbs_unit_adjustment(struct i2c_client *client, case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN: case POWER_SUPPLY_PROP_CURRENT_NOW: + case POWER_SUPPLY_PROP_CURRENT_AVG: case POWER_SUPPLY_PROP_CHARGE_NOW: case POWER_SUPPLY_PROP_CHARGE_FULL: case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: @@ -699,6 +704,7 @@ static int sbs_get_property(struct power_supply *psy, case POWER_SUPPLY_PROP_CYCLE_COUNT: case POWER_SUPPLY_PROP_VOLTAGE_NOW: case POWER_SUPPLY_PROP_CURRENT_NOW: + case POWER_SUPPLY_PROP_CURRENT_AVG: case POWER_SUPPLY_PROP_TEMP: case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG: case POWER_SUPPLY_PROP_TIME_TO_FULL_AVG: -- 2.26.2