Commit 69142ab1d90b1eef1d8d6a0137b24a9f75c14b83

Authored by Teo Hall
1 parent 0f6a15d8ad

MLK-19187: imx8qm/imx8qxp Add warning before programming ECC protected fuses

Add a warning message before programming any fuses which are ECC
protected on imx8qm/imx8qxp. Also protect any gaps in fuse indexes

Signed-off-by: Teo Hall <teo.hall@nxp.com>

Showing 1 changed file with 38 additions and 0 deletions Side-by-side Diff

arch/arm/mach-imx/imx8/fuse.c
... ... @@ -8,12 +8,30 @@
8 8 #include <common.h>
9 9 #include <errno.h>
10 10 #include <asm/io.h>
  11 +#include <console.h>
11 12 #include <fuse.h>
12 13 #include <asm/mach-imx/sci/sci.h>
13 14 #include <asm/arch/sys_proto.h>
14 15  
15 16 DECLARE_GLOBAL_DATA_PTR;
16 17  
  18 +
  19 +#define FSL_ECC_WORD_START_1 0x10
  20 +#define FSL_ECC_WORD_END_1 0x10F
  21 +
  22 +#ifdef CONFIG_IMX8QM
  23 +#define FSL_ECC_WORD_START_2 0x1A0
  24 +#define FSL_ECC_WORD_END_2 0x1FF
  25 +#endif
  26 +
  27 +#ifdef CONFIG_IMX8QXP
  28 +#define FSL_ECC_WORD_START_2 0x220
  29 +#define FSL_ECC_WORD_END_2 0x31F
  30 +
  31 +#define FSL_QXP_FUSE_GAP_START 0x110
  32 +#define FSL_QXP_FUSE_GAP_END 0x21F
  33 +#endif
  34 +
17 35 #define FSL_SIP_OTP_READ 0xc200000A
18 36 #define FSL_SIP_OTP_WRITE 0xc200000B
19 37  
... ... @@ -56,6 +74,26 @@
56 74 printf("Invalid bank argument, ONLY bank 0 is supported\n");
57 75 return -EINVAL;
58 76 }
  77 +#ifdef CONFIG_IMX8QXP
  78 + if ((word >= FSL_QXP_FUSE_GAP_START) && (word <= FSL_QXP_FUSE_GAP_END)) {
  79 + printf("Invalid word argument for this SoC\n");
  80 + return -EINVAL;
  81 + }
  82 +#endif
  83 +
  84 + if (((word >= FSL_ECC_WORD_START_1) && (word <= FSL_ECC_WORD_END_1)) ||
  85 + ((word >= FSL_ECC_WORD_START_2) && (word <= FSL_ECC_WORD_END_2)))
  86 + {
  87 + puts("Warning: Words in this index range have ECC protection and\n"
  88 + "can only be programmed once per word. Individual bit operations will\n"
  89 + "be rejected after the first one. \n"
  90 + "\n\n Really program this word? <y/N> \n");
  91 +
  92 + if(!confirm_yesno()) {
  93 + puts("Word programming aborted\n");
  94 + return -EPERM;
  95 + }
  96 + }
59 97  
60 98 #if defined(CONFIG_SMC_FUSE)
61 99 return call_imx_sip(FSL_SIP_OTP_WRITE, (unsigned long)word,\