summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorHyongbin Kim <hyongbink@nvidia.com>2013-08-26 16:08:45 +0900
committerGabby Lee <galee@nvidia.com>2013-08-26 23:08:36 -0700
commit50e2f7a6333ce75900995185c257d01d772173b9 (patch)
tree028e17c3080915ce07db63911c556cd2864810d5 /drivers
parent652a0736dbb6b24cc841d70c4ee3e5f3cfcec57b (diff)
power: max17048: add battery temperature property
To show battery temperature in APP, add POWER_SUPPLY_PROP_TEMP and POWER_SUPPLY_PROP_TEMP_AMBIENT in property. Android temperature unit is 1/10 C. And when battery temp is too hot(60) or too cold(-10), change battery health property. Bug 1302687 Bug 1355391 Change-Id: I530a7cd55e1abe8e7a1e3d12cfb2a95c169291d3 Signed-off-by: Hyongbin Kim <hyongbink@nvidia.com> Reviewed-on: http://git-master/r/266047 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Gabby Lee <galee@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/power/max17048_battery.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/drivers/power/max17048_battery.c b/drivers/power/max17048_battery.c
index 438efd753811..c3ed6715e356 100644
--- a/drivers/power/max17048_battery.c
+++ b/drivers/power/max17048_battery.c
@@ -49,6 +49,8 @@
#define MAX17048_DELAY (10*HZ)
#define MAX17048_BATTERY_FULL 100
#define MAX17048_BATTERY_LOW 15
+#define MAX17048_BATTERY_HOT (60*1000)
+#define MAX17048_BATTERY_COLD (-10*1000)
#define MAX17048_VERSION_NO_11 0x11
#define MAX17048_VERSION_NO_12 0x12
@@ -218,6 +220,14 @@ static int max17048_get_property(struct power_supply *psy,
case POWER_SUPPLY_PROP_VOLTAGE_OCV:
val->intval = max17048_get_ocv(chip);
break;
+ case POWER_SUPPLY_PROP_TEMP:
+ /* show 1 places of decimals, 681 means 68.1C */
+ val->intval = chip->temperature / 100;
+ break;
+ case POWER_SUPPLY_PROP_TEMP_AMBIENT:
+ /* show 1 places of decimals, 681 means 68.1C */
+ val->intval = chip->temperature / 100;
+ break;
default:
return -EINVAL;
}
@@ -434,10 +444,7 @@ static void max17048_work(struct work_struct *work)
/* Use Tskin as Battery Temp */
max17048_thz_get_temp("therm_est", &temp);
- if (temp >= 20000)
- chip->temperature = temp;
- else
- chip->temperature = 20000;
+ chip->temperature = temp;
}
if (abs(chip->temperature - chip->lasttime_temperature) >= 1500) {
@@ -452,6 +459,16 @@ static void max17048_work(struct work_struct *work)
max17048_set_current_threshold(chip->client);
max17048_sysedp_throttle(chip->client);
+ if (chip->temperature > MAX17048_BATTERY_HOT) {
+ chip->health = POWER_SUPPLY_HEALTH_OVERHEAT;
+ dev_info(&chip->client->dev, "%s: BATTERY HOT, Temp %ldC\n",
+ __func__, chip->temperature / 1000);
+ } else if (chip->temperature < MAX17048_BATTERY_COLD) {
+ dev_info(&chip->client->dev, "%s: BATTERY COLD, Temp %ldC\n",
+ __func__, chip->temperature / 1000);
+ chip->health = POWER_SUPPLY_HEALTH_COLD;
+ }
+
if (chip->soc != chip->lasttime_soc ||
chip->status != chip->lasttime_status) {
chip->lasttime_soc = chip->soc;
@@ -503,7 +520,9 @@ static enum power_supply_property max17048_battery_props[] = {
POWER_SUPPLY_PROP_CAPACITY,
POWER_SUPPLY_PROP_HEALTH,
POWER_SUPPLY_PROP_CAPACITY_LEVEL,
- POWER_SUPPLY_PROP_VOLTAGE_OCV
+ POWER_SUPPLY_PROP_VOLTAGE_OCV,
+ POWER_SUPPLY_PROP_TEMP,
+ POWER_SUPPLY_PROP_TEMP_AMBIENT,
};
static int max17048_write_rcomp_seg(struct i2c_client *client,