179ee3448SKumar Gala /* 2d621da00SJerry Huang * Copyright 2010-2011 Freescale Semiconductor, Inc. 379ee3448SKumar Gala * 41a459660SWolfgang Denk * SPDX-License-Identifier: GPL-2.0+ 579ee3448SKumar Gala */ 679ee3448SKumar Gala 779ee3448SKumar Gala #include <common.h> 879ee3448SKumar Gala #include <command.h> 979ee3448SKumar Gala #include <linux/compiler.h> 1079ee3448SKumar Gala #include <asm/processor.h> 11d607b968STimur Tabi #include "fsl_corenet_serdes.h" 1279ee3448SKumar Gala 130118033bSTimur Tabi #ifdef CONFIG_SYS_FSL_ERRATUM_A004849 140118033bSTimur Tabi /* 150118033bSTimur Tabi * This work-around is implemented in PBI, so just check to see if the 160118033bSTimur Tabi * work-around was actually applied. To do this, we check for specific data 170118033bSTimur Tabi * at specific addresses in DCSR. 180118033bSTimur Tabi * 190118033bSTimur Tabi * Array offsets[] contains a list of offsets within DCSR. According to the 200118033bSTimur Tabi * erratum document, the value at each offset should be 2. 210118033bSTimur Tabi */ 220118033bSTimur Tabi static void check_erratum_a4849(uint32_t svr) 230118033bSTimur Tabi { 240118033bSTimur Tabi void __iomem *dcsr = (void *)CONFIG_SYS_DCSRBAR + 0xb0000; 250118033bSTimur Tabi unsigned int i; 260118033bSTimur Tabi 270118033bSTimur Tabi #if defined(CONFIG_PPC_P2041) || defined(CONFIG_PPC_P3041) 280118033bSTimur Tabi static const uint8_t offsets[] = { 290118033bSTimur Tabi 0x50, 0x54, 0x58, 0x90, 0x94, 0x98 300118033bSTimur Tabi }; 310118033bSTimur Tabi #endif 320118033bSTimur Tabi #ifdef CONFIG_PPC_P4080 330118033bSTimur Tabi static const uint8_t offsets[] = { 340118033bSTimur Tabi 0x60, 0x64, 0x68, 0x6c, 0xa0, 0xa4, 0xa8, 0xac 350118033bSTimur Tabi }; 360118033bSTimur Tabi #endif 370118033bSTimur Tabi uint32_t x108; /* The value that should be at offset 0x108 */ 380118033bSTimur Tabi 390118033bSTimur Tabi for (i = 0; i < ARRAY_SIZE(offsets); i++) { 400118033bSTimur Tabi if (in_be32(dcsr + offsets[i]) != 2) { 410118033bSTimur Tabi printf("Work-around for Erratum A004849 is not enabled\n"); 420118033bSTimur Tabi return; 430118033bSTimur Tabi } 440118033bSTimur Tabi } 450118033bSTimur Tabi 460118033bSTimur Tabi #if defined(CONFIG_PPC_P2041) || defined(CONFIG_PPC_P3041) 470118033bSTimur Tabi x108 = 0x12; 480118033bSTimur Tabi #endif 490118033bSTimur Tabi 500118033bSTimur Tabi #ifdef CONFIG_PPC_P4080 510118033bSTimur Tabi /* 520118033bSTimur Tabi * For P4080, the erratum document says that the value at offset 0x108 530118033bSTimur Tabi * should be 0x12 on rev2, or 0x1c on rev3. 540118033bSTimur Tabi */ 550118033bSTimur Tabi if (SVR_MAJ(svr) == 2) 560118033bSTimur Tabi x108 = 0x12; 570118033bSTimur Tabi if (SVR_MAJ(svr) == 3) 580118033bSTimur Tabi x108 = 0x1c; 590118033bSTimur Tabi #endif 600118033bSTimur Tabi 610118033bSTimur Tabi if (in_be32(dcsr + 0x108) != x108) { 620118033bSTimur Tabi printf("Work-around for Erratum A004849 is not enabled\n"); 630118033bSTimur Tabi return; 640118033bSTimur Tabi } 650118033bSTimur Tabi 660118033bSTimur Tabi /* Everything matches, so the erratum work-around was applied */ 670118033bSTimur Tabi 680118033bSTimur Tabi printf("Work-around for Erratum A004849 enabled\n"); 690118033bSTimur Tabi } 700118033bSTimur Tabi #endif 710118033bSTimur Tabi 72d607b968STimur Tabi #ifdef CONFIG_SYS_FSL_ERRATUM_A004580 73d607b968STimur Tabi /* 74d607b968STimur Tabi * This work-around is implemented in PBI, so just check to see if the 75d607b968STimur Tabi * work-around was actually applied. To do this, we check for specific data 76d607b968STimur Tabi * at specific addresses in the SerDes register block. 77d607b968STimur Tabi * 78d607b968STimur Tabi * The work-around says that for each SerDes lane, write BnTTLCRy0 = 79d607b968STimur Tabi * 0x1B00_0001, Register 2 = 0x0088_0000, and Register 3 = 0x4000_0000. 80d607b968STimur Tabi 81d607b968STimur Tabi */ 82d607b968STimur Tabi static void check_erratum_a4580(uint32_t svr) 83d607b968STimur Tabi { 84d607b968STimur Tabi const serdes_corenet_t __iomem *srds_regs = 85d607b968STimur Tabi (void *)CONFIG_SYS_FSL_CORENET_SERDES_ADDR; 86d607b968STimur Tabi unsigned int lane; 87d607b968STimur Tabi 88d607b968STimur Tabi for (lane = 0; lane < SRDS_MAX_LANES; lane++) { 89d607b968STimur Tabi if (serdes_lane_enabled(lane)) { 90d607b968STimur Tabi const struct serdes_lane __iomem *srds_lane = 91d607b968STimur Tabi &srds_regs->lane[serdes_get_lane_idx(lane)]; 92d607b968STimur Tabi 93d607b968STimur Tabi /* 94d607b968STimur Tabi * Verify that the values we were supposed to write in 95d607b968STimur Tabi * the PBI are actually there. Also, the lower 15 96d607b968STimur Tabi * bits of res4[3] should be the same as the upper 15 97d607b968STimur Tabi * bits of res4[1]. 98d607b968STimur Tabi */ 99d607b968STimur Tabi if ((in_be32(&srds_lane->ttlcr0) != 0x1b000001) || 100d607b968STimur Tabi (in_be32(&srds_lane->res4[1]) != 0x880000) || 101d607b968STimur Tabi (in_be32(&srds_lane->res4[3]) != 0x40000044)) { 102d607b968STimur Tabi printf("Work-around for Erratum A004580 is " 103d607b968STimur Tabi "not enabled\n"); 104d607b968STimur Tabi return; 105d607b968STimur Tabi } 106d607b968STimur Tabi } 107d607b968STimur Tabi } 108d607b968STimur Tabi 109d607b968STimur Tabi /* Everything matches, so the erratum work-around was applied */ 110d607b968STimur Tabi 111d607b968STimur Tabi printf("Work-around for Erratum A004580 enabled\n"); 112d607b968STimur Tabi } 113d607b968STimur Tabi #endif 114d607b968STimur Tabi 11579ee3448SKumar Gala static int do_errata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 11679ee3448SKumar Gala { 11757125f22SYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011 11857125f22SYork Sun extern int enable_cpu_a011_workaround; 11957125f22SYork Sun #endif 12079ee3448SKumar Gala __maybe_unused u32 svr = get_svr(); 12179ee3448SKumar Gala 12279ee3448SKumar Gala #if defined(CONFIG_FSL_SATA_V2) && defined(CONFIG_FSL_SATA_ERRATUM_A001) 12379ee3448SKumar Gala if (IS_SVR_REV(svr, 1, 0)) { 12479ee3448SKumar Gala switch (SVR_SOC_VER(svr)) { 12579ee3448SKumar Gala case SVR_P1013: 12679ee3448SKumar Gala case SVR_P1022: 12779ee3448SKumar Gala puts("Work-around for Erratum SATA A001 enabled\n"); 12879ee3448SKumar Gala } 12979ee3448SKumar Gala } 13079ee3448SKumar Gala #endif 13179ee3448SKumar Gala 13261054ffaSKumar Gala #if defined(CONFIG_SYS_P4080_ERRATUM_SERDES8) 13361054ffaSKumar Gala puts("Work-around for Erratum SERDES8 enabled\n"); 13461054ffaSKumar Gala #endif 135df8af0b4SEmil Medve #if defined(CONFIG_SYS_P4080_ERRATUM_SERDES9) 136df8af0b4SEmil Medve puts("Work-around for Erratum SERDES9 enabled\n"); 137df8af0b4SEmil Medve #endif 138da30b9fdSTimur Tabi #if defined(CONFIG_SYS_P4080_ERRATUM_SERDES_A005) 139da30b9fdSTimur Tabi puts("Work-around for Erratum SERDES-A005 enabled\n"); 140da30b9fdSTimur Tabi #endif 141fd3c9befSKumar Gala #if defined(CONFIG_SYS_P4080_ERRATUM_CPU22) 1421e9ea85fSYork Sun if (SVR_MAJ(svr) < 3) 143fd3c9befSKumar Gala puts("Work-around for Erratum CPU22 enabled\n"); 144fd3c9befSKumar Gala #endif 1455e23ab0aSYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011 1465e23ab0aSYork Sun /* 1475e23ab0aSYork Sun * NMG_CPU_A011 applies to P4080 rev 1.0, 2.0, fixed in 3.0 1485e23ab0aSYork Sun * also applies to P3041 rev 1.0, 1.1, P2041 rev 1.0, 1.1 14957125f22SYork Sun * The SVR has been checked by cpu_init_r(). 1505e23ab0aSYork Sun */ 15157125f22SYork Sun if (enable_cpu_a011_workaround) 1525e23ab0aSYork Sun puts("Work-around for Erratum CPU-A011 enabled\n"); 1535e23ab0aSYork Sun #endif 15443f082bbSKumar Gala #if defined(CONFIG_SYS_FSL_ERRATUM_CPU_A003999) 15543f082bbSKumar Gala puts("Work-around for Erratum CPU-A003999 enabled\n"); 15643f082bbSKumar Gala #endif 1574108508aSYork Sun #if defined(CONFIG_SYS_FSL_ERRATUM_DDR_A003474) 1584108508aSYork Sun puts("Work-around for Erratum DDR-A003473 enabled\n"); 1594108508aSYork Sun #endif 160810c4427SBecky Bruce #if defined(CONFIG_SYS_FSL_ERRATUM_DDR_MSYNC_IN) 161810c4427SBecky Bruce puts("Work-around for DDR MSYNC_IN Erratum enabled\n"); 162810c4427SBecky Bruce #endif 163d621da00SJerry Huang #if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC111) 164d621da00SJerry Huang puts("Work-around for Erratum ESDHC111 enabled\n"); 165d621da00SJerry Huang #endif 166eb539412SYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_A004468 167eb539412SYork Sun puts("Work-around for Erratum A004468 enabled\n"); 168eb539412SYork Sun #endif 1693b4456ecSRoy Zang #if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC135) 1703b4456ecSRoy Zang puts("Work-around for Erratum ESDHC135 enabled\n"); 1713b4456ecSRoy Zang #endif 1724e0be34aSZang Roy-R61911 #if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC13) 1734e0be34aSZang Roy-R61911 if (SVR_MAJ(svr) < 3) 1744e0be34aSZang Roy-R61911 puts("Work-around for Erratum ESDHC13 enabled\n"); 175ae026ffdSRoy Zang #endif 1765103a03aSKumar Gala #if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC_A001) 1775103a03aSKumar Gala puts("Work-around for Erratum ESDHC-A001 enabled\n"); 1785103a03aSKumar Gala #endif 1791d2c2a62SKumar Gala #ifdef CONFIG_SYS_FSL_ERRATUM_CPC_A002 1801d2c2a62SKumar Gala puts("Work-around for Erratum CPC-A002 enabled\n"); 1811d2c2a62SKumar Gala #endif 182868da593SKumar Gala #ifdef CONFIG_SYS_FSL_ERRATUM_CPC_A003 183868da593SKumar Gala puts("Work-around for Erratum CPC-A003 enabled\n"); 184868da593SKumar Gala #endif 185f133796dSKumar Gala #ifdef CONFIG_SYS_FSL_ERRATUM_ELBC_A001 186f133796dSKumar Gala puts("Work-around for Erratum ELBC-A001 enabled\n"); 187f133796dSKumar Gala #endif 188fa8d23c0SYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_DDR_A003 189fa8d23c0SYork Sun puts("Work-around for Erratum DDR-A003 enabled\n"); 190fa8d23c0SYork Sun #endif 191eb0aff77SYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_DDR_115 192eb0aff77SYork Sun puts("Work-around for Erratum DDR115 enabled\n"); 193eb0aff77SYork Sun #endif 19491671913SYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_DDR111_DDR134 19591671913SYork Sun puts("Work-around for Erratum DDR111 enabled\n"); 19691671913SYork Sun puts("Work-around for Erratum DDR134 enabled\n"); 19791671913SYork Sun #endif 19842aee64bSPoonam Aggrwal #ifdef CONFIG_SYS_FSL_ERRATUM_IFC_A002769 19942aee64bSPoonam Aggrwal puts("Work-around for Erratum IFC-A002769 enabled\n"); 20042aee64bSPoonam Aggrwal #endif 201fb855f43SPoonam Aggrwal #ifdef CONFIG_SYS_FSL_ERRATUM_P1010_A003549 202fb855f43SPoonam Aggrwal puts("Work-around for Erratum P1010-A003549 enabled\n"); 203fb855f43SPoonam Aggrwal #endif 204bc6bbd6bSPoonam Aggrwal #ifdef CONFIG_SYS_FSL_ERRATUM_IFC_A003399 205bc6bbd6bSPoonam Aggrwal puts("Work-around for Erratum IFC A-003399 enabled\n"); 206bc6bbd6bSPoonam Aggrwal #endif 2075ace2992SKumar Gala #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_DDR120 2085ace2992SKumar Gala if ((SVR_MAJ(svr) == 1) || IS_SVR_REV(svr, 2, 0)) 2095ace2992SKumar Gala puts("Work-around for Erratum NMG DDR120 enabled\n"); 2105ace2992SKumar Gala #endif 2112b3a1cddSKumar Gala #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_LBC103 2122b3a1cddSKumar Gala puts("Work-around for Erratum NMG_LBC103 enabled\n"); 2132b3a1cddSKumar Gala #endif 214aada81deSchenhui zhao #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_ETSEC129 215aada81deSchenhui zhao if ((SVR_MAJ(svr) == 1) || IS_SVR_REV(svr, 2, 0)) 216aada81deSchenhui zhao puts("Work-around for Erratum NMG ETSEC129 enabled\n"); 217aada81deSchenhui zhao #endif 21833eee330SScott Wood #ifdef CONFIG_SYS_FSL_ERRATUM_A004510 21933eee330SScott Wood puts("Work-around for Erratum A004510 enabled\n"); 22033eee330SScott Wood #endif 221d59c5570SLiu Gang #ifdef CONFIG_SYS_FSL_ERRATUM_SRIO_A004034 222d59c5570SLiu Gang puts("Work-around for Erratum SRIO-A004034 enabled\n"); 223d59c5570SLiu Gang #endif 224a1d558a2SYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_A_004934 225a1d558a2SYork Sun puts("Work-around for Erratum A004934 enabled\n"); 226a1d558a2SYork Sun #endif 22772bd83cdSShengzhou Liu #ifdef CONFIG_SYS_FSL_ERRATUM_A005871 22872bd83cdSShengzhou Liu if (IS_SVR_REV(svr, 1, 0)) 22972bd83cdSShengzhou Liu puts("Work-around for Erratum A005871 enabled\n"); 23072bd83cdSShengzhou Liu #endif 2310118033bSTimur Tabi #ifdef CONFIG_SYS_FSL_ERRATUM_A004849 2320118033bSTimur Tabi /* This work-around is implemented in PBI, so just check for it */ 2330118033bSTimur Tabi check_erratum_a4849(svr); 2340118033bSTimur Tabi #endif 235d607b968STimur Tabi #ifdef CONFIG_SYS_FSL_ERRATUM_A004580 236d607b968STimur Tabi /* This work-around is implemented in PBI, so just check for it */ 237d607b968STimur Tabi check_erratum_a4580(svr); 238d607b968STimur Tabi #endif 239c0a4e6b8SYuanquan Chen #ifdef CONFIG_SYS_P4080_ERRATUM_PCIE_A003 240c0a4e6b8SYuanquan Chen puts("Work-around for Erratum PCIe-A003 enabled\n"); 241c0a4e6b8SYuanquan Chen #endif 24299d7b0a4SXulei #ifdef CONFIG_SYS_FSL_ERRATUM_USB14 24399d7b0a4SXulei puts("Work-around for Erratum USB14 enabled\n"); 24499d7b0a4SXulei #endif 24582125192SScott Wood #ifdef CONFIG_SYS_FSL_ERRATUM_A006593 24682125192SScott Wood puts("Work-around for Erratum A006593 enabled\n"); 24782125192SScott Wood #endif 248d217a9adSYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_A005812 249d217a9adSYork Sun puts("Work-around for Erratum A-005812 enabled\n"); 250d217a9adSYork Sun #endif 251*9c3f77ebSChunhe Lan #ifdef CONFIG_SYS_FSL_ERRATUM_I2C_A004447 252*9c3f77ebSChunhe Lan if ((SVR_SOC_VER(svr) == SVR_8548 && IS_SVR_REV(svr, 3, 1)) || 253*9c3f77ebSChunhe Lan (SVR_REV(svr) <= CONFIG_SYS_FSL_A004447_SVR_REV)) 254*9c3f77ebSChunhe Lan puts("Work-around for Erratum I2C-A004447 enabled\n"); 255*9c3f77ebSChunhe Lan #endif 25679ee3448SKumar Gala return 0; 25779ee3448SKumar Gala } 25879ee3448SKumar Gala 25979ee3448SKumar Gala U_BOOT_CMD( 26079ee3448SKumar Gala errata, 1, 0, do_errata, 26179ee3448SKumar Gala "Report errata workarounds", 26279ee3448SKumar Gala "" 26379ee3448SKumar Gala ); 264