at91_matrix.h 8.7 KB

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