diff --git a/drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd.h b/drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd.h index ba54785315d1..38a153f4c8b7 100644 --- a/drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd.h +++ b/drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd.h @@ -274,6 +274,7 @@ void dwc_otg_iso_buffer_done(dwc_otg_pcd_t *pcd, dwc_otg_pcd_ep_t *ep, void *req_handle); extern void do_test_mode(void *data); +extern int aml_new_usb_get_mode(void); #ifdef CONFIG_AMLOGIC_USB3PHY extern void set_usb_phy_device_tuning(int port, int default_val); #endif diff --git a/drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd_intr.c b/drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd_intr.c index 4b9fb07478b5..3382a6a1260d 100644 --- a/drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd_intr.c +++ b/drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd_intr.c @@ -1065,18 +1065,21 @@ int32_t dwc_otg_pcd_handle_enum_done_intr(dwc_otg_pcd_t *pcd) #ifdef CONFIG_AMLOGIC_USB3PHY if (GET_CORE_IF(pcd)->phy_interface != 1) { - speed = get_device_speed(GET_CORE_IF(pcd)); - if (speed != USB_SPEED_HIGH) { - gintsts.d32 = 0; - gintsts.b.enumdone = 1; - DWC_WRITE_REG32(&GET_CORE_IF(pcd)-> - core_global_regs->gintsts, gintsts.d32); - DWC_DEBUGPL(DBG_PCD, "false speed emun\n"); - return 1; + if (GET_CORE_IF(pcd)->controller_type == USB_OTG) { + speed = get_device_speed(GET_CORE_IF(pcd)); + if ((speed != USB_SPEED_HIGH) && + (aml_new_usb_get_mode() != 1)) { + gintsts.d32 = 0; + gintsts.b.enumdone = 1; + DWC_WRITE_REG32(&GET_CORE_IF(pcd)-> + core_global_regs->gintsts, gintsts.d32); + DWC_DEBUGPL(DBG_PCD, "false speed emun\n"); + return 1; + } } set_usb_phy_device_tuning(1, 0); - } +} #endif if (GET_CORE_IF(pcd)->snpsid >= OTG_CORE_REV_2_60a) { @@ -1558,7 +1561,8 @@ static inline void do_get_status(dwc_otg_pcd_t *pcd) } break; } else { - *status = 0x1; /* Self powered */ + *status = 0x0; /* bus powered */ + //*status = 0x1; /* Self powered */ *status |= pcd->remote_wakeup_enable << 1; break; } diff --git a/drivers/amlogic/usb/phy/phy-aml-new-usb2-v2.c b/drivers/amlogic/usb/phy/phy-aml-new-usb2-v2.c index 787da97d9a7d..e2b55e8d8e07 100644 --- a/drivers/amlogic/usb/phy/phy-aml-new-usb2-v2.c +++ b/drivers/amlogic/usb/phy/phy-aml-new-usb2-v2.c @@ -40,7 +40,7 @@ void set_usb_phy_host_tuning(int port, int default_val) if (!g_phy2_v2) return; - if (g_phy2_v2->phy_version == 1) + if (g_phy2_v2->phy_version) return; if (port > g_phy2_v2->portnum) @@ -69,7 +69,7 @@ void set_usb_phy_device_tuning(int port, int default_val) if (!g_phy2_v2) return; - if (g_phy2_v2->phy_version == 1) + if (g_phy2_v2->phy_version) return; if (port > g_phy2_v2->portnum) @@ -91,7 +91,6 @@ void set_usb_phy_device_tuning(int port, int default_val) g_phy2_v2->phy_cfg_state[port] = default_val; } - void set_usb_pll(struct amlogic_usb_v2 *phy, void __iomem *reg) { /* TO DO set usb PLL */ @@ -102,11 +101,23 @@ void set_usb_pll(struct amlogic_usb_v2 *phy, void __iomem *reg) writel((0x10000000 | (phy->pll_setting[0])), reg + 0x40); /* PHY Tune */ - writel(phy->pll_setting[3], reg + 0x50); - writel(phy->pll_setting[4], reg + 0x10); - /* Recovery analog status */ - writel(0, reg + 0x38); - writel(phy->pll_setting[5], reg + 0x34); + if (g_phy2_v2) { + if (g_phy2_v2->phy_version == 2) { + /**g12b revB don't need set 0x10 ,0x38 and 0x34**/ + writel(phy->pll_setting[3], reg + 0x50); + writel(0x70000, reg + 0x34); + } else { + writel(phy->pll_setting[3], reg + 0x50); + writel(phy->pll_setting[4], reg + 0x10); + writel(0, reg + 0x38); + writel(phy->pll_setting[5], reg + 0x34); + } + } else { + writel(phy->pll_setting[3], reg + 0x50); + writel(phy->pll_setting[4], reg + 0x10); + writel(0, reg + 0x38); + writel(phy->pll_setting[5], reg + 0x34); + } writel(TUNING_DISCONNECT_THRESHOLD, reg + 0xC); } @@ -246,7 +257,7 @@ static int amlogic_new_usb2_probe(struct platform_device *pdev) if (is_meson_g12b_cpu()) { if (!is_meson_rev_a()) - phy_version = 1; + phy_version = 2; } phy_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); diff --git a/drivers/amlogic/usb/phy/phy-aml-new-usb3-v2.c b/drivers/amlogic/usb/phy/phy-aml-new-usb3-v2.c index 3f360b589a79..727cdd845306 100644 --- a/drivers/amlogic/usb/phy/phy-aml-new-usb3-v2.c +++ b/drivers/amlogic/usb/phy/phy-aml-new-usb3-v2.c @@ -124,6 +124,19 @@ void aml_new_usb_v2_init(void) } EXPORT_SYMBOL(aml_new_usb_v2_init); +int aml_new_usb_get_mode(void) +{ + union usb_r5_v2 r5 = {.d32 = 0}; + + r5.d32 = readl(usb_new_aml_regs_v2.usb_r_v2[5]); + if (r5.b.iddig_curr == 0) + return 0; + else + return 1; +} +EXPORT_SYMBOL(aml_new_usb_get_mode); + + static void cr_bus_addr(unsigned int addr) { union phy3_r4 phy_r4 = {.d32 = 0}; diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 5b2f13ddc93c..508c9ef22898 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -2212,8 +2212,12 @@ free_interfaces: device_enable_async_suspend(&intf->dev); ret = device_add(&intf->dev); #ifdef CONFIG_AMLOGIC_USB - if (((&intf->dev)->driver) == NULL) - dev_err(&dev->dev, "Unsupported device\n"); + if (((&intf->dev)->driver) == NULL) { + if (intf->cur_altsetting->desc.bInterfaceClass == 0x09) + dev_err(&dev->dev, "Unsupported the hub\n"); + else + dev_err(&dev->dev, "Unsupported device\n"); + } #endif if (ret != 0) { dev_err(&dev->dev, "device_add(%s) --> %d\n",