993f54df44cc2eb1495edd724424377befd2d62f
[profile/mobile/platform/kernel/u-boot-tm1.git] / arch / arm / include / asm / arch-tiger / chip_drvapi.h
1 /******************************************************************************
2  ** File Name:      chip_drvapi.h                                                    *
3  ** Author:         Richard Yang                                              *
4  ** DATE:           08/14/2002                                                *
5  ** Copyright:      2002 Spreatrum, Incoporated. All Rights Reserved.         *
6  ** Description:    This driver is for spreadtrum chip set.                   *
7  ******************************************************************************
8
9  ******************************************************************************
10  **                        Edit History                                       *
11  ** ------------------------------------------------------------------------- *
12  ** DATE           NAME             DESCRIPTION                               *
13  ** 08/14/2002     Richard.Yang     Create.                                   *
14  ** 09/16/2003     Xueliang.Wang    Modify CR4013                 *
15  ******************************************************************************/
16 #ifndef _CHIP_DRVAPI_H_
17 #define _CHIP_DRVAPI_H_
18
19 /**---------------------------------------------------------------------------*
20  **                         Dependencies                                      *
21  **---------------------------------------------------------------------------*/
22
23 /**---------------------------------------------------------------------------*
24  **                         Compiler Flag                                     *
25  **---------------------------------------------------------------------------*/
26 #ifdef __cplusplus
27 extern   "C"
28 {
29 #endif
30
31 /**---------------------------------------------------------------------------*
32  **                         Defines                                           *
33  **---------------------------------------------------------------------------*/
34 //PLL clock
35 #define PLL_CLK_192M        192000000
36
37 #define CLK_DIV_1M            1000000
38
39 // ARM valid clock.
40 #define ARM_CLK_13M         13000000
41 #define ARM_CLK_20M         20000000
42 #define ARM_CLK_24M         24000000
43 #define ARM_CLK_26M         26000000
44 #define ARM_CLK_27M         27000000
45 #define ARM_CLK_28M         28800000
46 #define ARM_CLK_30M         30720000
47 #define ARM_CLK_32M         32000000
48 #define ARM_CLK_36M         36000000
49 #define ARM_CLK_39M         39000000
50 #define ARM_CLK_41M         41000000
51 #define ARM_CLK_48M         48000000
52 #define ARM_CLK_50M         50000000
53 #define ARM_CLK_52M         52000000
54 #define ARM_CLK_54M         54000000
55 #define ARM_CLK_60M         60000000
56 #define ARM_CLK_61M         61440000
57 #define ARM_CLK_64M         64000000
58 #define ARM_CLK_66M         66000000
59 #define ARM_CLK_78M         78000000
60 #define ARM_CLK_71M         71500000
61 #define ARM_CLK_72M         72000000
62 #define ARM_CLK_80M         80000000
63 #define ARM_CLK_82M         82000000
64 #define ARM_CLK_85M         85000000
65 #define ARM_CLK_96M         96000000
66 #define ARM_CLK_100M       100000000
67 #define ARM_CLK_102M       102000000
68 #define ARM_CLK_104M       104000000
69 #define ARM_CLK_109M       109000000
70 #define ARM_CLK_120M       120000000
71 #define ARM_CLK_128M       128000000
72 #define ARM_CLK_153M       153600000
73 #define ARM_CLK_164M       164000000
74 #define ARM_CLK_192M       192000000
75 #define ARM_CLK_200M       200000000
76 #define ARM_CLK_256M       256000000
77 #define ARM_CLK_384M       384000000
78 #define ARM_CLK_400M       400000000
79 #define ARM_CLK_512M       512000000
80
81 /**---------------------------------------------------------------------------*
82  **                         Constant Variables                                *
83  **---------------------------------------------------------------------------*/
84 typedef enum chip_serial_tag
85 {
86     SERIAL_SC6600I,
87     SERIAL_SC6600R,
88     SERIAL_SC6600H,
89     SERIAL_SC6800D,
90     SERIAL_SC8800D,
91     SERIAL_SC6600L,
92     SERIAL_SC8800H,
93     SERIAL_SC6800H,
94     SERIAL_SC8800G,
95     CHIP_SERIAL_MAX
96 }
97 CHIP_SERIAL_E;
98
99 typedef enum chip_type_tag
100 {
101     SC6600I_ID_BASE = SERIAL_SC6600I << 16,
102     SC6600I,
103     SC6600I_ID_MAX,
104     SC6600R_ID_BASE = SERIAL_SC6600R << 16,
105     SC6600R1,
106     SC6600R2,
107     SC6600R2A,
108     SC6600R3,
109     SC6600R3A,
110     SC6600R_ID_MAX,
111     SC6600H_ID_BASE = SERIAL_SC6600H << 16,
112     SC6600H1,
113     SC6600H2,
114     SC6600H3,
115     SC6600H_ID_MAX,
116     SC6800D_ID_BASE = SERIAL_SC6800D << 16,
117     SC6800D,
118     SC6800D_ID_MAX,
119     SC8800D_ID_BASE = SERIAL_SC8800D << 16,
120     SC8800D,
121     SC8800D_ID_MAX,
122     SC6600L_ID_BASE = SERIAL_SC6600L << 16,
123     SC6600L,
124     SC6600L2,
125     SC6600L7,
126     SC6600H3A,
127     SC6600W2,
128     SC6600L_ID_MAX,
129     SC8800H_ID_BASE = SERIAL_SC8800H << 16,
130     SC8800H,
131     SC8800S3B,
132     /* modified by zhengfei.xiao for SC8800H5 */
133     SC8800H5,
134     SC8800S4_AC,
135     SC8800H5_AC,
136     SC8800H_ID_MAX,
137     SC6800H_ID_BASE = SERIAL_SC6800H << 16,
138     SC6800H,
139     SC6800H_ID_MAX,
140     SC8800G_ID_BASE = SERIAL_SC8800G << 16,
141     SC8800G1,
142     SC8800G2,
143     SC8801G2,
144     SC8802G2,
145     SC8800G_ID_MAX,
146     CHIP_TYPE_MAX = 0x7FFFFFFF
147 } CHIP_TYPE_E;
148
149 //define dsp rom code id
150 typedef enum chip_dsp_rom_id_tag
151 {
152     CHIP_DSP_ROM_V1,
153     CHIP_DSP_ROM_V2,
154     CHIP_DSP_ROM_V3,
155     CHIP_DSP_ROM_ID_MAX
156 } CHIP_DSP_ROM_ID_E;
157
158 typedef enum module_clk
159 {
160     CLK_MCU = 16,
161     CLK_APB,
162     CLK_DSP,
163     CLK_CAL,
164     CLK_12M,
165     CLK_48M,
166     CLK_CCIR,
167     CLK_DCAM,
168     CLK_IIS,
169     CLK_VBC,
170     CLK_CDC,
171     CLK_AUX0,
172     CLK_AUX1
173 } MODULE_CLK_E;
174
175 typedef enum module_clk_src
176 {
177     CLKPLL = 0,
178     CLKUPLL,
179     CLK13M,
180     CLK32K
181 } MODULE_CLK_SRC_E;
182
183 typedef struct _SYS_CLK_CFG_INFO
184 {
185     uint32 pll_mn;
186     uint32 upll_mn;
187     uint32 dsp_arm_div;
188 } SYS_CLK_CFG_INFO;
189
190 typedef struct  _CHIP_INFO
191 {
192     CHIP_TYPE_E type;
193     char info[16];
194 } CHIP_INFO;
195
196 /**---------------------------------------------------------------------------*
197  **                         Function Prototypes                               *
198  **---------------------------------------------------------------------------*/
199 /*****************************************************************************/
200 //  Description:    The function is used to return chip ID (a uint32 number).
201 //  Global resource dependence:
202 //  Author:         Xueliang.Wang
203 //  Note:
204 /*****************************************************************************/
205 PUBLIC  uint32 CHIP_GetHWChipID (void);  // return chip ID number.
206
207 /*****************************************************************************/
208 //  Description:    The function is used to detect the memory type
209 //  Global resource dependence:
210 //  Author:         Nick.Zhao
211 //  Return value:
212 //                1      CS0 connects to SDRAM
213 //                0      CS0 connects to FLASH
214 /*****************************************************************************/
215 PUBLIC uint32 CHIP_DetectMemType (void);
216
217 /*****************************************************************************/
218 // Description :    This function is used to get current ARM clock.
219 // Global resource dependence :
220 // Author :         Xueliang.Wang
221 // Note :
222 /*****************************************************************************/
223 uint32 CHIP_GetArmClk (void);
224 /*****************************************************************************/
225 // Description :    This function is used to get current AHB clock.
226 // Global resource dependence :
227 // Author :         Zhengjiang.Lei
228 // Note :
229 /*****************************************************************************/
230 uint32 CHIP_GetAhbClk (void);
231 /*****************************************************************************/
232 // Description :    This function is used to get current APB clock.
233 // Global resource dependence :
234 // Author :         Xueliang.Wang
235 // Note :
236 /*****************************************************************************/
237 uint32 CHIP_GetAPBClk (void);
238 /*****************************************************************************/
239 // Description :    This function is used to get current PLL clock.
240 // Global resource dependence :
241 // Author :         Xueliang.Wang
242 // Note :
243 /*****************************************************************************/
244 uint32 CHIP_GetPllClk (void);
245
246 /*****************************************************************************/
247 // Description :    This function is used to get current PLL clock.
248 // Global resource dependence :
249 // Author :         Xueliang.Wang
250 // Note :
251 /*****************************************************************************/
252 uint32 CHIP_GetMPllClk (void);
253
254 /*****************************************************************************/
255 // Description :    This function is used to get current VPLL clock.
256 // Global resource dependence :
257 // Author :         Xueliang.Wang
258 // Note :           Daniel.ding add it for SC6800 .
259 /*****************************************************************************/
260 uint32 CHIP_GetVPllClk (void);
261
262
263 /*****************************************************************************/
264 // Description :    This function is used to disable all fiqs on sc6600d
265 // Global resource dependence :
266 // Author :         Xueliang.Wang
267 // Note :           every bit indicates one fiq src
268 /*****************************************************************************/
269 void CHIP_DisableFIQ (void);
270
271
272 /*****************************************************************************/
273 // Description :    This function is used to turn off the power.
274 // Global resource dependence :
275 // Author :         Xueliang.Wang
276 // Note :
277 /*****************************************************************************/
278 void CHIP_TurnOffPower (void);
279
280 /*****************************************************************************/
281 // Description :    This function is used to reset MCU.
282 // Global resource dependence :
283 // Author :         Xueliang.Wang
284 // Note :
285 /*****************************************************************************/
286 void CHIP_ResetMCU (void);
287
288 /*****************************************************************************/
289 // Description :    This function is used to reset MCU from boot code.
290 // Global resource dependence :
291 // Author :         Xueliang.Wang
292 // Note :
293 /*****************************************************************************/
294 void CHIP_BootReset (void);
295
296
297 /*****************************************************************************/
298 // Description :    This function is used to get current DSP clock.
299 // Global resource dependence :
300 // Author :         Benjamin.Wang
301 // Note :
302 /*****************************************************************************/
303 uint32 CHIP_GetDspClk (void);
304
305 /*****************************************************************************/
306 // Description :    This function is used to get current VPLL clock.
307 // Global resource dependence :
308 // Author :         Xueliang.Wang
309 // Note :           Aiguo.Miao update it for SC8800H .
310 /*****************************************************************************/
311 uint32 CHIP_GetTDPllClk (void);
312
313 /*********************************************************************************************/
314 //Description:   This function is used to initializtion system clk and other
315 //Author:
316 //Note:          Can't use trace and assert in this funciton ;
317 //Parameter:
318 /*********************************************************************************************/
319 void CHIP_Init (void);
320
321 /*****************************************************************************/
322 // Description :    This function is used get the chip type
323 // Global resource dependence : none
324 // Author :         yuhua.shi
325 // Note :
326 /*****************************************************************************/
327 PUBLIC CHIP_TYPE_E CHIP_GetChipType (void);
328
329
330 /*****************************************************************************/
331 // Description :    This function is used get the chip type
332 // Global resource dependence : none
333 // Author :         yuhua.shi
334 // Note :
335 /*****************************************************************************/
336 PUBLIC const char *CHIP_GetChipInfo (void);
337
338
339 /*****************************************************************************/
340 // Description :    This function is active/deactive share-memory clock
341 // Global resource dependence : none
342 // Author :
343 // Note :
344 /*****************************************************************************/
345 PUBLIC void CHIP_ActiveSMCLK (BOOLEAN is_active);
346 /*****************************************************************************/
347 // Description :    This function is Get Usb DM Value
348 // Global resource dependence : none
349 // Author :
350 // Note :
351 /*****************************************************************************/
352 PUBLIC BOOLEAN CHIP_GetUsbDMValue (void);
353
354 /*****************************************************************************/
355 //  Description:    The function is used to get the chip ID (a uint32 number).
356 //  Global resource dependence:
357 //  Author:         Richard.Yang
358 //  Note:           It must be called before any hardware related settings
359 /*****************************************************************************/
360 PUBLIC void CHIP_InitHWChipID (void);
361
362 #ifdef PLATFORM_SC8800H
363 /*****************************************************************************/
364 //  Description:    The function is used to init TD Calibration clock
365 //  Author:         Jeff.li
366 //  Note:
367 /*****************************************************************************/
368 PUBLIC void CHIP_TDCalClk_Init (void);
369
370 /*****************************************************************************/
371 //  Description:    The function is used to init TD clock
372 //  Author:         Jeff.li
373 //  Note:
374 /*****************************************************************************/
375 PUBLIC void CHIP_CEVAClk_Init (uint8 dsp_clk_sel);
376
377 /*****************************************************************************/
378 //  Description:    The function is called by Layer1 when response to DSP sleep
379 //  Author:         Jeff.li
380 //  Note:           Close RFLDO/TD CAL/UART
381 /*****************************************************************************/
382 PUBLIC void CHIP_DSPSleep (void);
383
384 /*****************************************************************************/
385 //  Description:    The function is called by Layer1 when response to DSP wake up
386 //  Author:         Jeff.li
387 //  Note:           Open RFLDO/TD CAL/UART
388 /*****************************************************************************/
389 PUBLIC void CHIP_DSPWakeUp (void);
390
391 /*****************************************************************************/
392 //  Description:    The function is used to get to know wheather use UART1 for LOG or not
393 //  Author:         Jeff.li
394 //  Note:
395 /*****************************************************************************/
396 PUBLIC uint32 CHIP_GetUART1LogMode (void);
397
398 /*****************************************************************************/
399 //  Description:    The function is used to set wheather use UART1 for LOG or not
400 //  Author:         Jeff.li
401 //  Note:
402 /*****************************************************************************/
403 PUBLIC void CHIP_SetUART1LogMode (uint32 UART1LogEn);
404
405 /*****************************************************************************/
406 //  Description:    The function is called by Layer1 when response to DSP wake up
407 //  Author:         Jeff.li
408 //  Note:           Disable UART1
409 /*****************************************************************************/
410 PUBLIC void CHIP_DSPUART1Dis (void);
411
412 /*****************************************************************************/
413 //  Description:    The function is called by Layer1 when response to DSP wake up
414 //  Author:         Jeff.li
415 //  Note:           Open UART1
416 /*****************************************************************************/
417 PUBLIC void CHIP_DSPUART1En (void);
418
419 #endif
420
421 /*****************************************************************************/
422 //  Description:   This function is used to do something before assert.
423 //  Global resource dependence:
424 //  Author:         Zhengjiang.Lei
425 //  Note:
426 /*****************************************************************************/
427
428 PUBLIC void CHIP_BeforeAssert (void);
429
430 /*below are removed from driver_export.c, wait clean up*/
431 // The function is used to reset dsp when arm system enter assert mode
432 PUBLIC BOOLEAN CHIP_ResetDspInAssertMode (void);
433
434 // The function is used to reset and set dsp to output dsp assert log to pc by uart1
435 PUBLIC void CHIP_DspOutPutAssertInfo (void);
436
437 // The function is used to get the IRAM/SHARE-MEMORY buf to store assert information
438 // in the assert mode.
439 // The buffer size must be larger than size(IRAM_buf) structure
440 PUBLIC void *CHIP_GetAssertInfoBufBase (void);
441
442 /******************************************************************************/
443 // Description:   Enable MCU can access switched-ram and shared-ram.
444 // Dependence:    NONE
445 // Author:        Haifeng.Yang
446 // Note:          Beforce invoking this function, the DSP/ISP should be hold on!
447 /******************************************************************************/
448 PUBLIC uint32 Chip_SwitchIRAM2Arm (void);
449
450 /******************************************************************************/
451 // Description:   handle function when dsp exception
452 // Dependence:    NONE
453 // Author:        
454 // Note:          
455 /******************************************************************************/
456 PUBLIC void L1API_DSPExceptionHandle(void);
457
458 extern SYS_CLK_CFG_INFO *Get_system_clk_cfg (void);
459 extern  void EMC_Close (void);
460 extern void __tx_reset (void);
461
462 /**---------------------------------------------------------------------------*
463  **                         Compiler Flag                                     *
464  **---------------------------------------------------------------------------*/
465 #ifdef __cplusplus
466 }
467 #endif
468
469 #endif // _CHIP_DRVAPI_H_