46cd71bf8462140014e88e357f297a3928f0669d
[profile/mobile/platform/kernel/u-boot-tm1.git] / arch / arm / include / asm / arch-sc8825 / chng_freq_drvapi.h
1 /******************************************************************************
2  ** File Name:      chng_freq_drvapi.h                                                    *
3  ** Author:         Zhengjiang.Lei                                              *
4  ** DATE:           12/08/2006                                                *
5  ** Copyright:      2006 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  ** 12/08/2006     Zhengjiang.Lei     Create.                                   *
14    ** 08/17/2010     Yuhua.Shii     Modify.                                   *
15  ******************************************************************************/
16 #ifndef _CHNG_FREQ_DRVAPI_H_
17 #define _CHNG_FREQ_DRVAPI_H_
18
19 /**---------------------------------------------------------------------------*
20  **                         Compiler Flag                                     *
21  **---------------------------------------------------------------------------*/
22 #ifdef __cplusplus
23 extern   "C"
24 {
25 #endif
26
27 /*----------------------------------------------------------------------------*
28  **                         Dependencies                                      *
29  **-------------------------------------------------------------------------- */
30
31 /**---------------------------------------------------------------------------*
32  **                         Defines                                           *
33  **---------------------------------------------------------------------------*/
34 //define the freq index for application(the freq index should be defined continuously)
35 #define FREQ_INDEX_BASE 0
36 typedef enum
37 {
38     FREQ_INDEX_GENERAL = FREQ_INDEX_BASE,//general freq index can be used for general application
39     FREQ_INDEX_MP3,                 //mp3 freq index
40     FREQ_INDEX_MIDI,                //midi freq index
41     FREQ_INDEX_AAC,                 //aac freq index
42     FREQ_INDEX_DC_LOW,          //dc low freq index
43     FREQ_INDEX_DC_HIGH,            //dc high freq index
44     FREQ_INDEX_ISP_LOW,         //isp low freq index
45     FREQ_INDEX_ISP_HIGH,               //isp high freq index
46     FREQ_INDEX_MP4_PLAY_LVL1,   //mp4 play level1 freq index
47     FREQ_INDEX_MP4_PLAY_LVL2,   //mp4 play level2 freq index
48     FREQ_INDEX_MP4_PLAY_LVL3,   //mp4 play level3 freq index
49     FREQ_INDEX_MP4_PLAY_LVL4,   //mp4 play level4 freq index
50     FREQ_INDEX_MP4_REC,         //mp4 record freq index
51     FREQ_INDEX_USB_LOW,         //usb low freq index
52     FREQ_INDEX_USB_MID,         //usb middle freq index
53     FREQ_INDEX_USB_HIGH,            //usb high freq index
54     FREQ_INDEX_PCM_BLUE_PLAY,   //pcm blue play freq index
55     FREQ_INDEX_BT_IDLE,         //bt idle freq index
56     FREQ_INDEX_BT_FTP,          //bt ftp freq index
57     FREQ_INDEX_BT_HFG,          //bt hfg freq index
58     FREQ_INDEX_BT_A2DP,         //bt a2dp freq index
59     FREQ_INDEX_ATC,               //atc freq index
60
61     FREQ_INDEX_CUSTOMIZED_BASE=0x1000, //base index for customized clk
62
63     //from FREQ_INDEX_CUSTOMIZED_BASE to FREQ_INDEX_MAX, reserved for application use
64
65     FREQ_INDEX_MAX = 0xFFFF           //max freq index
66                  }
67                  CHNG_FREQ_INDEX_E;
68
69 //define the min level that arm/ahb can run in our system( >= 0x1).
70 #define ARM_CLK_LVL5    0x5
71 #define ARM_CLK_LVL4    0x4
72 #define ARM_CLK_LVL3    0x3
73 #define ARM_CLK_LVL2    0x2
74
75
76 #define     WAIT_EMC_IDLE_TIMEOUT_RET        0xFF
77 #define CHNG_FREQ_REQ_HANDLER_NULL      0xFFFFFFFF
78
79 /*
80     define the event id of frequency-changing sync. usually all ahb masters which
81     will trig a hardware burst to access sdram should be defined .
82 */
83 typedef enum
84 {
85     FREQ_CHNG_EVENT_LCDC = 0,
86     FREQ_CHNG_EVENT_MPEG_ENC,
87     FREQ_CHNG_EVENT_MPEG_DEC,
88     FREQ_CHNG_EVENT_ISP,
89     FREQ_CHNG_EVENT_SDIO,
90     FREQ_CHNG__MAX_EVENT_ID
91 } FREQ_CHNG_EVENT_E;
92
93 #define FREQ_CHNG_EVENT_ALL             ((1<<FREQ_CHNG__MAX_EVENT_ID) - 1)
94
95 typedef enum
96 {
97     SYS_MODE_ASSERT = 0,            // Assert state
98     SYS_MODE_NORMAL    ,            // Normal Run
99     SYS_MODE_INT                // Interrupt state
100 } SYS_MODE_E;
101
102 typedef enum
103 {
104     CHNG_FREQ_REQ_CMD = 0xF000,
105     CHNG_FREQ_REQ_MAX
106 } CHNG_FREQ_COMMAND_E;
107
108
109 typedef struct _chng_freq_msg
110 {
111     uint32 freq_param1;//arm_ahb_clk_lvl;
112     uint32 freq_param2;//sdram_timing1;
113     uint32 freq_param3;//sdram_timing2;
114     uint32 freq_param4;//reserved
115 } CHNG_FREQ_MESSAGE_T;
116
117 /*****************************************************************************/
118 // Description :    This function is used to get a handler which specify the application
119 //                  that request the frequency-changing.
120 // Global resource dependence :
121 // Author :         Zhengjiang.Lei
122 // Note :           before an application request to change frequency, get a handler first.
123 /*****************************************************************************/
124 PUBLIC uint32 CHNG_FREQ_GetReqHandler (const char *handler_name);
125 /*****************************************************************************/
126 // Description :    This function is used to delete the handler which request to change frequency
127 //                  before .
128 // Global resource dependence :
129 // Author :         Zhengjiang.Lei
130 // Note :           .
131 /*****************************************************************************/
132 PUBLIC uint32 CHNG_FREQ_DeleteReqHandler (uint32 handler);
133
134 /*****************************************************************************/
135 // Description :    This function is used to set an event which specify this event
136 //                  permits to change frequency. after this event finished accessing
137 //                  sdram, set the event.
138 // Global resource dependence :
139 // Author :         Zhengjiang.Lei
140 // Note :           sys_mode: when you call this function in an isr handler,
141 //                          use SYS_MODE_INT.
142 /*****************************************************************************/
143 PUBLIC uint32 CHNG_FREQ_Event_Set (FREQ_CHNG_EVENT_E id, SYS_MODE_E sys_mode);
144 /*****************************************************************************/
145 // Description :    This function is used to clear an event which specify this event
146 //                  forbids to change frequency. before this event will begin to access
147 //                  sdram, clear the event.
148 // Global resource dependence :
149 // Author :         Zhengjiang.Lei
150 // Note :           sys_mode: when you call this function in an isr handler,
151 //                          use SYS_MODE_INT.
152 /*****************************************************************************/
153 PUBLIC uint32 CHNG_FREQ_Event_Clr (FREQ_CHNG_EVENT_E id, SYS_MODE_E sys_mode);
154 /*****************************************************************************/
155 // Description :    This function is used to init the chng_freq module.
156 // Global resource dependence :
157 // Author :         Zhengjiang.Lei
158 // Note :           you must call this function after RTOS init.
159 /*****************************************************************************/
160 PUBLIC void CHNG_FREQ_Init (void);
161
162 /*****************************************************************************/
163 // Description :    This function is used to set the customized freq config(base address)
164 // Global resource dependence :
165 // Author :
166 // Note :
167 /*****************************************************************************/
168 PUBLIC void CHNG_FREQ_SetCustomFreqCfg (uint32 *p_customized_freq_ptr);
169
170 /*****************************************************************************/
171 // Description :    This function is used to set ARM/AHB clock.
172 //                  Now, we only support change clock in a thread. If it is called
173 //                  at IRQ or FIQ, an assert happened.
174 // Global resource dependence :
175 // Author :         Xueliang.Wang
176 // Note :
177 /*****************************************************************************/
178 PUBLIC void CHNG_FREQ_SetArmClk (uint32 handler, CHNG_FREQ_INDEX_E clk_type_index);
179
180 /*****************************************************************************/
181 // Description :    This function is used to restore the original ARM_CLK/AHB_CLK
182 // Global resource dependence :
183 // Author :         Nick.Zhao
184 // Note :
185 /*****************************************************************************/
186 PUBLIC void CHNG_FREQ_RestoreARMClk (uint32 handler);
187
188
189 /**---------------------------------------------------------------------------*
190  **                         Compiler Flag                                     *
191  **---------------------------------------------------------------------------*/
192 #ifdef __cplusplus
193 }
194 #endif
195
196 #endif //_CHNG_FREQ_DRVAPI_H_