adp-ag101p.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. /*
  2. * Copyright (C) 2011 Andes Technology Corporation
  3. * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
  4. * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #ifndef __CONFIG_H
  9. #define __CONFIG_H
  10. #include <asm/arch-ag101/ag101.h>
  11. /*
  12. * CPU and Board Configuration Options
  13. */
  14. #define CONFIG_ADP_AG101P
  15. #define CONFIG_USE_INTERRUPT
  16. #define CONFIG_SKIP_LOWLEVEL_INIT
  17. #define CONFIG_SYS_GENERIC_GLOBAL_DATA
  18. /*
  19. * Definitions related to passing arguments to kernel.
  20. */
  21. #define CONFIG_CMDLINE_TAG /* send commandline to Kernel */
  22. #define CONFIG_SETUP_MEMORY_TAGS /* send memory definition to kernel */
  23. #define CONFIG_INITRD_TAG /* send initrd params */
  24. #ifndef CONFIG_SKIP_LOWLEVEL_INIT
  25. #define CONFIG_MEM_REMAP
  26. #endif
  27. #ifdef CONFIG_SKIP_LOWLEVEL_INIT
  28. #define CONFIG_SYS_TEXT_BASE 0x00500000
  29. #else
  30. #ifdef CONFIG_MEM_REMAP
  31. #define CONFIG_SYS_TEXT_BASE 0x80000000
  32. #else
  33. #define CONFIG_SYS_TEXT_BASE 0x00000000
  34. #endif
  35. #endif
  36. /*
  37. * Timer
  38. */
  39. #define CONFIG_SYS_CLK_FREQ 39062500
  40. #define VERSION_CLOCK CONFIG_SYS_CLK_FREQ
  41. /*
  42. * Use Externel CLOCK or PCLK
  43. */
  44. #undef CONFIG_FTRTC010_EXTCLK
  45. #ifndef CONFIG_FTRTC010_EXTCLK
  46. #define CONFIG_FTRTC010_PCLK
  47. #endif
  48. #ifdef CONFIG_FTRTC010_EXTCLK
  49. #define TIMER_CLOCK 32768 /* CONFIG_FTRTC010_EXTCLK */
  50. #else
  51. #define TIMER_CLOCK CONFIG_SYS_HZ /* CONFIG_FTRTC010_PCLK */
  52. #endif
  53. #define TIMER_LOAD_VAL 0xffffffff
  54. /*
  55. * Real Time Clock
  56. */
  57. #define CONFIG_RTC_FTRTC010
  58. /*
  59. * Real Time Clock Divider
  60. * RTC_DIV_COUNT (OSC_CLK/OSC_5MHZ)
  61. */
  62. #define OSC_5MHZ (5*1000000)
  63. #define OSC_CLK (4*OSC_5MHZ)
  64. #define RTC_DIV_COUNT (0.5) /* Why?? */
  65. /*
  66. * Serial console configuration
  67. */
  68. /* FTUART is a high speed NS 16C550A compatible UART, addr: 0x99600000 */
  69. #define CONFIG_BAUDRATE 38400
  70. #define CONFIG_CONS_INDEX 1
  71. #define CONFIG_SYS_NS16550_SERIAL
  72. #define CONFIG_SYS_NS16550_COM1 CONFIG_FTUART010_02_BASE
  73. #define CONFIG_SYS_NS16550_REG_SIZE -4
  74. #define CONFIG_SYS_NS16550_CLK ((18432000 * 20) / 25) /* AG101P */
  75. /*
  76. * Ethernet
  77. */
  78. #define CONFIG_FTMAC100
  79. /*
  80. * SD (MMC) controller
  81. */
  82. #define CONFIG_GENERIC_MMC
  83. #define CONFIG_DOS_PARTITION
  84. #define CONFIG_FTSDC010
  85. #define CONFIG_FTSDC010_NUMBER 1
  86. #define CONFIG_FTSDC010_SDIO
  87. /*
  88. * Command line configuration.
  89. */
  90. #define CONFIG_CMD_DATE
  91. /*
  92. * Miscellaneous configurable options
  93. */
  94. #define CONFIG_SYS_LONGHELP /* undef to save memory */
  95. #define CONFIG_SYS_CBSIZE 256 /* Console I/O Buffer Size */
  96. /* Print Buffer Size */
  97. #define CONFIG_SYS_PBSIZE \
  98. (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
  99. /* max number of command args */
  100. #define CONFIG_SYS_MAXARGS 16
  101. /* Boot Argument Buffer Size */
  102. #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
  103. /*
  104. * Size of malloc() pool
  105. */
  106. /* 512kB is suggested, (CONFIG_ENV_SIZE + 128 * 1024) was not enough */
  107. #define CONFIG_SYS_MALLOC_LEN (512 << 10)
  108. /*
  109. * AHB Controller configuration
  110. */
  111. #define CONFIG_FTAHBC020S
  112. #ifdef CONFIG_FTAHBC020S
  113. #include <faraday/ftahbc020s.h>
  114. /* Address of PHYS_SDRAM_0 before memory remap is at 0x(100)00000 */
  115. #define CONFIG_SYS_FTAHBC020S_SLAVE_BSR_BASE 0x100
  116. /*
  117. * CONFIG_SYS_FTAHBC020S_SLAVE_BSR_6: this define is used in lowlevel_init.S,
  118. * hence we cannot use FTAHBC020S_BSR_SIZE(2048) since it will use ffs() wrote
  119. * in C language.
  120. */
  121. #define CONFIG_SYS_FTAHBC020S_SLAVE_BSR_6 \
  122. (FTAHBC020S_SLAVE_BSR_BASE(CONFIG_SYS_FTAHBC020S_SLAVE_BSR_BASE) | \
  123. FTAHBC020S_SLAVE_BSR_SIZE(0xb))
  124. #endif
  125. /*
  126. * Watchdog
  127. */
  128. #define CONFIG_FTWDT010_WATCHDOG
  129. /*
  130. * PMU Power controller configuration
  131. */
  132. #define CONFIG_PMU
  133. #define CONFIG_FTPMU010_POWER
  134. #ifdef CONFIG_FTPMU010_POWER
  135. #include <faraday/ftpmu010.h>
  136. #define CONFIG_SYS_FTPMU010_PDLLCR0_HCLKOUTDIS 0x0E
  137. #define CONFIG_SYS_FTPMU010_SDRAMHTC (FTPMU010_SDRAMHTC_EBICTRL_DCSR | \
  138. FTPMU010_SDRAMHTC_EBIDATA_DCSR | \
  139. FTPMU010_SDRAMHTC_SDRAMCS_DCSR | \
  140. FTPMU010_SDRAMHTC_SDRAMCTL_DCSR | \
  141. FTPMU010_SDRAMHTC_CKE_DCSR | \
  142. FTPMU010_SDRAMHTC_DQM_DCSR | \
  143. FTPMU010_SDRAMHTC_SDCLK_DCSR)
  144. #endif
  145. /*
  146. * SDRAM controller configuration
  147. */
  148. #define CONFIG_FTSDMC021
  149. #ifdef CONFIG_FTSDMC021
  150. #include <faraday/ftsdmc021.h>
  151. #define CONFIG_SYS_FTSDMC021_TP1 (FTSDMC021_TP1_TRAS(2) | \
  152. FTSDMC021_TP1_TRP(1) | \
  153. FTSDMC021_TP1_TRCD(1) | \
  154. FTSDMC021_TP1_TRF(3) | \
  155. FTSDMC021_TP1_TWR(1) | \
  156. FTSDMC021_TP1_TCL(2))
  157. #define CONFIG_SYS_FTSDMC021_TP2 (FTSDMC021_TP2_INI_PREC(4) | \
  158. FTSDMC021_TP2_INI_REFT(8) | \
  159. FTSDMC021_TP2_REF_INTV(0x180))
  160. /*
  161. * CONFIG_SYS_FTSDMC021_CR1: this define is used in lowlevel_init.S,
  162. * hence we cannot use FTSDMC021_BANK_SIZE(64) since it will use ffs() wrote in
  163. * C language.
  164. */
  165. #define CONFIG_SYS_FTSDMC021_CR1 (FTSDMC021_CR1_DDW(2) | \
  166. FTSDMC021_CR1_DSZ(3) | \
  167. FTSDMC021_CR1_MBW(2) | \
  168. FTSDMC021_CR1_BNKSIZE(6))
  169. #define CONFIG_SYS_FTSDMC021_CR2 (FTSDMC021_CR2_IPREC | \
  170. FTSDMC021_CR2_IREF | \
  171. FTSDMC021_CR2_ISMR)
  172. #define CONFIG_SYS_FTSDMC021_BANK0_BASE CONFIG_SYS_FTAHBC020S_SLAVE_BSR_BASE
  173. #define CONFIG_SYS_FTSDMC021_BANK0_BSR (FTSDMC021_BANK_ENABLE | \
  174. CONFIG_SYS_FTSDMC021_BANK0_BASE)
  175. #define CONFIG_SYS_FTSDMC021_BANK1_BASE \
  176. (CONFIG_SYS_FTAHBC020S_SLAVE_BSR_BASE + (PHYS_SDRAM_0_SIZE >> 20))
  177. #define CONFIG_SYS_FTSDMC021_BANK1_BSR (FTSDMC021_BANK_ENABLE | \
  178. CONFIG_SYS_FTSDMC021_BANK1_BASE)
  179. #endif
  180. /*
  181. * Physical Memory Map
  182. */
  183. #ifdef CONFIG_SKIP_LOWLEVEL_INIT
  184. #define PHYS_SDRAM_0 0x00000000 /* SDRAM Bank #1 */
  185. #else
  186. #ifdef CONFIG_MEM_REMAP
  187. #define PHYS_SDRAM_0 0x00000000 /* SDRAM Bank #1 */
  188. #else
  189. #define PHYS_SDRAM_0 0x80000000 /* SDRAM Bank #1 */
  190. #endif
  191. #endif
  192. #define PHYS_SDRAM_1 \
  193. (PHYS_SDRAM_0 + PHYS_SDRAM_0_SIZE) /* SDRAM Bank #2 */
  194. #define CONFIG_NR_DRAM_BANKS 2 /* we have 2 bank of DRAM */
  195. #ifdef CONFIG_SKIP_LOWLEVEL_INIT
  196. #define PHYS_SDRAM_0_SIZE 0x20000000 /* 512 MB */
  197. #define PHYS_SDRAM_1_SIZE 0x20000000 /* 512 MB */
  198. #else
  199. #ifdef CONFIG_MEM_REMAP
  200. #define PHYS_SDRAM_0_SIZE 0x20000000 /* 512 MB */
  201. #define PHYS_SDRAM_1_SIZE 0x20000000 /* 512 MB */
  202. #else
  203. #define PHYS_SDRAM_0_SIZE 0x08000000 /* 128 MB */
  204. #define PHYS_SDRAM_1_SIZE 0x08000000 /* 128 MB */
  205. #endif
  206. #endif
  207. #define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_0
  208. #ifdef CONFIG_MEM_REMAP
  209. #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + 0xA0000 - \
  210. GENERATED_GBL_DATA_SIZE)
  211. #else
  212. #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + 0x1000 - \
  213. GENERATED_GBL_DATA_SIZE)
  214. #endif /* CONFIG_MEM_REMAP */
  215. /*
  216. * Load address and memory test area should agree with
  217. * arch/nds32/config.mk. Be careful not to overwrite U-Boot itself.
  218. */
  219. #define CONFIG_SYS_LOAD_ADDR 0x300000
  220. /* memtest works on 63 MB in DRAM */
  221. #define CONFIG_SYS_MEMTEST_START PHYS_SDRAM_0
  222. #define CONFIG_SYS_MEMTEST_END (PHYS_SDRAM_0 + 0x03F00000)
  223. /*
  224. * Static memory controller configuration
  225. */
  226. #define CONFIG_FTSMC020
  227. #ifdef CONFIG_FTSMC020
  228. #include <faraday/ftsmc020.h>
  229. #define CONFIG_SYS_FTSMC020_CONFIGS { \
  230. { FTSMC020_BANK0_CONFIG, FTSMC020_BANK0_TIMING, }, \
  231. { FTSMC020_BANK1_CONFIG, FTSMC020_BANK1_TIMING, }, \
  232. }
  233. #ifndef CONFIG_SKIP_LOWLEVEL_INIT /* FLASH is on BANK 0 */
  234. #define FTSMC020_BANK0_LOWLV_CONFIG (FTSMC020_BANK_ENABLE | \
  235. FTSMC020_BANK_SIZE_32M | \
  236. FTSMC020_BANK_MBW_32)
  237. #define FTSMC020_BANK0_LOWLV_TIMING (FTSMC020_TPR_RBE | \
  238. FTSMC020_TPR_AST(1) | \
  239. FTSMC020_TPR_CTW(1) | \
  240. FTSMC020_TPR_ATI(1) | \
  241. FTSMC020_TPR_AT2(1) | \
  242. FTSMC020_TPR_WTC(1) | \
  243. FTSMC020_TPR_AHT(1) | \
  244. FTSMC020_TPR_TRNA(1))
  245. #endif
  246. /*
  247. * FLASH on ADP_AG101P is connected to BANK0
  248. * Just disalbe the other BANK to avoid detection error.
  249. */
  250. #define FTSMC020_BANK0_CONFIG (FTSMC020_BANK_ENABLE | \
  251. FTSMC020_BANK_BASE(PHYS_FLASH_1) | \
  252. FTSMC020_BANK_SIZE_32M | \
  253. FTSMC020_BANK_MBW_32)
  254. #define FTSMC020_BANK0_TIMING (FTSMC020_TPR_AST(3) | \
  255. FTSMC020_TPR_CTW(3) | \
  256. FTSMC020_TPR_ATI(0xf) | \
  257. FTSMC020_TPR_AT2(3) | \
  258. FTSMC020_TPR_WTC(3) | \
  259. FTSMC020_TPR_AHT(3) | \
  260. FTSMC020_TPR_TRNA(0xf))
  261. #define FTSMC020_BANK1_CONFIG (0x00)
  262. #define FTSMC020_BANK1_TIMING (0x00)
  263. #endif /* CONFIG_FTSMC020 */
  264. /*
  265. * FLASH and environment organization
  266. */
  267. /* use CFI framework */
  268. #define CONFIG_SYS_FLASH_CFI
  269. #define CONFIG_FLASH_CFI_DRIVER
  270. #define CONFIG_SYS_FLASH_CFI_WIDTH FLASH_CFI_16BIT
  271. #define CONFIG_SYS_FLASH_USE_BUFFER_WRITE
  272. #define CONFIG_SYS_CFI_FLASH_STATUS_POLL
  273. /* support JEDEC */
  274. /* Do not use CONFIG_FLASH_CFI_LEGACY to detect on board flash */
  275. #ifdef CONFIG_SKIP_LOWLEVEL_INIT
  276. #define PHYS_FLASH_1 0x80000000 /* BANK 0 */
  277. #else
  278. #ifdef CONFIG_MEM_REMAP
  279. #define PHYS_FLASH_1 0x80000000 /* BANK 0 */
  280. #else
  281. #define PHYS_FLASH_1 0x00000000 /* BANK 0 */
  282. #endif
  283. #endif /* CONFIG_MEM_REMAP */
  284. #define CONFIG_SYS_FLASH_BASE PHYS_FLASH_1
  285. #define CONFIG_SYS_FLASH_BANKS_LIST { PHYS_FLASH_1, }
  286. #define CONFIG_SYS_MONITOR_BASE PHYS_FLASH_1
  287. #define CONFIG_SYS_FLASH_ERASE_TOUT 120000 /* TO for Flash Erase (ms) */
  288. #define CONFIG_SYS_FLASH_WRITE_TOUT 500 /* TO for Flash Write (ms) */
  289. /* max number of memory banks */
  290. /*
  291. * There are 4 banks supported for this Controller,
  292. * but we have only 1 bank connected to flash on board
  293. */
  294. #define CONFIG_SYS_MAX_FLASH_BANKS 1
  295. #define CONFIG_SYS_FLASH_BANKS_SIZES {0x4000000}
  296. /* max number of sectors on one chip */
  297. #define CONFIG_FLASH_SECTOR_SIZE (0x10000*2)
  298. #define CONFIG_ENV_SECT_SIZE CONFIG_FLASH_SECTOR_SIZE
  299. #define CONFIG_SYS_MAX_FLASH_SECT 512
  300. /* environments */
  301. #define CONFIG_ENV_IS_IN_FLASH
  302. #define CONFIG_ENV_ADDR (CONFIG_SYS_MONITOR_BASE + 0x140000)
  303. #define CONFIG_ENV_SIZE 8192
  304. #define CONFIG_ENV_OVERWRITE
  305. #endif /* __CONFIG_H */