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); }
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_class_device_netifx_suspend_notify(kal_uint8 class_device_id, kal_bool suspend, kal_bool remote_wakeup) { usbcore_usbidle_l4_power_saving_req_struct *rsp_msg_p; usbc_core_t* pUsbCore = usbc_core_get_instance(); if ( 1 #ifdef __USB_RNDIS_SUPPORT__ && (pUsbCore->class_device[class_device_id].class_type != USB_CLASS_RNDIS) #endif #ifdef __USB_MBIM_SUPPORT__ && (pUsbCore->class_device[class_device_id].class_type != USB_CLASS_MBIM) #endif #ifdef __USB_ECM_SUPPORT__ && (pUsbCore->class_device[class_device_id].class_type != USB_CLASS_ECM) #endif ) { ASSERT(0); return; } // In current implemnntation, only notifying L4 of USB suspended/resuming with remote wakeup is allowed ASSERT(remote_wakeup); if( suspend ) { rsp_msg_p = (usbcore_usbidle_l4_power_saving_req_struct*)construct_local_para(sizeof(usbcore_usbidle_l4_power_saving_req_struct), TD_RESET); ASSERT(rsp_msg_p); rsp_msg_p->notify_suspend = suspend; rsp_msg_p->notify_suspend_with_remote_wk = remote_wakeup; usb_idle_set_l4_power_saving(KAL_TRUE); msg_send6(MOD_USBCORE, // src module MOD_USBIDLE, // dst module 0, // sap id MSG_ID_USBCORE_IDLE_NOTIFY_TO_L4, (local_para_struct*)rsp_msg_p, 0); } else { usb_idle_set_l4_power_saving(KAL_FALSE); usb_idle_event_notify_to_l4(suspend, remote_wakeup); } }
void usbc_core_notify_function_state_resume(kal_uint8 class_device_id) { kal_uint8 func_suspend_list = usbc_core_get_function_suspend_list(); kal_bool remote_wakeup_enabled = (usbc_core_get_function_remote_wk_list()==0)? KAL_FALSE:KAL_TRUE; usbc_core_t *pUsbCore = usbc_core_get_instance(); // Notify the specific function of USB resuming if ( pUsbCore->class_device[class_device_id].is_func_suspend ) { usbc_core_indicate_function_state(class_device_id, USBC_USB_STATE_RESUME); pUsbCore->class_device[class_device_id].is_func_suspend = KAL_FALSE; } // Notify L4 to go back to normal operation states if function resumes from the status that all functions are suspended before if( !USBC_IS_IN_EXCEPTION_MODE() && func_suspend_list == ((0x01 << pUsbCore->total_class_devices)-1) ) { usbc_trace_info(USBCORE_DEV_SUSPEND_L4, 0, 0, 0, (remote_wakeup_enabled? 0:1)); usb_idle_set_l4_power_saving(KAL_FALSE); usb_idle_event_notify_to_l4(KAL_FALSE, remote_wakeup_enabled); } }