usb: revB usb EL compliance test [2/1]
authorhe.he <he.he@amlogic.com>
Tue, 19 Feb 2019 06:50:29 +0000 (14:50 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Fri, 1 Mar 2019 02:53:52 +0000 (18:53 -0800)
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: I9d7dc6472f95c6bcdf2c031222db4fed25be8a13
Signed-off-by: he.he <he.he@amlogic.com>
drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd.h
drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd_intr.c
drivers/amlogic/usb/phy/phy-aml-new-usb2-v2.c
drivers/amlogic/usb/phy/phy-aml-new-usb3-v2.c
drivers/usb/core/message.c

index ba54785..38a153f 100644 (file)
@@ -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
index 4b9fb07..3382a6a 100644 (file)
@@ -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;
                }
index 787da97..e2b55e8 100644 (file)
@@ -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);
index 3f360b5..727cdd8 100644 (file)
@@ -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};
index 5b2f13d..508c9ef 100644 (file)
@@ -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",