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); /* GPIO Selection */ DRV_WriteReg32(UART1_BASE + 0x90, 0x1); //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); /*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_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_usb(void) { usb_enable_clock(true); udelay(50); /* clear force_uart_en */ USBPHY_WRITE8(0x6B, 0x00); usb_enable_clock(false); usb_phy_poweron(); /* disable the USB clock turned on in usb_phy_poweron() */ usb_enable_clock(false); }
void usb_phy_switch_to_usb(void) { /* GPIO Selection */ DRV_WriteReg32(UART1_BASE + 0x90, 0x0); //set usb_enable_clock(true); udelay(50); /* clear force_uart_en */ USBPHY_WRITE8(0x6B, 0x00); usb_enable_clock(false); usb_phy_poweron(); /* disable the USB clock turned on in usb_phy_poweron() */ usb_enable_clock(false); }
bool usb_phy_check_in_uart_mode(void) { UINT8 usb_port_mode; usb_enable_clock(true); udelay(50); usb_port_mode = USB_PHY_Read_Register8(0x6B); usb_enable_clock(false); if ((usb_port_mode == 0x5C) || (usb_port_mode == 0x5E)) return true; else return false; }
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 usb_phy_savecurrent(void){ usb_phy_savecurrent_internal(); //4 14. turn off internal 48Mhz PLL. usb_enable_clock(false); printk("usb save current success\n"); }
void usb_phy_savecurrent(void) { /* to avoid hw access during clock-off */ unsigned long flags; int do_lock; do_lock = 0; usb_phy_savecurrent_internal(); /* to avoid deadlock, musb_shutdown will hold this clock too */ if (mtk_musb && !musb_is_shutting) { spin_lock_irqsave(&mtk_musb->lock, flags); do_lock = 1; } /* 4 14. turn off internal 48Mhz PLL. */ usb_enable_clock(false); if (do_lock) spin_unlock_irqrestore(&mtk_musb->lock, flags); DBG(0, "usb save current success\n"); }
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"); }
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; }
void usb_phy_switch_to_usb(void) { /* GPIO Selection */ DRV_WriteReg32(ap_uart0_base + 0xB0, 0x0); usb_enable_clock(true); udelay(50); /* clear force_uart_en */ USBPHY_WRITE8(0x6B, 0x00); usb_enable_clock(false); usb_phy_poweron(); /* disable the USB clock turned on in usb_phy_poweron() */ usb_enable_clock(false); DBG(0, "Unmask PMIC charger detection in USB mode.\n"); pmic_chrdet_int_en(1); }
void usb_phy_switch_to_usb(void) { /* GPIO Selection */ //DRV_WriteReg32(GPIO_BASE + 0x508, 0x10); //set mtk_uart_usb_rx_sel(1, 0); usb_enable_clock(true); udelay(50); /* clear force_uart_en */ USBPHY_WRITE8(0x6B, 0x00); usb_enable_clock(false); usb_phy_poweron(); /* disable the USB clock turned on in usb_phy_poweron() */ usb_enable_clock(false); usb_port_mode_temp = 0; printk("usb port value in usb function:%d\n", usb_port_mode_temp); }
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 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"); }
void usb_phy_switch_to_usb(void) { /* Disable UART */ DRV_WriteReg32(GPIO_BASE_1 + 0x11C, 0x02); //clear /* set uart rx path for K2 use */ //mtk_uart_usb_rx_sel(1, 0); usb_enable_clock(true); udelay(50); /* clear force_uart_en */ USBPHY_WRITE8(0x6B, 0x00); usb_enable_clock(false); usb_phy_poweron(); /* disable the USB clock turned on in usb_phy_poweron() */ usb_enable_clock(false); usb_port_mode_temp = 0; printk("usb port value in usb function:%d\n", usb_port_mode_temp); }
bool usb_phy_check_in_uart_mode() { UINT8 usb_port_mode; usb_enable_clock(true); udelay(50); usb_port_mode = USBPHY_READ8(0x6B); //usb_port_mode = 1; usb_enable_clock(false); if ((usb_port_mode == 0x5C) || (usb_port_mode == 0x5E) || (usb_port_mode_temp == 1)) { usb_port_mode_temp = 1; return true; } else return false; }
/* 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"); }
// 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"); }
bool usb_phy_check_in_uart_mode(void) { UINT8 usb_port_mode; usb_enable_clock(true); udelay(50); usb_port_mode = USBPHY_READ8(0x6B); usb_enable_clock(false); if ((usb_port_mode == 0x5C) || (usb_port_mode == 0x5E)) { DBG(0, "%s:%d - IN UART MODE : 0x%x\n", __func__, __LINE__, usb_port_mode); DBG(0, "Mask PMIC charger detection in UART mode.\n"); pmic_chrdet_int_en(0); in_uart_mode = true; } else { DBG(0, "%s:%d - NOT IN UART MODE : 0x%x\n", __func__, __LINE__, usb_port_mode); in_uart_mode = false; } return in_uart_mode; }
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(); }
/* 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_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"); }
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; }
static int mt_usb2jtag_hw_init(void) { struct device_node *node = NULL; int ret; node = of_find_compatible_node(NULL, NULL, "mediatek,usb2jtag_v1"); if (!node) { pr_err("[USB2JTAG] map node @ mediatek,usb2jtag_v1 failed\n"); return -1; } INFRA_AO_BASE = of_iomap(node, 0); if (!INFRA_AO_BASE) { pr_err("[USB2JTAG] iomap INFRA_AO_BASE failed\n"); return -1; } USB_SIF_BASE = of_iomap(node, 1); if (!USB_SIF_BASE) { pr_err("[USB2JTAG] iomap USB_SIF_BASE failed\n"); return -1; } /* set ap_usb2jtag_en: 0x1000_0700 bit[13] = 1 */ //enable clock usb_enable_clock(1); /* delay for enabling usb clock */ udelay(50); writel(readl(USB_SIF_BASE + 0x0800) | 0x21, USB_SIF_BASE + 0x0800); writel((readl(USB_SIF_BASE + 0x0818) & ~(0xff << 16)) | (0x7f << 16) , USB_SIF_BASE + 0x0818); writel(readl(USB_SIF_BASE + 0x0820) | (0x1 << 9), USB_SIF_BASE + 0x0820); writel(readl(INFRA_AO_BASE + 0xF00) | (0x1 << 14), INFRA_AO_BASE + 0xF00); pr_err("[USB2JTAG] 0x11210800 = 0x%x\n", readl(USB_SIF_BASE + 0x0800)); pr_err("[USB2JTAG] 0x11210808 = 0x%x\n", readl(USB_SIF_BASE + 0x0808)); pr_err("[USB2JTAG] 0x11210820 = 0x%x\n", readl(USB_SIF_BASE + 0x0820)); pr_err("[USB2JTAG] 0x10001F00 = 0x%x\n", readl(INFRA_AO_BASE + 0xF00)); pr_err("[USB2JTAG] setting done\n"); return 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"); }
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; }