mem.h 11 KB

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