power: bq24617: Add support to report charging separately

Just because the charger is present, doesn't mean that the battery is
being charged.  For example, the battery can be overheating, which
will prevent charging.

Change-Id: If5d8dc325fc6dc507808216f1e45a180d74b5d73
Signed-off-by: Greg Meiste <w30289@motorola.com>
This commit is contained in:
Greg Meiste
2010-09-07 11:20:39 -05:00
committed by Colin Cross
parent 17ab6bba46
commit ed28235171

View File

@@ -32,7 +32,8 @@ struct bq24617_data {
int ac_online;
};
static int bq24617_stat2_value;
static int bq24617_stat1_value = 1; /* 0 = charging in progress */
static int bq24617_stat2_value = 1; /* 0 = charge complete */
static char *bq24617_supply_list[] = {
"battery",
@@ -42,6 +43,11 @@ static enum power_supply_property bq24617_power_props[] = {
POWER_SUPPLY_PROP_ONLINE,
};
int is_ac_charging(void)
{
return (!bq24617_stat1_value || !bq24617_stat2_value);
}
int is_ac_charge_complete(void)
{
return !bq24617_stat2_value;
@@ -75,23 +81,23 @@ static void bq24617_work(struct work_struct *work)
{
struct bq24617_data *bq_data =
container_of(work, struct bq24617_data, work);
int stat1;
int detect = 0;
/* STAT1 indicates charging, STAT2 indicates charge complete */
stat1 = gpio_get_value(irq_to_gpio(bq_data->stat1_irq));
bq24617_stat1_value = gpio_get_value(irq_to_gpio(bq_data->stat1_irq));
bq24617_stat2_value = gpio_get_value(irq_to_gpio(bq_data->stat2_irq));
if (bq_data->detect_irq >= 0)
detect = gpio_get_value(irq_to_gpio(bq_data->detect_irq));
if (!stat1 || !bq24617_stat2_value || detect)
if (!bq24617_stat1_value || !bq24617_stat2_value || detect)
bq_data->ac_online = 1;
else
bq_data->ac_online = 0;
pr_info("%s: ac_online=%d (stat1=%d, stat2=%d, detect=%d)\n", __func__,
bq_data->ac_online, stat1, bq24617_stat2_value, detect);
bq_data->ac_online, bq24617_stat1_value, bq24617_stat2_value,
detect);
power_supply_changed(&bq_data->ac);
wake_unlock(&bq_data->wake_lock);