Kumar Gala | 79ee344 | 2010-06-09 22:59:41 -0500 | [diff] [blame] | 1 | /* |
Jerry Huang | d621da0 | 2011-01-06 23:42:19 -0600 | [diff] [blame] | 2 | * Copyright 2010-2011 Freescale Semiconductor, Inc. |
Kumar Gala | 79ee344 | 2010-06-09 22:59:41 -0500 | [diff] [blame] | 3 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Kumar Gala | 79ee344 | 2010-06-09 22:59:41 -0500 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <command.h> |
| 9 | #include <linux/compiler.h> |
York Sun | 133fbfa | 2013-09-16 12:49:31 -0700 | [diff] [blame] | 10 | #include <asm/fsl_errata.h> |
Kumar Gala | 79ee344 | 2010-06-09 22:59:41 -0500 | [diff] [blame] | 11 | #include <asm/processor.h> |
Timur Tabi | d607b96 | 2012-11-01 08:20:23 +0000 | [diff] [blame] | 12 | #include "fsl_corenet_serdes.h" |
Kumar Gala | 79ee344 | 2010-06-09 22:59:41 -0500 | [diff] [blame] | 13 | |
Timur Tabi | 0118033 | 2012-10-25 12:40:00 +0000 | [diff] [blame] | 14 | #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 | */ |
| 23 | static void check_erratum_a4849(uint32_t svr) |
| 24 | { |
| 25 | void __iomem *dcsr = (void *)CONFIG_SYS_DCSRBAR + 0xb0000; |
| 26 | unsigned int i; |
| 27 | |
| 28 | #if defined(CONFIG_PPC_P2041) || defined(CONFIG_PPC_P3041) |
| 29 | static const uint8_t offsets[] = { |
| 30 | 0x50, 0x54, 0x58, 0x90, 0x94, 0x98 |
| 31 | }; |
| 32 | #endif |
| 33 | #ifdef CONFIG_PPC_P4080 |
| 34 | 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 | |
| 47 | #if defined(CONFIG_PPC_P2041) || defined(CONFIG_PPC_P3041) |
| 48 | x108 = 0x12; |
| 49 | #endif |
| 50 | |
| 51 | #ifdef CONFIG_PPC_P4080 |
| 52 | /* |
| 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 Tabi | d607b96 | 2012-11-01 08:20:23 +0000 | [diff] [blame] | 73 | #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 | */ |
| 83 | static void check_erratum_a4580(uint32_t svr) |
| 84 | { |
| 85 | const serdes_corenet_t __iomem *srds_regs = |
| 86 | (void *)CONFIG_SYS_FSL_CORENET_SERDES_ADDR; |
| 87 | 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 | |
Kumar Gala | 79ee344 | 2010-06-09 22:59:41 -0500 | [diff] [blame] | 116 | static int do_errata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 117 | { |
York Sun | 57125f2 | 2012-08-08 18:04:53 +0000 | [diff] [blame] | 118 | #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011 |
| 119 | extern int enable_cpu_a011_workaround; |
| 120 | #endif |
Kumar Gala | 79ee344 | 2010-06-09 22:59:41 -0500 | [diff] [blame] | 121 | __maybe_unused u32 svr = get_svr(); |
| 122 | |
| 123 | #if defined(CONFIG_FSL_SATA_V2) && defined(CONFIG_FSL_SATA_ERRATUM_A001) |
| 124 | if (IS_SVR_REV(svr, 1, 0)) { |
| 125 | switch (SVR_SOC_VER(svr)) { |
| 126 | case SVR_P1013: |
Kumar Gala | 79ee344 | 2010-06-09 22:59:41 -0500 | [diff] [blame] | 127 | case SVR_P1022: |
Kumar Gala | 79ee344 | 2010-06-09 22:59:41 -0500 | [diff] [blame] | 128 | puts("Work-around for Erratum SATA A001 enabled\n"); |
| 129 | } |
| 130 | } |
| 131 | #endif |
| 132 | |
Kumar Gala | 61054ff | 2010-07-13 00:39:46 -0500 | [diff] [blame] | 133 | #if defined(CONFIG_SYS_P4080_ERRATUM_SERDES8) |
| 134 | puts("Work-around for Erratum SERDES8 enabled\n"); |
| 135 | #endif |
Emil Medve | df8af0b | 2010-08-31 22:57:38 -0500 | [diff] [blame] | 136 | #if defined(CONFIG_SYS_P4080_ERRATUM_SERDES9) |
| 137 | puts("Work-around for Erratum SERDES9 enabled\n"); |
| 138 | #endif |
Timur Tabi | da30b9f | 2011-04-01 13:19:36 -0500 | [diff] [blame] | 139 | #if defined(CONFIG_SYS_P4080_ERRATUM_SERDES_A005) |
| 140 | puts("Work-around for Erratum SERDES-A005 enabled\n"); |
| 141 | #endif |
Kumar Gala | fd3c9be | 2010-05-05 22:35:27 -0500 | [diff] [blame] | 142 | #if defined(CONFIG_SYS_P4080_ERRATUM_CPU22) |
York Sun | 1e9ea85 | 2012-05-07 07:26:45 +0000 | [diff] [blame] | 143 | if (SVR_MAJ(svr) < 3) |
| 144 | puts("Work-around for Erratum CPU22 enabled\n"); |
Kumar Gala | fd3c9be | 2010-05-05 22:35:27 -0500 | [diff] [blame] | 145 | #endif |
York Sun | 5e23ab0 | 2012-05-07 07:26:47 +0000 | [diff] [blame] | 146 | #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011 |
| 147 | /* |
| 148 | * NMG_CPU_A011 applies to P4080 rev 1.0, 2.0, fixed in 3.0 |
| 149 | * also applies to P3041 rev 1.0, 1.1, P2041 rev 1.0, 1.1 |
York Sun | 57125f2 | 2012-08-08 18:04:53 +0000 | [diff] [blame] | 150 | * The SVR has been checked by cpu_init_r(). |
York Sun | 5e23ab0 | 2012-05-07 07:26:47 +0000 | [diff] [blame] | 151 | */ |
York Sun | 57125f2 | 2012-08-08 18:04:53 +0000 | [diff] [blame] | 152 | if (enable_cpu_a011_workaround) |
York Sun | 5e23ab0 | 2012-05-07 07:26:47 +0000 | [diff] [blame] | 153 | puts("Work-around for Erratum CPU-A011 enabled\n"); |
| 154 | #endif |
Kumar Gala | 43f082b | 2011-11-22 06:51:15 -0600 | [diff] [blame] | 155 | #if defined(CONFIG_SYS_FSL_ERRATUM_CPU_A003999) |
| 156 | puts("Work-around for Erratum CPU-A003999 enabled\n"); |
| 157 | #endif |
York Sun | 4108508 | 2011-11-20 10:01:35 -0800 | [diff] [blame] | 158 | #if defined(CONFIG_SYS_FSL_ERRATUM_DDR_A003474) |
York Sun | b518816 | 2014-01-06 12:12:33 -0800 | [diff] [blame] | 159 | puts("Work-around for Erratum DDR-A003474 enabled\n"); |
York Sun | 4108508 | 2011-11-20 10:01:35 -0800 | [diff] [blame] | 160 | #endif |
Becky Bruce | 810c442 | 2010-12-17 17:17:58 -0600 | [diff] [blame] | 161 | #if defined(CONFIG_SYS_FSL_ERRATUM_DDR_MSYNC_IN) |
| 162 | puts("Work-around for DDR MSYNC_IN Erratum enabled\n"); |
| 163 | #endif |
Jerry Huang | d621da0 | 2011-01-06 23:42:19 -0600 | [diff] [blame] | 164 | #if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC111) |
| 165 | puts("Work-around for Erratum ESDHC111 enabled\n"); |
| 166 | #endif |
York Sun | eb53941 | 2012-10-08 07:44:25 +0000 | [diff] [blame] | 167 | #ifdef CONFIG_SYS_FSL_ERRATUM_A004468 |
| 168 | puts("Work-around for Erratum A004468 enabled\n"); |
| 169 | #endif |
Roy Zang | 3b4456e | 2011-01-07 00:06:47 -0600 | [diff] [blame] | 170 | #if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC135) |
| 171 | puts("Work-around for Erratum ESDHC135 enabled\n"); |
| 172 | #endif |
Zang Roy-R61911 | 4e0be34 | 2012-09-18 09:50:08 +0000 | [diff] [blame] | 173 | #if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC13) |
| 174 | if (SVR_MAJ(svr) < 3) |
| 175 | puts("Work-around for Erratum ESDHC13 enabled\n"); |
Roy Zang | ae026ff | 2011-01-07 00:24:27 -0600 | [diff] [blame] | 176 | #endif |
Kumar Gala | 5103a03 | 2011-01-29 15:36:10 -0600 | [diff] [blame] | 177 | #if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC_A001) |
| 178 | puts("Work-around for Erratum ESDHC-A001 enabled\n"); |
| 179 | #endif |
Kumar Gala | 1d2c2a6 | 2011-01-13 01:54:01 -0600 | [diff] [blame] | 180 | #ifdef CONFIG_SYS_FSL_ERRATUM_CPC_A002 |
| 181 | puts("Work-around for Erratum CPC-A002 enabled\n"); |
| 182 | #endif |
Kumar Gala | 868da59 | 2011-01-13 01:56:18 -0600 | [diff] [blame] | 183 | #ifdef CONFIG_SYS_FSL_ERRATUM_CPC_A003 |
| 184 | puts("Work-around for Erratum CPC-A003 enabled\n"); |
| 185 | #endif |
Kumar Gala | f133796 | 2011-01-13 02:58:23 -0600 | [diff] [blame] | 186 | #ifdef CONFIG_SYS_FSL_ERRATUM_ELBC_A001 |
| 187 | puts("Work-around for Erratum ELBC-A001 enabled\n"); |
| 188 | #endif |
York Sun | fa8d23c | 2011-01-10 12:03:01 +0000 | [diff] [blame] | 189 | #ifdef CONFIG_SYS_FSL_ERRATUM_DDR_A003 |
| 190 | puts("Work-around for Erratum DDR-A003 enabled\n"); |
| 191 | #endif |
York Sun | eb0aff7 | 2011-01-25 21:51:27 -0800 | [diff] [blame] | 192 | #ifdef CONFIG_SYS_FSL_ERRATUM_DDR_115 |
| 193 | puts("Work-around for Erratum DDR115 enabled\n"); |
| 194 | #endif |
York Sun | 9167191 | 2011-01-25 22:05:49 -0800 | [diff] [blame] | 195 | #ifdef CONFIG_SYS_FSL_ERRATUM_DDR111_DDR134 |
| 196 | puts("Work-around for Erratum DDR111 enabled\n"); |
| 197 | puts("Work-around for Erratum DDR134 enabled\n"); |
| 198 | #endif |
Poonam Aggrwal | 42aee64 | 2011-06-30 03:00:28 -0500 | [diff] [blame] | 199 | #ifdef CONFIG_SYS_FSL_ERRATUM_IFC_A002769 |
| 200 | puts("Work-around for Erratum IFC-A002769 enabled\n"); |
| 201 | #endif |
Poonam Aggrwal | fb855f4 | 2011-06-29 16:32:52 +0530 | [diff] [blame] | 202 | #ifdef CONFIG_SYS_FSL_ERRATUM_P1010_A003549 |
| 203 | puts("Work-around for Erratum P1010-A003549 enabled\n"); |
| 204 | #endif |
Poonam Aggrwal | bc6bbd6 | 2011-07-07 20:36:47 +0530 | [diff] [blame] | 205 | #ifdef CONFIG_SYS_FSL_ERRATUM_IFC_A003399 |
| 206 | puts("Work-around for Erratum IFC A-003399 enabled\n"); |
| 207 | #endif |
Kumar Gala | 5ace299 | 2011-09-16 09:54:30 -0500 | [diff] [blame] | 208 | #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_DDR120 |
| 209 | if ((SVR_MAJ(svr) == 1) || IS_SVR_REV(svr, 2, 0)) |
| 210 | puts("Work-around for Erratum NMG DDR120 enabled\n"); |
| 211 | #endif |
Kumar Gala | 2b3a1cd | 2011-10-03 08:37:57 -0500 | [diff] [blame] | 212 | #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_LBC103 |
| 213 | puts("Work-around for Erratum NMG_LBC103 enabled\n"); |
| 214 | #endif |
chenhui zhao | aada81d | 2011-10-03 08:38:50 -0500 | [diff] [blame] | 215 | #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_ETSEC129 |
| 216 | if ((SVR_MAJ(svr) == 1) || IS_SVR_REV(svr, 2, 0)) |
| 217 | puts("Work-around for Erratum NMG ETSEC129 enabled\n"); |
| 218 | #endif |
Scott Wood | 33eee33 | 2012-08-14 10:14:53 +0000 | [diff] [blame] | 219 | #ifdef CONFIG_SYS_FSL_ERRATUM_A004510 |
| 220 | puts("Work-around for Erratum A004510 enabled\n"); |
| 221 | #endif |
Liu Gang | d59c557 | 2012-09-28 21:26:19 +0000 | [diff] [blame] | 222 | #ifdef CONFIG_SYS_FSL_ERRATUM_SRIO_A004034 |
| 223 | puts("Work-around for Erratum SRIO-A004034 enabled\n"); |
| 224 | #endif |
York Sun | a1d558a | 2012-10-08 07:44:26 +0000 | [diff] [blame] | 225 | #ifdef CONFIG_SYS_FSL_ERRATUM_A_004934 |
| 226 | puts("Work-around for Erratum A004934 enabled\n"); |
| 227 | #endif |
Shengzhou Liu | 72bd83c | 2013-01-23 19:56:23 +0000 | [diff] [blame] | 228 | #ifdef CONFIG_SYS_FSL_ERRATUM_A005871 |
| 229 | if (IS_SVR_REV(svr, 1, 0)) |
| 230 | puts("Work-around for Erratum A005871 enabled\n"); |
| 231 | #endif |
Shaveta Leekha | 7af9a07 | 2014-02-26 16:08:22 +0530 | [diff] [blame] | 232 | #ifdef CONFIG_SYS_FSL_ERRATUM_A006475 |
| 233 | if (SVR_MAJ(get_svr()) == 1) |
| 234 | puts("Work-around for Erratum A006475 enabled\n"); |
| 235 | #endif |
| 236 | #ifdef CONFIG_SYS_FSL_ERRATUM_A006384 |
| 237 | if (SVR_MAJ(get_svr()) == 1) |
| 238 | puts("Work-around for Erratum A006384 enabled\n"); |
| 239 | #endif |
Timur Tabi | 0118033 | 2012-10-25 12:40:00 +0000 | [diff] [blame] | 240 | #ifdef CONFIG_SYS_FSL_ERRATUM_A004849 |
| 241 | /* This work-around is implemented in PBI, so just check for it */ |
| 242 | check_erratum_a4849(svr); |
| 243 | #endif |
Timur Tabi | d607b96 | 2012-11-01 08:20:23 +0000 | [diff] [blame] | 244 | #ifdef CONFIG_SYS_FSL_ERRATUM_A004580 |
| 245 | /* This work-around is implemented in PBI, so just check for it */ |
| 246 | check_erratum_a4580(svr); |
| 247 | #endif |
Yuanquan Chen | c0a4e6b | 2012-11-26 23:49:45 +0000 | [diff] [blame] | 248 | #ifdef CONFIG_SYS_P4080_ERRATUM_PCIE_A003 |
| 249 | puts("Work-around for Erratum PCIe-A003 enabled\n"); |
| 250 | #endif |
Xulei | 99d7b0a | 2013-03-11 17:56:34 +0000 | [diff] [blame] | 251 | #ifdef CONFIG_SYS_FSL_ERRATUM_USB14 |
| 252 | puts("Work-around for Erratum USB14 enabled\n"); |
| 253 | #endif |
Scott Wood | 8212519 | 2013-05-15 17:50:13 -0500 | [diff] [blame] | 254 | #ifdef CONFIG_SYS_FSL_ERRATUM_A006593 |
| 255 | puts("Work-around for Erratum A006593 enabled\n"); |
| 256 | #endif |
York Sun | 133fbfa | 2013-09-16 12:49:31 -0700 | [diff] [blame] | 257 | #ifdef CONFIG_SYS_FSL_ERRATUM_A006379 |
| 258 | if (has_erratum_a006379()) |
| 259 | puts("Work-around for Erratum A006379 enabled\n"); |
| 260 | #endif |
Shengzhou Liu | 424bf94 | 2013-08-15 09:31:47 +0800 | [diff] [blame] | 261 | #ifdef CONFIG_SYS_FSL_ERRATUM_SEC_A003571 |
| 262 | if (IS_SVR_REV(svr, 1, 0)) |
| 263 | puts("Work-around for Erratum A003571 enabled\n"); |
| 264 | #endif |
York Sun | d217a9a | 2013-06-25 11:37:49 -0700 | [diff] [blame] | 265 | #ifdef CONFIG_SYS_FSL_ERRATUM_A005812 |
| 266 | puts("Work-around for Erratum A-005812 enabled\n"); |
| 267 | #endif |
York Sun | 954a1a4 | 2013-08-20 15:09:43 -0700 | [diff] [blame] | 268 | #ifdef CONFIG_SYS_FSL_ERRATUM_A005125 |
| 269 | puts("Work-around for Erratum A005125 enabled\n"); |
| 270 | #endif |
Chunhe Lan | 9c3f77e | 2013-08-16 15:10:37 +0800 | [diff] [blame] | 271 | #ifdef CONFIG_SYS_FSL_ERRATUM_I2C_A004447 |
| 272 | if ((SVR_SOC_VER(svr) == SVR_8548 && IS_SVR_REV(svr, 3, 1)) || |
| 273 | (SVR_REV(svr) <= CONFIG_SYS_FSL_A004447_SVR_REV)) |
| 274 | puts("Work-around for Erratum I2C-A004447 enabled\n"); |
| 275 | #endif |
Suresh Gupta | 9c641a8 | 2014-02-26 14:29:12 +0530 | [diff] [blame] | 276 | #ifdef CONFIG_SYS_FSL_ERRATUM_A006261 |
| 277 | if (has_erratum_a006261()) |
| 278 | puts("Work-around for Erratum A006261 enabled\n"); |
| 279 | #endif |
Kumar Gala | 79ee344 | 2010-06-09 22:59:41 -0500 | [diff] [blame] | 280 | return 0; |
| 281 | } |
| 282 | |
| 283 | U_BOOT_CMD( |
| 284 | errata, 1, 0, do_errata, |
| 285 | "Report errata workarounds", |
| 286 | "" |
| 287 | ); |