예제 #1
0
void mt_usb_phy_poweron (void)
{
	/*
	 * swtich to USB function.
	 * (system register, force ip into usb mode).
	 */
	USBPHY_CLR8(0x6b, 0x04);
	USBPHY_CLR8(0x6e, 0x01);

	/* RG_USB20_BC11_SW_EN = 1'b0 */
	USBPHY_CLR8(0x1a, 0x80);

	/* RG_USB20_DP_100K_EN = 1'b0 */
	/* RG_USB20_DM_100K_EN = 1'b0 */
	USBPHY_CLR8(0x22, 0x03);

	/* release force suspendm */
	USBPHY_CLR8(0x6a, 0x04);

	udelay(800);

    /* force enter device mode */
	USBPHY_CLR8(0x6c, 0x10);
	USBPHY_SET8(0x6c, 0x2E);
	USBPHY_SET8(0x6d, 0x3E);
}
예제 #2
0
void usb_phy_switch_to_uart(void)
{

	if (usb_phy_check_in_uart_mode()) {
		return;
	}
	//ALPS00775710
	printk("%s, line %d: force to uart mode!!\n", __func__, __LINE__);
	//ALPS00775710

    usb_enable_clock(true);
	udelay(50);

	/* RG_USB20_BC11_SW_EN = 1'b0 */
	USBPHY_CLR8(0x1a, 0x80);

	/* Set RG_SUSPENDM to 1 */
	USBPHY_SET8(0x68, 0x08);

	/* force suspendm = 1 */
	USBPHY_SET8(0x6a, 0x04);

	/* Set ru_uart_mode to 2'b01 */
	USBPHY_SET8(0x6B, 0x5C);

	/* Set RG_UART_EN to 1 */
	USBPHY_SET8(0x6E, 0x07);

	/* Set RG_USB20_DM_100K_EN to 1 */
	USBPHY_SET8(0x22, 0x02);
    usb_enable_clock(false);
}
예제 #3
0
void usb_phy_switch_to_uart(void)
{
	if (usb_phy_check_in_uart_mode()) {
		return;
	}
    usb_enable_clock(true);
	udelay(50);

	/* RG_USB20_BC11_SW_EN = 1'b0 */
	USBPHY_CLR8(0x1a, 0x80);

	/* Set RG_SUSPENDM to 1 */
	USBPHY_SET8(0x68, 0x08);

	/* force suspendm = 1 */
	USBPHY_SET8(0x6a, 0x04);

	/* Set ru_uart_mode to 2'b01 */
	USBPHY_SET8(0x6B, 0x5C);

	/* Set RG_UART_EN to 1 */
	USBPHY_SET8(0x6E, 0x07);

	/* Set RG_USB20_DM_100K_EN to 1 */
	USBPHY_SET8(0x22, 0x02);
    usb_enable_clock(false);

	/* GPIO Selection */
	DRV_WriteReg32(UART1_BASE + 0x90, 0x1);	//set
}
예제 #4
0
void usb_phy_switch_to_uart(void)
{
	if (usb_phy_check_in_uart_mode())
		return;
	DBG(0, "Mask PMIC charger detection in UART mode.\n");
	pmic_chrdet_int_en(0);

	usb_enable_clock(true);
	udelay(50);

	/* RG_USB20_BC11_SW_EN = 1'b0 */
	USBPHY_CLR8(0x1a, 0x80);

	/* Set RG_SUSPENDM to 1 */
	USBPHY_SET8(0x68, 0x08);

	/* force suspendm = 1 */
	USBPHY_SET8(0x6a, 0x04);

	/* Set ru_uart_mode to 2'b01 */
	USBPHY_SET8(0x6B, 0x5C);

	/* Set RG_UART_EN to 1 */
	USBPHY_SET8(0x6E, 0x07);

	/* Set RG_USB20_DM_100K_EN to 1 */
	USBPHY_SET8(0x22, 0x02);
	usb_enable_clock(false);

	/* GPIO Selection */
	DRV_WriteReg32(ap_uart0_base + 0xB0, 0x1);
}
예제 #5
0
void usb_phy_switch_to_uart(void)
{
	if (usb_phy_check_in_uart_mode()) {
		return;
	}
    usb_enable_clock(true);
	udelay(50);

	/* RG_USB20_BC11_SW_EN = 1'b0 */
	USBPHY_CLR8(0x1a, 0x80);

	/* Set RG_SUSPENDM to 1 */
	USBPHY_SET8(0x68, 0x08);

	/* force suspendm = 1 */
	USBPHY_SET8(0x6a, 0x04);

	/* Set ru_uart_mode to 2'b01 */
	USBPHY_SET8(0x6B, 0x5C);

	/* Set RG_UART_EN to 1 */
	USBPHY_SET8(0x6E, 0x07);

	/* Set RG_USB20_DM_100K_EN to 1 */
	USBPHY_SET8(0x22, 0x02);
    usb_enable_clock(false);

  /*set uart rx path*/  
  mtk_uart_usb_rx_sel(1, 1);
  usb_port_mode_temp = 1;
  printk("usb port value in uart function:%d\n", usb_port_mode_temp);
	/* GPIO Selection */
	//DRV_WriteReg32(GPIO_BASE + 0x504, 0x10);	//set
}
예제 #6
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;
}
예제 #7
0
static void hs_slew_rate_cal(void)
{
	unsigned long data;
	unsigned long x;
	unsigned char value;
	unsigned long start_time, timeout;
	unsigned int timeout_flag = 0;
	/* 4 s1:enable usb ring oscillator. */
	USBPHY_SET8(0x15, 0x80);

	/* 4 s2:wait 1us. */
	udelay(1);

	/* 4 s3:enable free run clock */
	USBPHY_SET8(0xf00 - 0x800 + 0x11, 0x01);
	/* 4 s4:setting cyclecnt. */
	USBPHY_SET8(0xf00 - 0x800 + 0x01, 0x04);
	/* 4 s5:enable frequency meter */
	USBPHY_SET8(0xf00 - 0x800 + 0x03, 0x01);

	/* 4 s6:wait for frequency valid. */
	start_time = jiffies;
	timeout = jiffies + 3 * HZ;

	while (!(USBPHY_READ8(0xf00 - 0x800 + 0x10) & 0x1)) {
		if (time_after(jiffies, timeout)) {
			timeout_flag = 1;
			break;
		}
	}

	/* 4 s7: read result. */
	if (timeout_flag) {
		DBG(0, "[USBPHY] Slew Rate Calibration: Timeout\n");
		value = 0x4;
	} else {
		data = USBPHY_READ32(0xf00 - 0x800 + 0x0c);
		x = ((1024 * FRA * PARA) / data);
		value = (unsigned char)(x / 1000);
		if ((x - value * 1000) / 100 >= 5)
			value += 1;
		DBG(0, "[USBPHY]slew calibration:FM_OUT =%lu,x=%lu,value=%d\n", data, x, value);
	}

	/* 4 s8: disable Frequency and run clock. */
	USBPHY_CLR8(0xf00 - 0x800 + 0x03, 0x01);
	USBPHY_CLR8(0xf00 - 0x800 + 0x11, 0x01);

	/* 4 s9: */
#define MSK_RG_USB20_HSTX_SRCTRL 0x7
	/* all clr first then set */
	USBPHY_CLR8(0x15, MSK_RG_USB20_HSTX_SRCTRL << 4);
	USBPHY_SET8(0x15, (value & MSK_RG_USB20_HSTX_SRCTRL) << 4);

	/* 4 s10:disable usb ring oscillator. */
	USBPHY_CLR8(0x15, 0x80);
}
예제 #8
0
void mt_usb_phy_recover (void)
{
	/* 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);
	/* force_uart_en = 1'b0 */
	USBPHY_CLR8(0x6a, 0x04);

	USBPHY_CLR8(0x68, 0xf4);

	/* RG_DATAIN[3:0] = 4'b0000 */
	USBPHY_CLR8(0x69, 0x3c);

	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);

	print("USB HW reg: index14=0x%x\n", seclib_get_devinfo_with_index(14));
	if (seclib_get_devinfo_with_index(14) & (0x01<<22))
	{
		print("USB HW reg: read RG_USB20_INTR_EN 0x%x\n", USBPHY_READ8(0x00));
		USBPHY_CLR8(0x00, 0x20);
		print("USB HW reg: write RG_USB20_INTR_EN 0x%x\n", USBPHY_READ8(0x00));
	}
	
	if (seclib_get_devinfo_with_index(14) & (0x07<<19))
	{
		//RG_USB20_VRT_VREF_SEL[2:0]=5 (ori:4) (0x11110804[14:12])
		print("USB HW reg: read RG_USB20_VRT_VREF_SEL 0x%x\n", USBPHY_READ8(0x05));
		USBPHY_CLR8(0x05, 0x70);
  		USBPHY_SET8(0x05, ((seclib_get_devinfo_with_index(7)>>19)<<4)&0x70);
  		print("USB HW reg: overwrite RG_USB20_VRT_VREF_SEL 0x%x\n", USBPHY_READ8(0x05));
	}
