sama_matrix.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. /*
  2. ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. /**
  14. * @file SAMA5D2x/sama_matrix.h
  15. * @brief SAMA MATRIX support macros and structures.
  16. *
  17. * @addtogroup SAMA5D2x_MATRIX
  18. * @{
  19. */
  20. #ifndef SAMA_MATRIX_H
  21. #define SAMA_MATRIX_H
  22. /*===========================================================================*/
  23. /* Driver constants. */
  24. /*===========================================================================*/
  25. /**
  26. * @name SECURE MATRIX mode macros
  27. * @{
  28. */
  29. /**
  30. * @brief The low area of region is the securable one.
  31. */
  32. #define LOWER_AREA_SECURABLE 0x0u
  33. /**
  34. * @brief The upper area of region is the non-securable one.
  35. */
  36. #define UPPER_AREA_SECURABLE 0x1u
  37. /**
  38. * @brief Securable area is secured for reads.
  39. */
  40. #define SECURE_READ 0x0u
  41. /**
  42. * @brief Securable area is secured for writes.
  43. */
  44. #define SECURE_WRITE 0x0u
  45. /**
  46. * @brief Securable area is non-secured for reads.
  47. */
  48. #define NOT_SECURE_READ 0x1u
  49. /**
  50. * @brief Securable area is non-secured for writes.
  51. */
  52. #define NOT_SECURE_WRITE 0x1u
  53. /**
  54. * @brief Peripheral Securable as secure.
  55. */
  56. #define SECURE_PER FALSE
  57. /**
  58. * @brief Peripheral Securable as not-secure.
  59. */
  60. #define NOT_SECURE_PER TRUE
  61. /** @} */
  62. /**
  63. * @name MASTER TYPE MATRIX macros
  64. * @{
  65. */
  66. /**
  67. * @brief No Default Master.
  68. */
  69. #define NO_DEFAULT_MASTER 0x0u
  70. /**
  71. * @brief Last Default Master.
  72. */
  73. #define LAST_DEFAULT_MASTER 0x1u
  74. /**
  75. * @brief Fixed Default Master.
  76. */
  77. #define FIXED_DEFAULT_MASTER 0x2u
  78. /** @} */
  79. /**
  80. * @name REGION MATRIX MASK macros
  81. * @{
  82. */
  83. /**
  84. * @brief Region 0.
  85. */
  86. #define REGION_0_MSK (0x1u << 0)
  87. /**
  88. * @brief Region 1.
  89. */
  90. #define REGION_1_MSK (0x1u << 1)
  91. /**
  92. * @brief Region 2.
  93. */
  94. #define REGION_2_MSK (0x1u << 2)
  95. /**
  96. * @brief Region 3.
  97. */
  98. #define REGION_3_MSK (0x1u << 3)
  99. /**
  100. * @brief Region 4.
  101. */
  102. #define REGION_4_MSK (0x1u << 4)
  103. /**
  104. * @brief Region 5.
  105. */
  106. #define REGION_5_MSK (0x1u << 5)
  107. /**
  108. * @brief Region 6.
  109. */
  110. #define REGION_6_MSK (0x1u << 6)
  111. /**
  112. * @brief Region 7.
  113. */
  114. #define REGION_7_MSK (0x1u << 7)
  115. /** @} */
  116. /**
  117. * @name REGION MATRIX macros
  118. * @{
  119. */
  120. /**
  121. * @brief Region 0.
  122. */
  123. #define REGION_0 0x0u
  124. /**
  125. * @brief Region 1.
  126. */
  127. #define REGION_1 0x1u
  128. /**
  129. * @brief Region 2.
  130. */
  131. #define REGION_2 0x2u
  132. /**
  133. * @brief Region 3.
  134. */
  135. #define REGION_3 0x3u
  136. /**
  137. * @brief Region 4.
  138. */
  139. #define REGION_4 0x4u
  140. /**
  141. * @brief Region 5.
  142. */
  143. #define REGION_5 0x5u
  144. /**
  145. * @brief Region 6.
  146. */
  147. #define REGION_6 0x6u
  148. /**
  149. * @brief Region 7.
  150. */
  151. #define REGION_7 0x7u
  152. /** @} */
  153. /**
  154. * @name AREA SIZE MATRIX macros
  155. * @{
  156. */
  157. /**
  158. * @brief Area size 4 KB.
  159. */
  160. #define MATRIX_AREA_SIZE_4K 0x0u
  161. /**
  162. * @brief Area size 8 KB.
  163. */
  164. #define MATRIX_AREA_SIZE_8K 0x1u
  165. /**
  166. * @brief Area size 16 KB.
  167. */
  168. #define MATRIX_AREA_SIZE_16K 0x2u
  169. /**
  170. * @brief Area size 32 KB.
  171. */
  172. #define MATRIX_AREA_SIZE_32K 0x3u
  173. /**
  174. * @brief Area size 64 KB.
  175. */
  176. #define MATRIX_AREA_SIZE_64K 0x4u
  177. /**
  178. * @brief Area size 128 KB.
  179. */
  180. #define MATRIX_AREA_SIZE_128K 0x5u
  181. /**
  182. * @brief Area size 256 KB.
  183. */
  184. #define MATRIX_AREA_SIZE_256K 0x6u
  185. /**
  186. * @brief Area size 512 KB.
  187. */
  188. #define MATRIX_AREA_SIZE_512K 0x7u
  189. /**
  190. * @brief Area size 1 MB.
  191. */
  192. #define MATRIX_AREA_SIZE_1M 0x8u
  193. /**
  194. * @brief Area size 2 MB.
  195. */
  196. #define MATRIX_AREA_SIZE_2M 0x9u
  197. /**
  198. * @brief Area size 4 MB.
  199. */
  200. #define MATRIX_AREA_SIZE_4M 0xAu
  201. /**
  202. * @brief Area size 8 MB.
  203. */
  204. #define MATRIX_AREA_SIZE_8M 0xBu
  205. /**
  206. * @brief Area size 16 MB.
  207. */
  208. #define MATRIX_AREA_SIZE_16M 0xCu
  209. /**
  210. * @brief Area size 32 MB.
  211. */
  212. #define MATRIX_AREA_SIZE_32M 0xDu
  213. /**
  214. * @brief Area size 64 MB.
  215. */
  216. #define MATRIX_AREA_SIZE_64M 0xEu
  217. /**
  218. * @brief Area size 128 MB.
  219. */
  220. #define MATRIX_AREA_SIZE_128M 0xFu
  221. /** @} */
  222. /*===========================================================================*/
  223. /* Driver pre-compile time settings. */
  224. /*===========================================================================*/
  225. /*===========================================================================*/
  226. /* Derived constants and error checks. */
  227. /*===========================================================================*/
  228. /*===========================================================================*/
  229. /* Driver data structures and types. */
  230. /*===========================================================================*/
  231. /*===========================================================================*/
  232. /* Driver macros. */
  233. /*===========================================================================*/
  234. /**
  235. * @brief Configure LANSECH per Region.
  236. *
  237. * @param[in] region Region to configure.
  238. * @param[in] lansech Securable mode.
  239. *
  240. * @api
  241. */
  242. #define mtxRegionLansech(region, lansech) (lansech << region)
  243. /**
  244. * @brief Configure RDNSECH per Region.
  245. *
  246. * @param[in] region Region to configure.
  247. * @param[in] rdnsech Read securable mode.
  248. *
  249. * @api
  250. */
  251. #define mtxRegionRdnsech(region, rdnsech) (rdnsech << region)
  252. /**
  253. * @brief Configure WRNSECH per Region.
  254. *
  255. * @param[in] region Region to configure.
  256. * @param[in] wrnsech Write securable mode.
  257. *
  258. * @api
  259. */
  260. #define mtxRegionWrnsech(region, wrnsech) (wrnsech << region)
  261. /*===========================================================================*/
  262. /* External declarations. */
  263. /*===========================================================================*/
  264. #ifdef __cplusplus
  265. extern "C" {
  266. #endif
  267. bool mtxConfigPeriphSecurity(Matrix *mtxp, uint32_t id, bool mode);
  268. void mtxConfigDefaultMaster(Matrix *mtxp, uint8_t slaveID,
  269. uint8_t type, uint8_t masterID);
  270. void mtxConfigSlaveSec(Matrix *mtxp, uint8_t slaveID,
  271. uint8_t selMask, uint8_t readMask,
  272. uint8_t writeMask);
  273. void mtxSetSlaveSplitAddr(Matrix *mtxp, uint8_t slaveID,
  274. uint8_t area, uint8_t mask);
  275. void mtxSetSlaveRegionSize(Matrix *mtxp, uint8_t slaveID,
  276. uint8_t areaSize, uint8_t mask);
  277. void mtxRemapRom(void);
  278. void mtxRemapRam(void);
  279. #ifdef __cplusplus
  280. }
  281. #endif
  282. #endif /* SAMA_MATRIX_H */
  283. /** @} */