]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
powerpc/usb: Workaround for erratum-A006261
authorSuresh Gupta <suresh.gupta@freescale.com>
Wed, 26 Feb 2014 08:59:12 +0000 (14:29 +0530)
committerYork Sun <yorksun@freescale.com>
Fri, 7 Mar 2014 22:52:16 +0000 (14:52 -0800)
USB spec says that the minimum disconnect threshold should be
over 525 mV. However, internal USB PHY threshold value is below
this specified value. Due to this some devices disconnect at
run-time. Hence, phy settings are tweaked to increased disconnect
threshold to be above 525mV by using this workaround.

Signed-off-by: Suresh Gupta <suresh.gupta@freescale.com>
Reviewed-by: York Sun <yorksun@freescale.com>
arch/powerpc/cpu/mpc85xx/cmd_errata.c
arch/powerpc/cpu/mpc85xx/cpu_init.c
arch/powerpc/include/asm/config_mpc85xx.h
arch/powerpc/include/asm/fsl_errata.h
include/fsl_usb.h

index d0a1c518bb38db7b11115275a683caa980e76367..8b79c05b1f2dc945a7fc662a5e9a4bab45938847 100644 (file)
@@ -272,6 +272,10 @@ static int do_errata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        if ((SVR_SOC_VER(svr) == SVR_8548 && IS_SVR_REV(svr, 3, 1)) ||
            (SVR_REV(svr) <= CONFIG_SYS_FSL_A004447_SVR_REV))
                puts("Work-around for Erratum I2C-A004447 enabled\n");
+#endif
+#ifdef CONFIG_SYS_FSL_ERRATUM_A006261
+       if (has_erratum_a006261())
+               puts("Work-around for Erratum A006261 enabled\n");
 #endif
        return 0;
 }
index b31efb761041d985464c7f371ac7195884e8672c..81aeadd363feade245665a6cf98f94ec378d0594 100644 (file)
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#ifdef CONFIG_SYS_FSL_ERRATUM_A006261
+void fsl_erratum_a006261_workaround(struct ccsr_usb_phy __iomem *usb_phy)
+{
+#ifdef CONFIG_SYS_FSL_USB_DUAL_PHY_ENABLE
+       u32 xcvrprg = in_be32(&usb_phy->port1.xcvrprg);
+
+       /* Increase Disconnect Threshold by 50mV */
+       xcvrprg &= ~CONFIG_SYS_FSL_USB_XCVRPRG_HS_DCNT_PROG_MASK |
+                                               INC_DCNT_THRESHOLD_50MV;
+       /* Enable programming of USB High speed Disconnect threshold */
+       xcvrprg |= CONFIG_SYS_FSL_USB_XCVRPRG_HS_DCNT_PROG_EN;
+       out_be32(&usb_phy->port1.xcvrprg, xcvrprg);
+
+       xcvrprg = in_be32(&usb_phy->port2.xcvrprg);
+       /* Increase Disconnect Threshold by 50mV */
+       xcvrprg &= ~CONFIG_SYS_FSL_USB_XCVRPRG_HS_DCNT_PROG_MASK |
+                                               INC_DCNT_THRESHOLD_50MV;
+       /* Enable programming of USB High speed Disconnect threshold */
+       xcvrprg |= CONFIG_SYS_FSL_USB_XCVRPRG_HS_DCNT_PROG_EN;
+       out_be32(&usb_phy->port2.xcvrprg, xcvrprg);
+#else
+
+       u32 temp = 0;
+       u32 status = in_be32(&usb_phy->status1);
+
+       u32 squelch_prog_rd_0_2 =
+               (status >> CONFIG_SYS_FSL_USB_SQUELCH_PROG_RD_0)
+                       & CONFIG_SYS_FSL_USB_SQUELCH_PROG_MASK;
+
+       u32 squelch_prog_rd_3_5 =
+               (status >> CONFIG_SYS_FSL_USB_SQUELCH_PROG_RD_3)
+                       & CONFIG_SYS_FSL_USB_SQUELCH_PROG_MASK;
+
+       setbits_be32(&usb_phy->config1,
+                    CONFIG_SYS_FSL_USB_HS_DISCNCT_INC);
+       setbits_be32(&usb_phy->config2,
+                    CONFIG_SYS_FSL_USB_RX_AUTO_CAL_RD_WR_SEL);
+
+       temp = squelch_prog_rd_0_2 << CONFIG_SYS_FSL_USB_SQUELCH_PROG_WR_0;
+       out_be32(&usb_phy->config2, in_be32(&usb_phy->config2) | temp);
+
+       temp = squelch_prog_rd_3_5 << CONFIG_SYS_FSL_USB_SQUELCH_PROG_WR_3;
+       out_be32(&usb_phy->config2, in_be32(&usb_phy->config2) | temp);
+#endif
+}
+#endif
+
+
 #ifdef CONFIG_QE
 extern qe_iop_conf_t qe_iop_conf_tab[];
 extern void qe_config_iopin(u8 port, u8 pin, int dir,
@@ -625,6 +673,10 @@ skip_l2:
        {
                struct ccsr_usb_phy __iomem *usb_phy1 =
                        (void *)CONFIG_SYS_MPC85xx_USB1_PHY_ADDR;
+#ifdef CONFIG_SYS_FSL_ERRATUM_A006261
+               if (has_erratum_a006261())
+                       fsl_erratum_a006261_workaround(usb_phy1);
+#endif
                out_be32(&usb_phy1->usb_enable_override,
                                CONFIG_SYS_FSL_USB_ENABLE_OVERRIDE);
        }
@@ -633,6 +685,10 @@ skip_l2:
        {
                struct ccsr_usb_phy __iomem *usb_phy2 =
                        (void *)CONFIG_SYS_MPC85xx_USB2_PHY_ADDR;
+#ifdef CONFIG_SYS_FSL_ERRATUM_A006261
+               if (has_erratum_a006261())
+                       fsl_erratum_a006261_workaround(usb_phy2);
+#endif
                out_be32(&usb_phy2->usb_enable_override,
                                CONFIG_SYS_FSL_USB_ENABLE_OVERRIDE);
        }
@@ -672,8 +728,14 @@ skip_l2:
                             CONFIG_SYS_FSL_USB_DRVVBUS_CR_EN);
                setbits_be32(&usb_phy->port2.pwrfltcfg,
                             CONFIG_SYS_FSL_USB_PWRFLT_CR_EN);
