xref: /rk3399_rockchip-uboot/arch/powerpc/cpu/mpc85xx/cmd_errata.c (revision c0a4e6b889a702cc2c8375619ce7b093f6b3b1de)
179ee3448SKumar Gala /*
2d621da00SJerry Huang  * Copyright 2010-2011 Freescale Semiconductor, Inc.
379ee3448SKumar Gala  *
479ee3448SKumar Gala  * See file CREDITS for list of people who contributed to this
579ee3448SKumar Gala  * project.
679ee3448SKumar Gala  *
779ee3448SKumar Gala  * This program is free software; you can redistribute it and/or
879ee3448SKumar Gala  * modify it under the terms of the GNU General Public License as
979ee3448SKumar Gala  * published by the Free Software Foundation; either version 2 of
1079ee3448SKumar Gala  * the License, or (at your option) any later version.
1179ee3448SKumar Gala  *
1279ee3448SKumar Gala  * This program is distributed in the hope that it will be useful,
1379ee3448SKumar Gala  * but WITHOUT ANY WARRANTY; without even the implied warranty of
1479ee3448SKumar Gala  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1579ee3448SKumar Gala  * GNU General Public License for more details.
1679ee3448SKumar Gala  *
1779ee3448SKumar Gala  * You should have received a copy of the GNU General Public License
1879ee3448SKumar Gala  * along with this program; if not, write to the Free Software
1979ee3448SKumar Gala  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
2079ee3448SKumar Gala  * MA 02111-1307 USA
2179ee3448SKumar Gala  */
2279ee3448SKumar Gala 
2379ee3448SKumar Gala #include <common.h>
2479ee3448SKumar Gala #include <command.h>
2579ee3448SKumar Gala #include <linux/compiler.h>
2679ee3448SKumar Gala #include <asm/processor.h>
27d607b968STimur Tabi #include "fsl_corenet_serdes.h"
2879ee3448SKumar Gala 
290118033bSTimur Tabi #ifdef CONFIG_SYS_FSL_ERRATUM_A004849
300118033bSTimur Tabi /*
310118033bSTimur Tabi  * This work-around is implemented in PBI, so just check to see if the
320118033bSTimur Tabi  * work-around was actually applied.  To do this, we check for specific data
330118033bSTimur Tabi  * at specific addresses in DCSR.
340118033bSTimur Tabi  *
350118033bSTimur Tabi  * Array offsets[] contains a list of offsets within DCSR.  According to the
360118033bSTimur Tabi  * erratum document, the value at each offset should be 2.
370118033bSTimur Tabi  */
380118033bSTimur Tabi static void check_erratum_a4849(uint32_t svr)
390118033bSTimur Tabi {
400118033bSTimur Tabi 	void __iomem *dcsr = (void *)CONFIG_SYS_DCSRBAR + 0xb0000;
410118033bSTimur Tabi 	unsigned int i;
420118033bSTimur Tabi 
430118033bSTimur Tabi #if defined(CONFIG_PPC_P2041) || defined(CONFIG_PPC_P3041)
440118033bSTimur Tabi 	static const uint8_t offsets[] = {
450118033bSTimur Tabi 		0x50, 0x54, 0x58, 0x90, 0x94, 0x98
460118033bSTimur Tabi 	};
470118033bSTimur Tabi #endif
480118033bSTimur Tabi #ifdef CONFIG_PPC_P4080
490118033bSTimur Tabi 	static const uint8_t offsets[] = {
500118033bSTimur Tabi 		0x60, 0x64, 0x68, 0x6c, 0xa0, 0xa4, 0xa8, 0xac
510118033bSTimur Tabi 	};
520118033bSTimur Tabi #endif
530118033bSTimur Tabi 	uint32_t x108; /* The value that should be at offset 0x108 */
540118033bSTimur Tabi 
550118033bSTimur Tabi 	for (i = 0; i < ARRAY_SIZE(offsets); i++) {
560118033bSTimur Tabi 		if (in_be32(dcsr + offsets[i]) != 2) {
570118033bSTimur Tabi 			printf("Work-around for Erratum A004849 is not enabled\n");
580118033bSTimur Tabi 			return;
590118033bSTimur Tabi 		}
600118033bSTimur Tabi 	}
610118033bSTimur Tabi 
620118033bSTimur Tabi #if defined(CONFIG_PPC_P2041) || defined(CONFIG_PPC_P3041)
630118033bSTimur Tabi 	x108 = 0x12;
640118033bSTimur Tabi #endif
650118033bSTimur Tabi 
660118033bSTimur Tabi #ifdef CONFIG_PPC_P4080
670118033bSTimur Tabi 	/*
680118033bSTimur Tabi 	 * For P4080, the erratum document says that the value at offset 0x108
690118033bSTimur Tabi 	 * should be 0x12 on rev2, or 0x1c on rev3.
700118033bSTimur Tabi 	 */
710118033bSTimur Tabi 	if (SVR_MAJ(svr) == 2)
720118033bSTimur Tabi 		x108 = 0x12;
730118033bSTimur Tabi 	if (SVR_MAJ(svr) == 3)
740118033bSTimur Tabi 		x108 = 0x1c;
750118033bSTimur Tabi #endif
760118033bSTimur Tabi 
770118033bSTimur Tabi 	if (in_be32(dcsr + 0x108) != x108) {
780118033bSTimur Tabi 		printf("Work-around for Erratum A004849 is not enabled\n");
790118033bSTimur Tabi 		return;
800118033bSTimur Tabi 	}
810118033bSTimur Tabi 
820118033bSTimur Tabi 	/* Everything matches, so the erratum work-around was applied */
830118033bSTimur Tabi 
840118033bSTimur Tabi 	printf("Work-around for Erratum A004849 enabled\n");
850118033bSTimur Tabi }
860118033bSTimur Tabi #endif
870118033bSTimur Tabi 
88d607b968STimur Tabi #ifdef CONFIG_SYS_FSL_ERRATUM_A004580
89d607b968STimur Tabi /*
90d607b968STimur Tabi  * This work-around is implemented in PBI, so just check to see if the
91d607b968STimur Tabi  * work-around was actually applied.  To do this, we check for specific data
92d607b968STimur Tabi  * at specific addresses in the SerDes register block.
93d607b968STimur Tabi  *
94d607b968STimur Tabi  * The work-around says that for each SerDes lane, write BnTTLCRy0 =
95d607b968STimur Tabi  * 0x1B00_0001, Register 2 = 0x0088_0000, and Register 3 = 0x4000_0000.
96d607b968STimur Tabi 
97d607b968STimur Tabi  */
98d607b968STimur Tabi static void check_erratum_a4580(uint32_t svr)
99d607b968STimur Tabi {
100d607b968STimur Tabi 	const serdes_corenet_t __iomem *srds_regs =
101d607b968STimur Tabi 		(void *)CONFIG_SYS_FSL_CORENET_SERDES_ADDR;
102d607b968STimur Tabi 	unsigned int lane;
103d607b968STimur Tabi 
104d607b968STimur Tabi 	for (lane = 0; lane < SRDS_MAX_LANES; lane++) {
105d607b968STimur Tabi 		if (serdes_lane_enabled(lane)) {
106d607b968STimur Tabi 			const struct serdes_lane __iomem *srds_lane =
107d607b968STimur Tabi 				&srds_regs->lane[serdes_get_lane_idx(lane)];
108d607b968STimur Tabi 
109d607b968STimur Tabi 			/*
110d607b968STimur Tabi 			 * Verify that the values we were supposed to write in
111d607b968STimur Tabi 			 * the PBI are actually there.  Also, the lower 15
112d607b968STimur Tabi 			 * bits of res4[3] should be the same as the upper 15
113d607b968STimur Tabi 			 * bits of res4[1].
114d607b968STimur Tabi 			 */
115d607b968STimur Tabi 			if ((in_be32(&srds_lane->ttlcr0) != 0x1b000001) ||
116d607b968STimur Tabi 			    (in_be32(&srds_lane->res4[1]) != 0x880000) ||
117d607b968STimur Tabi 			    (in_be32(&srds_lane->res4[3]) != 0x40000044)) {
118d607b968STimur Tabi 				printf("Work-around for Erratum A004580 is "
119d607b968STimur Tabi 				       "not enabled\n");
120d607b968STimur Tabi 				return;
121d607b968STimur Tabi 			}
122d607b968STimur Tabi 		}
123d607b968STimur Tabi 	}
124d607b968STimur Tabi 
125d607b968STimur Tabi 	/* Everything matches, so the erratum work-around was applied */
126d607b968STimur Tabi 
127d607b968STimur Tabi 	printf("Work-around for Erratum A004580 enabled\n");
128d607b968STimur Tabi }
129d607b968STimur Tabi #endif
130d607b968STimur Tabi 
13179ee3448SKumar Gala static int do_errata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
13279ee3448SKumar Gala {
13357125f22SYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011
13457125f22SYork Sun 	extern int enable_cpu_a011_workaround;
13557125f22SYork Sun #endif
13679ee3448SKumar Gala 	__maybe_unused u32 svr = get_svr();
13779ee3448SKumar Gala 
13879ee3448SKumar Gala #if defined(CONFIG_FSL_SATA_V2) && defined(CONFIG_FSL_SATA_ERRATUM_A001)
13979ee3448SKumar Gala 	if (IS_SVR_REV(svr, 1, 0)) {
14079ee3448SKumar Gala 		switch (SVR_SOC_VER(svr)) {
14179ee3448SKumar Gala 		case SVR_P1013:
14279ee3448SKumar Gala 		case SVR_P1022:
14379ee3448SKumar Gala 			puts("Work-around for Erratum SATA A001 enabled\n");
14479ee3448SKumar Gala 		}
14579ee3448SKumar Gala 	}
14679ee3448SKumar Gala #endif
14779ee3448SKumar Gala 
14861054ffaSKumar Gala #if defined(CONFIG_SYS_P4080_ERRATUM_SERDES8)
14961054ffaSKumar Gala 	puts("Work-around for Erratum SERDES8 enabled\n");
15061054ffaSKumar Gala #endif
151df8af0b4SEmil Medve #if defined(CONFIG_SYS_P4080_ERRATUM_SERDES9)
152df8af0b4SEmil Medve 	puts("Work-around for Erratum SERDES9 enabled\n");
153df8af0b4SEmil Medve #endif
154da30b9fdSTimur Tabi #if defined(CONFIG_SYS_P4080_ERRATUM_SERDES_A005)
155da30b9fdSTimur Tabi 	puts("Work-around for Erratum SERDES-A005 enabled\n");
156da30b9fdSTimur Tabi #endif
157fd3c9befSKumar Gala #if defined(CONFIG_SYS_P4080_ERRATUM_CPU22)
1581e9ea85fSYork Sun 	if (SVR_MAJ(svr) < 3)
159fd3c9befSKumar Gala 		puts("Work-around for Erratum CPU22 enabled\n");
160fd3c9befSKumar Gala #endif
1615e23ab0aSYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011
1625e23ab0aSYork Sun 	/*
1635e23ab0aSYork Sun 	 * NMG_CPU_A011 applies to P4080 rev 1.0, 2.0, fixed in 3.0
1645e23ab0aSYork Sun 	 * also applies to P3041 rev 1.0, 1.1, P2041 rev 1.0, 1.1
16557125f22SYork Sun 	 * The SVR has been checked by cpu_init_r().
1665e23ab0aSYork Sun 	 */
16757125f22SYork Sun 	if (enable_cpu_a011_workaround)
1685e23ab0aSYork Sun 		puts("Work-around for Erratum CPU-A011 enabled\n");
1695e23ab0aSYork Sun #endif
17043f082bbSKumar Gala #if defined(CONFIG_SYS_FSL_ERRATUM_CPU_A003999)
17143f082bbSKumar Gala 	puts("Work-around for Erratum CPU-A003999 enabled\n");
17243f082bbSKumar Gala #endif
1734108508aSYork Sun #if defined(CONFIG_SYS_FSL_ERRATUM_DDR_A003474)
1744108508aSYork Sun 	puts("Work-around for Erratum DDR-A003473 enabled\n");
1754108508aSYork Sun #endif
176810c4427SBecky Bruce #if defined(CONFIG_SYS_FSL_ERRATUM_DDR_MSYNC_IN)
177810c4427SBecky Bruce 	puts("Work-around for DDR MSYNC_IN Erratum enabled\n");
178810c4427SBecky Bruce #endif
179d621da00SJerry Huang #if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC111)
180d621da00SJerry Huang 	puts("Work-around for Erratum ESDHC111 enabled\n");
181d621da00SJerry Huang #endif
182eb539412SYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_A004468
183eb539412SYork Sun 	puts("Work-around for Erratum A004468 enabled\n");
184eb539412SYork Sun #endif
1853b4456ecSRoy Zang #if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC135)
1863b4456ecSRoy Zang 	puts("Work-around for Erratum ESDHC135 enabled\n");
1873b4456ecSRoy Zang #endif
1884e0be34aSZang Roy-R61911 #if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC13)
1894e0be34aSZang Roy-R61911 	if (SVR_MAJ(svr) < 3)
1904e0be34aSZang Roy-R61911 		puts("Work-around for Erratum ESDHC13 enabled\n");
191ae026ffdSRoy Zang #endif
1925103a03aSKumar Gala #if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC_A001)
1935103a03aSKumar Gala 	puts("Work-around for Erratum ESDHC-A001 enabled\n");
1945103a03aSKumar Gala #endif
1951d2c2a62SKumar Gala #ifdef CONFIG_SYS_FSL_ERRATUM_CPC_A002
1961d2c2a62SKumar Gala 	puts("Work-around for Erratum CPC-A002 enabled\n");
1971d2c2a62SKumar Gala #endif
198868da593SKumar Gala #ifdef CONFIG_SYS_FSL_ERRATUM_CPC_A003
199868da593SKumar Gala 	puts("Work-around for Erratum CPC-A003 enabled\n");
200868da593SKumar Gala #endif
201f133796dSKumar Gala #ifdef CONFIG_SYS_FSL_ERRATUM_ELBC_A001
202f133796dSKumar Gala 	puts("Work-around for Erratum ELBC-A001 enabled\n");
203f133796dSKumar Gala #endif
204fa8d23c0SYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_DDR_A003
205fa8d23c0SYork Sun 	puts("Work-around for Erratum DDR-A003 enabled\n");
206fa8d23c0SYork Sun #endif
207eb0aff77SYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_DDR_115
208eb0aff77SYork Sun 	puts("Work-around for Erratum DDR115 enabled\n");
209eb0aff77SYork Sun #endif
21091671913SYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_DDR111_DDR134
21191671913SYork Sun 	puts("Work-around for Erratum DDR111 enabled\n");
21291671913SYork Sun 	puts("Work-around for Erratum DDR134 enabled\n");
21391671913SYork Sun #endif
21442aee64bSPoonam Aggrwal #ifdef CONFIG_SYS_FSL_ERRATUM_IFC_A002769
21542aee64bSPoonam Aggrwal 	puts("Work-around for Erratum IFC-A002769 enabled\n");
21642aee64bSPoonam Aggrwal #endif
217fb855f43SPoonam Aggrwal #ifdef CONFIG_SYS_FSL_ERRATUM_P1010_A003549
218fb855f43SPoonam Aggrwal 	puts("Work-around for Erratum P1010-A003549 enabled\n");
219fb855f43SPoonam Aggrwal #endif
220bc6bbd6bSPoonam Aggrwal #ifdef CONFIG_SYS_FSL_ERRATUM_IFC_A003399
221bc6bbd6bSPoonam Aggrwal 	puts("Work-around for Erratum IFC A-003399 enabled\n");
222bc6bbd6bSPoonam Aggrwal #endif
2235ace2992SKumar Gala #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_DDR120
2245ace2992SKumar Gala 	if ((SVR_MAJ(svr) == 1) || IS_SVR_REV(svr, 2, 0))
2255ace2992SKumar Gala 		puts("Work-around for Erratum NMG DDR120 enabled\n");
2265ace2992SKumar Gala #endif
2272b3a1cddSKumar Gala #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_LBC103
2282b3a1cddSKumar Gala 	puts("Work-around for Erratum NMG_LBC103 enabled\n");
2292b3a1cddSKumar Gala #endif
230aada81deSchenhui zhao #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_ETSEC129
231aada81deSchenhui zhao 	if ((SVR_MAJ(svr) == 1) || IS_SVR_REV(svr, 2, 0))
232aada81deSchenhui zhao 		puts("Work-around for Erratum NMG ETSEC129 enabled\n");
233aada81deSchenhui zhao #endif
23433eee330SScott Wood #ifdef CONFIG_SYS_FSL_ERRATUM_A004510
23533eee330SScott Wood 	puts("Work-around for Erratum A004510 enabled\n");
23633eee330SScott Wood #endif
237d59c5570SLiu Gang #ifdef CONFIG_SYS_FSL_ERRATUM_SRIO_A004034
238d59c5570SLiu Gang 	puts("Work-around for Erratum SRIO-A004034 enabled\n");
239d59c5570SLiu Gang #endif
240a1d558a2SYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_A_004934
241a1d558a2SYork Sun 	puts("Work-around for Erratum A004934 enabled\n");
242a1d558a2SYork Sun #endif
2430118033bSTimur Tabi #ifdef CONFIG_SYS_FSL_ERRATUM_A004849
2440118033bSTimur Tabi 	/* This work-around is implemented in PBI, so just check for it */
2450118033bSTimur Tabi 	check_erratum_a4849(svr);
2460118033bSTimur Tabi #endif
247d607b968STimur Tabi #ifdef CONFIG_SYS_FSL_ERRATUM_A004580
248d607b968STimur Tabi 	/* This work-around is implemented in PBI, so just check for it */
249d607b968STimur Tabi 	check_erratum_a4580(svr);
250d607b968STimur Tabi #endif
251*c0a4e6b8SYuanquan Chen #ifdef CONFIG_SYS_P4080_ERRATUM_PCIE_A003
252*c0a4e6b8SYuanquan Chen 	puts("Work-around for Erratum PCIe-A003 enabled\n");
253*c0a4e6b8SYuanquan Chen #endif
25479ee3448SKumar Gala 	return 0;
25579ee3448SKumar Gala }
25679ee3448SKumar Gala 
25779ee3448SKumar Gala U_BOOT_CMD(
25879ee3448SKumar Gala 	errata, 1, 0,	do_errata,
25979ee3448SKumar Gala 	"Report errata workarounds",
26079ee3448SKumar Gala 	""
26179ee3448SKumar Gala );
262