Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1701464 > unrolled thread

[RFC PATCH 5/5] power: generic-adc-battery: Add capacity handling

Started byMarek Belisko <marek.belisko@open-nandra.com>
First post2017-08-01 23:00 +0200
Last post2017-08-01 23:00 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [RFC PATCH 5/5] power: generic-adc-battery: Add capacity handling Marek Belisko <marek.belisko@open-nandra.com> - 2017-08-01 23:00 +0200

#1701464 — [RFC PATCH 5/5] power: generic-adc-battery: Add capacity handling

FromMarek Belisko <marek.belisko@open-nandra.com>
Date2017-08-01 23:00 +0200
Subject[RFC PATCH 5/5] power: generic-adc-battery: Add capacity handling
Message-ID<u9MqK-nk-1@gated-at.bofh.it>
From: Marek Belisko <marek.belisko@gmail.com>

Signed-off-by: Marek Belisko <marek.belisko@gmail.com>
---
 drivers/power/supply/generic-adc-battery.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/power/supply/generic-adc-battery.c b/drivers/power/supply/generic-adc-battery.c
index 0d27b59..9ce51d2 100644
--- a/drivers/power/supply/generic-adc-battery.c
+++ b/drivers/power/supply/generic-adc-battery.c
@@ -24,6 +24,7 @@
 #include <linux/iio/types.h>
 #include <linux/power/generic-adc-battery.h>
 #include <linux/of_gpio.h>
+#include <linux/power/generic-fuel-gauge.h>
 
 #define JITTER_DEFAULT 10 /* hope 10ms is enough */
 
@@ -81,6 +82,7 @@ static const enum power_supply_property gab_props[] = {
 	POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
 	POWER_SUPPLY_PROP_MODEL_NAME,
 	POWER_SUPPLY_PROP_TEMP,
+	POWER_SUPPLY_PROP_CAPACITY,
 };
 
 /*
@@ -202,6 +204,18 @@ static int gab_get_property(struct power_supply *psy,
 	case POWER_SUPPLY_PROP_MODEL_NAME:
 		val->strval = bat_info->name;
 		break;
+	case POWER_SUPPLY_PROP_CAPACITY:
+		{
+		int ret, curr, voltage;
+
+		ret = read_channel(adc_bat, POWER_SUPPLY_PROP_CURRENT_NOW, &curr);
+		ret |= read_channel(adc_bat, POWER_SUPPLY_PROP_VOLTAGE_NOW, &voltage);
+		if (ret < 0)
+			goto err;
+
+		val->intval = fuel_level_LiIon(voltage, curr, 10);
+		}
+		break;
 	default:
 		return -EINVAL;
 	}
-- 
2.7.4

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web