summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorwahsu <wahsu@nvidia.com>2014-03-20 19:50:02 +0800
committerRiham Haidar <rhaidar@nvidia.com>2014-05-05 11:06:52 -0700
commit299583f63a93fe4c2e6c1475b3682b8ed62b9427 (patch)
tree204f4e1fff48a8eb0bf6c7345c15eb5eff5176b6 /drivers/power
parent8970fd9f25ee29472718379e16a19321854657f5 (diff)
Batt: t124-tn8: add sysfs to read battery capacity
bug 1433349 Change-Id: I93d71ee6ae0f76f1a78ea272fb2d7b4210464e81 Signed-off-by: wahsu <wahsu@nvidia.com> Reviewed-on: http://git-master/r/384366 Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Change-Id: Ic87db2d5d7e07297eb111d11d1a6ead3c6c7fd39 Reviewed-on: http://git-master/r/404460 Reviewed-by: Wayne Hsu <wahsu@nvidia.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/battery-charger-gauge-comm.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/power/battery-charger-gauge-comm.c b/drivers/power/battery-charger-gauge-comm.c
index ee4c44116498..3b615bcc82bb 100644
--- a/drivers/power/battery-charger-gauge-comm.c
+++ b/drivers/power/battery-charger-gauge-comm.c
@@ -39,6 +39,7 @@
#include <linux/power/reset/system-pmic.h>
#include <linux/wakelock.h>
#include <linux/iio/consumer.h>
+#include <linux/iio/types.h>
#include <linux/iio/iio.h>
#define JETI_TEMP_COLD 0
@@ -264,15 +265,45 @@ static ssize_t battery_show_snapshot_capacity(struct device *dev,
bg_dev->battery_snapshot_capacity);
}
+static ssize_t battery_show_max_capacity(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct iio_channel *channel;
+ int val, ret;
+
+ channel = iio_channel_get(dev, "batt_id");
+ if (IS_ERR(channel)) {
+ dev_err(dev,
+ "%s: Failed to get channel batt_id, %ld\n",
+ __func__, PTR_ERR(channel));
+ return 0;
+ }
+
+ ret = iio_read_channel_raw(channel, &val);
+ if (ret < 0) {
+ dev_err(dev,
+ "%s: Failed to read channel, %d\n",
+ __func__, ret);
+ return 0;
+ }
+
+ return snprintf(buf, MAX_STR_PRINT, "%d\n", val);
+}
+
static DEVICE_ATTR(battery_snapshot_voltage, S_IRUGO,
battery_show_snapshot_voltage, NULL);
static DEVICE_ATTR(battery_snapshot_capacity, S_IRUGO,
battery_show_snapshot_capacity, NULL);
+static DEVICE_ATTR(battery_max_capacity, S_IRUGO,
+ battery_show_max_capacity, NULL);
+
static struct attribute *battery_snapshot_attributes[] = {
&dev_attr_battery_snapshot_voltage.attr,
&dev_attr_battery_snapshot_capacity.attr,
+ &dev_attr_battery_max_capacity.attr,
NULL
};