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 }
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 }
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); }
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); }
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_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; }
/* 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"); }
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"); }
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){ #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"); }
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; }
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)); }
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; }
void usb_phy_context_save(void) { #ifdef CONFIG_MTK_UART_USB_SWITCH in_uart_mode = usb_phy_check_in_uart_mode(); #endif }
/* 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"); }
/* Denali_USB_PWR Sequence 20141030.xls */ static void usb_phy_savecurrent_internal(void) { /* 4 1. swtich to USB function. (system register, force ip into usb mode. */ #ifdef CONFIG_MTK_UART_USB_SWITCH if (!usb_phy_check_in_uart_mode()) { /* 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_OTG_VBUSCMP_EN, 1'b0 */ USBPHY_CLR8(0x1a, 0x10); /* RG_SUSPENDM, 1'b1 */ USBPHY_SET8(0x68, 0x08); /* force_suspendm, 1'b1 */ USBPHY_SET8(0x6a, 0x04); usb_enable_clock(false); } else { if (skipDisableUartMode) skipDisableUartMode = false; else return; } #else /* 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_OTG_VBUSCMP_EN, 1'b0 */ USBPHY_CLR8(0x1a, 0x10); /* RG_SUSPENDM, 1'b1 */ USBPHY_SET8(0x68, 0x08); /* force_suspendm, 1'b1 */ USBPHY_SET8(0x6a, 0x04); #endif /* RG_DPPULLDOWN, 1'b1, RG_DMPULLDOWN, 1'b1 */ USBPHY_SET8(0x68, 0xc0); /* RG_XCVRSEL[1:0], 2'b01. */ USBPHY_CLR8(0x68, 0x20); 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, 1'b1, force_dm_pulldown, 1'b1, force_xcversel, 1'b1, force_termsel, 1'b1, force_datain, 1'b1 */ USBPHY_SET8(0x6a, 0xba); udelay(800); /* RG_SUSPENDM, 1'b0 */ USBPHY_CLR8(0x68, 0x08); /* ALPS00427972, implement the analog register formula */ /* DBG(0, "%s: USBPHY_READ8(0x05) = 0x%x\n", __func__, USBPHY_READ8(0x05)); DBG(0, "%s: USBPHY_READ8(0x07) = 0x%x\n", __func__, USBPHY_READ8(0x07)); */ /* ALPS00427972, implement the analog register formula */ udelay(1); /* force enter device mode, from K2, FIXME */ /* force enter device mode */ /* USBPHY_CLR8(0x6c, 0x10); */ /* USBPHY_SET8(0x6c, 0x2E); */ /* USBPHY_SET8(0x6d, 0x3E); */ #ifdef CONFIG_MTK_UART_USB_SWITCH if (in_uart_mode) { USBPHY_SET8(0x68, 0x08); DBG(0, "%s:%d - SWITCH to UART MODE after savecurrent!\n", __func__, __LINE__); } #endif }
static void usb_phy_savecurrent_internal(void){ //4 1. swtich to USB function. (system register, force ip into usb mode. #ifdef MTK_UART_USB_SWITCH if (!usb_phy_check_in_uart_mode()) { //4 s1: enable USB MAC clock. usb_enable_clock(true); //4 s2: wait 50 usec for PHY3.3v/1.8v stable. udelay(50); USBPHY_CLR8(0x6b, 0x04); USBPHY_CLR8(0x6e, 0x01); //4 2. release force suspendm. USBPHY_CLR8(0x6a, 0x04); usb_enable_clock(false); } else { if (skipDisableUartMode) skipDisableUartMode = false; else return; } #else USBPHY_CLR8(0x6b, 0x04); USBPHY_CLR8(0x6e, 0x01); //4 2. release force suspendm. USBPHY_CLR8(0x6a, 0x04); #endif //4 3. RG_DPPULLDOWN./RG_DMPULLDOWN. USBPHY_SET8(0x68, 0xc0); //4 4. RG_XCVRSEL[1:0] =2'b01. USBPHY_CLR8(0x68, 0x30); USBPHY_SET8(0x68, 0x10); //4 5. RG_TERMSEL = 1'b1 USBPHY_SET8(0x68, 0x04); //4 6. RG_DATAIN[3:0]=4'b0000 USBPHY_CLR8(0x69, 0x3c); //4 7.force_dp_pulldown, force_dm_pulldown, force_xcversel,force_termsel. USBPHY_SET8(0x6a, 0xba); //4 8.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)); //4 9.RG_USB20_OTG_VBUSSCMP_EN 1'b0 USBPHY_CLR8(0x1a, 0x10); //4 10. delay 800us. udelay(800); //4 11. rg_usb20_pll_stable = 1 USBPHY_SET8(0x63, 0x02); //ALPS00427972, implement the analog register formula printk("%s: USBPHY_READ8(0x05) = 0x%x \n", __func__, USBPHY_READ8(0x05)); printk("%s: USBPHY_READ8(0x07) = 0x%x \n", __func__, USBPHY_READ8(0x07)); //ALPS00427972, implement the analog register formula udelay(1); //4 12. force suspendm = 1. USBPHY_SET8(0x6a, 0x04); //4 13. wait 1us udelay(1); // force enter device mode USBPHY_CLR8(0x6c, 0x10); USBPHY_SET8(0x6c, 0x2E); USBPHY_SET8(0x6d, 0x3E); }
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); 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); #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); //RG_USB20_INTR_CAL[4:0] 5'b01101 Internal R selection if (get_devinfo_with_index(19) & (0xF80)) { //printk("USB HW reg: read RG_USB20_INTR_CAL 0x%x\n", USBPHY_READ8(0x06)); USBPHY_WRITE8(0x06,((USBPHY_READ8(0x06)&0x7)|((get_devinfo_with_index(19)&0xF80)>>4))); printk("USB HW reg: write RG_USB20_INTR_CAL 0x%x\n", USBPHY_READ8(0x06)); }