This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Bq27210 Android Battery Monitor query

Other Parts Discussed in Thread: BQ27210, BQ27500

Hi

we are using TI BQ27210 in our project for Battery voltage monitoring purpose.we are using the default driver bq27x00_battery .c provided with Android JB4.3.we are able to read the  entries from the battery driver through sysfs properly.But these details are not getting posted to the Android User space properly

we are seeing that power_supply_changed is not triggering the UEventThread' run function which is waiting on this event. in file frameworks/base/core/java/android/os/UEventObserver.java  i.e

/*******************************************************************

private static final class UEventThread extends Thread {
       ...................

            while (true) {
                Log.d(TAG, "***************nativeWaitForNextEvent()");
                String message = nativeWaitForNextEvent();
                Log.d(TAG, "***************got event from ---- nativeWaitForNextEvent()");
                if (message != null) {
                    if (DEBUG) {
                        Log.d(TAG, message);
                    }
                Log.d(TAG, "***************send event!");
                    sendEvent(message);
                }
            }
        }

****************************************************************************************

And below is our driver code which triggers power_supply changed function.This is being called every 120 seconds properly

static void bq27x00_update(struct bq27x00_device_info *di)
{
        struct bq27x00_reg_cache cache = {0, };
        bool is_bq27500 = di->chip == BQ27500;

        cache.flags = bq27x00_read(di, BQ27x00_REG_FLAGS, is_bq27500);
        if (cache.flags >= 0) {
                cache.capacity = bq27x00_battery_read_rsoc(di);

                cache.temperature = bq27x00_read(di, BQ27x00_REG_TEMP, false);
                cache.time_to_empty = bq27x00_battery_read_time(di, BQ27x00_REG_TTE);
                cache.time_to_empty_avg = bq27x00_battery_read_time(di, BQ27x00_REG_TTECP);
                cache.time_to_full = bq27x00_battery_read_time(di, BQ27x00_REG_TTF);
                cache.charge_full = bq27x00_battery_read_lmd(di);
                cache.cycle_count = bq27x00_battery_read_cyct(di);

                if (!is_bq27500)
                        cache.current_now = bq27x00_read(di, BQ27x00_REG_AI, false);

                /* We only have to read charge design full once */
                if (di->charge_design_full <= 0)
                        di->charge_design_full = bq27x00_battery_read_ilmd(di);
        }

        /* Ignore current_now which is a snapshot of the current battery state
         * and is likely to be different even between two consecutive reads */
        if (memcmp(&di->cache, &cache, sizeof(cache) - sizeof(int)) != 0) {
                di->cache = cache;
                printk(KERN_ERR "BQ27x00 power_supply_changed\n");
                power_supply_changed(&di->bat);
        }

        di->last_update = jiffies;
}

We are stuck.Please guide us in right direction.

Regards

Anand

  • Hi

    I found a clue in this direction that is I see a error value returned for the function call kobject_uevent as -2 (temp1 = -2) in below code.I dont know how to go ahead.

    static void power_supply_changed_work(struct work_struct *work)
    {
            unsigned long flags;
            int temp1;
            struct power_supply *psy = container_of(work, struct power_supply,
                                                    changed_work);

            dev_dbg(psy->dev, "%s changed flag = %d\n ", __func__,psy->changed);

            spin_lock_irqsave(&psy->changed_lock, flags);
            if (psy->changed) {
                    psy->changed = false;
                    spin_unlock_irqrestore(&psy->changed_lock, flags);

                    class_for_each_device(power_supply_class, NULL, psy,
                                          __power_supply_changed_work);

                    power_supply_update_leds(psy);

                    temp1 = kobject_uevent(&psy->dev->kobj, KOBJ_CHANGE);
                    dev_dbg(psy->dev,"temp 1 = %d",temp1);
                    spin_lock_irqsave(&psy->changed_lock, flags);
            }
            if (!psy->changed)
                    wake_unlock(&psy->work_wake_lock);
            spin_unlock_irqrestore(&psy->changed_lock, flags);
    }

    Regards

    Anand

  • Hi

    Can anybody in the forum reply to this question please.???

    Regards

    Anand