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> 10*133fbfa9SYork Sun #include <asm/fsl_errata.h> 1179ee3448SKumar Gala #include <asm/processor.h> 12d607b968STimur Tabi #include "fsl_corenet_serdes.h" 1379ee3448SKumar Gala 140118033bSTimur Tabi #ifdef CONFIG_SYS_FSL_ERRATUM_A004849 150118033bSTimur Tabi /* 160118033bSTimur Tabi * This work-around is implemented in PBI, so just check to see if the 170118033bSTimur Tabi * work-around was actually applied. To do this, we check for specific data 180118033bSTimur Tabi * at specific addresses in DCSR. 190118033bSTimur Tabi * 200118033bSTimur Tabi * Array offsets[] contains a list of offsets within DCSR. According to the 210118033bSTimur Tabi * erratum document, the value at each offset should be 2. 220118033bSTimur Tabi */ 230118033bSTimur Tabi static void check_erratum_a4849(uint32_t svr) 240118033bSTimur Tabi { 250118033bSTimur Tabi void __iomem *dcsr = (void *)CONFIG_SYS_DCSRBAR + 0xb0000; 260118033bSTimur Tabi unsigned int i; 270118033bSTimur Tabi 280118033bSTimur Tabi #if defined(CONFIG_PPC_P2041) || defined(CONFIG_PPC_P3041) 290118033bSTimur Tabi static const uint8_t offsets[] = { 300118033bSTimur Tabi 0x50, 0x54, 0x58, 0x90, 0x94, 0x98 310118033bSTimur Tabi }; 320118033bSTimur Tabi #endif 330118033bSTimur Tabi #ifdef CONFIG_PPC_P4080 340118033bSTimur Tabi static const uint8_t offsets[] = { 350118033bSTimur Tabi 0x60, 0x64, 0x68, 0x6c, 0xa0, 0xa4, 0xa8, 0xac 360118033bSTimur Tabi }; 370118033bSTimur Tabi #endif 380118033bSTimur Tabi uint32_t x108; /* The value that should be at offset 0x108 */ 390118033bSTimur Tabi 400118033bSTimur Tabi for (i = 0; i < ARRAY_SIZE(offsets); i++) { 410118033bSTimur Tabi if (in_be32(dcsr + offsets[i]) != 2) { 420118033bSTimur Tabi printf("Work-around for Erratum A004849 is not enabled\n"); 430118033bSTimur Tabi return; 440118033bSTimur Tabi } 450118033bSTimur Tabi } 460118033bSTimur Tabi 470118033bSTimur Tabi #if defined(CONFIG_PPC_P2041) || defined(CONFIG_PPC_P3041) 480118033bSTimur Tabi x108 = 0x12; 490118033bSTimur Tabi #endif 500118033bSTimur Tabi 510118033bSTimur Tabi #ifdef CONFIG_PPC_P4080 520118033bSTimur Tabi /* 530118033bSTimur Tabi * For P4080, the erratum document says that the value at offset 0x108 540118033bSTimur Tabi * should be 0x12 on rev2, or 0x1c on rev3. 550118033bSTimur Tabi */ 560118033bSTimur Tabi if (SVR_MAJ(svr) == 2) 570118033bSTimur Tabi x108 = 0x12; 580118033bSTimur Tabi if (SVR_MAJ(svr) == 3) 590118033bSTimur Tabi x108 = 0x1c; 600118033bSTimur Tabi #endif 610118033bSTimur Tabi 620118033bSTimur Tabi if (in_be32(dcsr + 0x108) != x108) { 630118033bSTimur Tabi printf("Work-around for Erratum A004849 is not enabled\n"); 640118033bSTimur Tabi return; 650118033bSTimur Tabi } 660118033bSTimur Tabi 670118033bSTimur Tabi /* Everything matches, so the erratum work-around was applied */ 680118033bSTimur Tabi 690118033bSTimur Tabi printf("Work-around for Erratum A004849 enabled\n"); 700118033bSTimur Tabi } 710118033bSTimur Tabi #endif 720118033bSTimur Tabi 73d607b968STimur Tabi #ifdef CONFIG_SYS_FSL_ERRATUM_A004580 74d607b968STimur Tabi /* 75d607b968STimur Tabi * This work-around is implemented in PBI, so just check to see if the 76d607b968STimur Tabi * work-around was actually applied. To do this, we check for specific data 77d607b968STimur Tabi * at specific addresses in the SerDes register block. 78d607b968STimur Tabi * 79d607b968STimur Tabi * The work-around says that for each SerDes lane, write BnTTLCRy0 = 80d607b968STimur Tabi * 0x1B00_0001, Register 2 = 0x0088_0000, and Register 3 = 0x4000_0000. 81d607b968STimur Tabi 82d607b968STimur Tabi */ 83d607b968STimur Tabi static void check_erratum_a4580(uint32_t svr) 84d607b968STimur Tabi { 85d607b968STimur Tabi const serdes_corenet_t __iomem *srds_regs = 86d607b968STimur Tabi (void *)CONFIG_SYS_FSL_CORENET_SERDES_ADDR; 87d607b968STimur Tabi unsigned int lane; 88d607b968STimur Tabi 89d607b968STimur Tabi for (lane = 0; lane < SRDS_MAX_LANES; lane++) { 90d607b968STimur Tabi if (serdes_lane_enabled(lane)) { 91d607b968STimur Tabi const struct serdes_lane __iomem *srds_lane = 92d607b968STimur Tabi &srds_regs->lane[serdes_get_lane_idx(lane)]; 93d607b968STimur Tabi 94d607b968STimur Tabi /* 95d607b968STimur Tabi * Verify that the values we were supposed to write in 96d607b968STimur Tabi * the PBI are actually there. Also, the lower 15 97d607b968STimur Tabi * bits of res4[3] should be the same as the upper 15 98d607b968STimur Tabi * bits of res4[1]. 99d607b968STimur Tabi */ 100d607b968STimur Tabi if ((in_be32(&srds_lane->ttlcr0) != 0x1b000001) || 101d607b968STimur Tabi (in_be32(&srds_lane->res4[1]) != 0x880000) || 102d607b968STimur Tabi (in_be32(&srds_lane->res4[3]) != 0x40000044)) { 103d607b968STimur Tabi printf("Work-around for Erratum A004580 is " 104d607b968STimur Tabi "not enabled\n"); 105d607b968STimur Tabi return; 106d607b968STimur Tabi } 107d607b968STimur Tabi } 108d607b968STimur Tabi } 109d607b968STimur Tabi 110d607b968STimur Tabi /* Everything matches, so the erratum work-around was applied */ 111d607b968STimur Tabi 112d607b968STimur Tabi printf("Work-around for Erratum A004580 enabled\n"); 113d607b968STimur Tabi } 114d607b968STimur Tabi #endif 115d607b968STimur Tabi 11679ee3448SKumar Gala static int do_errata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 11779ee3448SKumar Gala { 11857125f22SYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011 11957125f22SYork Sun extern int enable_cpu_a011_workaround; 12057125f22SYork Sun #endif 12179ee3448SKumar Gala __maybe_unused u32 svr = get_svr(); 12279ee3448SKumar Gala 12379ee3448SKumar Gala #if defined(CONFIG_FSL_SATA_V2) && defined(CONFIG_FSL_SATA_ERRATUM_A001) 12479ee3448SKumar Gala if (IS_SVR_REV(svr, 1, 0)) { 12579ee3448SKumar Gala switch (SVR_SOC_VER(svr)) { 12679ee3448SKumar Gala case SVR_P1013: 12779ee3448SKumar Gala case SVR_P1022: 12879ee3448SKumar Gala puts("Work-around for Erratum SATA A001 enabled\n"); 12979ee3448SKumar Gala } 13079ee3448SKumar Gala } 13179ee3448SKumar Gala #endif 13279ee3448SKumar Gala 13361054ffaSKumar Gala #if defined(CONFIG_SYS_P4080_ERRATUM_SERDES8) 13461054ffaSKumar Gala puts("Work-around for Erratum SERDES8 enabled\n"); 13561054ffaSKumar Gala #endif 136df8af0b4SEmil Medve #if defined(CONFIG_SYS_P4080_ERRATUM_SERDES9) 137df8af0b4SEmil Medve puts("Work-around for Erratum SERDES9 enabled\n"); 138df8af0b4SEmil Medve #endif 139da30b9fdSTimur Tabi #if defined(CONFIG_SYS_P4080_ERRATUM_SERDES_A005) 140da30b9fdSTimur Tabi puts("Work-around for Erratum SERDES-A005 enabled\n"); 141da30b9fdSTimur Tabi #endif 142fd3c9befSKumar Gala #if defined(CONFIG_SYS_P4080_ERRATUM_CPU22) 1431e9ea85fSYork Sun if (SVR_MAJ(svr) < 3) 144fd3c9befSKumar Gala puts("Work-around for Erratum CPU22 enabled\n"); 145fd3c9befSKumar Gala #endif 1465e23ab0aSYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011 1475e23ab0aSYork Sun /* 1485e23ab0aSYork Sun * NMG_CPU_A011 applies to P4080 rev 1.0, 2.0, fixed in 3.0 1495e23ab0aSYork Sun * also applies to P3041 rev 1.0, 1.1, P2041 rev 1.0, 1.1 15057125f22SYork Sun * The SVR has been checked by cpu_init_r(). 1515e23ab0aSYork Sun */ 15257125f22SYork Sun if (enable_cpu_a011_workaround) 1535e23ab0aSYork Sun puts("Work-around for Erratum CPU-A011 enabled\n"); 1545e23ab0aSYork Sun #endif 15543f082bbSKumar Gala #if defined(CONFIG_SYS_FSL_ERRATUM_CPU_A003999) 15643f082bbSKumar Gala puts("Work-around for Erratum CPU-A003999 enabled\n"); 15743f082bbSKumar Gala #endif 1584108508aSYork Sun #if defined(CONFIG_SYS_FSL_ERRATUM_DDR_A003474) 1594108508aSYork Sun puts("Work-around for Erratum DDR-A003473 enabled\n"); 1604108508aSYork Sun #endif 161810c4427SBecky Bruce #if defined(CONFIG_SYS_FSL_ERRATUM_DDR_MSYNC_IN) 162810c4427SBecky Bruce puts("Work-around for DDR MSYNC_IN Erratum enabled\n"); 163810c4427SBecky Bruce #endif 164d621da00SJerry Huang #if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC111) 165d621da00SJerry Huang puts("Work-around for Erratum ESDHC111 enabled\n"); 166d621da00SJerry Huang #endif 167eb539412SYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_A004468 168eb539412SYork Sun puts("Work-around for Erratum A004468 enabled\n"); 169eb539412SYork Sun #endif 1703b4456ecSRoy Zang #if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC135) 1713b4456ecSRoy Zang puts("Work-around for Erratum ESDHC135 enabled\n"); 1723b4456ecSRoy Zang #endif 1734e0be34aSZang Roy-R61911 #if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC13) 1744e0be34aSZang Roy-R61911 if (SVR_MAJ(svr) < 3) 1754e0be34aSZang Roy-R61911 puts("Work-around for Erratum ESDHC13 enabled\n"); 176ae026ffdSRoy Zang #endif 1775103a03aSKumar Gala #if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC_A001) 1785103a03aSKumar Gala puts("Work-around for Erratum ESDHC-A001 enabled\n"); 1795103a03aSKumar Gala #endif 1801d2c2a62SKumar Gala #ifdef CONFIG_SYS_FSL_ERRATUM_CPC_A002 1811d2c2a62SKumar Gala puts("Work-around for Erratum CPC-A002 enabled\n"); 1821d2c2a62SKumar Gala #endif 183868da593SKumar Gala #ifdef CONFIG_SYS_FSL_ERRATUM_CPC_A003 184868da593SKumar Gala puts("Work-around for Erratum CPC-A003 enabled\n"); 185868da593SKumar Gala #endif 186f133796dSKumar Gala #ifdef CONFIG_SYS_FSL_ERRATUM_ELBC_A001 187f133796dSKumar Gala puts("Work-around for Erratum ELBC-A001 enabled\n"); 188f133796dSKumar Gala #endif 189fa8d23c0SYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_DDR_A003 190fa8d23c0SYork Sun puts("Work-around for Erratum DDR-A003 enabled\n"); 191fa8d23c0SYork Sun #endif 192eb0aff77SYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_DDR_115 193eb0aff77SYork Sun puts("Work-around for Erratum DDR115 enabled\n"); 194eb0aff77SYork Sun #endif 19591671913SYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_DDR111_DDR134 19691671913SYork Sun puts("Work-around for Erratum DDR111 enabled\n"); 19791671913SYork Sun puts("Work-around for Erratum DDR134 enabled\n"); 19891671913SYork Sun #endif 19942aee64bSPoonam Aggrwal #ifdef CONFIG_SYS_FSL_ERRATUM_IFC_A002769 20042aee64bSPoonam Aggrwal puts("Work-around for Erratum IFC-A002769 enabled\n"); 20142aee64bSPoonam Aggrwal #endif 202fb855f43SPoonam Aggrwal #ifdef CONFIG_SYS_FSL_ERRATUM_P1010_A003549 203fb855f43SPoonam Aggrwal puts("Work-around for Erratum P1010-A003549 enabled\n"); 204fb855f43SPoonam Aggrwal #endif 205bc6bbd6bSPoonam Aggrwal #ifdef CONFIG_SYS_FSL_ERRATUM_IFC_A003399 206bc6bbd6bSPoonam Aggrwal puts("Work-around for Erratum IFC A-003399 enabled\n"); 207bc6bbd6bSPoonam Aggrwal #endif 2085ace2992SKumar Gala #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_DDR120 2095ace2992SKumar Gala if ((SVR_MAJ(svr) == 1) || IS_SVR_REV(svr, 2, 0)) 2105ace2992SKumar Gala puts("Work-around for Erratum NMG DDR120 enabled\n"); 2115ace2992SKumar Gala #endif 2122b3a1cddSKumar Gala #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_LBC103 2132b3a1cddSKumar Gala puts("Work-around for Erratum NMG_LBC103 enabled\n"); 2142b3a1cddSKumar Gala #endif 215aada81deSchenhui zhao #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_ETSEC129 216aada81deSchenhui zhao if ((SVR_MAJ(svr) == 1) || IS_SVR_REV(svr, 2, 0)) 217aada81deSchenhui zhao puts("Work-around for Erratum NMG ETSEC129 enabled\n"); 218aada81deSchenhui zhao #endif 21933eee330SScott Wood #ifdef CONFIG_SYS_FSL_ERRATUM_A004510 22033eee330SScott Wood puts("Work-around for Erratum A004510 enabled\n"); 22133eee330SScott Wood #endif 222d59c5570SLiu Gang #ifdef CONFIG_SYS_FSL_ERRATUM_SRIO_A004034 223d59c5570SLiu Gang puts("Work-around for Erratum SRIO-A004034 enabled\n"); 224d59c5570SLiu Gang #endif 225a1d558a2SYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_A_004934 226a1d558a2SYork Sun puts("Work-around for Erratum A004934 enabled\n"); 227a1d558a2SYork Sun #endif 22872bd83cdSShengzhou Liu #ifdef CONFIG_SYS_FSL_ERRATUM_A005871 22972bd83cdSShengzhou Liu if (IS_SVR_REV(svr, 1, 0)) 23072bd83cdSShengzhou Liu puts("Work-around for Erratum A005871 enabled\n"); 23172bd83cdSShengzhou Liu #endif 2320118033bSTimur Tabi #ifdef CONFIG_SYS_FSL_ERRATUM_A004849 2330118033bSTimur Tabi /* This work-around is implemented in PBI, so just check for it */ 2340118033bSTimur Tabi check_erratum_a4849(svr); 2350118033bSTimur Tabi #endif 236d607b968STimur Tabi #ifdef CONFIG_SYS_FSL_ERRATUM_A004580 237d607b968STimur Tabi /* This work-around is implemented in PBI, so just check for it */ 238d607b968STimur Tabi check_erratum_a4580(svr); 239d607b968STimur Tabi #endif 240c0a4e6b8SYuanquan Chen #ifdef CONFIG_SYS_P4080_ERRATUM_PCIE_A003 241c0a4e6b8SYuanquan Chen puts("Work-around for Erratum PCIe-A003 enabled\n"); 242c0a4e6b8SYuanquan Chen #endif 24399d7b0a4SXulei #ifdef CONFIG_SYS_FSL_ERRATUM_USB14 24499d7b0a4SXulei puts("Work-around for Erratum USB14 enabled\n"); 24599d7b0a4SXulei #endif 24682125192SScott Wood #ifdef CONFIG_SYS_FSL_ERRATUM_A006593 24782125192SScott Wood puts("Work-around for Erratum A006593 enabled\n"); 24882125192SScott Wood #endif 249*133fbfa9SYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_A006379 250*133fbfa9SYork Sun if (has_erratum_a006379()) 251*133fbfa9SYork Sun puts("Work-around for Erratum A006379 enabled\n"); 252*133fbfa9SYork Sun #endif 253424bf942SShengzhou Liu #ifdef CONFIG_SYS_FSL_ERRATUM_SEC_A003571 254424bf942SShengzhou Liu if (IS_SVR_REV(svr, 1, 0)) 255424bf942SShengzhou Liu puts("Work-around for Erratum A003571 enabled\n"); 256424bf942SShengzhou Liu #endif 257d217a9adSYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_A005812 258d217a9adSYork Sun puts("Work-around for Erratum A-005812 enabled\n"); 259d217a9adSYork Sun #endif 260954a1a47SYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_A005125 261954a1a47SYork Sun puts("Work-around for Erratum A005125 enabled\n"); 262954a1a47SYork Sun #endif 2639c3f77ebSChunhe Lan #ifdef CONFIG_SYS_FSL_ERRATUM_I2C_A004447 2649c3f77ebSChunhe Lan if ((SVR_SOC_VER(svr) == SVR_8548 && IS_SVR_REV(svr, 3, 1)) || 2659c3f77ebSChunhe Lan (SVR_REV(svr) <= CONFIG_SYS_FSL_A004447_SVR_REV)) 2669c3f77ebSChunhe Lan puts("Work-around for Erratum I2C-A004447 enabled\n"); 2679c3f77ebSChunhe Lan #endif 26879ee3448SKumar Gala return 0; 26979ee3448SKumar Gala } 27079ee3448SKumar Gala 27179ee3448SKumar Gala U_BOOT_CMD( 27279ee3448SKumar Gala errata, 1, 0, do_errata, 27379ee3448SKumar Gala "Report errata workarounds", 27479ee3448SKumar Gala "" 27579ee3448SKumar Gala ); 276