blob: f91a4d441d3aef6cbbe2f692502baea208688c18 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Kumar Gala5900ea72010-06-09 22:59:41 -05002/*
Jerry Huanged413672011-01-06 23:42:19 -06003 * Copyright 2010-2011 Freescale Semiconductor, Inc.
Kumar Gala5900ea72010-06-09 22:59:41 -05004 */
5
Kumar Gala5900ea72010-06-09 22:59:41 -05006#include <command.h>
Simon Glass97589732020-05-10 11:40:02 -06007#include <init.h>
Kumar Gala5900ea72010-06-09 22:59:41 -05008#include <linux/compiler.h>
Shengzhou Liu7d8dfb82015-11-20 15:52:03 +08009#include <fsl_errata.h>
Kumar Gala5900ea72010-06-09 22:59:41 -050010#include <asm/processor.h>
Nikhil Badola76c2f2e2014-09-30 11:22:43 +053011#include <fsl_usb.h>
Timur Tabic5355dd2012-11-01 08:20:23 +000012#include "fsl_corenet_serdes.h"
Kumar Gala5900ea72010-06-09 22:59:41 -050013
Timur Tabie3ab8c12012-10-25 12:40:00 +000014#ifdef CONFIG_SYS_FSL_ERRATUM_A004849
15/*
16 * This work-around is implemented in PBI, so just check to see if the
17 * work-around was actually applied. To do this, we check for specific data
18 * at specific addresses in DCSR.
19 *
20 * Array offsets[] contains a list of offsets within DCSR. According to the
21 * erratum document, the value at each offset should be 2.
22 */
23static void check_erratum_a4849(uint32_t svr)
24{
Tom Rini6a5dccc2022-11-16 13:10:41 -050025 void __iomem *dcsr = (void *)CFG_SYS_DCSRBAR + 0xb0000;
Timur Tabie3ab8c12012-10-25 12:40:00 +000026 unsigned int i;
27
York Sundf70d062016-11-18 11:20:40 -080028#if defined(CONFIG_ARCH_P2041) || defined(CONFIG_ARCH_P3041)
Timur Tabie3ab8c12012-10-25 12:40:00 +000029 static const uint8_t offsets[] = {
30 0x50, 0x54, 0x58, 0x90, 0x94, 0x98
31 };
32#endif
York Sun84be8a92016-11-18 11:24:40 -080033#ifdef CONFIG_ARCH_P4080
Timur Tabie3ab8c12012-10-25 12:40:00 +000034 static const uint8_t offsets[] = {
35 0x60, 0x64, 0x68, 0x6c, 0xa0, 0xa4, 0xa8, 0xac
36 };
37#endif
38 uint32_t x108; /* The value that should be at offset 0x108 */
39
40 for (i = 0; i < ARRAY_SIZE(offsets); i++) {
41 if (in_be32(dcsr + offsets[i]) != 2) {
42 printf("Work-around for Erratum A004849 is not enabled\n");
43 return;
44 }
45 }
46
York Sundf70d062016-11-18 11:20:40 -080047#if defined(CONFIG_ARCH_P2041) || defined(CONFIG_ARCH_P3041)
Timur Tabie3ab8c12012-10-25 12:40:00 +000048 x108 = 0x12;
49#endif
50
York Sun84be8a92016-11-18 11:24:40 -080051#ifdef CONFIG_ARCH_P4080
Timur Tabie3ab8c12012-10-25 12:40:00 +000052 /*
53 * For P4080, the erratum document says that the value at offset 0x108
54 * should be 0x12 on rev2, or 0x1c on rev3.
55 */
56 if (SVR_MAJ(svr) == 2)
57 x108 = 0x12;
58 if (SVR_MAJ(svr) == 3)
59 x108 = 0x1c;
60#endif
61
62 if (in_be32(dcsr + 0x108) != x108) {
63 printf("Work-around for Erratum A004849 is not enabled\n");
64 return;
65 }
66
67 /* Everything matches, so the erratum work-around was applied */
68
69 printf("Work-around for Erratum A004849 enabled\n");
70}
71#endif
72
Timur Tabic5355dd2012-11-01 08:20:23 +000073#ifdef CONFIG_SYS_FSL_ERRATUM_A004580
74/*
75 * This work-around is implemented in PBI, so just check to see if the
76 * work-around was actually applied. To do this, we check for specific data
77 * at specific addresses in the SerDes register block.
78 *
79 * The work-around says that for each SerDes lane, write BnTTLCRy0 =
80 * 0x1B00_0001, Register 2 = 0x0088_0000, and Register 3 = 0x4000_0000.
81
82 */
83static void check_erratum_a4580(uint32_t svr)
84{
85 const serdes_corenet_t __iomem *srds_regs =
Tom Rini376b88a2022-10-28 20:27:13 -040086 (void *)CFG_SYS_FSL_CORENET_SERDES_ADDR;
Timur Tabic5355dd2012-11-01 08:20:23 +000087 unsigned int lane;
88
89 for (lane = 0; lane < SRDS_MAX_LANES; lane++) {
90 if (serdes_lane_enabled(lane)) {
91 const struct serdes_lane __iomem *srds_lane =
92 &srds_regs->lane[serdes_get_lane_idx(lane)];
93
94 /*
95 * Verify that the values we were supposed to write in
96 * the PBI are actually there. Also, the lower 15
97 * bits of res4[3] should be the same as the upper 15
98 * bits of res4[1].
99 */
100 if ((in_be32(&srds_lane->ttlcr0) != 0x1b000001) ||
101 (in_be32(&srds_lane->res4[1]) != 0x880000) ||
102 (in_be32(&srds_lane->res4[3]) != 0x40000044)) {
103 printf("Work-around for Erratum A004580 is "
104 "not enabled\n");
105 return;
106 }
107 }
108 }
109
110 /* Everything matches, so the erratum work-around was applied */
111
112 printf("Work-around for Erratum A004580 enabled\n");
113}
114#endif
115
York Sun7b083df2014-03-28 15:07:27 -0700116#ifdef CONFIG_SYS_FSL_ERRATUM_A007212
117/*
118 * This workaround can be implemented in PBI, or by u-boot.
119 */
120static void check_erratum_a007212(void)
121{
Tom Rini6a5dccc2022-11-16 13:10:41 -0500122 u32 __iomem *plldgdcr = (void *)(CFG_SYS_DCSRBAR + 0x21c20);
York Sun7b083df2014-03-28 15:07:27 -0700123
124 if (in_be32(plldgdcr) & 0x1fe) {
125 /* check if PLL ratio is set by workaround */
126 puts("Work-around for Erratum A007212 enabled\n");
127 }
128}
129#endif
130
Simon Glassed38aef2020-05-10 11:40:03 -0600131static int do_errata(struct cmd_tbl *cmdtp, int flag, int argc,
132 char *const argv[])
Kumar Gala5900ea72010-06-09 22:59:41 -0500133{
York Sun53155532012-08-08 18:04:53 +0000134#ifdef CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011
135 extern int enable_cpu_a011_workaround;
136#endif
Kumar Gala5900ea72010-06-09 22:59:41 -0500137 __maybe_unused u32 svr = get_svr();
138
York Sunbe735532016-12-28 08:43:43 -0800139#if defined(CONFIG_FSL_SATA_V2) && defined(CONFIG_SYS_FSL_ERRATUM_SATA_A001)
Kumar Gala5900ea72010-06-09 22:59:41 -0500140 if (IS_SVR_REV(svr, 1, 0)) {
141 switch (SVR_SOC_VER(svr)) {
142 case SVR_P1013:
Kumar Gala5900ea72010-06-09 22:59:41 -0500143 case SVR_P1022:
Kumar Gala5900ea72010-06-09 22:59:41 -0500144 puts("Work-around for Erratum SATA A001 enabled\n");
145 }
146 }
147#endif
148
Kumar Gala779a5322010-07-13 00:39:46 -0500149#if defined(CONFIG_SYS_P4080_ERRATUM_SERDES8)
150 puts("Work-around for Erratum SERDES8 enabled\n");
151#endif
Emil Medveb01c81f2010-08-31 22:57:38 -0500152#if defined(CONFIG_SYS_P4080_ERRATUM_SERDES9)
153 puts("Work-around for Erratum SERDES9 enabled\n");
154#endif
Timur Tabi90f381d2011-04-01 13:19:36 -0500155#if defined(CONFIG_SYS_P4080_ERRATUM_SERDES_A005)
156 puts("Work-around for Erratum SERDES-A005 enabled\n");
157#endif
Kumar Gala6b245b92010-05-05 22:35:27 -0500158#if defined(CONFIG_SYS_P4080_ERRATUM_CPU22)
York Sund755c832012-05-07 07:26:45 +0000159 if (SVR_MAJ(svr) < 3)
160 puts("Work-around for Erratum CPU22 enabled\n");
Kumar Gala6b245b92010-05-05 22:35:27 -0500161#endif
York Sun9ed88112012-05-07 07:26:47 +0000162#ifdef CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011
163 /*
164 * NMG_CPU_A011 applies to P4080 rev 1.0, 2.0, fixed in 3.0
165 * also applies to P3041 rev 1.0, 1.1, P2041 rev 1.0, 1.1
York Sun53155532012-08-08 18:04:53 +0000166 * The SVR has been checked by cpu_init_r().
York Sun9ed88112012-05-07 07:26:47 +0000167 */
York Sun53155532012-08-08 18:04:53 +0000168 if (enable_cpu_a011_workaround)
York Sun9ed88112012-05-07 07:26:47 +0000169 puts("Work-around for Erratum CPU-A011 enabled\n");
170#endif
Kumar Gala945e59a2011-11-22 06:51:15 -0600171#if defined(CONFIG_SYS_FSL_ERRATUM_CPU_A003999)
172 puts("Work-around for Erratum CPU-A003999 enabled\n");
173#endif
York Sundf2be192011-11-20 10:01:35 -0800174#if defined(CONFIG_SYS_FSL_ERRATUM_DDR_A003474)
York Sunc723aa02014-01-06 12:12:33 -0800175 puts("Work-around for Erratum DDR-A003474 enabled\n");
York Sundf2be192011-11-20 10:01:35 -0800176#endif
Becky Bruce4212f232010-12-17 17:17:58 -0600177#if defined(CONFIG_SYS_FSL_ERRATUM_DDR_MSYNC_IN)
178 puts("Work-around for DDR MSYNC_IN Erratum enabled\n");
179#endif
Jerry Huanged413672011-01-06 23:42:19 -0600180#if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC111)
181 puts("Work-around for Erratum ESDHC111 enabled\n");
182#endif
York Suna28496f2012-10-08 07:44:25 +0000183#ifdef CONFIG_SYS_FSL_ERRATUM_A004468
184 puts("Work-around for Erratum A004468 enabled\n");
185#endif
Roy Zang39356612011-01-07 00:06:47 -0600186#if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC135)
187 puts("Work-around for Erratum ESDHC135 enabled\n");
188#endif
Zang Roy-R6191183659922012-09-18 09:50:08 +0000189#if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC13)
190 if (SVR_MAJ(svr) < 3)
191 puts("Work-around for Erratum ESDHC13 enabled\n");
Roy Zangc65dc4d2011-01-07 00:24:27 -0600192#endif
Kumar Gala9a878d52011-01-29 15:36:10 -0600193#if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC_A001)
194 puts("Work-around for Erratum ESDHC-A001 enabled\n");
195#endif
Kumar Gala9780b592011-01-13 01:54:01 -0600196#ifdef CONFIG_SYS_FSL_ERRATUM_CPC_A002
197 puts("Work-around for Erratum CPC-A002 enabled\n");
198#endif
Kumar Gala887c0e12011-01-13 01:56:18 -0600199#ifdef CONFIG_SYS_FSL_ERRATUM_CPC_A003
200 puts("Work-around for Erratum CPC-A003 enabled\n");
201#endif
Kumar Gala77b37af2011-01-13 02:58:23 -0600202#ifdef CONFIG_SYS_FSL_ERRATUM_ELBC_A001
203 puts("Work-around for Erratum ELBC-A001 enabled\n");
204#endif
York Sun922f40f2011-01-10 12:03:01 +0000205#ifdef CONFIG_SYS_FSL_ERRATUM_DDR_A003
206 puts("Work-around for Erratum DDR-A003 enabled\n");
207#endif
York Sun9aa857b2011-01-25 21:51:27 -0800208#ifdef CONFIG_SYS_FSL_ERRATUM_DDR_115
209 puts("Work-around for Erratum DDR115 enabled\n");
210#endif
York Sunc8fc9592011-01-25 22:05:49 -0800211#ifdef CONFIG_SYS_FSL_ERRATUM_DDR111_DDR134
212 puts("Work-around for Erratum DDR111 enabled\n");
213 puts("Work-around for Erratum DDR134 enabled\n");
214#endif
Poonam Aggrwalc7664a42011-06-30 03:00:28 -0500215#ifdef CONFIG_SYS_FSL_ERRATUM_IFC_A002769
216 puts("Work-around for Erratum IFC-A002769 enabled\n");
217#endif
Poonam Aggrwalaf54a5f2011-06-29 16:32:52 +0530218#ifdef CONFIG_SYS_FSL_ERRATUM_P1010_A003549
219 puts("Work-around for Erratum P1010-A003549 enabled\n");
220#endif
Poonam Aggrwal46b86ca2011-07-07 20:36:47 +0530221#ifdef CONFIG_SYS_FSL_ERRATUM_IFC_A003399
222 puts("Work-around for Erratum IFC A-003399 enabled\n");
223#endif
Kumar Gala866c6fa2011-09-16 09:54:30 -0500224#ifdef CONFIG_SYS_FSL_ERRATUM_NMG_DDR120
225 if ((SVR_MAJ(svr) == 1) || IS_SVR_REV(svr, 2, 0))
226 puts("Work-around for Erratum NMG DDR120 enabled\n");
227#endif
Kumar Galaf3339d62011-10-03 08:37:57 -0500228#ifdef CONFIG_SYS_FSL_ERRATUM_NMG_LBC103
229 puts("Work-around for Erratum NMG_LBC103 enabled\n");
230#endif
chenhui zhaoc8caa8a2011-10-03 08:38:50 -0500231#ifdef CONFIG_SYS_FSL_ERRATUM_NMG_ETSEC129
232 if ((SVR_MAJ(svr) == 1) || IS_SVR_REV(svr, 2, 0))
233 puts("Work-around for Erratum NMG ETSEC129 enabled\n");
234#endif
York Sun99825792014-05-23 13:15:00 -0700235#ifdef CONFIG_SYS_FSL_ERRATUM_A004508
236 puts("Work-around for Erratum A004508 enabled\n");
237#endif
Scott Wood80806962012-08-14 10:14:53 +0000238#ifdef CONFIG_SYS_FSL_ERRATUM_A004510
239 puts("Work-around for Erratum A004510 enabled\n");
240#endif
Liu Gang712b6622012-09-28 21:26:19 +0000241#ifdef CONFIG_SYS_FSL_ERRATUM_SRIO_A004034
242 puts("Work-around for Erratum SRIO-A004034 enabled\n");
243#endif
York Sun6995a022012-10-08 07:44:26 +0000244#ifdef CONFIG_SYS_FSL_ERRATUM_A_004934
245 puts("Work-around for Erratum A004934 enabled\n");
246#endif
Shengzhou Liu95bd8e52013-01-23 19:56:23 +0000247#ifdef CONFIG_SYS_FSL_ERRATUM_A005871
248 if (IS_SVR_REV(svr, 1, 0))
249 puts("Work-around for Erratum A005871 enabled\n");
250#endif
Shaveta Leekhad11523b2014-02-26 16:08:22 +0530251#ifdef CONFIG_SYS_FSL_ERRATUM_A006475
252 if (SVR_MAJ(get_svr()) == 1)
253 puts("Work-around for Erratum A006475 enabled\n");
254#endif
255#ifdef CONFIG_SYS_FSL_ERRATUM_A006384
256 if (SVR_MAJ(get_svr()) == 1)
257 puts("Work-around for Erratum A006384 enabled\n");
258#endif
Timur Tabie3ab8c12012-10-25 12:40:00 +0000259#ifdef CONFIG_SYS_FSL_ERRATUM_A004849
260 /* This work-around is implemented in PBI, so just check for it */
261 check_erratum_a4849(svr);
262#endif
Timur Tabic5355dd2012-11-01 08:20:23 +0000263#ifdef CONFIG_SYS_FSL_ERRATUM_A004580
264 /* This work-around is implemented in PBI, so just check for it */
265 check_erratum_a4580(svr);
266#endif
Yuanquan Chenc48234e2012-11-26 23:49:45 +0000267#ifdef CONFIG_SYS_P4080_ERRATUM_PCIE_A003
268 puts("Work-around for Erratum PCIe-A003 enabled\n");
269#endif
Xuleicf4f4932013-03-11 17:56:34 +0000270#ifdef CONFIG_SYS_FSL_ERRATUM_USB14
271 puts("Work-around for Erratum USB14 enabled\n");
272#endif
Shaveta Leekha7c0f5e82014-05-28 14:18:55 +0530273#ifdef CONFIG_SYS_FSL_ERRATUM_A007186
Zhao Qiang440914d2014-10-30 14:07:39 +0800274 if (has_erratum_a007186())
275 puts("Work-around for Erratum A007186 enabled\n");
Shaveta Leekha7c0f5e82014-05-28 14:18:55 +0530276#endif
Scott Wood3f4a5c42013-05-15 17:50:13 -0500277#ifdef CONFIG_SYS_FSL_ERRATUM_A006593
278 puts("Work-around for Erratum A006593 enabled\n");
279#endif
York Sunb1954252013-09-16 12:49:31 -0700280#ifdef CONFIG_SYS_FSL_ERRATUM_A006379
281 if (has_erratum_a006379())
282 puts("Work-around for Erratum A006379 enabled\n");
283#endif
Shengzhou Liu097be702013-08-15 09:31:47 +0800284#ifdef CONFIG_SYS_FSL_ERRATUM_SEC_A003571
285 if (IS_SVR_REV(svr, 1, 0))
286 puts("Work-around for Erratum A003571 enabled\n");
287#endif
York Suncca41c52013-06-25 11:37:49 -0700288#ifdef CONFIG_SYS_FSL_ERRATUM_A005812
289 puts("Work-around for Erratum A-005812 enabled\n");
290#endif
York Sun0cc59072013-08-20 15:09:43 -0700291#ifdef CONFIG_SYS_FSL_ERRATUM_A005125
292 puts("Work-around for Erratum A005125 enabled\n");
293#endif
Nikhil Badola2613cfc2014-02-26 17:43:15 +0530294#ifdef CONFIG_SYS_FSL_ERRATUM_A007075
295 if (has_erratum_a007075())
296 puts("Work-around for Erratum A007075 enabled\n");
297#endif
Nikhil Badola67f4b262014-10-17 09:12:07 +0530298#ifdef CONFIG_SYS_FSL_ERRATUM_A007798
299 if (has_erratum_a007798())
300 puts("Work-around for Erratum A007798 enabled\n");
301#endif
Nikhil Badola288542c2014-11-21 17:25:21 +0530302#ifdef CONFIG_SYS_FSL_ERRATUM_A004477
303 if (has_erratum_a004477())
304 puts("Work-around for Erratum A004477 enabled\n");
305#endif
Chunhe Lan92546402013-08-16 15:10:37 +0800306#ifdef CONFIG_SYS_FSL_ERRATUM_I2C_A004447
307 if ((SVR_SOC_VER(svr) == SVR_8548 && IS_SVR_REV(svr, 3, 1)) ||
308 (SVR_REV(svr) <= CONFIG_SYS_FSL_A004447_SVR_REV))
309 puts("Work-around for Erratum I2C-A004447 enabled\n");
310#endif
Chris Packham434f0582018-10-04 20:03:53 +1300311#ifdef CONFIG_SYS_FSL_ERRATUM_A005275
312 if (has_erratum_a005275())
313 puts("Work-around for Erratum A005275 enabled\n");
314#endif
Suresh Gupta086f0a72014-02-26 14:29:12 +0530315#ifdef CONFIG_SYS_FSL_ERRATUM_A006261
316 if (has_erratum_a006261())
317 puts("Work-around for Erratum A006261 enabled\n");
318#endif
York Sun7b083df2014-03-28 15:07:27 -0700319#ifdef CONFIG_SYS_FSL_ERRATUM_A007212
320 check_erratum_a007212();
321#endif
Chunhe Lan7155ad52014-05-07 10:50:20 +0800322#ifdef CONFIG_SYS_FSL_ERRATUM_A005434
323 puts("Work-around for Erratum A-005434 enabled\n");
324#endif
Prabhakar Kushwahac4c10d12014-10-29 22:33:09 +0530325#if defined(CONFIG_SYS_FSL_ERRATUM_A008044) && \
326 defined(CONFIG_A008044_WORKAROUND)
Prabhakar Kushwaha6467a7a2014-10-29 22:33:55 +0530327 if (IS_SVR_REV(svr, 1, 0))
328 puts("Work-around for Erratum A-008044 enabled\n");
Prabhakar Kushwahac4c10d12014-10-29 22:33:09 +0530329#endif
York Sun2dfafc62016-11-18 11:47:35 -0800330#if defined(CONFIG_SYS_FSL_B4860QDS_XFI_ERR) && \
331 (defined(CONFIG_TARGET_B4860QDS) || defined(CONFIG_TARGET_B4420QDS))
Shaohui Xie60c3b092014-11-13 11:27:49 +0800332 puts("Work-around for Erratum XFI on B4860QDS enabled\n");
333#endif
Shengzhou Liubdda96c2015-12-16 16:45:41 +0800334#ifdef CONFIG_SYS_FSL_ERRATUM_A009663
335 puts("Work-around for Erratum A009663 enabled\n");
336#endif
Darwin Dingela56d6c02016-10-25 09:48:01 +1300337#ifdef CONFIG_SYS_FSL_ERRATUM_A007907
338 puts("Work-around for Erratum A007907 enabled\n");
339#endif
Tony O'Brien8acb1272016-12-02 09:22:34 +1300340#ifdef CONFIG_SYS_FSL_ERRATUM_A007815
341 puts("Work-around for Erratum A007815 enabled\n");
342#endif
343
Kumar Gala5900ea72010-06-09 22:59:41 -0500344 return 0;
345}
346
347U_BOOT_CMD(
348 errata, 1, 0, do_errata,
349 "Report errata workarounds",
350 ""
351);