+
+#ifdef CONFIG_SYS_FSL_ERRATUM_A006261
+               if (has_erratum_a006261())
+                       fsl_erratum_a006261_workaround(usb_phy);
 #endif
 
+#endif /* CONFIG_SYS_FSL_USB_DUAL_PHY_ENABLE */
+
 #ifdef CONFIG_FMAN_ENET
        fman_enet_init();
 #endif
index 2f47b3fbd0fd064c5a418e3ad534b320b7a0e26d..9a20b971c5becfc3ae104e1aaed2622d273a3f0f 100644 (file)
 #define CONFIG_SYS_FSL_ERRATUM_IFC_A003399
 #define CONFIG_SYS_FSL_ERRATUM_A005125
 #define CONFIG_SYS_FSL_ERRATUM_I2C_A004447
+#define CONFIG_SYS_FSL_ERRATUM_A006261
 #define CONFIG_SYS_FSL_A004447_SVR_REV 0x10
 #define CONFIG_ESDHC_HC_BLK_ADDR
 
 #define CONFIG_SYS_FSL_ERRATUM_SRIO_A004034
 #define CONFIG_SYS_FSL_ERRATUM_A004849
 #define CONFIG_SYS_FSL_ERRATUM_I2C_A004447
+#define CONFIG_SYS_FSL_ERRATUM_A006261
 #define CONFIG_SYS_FSL_A004447_SVR_REV 0x11
 
 #elif defined(CONFIG_PPC_P3041)
 #define CONFIG_SYS_FSL_ERRATUM_A004849
 #define CONFIG_SYS_FSL_ERRATUM_A005812
 #define CONFIG_SYS_FSL_ERRATUM_I2C_A004447
+#define CONFIG_SYS_FSL_ERRATUM_A006261
 #define CONFIG_SYS_FSL_A004447_SVR_REV 0x20
 
 #elif defined(CONFIG_PPC_P4080) /* also supports P4040 */
 #define CONFIG_SYS_FSL_CORENET_SNOOPVEC_COREONLY 0xc0000000
 #define CONFIG_SYS_FSL_ERRATUM_SRIO_A004034
 #define CONFIG_SYS_FSL_ERRATUM_I2C_A004447
+#define CONFIG_SYS_FSL_ERRATUM_A006261
 #define CONFIG_SYS_FSL_A004447_SVR_REV 0x20
 
 #elif defined(CONFIG_PPC_P5040)
 #define CONFIG_SYS_FSL_ERRATUM_A004699
 #define CONFIG_SYS_FSL_ERRATUM_A004510
 #define CONFIG_SYS_FSL_ERRATUM_A004510_SVR_REV 0x10
+#define CONFIG_SYS_FSL_ERRATUM_A006261
 #define CONFIG_SYS_FSL_CORENET_SNOOPVEC_COREONLY 0xf0000000
 #define CONFIG_SYS_FSL_ERRATUM_A005812
 
 #define CONFIG_SYS_FSL_ERRATUM_A004468
 #define CONFIG_SYS_FSL_ERRATUM_A_004934
 #define CONFIG_SYS_FSL_ERRATUM_A005871
