mem.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. /*
  2. * (C) Copyright 2006-2008
  3. * Texas Instruments, <www.ti.com>
  4. * Richard Woodruff <r-woodruff2@ti.com>
  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 _MEM_H_
  25. #define _MEM_H_
  26. #define CS0 0x0
  27. #define CS1 0x1 /* mirror CS1 regs appear offset 0x30 from CS0 */
  28. #ifndef __ASSEMBLY__
  29. enum {
  30. STACKED = 0,
  31. IP_DDR = 1,
  32. COMBO_DDR = 2,
  33. IP_SDR = 3,
  34. };
  35. #endif /* __ASSEMBLY__ */
  36. #define EARLY_INIT 1
  37. /* Slower full frequency range default timings for x32 operation*/
  38. #define SDRC_SHARING 0x00000100
  39. #define SDRC_MR_0_SDR 0x00000031
  40. #define DLL_OFFSET 0
  41. #define DLL_WRITEDDRCLKX2DIS 1
  42. #define DLL_ENADLL 1
  43. #define DLL_LOCKDLL 0
  44. #define DLL_DLLPHASE_72 0
  45. #define DLL_DLLPHASE_90 1
  46. /* rkw - need to find of 90/72 degree recommendation for speed like before */
  47. #define SDP_SDRC_DLLAB_CTRL ((DLL_ENADLL << 3) | \
  48. (DLL_LOCKDLL << 2) | (DLL_DLLPHASE_90 << 1))
  49. /* Infineon part of 3430SDP (165MHz optimized) 6.06ns
  50. * ACTIMA
  51. * TDAL = Twr/Tck + Trp/tck = 15/6 + 18/6 = 2.5 + 3 = 5.5 -> 6
  52. * TDPL (Twr) = 15/6 = 2.5 -> 3
  53. * TRRD = 12/6 = 2
  54. * TRCD = 18/6 = 3
  55. * TRP = 18/6 = 3
  56. * TRAS = 42/6 = 7
  57. * TRC = 60/6 = 10
  58. * TRFC = 72/6 = 12
  59. * ACTIMB
  60. * TCKE = 2
  61. * XSR = 120/6 = 20
  62. */
  63. #define INFINEON_TDAL_165 6
  64. #define INFINEON_TDPL_165 3
  65. #define INFINEON_TRRD_165 2
  66. #define INFINEON_TRCD_165 3
  67. #define INFINEON_TRP_165 3
  68. #define INFINEON_TRAS_165 7
  69. #define INFINEON_TRC_165 10
  70. #define INFINEON_TRFC_165 12
  71. #define INFINEON_V_ACTIMA_165 ((INFINEON_TRFC_165 << 27) | \
  72. (INFINEON_TRC_165 << 22) | (INFINEON_TRAS_165 << 18) | \
  73. (INFINEON_TRP_165 << 15) | (INFINEON_TRCD_165 << 12) | \
  74. (INFINEON_TRRD_165 << 9) | (INFINEON_TDPL_165 << 6) | \
  75. (INFINEON_TDAL_165))
  76. #define INFINEON_TWTR_165 1
  77. #define INFINEON_TCKE_165 2
  78. #define INFINEON_TXP_165 2
  79. #define INFINEON_XSR_165 20
  80. #define INFINEON_V_ACTIMB_165 ((INFINEON_TCKE_165 << 12) | \
  81. (INFINEON_XSR_165 << 0) | (INFINEON_TXP_165 << 8) | \
  82. (INFINEON_TWTR_165 << 16))
  83. /* Micron part of 3430 EVM (165MHz optimized) 6.06ns
  84. * ACTIMA
  85. * TDAL = Twr/Tck + Trp/tck= 15/6 + 18 /6 = 2.5 + 3 = 5.5 -> 6
  86. * TDPL (Twr) = 15/6 = 2.5 -> 3
  87. * TRRD = 12/6 = 2
  88. * TRCD = 18/6 = 3
  89. * TRP = 18/6 = 3
  90. * TRAS = 42/6 = 7
  91. * TRC = 60/6 = 10
  92. * TRFC = 125/6 = 21
  93. * ACTIMB
  94. * TWTR = 1
  95. * TCKE = 1
  96. * TXSR = 138/6 = 23
  97. * TXP = 25/6 = 4.1 ~5
  98. */
  99. #define MICRON_TDAL_165 6
  100. #define MICRON_TDPL_165 3
  101. #define MICRON_TRRD_165 2
  102. #define MICRON_TRCD_165 3
  103. #define MICRON_TRP_165 3
  104. #define MICRON_TRAS_165 7
  105. #define MICRON_TRC_165 10
  106. #define MICRON_TRFC_165 21
  107. #define MICRON_V_ACTIMA_165 ((MICRON_TRFC_165 << 27) | \
  108. (MICRON_TRC_165 << 22) | (MICRON_TRAS_165 << 18) | \
  109. (MICRON_TRP_165 << 15) | (MICRON_TRCD_165 << 12) | \
  110. (MICRON_TRRD_165 << 9) | (MICRON_TDPL_165 << 6) | \
  111. (MICRON_TDAL_165))
  112. #define MICRON_TWTR_165 1
  113. #define MICRON_TCKE_165 1
  114. #define MICRON_XSR_165 23
  115. #define MICRON_TXP_165 5
  116. #define MICRON_V_ACTIMB_165 ((MICRON_TCKE_165 << 12) | \
  117. (MICRON_XSR_165 << 0) | (MICRON_TXP_165 << 8) | \
  118. (MICRON_TWTR_165 << 16))
  119. #define MICRON_RAMTYPE 0x1
  120. #define MICRON_DDRTYPE 0x0
  121. #define MICRON_DEEPPD 0x1
  122. #define MICRON_B32NOT16 0x1
  123. #define MICRON_BANKALLOCATION 0x2
  124. #define MICRON_RAMSIZE ((PHYS_SDRAM_1_SIZE/(1024*1024))/2)
  125. #define MICRON_ADDRMUXLEGACY 0x1
  126. #define MICRON_CASWIDTH 0x5
  127. #define MICRON_RASWIDTH 0x2
  128. #define MICRON_LOCKSTATUS 0x0
  129. #define MICRON_V_MCFG ((MICRON_LOCKSTATUS << 30) | (MICRON_RASWIDTH << 24) | \
  130. (MICRON_CASWIDTH << 20) | (MICRON_ADDRMUXLEGACY << 19) | \
  131. (MICRON_RAMSIZE << 8) | (MICRON_BANKALLOCATION << 6) | \
  132. (MICRON_B32NOT16 << 4) | (MICRON_DEEPPD << 3) | \
  133. (MICRON_DDRTYPE << 2) | (MICRON_RAMTYPE))
  134. #define MICRON_ARCV 2030
  135. #define MICRON_ARE 0x1
  136. #define MICRON_V_RFR_CTRL ((MICRON_ARCV << 8) | (MICRON_ARE))
  137. #define MICRON_BL 0x2
  138. #define MICRON_SIL 0x0
  139. #define MICRON_CASL 0x3
  140. #define MICRON_WBST 0x0
  141. #define MICRON_V_MR ((MICRON_WBST << 9) | (MICRON_CASL << 4) | \
  142. (MICRON_SIL << 3) | (MICRON_BL))
  143. /*
  144. * NUMONYX part of IGEP v2 (165MHz optimized) 6.06ns
  145. * ACTIMA
  146. * TDAL = Twr/Tck + Trp/tck = 15/6 + 18/6 = 2.5 + 3 = 5.5 -> 6
  147. * TDPL (Twr) = 15/6 = 2.5 -> 3
  148. * TRRD = 12/6 = 2
  149. * TRCD = 22.5/6 = 3.75 -> 4
  150. * TRP = 18/6 = 3
  151. * TRAS = 42/6 = 7
  152. * TRC = 60/6 = 10
  153. * TRFC = 140/6 = 23.3 -> 24
  154. * ACTIMB
  155. * TWTR = 2
  156. * TCKE = 2
  157. * TXSR = 200/6 = 33.3 -> 34
  158. * TXP = 1.0 + 1.1 = 2.1 -> 3
  159. */
  160. #define NUMONYX_TDAL_165 6
  161. #define NUMONYX_TDPL_165 3
  162. #define NUMONYX_TRRD_165 2
  163. #define NUMONYX_TRCD_165 4
  164. #define NUMONYX_TRP_165 3
  165. #define NUMONYX_TRAS_165 7
  166. #define NUMONYX_TRC_165 10
  167. #define NUMONYX_TRFC_165 24
  168. #define NUMONYX_V_ACTIMA_165 ((NUMONYX_TRFC_165 << 27) | \
  169. (NUMONYX_TRC_165 << 22) | (NUMONYX_TRAS_165 << 18) | \
  170. (NUMONYX_TRP_165 << 15) | (NUMONYX_TRCD_165 << 12) | \
  171. (NUMONYX_TRRD_165 << 9) | (NUMONYX_TDPL_165 << 6) | \
  172. (NUMONYX_TDAL_165))
  173. #define NUMONYX_TWTR_165 2
  174. #define NUMONYX_TCKE_165 2
  175. #define NUMONYX_TXP_165 3
  176. #define NUMONYX_XSR_165 34
  177. #define NUMONYX_V_ACTIMB_165 ((NUMONYX_TCKE_165 << 12) | \
  178. (NUMONYX_XSR_165 << 0) | (NUMONYX_TXP_165 << 8) | \
  179. (NUMONYX_TWTR_165 << 16))
  180. #ifdef CONFIG_OMAP3_INFINEON_DDR
  181. #define V_ACTIMA_165 INFINEON_V_ACTIMA_165
  182. #define V_ACTIMB_165 INFINEON_V_ACTIMB_165
  183. #endif
  184. #ifdef CONFIG_OMAP3_MICRON_DDR
  185. #define V_ACTIMA_165 MICRON_V_ACTIMA_165
  186. #define V_ACTIMB_165 MICRON_V_ACTIMB_165
  187. #define V_MCFG MICRON_V_MCFG
  188. #define V_RFR_CTRL MICRON_V_RFR_CTRL
  189. #define V_MR MICRON_V_MR
  190. #endif
  191. #ifdef CONFIG_OMAP3_NUMONYX_DDR
  192. #define V_ACTIMA_165 NUMONYX_V_ACTIMA_165
  193. #define V_ACTIMB_165 NUMONYX_V_ACTIMB_165
  194. #endif
  195. #if !defined(V_ACTIMA_165) || !defined(V_ACTIMB_165)
  196. #error "Please choose the right DDR type in config header"
  197. #endif
  198. #if defined(CONFIG_SPL_BUILD) && (!defined(V_MCFG) || !defined(V_RFR_CTRL))
  199. #error "Please choose the right DDR type in config header"
  200. #endif
  201. /*
  202. * GPMC settings -
  203. * Definitions is as per the following format
  204. * #define <PART>_GPMC_CONFIG<x> <value>
  205. * Where:
  206. * PART is the part name e.g. STNOR - Intel Strata Flash
  207. * x is GPMC config registers from 1 to 6 (there will be 6 macros)
  208. * Value is corresponding value
  209. *
  210. * For every valid PRCM configuration there should be only one definition of
  211. * the same. if values are independent of the board, this definition will be
  212. * present in this file if values are dependent on the board, then this should
  213. * go into corresponding mem-boardName.h file
  214. *
  215. * Currently valid part Names are (PART):
  216. * STNOR - Intel Strata Flash
  217. * SMNAND - Samsung NAND
  218. * MPDB - H4 MPDB board
  219. * SBNOR - Sibley NOR
  220. * MNAND - Micron Large page x16 NAND
  221. * ONNAND - Samsung One NAND
  222. *
  223. * include/configs/file.h contains the defn - for all CS we are interested
  224. * #define OMAP34XX_GPMC_CSx PART
  225. * #define OMAP34XX_GPMC_CSx_SIZE Size
  226. * #define OMAP34XX_GPMC_CSx_MAP Map
  227. * Where:
  228. * x - CS number
  229. * PART - Part Name as defined above
  230. * SIZE - how big is the mapping to be
  231. * GPMC_SIZE_128M - 0x8
  232. * GPMC_SIZE_64M - 0xC
  233. * GPMC_SIZE_32M - 0xE
  234. * GPMC_SIZE_16M - 0xF
  235. * MAP - Map this CS to which address(GPMC address space)- Absolute address
  236. * >>24 before being used.
  237. */
  238. #define GPMC_SIZE_128M 0x8
  239. #define GPMC_SIZE_64M 0xC
  240. #define GPMC_SIZE_32M 0xE
  241. #define GPMC_SIZE_16M 0xF
  242. #define SMNAND_GPMC_CONFIG1 0x00000800
  243. #define SMNAND_GPMC_CONFIG2 0x00141400
  244. #define SMNAND_GPMC_CONFIG3 0x00141400
  245. #define SMNAND_GPMC_CONFIG4 0x0F010F01
  246. #define SMNAND_GPMC_CONFIG5 0x010C1414
  247. #define SMNAND_GPMC_CONFIG6 0x1F0F0A80
  248. #define SMNAND_GPMC_CONFIG7 0x00000C44
  249. #define M_NAND_GPMC_CONFIG1 0x00001800
  250. #define M_NAND_GPMC_CONFIG2 0x00141400
  251. #define M_NAND_GPMC_CONFIG3 0x00141400
  252. #define M_NAND_GPMC_CONFIG4 0x0F010F01
  253. #define M_NAND_GPMC_CONFIG5 0x010C1414
  254. #define M_NAND_GPMC_CONFIG6 0x1f0f0A80
  255. #define M_NAND_GPMC_CONFIG7 0x00000C44
  256. #define STNOR_GPMC_CONFIG1 0x3
  257. #define STNOR_GPMC_CONFIG2 0x00151501
  258. #define STNOR_GPMC_CONFIG3 0x00060602
  259. #define STNOR_GPMC_CONFIG4 0x11091109
  260. #define STNOR_GPMC_CONFIG5 0x01141F1F
  261. #define STNOR_GPMC_CONFIG6 0x000004c4
  262. #define SIBNOR_GPMC_CONFIG1 0x1200
  263. #define SIBNOR_GPMC_CONFIG2 0x001f1f00
  264. #define SIBNOR_GPMC_CONFIG3 0x00080802
  265. #define SIBNOR_GPMC_CONFIG4 0x1C091C09
  266. #define SIBNOR_GPMC_CONFIG5 0x01131F1F
  267. #define SIBNOR_GPMC_CONFIG6 0x1F0F03C2
  268. #define SDPV2_MPDB_GPMC_CONFIG1 0x00611200
  269. #define SDPV2_MPDB_GPMC_CONFIG2 0x001F1F01
  270. #define SDPV2_MPDB_GPMC_CONFIG3 0x00080803
  271. #define SDPV2_MPDB_GPMC_CONFIG4 0x1D091D09
  272. #define SDPV2_MPDB_GPMC_CONFIG5 0x041D1F1F
  273. #define SDPV2_MPDB_GPMC_CONFIG6 0x1D0904C4
  274. #define MPDB_GPMC_CONFIG1 0x00011000
  275. #define MPDB_GPMC_CONFIG2 0x001f1f01
  276. #define MPDB_GPMC_CONFIG3 0x00080803
  277. #define MPDB_GPMC_CONFIG4 0x1c0b1c0a
  278. #define MPDB_GPMC_CONFIG5 0x041f1F1F
  279. #define MPDB_GPMC_CONFIG6 0x1F0F04C4
  280. #define P2_GPMC_CONFIG1 0x0
  281. #define P2_GPMC_CONFIG2 0x0
  282. #define P2_GPMC_CONFIG3 0x0
  283. #define P2_GPMC_CONFIG4 0x0
  284. #define P2_GPMC_CONFIG5 0x0
  285. #define P2_GPMC_CONFIG6 0x0
  286. #define ONENAND_GPMC_CONFIG1 0x00001200
  287. #define ONENAND_GPMC_CONFIG2 0x000F0F01
  288. #define ONENAND_GPMC_CONFIG3 0x00030301
  289. #define ONENAND_GPMC_CONFIG4 0x0F040F04
  290. #define ONENAND_GPMC_CONFIG5 0x010F1010
  291. #define ONENAND_GPMC_CONFIG6 0x1F060000
  292. #define NET_GPMC_CONFIG1 0x00001000
  293. #define NET_GPMC_CONFIG2 0x001e1e01
  294. #define NET_GPMC_CONFIG3 0x00080300
  295. #define NET_GPMC_CONFIG4 0x1c091c09
  296. #define NET_GPMC_CONFIG5 0x04181f1f
  297. #define NET_GPMC_CONFIG6 0x00000FCF
  298. #define NET_GPMC_CONFIG7 0x00000f6c
  299. /* max number of GPMC Chip Selects */
  300. #define GPMC_MAX_CS 8
  301. /* max number of GPMC regs */
  302. #define GPMC_MAX_REG 7
  303. #define PISMO1_NOR 1
  304. #define PISMO1_NAND 2
  305. #define PISMO2_CS0 3
  306. #define PISMO2_CS1 4
  307. #define PISMO1_ONENAND 5
  308. #define DBG_MPDB 6
  309. #define PISMO2_NAND_CS0 7
  310. #define PISMO2_NAND_CS1 8
  311. /* make it readable for the gpmc_init */
  312. #define PISMO1_NOR_BASE FLASH_BASE
  313. #define PISMO1_NAND_BASE NAND_BASE
  314. #define PISMO2_CS0_BASE PISMO2_MAP1
  315. #define PISMO1_ONEN_BASE ONENAND_MAP
  316. #define DBG_MPDB_BASE DEBUG_BASE
  317. #ifndef __ASSEMBLY__
  318. /* Function prototypes */
  319. void mem_init(void);
  320. u32 is_mem_sdr(void);
  321. u32 mem_ok(u32 cs);
  322. u32 get_sdr_cs_size(u32);
  323. u32 get_sdr_cs_offset(u32);
  324. #endif /* __ASSEMBLY__ */
  325. #endif /* endif _MEM_H_ */