apf27.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. /*
  2. * Copyright (C) 2008-2013 Eric Jarrige <eric.jarrige@armadeus.org>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef __APF27_H
  7. #define __APF27_H
  8. /* FPGA program pin configuration */
  9. #define ACFG_FPGA_PWR (GPIO_PORTF | 19) /* FPGA prog pin */
  10. #define ACFG_FPGA_PRG (GPIO_PORTF | 11) /* FPGA prog pin */
  11. #define ACFG_FPGA_CLK (GPIO_PORTF | 15) /* FPGA clk pin */
  12. #define ACFG_FPGA_RDATA 0xD6000000 /* FPGA data addr */
  13. #define ACFG_FPGA_WDATA 0xD6000000 /* FPGA data addr */
  14. #define ACFG_FPGA_INIT (GPIO_PORTF | 12) /* FPGA init pin */
  15. #define ACFG_FPGA_DONE (GPIO_PORTF | 9) /* FPGA done pin */
  16. #define ACFG_FPGA_RW (GPIO_PORTF | 21) /* FPGA done pin */
  17. #define ACFG_FPGA_CS (GPIO_PORTF | 22) /* FPGA done pin */
  18. #define ACFG_FPGA_SUSPEND (GPIO_PORTF | 10) /* FPGA done pin */
  19. #define ACFG_FPGA_RESET (GPIO_PORTF | 7) /* FPGA done pin */
  20. /* MMC pin */
  21. #define PC_PWRON (GPIO_PORTF | 16)
  22. /*
  23. * MPU CLOCK source before PLL
  24. * ACFG_CLK_FREQ (2/3 MPLL clock or ext 266 MHZ)
  25. */
  26. #define ACFG_MPCTL0_VAL 0x01EF15D5 /* 399.000 MHz */
  27. #define ACFG_MPCTL1_VAL 0
  28. #define CONFIG_MPLL_FREQ 399
  29. #define ACFG_CLK_FREQ (CONFIG_MPLL_FREQ*2/3) /* 266 MHz */
  30. /* Serial clock source before PLL (should be named ACFG_SYSPLL_CLK_FREQ)*/
  31. #define ACFG_SPCTL0_VAL 0x0475206F /* 299.99937 MHz */
  32. #define ACFG_SPCTL1_VAL 0
  33. #define CONFIG_SPLL_FREQ 300 /* MHz */
  34. /* ARM bus frequency (have to be a CONFIG_MPLL_FREQ ratio) */
  35. #define CONFIG_ARM_FREQ 399 /* up to 400 MHz */
  36. /* external bus frequency (have to be a ACFG_CLK_FREQ ratio) */
  37. #define CONFIG_HCLK_FREQ 133 /* (ACFG_CLK_FREQ/2) */
  38. #define CONFIG_PERIF1_FREQ 16 /* 16.625 MHz UART, GPT, PWM */
  39. #define CONFIG_PERIF2_FREQ 33 /* 33.25 MHz CSPI and SDHC */
  40. #define CONFIG_PERIF3_FREQ 33 /* 33.25 MHz LCD */
  41. #define CONFIG_PERIF4_FREQ 33 /* 33.25 MHz CSI */
  42. #define CONFIG_SSI1_FREQ 66 /* 66.50 MHz SSI1 */
  43. #define CONFIG_SSI2_FREQ 66 /* 66.50 MHz SSI2 */
  44. #define CONFIG_MSHC_FREQ 66 /* 66.50 MHz MSHC */
  45. #define CONFIG_H264_FREQ 66 /* 66.50 MHz H264 */
  46. #define CONFIG_CLK0_DIV 3 /* Divide CLK0 by 4 */
  47. #define CONFIG_CLK0_EN 1 /* CLK0 enabled */
  48. /* external bus frequency (have to be a CONFIG_HCLK_FREQ ratio) */
  49. #define CONFIG_NFC_FREQ 44 /* NFC Clock up to 44 MHz wh 133MHz */
  50. /* external serial bus frequency (have to be a CONFIG_SPLL_FREQ ratio) */
  51. #define CONFIG_USB_FREQ 60 /* 60 MHz */
  52. /*
  53. * SDRAM
  54. */
  55. #if (ACFG_SDRAM_MBYTE_SYZE == 64) /* micron MT46H16M32LF -6 */
  56. /* micron 64MB */
  57. #define ACFG_SDRAM_NUM_COL 9 /* 8, 9, 10 or 11
  58. * column address bits
  59. */
  60. #define ACFG_SDRAM_NUM_ROW 13 /* 11, 12 or 13
  61. * row address bits
  62. */
  63. #define ACFG_SDRAM_REFRESH 3 /* 0=OFF 1=2048
  64. * 2=4096 3=8192 refresh
  65. */
  66. #define ACFG_SDRAM_EXIT_PWD 25 /* ns exit power
  67. * down delay
  68. */
  69. #define ACFG_SDRAM_W2R_DELAY 1 /* write to read
  70. * cycle delay > 0
  71. */
  72. #define ACFG_SDRAM_ROW_PRECHARGE_DELAY 18 /* ns */
  73. #define ACFG_SDRAM_TMRD_DELAY 2 /* Load mode register
  74. * cycle delay 1..4
  75. */
  76. #define ACFG_SDRAM_TWR_DELAY 1 /* LPDDR: 0=2ck 1=3ck
  77. * SDRAM: 0=1ck 1=2ck
  78. */
  79. #define ACFG_SDRAM_RAS_DELAY 42 /* ns ACTIVE-to-PRECHARGE delay */
  80. #define ACFG_SDRAM_RRD_DELAY 12 /* ns ACTIVE-to-ACTIVE delay */
  81. #define ACFG_SDRAM_RCD_DELAY 18 /* ns Row to Column delay */
  82. #define ACFG_SDRAM_RC_DELAY 70 /* ns Row cycle delay (tRFC
  83. * refresh to command)
  84. */
  85. #define ACFG_SDRAM_CLOCK_CYCLE_CL_1 0 /* ns clock cycle time
  86. * estimated fo CL=1
  87. * 0=force 3 for lpddr
  88. */
  89. #define ACFG_SDRAM_PARTIAL_ARRAY_SR 0 /* 0=full 1=half 2=quater
  90. * 3=Eighth 4=Sixteenth
  91. */
  92. #define ACFG_SDRAM_DRIVE_STRENGH 0 /* 0=Full-strength 1=half
  93. * 2=quater 3=Eighth
  94. */
  95. #define ACFG_SDRAM_BURST_LENGTH 3 /* 2^N BYTES (N=0..3) */
  96. #define ACFG_SDRAM_SINGLE_ACCESS 0 /* 1= single access
  97. * 0 = Burst mode
  98. */
  99. #endif
  100. #if (ACFG_SDRAM_MBYTE_SYZE == 128)
  101. /* micron 128MB */
  102. #define ACFG_SDRAM_NUM_COL 9 /* 8, 9, 10 or 11
  103. * column address bits
  104. */
  105. #define ACFG_SDRAM_NUM_ROW 14 /* 11, 12 or 13
  106. * row address bits
  107. */
  108. #define ACFG_SDRAM_REFRESH 3 /* 0=OFF 1=2048
  109. * 2=4096 3=8192 refresh
  110. */
  111. #define ACFG_SDRAM_EXIT_PWD 25 /* ns exit power
  112. * down delay
  113. */
  114. #define ACFG_SDRAM_W2R_DELAY 1 /* write to read
  115. * cycle delay > 0
  116. */
  117. #define ACFG_SDRAM_ROW_PRECHARGE_DELAY 18 /* ns */
  118. #define ACFG_SDRAM_TMRD_DELAY 2 /* Load mode register
  119. * cycle delay 1..4
  120. */
  121. #define ACFG_SDRAM_TWR_DELAY 1 /* LPDDR: 0=2ck 1=3ck
  122. * SDRAM: 0=1ck 1=2ck
  123. */
  124. #define ACFG_SDRAM_RAS_DELAY 42 /* ns ACTIVE-to-PRECHARGE delay */
  125. #define ACFG_SDRAM_RRD_DELAY 12 /* ns ACTIVE-to-ACTIVE delay */
  126. #define ACFG_SDRAM_RCD_DELAY 18 /* ns Row to Column delay */
  127. #define ACFG_SDRAM_RC_DELAY 70 /* ns Row cycle delay (tRFC
  128. * refresh to command)
  129. */
  130. #define ACFG_SDRAM_CLOCK_CYCLE_CL_1 0 /* ns clock cycle time
  131. * estimated fo CL=1
  132. * 0=force 3 for lpddr
  133. */
  134. #define ACFG_SDRAM_PARTIAL_ARRAY_SR 0 /* 0=full 1=half 2=quater
  135. * 3=Eighth 4=Sixteenth
  136. */
  137. #define ACFG_SDRAM_DRIVE_STRENGH 0 /* 0=Full-strength 1=half
  138. * 2=quater 3=Eighth
  139. */
  140. #define ACFG_SDRAM_BURST_LENGTH 3 /* 2^N BYTES (N=0..3) */
  141. #define ACFG_SDRAM_SINGLE_ACCESS 0 /* 1= single access
  142. * 0 = Burst mode
  143. */
  144. #endif
  145. #if (ACFG_SDRAM_MBYTE_SYZE == 256)
  146. /* micron 256MB */
  147. #define ACFG_SDRAM_NUM_COL 10 /* 8, 9, 10 or 11
  148. * column address bits
  149. */
  150. #define ACFG_SDRAM_NUM_ROW 14 /* 11, 12 or 13
  151. * row address bits
  152. */
  153. #define ACFG_SDRAM_REFRESH 3 /* 0=OFF 1=2048
  154. * 2=4096 3=8192 refresh
  155. */
  156. #define ACFG_SDRAM_EXIT_PWD 25 /* ns exit power
  157. * down delay
  158. */
  159. #define ACFG_SDRAM_W2R_DELAY 1 /* write to read cycle
  160. * delay > 0
  161. */
  162. #define ACFG_SDRAM_ROW_PRECHARGE_DELAY 18 /* ns */
  163. #define ACFG_SDRAM_TMRD_DELAY 2 /* Load mode register
  164. * cycle delay 1..4
  165. */
  166. #define ACFG_SDRAM_TWR_DELAY 1 /* LPDDR: 0=2ck 1=3ck
  167. * SDRAM: 0=1ck 1=2ck
  168. */
  169. #define ACFG_SDRAM_RAS_DELAY 42 /* ns ACTIVE-to-PRECHARGE delay */
  170. #define ACFG_SDRAM_RRD_DELAY 12 /* ns ACTIVE-to-ACTIVE delay */
  171. #define ACFG_SDRAM_RCD_DELAY 18 /* ns Row to Column delay */
  172. #define ACFG_SDRAM_RC_DELAY 70 /* ns Row cycle delay (tRFC
  173. * refresh to command)
  174. */
  175. #define ACFG_SDRAM_CLOCK_CYCLE_CL_1 0 /* ns clock cycle time
  176. * estimated fo CL=1
  177. * 0=force 3 for lpddr
  178. */
  179. #define ACFG_SDRAM_PARTIAL_ARRAY_SR 0 /* 0=full 1=half 2=quater
  180. * 3=Eighth 4=Sixteenth
  181. */
  182. #define ACFG_SDRAM_DRIVE_STRENGH 0 /* 0=Full-strength
  183. * 1=half
  184. * 2=quater
  185. * 3=Eighth
  186. */
  187. #define ACFG_SDRAM_BURST_LENGTH 3 /* 2^N BYTES (N=0..3) */
  188. #define ACFG_SDRAM_SINGLE_ACCESS 0 /* 1= single access
  189. * 0 = Burst mode
  190. */
  191. #endif
  192. /*
  193. * External interface
  194. */
  195. /*
  196. * CSCRxU_VAL:
  197. * 31| x | x | x x |x x x x| x x | x | x |x x x x|16
  198. * |SP |WP | BCD | BCS | PSZ |PME|SYNC| DOL |
  199. *
  200. * 15| x x | x x x x x x | x | x x x x | x x x x |0
  201. * | CNC | WSC |EW | WWS | EDC |
  202. *
  203. * CSCRxL_VAL:
  204. * 31| x x x x | x x x x | x x x x | x x x x |16
  205. * | OEA | OEN | EBWA | EBWN |
  206. * 15|x x x x| x |x x x |x x x x| x | x | x | x | 0
  207. * | CSA |EBC| DSZ | CSN |PSR|CRE|WRAP|CSEN|
  208. *
  209. * CSCRxA_VAL:
  210. * 31| x x x x | x x x x | x x x x | x x x x |16
  211. * | EBRA | EBRN | RWA | RWN |
  212. * 15| x | x x |x x x|x x|x x|x x| x | x | x | x | 0
  213. * |MUM| LAH | LBN |LBA|DWW|DCT|WWU|AGE|CNC2|FCE|
  214. */
  215. /* CS0 configuration for 16 bit nor flash */
  216. #define ACFG_CS0U_VAL 0x0000CC03
  217. #define ACFG_CS0L_VAL 0xa0330D01
  218. #define ACFG_CS0A_VAL 0x00220800
  219. #define ACFG_CS1U_VAL 0x00000f00
  220. #define ACFG_CS1L_VAL 0x00000D01
  221. #define ACFG_CS1A_VAL 0
  222. #define ACFG_CS2U_VAL 0
  223. #define ACFG_CS2L_VAL 0
  224. #define ACFG_CS2A_VAL 0
  225. #define ACFG_CS3U_VAL 0
  226. #define ACFG_CS3L_VAL 0
  227. #define ACFG_CS3A_VAL 0
  228. #define ACFG_CS4U_VAL 0
  229. #define ACFG_CS4L_VAL 0
  230. #define ACFG_CS4A_VAL 0
  231. /* FPGA 16 bit data bus */
  232. #define ACFG_CS5U_VAL 0x00000600
  233. #define ACFG_CS5L_VAL 0x00000D01
  234. #define ACFG_CS5A_VAL 0
  235. #define ACFG_EIM_VAL 0x00002200
  236. /*
  237. * FPGA specific settings
  238. */
  239. /* CLKO */
  240. #define ACFG_CCSR_VAL 0x00000305
  241. /* drive strength CLKO set to 2 */
  242. #define ACFG_DSCR10_VAL 0x00020000
  243. /* drive strength A1..A12 set to 2 */
  244. #define ACFG_DSCR3_VAL 0x02AAAAA8
  245. /* drive strength ctrl */
  246. #define ACFG_DSCR7_VAL 0x00020880
  247. /* drive strength data */
  248. #define ACFG_DSCR2_VAL 0xAAAAAAAA
  249. /*
  250. * Default configuration for GPIOs and peripherals
  251. */
  252. #define ACFG_DDIR_A_VAL 0x00000000
  253. #define ACFG_OCR1_A_VAL 0x00000000
  254. #define ACFG_OCR2_A_VAL 0x00000000
  255. #define ACFG_ICFA1_A_VAL 0xFFFFFFFF
  256. #define ACFG_ICFA2_A_VAL 0xFFFFFFFF
  257. #define ACFG_ICFB1_A_VAL 0xFFFFFFFF
  258. #define ACFG_ICFB2_A_VAL 0xFFFFFFFF
  259. #define ACFG_DR_A_VAL 0x00000000
  260. #define ACFG_GIUS_A_VAL 0xFFFFFFFF
  261. #define ACFG_ICR1_A_VAL 0x00000000
  262. #define ACFG_ICR2_A_VAL 0x00000000
  263. #define ACFG_IMR_A_VAL 0x00000000
  264. #define ACFG_GPR_A_VAL 0x00000000
  265. #define ACFG_PUEN_A_VAL 0xFFFFFFFF
  266. #define ACFG_DDIR_B_VAL 0x00000000
  267. #define ACFG_OCR1_B_VAL 0x00000000
  268. #define ACFG_OCR2_B_VAL 0x00000000
  269. #define ACFG_ICFA1_B_VAL 0xFFFFFFFF
  270. #define ACFG_ICFA2_B_VAL 0xFFFFFFFF
  271. #define ACFG_ICFB1_B_VAL 0xFFFFFFFF
  272. #define ACFG_ICFB2_B_VAL 0xFFFFFFFF
  273. #define ACFG_DR_B_VAL 0x00000000
  274. #define ACFG_GIUS_B_VAL 0xFF3FFFF0
  275. #define ACFG_ICR1_B_VAL 0x00000000
  276. #define ACFG_ICR2_B_VAL 0x00000000
  277. #define ACFG_IMR_B_VAL 0x00000000
  278. #define ACFG_GPR_B_VAL 0x00000000
  279. #define ACFG_PUEN_B_VAL 0xFFFFFFFF
  280. #define ACFG_DDIR_C_VAL 0x00000000
  281. #define ACFG_OCR1_C_VAL 0x00000000
  282. #define ACFG_OCR2_C_VAL 0x00000000
  283. #define ACFG_ICFA1_C_VAL 0xFFFFFFFF
  284. #define ACFG_ICFA2_C_VAL 0xFFFFFFFF
  285. #define ACFG_ICFB1_C_VAL 0xFFFFFFFF
  286. #define ACFG_ICFB2_C_VAL 0xFFFFFFFF
  287. #define ACFG_DR_C_VAL 0x00000000
  288. #define ACFG_GIUS_C_VAL 0xFFFFC07F
  289. #define ACFG_ICR1_C_VAL 0x00000000
  290. #define ACFG_ICR2_C_VAL 0x00000000
  291. #define ACFG_IMR_C_VAL 0x00000000
  292. #define ACFG_GPR_C_VAL 0x00000000
  293. #define ACFG_PUEN_C_VAL 0xFFFFFF87
  294. #define ACFG_DDIR_D_VAL 0x00000000
  295. #define ACFG_OCR1_D_VAL 0x00000000
  296. #define ACFG_OCR2_D_VAL 0x00000000
  297. #define ACFG_ICFA1_D_VAL 0xFFFFFFFF
  298. #define ACFG_ICFA2_D_VAL 0xFFFFFFFF
  299. #define ACFG_ICFB1_D_VAL 0xFFFFFFFF
  300. #define ACFG_ICFB2_D_VAL 0xFFFFFFFF
  301. #define ACFG_DR_D_VAL 0x00000000
  302. #define ACFG_GIUS_D_VAL 0xFFFFFFFF
  303. #define ACFG_ICR1_D_VAL 0x00000000
  304. #define ACFG_ICR2_D_VAL 0x00000000
  305. #define ACFG_IMR_D_VAL 0x00000000
  306. #define ACFG_GPR_D_VAL 0x00000000
  307. #define ACFG_PUEN_D_VAL 0xFFFFFFFF
  308. #define ACFG_DDIR_E_VAL 0x00000000
  309. #define ACFG_OCR1_E_VAL 0x00000000
  310. #define ACFG_OCR2_E_VAL 0x00000000
  311. #define ACFG_ICFA1_E_VAL 0xFFFFFFFF
  312. #define ACFG_ICFA2_E_VAL 0xFFFFFFFF
  313. #define ACFG_ICFB1_E_VAL 0xFFFFFFFF
  314. #define ACFG_ICFB2_E_VAL 0xFFFFFFFF
  315. #define ACFG_DR_E_VAL 0x00000000
  316. #define ACFG_GIUS_E_VAL 0xFCFFCCF8
  317. #define ACFG_ICR1_E_VAL 0x00000000
  318. #define ACFG_ICR2_E_VAL 0x00000000
  319. #define ACFG_IMR_E_VAL 0x00000000
  320. #define ACFG_GPR_E_VAL 0x00000000
  321. #define ACFG_PUEN_E_VAL 0xFFFFFFFF
  322. #define ACFG_DDIR_F_VAL 0x00000000
  323. #define ACFG_OCR1_F_VAL 0x00000000
  324. #define ACFG_OCR2_F_VAL 0x00000000
  325. #define ACFG_ICFA1_F_VAL 0xFFFFFFFF
  326. #define ACFG_ICFA2_F_VAL 0xFFFFFFFF
  327. #define ACFG_ICFB1_F_VAL 0xFFFFFFFF
  328. #define ACFG_ICFB2_F_VAL 0xFFFFFFFF
  329. #define ACFG_DR_F_VAL 0x00000000
  330. #define ACFG_GIUS_F_VAL 0xFF7F8000
  331. #define ACFG_ICR1_F_VAL 0x00000000
  332. #define ACFG_ICR2_F_VAL 0x00000000
  333. #define ACFG_IMR_F_VAL 0x00000000
  334. #define ACFG_GPR_F_VAL 0x00000000
  335. #define ACFG_PUEN_F_VAL 0xFFFFFFFF
  336. /* Enforce DDR signal strengh & enable USB/PP/DMA burst override bits */
  337. #define ACFG_GPCR_VAL 0x0003000F
  338. #define ACFG_ESDMISC_VAL ESDMISC_LHD+ESDMISC_MDDREN
  339. /* FMCR select num LPDDR RAMs and nand 16bits, 2KB pages */
  340. #if (CONFIG_NR_DRAM_BANKS == 1)
  341. #define ACFG_FMCR_VAL 0xFFFFFFF9
  342. #elif (CONFIG_NR_DRAM_BANKS == 2)
  343. #define ACFG_FMCR_VAL 0xFFFFFFFB
  344. #endif
  345. #define ACFG_AIPI1_PSR0_VAL 0x20040304
  346. #define ACFG_AIPI1_PSR1_VAL 0xDFFBFCFB
  347. #define ACFG_AIPI2_PSR0_VAL 0x00000000
  348. #define ACFG_AIPI2_PSR1_VAL 0xFFFFFFFF
  349. /* PCCR enable DMA FEC I2C1 IIM SDHC1 */
  350. #define ACFG_PCCR0_VAL 0x05070410
  351. #define ACFG_PCCR1_VAL 0xA14A0608
  352. /*
  353. * From here, there should not be any user configuration.
  354. * All Equations are automatic
  355. */
  356. /* fixme none integer value (7.5ns) => 2*hclock = 15ns */
  357. #define ACFG_2XHCLK_LGTH (2000/CONFIG_HCLK_FREQ) /* ns */
  358. /* USB 60 MHz ; ARM up to 400; HClK up to 133MHz*/
  359. #define CSCR_MASK 0x0300800D
  360. #define ACFG_CSCR_VAL \
  361. (CSCR_MASK \
  362. |((((CONFIG_SPLL_FREQ/CONFIG_USB_FREQ)-1)&0x07) << 28) \
  363. |((((CONFIG_MPLL_FREQ/CONFIG_ARM_FREQ)-1)&0x03) << 12) \
  364. |((((ACFG_CLK_FREQ/CONFIG_HCLK_FREQ)-1)&0x03) << 8))
  365. /* SSIx CLKO NFC H264 MSHC */
  366. #define ACFG_PCDR0_VAL\
  367. (((((ACFG_CLK_FREQ/CONFIG_MSHC_FREQ)-1)&0x3F)<<0) \
  368. |((((CONFIG_HCLK_FREQ/CONFIG_NFC_FREQ)-1)&0x0F)<<6) \
  369. |(((((ACFG_CLK_FREQ/CONFIG_H264_FREQ)-2)*2)&0x3F)<<10)\
  370. |(((((ACFG_CLK_FREQ/CONFIG_SSI1_FREQ)-2)*2)&0x3F)<<16)\
  371. |(((CONFIG_CLK0_DIV)&0x07)<<22)\
  372. |(((CONFIG_CLK0_EN)&0x01)<<25)\
  373. |(((((ACFG_CLK_FREQ/CONFIG_SSI2_FREQ)-2)*2)&0x3F)<<26))
  374. /* PERCLKx */
  375. #define ACFG_PCDR1_VAL\
  376. (((((ACFG_CLK_FREQ/CONFIG_PERIF1_FREQ)-1)&0x3F)<<0) \
  377. |((((ACFG_CLK_FREQ/CONFIG_PERIF2_FREQ)-1)&0x3F)<<8) \
  378. |((((ACFG_CLK_FREQ/CONFIG_PERIF3_FREQ)-1)&0x3F)<<16) \
  379. |((((ACFG_CLK_FREQ/CONFIG_PERIF4_FREQ)-1)&0x3F)<<24))
  380. /* SDRAM controller programming Values */
  381. #if (((2*ACFG_SDRAM_CLOCK_CYCLE_CL_1) > (3*ACFG_2XHCLK_LGTH)) || \
  382. (ACFG_SDRAM_CLOCK_CYCLE_CL_1 < 1))
  383. #define REG_FIELD_SCL_VAL 3
  384. #define REG_FIELD_SCLIMX_VAL 0
  385. #else
  386. #define REG_FIELD_SCL_VAL\
  387. ((2*ACFG_SDRAM_CLOCK_CYCLE_CL_1+ACFG_2XHCLK_LGTH-1)/ \
  388. ACFG_2XHCLK_LGTH)
  389. #define REG_FIELD_SCLIMX_VAL REG_FIELD_SCL_VAL
  390. #endif
  391. #if ((2*ACFG_SDRAM_RC_DELAY) > (16*ACFG_2XHCLK_LGTH))
  392. #define REG_FIELD_SRC_VAL 0
  393. #else
  394. #define REG_FIELD_SRC_VAL\
  395. ((2*ACFG_SDRAM_RC_DELAY+ACFG_2XHCLK_LGTH-1)/ \
  396. ACFG_2XHCLK_LGTH)
  397. #endif
  398. /* TBD Power down timer ; PRCT Bit Field Encoding; burst length 8 ; FP = 0*/
  399. #define REG_ESDCTL_BASE_CONFIG (0x80020485\
  400. | (((ACFG_SDRAM_NUM_ROW-11)&0x7)<<24)\
  401. | (((ACFG_SDRAM_NUM_COL-8)&0x3)<<20)\
  402. | (((ACFG_SDRAM_REFRESH)&0x7)<<13))
  403. #define ACFG_NORMAL_RW_CMD ((0x0<<28)+REG_ESDCTL_BASE_CONFIG)
  404. #define ACFG_PRECHARGE_CMD ((0x1<<28)+REG_ESDCTL_BASE_CONFIG)
  405. #define ACFG_AUTOREFRESH_CMD ((0x2<<28)+REG_ESDCTL_BASE_CONFIG)
  406. #define ACFG_SET_MODE_REG_CMD ((0x3<<28)+REG_ESDCTL_BASE_CONFIG)
  407. /* ESDRAMC Configuration Registers : force CL=3 to lpddr */
  408. #define ACFG_SDRAM_ESDCFG_REGISTER_VAL (0x0\
  409. | (((((2*ACFG_SDRAM_EXIT_PWD+ACFG_2XHCLK_LGTH-1)/ \
  410. ACFG_2XHCLK_LGTH)-1)&0x3)<<21)\
  411. | (((ACFG_SDRAM_W2R_DELAY-1)&0x1)<<20)\
  412. | (((((2*ACFG_SDRAM_ROW_PRECHARGE_DELAY+ \
  413. ACFG_2XHCLK_LGTH-1)/ACFG_2XHCLK_LGTH)-1)&0x3)<<18) \
  414. | (((ACFG_SDRAM_TMRD_DELAY-1)&0x3)<<16)\
  415. | (((ACFG_SDRAM_TWR_DELAY)&0x1)<<15)\
  416. | (((((2*ACFG_SDRAM_RAS_DELAY+ACFG_2XHCLK_LGTH-1)/ \
  417. ACFG_2XHCLK_LGTH)-1)&0x7)<<12) \
  418. | (((((2*ACFG_SDRAM_RRD_DELAY+ACFG_2XHCLK_LGTH-1)/ \
  419. ACFG_2XHCLK_LGTH)-1)&0x3)<<10) \
  420. | (((REG_FIELD_SCLIMX_VAL)&0x3)<<8)\
  421. | (((((2*ACFG_SDRAM_RCD_DELAY+ACFG_2XHCLK_LGTH-1)/ \
  422. ACFG_2XHCLK_LGTH)-1)&0x7)<<4) \
  423. | (((REG_FIELD_SRC_VAL)&0x0F)<<0))
  424. /* Issue Mode register Command to SDRAM */
  425. #define ACFG_SDRAM_MODE_REGISTER_VAL\
  426. ((((ACFG_SDRAM_BURST_LENGTH)&0x7)<<(0))\
  427. | (((REG_FIELD_SCL_VAL)&0x7)<<(4))\
  428. | ((0)<<(3)) /* sequentiql access */ \
  429. /*| (((ACFG_SDRAM_SINGLE_ACCESS)&0x1)<<(1))*/)
  430. /* Issue Extended Mode register Command to SDRAM */
  431. #define ACFG_SDRAM_EXT_MODE_REGISTER_VAL\
  432. ((ACFG_SDRAM_PARTIAL_ARRAY_SR<<0)\
  433. | (ACFG_SDRAM_DRIVE_STRENGH<<(5))\
  434. | (1<<(ACFG_SDRAM_NUM_COL+ACFG_SDRAM_NUM_ROW+1+2)))
  435. /* Issue Precharge all Command to SDRAM */
  436. #define ACFG_SDRAM_PRECHARGE_ALL_VAL (1<<10)
  437. #endif /* __APF27_H */