예제 #1
0
void bat_log_work_func(struct work_struct *work)
{
    char buf[80];
    struct bq27541_info *di = container_of(work,
                struct bq27541_info, bat_log_work.work);
    sprintf(buf,"%s:def:capacity=%d,current=%d,voltage=%d",__func__,di->capacity,di->current_avg,di->voltage);
    log_to_metrics(ANDROID_LOG_INFO, "Battery", buf);
    if(di->state==BAT_CRITICAL_STATE)
        queue_delayed_work(bat_work_queue,&di->bat_log_work,
                            msecs_to_jiffies(60000 * 1));
}
예제 #2
0
static irqreturn_t powerbutton_irq(int irq, void *_pwr)
{
	struct input_dev *pwr = _pwr;
	int err;
	u8 value;

	err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &value,REG_STS_HW_CONDITIONS);
	if (!err)  {
		char buf[128];

		int press = (value & PWR_PWRON_IRQ) ? STATE_RELEASE : STATE_PRESS;

		char *action = press ? "press" : "release";

		input_report_key(pwr, KEY_POWER, press);
		input_sync(pwr);

		sprintf(buf, "%s:powi%c:action=%s:", __func__, action[0], action);

		log_to_metrics(ANDROID_LOG_INFO, "PowerKeyEvent", buf);

		strcat(buf, "\n");
		printk(buf);


		if(press != prev_press) {
			if(press) {
				prev_press = STATE_PRESS;

			} else {
				prev_press = STATE_RELEASE;

				/* Check if we are connected to USB */
				if (!twl_i2c_read_u8(TWL6030_MODULE_CHARGER,
						&value, 0x03) && !(value & (1 << 2))) {

					/*
					 * No USB, hold a partial wakelock,
					 * scheduled a work 2 seconds later
					 * to switch off the LED
					 */
					wake_lock_timeout(&pwrbutton_wakelock, 3*HZ);
					cancel_delayed_work_sync(&pwrbutton_work);
					omap4430_orange_led_set(NULL, 0);
					omap4430_green_led_set(NULL, 255);

					schedule_delayed_work(&pwrbutton_work,
						HZ*2);
				}
			}
		}else{
			if(g_in_suspend==1){
					wake_lock(&pwrbutton_wakelock);
					input_report_key(pwr, KEY_POWER, 1);
					input_report_key(pwr, KEY_POWER, 0);
					input_sync(pwr);
					omap4430_orange_led_set(NULL, 0);
					omap4430_green_led_set(NULL, 255);
					schedule_delayed_work(&pwrbutton_work,
						msecs_to_jiffies(2000));
			}
		}
	} else {
		dev_err(pwr->dev.parent, "twl4030: i2c error %d while reading"
			" TWL4030 PM_MASTER STS_HW_CONDITIONS register\n", err);

                /* If an error occurs we don't want to display the SysReq the next time user will
                 * push and release power button.
                 */
                prev_press = STATE_UNKNOWN;
	}

	return IRQ_HANDLED;
}