예제 #9
0
void mt_usb_phy_recover (void)
{
    /* 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);
    /* force_uart_en = 1'b0 */
    USBPHY_CLR8(0x6a, 0x04);

    USBPHY_CLR8(0x68, 0xf4);

    /* RG_DATAIN[3:0] = 4'b0000 */
    USBPHY_CLR8(0x69, 0x3c);

    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);

    return;
}
예제 #10
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;
}
예제 #11
0
void musb_session_restart(struct musb *musb)
{
	void __iomem	*mbase = musb->mregs;
	musb_writeb(mbase, MUSB_DEVCTL, (musb_readb(mbase, MUSB_DEVCTL) & (~MUSB_DEVCTL_SESSION)));
	DBG(0,"[MUSB] stopped session for VBUSERROR interrupt\n");
	USBPHY_SET8(0x6d, 0x3c);
	USBPHY_SET8(0x6c, 0x10);
	USBPHY_CLR8(0x6c, 0x2c);
	DBG(0,"[MUSB] force PHY to idle, 0x6d=%x, 0x6c=%x\n", USBPHY_READ8(0x6d), USBPHY_READ8(0x6c));
	mdelay(5);
	USBPHY_CLR8(0x6d, 0x3c);
	USBPHY_CLR8(0x6c, 0x3c);
	DBG(0,"[MUSB] let PHY resample VBUS, 0x6d=%x, 0x6c=%x\n", USBPHY_READ8(0x6d), USBPHY_READ8(0x6c));
	musb_writeb(mbase, MUSB_DEVCTL, (musb_readb(mbase, MUSB_DEVCTL) | MUSB_DEVCTL_SESSION));
	DBG(0,"[MUSB] restart session\n");
}
예제 #12
0
void usb_phy_savecurrent(){
	if (usb_phy_check_in_uart_mode())
		return;
	
	/*
	 * swtich to USB function.
	 * (system register, force ip into usb mode).
	 */
	USBPHY_CLR8(0x6b, 0x04);
	USBPHY_CLR8(0x6e, 0x01);

	/* release force suspendm */
	USBPHY_CLR8(0x6a, 0x04);
	/* RG_DPPULLDOWN./RG_DMPULLDOWN. */
	USBPHY_SET8(0x68, 0xc0);
	/* RG_XCVRSEL[1:0] = 2'b01 */
	USBPHY_CLR8(0x68, 0x30);
	USBPHY_SET8(0x68, 0x10);
	/* RG_TERMSEL = 1'b1 */
	USBPHY_SET8(0x68, 0x04);
	/* RG_DATAIN[3:0] = 4'b0000 */
	USBPHY_CLR8(0x69, 0x3c);

	/*
	 * force_dp_pulldown, force_dm_pulldown, 
	 * force_xcversel, force_termsel.
	 */
	USBPHY_SET8(0x6a, 0xba);

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

	udelay(800);

	/* rg_usb20_pll_stable = 1 */
	USBPHY_SET8(0x63, 0x02);

	udelay(1);

	/* force suspendm = 1 */
	USBPHY_SET8(0x6a, 0x04);

	udelay(1);

// force enter device mode
	USBPHY_CLR8(0x6c, 0x10);
	USBPHY_SET8(0x6c, 0x2E);
	USBPHY_SET8(0x6d, 0x3E);
	
    //4 14. turn off internal 48Mhz PLL.
    usb_enable_clock(false);

  printk("usb save current success\n");
  return;
}
예제 #13
0
/* Denali_USB_PWR Sequence 20141030.xls */
void usb_phy_poweron(void)
{

#ifdef CONFIG_MTK_UART_USB_SWITCH
	if (usb_phy_check_in_uart_mode())
		return;
#endif

	/* enable USB MAC clock. */
	usb_enable_clock(true);

	/* wait 50 usec for PHY3.3v/1.8v stable. */
	udelay(50);

	/* 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);

	/* RG_USB20_BC11_SW_EN, 1'b0 */
	USBPHY_CLR8(0x1a, 0x80);

	/* rg_usb20_dp_100k_mode, 1'b1 */
	USBPHY_SET8(0x22, 0x04);
	/* USB20_DP_100K_EN 1'b0, RG_USB20_DM_100K_EN, 1'b0 */
	USBPHY_CLR8(0x22, 0x03);

	/* RG_USB20_OTG_VBUSCMP_EN, 1'b1 */
	USBPHY_SET8(0x1a, 0x10);

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

	/* 7 s7: wait for 800 usec. */
	udelay(800);

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

	DBG(0, "usb power on success\n");
}
예제 #14
0
void hs_slew_rate_cal(void){
  
  unsigned char valid_reg;
  unsigned long data;
  unsigned long x;
  unsigned char value;
  unsigned long start_time, timeout;
  unsigned int timeout_flag = 0;
  //4 s1:enable usb ring oscillator.
  USBPHY_WRITE8(0x15,0x80);

  //4 s2:wait 1us.
  udelay(1);

  //4 s3:enable free run clock
  USBPHY_WRITE8 (0xf00-0x800+0x11,0x01);
  //4 s4:setting cyclecnt.
  USBPHY_WRITE8 (0xf00-0x800+0x01,0x04);
  //4 s5:enable frequency meter
  USBPHY_SET8 (0xf00-0x800+0x03,0x01);

  //4 s6:wait for frequency valid.
  start_time = jiffies;
  timeout = jiffies + 3 * HZ;

  while(!(USBPHY_READ8(0xf00-0x800+0x10)&0x1)){
    if(time_after(jiffies, timeout)){
        timeout_flag = 1;
        break;
        }
    }

  //4 s7: read result.
  if(timeout_flag){
    printk("[USBPHY] Slew Rate Calibration: Timeout\n");
    value = 0x4;
    }
  else{
      data = USBPHY_READ32 (0xf00-0x800+0x0c);
      x = ((1024*FRA*PARA)/data);
      value = (unsigned char)(x/1000);
      if((x-value*1000)/100>=5)
        value += 1;
        printk("[USBPHY]slew calibration:FM_OUT =%lu,x=%lu,value=%d\n",data,x,value);
    }

  //4 s8: disable Frequency and run clock.
  USBPHY_CLR8 (0xf00-0x800+0x03,0x01);//disable frequency meter
  USBPHY_CLR8 (0xf00-0x800+0x11,0x01);//disable free run clock

  //4 s9:
  //USBPHY_WRITE8(0x15,value);
  USBPHY_WRITE8(0x15, (value<<4));

  //4 s10:disable usb ring oscillator.
  USBPHY_CLR8(0x15,0x80);
}
예제 #15
0
void usb_phy_poweron(void){

	#ifdef MTK_UART_USB_SWITCH
	if (usb_phy_check_in_uart_mode())
		return;
	#endif

    //4 s1: enable USB MAC clock.
    usb_enable_clock(true);

    //4 s2: wait 50 usec for PHY3.3v/1.8v stable.
    udelay(50);

    //4 s3: swtich to USB function. (system register, force ip into usb mode.
    USBPHY_CLR8(0x6b, 0x04);
    USBPHY_CLR8(0x6e, 0x01);
    USBPHY_CLR8(0x21, 0x03);
    //USBPHY_CLR8(0x21, 0x01);

    //4 s4: RG_USB20_BC11_SW_EN 1'b0
    USBPHY_CLR8(0x1a, 0x80);

    //5 s5: RG_USB20_DP_100K_EN 1'b0, RG_USB20_DM_100K_EN 1'b0
    USBPHY_SET8(0x22, 0x04);
    USBPHY_CLR8(0x22, 0x03);

    /*OTG enable*/
    USBPHY_SET8(0x20, 0x10);
    //6 s6: release force suspendm.
    USBPHY_CLR8(0x6a, 0x04);

    //6-1. PASS RX sensitivity HQA requirement
    USBPHY_SET8(0x18, 0x06);

    //7 s7: wait for 800 usec.
    udelay(800);

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

    printk("usb power on success\n");
}
예제 #16
0
// BC1.2
void Charger_Detect_Init(void)
{
    //turn on USB reference clock.
    usb_enable_clock(true);
    //wait 50 usec.
    udelay(50);
    /* RG_USB20_BC11_SW_EN = 1'b1 */
    USBPHY_SET8(0x1a, 0x80);
    printk("Charger_Detect_Init\n");
}
예제 #17
0
/* BC1.2 */
void Charger_Detect_Init(void)
{
	/* turn on USB reference clock. */
	usb_enable_clock(true);
	/* wait 50 usec. */
	udelay(50);
	/* RG_USB20_BC11_SW_EN = 1'b1 */
	USBPHY_SET8(0x1a, 0x80);
	DBG(0, "Charger_Detect_Init\n");
}
예제 #18
0
void hs_slew_rate_cal(void){

    unsigned long start_time, timeout;
    unsigned long data = 0, cal;
    unsigned int timeout_flag = 0;

    USBPHY_SET8(0x1d, 0x40);
    USBPHY_SET8(0x66, 0x20);
    USBPHY_WRITE32(0x700, (1<<28) | (1<<24) | TIME_WINDOW);
    
    start_time = jiffies;
    timeout = jiffies + 3 * HZ;
    
    while(!(USBPHY_READ32(0x710)&0x1))
    {
        if(time_after(jiffies, timeout))
        {
            timeout_flag = 1;
            break;
        }
    }

    if(timeout_flag)
    {
        printk("[USB] Slew Rate Calibration: Timeout\n");
        cal = 0x4;
    }
    else
    {
        printk("[USB] Slew Rate Calibration: Complete\n");
        data = USBPHY_READ32(0x70c);
        cal = ((((2 * A * 48 * TIME_WINDOW) / FRA) / data) + 1) / 2;
    }

    printk("[USB] cal = %lu\n", cal);
    USBPHY_CLR8(0x15, 0x07);
    USBPHY_SET8(0x15, (cal & 0x7));
    USBPHY_CLR8(0x703, 0x01);
    USBPHY_CLR8(0x1d, 0x40);

    return;
}
예제 #19
0
static void HQA_special(void)
{
	u8 val;

	val = USBPHY_READ8(0x18);
	DBG(0, "HQA, 0x18, before:%x\n", val);
	USBPHY_CLR8(0x18, 0x08);
	USBPHY_SET8(0x18, 0x06);
	val = USBPHY_READ8(0x18);
	DBG(0, "HQA, 0x18, after:%x\n", val);
}
예제 #20
0
void usb_phy_poweron(void){

    #ifndef CONFIG_MT6575T_FPGA
    usb_enable_clock(true);

    udelay(50);

    USBPHY_CLR8(0x6b, 0x04);
    USBPHY_CLR8(0x6e, 0x01);
	USBPHY_CLR8(0x1c, 0x80);
    USBPHY_CLR8(0x02, 0x7f);
    USBPHY_SET8(0x02, 0x09);
    USBPHY_CLR8(0x22, 0x03);
    USBPHY_CLR8(0x6a, 0x04);
    USBPHY_SET8(0x1b, 0x08);

    udelay(800);
    #endif

    printk("usb power on success\n");
}
예제 #21
0
void usb_phy_poweron(){
    

    usb_enable_clock(true);

    udelay(50);

    USBPHY_CLR8(0x6b, 0x04);  
    USBPHY_CLR8(0x6e, 0x01);
	USBPHY_CLR8(0x1c, 0x80); 
    USBPHY_CLR8(0x02, 0x7f);
    USBPHY_SET8(0x02, 0x09);
    USBPHY_CLR8(0x22, 0x03);
    USBPHY_CLR8(0x6a, 0x04);
    USBPHY_SET8(0x1b, 0x08);

    udelay(800);

    printk("usb power on success\n");
    return;
}
예제 #22
0
void usb_phy_switch_to_uart(void)
{
	usb_enable_clock(true);
	if (usb_phy_check_in_uart_mode())
		return;
	
	cur_usb_mode = UART_MODE;
	
	/* RG_USB20_BC11_SW_EN = 1'b0 */
	USBPHY_CLR8(0x1a, 0x80);
	
	/* Set ru_uart_mode to 2'b01 */
	USBPHY_SET8(0x6B, 0x5C);

	/* Set RG_UART_EN to 1 */
	USBPHY_SET8(0x6E, 0x07);

	/* Set RG_USB20_DM_100K_EN to 1 */
	USBPHY_SET8(0x22, 0x02);
	
	/* Set RG_SUSPENDM to 1 */
	USBPHY_SET8(0x68, 0x08);
	
	/* force suspendm = 1 */
	USBPHY_SET8(0x6a, 0x04);
	
	/* EN_PU_DM = 1*/
	USBPHY_SET8(0x1d, 0x18);
	usb_enable_clock(false);
	
	/* GPIO Selection */
	mdelay(100);
	DRV_WriteReg32(GPIO_BASE + 0x504, 0x20);	//set
}
예제 #23
0
void usb_phy_savecurrent(){
    #ifndef CONFIG_MT6575T_FPGA
    USBPHY_CLR8(0x6b, 0x04);
    USBPHY_CLR8(0x6e, 0x01);

    USBPHY_CLR8(0x6a, 0x04);

    USBPHY_SET8(0x68, 0xc0);
    USBPHY_CLR8(0x68, 0x30);

    USBPHY_SET8(0x68, 0x10);

	USBPHY_SET8(0x68, 0x04);
	USBPHY_CLR8(0x69, 0x3c);

    USBPHY_SET8(0x6a, 0x3a);

	USBPHY_CLR8(0x1c, 0x80);
	USBPHY_CLR8(0x1b, 0x08);

    udelay(800);

    USBPHY_SET8(0x63, 0x02);

    udelay(1);

    USBPHY_SET8(0x6a, 0x04);

    udelay(1);

    usb_enable_clock(false);
    #endif

    printk("usb save current success\n");
}
예제 #24
0
void usb_phy_savecurrent(){

    USBPHY_CLR8(0x6b, 0x04);  
    USBPHY_CLR8(0x6e, 0x01); 
	
    USBPHY_CLR8(0x6a, 0x04); 

    USBPHY_SET8(0x68, 0xc0);
    USBPHY_CLR8(0x68, 0x30);
	
    USBPHY_SET8(0x68, 0x10);
	
	USBPHY_SET8(0x68, 0x04);
	USBPHY_CLR8(0x69, 0x3c);
	
    USBPHY_SET8(0x6a, 0x3a);   

	USBPHY_CLR8(0x1c, 0x80);
	USBPHY_CLR8(0x1b, 0x08);

    udelay(800);

    USBPHY_SET8(0x63, 0x02); 
    
    udelay(1);

    USBPHY_SET8(0x6a, 0x04); 

    udelay(1);

    usb_enable_clock(false);

    printk("usb save current success\n");
    return;
}
예제 #25
0
void usb_phy_poweron(void){

	#ifdef MTK_UART_USB_SWITCH
	if (usb_phy_check_in_uart_mode())
		return;
	#endif

    //4 s1: enable USB MAC clock.
    usb_enable_clock(true);

    //4 s2: wait 50 usec for PHY3.3v/1.8v stable.
    udelay(50);

    //4 s3: swtich to USB function. (system register, force ip into usb mode.
    USBPHY_CLR8(0x6b, 0x04);
    USBPHY_CLR8(0x6e, 0x01);

    //4 s4: RG_USB20_BC11_SW_EN 1'b0
    USBPHY_CLR8(0x1a, 0x80);

	//RG_USB20_INTR_CAL[4:0]	5'b01101	Internal R selection
	USBPHY_WRITE8(0x06,((USBPHY_READ8(0x06)&0x7)|0x68));
    //5 s5: RG_USB20_DP_100K_EN 1'b0, RG_USB20_DM_100K_EN 1'b0
    USBPHY_CLR8(0x22, 0x03);

    //6 s6: release force suspendm.
    USBPHY_CLR8(0x6a, 0x04);

    //7 s7: wait for 800 usec.
    udelay(800);

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

    printk("usb power on success\n");
}
예제 #26
0
void usb_phy_poweron()
{	
  //turn on USB reference clock. 
  usb_enable_clock(true);
  
  if (usb_phy_check_in_uart_mode())
		return;

  //wait 50 usec.
  udelay(50);    
  
	/*
	 * swtich to USB function.
	 * (system register, force ip into usb mode).
	 */
	USBPHY_CLR8(0x6b, 0x04);
	USBPHY_CLR8(0x6e, 0x01);

	/* RG_USB20_BC11_SW_EN = 1'b0 */
	USBPHY_CLR8(0x1a, 0x80);

  /*DP, DM 100K disable*/
	USBPHY_CLR8(0x22, 0x03);

	/* release force suspendm */
	USBPHY_CLR8(0x6a, 0x04);

	udelay(800);
	
// force enter device mode
	USBPHY_CLR8(0x6c, 0x10);
	USBPHY_SET8(0x6c, 0x2E);
	USBPHY_SET8(0x6d, 0x3E);
			
  printk("usb power on success\n");
  return;
}
예제 #27
0
void hs_slew_rate_cal(void){
  
  unsigned long data;
  unsigned long x;
  unsigned char value;
  unsigned long start_time, timeout;
  unsigned int timeout_flag = 0;
  //s1:
  USBPHY_WRITE8(0x12,0x81);
  //s2:
  USBPHY_WRITE8 (0xf00-0x800+0x11,0x01);
  USBPHY_WRITE8 (0xf00-0x800+0x01,0x04);
  USBPHY_SET8 (0xf00-0x800+0x03,0x01);
  //s3:
  start_time = jiffies;
  timeout = jiffies + 3 * HZ;
    
  while(!(USBPHY_READ8(0xf00-0x800+0x10)&0x1)){
    if(time_after(jiffies, timeout)){
        timeout_flag = 1;
        break;
        }
    }
  //s4:
  if(timeout_flag){
    printk("[USBPHY] Slew Rate Calibration: Timeout\n");
    value = 0x4;
    }
  else{
      data = USBPHY_READ32 (0xf00-0x800+0x0c);
      x = ((1024*FRA*PARA)/data);
      value = (unsigned char)(x/1000);
      if((x-value*1000)/100>=5)
        value += 1;
      //printk("[USBPHY]slew calibration:x=%d,value=%d\n",x,value);
    }
  //s5:
  USBPHY_CLR8 (0xf00-0x800+0x03,0x01);//disable frequency meter
  USBPHY_CLR8 (0xf00-0x800+0x11,0x01);//disable free run clock
  USBPHY_WRITE8(0x12,value);
}
예제 #28
0
void mt_usb_phy_savecurrent (void)
{
    /*
     * swtich to USB function.
     * (system register, force ip into usb mode).
     */
    USBPHY_CLR8(0x6b, 0x04);
    USBPHY_CLR8(0x6e, 0x01);

    /* release force suspendm */
    USBPHY_CLR8(0x6a, 0x04);
    /* RG_DPPULLDOWN./RG_DMPULLDOWN. */
    USBPHY_SET8(0x68, 0xc0);
    /* RG_XCVRSEL[1:0] = 2'b01 */
    USBPHY_CLR8(0x68, 0x30);
    USBPHY_SET8(0x68, 0x10);
    /* RG_TERMSEL = 1'b1 */
    USBPHY_SET8(0x68, 0x04);
    /* RG_DATAIN[3:0] = 4'b0000 */
    USBPHY_CLR8(0x69, 0x3c);

    /*
     * force_dp_pulldown, force_dm_pulldown,
     * force_xcversel, force_termsel.
     */
    USBPHY_SET8(0x6a, 0xba);

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

    udelay(800);

    /* rg_usb20_pll_stable = 1 */
    USBPHY_SET8(0x63, 0x02);

    udelay(1);

    /* force suspendm = 1 */
    USBPHY_SET8(0x6a, 0x04);

    udelay(1);

    return;
}
예제 #29
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));
	}
예제 #30
0
/* 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");
}