static DEFINE_MUTEX(charging_lock); enum power_supply_type charging_ic_status; //static recharging_state_t recharging_status; static int bat_soc; struct delayed_work charger_timer_work; struct timer_list charging_timer; void charging_timer_func(unsigned long try) { u32 wait; // [[email protected]] FIXME : get battery SOC from fuel gague bat_soc = get_bat_soc(); if(charging_timer.data > 3 || bat_soc > 99) { schedule_delayed_work(&charger_timer_work, 0); return; } else { //wait = (HZ*CHR_TIMER_SECS * (100 - bat_soc)) / 100; wait = HZ*CHR_TIMER_SECS; // // charging_timer.expires += wait; charging_timer.data += 1; add_timer(&charging_timer);
/** * suspend_devices_and_enter - suspend devices and enter the desired system * sleep state. * @state: state to enter */ int suspend_devices_and_enter(suspend_state_t state) { int error; gfp_t saved_mask; if (!suspend_ops) return -ENOSYS; if (suspend_ops->begin) { error = suspend_ops->begin(state); if (error) goto Close; } #if 1 { struct timespec ts; struct rtc_time tm; long elasped_time=0L; int capa = get_bat_soc(); // battery capa get int volt = get_bat_volt(); // fuel gage volt getnstimeofday(&ts); rtc_time_to_tm(ts.tv_sec, &tm); //printk("%s:", __func__); elasped_time=ts.tv_sec-old_ts.tv_sec; printk("([elasped_time=%ldsec, suspend]%d-%02d-%02d %02d:%02d:%02d.%09lu UTC, battery capa=%d, volt=%d)\n", elasped_time, tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, ts.tv_nsec, capa, volt); old_ts = ts; } #endif suspend_console(); saved_mask = clear_gfp_allowed_mask(GFP_IOFS); suspend_test_start(); error = dpm_suspend_start(PMSG_SUSPEND); if (error) { printk(KERN_ERR "PM: Some devices failed to suspend\n"); goto Recover_platform; } suspend_test_finish("suspend devices"); if (suspend_test(TEST_DEVICES)) goto Recover_platform; suspend_enter(state); Resume_devices: suspend_test_start(); dpm_resume_end(PMSG_RESUME); suspend_test_finish("resume devices"); set_gfp_allowed_mask(saved_mask); resume_console(); #if 1 { struct timespec ts; struct rtc_time tm; int capa = get_bat_soc(); // battery capa get int volt = get_bat_volt(); // fuel gage volt getnstimeofday(&ts); long elasped_time=0L; elasped_time=ts.tv_sec-old_ts.tv_sec; rtc_time_to_tm(ts.tv_sec, &tm); //printk("%s:", __func__); printk("\n([elasped_time=%ldsec, resume]%d-%02d-%02d %02d:%02d:%02d.%09lu UTC, battery capa=%d, volt=%d)\n", elasped_time, tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, ts.tv_nsec, capa, volt); old_ts = ts; } #endif Close: if (suspend_ops->end) suspend_ops->end(); return error; Recover_platform: if (suspend_ops->recover) suspend_ops->recover(); goto Resume_devices; }