summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2014-04-13 11:19:41 +0530
committerLaxman Dewangan <ldewangan@nvidia.com>2014-04-13 05:39:00 -0700
commit3569d0862852a998f8e739ab0920a035e19a4b38 (patch)
tree43778dcf8e9c726d694969aef4c47f59ac4d099a /drivers/power
parent4e87d8c960256166fed7e6edd228b418bbe1aa08 (diff)
power: lc709203f: add support for CURRENT_NOW property
Add support for measuring battery current now if the device node has required properties to read the battery current. bug 1413219 Change-Id: Ie0e1cf61306ce0f5fdd7611a54781fc003c8156e Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Reviewed-on: http://git-master/r/395552
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/lc709203f_battery.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/power/lc709203f_battery.c b/drivers/power/lc709203f_battery.c
index d8955ed09b3c..c7b43639e6e4 100644
--- a/drivers/power/lc709203f_battery.c
+++ b/drivers/power/lc709203f_battery.c
@@ -63,6 +63,7 @@ struct lc709203f_platform_data {
u32 maximum_soc;
u32 alert_low_rsoc;
u32 alert_low_voltage;
+ bool support_battery_current;
};
struct lc709203f_chip {
@@ -215,6 +216,7 @@ static enum power_supply_property lc709203f_battery_props[] = {
POWER_SUPPLY_PROP_PRESENT,
POWER_SUPPLY_PROP_CAPACITY_LEVEL,
POWER_SUPPLY_PROP_TEMP,
+ POWER_SUPPLY_PROP_CURRENT_NOW,
};
static int lc709203f_get_property(struct power_supply *psy,
@@ -224,6 +226,8 @@ static int lc709203f_get_property(struct power_supply *psy,
struct lc709203f_chip *chip = container_of(psy,
struct lc709203f_chip, battery);
int temperature;
+ int curr_ma;
+ int ret;
switch (psp) {
case POWER_SUPPLY_PROP_TECHNOLOGY:
@@ -265,6 +269,12 @@ static int lc709203f_get_property(struct power_supply *psy,
*/
val->intval = temperature - 2732;
break;
+ case POWER_SUPPLY_PROP_CURRENT_NOW:
+ val->intval = 0;
+ ret = battery_gauge_get_battery_current(chip->bg_dev, &curr_ma);
+ if (!ret)
+ val->intval = curr_ma;
+ break;
default:
return -EINVAL;
}
@@ -301,6 +311,7 @@ static struct battery_gauge_ops lc709203f_bg_ops = {
static struct battery_gauge_info lc709203f_bgi = {
.cell_id = 0,
.bg_ops = &lc709203f_bg_ops,
+ .current_channel_name = "battery-current",
};
static irqreturn_t lc709203f_irq(int id, void *dev)
@@ -371,6 +382,9 @@ static void of_lc709203f_parse_platform_data(struct i2c_client *client,
ret = of_property_read_u32(np, "onsemi,alert-low-voltage", &pval);
if (!ret)
pdata->alert_low_voltage = pval;
+
+ pdata->support_battery_current = of_property_read_bool(np,
+ "io-channel-names");
}
#ifdef CONFIG_DEBUG_FS
@@ -544,6 +558,10 @@ skip_thermistor_config:
chip->lasttime_status = POWER_SUPPLY_STATUS_DISCHARGING;
chip->charge_complete = 0;
+ /* Remove current property if it is not supported */
+ if (!chip->pdata->support_battery_current)
+ chip->battery.num_properties--;
+
ret = power_supply_register(&client->dev, &chip->battery);
if (ret) {
dev_err(&client->dev, "failed: power supply register\n");