at91_matrix.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /*
  2. * Copyright (C) 2009 Jens Scharsig (js_at_ng@scharsoft.de)
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef AT91_MATRIX_H
  7. #define AT91_MATRIX_H
  8. #ifdef __ASSEMBLY__
  9. #if defined(CONFIG_AT91SAM9260) || defined(CONFIG_AT91SAM9G20)
  10. #define AT91_ASM_MATRIX_CSA0 (ATMEL_BASE_MATRIX + 0x11C)
  11. #elif defined(CONFIG_AT91SAM9261)
  12. #define AT91_ASM_MATRIX_CSA0 (ATMEL_BASE_MATRIX + 0x30)
  13. #elif defined(CONFIG_AT91SAM9263)
  14. #define AT91_ASM_MATRIX_CSA0 (ATMEL_BASE_MATRIX + 0x120)
  15. #elif defined(CONFIG_AT91SAM9G45)
  16. #define AT91_ASM_MATRIX_CSA0 (ATMEL_BASE_MATRIX + 0x128)
  17. #else
  18. #error AT91_ASM_MATRIX_CSA0 is not definied for current CPU
  19. #endif
  20. #define AT91_ASM_MATRIX_MCFG ATMEL_BASE_MATRIX
  21. #else
  22. #if defined(CONFIG_AT91SAM9260) || defined(CONFIG_AT91SAM9G20)
  23. #define AT91_MATRIX_MASTERS 6
  24. #define AT91_MATRIX_SLAVES 5
  25. #elif defined(CONFIG_AT91SAM9261)
  26. #define AT91_MATRIX_MASTERS 1
  27. #define AT91_MATRIX_SLAVES 5
  28. #elif defined(CONFIG_AT91SAM9263)
  29. #define AT91_MATRIX_MASTERS 9
  30. #define AT91_MATRIX_SLAVES 7
  31. #elif defined(CONFIG_AT91SAM9G45)
  32. #define AT91_MATRIX_MASTERS 11
  33. #define AT91_MATRIX_SLAVES 8
  34. #else
  35. #error CPU not supported. Please update at91_matrix.h
  36. #endif
  37. typedef struct at91_priority {
  38. u32 a;
  39. u32 b;
  40. } at91_priority_t;
  41. typedef struct at91_matrix {
  42. u32 mcfg[AT91_MATRIX_MASTERS];
  43. #if defined(CONFIG_AT91SAM9261)
  44. u32 scfg[AT91_MATRIX_SLAVES];
  45. u32 res61_1[3];
  46. u32 tcr;
  47. u32 res61_2[2];
  48. u32 csa;
  49. u32 pucr;
  50. u32 res61_3[114];
  51. #else
  52. u32 reserve1[16 - AT91_MATRIX_MASTERS];
  53. u32 scfg[AT91_MATRIX_SLAVES];
  54. u32 reserve2[16 - AT91_MATRIX_SLAVES];
  55. at91_priority_t pr[AT91_MATRIX_SLAVES];
  56. u32 reserve3[32 - (2 * AT91_MATRIX_SLAVES)];
  57. u32 mrcr; /* 0x100 Master Remap Control */
  58. u32 reserve4[3];
  59. #if defined(CONFIG_AT91SAM9G45)
  60. u32 ccr[52]; /* 0x110 - 0x1E0 Chip Configuration */
  61. u32 womr; /* 0x1E4 Write Protect Mode */
  62. u32 wpsr; /* 0x1E8 Write Protect Status */
  63. u32 resg45_1[10];
  64. #elif defined(CONFIG_AT91SAM9260) || defined(CONFIG_AT91SAM9G20)
  65. u32 res60_1[3];
  66. u32 csa;
  67. u32 res60_2[56];
  68. #elif defined(CONFIG_AT91SAM9263)
  69. u32 res63_1;
  70. u32 tcmr;
  71. u32 res63_2[2];
  72. u32 csa[2];
  73. u32 res63_3[54];
  74. #else
  75. u32 reserve5[60];
  76. #endif
  77. #endif
  78. } at91_matrix_t;
  79. #endif /* __ASSEMBLY__ */
  80. #define AT91_MATRIX_CSA_DBPUC 0x00000100
  81. #define AT91_MATRIX_CSA_VDDIOMSEL_1_8V 0x00000000
  82. #define AT91_MATRIX_CSA_VDDIOMSEL_3_3V 0x00010000
  83. #define AT91_MATRIX_CSA_EBI_CS1A 0x00000002
  84. #define AT91_MATRIX_CSA_EBI_CS3A 0x00000008
  85. #define AT91_MATRIX_CSA_EBI_CS4A 0x00000010
  86. #define AT91_MATRIX_CSA_EBI_CS5A 0x00000020
  87. #define AT91_MATRIX_CSA_EBI1_CS2A 0x00000008
  88. #if defined CONFIG_AT91SAM9261
  89. /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */
  90. #define AT91_MATRIX_MCFG_RCB0 (1 << 0)
  91. /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */
  92. #define AT91_MATRIX_MCFG_RCB1 (1 << 1)
  93. #endif
  94. /* Undefined Length Burst Type */
  95. #if defined(CONFIG_AT91SAM9260) || defined(CONFIG_AT91SAM9263) || \
  96. defined(CONFIG_AT91SAM9G45)
  97. #define AT91_MATRIX_MCFG_ULBT_INFINITE 0x00000000
  98. #define AT91_MATRIX_MCFG_ULBT_SINGLE 0x00000001
  99. #define AT91_MATRIX_MCFG_ULBT_FOUR 0x00000002
  100. #define AT91_MATRIX_MCFG_ULBT_EIGHT 0x00000003
  101. #define AT91_MATRIX_MCFG_ULBT_SIXTEEN 0x00000004
  102. #endif
  103. #if defined(CONFIG_AT91SAM9G45)
  104. #define AT91_MATRIX_MCFG_ULBT_THIRTYTWO 0x00000005
  105. #define AT91_MATRIX_MCFG_ULBT_SIXTYFOUR 0x00000006
  106. #define AT91_MATRIX_MCFG_ULBT_128 0x00000007
  107. #endif
  108. /* Default Master Type */
  109. #define AT91_MATRIX_SCFG_DEFMSTR_TYPE_NONE 0x00000000
  110. #define AT91_MATRIX_SCFG_DEFMSTR_TYPE_LAST 0x00010000
  111. #define AT91_MATRIX_SCFG_DEFMSTR_TYPE_FIXED 0x00020000
  112. /* Fixed Index of Default Master */
  113. #if defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9263)
  114. #define AT91_MATRIX_SCFG_FIXED_DEFMSTR(x) ((x & 0xf) << 18)
  115. #elif defined(CONFIG_AT91SAM9261) || defined(CONFIG_AT91SAM9260)
  116. #define AT91_MATRIX_SCFG_FIXED_DEFMSTR(x) ((x & 7) << 18)
  117. #endif
  118. /* Maximum Number of Allowed Cycles for a Burst */
  119. #if defined(CONFIG_AT91SAM9G45)
  120. #define AT91_MATRIX_SCFG_SLOT_CYCLE(x) ((x & 0x1ff) << 0)
  121. #elif defined(CONFIG_AT91SAM9260) || defined(CONFIG_AT91SAM9261) || \
  122. defined(CONFIG_AT91SAM9263)
  123. #define AT91_MATRIX_SCFG_SLOT_CYCLE(x) ((x & 0xff) << 0)
  124. #endif
  125. /* Arbitration Type */
  126. #if defined(CONFIG_AT91SAM9260) || defined(CONFIG_AT91SAM9263)
  127. #define AT91_MATRIX_SCFG_ARBT_ROUND_ROBIN 0x00000000
  128. #define AT91_MATRIX_SCFG_ARBT_FIXED_PRIORITY 0x01000000
  129. #endif
  130. /* Master Remap Control Register */
  131. #if defined(CONFIG_AT91SAM9260) || defined(CONFIG_AT91SAM9263) || \
  132. defined(CONFIG_AT91SAM9G45)
  133. /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */
  134. #define AT91_MATRIX_MRCR_RCB0 (1 << 0)
  135. /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */
  136. #define AT91_MATRIX_MRCR_RCB1 (1 << 1)
  137. #endif
  138. #if defined(CONFIG_AT91SAM9263) || defined(CONFIG_AT91SAM9G45)
  139. #define AT91_MATRIX_MRCR_RCB2 0x00000004
  140. #define AT91_MATRIX_MRCR_RCB3 0x00000008
  141. #define AT91_MATRIX_MRCR_RCB4 0x00000010
  142. #define AT91_MATRIX_MRCR_RCB5 0x00000020
  143. #define AT91_MATRIX_MRCR_RCB6 0x00000040
  144. #define AT91_MATRIX_MRCR_RCB7 0x00000080
  145. #define AT91_MATRIX_MRCR_RCB8 0x00000100
  146. #endif
  147. #if defined(CONFIG_AT91SAM9G45)
  148. #define AT91_MATRIX_MRCR_RCB9 0x00000200
  149. #define AT91_MATRIX_MRCR_RCB10 0x00000400
  150. #define AT91_MATRIX_MRCR_RCB11 0x00000800
  151. #endif
  152. /* TCM Configuration Register */
  153. #if defined(CONFIG_AT91SAM9G45)
  154. /* Size of ITCM enabled memory block */
  155. #define AT91_MATRIX_TCMR_ITCM_0 0x00000000
  156. #define AT91_MATRIX_TCMR_ITCM_32 0x00000040
  157. /* Size of DTCM enabled memory block */
  158. #define AT91_MATRIX_TCMR_DTCM_0 0x00000000
  159. #define AT91_MATRIX_TCMR_DTCM_32 0x00000060
  160. #define AT91_MATRIX_TCMR_DTCM_64 0x00000070
  161. /* Wait state TCM register */
  162. #define AT91_MATRIX_TCMR_TCM_NO_WS 0x00000000
  163. #define AT91_MATRIX_TCMR_TCM_ONE_WS 0x00000800
  164. #endif
  165. #if defined(CONFIG_AT91SAM9263)
  166. /* Size of ITCM enabled memory block */
  167. #define AT91_MATRIX_TCMR_ITCM_0 0x00000000
  168. #define AT91_MATRIX_TCMR_ITCM_16 0x00000005
  169. #define AT91_MATRIX_TCMR_ITCM_32 0x00000006
  170. /* Size of DTCM enabled memory block */
  171. #define AT91_MATRIX_TCMR_DTCM_0 0x00000000
  172. #define AT91_MATRIX_TCMR_DTCM_16 0x00000050
  173. #define AT91_MATRIX_TCMR_DTCM_32 0x00000060
  174. #endif
  175. #if defined(CONFIG_AT91SAM9261)
  176. /* Size of ITCM enabled memory block */
  177. #define AT91_MATRIX_TCMR_ITCM_0 0x00000000
  178. #define AT91_MATRIX_TCMR_ITCM_16 0x00000005
  179. #define AT91_MATRIX_TCMR_ITCM_32 0x00000006
  180. #define AT91_MATRIX_TCMR_ITCM_64 0x00000007
  181. /* Size of DTCM enabled memory block */
  182. #define AT91_MATRIX_TCMR_DTCM_0 0x00000000
  183. #define AT91_MATRIX_TCMR_DTCM_16 0x00000050
  184. #define AT91_MATRIX_TCMR_DTCM_32 0x00000060
  185. #define AT91_MATRIX_TCMR_DTCM_64 0x00000070
  186. #endif
  187. #if defined(CONFIG_AT91SAM9G45)
  188. /* Video Mode Configuration Register */
  189. #define AT91C_MATRIX_VDEC_SEL_OFF 0x00000000
  190. #define AT91C_MATRIX_VDEC_SEL_ON 0x00000001
  191. /* Write Protect Mode Register */
  192. #define AT91_MATRIX_WPMR_WP_WPDIS 0x00000000
  193. #define AT91_MATRIX_WPMR_WP_WPEN 0x00000001
  194. #define AT91_MATRIX_WPMR_WPKEY 0xFFFFFF00 /* Write Protect KEY */
  195. /* Write Protect Status Register */
  196. #define AT91_MATRIX_WPSR_NO_WPV 0x00000000
  197. #define AT91_MATRIX_WPSR_WPV 0x00000001
  198. #define AT91_MATRIX_WPSR_WPVSRC 0x00FFFF00 /* Write Protect Violation Source */
  199. #endif
  200. /* USB Pad Pull-Up Control Register */
  201. #if defined(CONFIG_AT91SAM9261)
  202. #define AT91_MATRIX_USBPUCR_PUON 0x40000000
  203. #endif
  204. #define AT91_MATRIX_PRA_M0(x) ((x & 3) << 0) /* Master 0 Priority Reg. A*/
  205. #define AT91_MATRIX_PRA_M1(x) ((x & 3) << 4) /* Master 1 Priority Reg. A*/
  206. #define AT91_MATRIX_PRA_M2(x) ((x & 3) << 8) /* Master 2 Priority Reg. A*/
  207. #define AT91_MATRIX_PRA_M3(x) ((x & 3) << 12) /* Master 3 Priority Reg. A*/
  208. #define AT91_MATRIX_PRA_M4(x) ((x & 3) << 16) /* Master 4 Priority Reg. A*/
  209. #define AT91_MATRIX_PRA_M5(x) ((x & 3) << 20) /* Master 5 Priority Reg. A*/
  210. #define AT91_MATRIX_PRA_M6(x) ((x & 3) << 24) /* Master 6 Priority Reg. A*/
  211. #define AT91_MATRIX_PRA_M7(x) ((x & 3) << 28) /* Master 7 Priority Reg. A*/
  212. #define AT91_MATRIX_PRB_M8(x) ((x & 3) << 0) /* Master 8 Priority Reg. B) */
  213. #define AT91_MATRIX_PRB_M9(x) ((x & 3) << 4) /* Master 9 Priority Reg. B) */
  214. #define AT91_MATRIX_PRB_M10(x) ((x & 3) << 8) /* Master 10 Priority Reg. B) */
  215. #endif