ccci.h
15.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2001
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* ccci.h
*
* Project:
* --------
* Maui
*
* Description:
* ------------
* Header file of CCCI.
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
#ifndef __CCCI_H__
#define __CCCI_H__
#if defined(__SMART_PHONE_MODEM__)
#include "kal_general_types.h"
#include "kal_public_defs.h"
//#define ARM9
//#define TK6516
#if (defined(TK6516) || defined(MT6516) || defined(MT6573)) && defined(__APPLICATION_PROCESSOR__)
#define CCCI_FOR_AP_SIDE
#else /* (TK6516 || MT6516) && __APPLICATION_PROCESSOR__ */
#define CCCI_FOR_MD_SIDE
#endif /* (TK6516 || MT6516 ) && __APPLICATION_PROCESSOR__ */
/*******************************************************************************
* Define data structure.
*******************************************************************************/
/* CCCI API return value */
typedef enum
{
CCCI_SUCCESS = 0,
CCCI_FAIL = -1001,
CCCI_IN_USE = -1002,
CCCI_NOT_OWNER = -1003,
CCCI_INVALID_PARAM = -1004,
CCCI_NO_PHY_CHANNEL = -1005,
CCCI_IN_LISR = -1006
}CCCI_RETURNVAL_T;
/* CCCI status */
typedef enum
{
CCCI_IDLE = 0x00,
CCCI_ACTIVE_READ = 0x01,
CCCI_ACTIVE_WRITE = 0x02,
CCCI_ACTIVE_ISR = 0x04
} CCCI_STATE_T;
/* CCCI logical channel */
/* NOTICE: Negotiations With AP Owner Before Modification */
typedef enum
{
CCCI_CONTROL_CHANNEL = 0,
CCCI_CONTROL_CHANNEL_ACK =1,
CCCI_SYSTEM_CHANNEL = 2,
CCCI_SYSTEM_CHANNEL_ACK = 3,
CCCI_PCM_CHANNEL = 4,
CCCI_PCM_CHANNEL_ACK = 5,
CCCI_TST_CHANNEL = 6,
CCCI_TST_ACK_CHANNEL = 7,
CCCI_TR_CHANNEL = 8,
CCCI_TR_ACK_CHANNEL = 9,
CCCI_AT_CHANNEL_TX = 10,
CCCI_AT_ACK_CHANNEL_TX = 11,
CCCI_AT_CHANNEL_RX = 12,
CCCI_AT_ACK_CHANNEL_RX = 13,
CCCI_FS_CHANNEL = 14,
CCCI_FS_ACK_CHANNEL = 15,
CCCI_PMIC_CHANNEL = 16,
CCCI_PMIC_ACK_CHANNEL = 17,
CCCI_UEM_CHANNEL = 18,
CCCI_UEM_ACK_CHANNEL = 19,
CCCI_CCMNI1_RX = 20,
CCCI_CCMNI1_RX_ACK = 21,
CCCI_CCMNI1_TX = 22,
CCCI_CCMNI1_TX_ACK = 23,
CCCI_CCMNI2_RX = 24,
CCCI_CCMNI2_RX_ACK = 25,
CCCI_CCMNI2_TX = 26,
CCCI_CCMNI2_TX_ACK = 27,
CCCI_CCMNI3_RX = 28,
CCCI_CCMNI3_RX_ACK = 29,
CCCI_CCMNI3_TX = 30,
CCCI_CCMNI3_TX_ACK = 31,
CCCI_IPC_RPC_CHANNEL = 32,
CCCI_IPC_RPC_ACK_CHANNEL = 33,
CCCI_MSGSVC_SEND_CHANNEL = 34,
CCCI_MSGSVC_SEND_ACK_CHANNEL = 35,
CCCI_MSGSVC_RCV_CHANNEL = 36,
CCCI_MSGSVC_RCV_ACK_CHANNEL = 37,
CCCI_GPS_CHANNEL_TX = 38,
CCCI_GPS_ACK_CHANNEL_TX = 39,
CCCI_GPS_CHANNEL_RX = 40,
CCCI_GPS_ACK_CHANNEL_RX = 41,
CCCI_MD_LOG_RX = 42,
CCCI_MD_LOG_TX = 43,
CCCI_MAX_CHANNEL = 44,
CCCI_FORCE_RESET_MODEM_CHANNEL = 20090215
} CCCI_CHANNEL_T;
/* CCCI mailbox channel structure */
typedef struct
{
kal_uint32 magic; /* 0xFFFFFFFF */
kal_uint32 id;
} CCCI_MAILBOX_T;
/* CCCI stream channel structure */
typedef struct
{
kal_uint32 addr;
kal_uint32 len;
} CCCI_STREAM_T;
/* CCCI channel buffer structure */
typedef struct
{
kal_uint32 data[2];
kal_uint32 channel;
kal_uint32 reserved;
} CCCI_BUFF_T;
/* CCCI callback function prototype */
typedef void (*CCCI_CALLBACK)(CCCI_BUFF_T *buff);
/* CCCI control structure */
typedef struct
{
CCCI_STATE_T state;
kal_uint32 owner;
CCCI_BUFF_T buff;
CCCI_CALLBACK funp;
kal_eventgrpid event;
} CCCI_CTRL_T;
/* CCCI RunTime Data structure */
/* NOTICE: Negotiations With AP Side Owner Before Modification */
/* DriverVersion */
#define CCCI_CURRENT_VERSION 0x20110118
/* BootingStartID */
#define NORMAL_BOOT_ID 0
#define META_BOOT_ID 1
/* BootAttributes */
#define BOOT_ATTR_IS_CLEAN_BOOT 0x00000001
#define UART_MAX_PORT_NUM 8
typedef struct MODEM_RUNTIME_DATA_T
{
kal_uint8 Prefix[4]; // "CCIF"
kal_uint8 Platform[8]; // Hardware Platform String ex: "MT6516E1"
kal_uint32 DriverVersion; // 0x00000929 since W09.29
kal_uint32 BootChannel; // Channel to ACK AP with boot ready
kal_uint32 BootingStartID; // MD is booting. NORMAL_BOOT_ID or META_BOOT_ID
kal_uint32 BootAttributes; // Attributes passing from AP to MD Booting
kal_uint32 BootReadyID; // MD response ID if boot successful and ready ,
// Cannot equal to CCMSG_ID_DRV_VERSION_ERR
kal_uint32 MdlogShareMemBase;
kal_uint32 MdlogShareMemSize;
kal_uint32 PcmShareMemBase;
kal_uint32 PcmShareMemSize;
kal_uint32 UartPortNum;
kal_uint32 UartShareMemBase[UART_MAX_PORT_NUM];
kal_uint32 UartShareMemSize[UART_MAX_PORT_NUM];
kal_uint32 FileShareMemBase;
kal_uint32 FileShareMemSize;
kal_uint32 RpcShareMemBase;
kal_uint32 RpcShareMemSize;
kal_uint32 PmicShareMemBase;
kal_uint32 PmicShareMemSize;
kal_uint32 ExceShareMemBase;
kal_uint32 ExceShareMemSize; // 512 Bytes Required
kal_uint32 SysShareMemBase;
kal_uint32 SysShareMemSize; // AP MD run-time share data
kal_uint32 IPCShareMemBase;
kal_uint32 IPCShareMemSize; // AP MD run-time share data
kal_uint32 CheckSum;
kal_uint8 Postfix[4]; //"CCIF"
}MODEM_RUNTIME_DATA;
extern MODEM_RUNTIME_DATA ap_md_share_data;
/* CCCI Message ID Passing Through CONTROL_CHANNEL and SYSTEM_CHANNEL */
/* NOTICE: Negotiations With AP Owner Before Modification */
typedef enum
{
CCMSG_ID_START_BOOT = 0x00000000,
CCMSG_ID_NORMAL_BOOT_READY = 0x00000001,
CCMSG_ID_META_BOOT_READY = 0x00000002,
CCMSG_ID_RESET = 0x00000003,
CCMSG_ID_EXCEPTION_CHECK = 0x00000004,
CCMSG_ID_DRV_VERSION_ERR = 0x00000005,
CCMSG_ID_EXCEPTION_REC_OK = 0x00000006,
/* System Channel */
CCMSG_ID_MD_EINT_POLARITY = 0x00000007,
CCMSG_ID_MD_EINT_ON_OFF = 0x00000008,
CCMSG_ID_MD_EINT_ACK = 0x0000000B,
CCMSG_ID_MD_OS_TICK_UPDATE = 0x00000009,
CCMSG_ID_MD_OS_TICK_QUERY = 0x0000000A,
CCMSG_ID_MD_PERIODIC_COM = 0x0000000C,
CCMSG_ID_MD_PERIODIC_ACK = 0x0000000D,
CCMSG_ID_MD_L4_MOD = 0x0000000E,//add for RIL (AP task) and L4C (MD task) communication message
}CONTROL_CHANNEL_MSG;
/* Structure usage for L1SM */
#define CCCI_EXCHANGE_SLEEP_STATE_AWAKEN (0)
#define CCCI_EXCHANGE_SLEEP_STATE_SLEEP (1)
#define CCCI_EXCHANGE_SLEEP_STATE_SLUMBER (2)
typedef struct
{
kal_uint8 AP_Sleep; // flag for AP to inform MD sleeping state
// 0 awaken, 1 sleep with alarm , 2 slumber... until event
kal_uint8 paddingA1; // un-used , explict and manually alignment to prevent mistake
kal_uint8 paddingA2; // un-used , explict and manually alignment to prevent mistake
kal_uint8 paddingA3; // un-used , explict and manually alignment to prevent mistake
kal_uint32 RTC_AP_WakeUp; // The time AP will wake up
kal_uint32 AP_SettleTime; // The time for 26M clock to settle
kal_uint8 MD_Sleep; // flag for MD to inform AP sleep state
// 0 awaken, 1 sleep with alarm
kal_uint8 paddingM1; // un-used , explict and manually alignment to prevent mistake
kal_uint8 paddingM2; // un-used , explict and manually alignment to prevent mistake
kal_uint8 paddingM3; // un-used , explict and manually alignment to prevent mistake
kal_uint32 RTC_MD_WakeUp; // The time MD will wake up
kal_uint32 RTC_MD_Settle_OK; // The time MD will finish 26M clock settle
}EXCHANGE_SLEEP_TICKS;
typedef struct
{
kal_uint8 eint_no; // eint no.
kal_bool Sensitivity; // config level or edge sensitivity
// follow spec. level = 1 and edge = 0
kal_bool ACT_Polarity; // if edge sensitivity, positive or negative
kal_bool Dbounce_En; // enable the debounce
kal_uint32 Dbounce_ms; // debounce time in mini-second
}PROPAGATE_EINT_CFG;
typedef struct
{
EXCHANGE_SLEEP_TICKS sleep_mode_data; // exchange sleep mode data
kal_uint32 cfg_report_os_tick; // Report OS Tick Periodic in second unit
// ( 0 = disable )
kal_uint32 eint_array_numbers; // PROPAGATE_EINT_CFG array valid elements
kal_uint32 eint_array_offset; // PROPAGATE_EINT_CFG array location in offset form
// (bytes from SysShareMemBase)
}SYSTEM_EXCHANGE_DATA;
/*******************************************************************************
* Define marco.
*******************************************************************************/
/* initialize a CCCI mailbox buffer */
#define CCCI_INIT_MAILBOX(buff, mailbox_id) \
do { \
((CCCI_MAILBOX_T *)(buff))->magic = 0xFFFFFFFF; \
((CCCI_MAILBOX_T *)(buff))->id = (mailbox_id); \
(buff)->channel = CCCI_MAX_CHANNEL; \
(buff)->reserved = 0; \
} while (0)
/* initialize a CCCI stream buffer */
#define CCCI_INIT_STREAM(buff, stream_addr, stream_len) \
do { \
((CCCI_STREAM_T *)(buff))->addr = (stream_addr); \
((CCCI_STREAM_T *)(buff))->len = (stream_len); \
(buff)->channel = CCCI_MAX_CHANNEL; \
(buff)->reserved = 0; \
} while (0)
/* check the CCCI buffer type */
#define CCCI_IS_MAILBOX(buff) ((((CCCI_MAILBOX_T *)(buff))->magic == 0xFFFFFFFF)? 1: 0)
/* get the id of the CCCI mailbox buffer */
#define CCCI_MAILBOX_ID(buff) (((CCCI_MAILBOX_T *)(buff))->id)
/* get the addr of the CCCI stream buffer */
#define CCCI_STREAM_ADDR(buff) (((CCCI_STREAM_T *)(buff))->addr)
/* get the len of the CCCI stream buffer */
#define CCCI_STREAM_LEN(buff) (((CCCI_STREAM_T *)(buff))->len)
/*******************************************************************************
* define global variable
*******************************************************************************/
#define BOOT_CHECK_ID 0x5555FFFF /* magic id : Placed on reserved field */
#define EXCEPTION_CHECK_ID 0x45584350 /* EXCP : Placed on reserved field */
#define EXCEPTION_REC_READY 0x45524543 /* EREC : Placed on reserved field */
#define CCCI_WAIT_MAX_TIME 4615
/*******************************************************************************
* Declare function prototype.
* User APIs
*******************************************************************************/
extern kal_int32 ccci_init(CCCI_CHANNEL_T channel, CCCI_CALLBACK funp);
extern kal_int32 ccci_deinit(CCCI_CHANNEL_T channel);
extern kal_int32 ccci_stream_write(CCCI_CHANNEL_T channel, kal_uint32 addr, kal_uint32 len);
extern kal_int32 ccci_stream_read(CCCI_CHANNEL_T channel, kal_uint32 *addr, kal_uint32 *len);
extern kal_int32 ccci_stream_read_with_reserved(CCCI_CHANNEL_T channel, kal_uint32 *addr, kal_uint32 *len, kal_uint32 *reserved);
extern kal_int32 ccci_stream_write_with_reserved(CCCI_CHANNEL_T channel, kal_uint32 addr, kal_uint32 len,kal_uint32 reserved);
extern kal_int32 ccci_mailbox_write(CCCI_CHANNEL_T channel, kal_uint32 id);
extern kal_int32 ccci_mailbox_read(CCCI_CHANNEL_T channel);
extern kal_int32 ccci_mailbox_write_with_reserved(CCCI_CHANNEL_T channel, kal_uint32 id,kal_uint32 reserved);
extern kal_int32 ccci_mailbox_read_with_reserved(CCCI_CHANNEL_T channel,kal_uint32 *reserved);
extern void ccci_GetShareMemInfo( kal_uint32 **info, kal_uint16* count );
extern void ccci_CalculateShareMem(kal_uint32 *start_addr, kal_uint32 *end_addr , kal_uint32 *size);
extern kal_bool ccci_queryBootAttributes(kal_uint32 mask);
extern EXCHANGE_SLEEP_TICKS* ccci_query_ptr_of_exchange_sleeptick(void);
extern PROPAGATE_EINT_CFG* ccci_query_ptr_of_exchange_eint(kal_uint32 *number);
extern kal_bool ccci_chk_sententry_not_receive(kal_uint32 query_log, kal_uint32 data);
/*******************************************************************************
* Declare function prototype.
* Kernel/System Use APIs
*******************************************************************************/
extern kal_int32 ccci_read(CCCI_CHANNEL_T channel, CCCI_BUFF_T *buff);
extern kal_int32 ccci_write_internal(CCCI_CHANNEL_T channel, CCCI_BUFF_T *buff,kal_bool check_lisr);
#define ccci_write(a,b) ccci_write_internal(a,b,1)
extern kal_int32 ccci_owner_init(CCCI_CHANNEL_T channel, kal_taskid task, CCCI_CALLBACK funp);
extern kal_uint32 ccci_query_sharemem_addr(CCCI_CHANNEL_T channel,kal_uint32 *size);
extern void ccci_change_owner_only(CCCI_CHANNEL_T channel,kal_uint8 owner);
extern void ccif_init(kal_uint32 arb, kal_uint32 md_offset);
extern kal_bool ccci_chk_recentry_in_queue(kal_uint32 query_log, kal_bool Is_Ack_All_if_found);
extern void ccci_init_handshake_phase1(void);
extern void ccci_init_handshake_phase2(kal_uint16 _boot_mode);
extern void ccci_exception_handshake(void) ;
extern void ccci_exception_info_passed(void) ;
extern void ccci_except_ack(CCCI_BUFF_T *bufp);
extern kal_bool ccci_send_sharemem_to_ap(kal_uint32* data_to_ap, kal_uint32 data_size, kal_uint32 reserved);
#endif /* __SMART_PHONE_MODEM__ */
#endif /* !__CCCI_H__ */