linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: Sebastian Reichel <sre@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J . Wysocki" <rafael@kernel.org>
Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel@collabora.com,
	Sebastian Reichel <sebastian.reichel@collabora.com>
Subject: [PATCHv1 09/19] power: supply: sbs-battery: add POWER_SUPPLY_PROP_CURRENT_AVG support
Date: Wed, 13 May 2020 20:56:05 +0200	[thread overview]
Message-ID: <20200513185615.508236-10-sebastian.reichel@collabora.com> (raw)
In-Reply-To: <20200513185615.508236-1-sebastian.reichel@collabora.com>

Expose averaged current information, which is part of the SBS
standard and should be supported by all batteries.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 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


  parent reply	other threads:[~2020-05-13 18:57 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-13 18:55 [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
2020-05-13 18:55 ` [PATCHv1 01/19] kobject: increase allowed number of uevent variables Sebastian Reichel
2020-05-14  6:11   ` Greg Kroah-Hartman
2020-05-15 14:45   ` Emil Velikov
2020-05-13 18:55 ` [PATCHv1 02/19] power: supply: core: add capacity error margin property Sebastian Reichel
2020-05-13 18:55 ` [PATCHv1 03/19] power: supply: core: add manufacture date properties Sebastian Reichel
2020-05-15 14:47   ` Emil Velikov
2020-05-15 15:14     ` Sebastian Reichel
2020-05-15 16:01       ` Emil Velikov
2020-05-13 18:56 ` [PATCHv1 04/19] power: supply: core: add POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED Sebastian Reichel
2020-05-13 18:56 ` [PATCHv1 05/19] power: supply: sbs-battery: Add TI BQ20Z65 support Sebastian Reichel
2020-05-28  2:37   ` Rob Herring
2020-05-13 18:56 ` [PATCHv1 06/19] power: supply: sbs-battery: add POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN support Sebastian Reichel
2020-05-13 18:56 ` [PATCHv1 07/19] power: supply: sbs-battery: simplify read_read_string_data Sebastian Reichel
2020-05-13 18:56 ` [PATCHv1 08/19] power: supply: sbs-battery: add PEC support Sebastian Reichel
2020-05-13 18:56 ` Sebastian Reichel [this message]
2020-05-13 18:56 ` [PATCHv1 10/19] power: supply: sbs-battery: Improve POWER_SUPPLY_PROP_TECHNOLOGY support Sebastian Reichel
2020-05-13 18:56 ` [PATCHv1 11/19] power: supply: sbs-battery: add POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT/VOLTAGE_MAX support Sebastian Reichel
2020-05-13 18:56 ` [PATCHv1 12/19] power: supply: sbs-battery: add MANUFACTURE_DATE support Sebastian Reichel
2020-05-13 18:56 ` [PATCHv1 13/19] power: supply: sbs-battery: add POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED support Sebastian Reichel
2020-05-15 15:35   ` Emil Velikov
2020-05-13 18:56 ` [PATCHv1 14/19] power: supply: sbs-battery: fix idle battery status Sebastian Reichel
2020-05-13 18:56 ` [PATCHv1 15/19] power: supply: sbs-battery: add ability to disable charger broadcasts Sebastian Reichel
2020-05-15 14:57   ` Emil Velikov
2020-05-13 18:56 ` [PATCHv1 16/19] power: supply: sbs-battery: switch from of_property_* to device_property_* Sebastian Reichel
2020-05-13 18:56 ` [PATCHv1 17/19] power: supply: sbs-battery: switch to i2c's probe_new Sebastian Reichel
2020-05-13 18:56 ` [PATCHv1 18/19] power: supply: sbs-battery: constify power-supply property array Sebastian Reichel
2020-05-13 18:56 ` [PATCHv1 19/19] dt-bindings: power: sbs-battery: Convert to yaml Sebastian Reichel
2020-05-28  2:40   ` Rob Herring
2020-05-28 22:44 ` [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
2020-05-29 16:27 ` Pavel Machek
2020-06-01 21:57   ` Sebastian Reichel
     [not found] ` <CGME20200601104027eucas1p2b076ee860520d709e8178c41550653f7@eucas1p2.samsung.com>
2020-06-01 10:40   ` Marek Szyprowski
2020-06-01 17:05     ` Sebastian Reichel
2020-06-02  7:17       ` Marek Szyprowski
2020-06-02 18:01         ` Sebastian Reichel
2020-06-03 18:49           ` Marek Szyprowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200513185615.508236-10-sebastian.reichel@collabora.com \
    --to=sebastian.reichel@collabora.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).