cmd_errata.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2010-2011 Freescale Semiconductor, Inc.
  4. */
  5. #include <common.h>
  6. #include <command.h>
  7. #include <linux/compiler.h>
  8. #include <fsl_errata.h>
  9. #include <asm/processor.h>
  10. #include <fsl_usb.h>
  11. #include "fsl_corenet_serdes.h"
  12. #ifdef CONFIG_SYS_FSL_ERRATUM_A004849
  13. /*
  14. * This work-around is implemented in PBI, so just check to see if the
  15. * work-around was actually applied. To do this, we check for specific data
  16. * at specific addresses in DCSR.
  17. *
  18. * Array offsets[] contains a list of offsets within DCSR. According to the
  19. * erratum document, the value at each offset should be 2.
  20. */
  21. static void check_erratum_a4849(uint32_t svr)
  22. {
  23. void __iomem *dcsr = (void *)CONFIG_SYS_DCSRBAR + 0xb0000;
  24. unsigned int i;
  25. #if defined(CONFIG_ARCH_P2041) || defined(CONFIG_ARCH_P3041)
  26. static const uint8_t offsets[] = {
  27. 0x50, 0x54, 0x58, 0x90, 0x94, 0x98
  28. };
  29. #endif
  30. #ifdef CONFIG_ARCH_P4080
  31. static const uint8_t offsets[] = {
  32. 0x60, 0x64, 0x68, 0x6c, 0xa0, 0xa4, 0xa8, 0xac
  33. };
  34. #endif
  35. uint32_t x108; /* The value that should be at offset 0x108 */
  36. for (i = 0; i < ARRAY_SIZE(offsets); i++) {
  37. if (in_be32(dcsr + offsets[i]) != 2) {
  38. printf("Work-around for Erratum A004849 is not enabled\n");
  39. return;
  40. }
  41. }
  42. #if defined(CONFIG_ARCH_P2041) || defined(CONFIG_ARCH_P3041)
  43. x108 = 0x12;
  44. #endif
  45. #ifdef CONFIG_ARCH_P4080
  46. /*
  47. * For P4080, the erratum document says that the value at offset 0x108
  48. * should be 0x12 on rev2, or 0x1c on rev3.
  49. */
  50. if (SVR_MAJ(svr) == 2)
  51. x108 = 0x12;
  52. if (SVR_MAJ(svr) == 3)
  53. x108 = 0x1c;
  54. #endif
  55. if (in_be32(dcsr + 0x108) != x108) {
  56. printf("Work-around for Erratum A004849 is not enabled\n");
  57. return;
  58. }
  59. /* Everything matches, so the erratum work-around was applied */
  60. printf("Work-around for Erratum A004849 enabled\n");
  61. }
  62. #endif
  63. #ifdef CONFIG_SYS_FSL_ERRATUM_A004580
  64. /*
  65. * This work-around is implemented in PBI, so just check to see if the
  66. * work-around was actually applied. To do this, we check for specific data
  67. * at specific addresses in the SerDes register block.
  68. *
  69. * The work-around says that for each SerDes lane, write BnTTLCRy0 =
  70. * 0x1B00_0001, Register 2 = 0x0088_0000, and Register 3 = 0x4000_0000.
  71. */
  72. static void check_erratum_a4580(uint32_t svr)
  73. {
  74. const serdes_corenet_t __iomem *srds_regs =
  75. (void *)CONFIG_SYS_FSL_CORENET_SERDES_ADDR;
  76. unsigned int lane;
  77. for (lane = 0; lane < SRDS_MAX_LANES; lane++) {
  78. if (serdes_lane_enabled(lane)) {
  79. const struct serdes_lane __iomem *srds_lane =
  80. &srds_regs->lane[serdes_get_lane_idx(lane)];
  81. /*
  82. * Verify that the values we were supposed to write in
  83. * the PBI are actually there. Also, the lower 15
  84. * bits of res4[3] should be the same as the upper 15
  85. * bits of res4[1].
  86. */
  87. if ((in_be32(&srds_lane->ttlcr0) != 0x1b000001) ||
  88. (in_be32(&srds_lane->res4[1]) != 0x880000) ||
  89. (in_be32(&srds_lane->res4[3]) != 0x40000044)) {
  90. printf("Work-around for Erratum A004580 is "
  91. "not enabled\n");
  92. return;
  93. }
  94. }
  95. }
  96. /* Everything matches, so the erratum work-around was applied */
  97. printf("Work-around for Erratum A004580 enabled\n");
  98. }
  99. #endif
  100. #ifdef CONFIG_SYS_FSL_ERRATUM_A007212
  101. /*
  102. * This workaround can be implemented in PBI, or by u-boot.
  103. */
  104. static void check_erratum_a007212(void)
  105. {
  106. u32 __iomem *plldgdcr = (void *)(CONFIG_SYS_DCSRBAR + 0x21c20);
  107. if (in_be32(plldgdcr) & 0x1fe) {
  108. /* check if PLL ratio is set by workaround */
  109. puts("Work-around for Erratum A007212 enabled\n");
  110. }
  111. }
  112. #endif
  113. static int do_errata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  114. {
  115. #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011
  116. extern int enable_cpu_a011_workaround;
  117. #endif
  118. __maybe_unused u32 svr = get_svr();
  119. #if defined(CONFIG_FSL_SATA_V2) && defined(CONFIG_SYS_FSL_ERRATUM_SATA_A001)
  120. if (IS_SVR_REV(svr, 1, 0)) {
  121. switch (SVR_SOC_VER(svr)) {
  122. case SVR_P1013:
  123. case SVR_P1022:
  124. puts("Work-around for Erratum SATA A001 enabled\n");
  125. }
  126. }
  127. #endif
  128. #if defined(CONFIG_SYS_P4080_ERRATUM_SERDES8)
  129. puts("Work-around for Erratum SERDES8 enabled\n");
  130. #endif
  131. #if defined(CONFIG_SYS_P4080_ERRATUM_SERDES9)
  132. puts("Work-around for Erratum SERDES9 enabled\n");
  133. #endif
  134. #if defined(CONFIG_SYS_P4080_ERRATUM_SERDES_A005)
  135. puts("Work-around for Erratum SERDES-A005 enabled\n");
  136. #endif
  137. #if defined(CONFIG_SYS_P4080_ERRATUM_CPU22)
  138. if (SVR_MAJ(svr) < 3)
  139. puts("Work-around for Erratum CPU22 enabled\n");
  140. #endif
  141. #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011
  142. /*
  143. * NMG_CPU_A011 applies to P4080 rev 1.0, 2.0, fixed in 3.0
  144. * also applies to P3041 rev 1.0, 1.1, P2041 rev 1.0, 1.1
  145. * The SVR has been checked by cpu_init_r().
  146. */
  147. if (enable_cpu_a011_workaround)
  148. puts("Work-around for Erratum CPU-A011 enabled\n");
  149. #endif
  150. #if defined(CONFIG_SYS_FSL_ERRATUM_CPU_A003999)
  151. puts("Work-around for Erratum CPU-A003999 enabled\n");
  152. #endif
  153. #if defined(CONFIG_SYS_FSL_ERRATUM_DDR_A003474)
  154. puts("Work-around for Erratum DDR-A003474 enabled\n");
  155. #endif
  156. #if defined(CONFIG_SYS_FSL_ERRATUM_DDR_MSYNC_IN)
  157. puts("Work-around for DDR MSYNC_IN Erratum enabled\n");
  158. #endif
  159. #if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC111)
  160. puts("Work-around for Erratum ESDHC111 enabled\n");
  161. #endif
  162. #ifdef CONFIG_SYS_FSL_ERRATUM_A004468
  163. puts("Work-around for Erratum A004468 enabled\n");
  164. #endif
  165. #if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC135)
  166. puts("Work-around for Erratum ESDHC135 enabled\n");
  167. #endif
  168. #if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC13)
  169. if (SVR_MAJ(svr) < 3)
  170. puts("Work-around for Erratum ESDHC13 enabled\n");
  171. #endif
  172. #if defined(CONFIG_SYS_FSL_ERRATUM_ESDHC_A001)
  173. puts("Work-around for Erratum ESDHC-A001 enabled\n");
  174. #endif
  175. #ifdef CONFIG_SYS_FSL_ERRATUM_CPC_A002
  176. puts("Work-around for Erratum CPC-A002 enabled\n");
  177. #endif
  178. #ifdef CONFIG_SYS_FSL_ERRATUM_CPC_A003
  179. puts("Work-around for Erratum CPC-A003 enabled\n");
  180. #endif
  181. #ifdef CONFIG_SYS_FSL_ERRATUM_ELBC_A001
  182. puts("Work-around for Erratum ELBC-A001 enabled\n");
  183. #endif
  184. #ifdef CONFIG_SYS_FSL_ERRATUM_DDR_A003
  185. puts("Work-around for Erratum DDR-A003 enabled\n");
  186. #endif
  187. #ifdef CONFIG_SYS_FSL_ERRATUM_DDR_115
  188. puts("Work-around for Erratum DDR115 enabled\n");
  189. #endif
  190. #ifdef CONFIG_SYS_FSL_ERRATUM_DDR111_DDR134
  191. puts("Work-around for Erratum DDR111 enabled\n");
  192. puts("Work-around for Erratum DDR134 enabled\n");
  193. #endif
  194. #ifdef CONFIG_SYS_FSL_ERRATUM_IFC_A002769
  195. puts("Work-around for Erratum IFC-A002769 enabled\n");
  196. #endif
  197. #ifdef CONFIG_SYS_FSL_ERRATUM_P1010_A003549
  198. puts("Work-around for Erratum P1010-A003549 enabled\n");
  199. #endif
  200. #ifdef CONFIG_SYS_FSL_ERRATUM_IFC_A003399
  201. puts("Work-around for Erratum IFC A-003399 enabled\n");
  202. #endif
  203. #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_DDR120
  204. if ((SVR_MAJ(svr) == 1) || IS_SVR_REV(svr, 2, 0))
  205. puts("Work-around for Erratum NMG DDR120 enabled\n");
  206. #endif
  207. #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_LBC103
  208. puts("Work-around for Erratum NMG_LBC103 enabled\n");
  209. #endif
  210. #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_ETSEC129
  211. if ((SVR_MAJ(svr) == 1) || IS_SVR_REV(svr, 2, 0))
  212. puts("Work-around for Erratum NMG ETSEC129 enabled\n");
  213. #endif
  214. #ifdef CONFIG_SYS_FSL_ERRATUM_A004508
  215. puts("Work-around for Erratum A004508 enabled\n");
  216. #endif
  217. #ifdef CONFIG_SYS_FSL_ERRATUM_A004510
  218. puts("Work-around for Erratum A004510 enabled\n");
  219. #endif
  220. #ifdef CONFIG_SYS_FSL_ERRATUM_SRIO_A004034
  221. puts("Work-around for Erratum SRIO-A004034 enabled\n");
  222. #endif
  223. #ifdef CONFIG_SYS_FSL_ERRATUM_A_004934
  224. puts("Work-around for Erratum A004934 enabled\n");
  225. #endif
  226. #ifdef CONFIG_SYS_FSL_ERRATUM_A005871
  227. if (IS_SVR_REV(svr, 1, 0))
  228. puts("Work-around for Erratum A005871 enabled\n");
  229. #endif
  230. #ifdef CONFIG_SYS_FSL_ERRATUM_A006475
  231. if (SVR_MAJ(get_svr()) == 1)
  232. puts("Work-around for Erratum A006475 enabled\n");
  233. #endif
  234. #ifdef CONFIG_SYS_FSL_ERRATUM_A006384
  235. if (SVR_MAJ(get_svr()) == 1)
  236. puts("Work-around for Erratum A006384 enabled\n");
  237. #endif
  238. #ifdef CONFIG_SYS_FSL_ERRATUM_A004849
  239. /* This work-around is implemented in PBI, so just check for it */
  240. check_erratum_a4849(svr);
  241. #endif
  242. #ifdef CONFIG_SYS_FSL_ERRATUM_A004580
  243. /* This work-around is implemented in PBI, so just check for it */
  244. check_erratum_a4580(svr);
  245. #endif
  246. #ifdef CONFIG_SYS_P4080_ERRATUM_PCIE_A003
  247. puts("Work-around for Erratum PCIe-A003 enabled\n");
  248. #endif
  249. #ifdef CONFIG_SYS_FSL_ERRATUM_USB14
  250. puts("Work-around for Erratum USB14 enabled\n");
  251. #endif
  252. #ifdef CONFIG_SYS_FSL_ERRATUM_A007186
  253. if (has_erratum_a007186())
  254. puts("Work-around for Erratum A007186 enabled\n");
  255. #endif
  256. #ifdef CONFIG_SYS_FSL_ERRATUM_A006593
  257. puts("Work-around for Erratum A006593 enabled\n");
  258. #endif
  259. #ifdef CONFIG_SYS_FSL_ERRATUM_A006379
  260. if (has_erratum_a006379())
  261. puts("Work-around for Erratum A006379 enabled\n");
  262. #endif
  263. #ifdef CONFIG_SYS_FSL_ERRATUM_SEC_A003571
  264. if (IS_SVR_REV(svr, 1, 0))
  265. puts("Work-around for Erratum A003571 enabled\n");
  266. #endif
  267. #ifdef CONFIG_SYS_FSL_ERRATUM_A005812
  268. puts("Work-around for Erratum A-005812 enabled\n");
  269. #endif
  270. #ifdef CONFIG_SYS_FSL_ERRATUM_A005125
  271. puts("Work-around for Erratum A005125 enabled\n");
  272. #endif
  273. #ifdef CONFIG_SYS_FSL_ERRATUM_A007075
  274. if (has_erratum_a007075())
  275. puts("Work-around for Erratum A007075 enabled\n");
  276. #endif
  277. #ifdef CONFIG_SYS_FSL_ERRATUM_A007798
  278. if (has_erratum_a007798())
  279. puts("Work-around for Erratum A007798 enabled\n");
  280. #endif
  281. #ifdef CONFIG_SYS_FSL_ERRATUM_A004477
  282. if (has_erratum_a004477())
  283. puts("Work-around for Erratum A004477 enabled\n");
  284. #endif
  285. #ifdef CONFIG_SYS_FSL_ERRATUM_I2C_A004447
  286. if ((SVR_SOC_VER(svr) == SVR_8548 && IS_SVR_REV(svr, 3, 1)) ||
  287. (SVR_REV(svr) <= CONFIG_SYS_FSL_A004447_SVR_REV))
  288. puts("Work-around for Erratum I2C-A004447 enabled\n");
  289. #endif
  290. #ifdef CONFIG_SYS_FSL_ERRATUM_A005275
  291. if (has_erratum_a005275())
  292. puts("Work-around for Erratum A005275 enabled\n");
  293. #endif
  294. #ifdef CONFIG_SYS_FSL_ERRATUM_A006261
  295. if (has_erratum_a006261())
  296. puts("Work-around for Erratum A006261 enabled\n");
  297. #endif
  298. #ifdef CONFIG_SYS_FSL_ERRATUM_A007212
  299. check_erratum_a007212();
  300. #endif
  301. #ifdef CONFIG_SYS_FSL_ERRATUM_A005434
  302. puts("Work-around for Erratum A-005434 enabled\n");
  303. #endif
  304. #if defined(CONFIG_SYS_FSL_ERRATUM_A008044) && \
  305. defined(CONFIG_A008044_WORKAROUND)
  306. if (IS_SVR_REV(svr, 1, 0))
  307. puts("Work-around for Erratum A-008044 enabled\n");
  308. #endif
  309. #if defined(CONFIG_SYS_FSL_B4860QDS_XFI_ERR) && \
  310. (defined(CONFIG_TARGET_B4860QDS) || defined(CONFIG_TARGET_B4420QDS))
  311. puts("Work-around for Erratum XFI on B4860QDS enabled\n");
  312. #endif
  313. #ifdef CONFIG_SYS_FSL_ERRATUM_A009663
  314. puts("Work-around for Erratum A009663 enabled\n");
  315. #endif
  316. #ifdef CONFIG_SYS_FSL_ERRATUM_A007907
  317. puts("Work-around for Erratum A007907 enabled\n");
  318. #endif
  319. #ifdef CONFIG_SYS_FSL_ERRATUM_A007815
  320. puts("Work-around for Erratum A007815 enabled\n");
  321. #endif
  322. return 0;
  323. }
  324. U_BOOT_CMD(
  325. errata, 1, 0, do_errata,
  326. "Report errata workarounds",
  327. ""
  328. );