#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /****************************************************************************************** * Macro definition region ******************************************************************************************/ #define DEVICE0_ID (0x0) #define USER0_NAME "USB-Host" #define DEVICE1_ID (0x1) #define USER1_NAME "UART" #define WAKEUP_EMD_USER_NUM (2) /****************************************************************************************** * Data structure definition region ******************************************************************************************/ typedef struct _wakeup_ctl_info{ int dev_major_id; int dev_sub_id; int time_out_req_count; int manual_req_count; char *name; }wakeup_ctl_info_t; /****************************************************************************************** * Gloabal variables region ******************************************************************************************/ static wakeup_ctl_info_t wakeup_user[WAKEUP_EMD_USER_NUM]; // 0-USB, 1-UART static void emd_wakeup_timer_cb(unsigned long); static void emd_wdt_work_func(struct work_struct *data); static DECLARE_WORK(emd_wdt_work, emd_wdt_work_func); static DEFINE_TIMER(emd_wakeup_timer,emd_wakeup_timer_cb,0,0); static unsigned int timeout_pending_count = 0; static spinlock_t wakeup_ctl_lock; static struct wake_lock emd_wake_lock; // Make sure WDT reset not to suspend /****************************************************************************************** * External customization functions region ******************************************************************************************/ void request_wakeup_md_timeout(unsigned int dev_id, unsigned int dev_sub_id) { int i; unsigned long flags; for(i=0; i 2) timeout_pending_count = 2; spin_unlock_irqrestore(&wakeup_ctl_lock, flags); break; } } } void request_wakeup_md(unsigned int dev_id, unsigned int dev_sub_id) { int i; unsigned long flags; for(i=0; i 0){ wakeup_user[i].time_out_req_count=0; } } // 2. Update timeout pending counter if(timeout_pending_count == 0){ EMD_MSG_INF("chr","timeout_pending_count == 0\n"); }else{ timeout_pending_count--; } // 3. Check whether need to release wakeup signal if(timeout_pending_count == 0){ // Need check whether to release for(i=0; i 0){ release_wakeup_confirm = 0; break; } } if(release_wakeup_confirm){ EMD_MSG_INF("chr","cm_release_wakeup_md_signal before\n"); cm_release_wakeup_md_signal(); } }else{ // Need to run once more mod_timer(&emd_wakeup_timer, jiffies+2*HZ); } spin_unlock_irqrestore(&wakeup_ctl_lock, flags); } static void reset_wakeup_control_logic(void) { int i; unsigned long flags; spin_lock_irqsave(&wakeup_ctl_lock, flags); for(i=0; i