tizen 2.4 release
[profile/mobile/platform/kernel/u-boot-tm1.git] / arch / arm / include / asm / arch-sc8810 / pcm_drvapi.h
1 /******************************************************************************
2  ** File Name:      pcm_drvapi.h                                             *
3  ** Author:         Thomas.Chai                                                 *
4  ** DATE:           4/26/2006                                                *
5  ** Copyright:      2006 Spreatrum, Incoporated. All Rights Reserved.         *
6  ** Description:    This file contains driver for LCM controller.
7  **
8  ******************************************************************************/
9
10 #ifndef _PCM_DRVAPI_H_
11 #define _PCM_DRVAPI_H_
12
13 /**---------------------------------------------------------------------------*
14  **                         Compiler Flag                                     *
15  **---------------------------------------------------------------------------*/
16 #ifdef   __cplusplus
17 extern   "C"
18 {
19 #endif
20
21
22 /**---------------------------------------------------------------------------*
23  **                         Const variables                                   *
24  **---------------------------------------------------------------------------*/
25
26
27 /**---------------------------------------------------------------------------*
28  **                         Data Structures                                   *
29  **---------------------------------------------------------------------------*/
30 //pcm operation mode
31 typedef enum
32 {
33     LONG_FRAME_SYNC_MODE  = 0, //long frame sync mode.
34     SHORT_FRAME_SYNC_MODE = 1, //short frame sync mode
35     MULTI_SLOT_OPERATOR_MODE = 2
36                            }
37                            PCM_SYNC_MODE_E;
38
39 typedef enum
40 {
41     MASTER_MODE = 0,  //PCM working at master mode
42     SLAVE_MODE = 1    //PCM working at slave mode
43 } PCM_OPERATE_MODE_E;
44
45
46 typedef enum
47 {
48     PCM_SLOT0 = 0x01,
49     PCM_SLOT1 = 0x02,
50     PCM_SLOT2 = 0x04
51 } PCM_SLOT_E;
52
53 typedef enum
54 {
55     TX_8BITS_PER_FRAME = 0,   // the data bit number of user transmitting/receiving is 8 bits
56     TX_16BITS_PER_FRAME = 1,  // the data bit number of user transmitting/receiving is 16 bits
57     TX_32BITS_PER_FRAME   = 2 // the data bit number of user transmitting/receiving is 32 bits
58 } DATA_BIT_NUM_E;
59
60
61 typedef enum
62 {
63     CLOSE_STATUS = 0,
64     OPEN_STATUS = 1
65 } PCM_STATUS_E;
66
67 typedef enum
68 {
69     ERR_PCM_SUCCESS = 0,
70     ERR_PCM_NO_TX_DATA,        // No vaild data to transmit
71     ERR_PCM_TIMEOUT ,               // receive data is timeout
72     ERR_PCM_CLOSE ,                 // PCM had been closed
73     ERR_PCM_PARAM_SCALE_WRONG ,     // PCM_PARA_T Parameter scale wrong
74     ERR_PCM_PARAM_DISMATCH_WRONG,   // INPUT Parameters dismatch
75     ERR_PCM_POINTER_NULL,           // Input pointer is PNULL
76     ERR_PCM_OPERATE_FAIL,           // Operate fail
77     ERR_PCM_FUNC_NOT_SUPPORT        // PCM not support this function
78     // Success, no error
79 } ERR_PCM_E;
80
81
82
83 /**---------------------------------------------------------------------------*
84  **                         Data Structures                                   *
85  **---------------------------------------------------------------------------*/
86 typedef struct
87 {
88     uint32 value;     //the data number had been transmitted/received
89     ERR_PCM_E  error;    //the status of current transmitting/receiving
90 } CALL_RET_T;
91
92 //Call back define
93 typedef ERR_PCM_E (*PCMCallback) (CALL_RET_T ret);
94
95
96 typedef struct
97 {
98     PCM_SYNC_MODE_E    sync_mode;         //pcm operate mode.(sc6600m only support short frame sync mode)
99     PCM_OPERATE_MODE_E     operate_mode;      //Master/Slave mode.0:master 1:slave
100     DATA_BIT_NUM_E     data_bit_num;    //the data bit number want to transmit
101     PCM_SLOT_E        pcm_slot;
102     uint8     tx_watermark;            // the watermark value when the Tx interrupt will happen  1 ~~~~~ 32
103     uint8     rx_watermark;           // the watermark value when the Rx interrupt will happen
104     PCMCallback tx_CallBack;          // Tx call back function
105     PCMCallback rx_CallBack;          // Rx call back function
106 } PCM_PARA_T;
107
108 typedef struct
109 {
110     uint32 size;      // Total Size of the buffer.
111     uint32 start_point;   // First data in the buffer.
112     uint8 *sio_buf_ptr;       // Sio buffer address.
113 } PCM_BUF_T;
114
115 typedef struct
116 {
117     PCM_PARA_T  dev_para;
118     PCM_BUF_T   tx_buf;
119     PCM_BUF_T   rx_buf;
120     PCM_STATUS_E pcm_status;
121     uint8  byte_per_frame;
122 } PCM_HAL_T;
123
124
125
126 /**---------------------------------------------------------------------------*
127  **                      Function  Prototype
128  **---------------------------------------------------------------------------*/
129 /*****************************************************************************/
130 //  Description:    This function initalize PCM Paramer
131 //  Author:         Thomas.Chai
132 //  Note:
133 //
134 /*****************************************************************************/
135 PUBLIC void PCM_Init (void);
136
137
138 /*****************************************************************************/
139 //  Description:    Open a PCM interface, and start to transmit data. you can set
140 //                  a new paramer for PCM, and you also set the paramer to zero,
141 //                  then it will use the default setting to PCM. If the new paramer
142 //                  is unvaild, it also will use the default setting
143 //  Author:         Thomas.Chai
144 //  Note:
145 //
146 /*****************************************************************************/
147 PUBLIC ERR_PCM_E  PCM_Open (PCM_PARA_T *paramer);
148
149
150 /*****************************************************************************/
151 //  Description:    Give the outside buffer pointer to PCM data sending buffer
152 //                  pointer. and start the transmit interrupt to transmit data
153 //  Global resource dependence:
154 //  Author:         Thomas.Chai
155 //  Note:
156 /*****************************************************************************/
157 PUBLIC int32  PCM_SendData (uint8 *data_ptr,  //data pointer of user want to send
158                             uint32 data_len);  //data length
159
160
161 /*****************************************************************************/
162 //  Description:    Move received data from fifo to outside buffer
163 //  Global resource dependence:
164 //  Author:         Thomas.Chai
165 //  Note:
166 /*****************************************************************************/
167 PUBLIC int32 PCM_ReceiveData (uint8 *buff_ptr,   //receive data buffer pointer
168                               uint32 data_len);   //receive data buffer length
169
170 /*****************************************************************************/
171 //  Description:    stop PCM transmit, and close pcm interface.
172 //  Global resource dependence:
173 //  Author:         Livy.Liu&Thomas.Chai
174 //  Note:
175 /*****************************************************************************/
176 PUBLIC ERR_PCM_E  PCM_Close (void);
177
178
179
180 /*****************************************************************************/
181 //  Description:    Set a new PCM Paramer to system, if the new paramer is not right,
182 //                  the  setting is unuseful
183 //  Global resource dependence:
184 //  Author:         Thomas.Chai
185 //  Note:
186 /*****************************************************************************/
187 PUBLIC ERR_PCM_E PCM_SetParamer (PCM_PARA_T *paramer);
188
189 /*****************************************************************************/
190 //  Description:    Get Current PCM Paramer in the PCM driver
191 //  Global resource dependence:
192 //  Author:         Thomas.Chai
193 //  Note:
194 /*****************************************************************************/
195 PUBLIC ERR_PCM_E  PCM_GetCurrentParamer (PCM_PARA_T   *paramer);
196
197
198 /*****************************************************************************/
199 //  Description:    PCM ISR Entry
200 //  Global resource dependence:
201 //  Author:         Thomas.Chai
202 //  Note:
203 /*****************************************************************************/
204 PUBLIC void PCM_ISRHandle (uint32 int_num);
205
206
207
208 #ifdef   __cplusplus
209 }
210 #endif
211
212 #endif /*_PCM_DRVAPI_H_*/