/*============================================================================*/
bool usb_handshake(struct bldr_command_handler *handler)
{
    uint32 enum_tmo = CFG_USB_ENUM_TIMEOUT_EN ? USB_ENUM_TIMEOUT : 0;
    uint32 handshake_tmo = CFG_USB_HANDSHAKE_TIMEOUT_EN ? USB_SYNC_TIME : 0;
    bool result = FALSE;
    bool force_download = FALSE;

    platform_vusb_on();

    force_download = platform_com_wait_forever_check();

    if (TRUE == force_download) {
        enum_tmo = 0;
        handshake_tmo = 0;
    } else if (!usb_cable_in()) {
        return FALSE;
    }
    
    print("%s USB enum timeout (%s), handshake timeout(%s)\n", MOD, 
        enum_tmo ? "Yes" : "No", 
        handshake_tmo ? "Yes" : "No");
    
    usbdl_init();
    udelay(1000);
    usb_disconnect();

    if (usb_connect(enum_tmo) == FALSE) {
        print("%s USB enum timeout!\n", MOD);
        goto end;
    }

    udelay(1000);
    if (FALSE == usb_handshake_handler(handler, handshake_tmo)) {    
        goto end;
    }

    result = TRUE;

    if (FALSE == usb_port_down(USB_PORT_DOWN_TIME)) {
        print("%s USB port down timeout!\n", MOD);
    }

end:
    usb_service_offline();

#if CFG_USBIF_COMPLIANCE
    /* USB compliance test: 100mA charging current when USB is unconfigured. */
    platform_set_chrg_cur(70);
#endif

    return result;
}
Ejemplo n.º 2
0
static int bldr_handshake(struct bldr_command_handler *handler)
{
    boot_mode_t mode = 0;
    bool isSBC = 0;

#ifdef MTK_SECURITY_SW_SUPPORT
    /* get mode type */
    mode = seclib_brom_meta_mode();
    isSBC = seclib_sbc_enabled();
	BOOTING_TIME_PROFILING_LOG("seclib_brom_meta_mode");
#endif


    switch (mode) {
    case NORMAL_BOOT:
        /* ------------------------- */
        /* security check            */
        /* ------------------------- */
        if (TRUE == isSBC) {
            handler->attr |= CMD_HNDL_ATTR_COM_FORBIDDEN;
            print("%s META DIS\n", MOD);
        }

        #if CFG_USB_TOOL_HANDSHAKE
        platform_pmic_full_reset_disable();
        if (TRUE == usb_handshake(handler))
            g_meta_com_type = META_USB_COM;
        platform_pmic_full_reset_enable();
		BOOTING_TIME_PROFILING_LOG("USB handshake");
        #endif
        #if CFG_UART_TOOL_HANDSHAKE
        if (TRUE == uart_handshake(handler))
            g_meta_com_type = META_UART_COM;
		BOOTING_TIME_PROFILING_LOG("UART handshake");
        #endif

        break;

    case META_BOOT:
        print("%s BR META BOOT\n", MOD);
        g_boot_mode = META_BOOT;

        if(!usb_cable_in())
            g_meta_com_type = META_UART_COM;
        else
            g_meta_com_type = META_USB_COM;
        break;


    case FACTORY_BOOT:
        print("%s BR FACTORY BOOT\n", MOD);
        g_boot_mode = FACTORY_BOOT;

        if(!usb_cable_in())
            g_meta_com_type = META_UART_COM;
        else
            g_meta_com_type = META_USB_COM;
        break;


    case ADVMETA_BOOT:
        print("%s BR ADVMETA BOOT\n", MOD);
        g_boot_mode = ADVMETA_BOOT;

        if(!usb_cable_in())
            g_meta_com_type = META_UART_COM;
        else
            g_meta_com_type = META_USB_COM;
        break;


    case ATE_FACTORY_BOOT:
        print("%s BR ATE FACTORY BOOT\n", MOD);
        g_boot_mode = ATE_FACTORY_BOOT;

        if(!usb_cable_in())
            g_meta_com_type = META_UART_COM;
        else
            g_meta_com_type = META_USB_COM;
        break;


    default:
        print("%s UNKNOWN MODE\n", MOD);
        break;
    }

    return 0;
}