Example #1
0
void usb_phy_recover(){
    usb_enable_clock(true);

    udelay(50);

    USBPHY_CLR8(0x6b, 0x04);  
    USBPHY_CLR8(0x6e, 0x1); 
	
	USBPHY_CLR8(0x6a, 0x04);
	
	USBPHY_CLR8(0x68, 0x40);
	USBPHY_CLR8(0x68, 0x80);
	USBPHY_CLR8(0x68, 0x30); 
	USBPHY_CLR8(0x68, 0x04);
	USBPHY_CLR8(0x69, 0x3c);
	
	USBPHY_CLR8(0x6a, 0x10);
	USBPHY_CLR8(0x6a, 0x20);
	USBPHY_CLR8(0x6a, 0x08);
	USBPHY_CLR8(0x6a, 0x02);
	USBPHY_CLR8(0x6a, 0x80);

	USBPHY_CLR8(0x1c, 0x80);
    USBPHY_SET8(0x1b, 0x08);
    udelay(800);

    hs_slew_rate_cal();

printk("usb recovery success\n");
    return;
}
Example #2
0
void mt6573_usb_phy_recover(struct mt_udc *udc){

    if(udc->power == USB_TRUE)
        return;

    mt6573_usb_enable_clock(TRUE);

    udelay(50);

    USBPHY_CLR8(0x1e, 0x04);
    USBPHY_CLR8(0x10, 0x10);  
    USBPHY_CLR8(0x6b, 0x04); 
    USBPHY_CLR8(0x66, 0x40);  
    USBPHY_SET8(0x66, 0x20);  
    USBPHY_CLR8(0x6a, 0x04); 
    USBPHY_CLR8(0x68, 0x40);  
    USBPHY_CLR8(0x68, 0x80);  
    USBPHY_CLR8(0x68, 0x30);  
    USBPHY_CLR8(0x68, 0x04);  
    USBPHY_CLR8(0x69, 0x3c);  
    USBPHY_CLR8(0x6a, 0x10);  
    USBPHY_CLR8(0x6a, 0x20);  
    USBPHY_CLR8(0x6a, 0x08);  
    USBPHY_CLR8(0x6a, 0x02); 
    USBPHY_CLR8(0x6a, 0x80); 
    USBPHY_SET8(0x1b, 0x04); 
		USBPHY_SET8(0x00, 0x80); 
    udelay(100);

    hs_slew_rate_cal();

    udc->power = USB_TRUE;

    return;
}
Example #3
0
void usb_phy_recover(){

  //turn on USB reference clock. 
  usb_enable_clock(true);
  
  if (usb_phy_check_in_uart_mode())
		return;
		
  //wait 50 usec.
  udelay(50);

	/* force_uart_en = 1'b0 */
	USBPHY_CLR8(0x6b, 0x04);
	/* RG_UART_EN = 1'b0 */
	USBPHY_CLR8(0x6e, 0x01);
	/* force_uart_en = 1'b0 */
	USBPHY_CLR8(0x6a, 0x04);
  /* RG_DPPULLDOWN./RG_DMPULLDOWN. */
  /* RG_XCVRSEL[1:0] = 2'b00 */
  /* RG_TERMSEL = 1'b0 */
	USBPHY_CLR8(0x68, 0xf4);
	/* RG_DATAIN[3:0] = 4'b0000 */
	USBPHY_CLR8(0x69, 0x3c);
	/*
	 * force_dp_pulldown, force_dm_pulldown, 
	 * force_xcversel, force_termsel.
	 */
	USBPHY_CLR8(0x6a, 0xba);

	/* RG_USB20_BC11_SW_EN = 1'b0 */
	USBPHY_CLR8(0x1a, 0x80);
	/* RG_USB20_OTG_VBUSSCMP_EN = 1'b1 */
	USBPHY_SET8(0x1a, 0x10);

	udelay(800);
    
// force enter device mode
	USBPHY_CLR8(0x6c, 0x10);
	USBPHY_SET8(0x6c, 0x2E);
	USBPHY_SET8(0x6d, 0x3E);
  
  hs_slew_rate_cal();
  
  //RG_USB20_VRT_VREF_SEL[2:0]=5 (ori:4) (0x11110804[14:12])
  USBPHY_SET8(0x05, 0x10);
  //RG_USB20_TERM_VREF_SEL[2:0]=5 (ori:4) (0x11110804[10:8])
  USBPHY_SET8(0x05, 0x01);
  

	printk("USB HW reg: index18=0x%x, index7=0x%x\n", get_devinfo_with_index(18), get_devinfo_with_index(7));  
  if (get_devinfo_with_index(18) & (0x01<<14))
	{
		USBPHY_CLR8(0x00, 0x20);
		printk("USB HW reg: write RG_USB20_INTR_EN 0x%x\n", USBPHY_READ8(0x00));
	}
	
	if (get_devinfo_with_index(7) & (0x07<<8))
	{
		//RG_USB20_VRT_VREF_SEL[2:0]=5 (ori:4) (0x11110804[14:12])
		USBPHY_CLR8(0x05, 0x70);
  	USBPHY_SET8(0x05, ((get_devinfo_with_index(7)>>8)<<4)&0x70);
  	printk("USB HW reg: overwrite RG_USB20_VRT_VREF_SEL 0x%x\n", USBPHY_READ8(0x05));
	}
/* Denali_USB_PWR Sequence 20141030.xls */
void usb_phy_recover(void)
{

	/* to avoid hw access during clock-on */
	unsigned long flags;
	int do_lock;

	do_lock = 0;

	if (mtk_musb) {
		spin_lock_irqsave(&mtk_musb->lock, flags);
		do_lock = 1;
	} else {
		DBG(0, "mtk_musb is NULL\n");
		return;
	}

	/* turn on USB reference clock. */
	usb_enable_clock(true);

	if (do_lock)
		spin_unlock_irqrestore(&mtk_musb->lock, flags);

	/* wait 50 usec. */
	udelay(50);

#ifdef CONFIG_MTK_UART_USB_SWITCH
	if (!usb_phy_check_in_uart_mode()) {
		/* clean PUPD_BIST_EN */
		/* PUPD_BIST_EN = 1'b0 */
		/* PMIC will use it to detect charger type */
		USBPHY_CLR8(0x1d, 0x10);

		/* force_uart_en, 1'b0 */
		USBPHY_CLR8(0x6b, 0x04);
		/* RG_UART_EN, 1'b0 */
		USBPHY_CLR8(0x6e, 0x01);
		/* rg_usb20_gpio_ctl, 1'b0, usb20_gpio_mode, 1'b0 */
		USBPHY_CLR8(0x21, 0x03);

		/* force_suspendm, 1'b0 */
		USBPHY_CLR8(0x6a, 0x04);

		skipDisableUartMode = false;
	} else {
		if (!skipDisableUartMode)
			return;
	}
#else

	/* clean PUPD_BIST_EN */
	/* PUPD_BIST_EN = 1'b0 */
	/* PMIC will use it to detect charger type */
	USBPHY_CLR8(0x1d, 0x10);

	/* force_uart_en, 1'b0 */
	USBPHY_CLR8(0x6b, 0x04);
	/* RG_UART_EN, 1'b0 */
	USBPHY_CLR8(0x6e, 0x01);
	/* rg_usb20_gpio_ctl, 1'b0, usb20_gpio_mode, 1'b0 */
	USBPHY_CLR8(0x21, 0x03);

	/* force_suspendm, 1'b0 */
	USBPHY_CLR8(0x6a, 0x04);
#endif

	/* RG_DPPULLDOWN, 1'b0, RG_DMPULLDOWN, 1'b0 */
	USBPHY_CLR8(0x68, 0xc0);
	/* RG_XCVRSEL[1:0], 2'b00. */
	USBPHY_CLR8(0x68, 0x30);
	/* RG_TERMSEL, 1'b0 */
	USBPHY_CLR8(0x68, 0x04);
	/* RG_DATAIN[3:0], 4'b0000 */
	USBPHY_CLR8(0x69, 0x3c);

	/* force_dp_pulldown, 1'b0, force_dm_pulldown, 1'b0,
	   force_xcversel, 1'b0, force_termsel, 1'b0, force_datain, 1'b0 */
	USBPHY_CLR8(0x6a, 0xba);

	/* RG_USB20_BC11_SW_EN, 1'b0 */
	USBPHY_CLR8(0x1a, 0x80);
	/* RG_USB20_OTG_VBUSCMP_EN, 1'b1 */
	USBPHY_SET8(0x1a, 0x10);


	/* wait 800 usec. */
	udelay(800);

	/* force enter device mode, from K2, FIXME */
	USBPHY_CLR8(0x6c, 0x10);
	USBPHY_SET8(0x6c, 0x2F);
	USBPHY_SET8(0x6d, 0x3F);

	/* from K2, FIXME */
#if defined(MTK_HDMI_SUPPORT)
	USBPHY_SET8(0x05, 0x05);
	USBPHY_SET8(0x05, 0x50);
#endif

	/* adjustment after HQA */
	HQA_special();

	hs_slew_rate_cal();

	DBG(0, "usb recovery success\n");
}
Example #5
0
void usb_phy_recover(void){

    //4 1. turn on USB reference clock.
    usb_enable_clock(true);
    //4 2. wait 50 usec.
    udelay(50);

	#ifdef MTK_UART_USB_SWITCH
	if (!usb_phy_check_in_uart_mode()) {
    // clean PUPD_BIST_EN
    // PUPD_BIST_EN = 1'b0
    // PMIC will use it to detect charger type
    USBPHY_CLR8(0x1d, 0x10);

    //4 3. force_uart_en = 1'b0
    USBPHY_CLR8(0x6b, 0x04);
    //4 4. RG_UART_EN = 1'b0
    USBPHY_CLR8(0x6e, 0x1);
	//4 5. release force suspendm.
    USBPHY_CLR8(0x6a, 0x04);
    USBPHY_CLR8(0x22, 0x02);

	skipDisableUartMode = false;
	} else {
		//if (!skipDisableUartMode)
			return;
	}
	#else
    // clean PUPD_BIST_EN
    // PUPD_BIST_EN = 1'b0
    // PMIC will use it to detect charger type
    USBPHY_CLR8(0x1d, 0x10);

    //4 3. force_uart_en = 1'b0
    USBPHY_CLR8(0x6b, 0x04);
    //4 4. RG_UART_EN = 1'b0
    USBPHY_CLR8(0x6e, 0x1);
    //4 5. force_uart_en = 1'b0
    USBPHY_CLR8(0x6a, 0x04);

    USBPHY_CLR8(0x21, 0x03);
	#endif

    //4 6. RG_DPPULLDOWN = 1'b0
    USBPHY_CLR8(0x68, 0x40);
    //4 7. RG_DMPULLDOWN = 1'b0
    USBPHY_CLR8(0x68, 0x80);
    //4 8. RG_XCVRSEL = 2'b00
    USBPHY_CLR8(0x68, 0x30);
    //4 9. RG_TERMSEL = 1'b0
    USBPHY_CLR8(0x68, 0x04);
    //4 10. RG_DATAIN[3:0] = 4'b0000
    USBPHY_CLR8(0x69, 0x3c);

   //4 11. force_dp_pulldown = 1b'0
    USBPHY_CLR8(0x6a, 0x10);
    //4 12. force_dm_pulldown = 1b'0
    USBPHY_CLR8(0x6a, 0x20);
    //4 13. force_xcversel = 1b'0
    USBPHY_CLR8(0x6a, 0x08);
    //4 14. force_termsel = 1b'0
    USBPHY_CLR8(0x6a, 0x02);
    //4 15. force_datain = 1b'0
    USBPHY_CLR8(0x6a, 0x80);

    //4 16. RG_USB20_BC11_SW_EN 1'b0
    USBPHY_CLR8(0x1a, 0x80);
    //4 17. RG_USB20_OTG_VBUSSCMP_EN 1'b1
    USBPHY_SET8(0x1a, 0x10);
    //18. PASS RX sensitivity HQA requirement
    USBPHY_CLR8(0x18, 0x08);
    USBPHY_SET8(0x18, 0x06);

    //4 18. wait 800 usec.
    udelay(800);

    // force enter device mode, k2 need?
    USBPHY_CLR8(0x6c, 0x10);
    USBPHY_SET8(0x6c, 0x2E);
    USBPHY_SET8(0x6d, 0x3E);

    #if defined(MTK_HDMI_SUPPORT)
    USBPHY_SET8(0x05, 0x05);
    USBPHY_SET8(0x05, 0x50);
    #endif
    hs_slew_rate_cal();

    printk("usb recovery success\n");
    return;
}