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);
}
Exemple #2
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);
}
Exemple #3
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;
}
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);
}
Exemple #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);

	/* GPIO Selection */
	DRV_WriteReg32(UART1_BASE + 0x90, 0x1);	//set
}
Exemple #6
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);
}
Exemple #7
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
}
void usb_phy_recover(void)
{
	//usb phy initial sequence
	USB_PHY_Write_Register8(0x00, 0xFF);
	USB_PHY_Write_Register8(0x04, 0x61);
	USB_PHY_Write_Register8(0x00, 0x68);
	USB_PHY_Write_Register8(0x00, 0x6a);
	USB_PHY_Write_Register8(0x6e, 0x00);
	USB_PHY_Write_Register8(0x0c, 0x1b);
	USB_PHY_Write_Register8(0x44, 0x08);
	USB_PHY_Write_Register8(0x55, 0x11);
	USB_PHY_Write_Register8(0x68, 0x1a);
	USBPHY_CLR8(0x6a, 0xff);

	printk("[MUSB]addr: 0xFF, value: %x\n", USB_PHY_Read_Register8(0xFF));
	printk("[MUSB]addr: 0x61, value: %x\n", USB_PHY_Read_Register8(0x61));
	printk("[MUSB]addr: 0x68, value: %x\n", USB_PHY_Read_Register8(0x68));
	printk("[MUSB]addr: 0x6a, value: %x\n", USB_PHY_Read_Register8(0x6a));
	printk("[MUSB]addr: 0x00, value: %x\n", USB_PHY_Read_Register8(0x00));
	printk("[MUSB]addr: 0x1b, value: %x\n", USB_PHY_Read_Register8(0x1b));
	printk("[MUSB]addr: 0x08, value: %x\n", USB_PHY_Read_Register8(0x08));
	printk("[MUSB]addr: 0x11, value: %x\n", USB_PHY_Read_Register8(0x11));
	printk("[MUSB]addr: 0x1a, value: %x\n", USB_PHY_Read_Register8(0x1a));
	printk("[MUSB]usb_phy_recover \n");
}
Exemple #9
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
}
Exemple #10
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");
}
Exemple #11
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;
}
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");
}
Exemple #13
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;
}
void Charger_Detect_Release(void)
{
	/* RG_USB20_BC11_SW_EN = 1'b0 */
	USBPHY_CLR8(0x1a, 0x80);
	udelay(1);
	/* 4 14. turn off internal 48Mhz PLL. */
	usb_enable_clock(false);
	DBG(0, "Charger_Detect_Release\n");
}
Exemple #15
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(0x1c, 0x80);

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

    udelay(800);

    return;
}
Exemple #16
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;
}
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);
}
Exemple #18
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);
}
Exemple #19
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);
}
Exemple #20
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;
}
/* 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");
}
Exemple #22
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");
}
Exemple #23
0
void usb_phy_switch_to_usb(void)
{
	usb_enable_clock(true);
	if (!usb_phy_check_in_uart_mode())
		return;
		
	cur_usb_mode = USB_MODE;
		
	/* GPIO Selection */
	DRV_WriteReg32(GPIO_BASE + 0x508, 0x20);	//clear
	mdelay(200);
	
	/*cler force_uart_xxx*/  
	USBPHY_WRITE8(0x6B, 0x00);
	
	/* EN_PU_DM = 0*/
	USBPHY_CLR8(0x1d, 0x18);
	usb_enable_clock(false);
	
	udelay(1000);
	usb_phy_poweron();
}
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");
}
Exemple #25
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;
}
Exemple #26
0
void mt6573_usb_phy_savecurrent(struct mt_udc *udc){

    if(!udc || (udc->power == USB_FALSE))
        return;

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

    udelay(100);

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

    USBPHY_SET8(0x6a, 0x04); 

    udelay(1);

    mt6573_usb_enable_clock(FALSE);

    udc->power = USB_FALSE;
    
    return;
}
Exemple #27
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");
}
Exemple #28
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;
}
Exemple #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));
	}
Exemple #30
0
void mt_usb_phy_poweron (void)
{

	#define PHY_DRIVING   0x3

	UINT8 usbreg8;
	unsigned int i;

	/* force_suspendm = 0 */
	USBPHY_CLR8(0x6a, 0x04);

	USBPHY_I2C_WRITE8(0xff, 0x00);
	USBPHY_I2C_WRITE8(0x61, 0x04);
	USBPHY_I2C_WRITE8(0x68, 0x00);
	USBPHY_I2C_WRITE8(0x6a, 0x00);
	USBPHY_I2C_WRITE8(0x00, 0x6e);
	USBPHY_I2C_WRITE8(0x1b, 0x0c);
	USBPHY_I2C_WRITE8(0x08, 0x44);
	USBPHY_I2C_WRITE8(0x11, 0x55);
	USBPHY_I2C_WRITE8(0x1a, 0x68);

	#if defined(USB_PHY_DRIVING_TUNING)
	/* driving tuning */
	USBPHY_I2C_READ8(0xab, &usbreg8);
	usbreg8 &= ~0x3;
	usbreg8 |= PHY_DRIVING;
	USBPHY_I2C_WRITE8(0xab, usbreg8);

	for(i = 0; i < 16; i++)
	{
		USBPHY_I2C_READ8((0x92+i), &usbreg8);
		usbreg8 &= ~0x3;
		usbreg8 |= PHY_DRIVING;
		USBPHY_I2C_WRITE8((0x92+i), usbreg8);
	}

	USBPHY_I2C_READ8(0xbc, &usbreg8);
	usbreg8 &= ~0x3;
	usbreg8 |= PHY_DRIVING;
	USBPHY_I2C_WRITE8(0xbc, usbreg8);

	USBPHY_I2C_READ8(0xbe, &usbreg8);
	usbreg8 &= ~0x3;
	usbreg8 |= PHY_DRIVING;
	USBPHY_I2C_WRITE8(0xbe, usbreg8);

	USBPHY_I2C_READ8(0xbf, &usbreg8);
	usbreg8 &= ~0x3;
	usbreg8 |= PHY_DRIVING;
	USBPHY_I2C_WRITE8(0xbf, usbreg8);

	USBPHY_I2C_READ8(0xcd, &usbreg8);
	usbreg8 &= ~0x3;
	usbreg8 |= PHY_DRIVING;
	USBPHY_I2C_WRITE8(0xcd, usbreg8);

	USBPHY_I2C_READ8(0xf1, &usbreg8);
	usbreg8 &= ~0x3;
	usbreg8 |= PHY_DRIVING;
	USBPHY_I2C_WRITE8(0xf1, usbreg8);

	USBPHY_I2C_READ8(0xa7, &usbreg8);
	usbreg8 &= ~0x3;
	usbreg8 |= PHY_DRIVING;
	USBPHY_I2C_WRITE8(0xa7, usbreg8);

	USBPHY_I2C_READ8(0xa8, &usbreg8);
	usbreg8 &= ~0x3;
	usbreg8 |= PHY_DRIVING;
	USBPHY_I2C_WRITE8(0xa8, usbreg8);
	#endif

	udelay(800);
}