fsl_sec.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. * Common internal memory map for some Freescale SoCs
  3. *
  4. * Copyright 2014 Freescale Semiconductor, Inc.
  5. *
  6. */
  7. #ifndef __FSL_SEC_H
  8. #define __FSL_SEC_H
  9. #include <common.h>
  10. #include <asm/io.h>
  11. #ifdef CONFIG_SYS_FSL_SEC_LE
  12. #define sec_in32(a) in_le32(a)
  13. #define sec_out32(a, v) out_le32(a, v)
  14. #define sec_in16(a) in_le16(a)
  15. #define sec_clrbits32 clrbits_le32
  16. #define sec_setbits32 setbits_le32
  17. #elif defined(CONFIG_SYS_FSL_SEC_BE)
  18. #define sec_in32(a) in_be32(a)
  19. #define sec_out32(a, v) out_be32(a, v)
  20. #define sec_in16(a) in_be16(a)
  21. #define sec_clrbits32 clrbits_be32
  22. #define sec_setbits32 setbits_be32
  23. #else
  24. #error Neither CONFIG_SYS_FSL_SEC_LE nor CONFIG_SYS_FSL_SEC_BE is defined
  25. #endif
  26. /* Security Engine Block (MS = Most Sig., LS = Least Sig.) */
  27. #if CONFIG_SYS_FSL_SEC_COMPAT >= 4
  28. /* RNG4 TRNG test registers */
  29. struct rng4tst {
  30. #define RTMCTL_PRGM 0x00010000 /* 1 -> program mode, 0 -> run mode */
  31. u32 rtmctl; /* misc. control register */
  32. u32 rtscmisc; /* statistical check misc. register */
  33. u32 rtpkrrng; /* poker range register */
  34. #define RTSDCTL_ENT_DLY_MIN 1200
  35. #define RTSDCTL_ENT_DLY_MAX 12800
  36. union {
  37. u32 rtpkrmax; /* PRGM=1: poker max. limit register */
  38. u32 rtpkrsq; /* PRGM=0: poker square calc. result register */
  39. };
  40. #define RTSDCTL_ENT_DLY_SHIFT 16
  41. #define RTSDCTL_ENT_DLY_MASK (0xffff << RTSDCTL_ENT_DLY_SHIFT)
  42. u32 rtsdctl; /* seed control register */
  43. union {
  44. u32 rtsblim; /* PRGM=1: sparse bit limit register */
  45. u32 rttotsam; /* PRGM=0: total samples register */
  46. };
  47. u32 rtfreqmin; /* frequency count min. limit register */
  48. union {
  49. u32 rtfreqmax; /* PRGM=1: freq. count max. limit register */
  50. u32 rtfreqcnt; /* PRGM=0: freq. count register */
  51. };
  52. u32 rsvd1[40];
  53. #define RNG_STATE0_HANDLE_INSTANTIATED 0x00000001
  54. u32 rdsta; /*RNG DRNG Status Register*/
  55. u32 rsvd2[15];
  56. };
  57. typedef struct ccsr_sec {
  58. u32 res0;
  59. u32 mcfgr; /* Master CFG Register */
  60. u8 res1[0x4];
  61. u32 scfgr;
  62. struct {
  63. u32 ms; /* Job Ring LIODN Register, MS */
  64. u32 ls; /* Job Ring LIODN Register, LS */
  65. } jrliodnr[4];
  66. u8 res2[0x2c];
  67. u32 jrstartr; /* Job Ring Start Register */
  68. struct {
  69. u32 ms; /* RTIC LIODN Register, MS */
  70. u32 ls; /* RTIC LIODN Register, LS */
  71. } rticliodnr[4];
  72. u8 res3[0x1c];
  73. u32 decorr; /* DECO Request Register */
  74. struct {
  75. u32 ms; /* DECO LIODN Register, MS */
  76. u32 ls; /* DECO LIODN Register, LS */
  77. } decoliodnr[8];
  78. u8 res4[0x40];
  79. u32 dar; /* DECO Avail Register */
  80. u32 drr; /* DECO Reset Register */
  81. u8 res5[0x4d8];
  82. struct rng4tst rng; /* RNG Registers */
  83. u8 res11[0x8a0];
  84. u32 crnr_ms; /* CHA Revision Number Register, MS */
  85. u32 crnr_ls; /* CHA Revision Number Register, LS */
  86. u32 ctpr_ms; /* Compile Time Parameters Register, MS */
  87. u32 ctpr_ls; /* Compile Time Parameters Register, LS */
  88. u8 res6[0x10];
  89. u32 far_ms; /* Fault Address Register, MS */
  90. u32 far_ls; /* Fault Address Register, LS */
  91. u32 falr; /* Fault Address LIODN Register */
  92. u32 fadr; /* Fault Address Detail Register */
  93. u8 res7[0x4];
  94. u32 csta; /* CAAM Status Register */
  95. u8 res8[0x8];
  96. u32 rvid; /* Run Time Integrity Checking Version ID Reg.*/
  97. u32 ccbvid; /* CHA Cluster Block Version ID Register */
  98. u32 chavid_ms; /* CHA Version ID Register, MS */
  99. u32 chavid_ls; /* CHA Version ID Register, LS */
  100. u32 chanum_ms; /* CHA Number Register, MS */
  101. u32 chanum_ls; /* CHA Number Register, LS */
  102. u32 secvid_ms; /* SEC Version ID Register, MS */
  103. u32 secvid_ls; /* SEC Version ID Register, LS */
  104. u8 res9[0x6020];
  105. u32 qilcr_ms; /* Queue Interface LIODN CFG Register, MS */
  106. u32 qilcr_ls; /* Queue Interface LIODN CFG Register, LS */
  107. u8 res10[0x8fd8];
  108. } ccsr_sec_t;
  109. #define SEC_CTPR_MS_AXI_LIODN 0x08000000
  110. #define SEC_CTPR_MS_QI 0x02000000
  111. #define SEC_CTPR_MS_VIRT_EN_INCL 0x00000001
  112. #define SEC_CTPR_MS_VIRT_EN_POR 0x00000002
  113. #define SEC_RVID_MA 0x0f000000
  114. #define SEC_CHANUM_MS_JRNUM_MASK 0xf0000000
  115. #define SEC_CHANUM_MS_JRNUM_SHIFT 28
  116. #define SEC_CHANUM_MS_DECONUM_MASK 0x0f000000
  117. #define SEC_CHANUM_MS_DECONUM_SHIFT 24
  118. #define SEC_SECVID_MS_IPID_MASK 0xffff0000
  119. #define SEC_SECVID_MS_IPID_SHIFT 16
  120. #define SEC_SECVID_MS_MAJ_REV_MASK 0x0000ff00
  121. #define SEC_SECVID_MS_MAJ_REV_SHIFT 8
  122. #define SEC_CCBVID_ERA_MASK 0xff000000
  123. #define SEC_CCBVID_ERA_SHIFT 24
  124. #define SEC_SCFGR_RDBENABLE 0x00000400
  125. #define SEC_SCFGR_VIRT_EN 0x00008000
  126. #define SEC_CHAVID_LS_RNG_SHIFT 16
  127. #define SEC_CHAVID_RNG_LS_MASK 0x000f0000
  128. #define CONFIG_JRSTARTR_JR0 0x00000001
  129. struct jr_regs {
  130. #ifdef CONFIG_SYS_FSL_SEC_LE
  131. u32 irba_l;
  132. u32 irba_h;
  133. #else
  134. u32 irba_h;
  135. u32 irba_l;
  136. #endif
  137. u32 rsvd1;
  138. u32 irs;
  139. u32 rsvd2;
  140. u32 irsa;
  141. u32 rsvd3;
  142. u32 irja;
  143. #ifdef CONFIG_SYS_FSL_SEC_LE
  144. u32 orba_l;
  145. u32 orba_h;
  146. #else
  147. u32 orba_h;
  148. u32 orba_l;
  149. #endif
  150. u32 rsvd4;
  151. u32 ors;
  152. u32 rsvd5;
  153. u32 orjr;
  154. u32 rsvd6;
  155. u32 orsf;
  156. u32 rsvd7;
  157. u32 jrsta;
  158. u32 rsvd8;
  159. u32 jrint;
  160. u32 jrcfg0;
  161. u32 jrcfg1;
  162. u32 rsvd9;
  163. u32 irri;
  164. u32 rsvd10;
  165. u32 orwi;
  166. u32 rsvd11;
  167. u32 jrcr;
  168. };
  169. int sec_init(void);
  170. #endif
  171. #endif /* __FSL_SEC_H */