void usbc_core_notify_state_reset() { kal_bool remote_wakeup_enabled = (usbc_core_get_function_remote_wk_list()==0)? KAL_FALSE:KAL_TRUE; if( USBC_IS_IN_EXCEPTION_MODE() ) { usbc_core_indicate_state(USBC_USB_STATE_RESET); usbc_core_clear_status(); return; } // nofity USBIDLE that it does not have to gate the clock of USB IP usbc_trace_info(USBCORE_DEV_SUSPEND_CLOCK, 0, 0); usb_idle_set_clockGating(KAL_FALSE); // Update function pointer for set GPDs to hardware normally usbc_trace_info(USBCORE_UPDATE_API_BUFF_GPD, 0); usbc_normal_hif_factory(); // Notify USB reset event to USB classes and clear USB status usbc_core_indicate_state(USBC_USB_STATE_RESET); usbc_core_clear_status(); // Ask USBIDLE to notify L4 to turn RF power on or go back to normal operation state usbc_trace_info(USBCORE_DEV_SUSPEND_L4, 0, 0, 0, (remote_wakeup_enabled? 1:0)); usb_idle_set_l4_power_saving(KAL_FALSE); usb_idle_event_notify_to_l4(KAL_FALSE, remote_wakeup_enabled); }
void usbc_core_notify_state_resume() { kal_bool remote_wakeup_enabled = (usbc_core_get_function_remote_wk_list()==0)? KAL_FALSE:KAL_TRUE; if( USBC_IS_IN_EXCEPTION_MODE() ) { usbc_core_indicate_state(USBC_USB_STATE_RESUME); return; } // nofity USBIDLE that it does not have to gate the clock of USB IP usbc_trace_info(USBCORE_DEV_SUSPEND_CLOCK, 0, 0); usb_idle_set_clockGating(KAL_FALSE); // Notify USB resume event to USB classes usbc_core_indicate_state(USBC_USB_STATE_RESUME); // Update function pointer for set GPDs to hardware normally usbc_trace_info(USBCORE_UPDATE_API_BUFF_GPD, 0); usbc_normal_hif_factory(); // Set GPDs that are buffered in DRAM to hardware usbc_normal_hif_restore_gpd_pwrsave(); // Set USBCORE task to wait for both indication events and tick events usbc_trace_info(USBCORE_SUSPEND_START_POLL); usbc_core_get_instance()->hmu_indication = HIF_DRV_EG_HIF_TICK_EVENT | HIF_DRV_EG_USBC_IND_EVENT; // Ask USBIDLE to notify L4 to turn RF power on or go back to normal operation state usbc_trace_info(USBCORE_DEV_SUSPEND_L4, 0, 0, 0, (remote_wakeup_enabled? 1:0)); usb_idle_set_l4_power_saving(KAL_FALSE); usb_idle_event_notify_to_l4(KAL_FALSE, remote_wakeup_enabled); }
kal_bool usbc_cosim_core_task_init(void) { usbc_core_t* pUsbCore; kal_char usbc_class_mutex_name[50]; #ifdef IPCORE_NOT_PRESENT hmu_boot_init(); #endif usbc_set_op_mode(USBC_OP_MODE_NORMAL); kal_mem_set(usbc_core_get_instance(), 0, sizeof(usbc_core_t)); usbc_core_clear_register(); usbc_core_clear_status(); pUsbCore = usbc_core_get_instance(); // create enhance mutex sprintf(usbc_class_mutex_name, "USBC_CLASS_REMOTE_WK_MUTEX"); pUsbCore->usbc_class_remote_wk_mutex = kal_create_enh_mutex(usbc_class_mutex_name); sprintf(usbc_class_mutex_name, "USBC_CLASS_RENOTIFY_MUTEX"); pUsbCore->usbc_class_renotify_mutex = kal_create_enh_mutex(usbc_class_mutex_name); sprintf(usbc_class_mutex_name, "USBC_CLASS_FUNC_ACCESS_MUTEX"); pUsbCore->usbc_class_func_access_mutex = kal_create_enh_mutex(usbc_class_mutex_name); if ( NULL == pUsbCore->usbc_class_remote_wk_mutex || NULL == pUsbCore->usbc_class_renotify_mutex || NULL == pUsbCore->usbc_class_func_access_mutex ) { ASSERT(0); } // initial an evnet scheduler pUsbCore->usbc_es_wk_notify_g = evshed_create( "USBC_WK_NOTIFY", /* timer_name: event scheduler name */ MOD_USBCORE, /* dest_mod_id: system sends timeout message to this module when event scheduler timeout happens */ 0, /* fuzz */ 255); /* max_delay_ticks */ if (pUsbCore->usbc_es_wk_notify_g) { evshed_set_index(pUsbCore->usbc_es_wk_notify_g, USBC_WK_NOTIFY_INDEX); } else { ASSERT(0); } usbc_normal_hif_factory(); usbc_cosim_hif_factory(); usbc_stack_checkin(USB_CLASS_NUM, NULL); return KAL_TRUE; }