hw_des.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. //*****************************************************************************
  2. //
  3. // Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
  4. //
  5. //
  6. // Redistribution and use in source and binary forms, with or without
  7. // modification, are permitted provided that the following conditions
  8. // are met:
  9. //
  10. // Redistributions of source code must retain the above copyright
  11. // notice, this list of conditions and the following disclaimer.
  12. //
  13. // Redistributions in binary form must reproduce the above copyright
  14. // notice, this list of conditions and the following disclaimer in the
  15. // documentation and/or other materials provided with the
  16. // distribution.
  17. //
  18. // Neither the name of Texas Instruments Incorporated nor the names of
  19. // its contributors may be used to endorse or promote products derived
  20. // from this software without specific prior written permission.
  21. //
  22. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  25. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  26. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  27. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  28. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  29. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  30. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  32. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. //
  34. //*****************************************************************************
  35. #ifndef __HW_DES_H__
  36. #define __HW_DES_H__
  37. //*****************************************************************************
  38. //
  39. // The following are defines for the DES_P register offsets.
  40. //
  41. //*****************************************************************************
  42. #define DES_O_KEY3_L 0x00000000 // KEY3 (LSW) for 192-bit key
  43. #define DES_O_KEY3_H 0x00000004 // KEY3 (MSW) for 192-bit key
  44. #define DES_O_KEY2_L 0x00000008 // KEY2 (LSW) for 192-bit key
  45. #define DES_O_KEY2_H 0x0000000C // KEY2 (MSW) for 192-bit key
  46. #define DES_O_KEY1_L 0x00000010 // KEY1 (LSW) for 128-bit
  47. // key/192-bit key
  48. #define DES_O_KEY1_H 0x00000014 // KEY1 (LSW) for 128-bit
  49. // key/192-bit key
  50. #define DES_O_IV_L 0x00000018 // Initialization vector LSW
  51. #define DES_O_IV_H 0x0000001C // Initialization vector MSW
  52. #define DES_O_CTRL 0x00000020
  53. #define DES_O_LENGTH 0x00000024 // Indicates the cryptographic data
  54. // length in bytes for all modes.
  55. // Once processing is started with
  56. // this context this length
  57. // decrements to zero. Data lengths
  58. // up to (2^32 – 1) bytes are
  59. // allowed. A write to this register
  60. // triggers the engine to start
  61. // using this context. For a Host
  62. // read operation these registers
  63. // return all-zeroes.
  64. #define DES_O_DATA_L 0x00000028 // Data register(LSW) to read/write
  65. // encrypted/decrypted data.
  66. #define DES_O_DATA_H 0x0000002C // Data register(MSW) to read/write
  67. // encrypted/decrypted data.
  68. #define DES_O_REVISION 0x00000030
  69. #define DES_O_SYSCONFIG 0x00000034
  70. #define DES_O_SYSSTATUS 0x00000038
  71. #define DES_O_IRQSTATUS 0x0000003C // This register indicates the
  72. // interrupt status. If one of the
  73. // interrupt bits is set the
  74. // interrupt output will be asserted
  75. #define DES_O_IRQENABLE 0x00000040 // This register contains an enable
  76. // bit for each unique interrupt
  77. // generated by the module. It
  78. // matches the layout of
  79. // DES_IRQSTATUS register. An
  80. // interrupt is enabled when the bit
  81. // in this register is set to 1
  82. //******************************************************************************
  83. //
  84. // The following are defines for the bit fields in the DES_O_KEY3_L register.
  85. //
  86. //******************************************************************************
  87. #define DES_KEY3_L_KEY3_L_M 0xFFFFFFFF // data for key3
  88. #define DES_KEY3_L_KEY3_L_S 0
  89. //******************************************************************************
  90. //
  91. // The following are defines for the bit fields in the DES_O_KEY3_H register.
  92. //
  93. //******************************************************************************
  94. #define DES_KEY3_H_KEY3_H_M 0xFFFFFFFF // data for key3
  95. #define DES_KEY3_H_KEY3_H_S 0
  96. //******************************************************************************
  97. //
  98. // The following are defines for the bit fields in the DES_O_KEY2_L register.
  99. //
  100. //******************************************************************************
  101. #define DES_KEY2_L_KEY2_L_M 0xFFFFFFFF // data for key2
  102. #define DES_KEY2_L_KEY2_L_S 0
  103. //******************************************************************************
  104. //
  105. // The following are defines for the bit fields in the DES_O_KEY2_H register.
  106. //
  107. //******************************************************************************
  108. #define DES_KEY2_H_KEY2_H_M 0xFFFFFFFF // data for key2
  109. #define DES_KEY2_H_KEY2_H_S 0
  110. //******************************************************************************
  111. //
  112. // The following are defines for the bit fields in the DES_O_KEY1_L register.
  113. //
  114. //******************************************************************************
  115. #define DES_KEY1_L_KEY1_L_M 0xFFFFFFFF // data for key1
  116. #define DES_KEY1_L_KEY1_L_S 0
  117. //******************************************************************************
  118. //
  119. // The following are defines for the bit fields in the DES_O_KEY1_H register.
  120. //
  121. //******************************************************************************
  122. #define DES_KEY1_H_KEY1_H_M 0xFFFFFFFF // data for key1
  123. #define DES_KEY1_H_KEY1_H_S 0
  124. //******************************************************************************
  125. //
  126. // The following are defines for the bit fields in the DES_O_IV_L register.
  127. //
  128. //******************************************************************************
  129. #define DES_IV_L_IV_L_M 0xFFFFFFFF // initialization vector for CBC
  130. // CFB modes
  131. #define DES_IV_L_IV_L_S 0
  132. //******************************************************************************
  133. //
  134. // The following are defines for the bit fields in the DES_O_IV_H register.
  135. //
  136. //******************************************************************************
  137. #define DES_IV_H_IV_H_M 0xFFFFFFFF // initialization vector for CBC
  138. // CFB modes
  139. #define DES_IV_H_IV_H_S 0
  140. //******************************************************************************
  141. //
  142. // The following are defines for the bit fields in the DES_O_CTRL register.
  143. //
  144. //******************************************************************************
  145. #define DES_CTRL_CONTEXT 0x80000000 // If ‘1’ this read-only status bit
  146. // indicates that the context data
  147. // registers can be overwritten and
  148. // the host is permitted to write
  149. // the next context.
  150. #define DES_CTRL_MODE_M 0x00000030 // Select CBC ECB or CFB mode 0x0
  151. // ecb mode 0x1 cbc mode 0x2 cfb
  152. // mode 0x3 reserved
  153. #define DES_CTRL_MODE_S 4
  154. #define DES_CTRL_TDES 0x00000008 // Select DES or triple DES
  155. // encryption/decryption. 0 des mode
  156. // 1 tdes mode
  157. #define DES_CTRL_DIRECTION 0x00000004 // select encryption/decryption 0
  158. // decryption is selected 1
  159. // Encryption is selected
  160. #define DES_CTRL_INPUT_READY 0x00000002 // When '1' ready to
  161. // encrypt/decrypt data
  162. #define DES_CTRL_OUTPUT_READY 0x00000001 // When '1' Data
  163. // decrypted/encrypted ready
  164. //******************************************************************************
  165. //
  166. // The following are defines for the bit fields in the DES_O_LENGTH register.
  167. //
  168. //******************************************************************************
  169. #define DES_LENGTH_LENGTH_M 0xFFFFFFFF
  170. #define DES_LENGTH_LENGTH_S 0
  171. //******************************************************************************
  172. //
  173. // The following are defines for the bit fields in the DES_O_DATA_L register.
  174. //
  175. //******************************************************************************
  176. #define DES_DATA_L_DATA_L_M 0xFFFFFFFF // data for encryption/decryption
  177. #define DES_DATA_L_DATA_L_S 0
  178. //******************************************************************************
  179. //
  180. // The following are defines for the bit fields in the DES_O_DATA_H register.
  181. //
  182. //******************************************************************************
  183. #define DES_DATA_H_DATA_H_M 0xFFFFFFFF // data for encryption/decryption
  184. #define DES_DATA_H_DATA_H_S 0
  185. //******************************************************************************
  186. //
  187. // The following are defines for the bit fields in the DES_O_REVISION register.
  188. //
  189. //******************************************************************************
  190. #define DES_REVISION_SCHEME_M 0xC0000000
  191. #define DES_REVISION_SCHEME_S 30
  192. #define DES_REVISION_FUNC_M 0x0FFF0000 // Function indicates a software
  193. // compatible module family. If
  194. // there is no level of software
  195. // compatibility a new Func number
  196. // (and hence REVISION) should be
  197. // assigned.
  198. #define DES_REVISION_FUNC_S 16
  199. #define DES_REVISION_R_RTL_M 0x0000F800 // RTL Version (R) maintained by IP
  200. // design owner. RTL follows a
  201. // numbering such as X.Y.R.Z which
  202. // are explained in this table. R
  203. // changes ONLY when: (1) PDS
  204. // uploads occur which may have been
  205. // due to spec changes (2) Bug fixes
  206. // occur (3) Resets to '0' when X or
  207. // Y changes. Design team has an
  208. // internal 'Z' (customer invisible)
  209. // number which increments on every
  210. // drop that happens due to DV and
  211. // RTL updates. Z resets to 0 when R
  212. // increments.
  213. #define DES_REVISION_R_RTL_S 11
  214. #define DES_REVISION_X_MAJOR_M \
  215. 0x00000700 // Major Revision (X) maintained by
  216. // IP specification owner. X changes
  217. // ONLY when: (1) There is a major
  218. // feature addition. An example
  219. // would be adding Master Mode to
  220. // Utopia Level2. The Func field (or
  221. // Class/Type in old PID format)
  222. // will remain the same. X does NOT
  223. // change due to: (1) Bug fixes (2)
  224. // Change in feature parameters.
  225. #define DES_REVISION_X_MAJOR_S 8
  226. #define DES_REVISION_CUSTOM_M 0x000000C0
  227. #define DES_REVISION_CUSTOM_S 6
  228. #define DES_REVISION_Y_MINOR_M \
  229. 0x0000003F // Minor Revision (Y) maintained by
  230. // IP specification owner. Y changes
  231. // ONLY when: (1) Features are
  232. // scaled (up or down). Flexibility
  233. // exists in that this feature
  234. // scalability may either be
  235. // represented in the Y change or a
  236. // specific register in the IP that
  237. // indicates which features are
  238. // exactly available. (2) When
  239. // feature creeps from Is-Not list
  240. // to Is list. But this may not be
  241. // the case once it sees silicon; in
  242. // which case X will change. Y does
  243. // NOT change due to: (1) Bug fixes
  244. // (2) Typos or clarifications (3)
  245. // major functional/feature
  246. // change/addition/deletion. Instead
  247. // these changes may be reflected
  248. // via R S X as applicable. Spec
  249. // owner maintains a
  250. // customer-invisible number 'S'
  251. // which changes due to: (1)
  252. // Typos/clarifications (2) Bug
  253. // documentation. Note that this bug
  254. // is not due to a spec change but
  255. // due to implementation.
  256. // Nevertheless the spec tracks the
  257. // IP bugs. An RTL release (say for
  258. // silicon PG1.1) that occurs due to
  259. // bug fix should document the
  260. // corresponding spec number (X.Y.S)
  261. // in its release notes.
  262. #define DES_REVISION_Y_MINOR_S 0
  263. //******************************************************************************
  264. //
  265. // The following are defines for the bit fields in the DES_O_SYSCONFIG register.
  266. //
  267. //******************************************************************************
  268. #define DES_SYSCONFIG_DMA_REQ_CONTEXT_IN_EN \
  269. 0x00000080 // If set to ‘1’ the DMA context
  270. // request is enabled. 0 Dma
  271. // disabled 1 Dma enabled
  272. #define DES_SYSCONFIG_DMA_REQ_DATA_OUT_EN \
  273. 0x00000040 // If set to ‘1’ the DMA output
  274. // request is enabled. 0 Dma
  275. // disabled 1 Dma enabled
  276. #define DES_SYSCONFIG_DMA_REQ_DATA_IN_EN \
  277. 0x00000020 // If set to ‘1’ the DMA input
  278. // request is enabled. 0 Dma
  279. // disabled 1 Dma enabled
  280. //******************************************************************************
  281. //
  282. // The following are defines for the bit fields in the DES_O_SYSSTATUS register.
  283. //
  284. //******************************************************************************
  285. #define DES_SYSSTATUS_RESETDONE \
  286. 0x00000001
  287. //******************************************************************************
  288. //
  289. // The following are defines for the bit fields in the DES_O_IRQSTATUS register.
  290. //
  291. //******************************************************************************
  292. #define DES_IRQSTATUS_DATA_OUT \
  293. 0x00000004 // This bit indicates data output
  294. // interrupt is active and triggers
  295. // the interrupt output.
  296. #define DES_IRQSTATUS_DATA_IN 0x00000002 // This bit indicates data input
  297. // interrupt is active and triggers
  298. // the interrupt output.
  299. #define DES_IRQSTATUS_CONTEX_IN \
  300. 0x00000001 // This bit indicates context
  301. // interrupt is active and triggers
  302. // the interrupt output.
  303. //******************************************************************************
  304. //
  305. // The following are defines for the bit fields in the DES_O_IRQENABLE register.
  306. //
  307. //******************************************************************************
  308. #define DES_IRQENABLE_M_DATA_OUT \
  309. 0x00000004 // If this bit is set to ‘1’ the
  310. // secure data output interrupt is
  311. // enabled.
  312. #define DES_IRQENABLE_M_DATA_IN \
  313. 0x00000002 // If this bit is set to ‘1’ the
  314. // secure data input interrupt is
  315. // enabled.
  316. #define DES_IRQENABLE_M_CONTEX_IN \
  317. 0x00000001 // If this bit is set to ‘1’ the
  318. // secure context interrupt is
  319. // enabled.
  320. #endif // __HW_DES_H__