x1000.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. /*
  2. * File : x1000.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2008 - 2012, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2015-11-19 Urey the first version
  23. */
  24. #ifndef X1000_H__
  25. #define X1000_H__
  26. #ifndef __ASSEMBLY__
  27. // typedef unsigned int size_t;
  28. #define u64 unsigned long long
  29. #define u32 unsigned int
  30. #define u16 unsigned short
  31. #define u8 unsigned char
  32. #define U64 unsigned long long
  33. #define U32 unsigned int
  34. #define U16 unsigned short
  35. #define U8 unsigned char
  36. #define S64 signed long long
  37. #define S32 int
  38. #define S16 short int
  39. #define S8 signed char
  40. #define cache_unroll(base,op) \
  41. __asm__ __volatile__(" \
  42. .set noreorder; \
  43. .set mips3; \
  44. cache %1, (%0); \
  45. .set mips0; \
  46. .set reorder" \
  47. : \
  48. : "r" (base), \
  49. "i" (op));
  50. /* cpu pipeline flush */
  51. static inline void jz_sync(void)
  52. {
  53. __asm__ volatile ("sync");
  54. }
  55. static inline void writeb(u8 value, u32 address)
  56. {
  57. *((volatile u8 *) address) = value;
  58. }
  59. static inline void writew( u16 value, u32 address)
  60. {
  61. *((volatile u16 *) address) = value;
  62. }
  63. static inline void writel(u32 value, u32 address)
  64. {
  65. *((volatile u32 *) address) = value;
  66. }
  67. static inline u8 readb(u32 address)
  68. {
  69. return *((volatile u8 *)address);
  70. }
  71. static inline u16 readw(u32 address)
  72. {
  73. return *((volatile u16 *)address);
  74. }
  75. static inline u32 readl(u32 address)
  76. {
  77. return *((volatile u32 *)address);
  78. }
  79. static inline void jz_writeb(u32 address, u8 value)
  80. {
  81. *((volatile u8 *)address) = value;
  82. }
  83. static inline void jz_writew(u32 address, u16 value)
  84. {
  85. *((volatile u16 *)address) = value;
  86. }
  87. static inline void jz_writel(u32 address, u32 value)
  88. {
  89. *((volatile u32 *)address) = value;
  90. }
  91. static inline u8 jz_readb(u32 address)
  92. {
  93. return *((volatile u8 *)address);
  94. }
  95. static inline u16 jz_readw(u32 address)
  96. {
  97. return *((volatile u16 *)address);
  98. }
  99. static inline u32 jz_readl(u32 address)
  100. {
  101. return *((volatile u32 *)address);
  102. }
  103. #define REG8(addr) *((volatile u8 *)(addr))
  104. #define REG16(addr) *((volatile u16 *)(addr))
  105. #define REG32(addr) *((volatile u32 *)(addr))
  106. #define BIT(n) (0x01u << (n))
  107. #else
  108. #define REG8(addr) (addr)
  109. #define REG16(addr) (addr)
  110. #define REG32(addr) (addr)
  111. #endif /* !ASSEMBLY */
  112. //----------------------------------------------------------------------
  113. // Register Definitions
  114. //
  115. /* AHB0 BUS Devices Base */
  116. #define HARB0_BASE 0xB3000000
  117. #define EMC_BASE 0xB3010000
  118. #define DDRC_BASE 0xB3020000
  119. #define MDMAC_BASE 0xB3030000
  120. #define LCD_BASE 0xB3050000
  121. #define TVE_BASE 0xB3050000
  122. #define SLCD_BASE 0xB3050000
  123. #define CIM_BASE 0xB3060000
  124. #define IPU_BASE 0xB3080000
  125. /* AHB1 BUS Devices Base */
  126. #define HARB1_BASE 0xB3200000
  127. #define DMAGP0_BASE 0xB3210000
  128. #define DMAGP1_BASE 0xB3220000
  129. #define DMAGP2_BASE 0xB3230000
  130. #define MC_BASE 0xB3250000
  131. #define ME_BASE 0xB3260000
  132. #define DEBLK_BASE 0xB3270000
  133. #define IDCT_BASE 0xB3280000
  134. #define CABAC_BASE 0xB3290000
  135. #define TCSM0_BASE 0xB32B0000
  136. #define TCSM1_BASE 0xB32C0000
  137. #define SRAM_BASE 0xB32D0000
  138. /* AHB2 BUS Devices Base */
  139. #define HARB2_BASE 0xB3400000
  140. #define NEMC_BASE 0xB3410000
  141. #define DMAC_BASE 0xB3420000
  142. #define UHC_BASE 0xB3430000
  143. #define UDC_BASE 0xB3440000
  144. #define GPS_BASE 0xB3480000
  145. #define ETHC_BASE 0xB34B0000
  146. #define BCH_BASE 0xB34D0000
  147. #define MSC0_BASE 0xB3450000
  148. #define MSC1_BASE 0xB3460000
  149. #define MSC2_BASE 0xB3470000
  150. /* APB BUS Devices Base */
  151. #define CPM_BASE 0xB0000000
  152. #define INTC_BASE 0xB0001000
  153. #define TCU_BASE 0xB0002000
  154. #define WDT_BASE 0xB0002000
  155. #define OST_BASE 0xB2000000 /* OS Timer */
  156. #define RTC_BASE 0xB0003000
  157. #define GPIO_BASE 0xB0010000
  158. #define AIC_BASE 0xB0020000
  159. #define DMIC_BASE 0xB0021000
  160. #define ICDC_BASE 0xB0020000
  161. #define UART0_BASE 0xB0030000
  162. #define UART1_BASE 0xB0031000
  163. #define UART2_BASE 0xB0032000
  164. #define UART3_BASE 0xB0033000
  165. #define SCC_BASE 0xB0040000
  166. #define SSI0_BASE 0xB0043000
  167. #define SSI1_BASE 0xB0044000
  168. #define SSI2_BASE 0xB0045000
  169. #define I2C0_BASE 0xB0050000
  170. #define I2C1_BASE 0xB0051000
  171. #define PS2_BASE 0xB0060000
  172. #define SADC_BASE 0xB0070000
  173. #define OWI_BASE 0xB0072000
  174. #define TSSI_BASE 0xB0073000
  175. /* NAND CHIP Base Address*/
  176. #define NEMC_CS1_IOBASE 0Xbb000000
  177. #define NEMC_CS2_IOBASE 0Xba000000
  178. #define NEMC_CS3_IOBASE 0Xb9000000
  179. #define NEMC_CS4_IOBASE 0Xb8000000
  180. #define NEMC_CS5_IOBASE 0Xb7000000
  181. #define NEMC_CS6_IOBASE 0Xb6000000
  182. /*********************************************************************************************************
  183. ** WDT
  184. *********************************************************************************************************/
  185. #define WDT_TDR (WDT_BASE + 0x00)
  186. #define WDT_TCER (WDT_BASE + 0x04)
  187. #define WDT_TCNT (WDT_BASE + 0x08)
  188. #define WDT_TCSR (WDT_BASE + 0x0C)
  189. #define REG_WDT_TDR REG16(WDT_TDR)
  190. #define REG_WDT_TCER REG8(WDT_TCER)
  191. #define REG_WDT_TCNT REG16(WDT_TCNT)
  192. #define REG_WDT_TCSR REG16(WDT_TCSR)
  193. #define WDT_TSCR_WDTSC (1 << 16)
  194. #define WDT_TCSR_PRESCALE_1 (0 << 3)
  195. #define WDT_TCSR_PRESCALE_4 (1 << 3)
  196. #define WDT_TCSR_PRESCALE_16 (2 << 3)
  197. #define WDT_TCSR_PRESCALE_64 (3 << 3)
  198. #define WDT_TCSR_PRESCALE_256 (4 << 3)
  199. #define WDT_TCSR_PRESCALE_1024 (5 << 3)
  200. #define WDT_TCSR_EXT_EN (1 << 2)
  201. #define WDT_TCSR_RTC_EN (1 << 1)
  202. #define WDT_TCSR_PCK_EN (1 << 0)
  203. #define WDT_TCER_TCEN (1 << 0)
  204. /*********************************************************************************************************
  205. ** ÖжÏÔ´
  206. *********************************************************************************************************/
  207. /* INTC (Interrupt Controller) */
  208. #define INTC_ISR(n) (INTC_BASE + 0x00 + (n) * 0x20)
  209. #define INTC_IMR(n) (INTC_BASE + 0x04 + (n) * 0x20)
  210. #define INTC_IMSR(n) (INTC_BASE + 0x08 + (n) * 0x20)
  211. #define INTC_IMCR(n) (INTC_BASE + 0x0c + (n) * 0x20)
  212. #define INTC_IPR(n) (INTC_BASE + 0x10 + (n) * 0x20)
  213. #define REG_INTC_ISR(n) REG32(INTC_ISR((n)))
  214. #define REG_INTC_IMR(n) REG32(INTC_IMR((n)))
  215. #define REG_INTC_IMSR(n) REG32(INTC_IMSR((n)))
  216. #define REG_INTC_IMCR(n) REG32(INTC_IMCR((n)))
  217. #define REG_INTC_IPR(n) REG32(INTC_IPR((n)))
  218. // interrupt controller interrupts
  219. #define IRQ_DMIC 0
  220. #define IRQ_AIC0 1
  221. #define IRQ_RESERVED2 2
  222. #define IRQ_RESERVED3 3
  223. #define IRQ_RESERVED4 4
  224. #define IRQ_RESERVED5 5
  225. #define IRQ_RESERVED6 6
  226. #define IRQ_SFC 7
  227. #define IRQ_SSI0 8
  228. #define IRQ_RESERVED9 9
  229. #define IRQ_PDMA 10
  230. #define IRQ_PDMAD 11
  231. #define IRQ_RESERVED12 12
  232. #define IRQ_RESERVED13 13
  233. #define IRQ_GPIO3 14
  234. #define IRQ_GPIO2 15
  235. #define IRQ_GPIO1 16
  236. #define IRQ_GPIO0 17
  237. #define IRQ_RESERVED18 18
  238. #define IRQ_RESERVED19 19
  239. #define IRQ_RESERVED20 20
  240. #define IRQ_OTG 21
  241. #define IRQ_RESERVED22 22
  242. #define IRQ_AES 23
  243. #define IRQ_RESERVED24 24
  244. #define IRQ_TCU2 25
  245. #define IRQ_TCU1 26
  246. #define IRQ_TCU0 27
  247. #define IRQ_RESERVED28 28
  248. #define IRQ_RESERVED29 29
  249. #define IRQ_CIM 30
  250. #define IRQ_LCD 31
  251. #define IRQ_RTC 32
  252. #define IRQ_RESERVED33 33
  253. #define IRQ_RESERVED34 34
  254. #define IRQ_RESERVED35 35
  255. #define IRQ_MSC1 36
  256. #define IRQ_MSC0 37
  257. #define IRQ_SCC 38
  258. #define IRQ_RESERVED39 39
  259. #define IRQ_PCM0 40
  260. #define IRQ_RESERVED41 41
  261. #define IRQ_RESERVED42 42
  262. #define IRQ_RESERVED43 43
  263. #define IRQ_HARB2 44
  264. #define IRQ_RESERVED45 45
  265. #define IRQ_HARB0 46
  266. #define IRQ_CPM 47
  267. #define IRQ_RESERVED48 48
  268. #define IRQ_UART2 49
  269. #define IRQ_UART1 50
  270. #define IRQ_UART0 51
  271. #define IRQ_DDR 52
  272. #define IRQ_RESERVED53 53
  273. #define IRQ_EFUSE 54
  274. #define IRQ_MAC 55
  275. #define IRQ_RESERVED56 56
  276. #define IRQ_RESERVED57 57
  277. #define IRQ_I2C2 58
  278. #define IRQ_I2C1 59
  279. #define IRQ_I2C0 60
  280. #define IRQ_PDMAM 61
  281. #define IRQ_JPEG 62
  282. #define IRQ_RESERVED63 63
  283. #define IRQ_INTC_MAX 63
  284. #ifndef __ASSEMBLY__
  285. #define __intc_unmask_irq(n) (REG_INTC_IMCR((n)/32) = (1 << ((n)%32)))
  286. #define __intc_mask_irq(n) (REG_INTC_IMSR((n)/32) = (1 << ((n)%32)))
  287. #define __intc_ack_irq(n) (REG_INTC_IPR((n)/32) = (1 << ((n)%32))) /* A dummy ack, as the Pending Register is Read Only. Should we remove __intc_ack_irq() */
  288. #endif /* !__ASSEMBLY__ */
  289. #endif /* _JZ_M150_H_ */