1 /******************************************************************************
2 ** File Name: emc_drvapi.h *
5 ** Copyright: 2008 Spreatrum, Incoporated. All Rights Reserved. *
6 ** Description: EMC drv public type and exprot interface declaration *
7 ******************************************************************************
9 ******************************************************************************
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_
20 /**---------------------------------------------------------------------------*
22 **---------------------------------------------------------------------------*/
23 /**---------------------------------------------------------------------------*
25 **---------------------------------------------------------------------------*/
31 #if defined(PLATFORM_SC6600L)
33 #define DISABLE_CACHE EMC_DisableCache();
34 #define ENABLE_CACHE EMC_EnableCache();
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();
42 #define EMC_REG(_ADDR) (REG32(_ADDR))
44 #define EMC_CS_REG_INIT_FLAG 0x5a5a5a5a
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
76 EMC_WRITE_NORMAL_MODE = 0,//asynchronous single-mode write
77 EMC_WRITE_BURST_MODE //synchronous burst-mode write
88 } EMC_PAGE_BURST_LEN_E;
90 typedef struct emc_mode_cfg_s
92 EMC_CS_MEM_TYPE_E emc_cs_mem_type; //flash,psram
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;
99 } EMC_MODE_CFG_T, * EMC_MODE_CFG_PTR;
101 typedef void *EMC_TIMING_PTR;
103 typedef struct emc_reginfo_s
106 EMC_MODE_CFG_PTR emc_cs_cfg_ptr;
107 EMC_TIMING_PTR emc_cs_mem_info_ptr;
111 /**---------------------------------------------------------------------------*
112 ** Function Definitions *
113 **---------------------------------------------------------------------------*/
114 /*****************************************************************************/
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
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);
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);
135 /*****************************************************************************/
141 /*****************************************************************************/
142 void EMC_EnableCache (void);
144 /*****************************************************************************/
150 /*****************************************************************************/
151 void EMC_DisableCache (void);
154 /*****************************************************************************/
155 // Description: This function is used to set EMC reg value according different ahb clk.
156 // Global resource dependence :
157 // Author: younger.yang
159 /*****************************************************************************/
160 PUBLIC void EMC_Timing_chng (uint32 ahb_clk);
162 /*****************************************************************************/
164 // Set All EMC CS Parameter To Default.
170 /*****************************************************************************/
171 PUBLIC void EMC_Close (void);
173 /**---------------------------------------------------------------------------*
175 **---------------------------------------------------------------------------*/
180 #endif // _EMC_DRVAPI_H_