Exemple #1
0
void usbc_core_notify_function_state_suspending(kal_uint8 class_device_id)
{
    kal_uint8 func_suspend_list;
    kal_uint8 func_wk_list = usbc_core_get_function_remote_wk_list();
    usbc_core_t *pUsbCore = usbc_core_get_instance();
    usbcore_usbidle_l4_power_saving_req_struct *rsp_msg_p;

    // Notify the specific function of USB suspended
    if ( !pUsbCore->class_device[class_device_id].is_func_suspend )
    {
        usbc_core_indicate_function_state(class_device_id, USBC_USB_STATE_SUSPENDING);
        usbc_core_indicate_function_state(class_device_id, USBC_USB_STATE_SUSPENDED);
        pUsbCore->class_device[class_device_id].is_func_suspend = KAL_TRUE;
    }

    // If all functions of the device are suspended, we notify L4 to do power saving
    func_suspend_list = usbc_core_get_function_suspend_list();
    if( !USBC_IS_IN_EXCEPTION_MODE() &&
        func_suspend_list == ((0x01 << pUsbCore->total_class_devices)-1) )
    {
        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 = KAL_TRUE;
        rsp_msg_p->notify_suspend_with_remote_wk = (func_wk_list==0)? KAL_FALSE:KAL_TRUE;
        usbc_trace_info(USBCORE_DEV_SUSPEND_L4, 1, 1, 1, (rsp_msg_p->notify_suspend_with_remote_wk? 0:1));
        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); //msg id
    }
}
Exemple #2
0
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);
}
Exemple #3
0
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);
}
Exemple #4
0
void usbc_core_notify_state_suspending()
{
    kal_uint8 func_list;
    usbcore_usbidle_l4_power_saving_req_struct *rsp_msg_p;

    // notify USBCLASS of USB suspended
    usbc_core_indicate_state(USBC_USB_STATE_SUSPENDING);
    usbc_core_indicate_state(USBC_USB_STATE_SUSPENDED);

    if( USBC_IS_IN_EXCEPTION_MODE() )
    {
        return;
    }	    

    // Updatea function pointer for setting GPDs in DRAM buffer
    usbc_trace_info(USBCORE_UPDATE_API_BUFF_GPD, 1);
    usbc_suspended_hif_factory();

    // Notify USBIDLE task to gate USB clock
    usbc_trace_info(USBCORE_DEV_SUSPEND_CLOCK, 1, 1);
    usb_idle_set_clockGating(KAL_TRUE);         // notify USBIDLE that it has to gate the clock of USB IP
    msg_send4(MOD_USBCORE,  // src module
              MOD_USBIDLE,  // dst module
              0,       // sap id
              MSG_ID_USBCORE_SUSPEND_TO_IDLE); //msg id

    // Ask USBIDLE to notify L4 to turn RF power off or go to fast dormancy
    func_list = usbc_core_get_function_remote_wk_list();
    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 = KAL_TRUE;
    rsp_msg_p->notify_suspend_with_remote_wk = (func_list==0)? KAL_FALSE:KAL_TRUE;
    usbc_trace_info(USBCORE_DEV_SUSPEND_L4, 1, 1, 1, (rsp_msg_p->notify_suspend_with_remote_wk? 1:0));
    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); //msg id
 
    // Set USBCORE task to wait for indication events only
    usbc_trace_info(USBCORE_SUSPEND_STOP_POLL);
    usbc_core_get_instance()->hmu_indication = HIF_DRV_EG_USBC_IND_EVENT;   // Set USBCORE task to wait for indication events only
}
kal_bool usbc_class_device_submit_control_request(
    kal_uint8 class_device_id, kal_uint8* buffer, kal_uint32 length,
    usbc_control_request_type_e type)
{
    usbc_core_t* pUsbCore = usbc_core_get_instance();

    if (!USBC_IS_IN_EXCEPTION_MODE())
    {
        USBC_CLASS_DEVICE_CONTEXT_CHECK();
    }

    if ( (class_device_id >= pUsbCore->total_class_devices) ||
         (pUsbCore->class_device[class_device_id].state != USBC_CORE_CLASS_DEVICE_STATE_REGISTERED) )
    {
        ASSERT(0);
        return KAL_FALSE;
    }

    usbc_core_set_control_request(buffer, length, type);

    return KAL_TRUE;
}
Exemple #6
0
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);
    }
}