setup.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. /*
  2. * Machine Specific Values for SMDK5250 board based on S5PC520
  3. *
  4. * Copyright (C) 2012 Samsung Electronics
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #ifndef _SMDK5250_SETUP_H
  25. #define _SMDK5250_SETUP_H
  26. #include <config.h>
  27. #include <version.h>
  28. #include <asm/arch/cpu.h>
  29. /* GPIO Offsets for UART: GPIO Contol Register */
  30. #define EXYNOS5_GPIO_A0_CON_OFFSET 0x0
  31. #define EXYNOS5_GPIO_A1_CON_OFFSET 0x20
  32. /* TZPC : Register Offsets */
  33. #define TZPC0_BASE 0x10100000
  34. #define TZPC1_BASE 0x10110000
  35. #define TZPC2_BASE 0x10120000
  36. #define TZPC3_BASE 0x10130000
  37. #define TZPC4_BASE 0x10140000
  38. #define TZPC5_BASE 0x10150000
  39. #define TZPC6_BASE 0x10160000
  40. #define TZPC7_BASE 0x10170000
  41. #define TZPC8_BASE 0x10180000
  42. #define TZPC9_BASE 0x10190000
  43. /* CLK_SRC_CPU */
  44. /* 0 = MOUTAPLL, 1 = SCLKMPLL */
  45. #define MUX_HPM_SEL 0
  46. #define MUX_CPU_SEL 0
  47. #define MUX_APLL_SEL 1
  48. #define CLK_SRC_CPU_VAL ((MUX_HPM_SEL << 20) \
  49. | (MUX_CPU_SEL << 16) \
  50. | (MUX_APLL_SEL))
  51. /* CLK_DIV_CPU0 */
  52. #define ARM2_RATIO 0x0
  53. #define APLL_RATIO 0x1
  54. #define PCLK_DBG_RATIO 0x1
  55. #define ATB_RATIO 0x4
  56. #define PERIPH_RATIO 0x7
  57. #define ACP_RATIO 0x7
  58. #define CPUD_RATIO 0x2
  59. #define ARM_RATIO 0x0
  60. #define CLK_DIV_CPU0_VAL ((ARM2_RATIO << 28) \
  61. | (APLL_RATIO << 24) \
  62. | (PCLK_DBG_RATIO << 20) \
  63. | (ATB_RATIO << 16) \
  64. | (PERIPH_RATIO << 12) \
  65. | (ACP_RATIO << 8) \
  66. | (CPUD_RATIO << 4) \
  67. | (ARM_RATIO))
  68. /* CLK_DIV_CPU1 */
  69. #define HPM_RATIO 0x4
  70. #define COPY_RATIO 0x0
  71. #define CLK_DIV_CPU1_VAL ((HPM_RATIO << 4) \
  72. | (COPY_RATIO))
  73. #define APLL_MDIV 0x7D
  74. #define APLL_PDIV 0x3
  75. #define APLL_SDIV 0x0
  76. #define MPLL_MDIV 0x64
  77. #define MPLL_PDIV 0x3
  78. #define MPLL_SDIV 0x0
  79. #define CPLL_MDIV 0x96
  80. #define CPLL_PDIV 0x4
  81. #define CPLL_SDIV 0x0
  82. /* APLL_CON1 */
  83. #define APLL_CON1_VAL (0x00203800)
  84. /* MPLL_CON1 */
  85. #define MPLL_CON1_VAL (0x00203800)
  86. /* CPLL_CON1 */
  87. #define CPLL_CON1_VAL (0x00203800)
  88. #define EPLL_MDIV 0x60
  89. #define EPLL_PDIV 0x3
  90. #define EPLL_SDIV 0x3
  91. #define EPLL_CON1_VAL 0x00000000
  92. #define EPLL_CON2_VAL 0x00000080
  93. #define VPLL_MDIV 0x96
  94. #define VPLL_PDIV 0x3
  95. #define VPLL_SDIV 0x2
  96. #define VPLL_CON1_VAL 0x00000000
  97. #define VPLL_CON2_VAL 0x00000080
  98. #define BPLL_MDIV 0x215
  99. #define BPLL_PDIV 0xC
  100. #define BPLL_SDIV 0x1
  101. #define BPLL_CON1_VAL 0x00203800
  102. /* Set PLL */
  103. #define set_pll(mdiv, pdiv, sdiv) (1<<31 | mdiv<<16 | pdiv<<8 | sdiv)
  104. #define APLL_CON0_VAL set_pll(APLL_MDIV, APLL_PDIV, APLL_SDIV)
  105. #define MPLL_CON0_VAL set_pll(MPLL_MDIV, MPLL_PDIV, MPLL_SDIV)
  106. #define CPLL_CON0_VAL set_pll(CPLL_MDIV, CPLL_PDIV, CPLL_SDIV)
  107. #define EPLL_CON0_VAL set_pll(EPLL_MDIV, EPLL_PDIV, EPLL_SDIV)
  108. #define VPLL_CON0_VAL set_pll(VPLL_MDIV, VPLL_PDIV, VPLL_SDIV)
  109. #define BPLL_CON0_VAL set_pll(BPLL_MDIV, BPLL_PDIV, BPLL_SDIV)
  110. /* CLK_SRC_CORE0 */
  111. #define CLK_SRC_CORE0_VAL 0x00060000
  112. /* CLK_SRC_CORE1 */
  113. #define CLK_SRC_CORE1_VAL 0x100
  114. /* CLK_DIV_CORE0 */
  115. #define CLK_DIV_CORE0_VAL 0x120000
  116. /* CLK_DIV_CORE1 */
  117. #define CLK_DIV_CORE1_VAL 0x07070700
  118. /* CLK_SRC_CDREX */
  119. #define CLK_SRC_CDREX_INIT_VAL 0x1
  120. #define CLK_SRC_CDREX_VAL 0x111
  121. /* CLK_DIV_CDREX */
  122. #define CLK_DIV_CDREX_INIT_VAL 0x71771111
  123. #define MCLK_CDREX2_RATIO 0x0
  124. #define ACLK_EFCON_RATIO 0x1
  125. #define MCLK_DPHY_RATIO 0x0
  126. #define MCLK_CDREX_RATIO 0x0
  127. #define ACLK_C2C_200_RATIO 0x1
  128. #define C2C_CLK_400_RATIO 0x1
  129. #define PCLK_CDREX_RATIO 0x3
  130. #define ACLK_CDREX_RATIO 0x1
  131. #define CLK_DIV_CDREX_VAL ((MCLK_DPHY_RATIO << 20) \
  132. | (MCLK_CDREX_RATIO << 16) \
  133. | (ACLK_C2C_200_RATIO << 12) \
  134. | (C2C_CLK_400_RATIO << 8) \
  135. | (PCLK_CDREX_RATIO << 4) \
  136. | (ACLK_CDREX_RATIO))
  137. #define MCLK_EFPHY_RATIO 0x4
  138. #define CLK_DIV_CDREX2_VAL MCLK_EFPHY_RATIO
  139. /* CLK_DIV_ACP */
  140. #define CLK_DIV_ACP_VAL 0x12
  141. /* CLK_SRC_TOP0 */
  142. #define MUX_ACLK_300_GSCL_SEL 0x1
  143. #define MUX_ACLK_300_GSCL_MID_SEL 0x0
  144. #define MUX_ACLK_400_SEL 0x0
  145. #define MUX_ACLK_333_SEL 0x0
  146. #define MUX_ACLK_300_DISP1_SEL 0x1
  147. #define MUX_ACLK_300_DISP1_MID_SEL 0x0
  148. #define MUX_ACLK_200_SEL 0x0
  149. #define MUX_ACLK_166_SEL 0x0
  150. #define CLK_SRC_TOP0_VAL ((MUX_ACLK_300_GSCL_SEL << 25) \
  151. | (MUX_ACLK_300_GSCL_MID_SEL << 24) \
  152. | (MUX_ACLK_400_SEL << 20) \
  153. | (MUX_ACLK_333_SEL << 16) \
  154. | (MUX_ACLK_300_DISP1_SEL << 15) \
  155. | (MUX_ACLK_300_DISP1_MID_SEL << 14) \
  156. | (MUX_ACLK_200_SEL << 12) \
  157. | (MUX_ACLK_166_SEL << 8))
  158. /* CLK_SRC_TOP1 */
  159. #define MUX_ACLK_400_ISP_SEL 0x0
  160. #define MUX_ACLK_400_IOP_SEL 0x0
  161. #define MUX_ACLK_MIPI_HSI_TXBASE_SEL 0x0
  162. #define CLK_SRC_TOP1_VAL ((MUX_ACLK_400_ISP_SEL << 24) \
  163. |(MUX_ACLK_400_IOP_SEL << 20) \
  164. |(MUX_ACLK_MIPI_HSI_TXBASE_SEL << 16))
  165. /* CLK_SRC_TOP2 */
  166. #define MUX_BPLL_USER_SEL 0x1
  167. #define MUX_MPLL_USER_SEL 0x1
  168. #define MUX_VPLL_SEL 0x0
  169. #define MUX_EPLL_SEL 0x0
  170. #define MUX_CPLL_SEL 0x0
  171. #define VPLLSRC_SEL 0x0
  172. #define CLK_SRC_TOP2_VAL ((MUX_BPLL_USER_SEL << 24) \
  173. | (MUX_MPLL_USER_SEL << 20) \
  174. | (MUX_VPLL_SEL << 16) \
  175. | (MUX_EPLL_SEL << 12) \
  176. | (MUX_CPLL_SEL << 8) \
  177. | (VPLLSRC_SEL))
  178. /* CLK_SRC_TOP3 */
  179. #define MUX_ACLK_333_SUB_SEL 0x1
  180. #define MUX_ACLK_400_SUB_SEL 0x1
  181. #define MUX_ACLK_266_ISP_SUB_SEL 0x1
  182. #define MUX_ACLK_266_GPS_SUB_SEL 0x1
  183. #define MUX_ACLK_300_GSCL_SUB_SEL 0x1
  184. #define MUX_ACLK_266_GSCL_SUB_SEL 0x1
  185. #define MUX_ACLK_300_DISP1_SUB_SEL 0x1
  186. #define MUX_ACLK_200_DISP1_SUB_SEL 0x1
  187. #define CLK_SRC_TOP3_VAL ((MUX_ACLK_333_SUB_SEL << 24) \
  188. | (MUX_ACLK_400_SUB_SEL << 20) \
  189. | (MUX_ACLK_266_ISP_SUB_SEL << 16) \
  190. | (MUX_ACLK_266_GPS_SUB_SEL << 12) \
  191. | (MUX_ACLK_300_GSCL_SUB_SEL << 10) \
  192. | (MUX_ACLK_266_GSCL_SUB_SEL << 8) \
  193. | (MUX_ACLK_300_DISP1_SUB_SEL << 6) \
  194. | (MUX_ACLK_200_DISP1_SUB_SEL << 4))
  195. /* CLK_DIV_TOP0 */
  196. #define ACLK_300_RATIO 0x0
  197. #define ACLK_400_RATIO 0x3
  198. #define ACLK_333_RATIO 0x2
  199. #define ACLK_266_RATIO 0x2
  200. #define ACLK_200_RATIO 0x3
  201. #define ACLK_166_RATIO 0x5
  202. #define ACLK_133_RATIO 0x1
  203. #define ACLK_66_RATIO 0x5
  204. #define CLK_DIV_TOP0_VAL ((ACLK_300_RATIO << 28) \
  205. | (ACLK_400_RATIO << 24) \
  206. | (ACLK_333_RATIO << 20) \
  207. | (ACLK_266_RATIO << 16) \
  208. | (ACLK_200_RATIO << 12) \
  209. | (ACLK_166_RATIO << 8) \
  210. | (ACLK_133_RATIO << 4) \
  211. | (ACLK_66_RATIO))
  212. /* CLK_DIV_TOP1 */
  213. #define ACLK_MIPI_HSI_TX_BASE_RATIO 0x3
  214. #define ACLK_66_PRE_RATIO 0x1
  215. #define ACLK_400_ISP_RATIO 0x1
  216. #define ACLK_400_IOP_RATIO 0x1
  217. #define ACLK_300_GSCL_RATIO 0x0
  218. #define ACLK_266_GPS_RATIO 0x7
  219. #define CLK_DIV_TOP1_VAL ((ACLK_MIPI_HSI_TX_BASE_RATIO << 28) \
  220. | (ACLK_66_PRE_RATIO << 24) \
  221. | (ACLK_400_ISP_RATIO << 20) \
  222. | (ACLK_400_IOP_RATIO << 16) \
  223. | (ACLK_300_GSCL_RATIO << 12) \
  224. | (ACLK_266_GPS_RATIO << 8))
  225. /* APLL_LOCK */
  226. #define APLL_LOCK_VAL (0x3E8)
  227. /* MPLL_LOCK */
  228. #define MPLL_LOCK_VAL (0x2F1)
  229. /* CPLL_LOCK */
  230. #define CPLL_LOCK_VAL (0x3E8)
  231. /* EPLL_LOCK */
  232. #define EPLL_LOCK_VAL (0x2321)
  233. /* VPLL_LOCK */
  234. #define VPLL_LOCK_VAL (0x2321)
  235. /* BPLL_LOCK */
  236. #define BPLL_LOCK_VAL (0x3E8)
  237. /* CLK_SRC_PERIC0 */
  238. /* SRC_CLOCK = SCLK_MPLL */
  239. #define PWM_SEL 0
  240. #define UART4_SEL 6
  241. #define UART3_SEL 6
  242. #define UART2_SEL 6
  243. #define UART1_SEL 6
  244. #define UART0_SEL 6
  245. #define CLK_SRC_PERIC0_VAL ((PWM_SEL << 24) \
  246. | (UART4_SEL << 16) \
  247. | (UART3_SEL << 12) \
  248. | (UART2_SEL << 8) \
  249. | (UART1_SEL << 4) \
  250. | (UART0_SEL << 0))
  251. #define CLK_SRC_FSYS_VAL 0x66666
  252. #define CLK_DIV_FSYS0_VAL 0x0BB00000
  253. #define CLK_DIV_FSYS1_VAL 0x000f000f
  254. #define CLK_DIV_FSYS2_VAL 0x020f020f
  255. #define CLK_DIV_FSYS3_VAL 0x000f
  256. /* CLK_DIV_PERIC0 */
  257. #define UART5_RATIO 8
  258. #define UART4_RATIO 8
  259. #define UART3_RATIO 8
  260. #define UART2_RATIO 8
  261. #define UART1_RATIO 8
  262. #define UART0_RATIO 8
  263. #define CLK_DIV_PERIC0_VAL ((UART4_RATIO << 16) \
  264. | (UART3_RATIO << 12) \
  265. | (UART2_RATIO << 8) \
  266. | (UART1_RATIO << 4) \
  267. | (UART0_RATIO << 0))
  268. /* CLK_DIV_PERIC3 */
  269. #define PWM_RATIO 8
  270. #define CLK_DIV_PERIC3_VAL (PWM_RATIO << 0)
  271. /* CLK_SRC_LEX */
  272. #define CLK_SRC_LEX_VAL 0x0
  273. /* CLK_DIV_LEX */
  274. #define CLK_DIV_LEX_VAL 0x10
  275. /* CLK_DIV_R0X */
  276. #define CLK_DIV_R0X_VAL 0x10
  277. /* CLK_DIV_L0X */
  278. #define CLK_DIV_R1X_VAL 0x10
  279. /* SCLK_SRC_ISP */
  280. #define SCLK_SRC_ISP_VAL 0x600
  281. /* CLK_DIV_ISP0 */
  282. #define CLK_DIV_ISP0_VAL 0x31
  283. /* CLK_DIV_ISP1 */
  284. #define CLK_DIV_ISP1_VAL 0x0
  285. /* CLK_DIV_ISP2 */
  286. #define CLK_DIV_ISP2_VAL 0x1
  287. #define MPLL_DEC (MPLL_MDIV * MPLL_MDIV / (MPLL_PDIV * 2^(MPLL_SDIV-1)))
  288. /*
  289. * TZPC Register Value :
  290. * R0SIZE: 0x0 : Size of secured ram
  291. */
  292. #define R0SIZE 0x0
  293. /*
  294. * TZPC Decode Protection Register Value :
  295. * DECPROTXSET: 0xFF : Set Decode region to non-secure
  296. */
  297. #define DECPROTXSET 0xFF
  298. /* DMC Init */
  299. #define SET 1
  300. #define RESET 0
  301. /* (Memory Interleaving Size = 1 << IV_SIZE) */
  302. #define CONFIG_IV_SIZE 0x07
  303. #define PHY_RESET_VAL (0 << 0)
  304. /*ZQ Configurations */
  305. #define PHY_CON16_RESET_VAL 0x08000304
  306. #define ZQ_MODE_DDS_VAL (0x5 << 24)
  307. #define ZQ_MODE_TERM_VAL (0x5 << 21)
  308. #define SET_ZQ_MODE_DDS_VAL(x) (x = (x & ~(0x7 << 24)) | ZQ_MODE_DDS_VAL)
  309. #define SET_ZQ_MODE_TERM_VAL(x) (x = (x & ~(0x7 << 21)) | ZQ_MODE_TERM_VAL)
  310. #define ZQ_MODE_NOTERM (1 << 19)
  311. #define ZQ_CLK_DIV_EN (1 << 18)
  312. #define ZQ_MANUAL_STR (1 << 1)
  313. /* Channel and Chip Selection */
  314. #define CONFIG_DMC_CHANNELS 2
  315. #define CONFIG_CHIPS_PER_CHANNEL 2
  316. #define SET_CMD_CHANNEL(x, y) (x = (x & ~(1 << 28)) | y << 28)
  317. #define SET_CMD_CHIP(x, y) (x = (x & ~(1 << 20)) | y << 20)
  318. /* Diret Command */
  319. #define DIRECT_CMD_NOP 0x07000000
  320. #define DIRECT_CMD_MRS1 0x00071C00
  321. #define DIRECT_CMD_MRS2 0x00010BFC
  322. #define DIRECT_CMD_MRS3 0x00000708
  323. #define DIRECT_CMD_MRS4 0x00000818
  324. #define DIRECT_CMD_PALL 0x01000000
  325. /* DLL Resync */
  326. #define FP_RSYNC (1 << 3)
  327. #define CONFIG_CTRL_DLL_ON(x, y) (x = (x & ~(1 << 5)) | y << 5)
  328. #define CONFIG_CTRL_START(x, y) (x = (x & ~(1 << 6)) | y << 6)
  329. #define SET_CTRL_FORCE_VAL(x, y) (x = (x & ~(0x7F << 8)) | y << 8)
  330. /* RDLVL */
  331. #define PHY_CON0_RESET_VAL 0x17023240
  332. #define DDR_MODE_LPDDR2 0x2
  333. #define BYTE_RDLVL_EN (1 << 13)
  334. #define CTRL_ATGATE (1 << 6)
  335. #define SET_CTRL_DDR_MODE(x, y) (x = (x & ~(0x3 << 11)) | y << 11)
  336. #define PHY_CON1_RESET_VAL 0x9210100
  337. #define RDLVL_RDDATAPADJ 0x1
  338. #define SET_RDLVL_RDDATAPADJ ((PHY_CON1_RESET_VAL & ~(0xFFFF << 0))\
  339. | RDLVL_RDDATAPADJ << 0)
  340. #define PHY_CON2_RESET_VAL 0x00010004
  341. #define RDLVL_EN (1 << 25)
  342. #define RDDSKEW_CLEAR (1 << 13)
  343. #define CTRL_RDLVL_DATA_EN (1 << 1)
  344. #define LPDDR2_ADDR 0x00000208
  345. #define DMC_MEMCONFIG0_VAL 0x00001323
  346. #define DMC_MEMCONFIG1_VAL 0x00001323
  347. #define DMC_MEMBASECONFIG0_VAL 0x00400780
  348. #define DMC_MEMBASECONFIG1_VAL 0x00800780
  349. #define DMC_MEMCONTROL_VAL 0x00212500
  350. #define DMC_PRECHCONFIG_VAL 0xFF000000
  351. #define DMC_PWRDNCONFIG_VAL 0xFFFF00FF
  352. #define DMC_TIMINGREF_VAL 0x0000005D
  353. #define DMC_TIMINGROW_VAL 0x2336544C
  354. #define DMC_TIMINGDATA_VAL 0x24202408
  355. #define DMC_TIMINGPOWER_VAL 0x38260235
  356. #define CTRL_BSTLEN 0x04
  357. #define CTRL_RDLAT 0x08
  358. #define PHY_CON42_VAL (CTRL_BSTLEN << 8 | CTRL_RDLAT << 0)
  359. /* DQS, DQ, DEBUG offsets */
  360. #define SET_DQS_OFFSET_VAL 0x7F7F7F7F
  361. #define SET_DQ_OFFSET_VAL 0x7F7F7F7F
  362. #define SET_DEBUG_OFFSET_VAL 0x7F
  363. #define RESET_DQS_OFFSET_VAL 0x08080808
  364. #define RESET_DQ_OFFSET_VAL 0x08080808
  365. #define RESET_DEBUG_OFFSET_VAL 0x8
  366. #define CTRL_PULLD_DQ (0x0F << 8)
  367. #define CTRL_PULLD_DQS (0x0F << 0)
  368. #define DFI_INIT_START (1 << 28)
  369. #define CLK_STOP_EN (1 << 0)
  370. #define DPWRDN_EN (1 << 1)
  371. #define DSREF_EN (1 << 5)
  372. #define AREF_EN (1 << 5)
  373. void sdelay(unsigned long);
  374. void mem_ctrl_init(void);
  375. void system_clock_init(void);
  376. void tzpc_init(void);
  377. #endif