1 /******************************************************************************
2 ** File Name: sdram_prod.c *
5 ** Copyright: 2008 Spreadtrum, Incoporated. All Rights Reserved. *
6 ** Description: This file defines the product configurable parameters of *
9 ******************************************************************************
11 ******************************************************************************
13 ** ------------------------------------------------------------------------- *
14 ** DATE NAME DESCRIPTION *
15 ** 04/18/2008 Create. *
16 ******************************************************************************/
18 /**---------------------------------------------------------------------------*
20 **---------------------------------------------------------------------------*/
21 #include <asm/arch/sci_types.h>
22 #include <asm/arch/sdram_cfg.h>
24 /**---------------------------------------------------------------------------*
26 **---------------------------------------------------------------------------*/
30 /**---------------------------------------------------------------------------*
32 **---------------------------------------------------------------------------*/
38 /*********************************************************************************/
40 /*********************************************************************************/
42 #if defined (BB_DRAM_TYPE_32MB_16BIT)
43 #define SDRAM_ROW_MODE ROW_MODE_13
44 #define SDRAM_COL_MODE COL_MODE_9
45 #define SDRAM_DATA_WIDTH DATA_WIDTH_16
46 #define SDRAM_SIZE SDRAM_32M
48 #elif defined(BB_DRAM_TYPE_32MB_32BIT_13R)
49 #define SDRAM_ROW_MODE ROW_MODE_13
50 #define SDRAM_COL_MODE COL_MODE_8
51 #define SDRAM_DATA_WIDTH DATA_WIDTH_32
52 #define SDRAM_SIZE SDRAM_32M
54 #elif defined(BB_DRAM_TYPE_32MB_32BIT_12R)
55 #define SDRAM_ROW_MODE ROW_MODE_12
56 #define SDRAM_COL_MODE COL_MODE_9
57 #define SDRAM_DATA_WIDTH DATA_WIDTH_32
58 #define SDRAM_SIZE SDRAM_32M
60 #elif defined(BB_DRAM_TYPE_64MB_16BIT)
61 #define SDRAM_ROW_MODE ROW_MODE_13
62 #define SDRAM_COL_MODE COL_MODE_10
63 #define SDRAM_DATA_WIDTH DATA_WIDTH_16
64 #define SDRAM_SIZE SDRAM_64M
66 #elif defined(BB_DRAM_TYPE_64MB_32BIT)
67 #define SDRAM_ROW_MODE ROW_MODE_13
68 #define SDRAM_COL_MODE COL_MODE_9
69 #define SDRAM_DATA_WIDTH DATA_WIDTH_32
70 #define SDRAM_SIZE SDRAM_64M
72 #elif defined(BB_DRAM_TYPE_128MB_16BIT)
73 #define SDRAM_ROW_MODE ROW_MODE_14
74 #define SDRAM_COL_MODE COL_MODE_10
75 #define SDRAM_DATA_WIDTH DATA_WIDTH_16
76 #define SDRAM_SIZE SDRAM_128M
78 #elif defined(BB_DRAM_TYPE_128MB_32BIT)
79 #define SDRAM_ROW_MODE ROW_MODE_13
80 #define SDRAM_COL_MODE COL_MODE_10
81 #define SDRAM_DATA_WIDTH DATA_WIDTH_32
82 #define SDRAM_SIZE SDRAM_128M
84 #elif defined(BB_DRAM_TYPE_256MB_32BIT)
85 #define SDRAM_ROW_MODE ROW_MODE_14
86 #define SDRAM_COL_MODE COL_MODE_10
87 #define SDRAM_DATA_WIDTH DATA_WIDTH_32
88 #define SDRAM_SIZE SDRAM_256M
91 #error do not select size and bit width for SDRAM
94 #define BK_MODE BK_MODE_4
96 #if defined(PLATFORM_SC8800H)
97 #define BURST_LEN BURST_LEN_8
98 #elif defined(PLATFORM_SC6800H)
99 #define BURST_LEN BURST_LEN_2
100 #elif defined(PLATFORM_SC8800G)
101 #define BURST_LEN BURST_LEN_2
102 #elif defined(CONFIG_SC8810)
103 #define BURST_LEN BURST_LEN_2
105 #error do not select burst len for SDRAM
108 #define CAS_LATENCY CAS_LATENCY_3
110 // Include Product config
111 #include "sdram_cfg.c"
113 /**---------------------------------------------------------------------------*
115 **---------------------------------------------------------------------------*/
116 #ifdef CONFIG_SP8810 // for 8810&6820
117 LOCAL CONST EMC_PARAM_T s_emc_parm =
120 1000000000, // arm_clk 1G
121 400000000, // emc_clk 400M
131 0x818, // value read from 0x20000174
133 //set cs map to external memory
134 7 , //set cs map to 2G bit
136 #else // for openphone
137 LOCAL CONST EMC_PARAM_T s_emc_parm =
140 850000000, // arm_clk 850M
141 333000000, // emc_clk 333M
151 0x81c, // value read from 0x20000174
155 /*******************************************************************************/
156 // sdram_parameters[] is used to config SDRAM controller according to variable
157 //sdram. The unit is ns. The end of array is marked with 0xffffffff at the last element.
158 /*******************************************************************************/
159 LOCAL CONST SDRAM_TIMING_PARA_T s_sdram_timing_param =
160 // ms ns ns ns ns ns ns ns clk clk
161 // tREF, tRP, tRCD, tWR/tRDL/tDPL,tRFC,tXSR, tRAS,tRRD,tMRD, tWTR(wtr is only for ddr)
162 {64, 30, 30, 20, 110, 150, 60, 20, 2, 2 };
164 /*******************************************************************************/
165 // sdram_cofig_info is used to config sdram controller when to init sdram
166 /*******************************************************************************/
167 LOCAL CONST SDRAM_CFG_INFO_T s_sdram_config_info =
175 SDRAM_EXT_MODE_VALUE,
179 /**---------------------------------------------------------------------------*
180 ** Public Function Prototypes *
181 **---------------------------------------------------------------------------*/
182 PUBLIC EMC_PARAM_T_PTR EMC_GetPara(void)
184 return (EMC_PARAM_T_PTR)&s_emc_parm;
188 /*****************************************************************************/
189 // Description: This function get sdram config pointer
192 /*****************************************************************************/
193 PUBLIC SDRAM_CFG_INFO_T_PTR SDRAM_GetCfg(void)
195 return (SDRAM_CFG_INFO_T_PTR)&s_sdram_config_info;
198 /*****************************************************************************/
199 // Description: This function get sdram timing parameter pointer
200 // Author: Liangwen.Zhen
202 /*****************************************************************************/
203 PUBLIC SDRAM_TIMING_PARA_T_PTR SDRAM_GetTimingPara(void)
205 return (SDRAM_TIMING_PARA_T_PTR)&s_sdram_timing_param;
208 /*****************************************************************************/
209 // Description: This function can be defined by user if needed. It will be called
210 // before the SDRAM initialization.
213 /*****************************************************************************/
214 PUBLIC void Userdef_before_sdram_init(void)
218 /*****************************************************************************/
219 // Description: This function can be defined by user if needed. It will be called
220 // after the SDRAM initialization.
223 /*****************************************************************************/
224 PUBLIC void Userdef_after_sdram_init(void)
229 /**---------------------------------------------------------------------------*
231 **---------------------------------------------------------------------------*/