tizen 2.4 release
[profile/mobile/platform/kernel/u-boot-tm1.git] / arch / arm / include / asm / arch-sc8810 / emc_drvapi.h
1 /******************************************************************************
2  ** File Name:      emc_drvapi.h                                                                                   *
3  ** Author:         lin.liu                                                                                         *
4  ** DATE:           17/12/2008                                                                                  *
5  ** Copyright:      2008 Spreatrum, Incoporated. All Rights Reserved.                                   *
6  ** Description:    EMC drv public type and exprot interface declaration                                *
7  ******************************************************************************
8
9  ******************************************************************************
10  **                        Edit History                                       *
11  ** ------------------------------------------------------------------------- *
12  ** DATE           NAME             DESCRIPTION                               *
13  ** 27/11/2001     Lin.liu          Create.                                   *
14  ** 17/12/2008    hyy       Modify
15  ******************************************************************************/
16 #ifndef _EMC_DRVAPI_H_
17 #define _EMC_DRVAPI_H_
18
19
20 /**---------------------------------------------------------------------------*
21  **                         Dependencies                                      *
22  **---------------------------------------------------------------------------*/
23 /**---------------------------------------------------------------------------*
24  **                         Compiler Flag                                     *
25  **---------------------------------------------------------------------------*/
26 #ifdef __cplusplus
27 extern   "C"
28 {
29 #endif
30
31 #if defined(PLATFORM_SC6600L)
32
33 #define DISABLE_CACHE   EMC_DisableCache();
34 #define ENABLE_CACHE    EMC_EnableCache();
35
36 #elif defined(PLATFORM_SC6800H)
37 /*Since MMU Config Flash Code region to read only, then before send flash
38   command at code region should close MMU and Cache*/
39 #define DISABLE_CACHE   MMU_Disable();
40 #define ENABLE_CACHE     MMU_Enable();
41 #endif
42 #define EMC_REG(_ADDR)              (REG32(_ADDR))
43
44 #define EMC_CS_REG_INIT_FLAG        0x5a5a5a5a
45
46
47 typedef enum
48 {
49     EMC_CS0 = 0,
50     EMC_CS1,
51     EMC_CS2,
52     EMC_CS3,
53     EMC_CS4,
54     EMC_CS_MAX
55 }
56 EMC_CS_NUM_E;
57
58
59 typedef enum
60 {
61     EMC_MEM_FLASH = 0,
62     EMC_MEM_SRAM,
63     EMC_MEM_LCM,
64     EMC_MEM_OTHER
65 } EMC_CS_MEM_TYPE_E;
66
67 typedef enum
68 {
69     EMC_READ_NORMAL_MODE    = 0x0,  //asynchronous single-mode read
70     EMC_READ_PAGE_MODE          ,       //asynchronous page-mode read
71     EMC_READ_BURST_MODE         //synchronous burst-mode read
72 } EMC_READ_MODE_E;
73
74 typedef enum
75 {
76     EMC_WRITE_NORMAL_MODE = 0,//asynchronous single-mode write
77     EMC_WRITE_BURST_MODE        //synchronous burst-mode write
78 } EMC_WRITE_MODE_E;
79
80 typedef enum
81 {
82     EMC_LEN_SINGLE = 0x0,
83     EMC_LEN_4 ,
84     EMC_LEN_8 ,
85     EMC_LEN_16 ,
86     EMC_LEN_32,
87     EMC_LEN_CONTINUOUS
88 } EMC_PAGE_BURST_LEN_E;
89
90 typedef struct emc_mode_cfg_s
91 {
92     EMC_CS_MEM_TYPE_E       emc_cs_mem_type;         //flash,psram
93
94     EMC_READ_MODE_E         emc_read_mode;
95     EMC_PAGE_BURST_LEN_E    emc_read_len;
96     EMC_WRITE_MODE_E        emc_write_mode;
97     EMC_PAGE_BURST_LEN_E    emc_write_len;
98     void                       *other;
99 } EMC_MODE_CFG_T, * EMC_MODE_CFG_PTR;
100
101 typedef void *EMC_TIMING_PTR;
102
103 typedef struct emc_reginfo_s
104 {
105     EMC_CS_NUM_E            emc_cs;
106     EMC_MODE_CFG_PTR    emc_cs_cfg_ptr;
107     EMC_TIMING_PTR          emc_cs_mem_info_ptr;
108     uint32              reg_flag;
109 } EMC_REGINFO_T;
110
111 /**---------------------------------------------------------------------------*
112  **                         Function Definitions                              *
113  **---------------------------------------------------------------------------*/
114 /*****************************************************************************/
115 //  Description :
116 //      1.call FLASH_ReadID to get manufacture ID and device ID
117 //      2.call GetNorMCP_Entity to get normcp configuration from user table
118 //      3.call FLASH_InitHAL to init flash HAL
119 //  Global resource dependence :
120 //      s_normcp_entity_ptr
121 //      g_normcp_spec_ptr
122 //      g_Nor_Config_ptr
123 //      g_Nor_Driver_ptr
124 //
125 //  Author:
126 //      Younger.yang
127 //  Note:
128 //      code must be located at SRAM or internal-RAM.
129 //      must be called before EMC_Timing_cfg()
130 /*****************************************************************************/
131 PUBLIC void EMC_Init (void);
132
133 PUBLIC void EMC_RegMemoryInfo (EMC_CS_NUM_E cs_num, EMC_MODE_CFG_PTR emc_cs_cfg_ptr, EMC_TIMING_PTR emc_cs_mem_info_ptr);
134
135 /*****************************************************************************/
136 //  Description :
137 //  Author:
138 //      Younger.yang
139 //  Note:
140 //      Enable CS0 Cache
141 /*****************************************************************************/
142 void EMC_EnableCache (void);
143
144 /*****************************************************************************/
145 //  Description :
146 //  Author:
147 //      Younger.yang
148 //  Note:
149 //      Disable CS0 Cache
150 /*****************************************************************************/
151 void EMC_DisableCache (void);
152
153
154 /*****************************************************************************/
155 //  Description:    This function is used to set EMC reg value according different ahb clk.
156 //  Global resource dependence :
157 //  Author:          younger.yang
158 //  Note:
159 /*****************************************************************************/
160 PUBLIC void EMC_Timing_chng (uint32 ahb_clk);
161
162 /*****************************************************************************/
163 //  Description :
164 //  Set All EMC CS Parameter To Default.
165 //
166 //  Author:
167 //      Younger.yang
168 //  Note:
169 //
170 /*****************************************************************************/
171 PUBLIC void EMC_Close (void);
172
173 /**---------------------------------------------------------------------------*
174  **                         Compiler Flag                                     *
175  **---------------------------------------------------------------------------*/
176 #ifdef __cplusplus
177 }
178 #endif
179
180 #endif // _EMC_DRVAPI_H_