Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 330506
b: refs/heads/master
c: b1ad079
h: refs/heads/master
v: v3
  • Loading branch information
Kim, Milo authored and Anton Vorontsov committed Sep 21, 2012
1 parent 1b9b862 commit 2f339aa
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 638555d2769b7dfb8654bae513cff295ea9a3837
refs/heads/master: b1ad079680b24386d12aa99dd9afd4eb7093bbee
31 changes: 26 additions & 5 deletions trunk/drivers/power/lp8727_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@

/* STATUS2 register */
#define TEMP_STAT (3 << 5)
#define TEMP_SHIFT 5

enum lp8727_dev_id {
ID_NONE,
Expand All @@ -75,6 +76,13 @@ enum lp8727_chg_stat {
EOC,
};

enum lp8727_die_temp {
LP8788_TEMP_75C,
LP8788_TEMP_95C,
LP8788_TEMP_115C,
LP8788_TEMP_135C,
};

struct lp8727_psy {
struct power_supply ac;
struct power_supply usb;
Expand Down Expand Up @@ -315,12 +323,25 @@ static int lp8727_charger_get_property(struct power_supply *psy,
return 0;
}

static bool lp8727_is_high_temperature(enum lp8727_die_temp temp)
{
switch (temp) {
case LP8788_TEMP_95C:
case LP8788_TEMP_115C:
case LP8788_TEMP_135C:
return true;
default:
return false;
}
}

static int lp8727_battery_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{
struct lp8727_chg *pchg = dev_get_drvdata(psy->dev->parent);
struct lp8727_platform_data *pdata = pchg->pdata;
enum lp8727_die_temp temp;
u8 read;

switch (psp) {
Expand All @@ -337,11 +358,11 @@ static int lp8727_battery_get_property(struct power_supply *psy,
break;
case POWER_SUPPLY_PROP_HEALTH:
lp8727_read_byte(pchg, STATUS2, &read);
read = (read & TEMP_STAT) >> 5;
if (read >= 0x1 && read <= 0x3)
val->intval = POWER_SUPPLY_HEALTH_OVERHEAT;
else
val->intval = POWER_SUPPLY_HEALTH_GOOD;
temp = (read & TEMP_STAT) >> TEMP_SHIFT;

val->intval = lp8727_is_high_temperature(temp) ?
POWER_SUPPLY_HEALTH_OVERHEAT :
POWER_SUPPLY_HEALTH_GOOD;
break;
case POWER_SUPPLY_PROP_PRESENT:
if (!pdata)
Expand Down

0 comments on commit 2f339aa

Please sign in to comment.