From f8800761412cfcdcc2c681650c027463f214ad9d Mon Sep 17 00:00:00 2001 From: "he.he" Date: Tue, 19 Feb 2019 14:50:29 +0800 Subject: [PATCH] usb: revB usb EL compliance test [2/1] PD#SWPL-4941 Problem: EL27,28,29,31 failed in the el compliance test. tl1 frameworks test result(USB20CV) failed. Solution: Change the parameters (0x10 and 0x38) of usb phy to solve the el failed problem and modified the dwc_otg_pcd_handle_enum_done_intr function to solve the USB20CV failed problem. Verify: verify on revB Test: Pass Change-Id: I50ea27dbf9e3d74ca0c49e8615c6cf1bc27306aa Signed-off-by: he.he --- drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd.h | 1 + .../usb/dwc_otg/310/dwc_otg_pcd_intr.c | 24 +++++++++------- drivers/amlogic/usb/phy/phy-aml-new-usb2-v2.c | 28 +++++++++++++------ drivers/amlogic/usb/phy/phy-aml-new-usb3-v2.c | 13 +++++++++ drivers/usb/core/message.c | 8 ++++-- 5 files changed, 54 insertions(+), 20 deletions(-) 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 ca23f2b12680..c81429aaeb22 100644 --- a/drivers/amlogic/usb/phy/phy-aml-new-usb2-v2.c +++ b/drivers/amlogic/usb/phy/phy-aml-new-usb2-v2.c @@ -41,7 +41,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) @@ -70,7 +70,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) @@ -140,11 +140,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); } @@ -307,7 +319,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 cd90007f832b..3c97500bb819 100644 --- a/drivers/amlogic/usb/phy/phy-aml-new-usb3-v2.c +++ b/drivers/amlogic/usb/phy/phy-aml-new-usb3-v2.c @@ -125,6 +125,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",