+#define CONFIG_SYS_FSL_ERRATUM_A006261
 #define CONFIG_SYS_FSL_ERRATUM_A006379
 #define CONFIG_SYS_FSL_ERRATUM_A006593
 #define CONFIG_SYS_CCSRBAR_DEFAULT     0xfe000000
@@ -726,6 +732,7 @@ defined(CONFIG_PPC_T1020) || defined(CONFIG_PPC_T1022)
 #define CONFIG_SYS_FSL_PCIE_COMPAT     "fsl,qoriq-pcie-v2.4"
 #define CONFIG_SYS_FSL_USB_DUAL_PHY_ENABLE
 #define CONFIG_SYS_FSL_USB_INTERNAL_UTMI_PHY
+#define CONFIG_SYS_FSL_ERRATUM_A006261
 #define CONFIG_SYS_CCSRBAR_DEFAULT     0xfe000000
 
 #elif defined(CONFIG_PPC_T2080) || defined(CONFIG_PPC_T2081)
index a59091977efb30150dacee195edd14499d3efccb..c9982cc8ec49486cf14c3ed786cac48f46d4c17f 100644 (file)
@@ -26,4 +26,38 @@ static inline bool has_erratum_a006379(void)
 }
 #endif
 
+#ifdef CONFIG_SYS_FSL_ERRATUM_A006261
+static inline bool has_erratum_a006261(void)
+{
+       u32 svr = get_svr();
+       u32 soc = SVR_SOC_VER(svr);
+
+       switch (soc) {
+       case SVR_P1010:
+               return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0);
+       case SVR_P2041:
+       case SVR_P2040:
+               return IS_SVR_REV(svr, 1, 0) ||
+                       IS_SVR_REV(svr, 1, 1) || IS_SVR_REV(svr, 2, 1);
+       case SVR_P3041:
+               return IS_SVR_REV(svr, 1, 0) ||
+                       IS_SVR_REV(svr, 1, 1) ||
+                       IS_SVR_REV(svr, 2, 0) || IS_SVR_REV(svr, 2, 1);
+       case SVR_P5010:
+       case SVR_P5020:
+       case SVR_P5021:
+               return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0);
+       case SVR_T4240:
+       case SVR_T4160:
+               return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0);
+       case SVR_T1040:
+               return IS_SVR_REV(svr, 1, 0);
+       case SVR_P5040:
+               return IS_SVR_REV(svr, 1, 0);
+       }
+
+       return false;
+}
+#endif
+
 #endif
index 915774cba8af69a907f26ed32804b5a9223491a2..8b63cdd88c03416d043521a758d8f983a4eb63c2 100644 (file)
@@ -52,13 +52,32 @@ struct ccsr_usb_phy {
 #define CONFIG_SYS_FSL_USB_PLLPRG2_MFI (5 << 16)
 #define CONFIG_SYS_FSL_USB_PLLPRG2_PLL_EN (1 << 21)
 #define CONFIG_SYS_FSL_USB_SYS_CLK_VALID (1 << 0)
+#define CONFIG_SYS_FSL_USB_XCVRPRG_HS_DCNT_PROG_EN (1 << 7)
+#define CONFIG_SYS_FSL_USB_XCVRPRG_HS_DCNT_PROG_MASK (3 << 4)
+
+#define INC_DCNT_THRESHOLD_25MV        (0 << 4)
+#define INC_DCNT_THRESHOLD_50MV        (1 << 4)
+#define DEC_DCNT_THRESHOLD_25MV        (2 << 4)
+#define DEC_DCNT_THRESHOLD_50MV        (3 << 4)
 #else
 struct ccsr_usb_phy {
-       u8      res0[0x18];
+       u32     config1;
+       u32     config2;
+       u32     config3;
+       u32     config4;
+       u32     config5;
+       u32     status1;
        u32     usb_enable_override;
        u8      res[0xe4];
 };
-#define        CONFIG_SYS_FSL_USB_ENABLE_OVERRIDE      1
+#define CONFIG_SYS_FSL_USB_HS_DISCNCT_INC (3 << 22)
+#define CONFIG_SYS_FSL_USB_RX_AUTO_CAL_RD_WR_SEL (1 << 20)
+#define CONFIG_SYS_FSL_USB_SQUELCH_PROG_WR_0 13
+#define CONFIG_SYS_FSL_USB_SQUELCH_PROG_WR_3 16
+#define CONFIG_SYS_FSL_USB_SQUELCH_PROG_RD_0 0
+#define CONFIG_SYS_FSL_USB_SQUELCH_PROG_RD_3 3
+#define CONFIG_SYS_FSL_USB_ENABLE_OVERRIDE 1
+#define CONFIG_SYS_FSL_USB_SQUELCH_PROG_MASK 0x07
 #endif
 
 #endif /*_ASM_FSL_USB_H_ */