x1000.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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. #include "../common/mips.h"
  27. #ifndef __ASSEMBLY__
  28. #define cache_unroll(base,op) \
  29. __asm__ __volatile__(" \
  30. .set noreorder; \
  31. .set mips3; \
  32. cache %1, (%0); \
  33. .set mips0; \
  34. .set reorder" \
  35. : \
  36. : "r" (base), \
  37. "i" (op));
  38. /* cpu pipeline flush */
  39. static inline void jz_sync(void)
  40. {
  41. __asm__ volatile ("sync");
  42. }
  43. static inline void writeb(u8 value, u32 address)
  44. {
  45. *((volatile u8 *) address) = value;
  46. }
  47. static inline void writew( u16 value, u32 address)
  48. {
  49. *((volatile u16 *) address) = value;
  50. }
  51. static inline void writel(u32 value, u32 address)
  52. {
  53. *((volatile u32 *) address) = value;
  54. }
  55. static inline u8 readb(u32 address)
  56. {
  57. return *((volatile u8 *)address);
  58. }
  59. static inline u16 readw(u32 address)
  60. {
  61. return *((volatile u16 *)address);
  62. }
  63. static inline u32 readl(u32 address)
  64. {
  65. return *((volatile u32 *)address);
  66. }
  67. static inline void jz_writeb(u32 address, u8 value)
  68. {
  69. *((volatile u8 *)address) = value;
  70. }
  71. static inline void jz_writew(u32 address, u16 value)
  72. {
  73. *((volatile u16 *)address) = value;
  74. }
  75. static inline void jz_writel(u32 address, u32 value)
  76. {
  77. *((volatile u32 *)address) = value;
  78. }
  79. static inline u8 jz_readb(u32 address)
  80. {
  81. return *((volatile u8 *)address);
  82. }
  83. static inline u16 jz_readw(u32 address)
  84. {
  85. return *((volatile u16 *)address);
  86. }
  87. static inline u32 jz_readl(u32 address)
  88. {
  89. return *((volatile u32 *)address);
  90. }
  91. #define BIT(n) (0x01u << (n))
  92. #define BIT0 (0x01u << 0)
  93. #define BIT1 (0x01u << 1)
  94. #define BIT2 (0x01u << 2)
  95. #define BIT3 (0x01u << 3)
  96. #define BIT4 (0x01u << 4)
  97. #define BIT5 (0x01u << 5)
  98. #define BIT6 (0x01u << 6)
  99. #define BIT7 (0x01u << 7)
  100. #define BIT8 (0x01u << 8)
  101. #define BIT9 (0x01u << 9)
  102. #define BIT10 (0x01u << 10)
  103. #define BIT11 (0x01u << 11)
  104. #define BIT12 (0x01u << 12)
  105. #define BIT13 (0x01u << 13)
  106. #define BIT14 (0x01u << 14)
  107. #define BIT15 (0x01u << 15)
  108. #define BIT16 (0x01u << 16)
  109. #define BIT17 (0x01u << 17)
  110. #define BIT18 (0x01u << 18)
  111. #define BIT19 (0x01u << 19)
  112. #define BIT20 (0x01u << 20)
  113. #define BIT21 (0x01u << 21)
  114. #define BIT22 (0x01u << 22)
  115. #define BIT23 (0x01u << 23)
  116. #define BIT24 (0x01u << 24)
  117. #define BIT25 (0x01u << 25)
  118. #define BIT26 (0x01u << 26)
  119. #define BIT27 (0x01u << 27)
  120. #define BIT28 (0x01u << 28)
  121. #define BIT29 (0x01u << 29)
  122. #define BIT30 (0x01u << 30)
  123. #define BIT31 (0x01u << 31)
  124. /* Generate the bit field mask from msb to lsb */
  125. #define BITS_H2L(msb, lsb) ((0xFFFFFFFF >> (32-((msb)-(lsb)+1))) << (lsb))
  126. /* Get the bit field value from the data which is read from the register */
  127. #define get_bf_value(data, lsb, mask) (((data) & (mask)) >> (lsb))
  128. #endif /* !ASSEMBLY */
  129. //----------------------------------------------------------------------
  130. // Register Definitions
  131. //
  132. /* AHB0 BUS Devices Base */
  133. #define HARB0_BASE 0xB3000000
  134. #define EMC_BASE 0xB3010000
  135. #define DDRC_BASE 0xB3020000
  136. #define MDMAC_BASE 0xB3030000
  137. #define LCD_BASE 0xB3050000
  138. #define TVE_BASE 0xB3050000
  139. #define SLCD_BASE 0xB3050000
  140. #define CIM_BASE 0xB3060000
  141. #define IPU_BASE 0xB3080000
  142. /* AHB1 BUS Devices Base */
  143. #define HARB1_BASE 0xB3200000
  144. #define DMAGP0_BASE 0xB3210000
  145. #define DMAGP1_BASE 0xB3220000
  146. #define DMAGP2_BASE 0xB3230000
  147. #define MC_BASE 0xB3250000
  148. #define ME_BASE 0xB3260000
  149. #define DEBLK_BASE 0xB3270000
  150. #define IDCT_BASE 0xB3280000
  151. #define CABAC_BASE 0xB3290000
  152. #define TCSM0_BASE 0xB32B0000
  153. #define TCSM1_BASE 0xB32C0000
  154. #define SRAM_BASE 0xB32D0000
  155. /* AHB2 BUS Devices Base */
  156. #define HARB2_BASE 0xB3400000
  157. #define NEMC_BASE 0xB3410000
  158. #define DMAC_BASE 0xB3420000
  159. #define UHC_BASE 0xB3430000
  160. //#define UDC_BASE 0xB3440000
  161. #define SFC_BASE 0xB3440000
  162. #define GPS_BASE 0xB3480000
  163. #define ETHC_BASE 0xB34B0000
  164. #define BCH_BASE 0xB34D0000
  165. #define MSC0_BASE 0xB3450000
  166. #define MSC1_BASE 0xB3460000
  167. #define MSC2_BASE 0xB3470000
  168. #define OTG_BASE 0xb3500000
  169. /* APB BUS Devices Base */
  170. #define CPM_BASE 0xB0000000
  171. #define INTC_BASE 0xB0001000
  172. #define TCU_BASE 0xB0002000
  173. #define WDT_BASE 0xB0002000
  174. #define OST_BASE 0xB2000000 /* OS Timer */
  175. #define RTC_BASE 0xB0003000
  176. #define GPIO_BASE 0xB0010000
  177. #define AIC_BASE 0xB0020000
  178. #define DMIC_BASE 0xB0021000
  179. #define ICDC_BASE 0xB0020000
  180. #define UART0_BASE 0xB0030000
  181. #define UART1_BASE 0xB0031000
  182. #define UART2_BASE 0xB0032000
  183. #define SCC_BASE 0xB0040000
  184. #define SSI0_BASE 0xB0043000
  185. #define SSI1_BASE 0xB0044000
  186. #define SSI2_BASE 0xB0045000
  187. #define I2C0_BASE 0xB0050000
  188. #define I2C1_BASE 0xB0051000
  189. #define I2C2_BASE 0xB0052000
  190. #define PS2_BASE 0xB0060000
  191. #define SADC_BASE 0xB0070000
  192. #define OWI_BASE 0xB0072000
  193. #define TSSI_BASE 0xB0073000
  194. /* NAND CHIP Base Address*/
  195. #define NEMC_CS1_IOBASE 0Xbb000000
  196. #define NEMC_CS2_IOBASE 0Xba000000
  197. #define NEMC_CS3_IOBASE 0Xb9000000
  198. #define NEMC_CS4_IOBASE 0Xb8000000
  199. #define NEMC_CS5_IOBASE 0Xb7000000
  200. #define NEMC_CS6_IOBASE 0Xb6000000
  201. /*********************************************************************************************************
  202. ** WDT
  203. *********************************************************************************************************/
  204. #define WDT_TDR (0x00)
  205. #define WDT_TCER (0x04)
  206. #define WDT_TCNT (0x08)
  207. #define WDT_TCSR (0x0C)
  208. #define REG_WDT_TDR REG16(WDT_BASE + WDT_TDR)
  209. #define REG_WDT_TCER REG8(WDT_BASE + WDT_TCER)
  210. #define REG_WDT_TCNT REG16(WDT_BASE + WDT_TCNT)
  211. #define REG_WDT_TCSR REG16(WDT_BASE + WDT_TCSR)
  212. #define WDT_TSCR_WDTSC (1 << 16)
  213. #define WDT_TCSR_PRESCALE_1 (0 << 3)
  214. #define WDT_TCSR_PRESCALE_4 (1 << 3)
  215. #define WDT_TCSR_PRESCALE_16 (2 << 3)
  216. #define WDT_TCSR_PRESCALE_64 (3 << 3)
  217. #define WDT_TCSR_PRESCALE_256 (4 << 3)
  218. #define WDT_TCSR_PRESCALE_1024 (5 << 3)
  219. #define WDT_TCSR_EXT_EN (1 << 2)
  220. #define WDT_TCSR_RTC_EN (1 << 1)
  221. #define WDT_TCSR_PCK_EN (1 << 0)
  222. #define WDT_TCER_TCEN (1 << 0)
  223. /* RTC Reg */
  224. #define RTC_RTCCR (0x00) /* rw, 32, 0x00000081 */
  225. #define RTC_RTCSR (0x04) /* rw, 32, 0x???????? */
  226. #define RTC_RTCSAR (0x08) /* rw, 32, 0x???????? */
  227. #define RTC_RTCGR (0x0c) /* rw, 32, 0x0??????? */
  228. #define RTC_HCR (0x20) /* rw, 32, 0x00000000 */
  229. #define RTC_HWFCR (0x24) /* rw, 32, 0x0000???0 */
  230. #define RTC_HRCR (0x28) /* rw, 32, 0x00000??0 */
  231. #define RTC_HWCR (0x2c) /* rw, 32, 0x00000008 */
  232. #define RTC_HWRSR (0x30) /* rw, 32, 0x00000000 */
  233. #define RTC_HSPR (0x34) /* rw, 32, 0x???????? */
  234. #define RTC_WENR (0x3c) /* rw, 32, 0x00000000 */
  235. #define RTC_CKPCR (0x40) /* rw, 32, 0x00000010 */
  236. #define RTC_OWIPCR (0x44) /* rw, 32, 0x00000010 */
  237. #define RTC_PWRONCR (0x48) /* rw, 32, 0x???????? */
  238. #define RTCCR_WRDY BIT(7)
  239. #define WENR_WEN BIT(31)
  240. #define RECOVERY_SIGNATURE (0x001a1a)
  241. #define REBOOT_SIGNATURE (0x003535)
  242. #define UNMSAK_SIGNATURE (0x7c0000)//do not use these bits
  243. #include "x1000_cpm.h"
  244. #include "x1000_intc.h"
  245. #include "x1000_otg_dwc.h"
  246. #include "x1000_aic.h"
  247. #include "x1000_slcdc.h"
  248. #endif /* _JZ_M150_H_ */