Kumar Gala | 5900ea7 | 2010-06-09 22:59:41 -0500 | [diff] [blame] | 1 | /* |
Jerry Huang | ed41367 | 2011-01-06 23:42:19 -0600 | [diff] [blame] | 2 | * Copyright 2010-2011 Freescale Semiconductor, Inc. |
Kumar Gala | 5900ea7 | 2010-06-09 22:59:41 -0500 | [diff] [blame] | 3 | * |
| 4 | * See file CREDITS for list of people who contributed to this |
| 5 | * project. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License as |
| 9 | * published by the Free Software Foundation; either version 2 of |
| 10 | * the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 20 | * MA 02111-1307 USA |
| 21 | */ |
| 22 | |
| 23 | #include <common.h> |
| 24 | #include <command.h> |
| 25 | #include <linux/compiler.h> |
| 26 | #include <asm/processor.h> |
Timur Tabi | c5355dd | 2012-11-01 08:20:23 +0000 | [diff] [blame] | 27 | #include "fsl_corenet_serdes.h" |
Kumar Gala | 5900ea7 | 2010-06-09 22:59:41 -0500 | [diff] [blame] | 28 | |
Timur Tabi | e3ab8c1 | 2012-10-25 12:40:00 +0000 | [diff] [blame] | 29 | #ifdef CONFIG_SYS_FSL_ERRATUM_A004849 |
| 30 | /* |
| 31 | * This work-around is implemented in PBI, so just check to see if the |
| 32 | * work-around was actually applied. To do this, we check for specific data |
| 33 | * at specific addresses in DCSR. |
| 34 | * |
| 35 | * Array offsets[] contains a list of offsets within DCSR. According to the |
| 36 | * erratum document, the value at each offset should be 2. |
| 37 | */ |
| 38 | static void check_erratum_a4849(uint32_t svr) |
| 39 | { |
| 40 | void __iomem *dcsr = (void *)CONFIG_SYS_DCSRBAR + 0xb0000; |
| 41 | unsigned int i; |
| 42 | |
| 43 | #if defined(CONFIG_PPC_P2041) || defined(CONFIG_PPC_P3041) |
| 44 | static const uint8_t offsets[] = { |
| 45 | 0x50, 0x54, 0x58, 0x90, 0x94, 0x98 |
| 46 | }; |
| 47 | #endif |
| 48 | #ifdef CONFIG_PPC_P4080 |
| 49 | static const uint8_t offsets[] = { |
| 50 | 0x60, 0x64, 0x68, 0x6c, 0xa0, 0xa4, 0xa8, 0xac |
| 51 | }; |
| 52 | #endif |
| 53 | uint32_t x108; /* The value that should be at offset 0x108 */ |
| 54 | |
| 55 | for (i = 0; i < ARRAY_SIZE(offsets); i++) { |
| 56 | if (in_be32(dcsr + offsets[i]) != 2) { |
| 57 | printf("Work-around for Erratum A004849 is not enabled\n"); |
| 58 | return; |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | #if defined(CONFIG_PPC_P2041) || defined(CONFIG_PPC_P3041) |
| 63 | x108 = 0x12; |
| 64 | #endif |
| 65 | |
| 66 | #ifdef CONFIG_PPC_P4080 |
| 67 | /* |
| 68 | * For P4080, the erratum document says that the value at offset 0x108 |
| 69 | * should be 0x12 on rev2, or 0x1c on rev3. |
| 70 | */ |
| 71 | if (SVR_MAJ(svr) == 2) |
| 72 | x108 = 0x12; |
| 73 | if (SVR_MAJ(svr) == 3) |
| 74 | x108 = 0x1c; |
| 75 | #endif |
| 76 | |
| 77 | if (in_be32(dcsr + 0x108) != x108) { |
| 78 | printf("Work-around for Erratum A004849 is not enabled\n"); |
| 79 | return; |
| 80 | } |
| 81 | |
| 82 | /* Everything matches, so the erratum work-around was applied */ |
| 83 | |
| 84 | printf("Work-around for Erratum A004849 enabled\n"); |
| 85 | } |
| 86 | #endif |
| 87 | |
Timur Tabi | c5355dd | 2012-11-01 08:20:23 +0000 | [diff] [blame] | 88 | #ifdef CONFIG_SYS_FSL_ERRATUM_A004580 |
| 89 | /* |
| 90 | * This work-around is implemented in PBI, so just check to see if the |
| 91 | * work-around was actually applied. To do this, we check for specific data |
| 92 | * at specific addresses in the SerDes register block. |
| 93 | * |
| 94 | * The work-around says that for each SerDes lane, write BnTTLCRy0 = |
| 95 | * 0x1B00_0001, Register 2 = 0x0088_0000, and Register 3 = 0x4000_0000. |
| 96 | |
| 97 | */ |
| 98 | static void check_erratum_a4580(uint32_t svr) |
| 99 | { |
| 100 | const serdes_corenet_t __iomem *srds_regs = |
| 101 | (void *)CONFIG_SYS_FSL_CORENET_SERDES_ADDR; |
| 102 | unsigned int lane; |
| 103 | |
| 104 | for (lane = 0; lane < SRDS_MAX_LANES; lane++) { |
| 105 | if (serdes_lane_enabled(lane)) { |
| 106 | const struct serdes_lane __iomem *srds_lane = |
| 107 | &srds_regs->lane[serdes_get_lane_idx(lane)]; |
| 108 | |
| 109 | /* |
| 110 | * Verify that the values we were supposed to write in |
| 111 | * the PBI are actually there. Also, the lower 15 |
| 112 | * bits of res4[3] should be the same as the upper 15 |
| 113 | * bits of res4[1]. |
| 114 | */ |
| 115 | if ((in_be32(&srds_lane->ttlcr0) != 0x1b000001) || |
| 116 | (in_be32(&srds_lane->res4[1]) != 0x880000) || |
| 117 | (in_be32(&srds_lane->res4[3]) != 0x40000044)) { |
| 118 | printf("Work-around for Erratum A004580 is " |
| 119 | "not enabled\n"); |
| 120 | return; |
| 121 | } |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | /* Everything matches, so the erratum work-around was applied */ |
| 126 | |
| 127 | printf("Work-around for Erratum A004580 enabled\n"); |
| 128 | } |
| 129 | #endif |
| 130 | |
Kumar Gala | 5900ea7 | 2010-06-09 22:59:41 -0500 | [diff] [blame] | 131 | static int do_errata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 132 | { |
York Sun | 5315553 | 2012-08-08 18:04:53 +0000 | [diff] [blame] | 133 | #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011 |
| 134 | extern int enable_cpu_a011_workaround; |
| 135 | #endif |
Kumar Gala | 5900ea7 | 2010-06-09 22:59:41 -0500 | [diff] [blame] | 136 | __maybe_unused u32 svr = get_svr(); |
| 137 | |
| 138 | #if defined(CONFIG_FSL_SATA_V2) && defined(CONFIG_FSL_SATA_ERRATUM_A001) |
| 139 | if (IS_SVR_REV(svr, 1, 0)) { |
| 140 | switch (SVR_SOC_VER(svr)) { |
| 141 | case SVR_P1013: |
Kumar Gala | 5900ea7 | 2010-06-09 22:59:41 -0500 | [diff] [blame] | 142 | case SVR_P1022: |
Kumar Gala | 5900ea7 | 2010-06-09 22:59:41 -0500 | [diff] [blame] | 143 | puts("Work-around for Erratum SATA A001 enabled\n"); |
| 144 | } |
| 145 | } |
| 146 | #endif |
| 147 | |
Kumar Gala | 779a532 | 2010-07-13 00:39:46 -0500 | [diff] [blame] | 148 | #if defined(CONFIG_SYS_P4080_ERRATUM_SERDES8) |
| 149 | puts("Work-around for Erratum SERDES8 enabled\n"); |
| 150 | #endif |
Emil Medve | b01c81f | 2010-08-31 22:57:38 -0500 | [diff] [blame] | 151 | #if defined(CONFIG_SYS_P4080_ERRATUM_SERDES9) |
| 152 | puts("Work-around for Erratum SERDES9 enabled\n"); |
| 153 | #endif |
Timur Tabi | 90f381d | 2011-04-01 13:19:36 -0500 | [diff] [blame] | 154 | #if defined(CONFIG_SYS_P4080_ERRATUM_SERDES_A005) |
| 155 | puts("Work-around for Erratum SERDES-A005 enabled\n"); |
| 156 | #endif |
Kumar Gala | 6b245b9 | 2010-05-05 22:35:27 -0500 | [diff] [blame] | 157 | #if defined(CONFIG_SYS_P4080_ERRATUM_CPU22) |
York Sun | d755c83 | 2012-05-07 07:26:45 +0000 | [diff] [blame] | 158 | if (SVR_MAJ(svr) < 3) |
| 159 | puts("Work-around for Erratum CPU22 enabled\n"); |
Kumar Gala | 6b245b9 | 2010-05-05 22:35:27 -0500 | [diff] [blame] | 160 | #endif |
York Sun | 9ed8811 | 2012-05-07 07:26:47 +0000 | [diff] [blame] | 161 | #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011 |
| 162 | /* |
| 163 | * NMG_CPU_A011 applies to P4080 rev 1.0, 2.0, fixed in 3.0 |
| 164 | * also applies to P3041 rev 1.0, 1.1, P2041 rev 1.0, 1.1 |
York Sun | 5315553 | 2012-08-08 18:04:53 +0000 | [diff] [blame] | 165 | * The SVR has been checked by cpu_init_r(). |
York Sun | 9ed8811 | 2012-05-07 07:26:47 +0000 | [diff] [blame] | 166 | */ |
York Sun | 5315553 | 2012-08-08 18:04:53 +0000 | [diff] [blame] | 167 | if (enable_cpu_a011_workaround) |
York Sun | 9ed8811 | 2012-05-07 07:26:47 +0000 | [diff] [blame] | 168 | puts("Work-around for Erratum CPU-A011 enabled\n"); |
| 169 | #endif |
Kumar Gala | 945e59a | 2011-11-22 06:51:15 -0600 | [diff] [blame] | 170 | #if defined(CONFIG_SYS_FSL_ERRATUM_CPU_A003999) |
| 171 | puts("Work-around for Erratum CPU-A003999 enabled\n"); |
| 172 | #endif |
York Sun | df2be19 | 2011-11-20 10:01:35 -0800 | [diff] [blame] | 173 | #if defined(CONFIG_SYS_FSL_ERRATUM_DDR_A003474) |
| 174 | puts("Work-around for Erratum DDR-A003473 enabled\n"); |
| 175 | #endif |
Becky Bruce | 4212f23 | 2010-12-17 17:17:58 -0600 | [diff] [blame] | 176 | #if defined(CONFIG_SYS_FSL_ERRATUM_DDR_MSYNC_IN) |
| 177 | puts("Work-around for DDR MSYNC_IN Erratum enabled\n"); |
| 178 | #endif |
Jerry Huang | ed41367 | 2011-01-06 23:42:19 -0600 | [diff] [blame] | 179 | #if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC111) |
| 180 | puts("Work-around for Erratum ESDHC111 enabled\n"); |
| 181 | #endif |
York Sun | a28496f | 2012-10-08 07:44:25 +0000 | [diff] [blame] | 182 | #ifdef CONFIG_SYS_FSL_ERRATUM_A004468 |
| 183 | puts("Work-around for Erratum A004468 enabled\n"); |
| 184 | #endif |
Roy Zang | 3935661 | 2011-01-07 00:06:47 -0600 | [diff] [blame] | 185 | #if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC135) |
| 186 | puts("Work-around for Erratum ESDHC135 enabled\n"); |
| 187 | #endif |
Zang Roy-R61911 | 8365992 | 2012-09-18 09:50:08 +0000 | [diff] [blame] | 188 | #if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC13) |
| 189 | if (SVR_MAJ(svr) < 3) |
| 190 | puts("Work-around for Erratum ESDHC13 enabled\n"); |
Roy Zang | c65dc4d | 2011-01-07 00:24:27 -0600 | [diff] [blame] | 191 | #endif |
Kumar Gala | 9a878d5 | 2011-01-29 15:36:10 -0600 | [diff] [blame] | 192 | #if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC_A001) |
| 193 | puts("Work-around for Erratum ESDHC-A001 enabled\n"); |
| 194 | #endif |
Kumar Gala | 9780b59 | 2011-01-13 01:54:01 -0600 | [diff] [blame] | 195 | #ifdef CONFIG_SYS_FSL_ERRATUM_CPC_A002 |
| 196 | puts("Work-around for Erratum CPC-A002 enabled\n"); |
| 197 | #endif |
Kumar Gala | 887c0e1 | 2011-01-13 01:56:18 -0600 | [diff] [blame] | 198 | #ifdef CONFIG_SYS_FSL_ERRATUM_CPC_A003 |
| 199 | puts("Work-around for Erratum CPC-A003 enabled\n"); |
| 200 | #endif |
Kumar Gala | 77b37af | 2011-01-13 02:58:23 -0600 | [diff] [blame] | 201 | #ifdef CONFIG_SYS_FSL_ERRATUM_ELBC_A001 |
| 202 | puts("Work-around for Erratum ELBC-A001 enabled\n"); |
| 203 | #endif |
York Sun | 922f40f | 2011-01-10 12:03:01 +0000 | [diff] [blame] | 204 | #ifdef CONFIG_SYS_FSL_ERRATUM_DDR_A003 |
| 205 | puts("Work-around for Erratum DDR-A003 enabled\n"); |
| 206 | #endif |
York Sun | 9aa857b | 2011-01-25 21:51:27 -0800 | [diff] [blame] | 207 | #ifdef CONFIG_SYS_FSL_ERRATUM_DDR_115 |
| 208 | puts("Work-around for Erratum DDR115 enabled\n"); |
| 209 | #endif |
York Sun | c8fc959 | 2011-01-25 22:05:49 -0800 | [diff] [blame] | 210 | #ifdef CONFIG_SYS_FSL_ERRATUM_DDR111_DDR134 |
| 211 | puts("Work-around for Erratum DDR111 enabled\n"); |
| 212 | puts("Work-around for Erratum DDR134 enabled\n"); |
| 213 | #endif |
Poonam Aggrwal | c7664a4 | 2011-06-30 03:00:28 -0500 | [diff] [blame] | 214 | #ifdef CONFIG_SYS_FSL_ERRATUM_IFC_A002769 |
| 215 | puts("Work-around for Erratum IFC-A002769 enabled\n"); |
| 216 | #endif |
Poonam Aggrwal | af54a5f | 2011-06-29 16:32:52 +0530 | [diff] [blame] | 217 | #ifdef CONFIG_SYS_FSL_ERRATUM_P1010_A003549 |
| 218 | puts("Work-around for Erratum P1010-A003549 enabled\n"); |
| 219 | #endif |
Poonam Aggrwal | 46b86ca | 2011-07-07 20:36:47 +0530 | [diff] [blame] | 220 | #ifdef CONFIG_SYS_FSL_ERRATUM_IFC_A003399 |
| 221 | puts("Work-around for Erratum IFC A-003399 enabled\n"); |
| 222 | #endif |
Kumar Gala | 866c6fa | 2011-09-16 09:54:30 -0500 | [diff] [blame] | 223 | #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_DDR120 |
| 224 | if ((SVR_MAJ(svr) == 1) || IS_SVR_REV(svr, 2, 0)) |
| 225 | puts("Work-around for Erratum NMG DDR120 enabled\n"); |
| 226 | #endif |
Kumar Gala | f3339d6 | 2011-10-03 08:37:57 -0500 | [diff] [blame] | 227 | #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_LBC103 |
| 228 | puts("Work-around for Erratum NMG_LBC103 enabled\n"); |
| 229 | #endif |
chenhui zhao | c8caa8a | 2011-10-03 08:38:50 -0500 | [diff] [blame] | 230 | #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_ETSEC129 |
| 231 | if ((SVR_MAJ(svr) == 1) || IS_SVR_REV(svr, 2, 0)) |
| 232 | puts("Work-around for Erratum NMG ETSEC129 enabled\n"); |
| 233 | #endif |
Scott Wood | 8080696 | 2012-08-14 10:14:53 +0000 | [diff] [blame] | 234 | #ifdef CONFIG_SYS_FSL_ERRATUM_A004510 |
| 235 | puts("Work-around for Erratum A004510 enabled\n"); |
| 236 | #endif |
Liu Gang | 712b662 | 2012-09-28 21:26:19 +0000 | [diff] [blame] | 237 | #ifdef CONFIG_SYS_FSL_ERRATUM_SRIO_A004034 |
| 238 | puts("Work-around for Erratum SRIO-A004034 enabled\n"); |
| 239 | #endif |
York Sun | 6995a02 | 2012-10-08 07:44:26 +0000 | [diff] [blame] | 240 | #ifdef CONFIG_SYS_FSL_ERRATUM_A_004934 |
| 241 | puts("Work-around for Erratum A004934 enabled\n"); |
| 242 | #endif |
Shengzhou Liu | 95bd8e5 | 2013-01-23 19:56:23 +0000 | [diff] [blame] | 243 | #ifdef CONFIG_SYS_FSL_ERRATUM_A005871 |
| 244 | if (IS_SVR_REV(svr, 1, 0)) |
| 245 | puts("Work-around for Erratum A005871 enabled\n"); |
| 246 | #endif |
Timur Tabi | e3ab8c1 | 2012-10-25 12:40:00 +0000 | [diff] [blame] | 247 | #ifdef CONFIG_SYS_FSL_ERRATUM_A004849 |
| 248 | /* This work-around is implemented in PBI, so just check for it */ |
| 249 | check_erratum_a4849(svr); |
| 250 | #endif |
Timur Tabi | c5355dd | 2012-11-01 08:20:23 +0000 | [diff] [blame] | 251 | #ifdef CONFIG_SYS_FSL_ERRATUM_A004580 |
| 252 | /* This work-around is implemented in PBI, so just check for it */ |
| 253 | check_erratum_a4580(svr); |
| 254 | #endif |
Yuanquan Chen | c48234e | 2012-11-26 23:49:45 +0000 | [diff] [blame] | 255 | #ifdef CONFIG_SYS_P4080_ERRATUM_PCIE_A003 |
| 256 | puts("Work-around for Erratum PCIe-A003 enabled\n"); |
| 257 | #endif |
Xulei | cf4f493 | 2013-03-11 17:56:34 +0000 | [diff] [blame] | 258 | #ifdef CONFIG_SYS_FSL_ERRATUM_USB14 |
| 259 | puts("Work-around for Erratum USB14 enabled\n"); |
| 260 | #endif |
Kumar Gala | 5900ea7 | 2010-06-09 22:59:41 -0500 | [diff] [blame] | 261 | return 0; |
| 262 | } |
| 263 | |
| 264 | U_BOOT_CMD( |
| 265 | errata, 1, 0, do_errata, |
| 266 | "Report errata workarounds", |
| 267 | "" |
| 268 | ); |