1 #include <linux/module.h>
2 #include <linux/device.h>
4 #include <linux/cdev.h>
5 #include <linux/interrupt.h>
6 #include <linux/spinlock.h>
7 #include <linux/uaccess.h>
9 #include <linux/kfifo.h>
10 #include <linux/firmware.h>
11 #include <linux/syscalls.h>
12 #include <linux/uaccess.h>
13 #include <linux/platform_device.h>
14 #include <linux/proc_fs.h>
15 #include <asm/setup.h>
16 #include <asm/memblock.h>
17 #include <mach/mtk_ccci_helper.h>
19 #include <mach/eint.h>
20 #include <mach/mt_gpio.h>
21 #include <mach/mt_reg_base.h>
22 #include <mach/battery_common.h>
23 #include <mach/dfo_boot.h>
24 #include <mach/pmic_mt6320_sw.h>
25 #include <mach/upmu_common.h>
26 #include <mach/upmu_hw.h>
27 #include <mach/mt_boot.h>
29 extern BOOTMODE g_boot_mode
;
30 extern int md_power_on(int);
31 extern int md_power_off(int,unsigned int);
33 static void internal_md_power_down(void)
36 * MDMCU Control Power Registers
38 #define MD_TOPSM_BASE (0x20030000)
39 #define MD_TOPSM_RM_TMR_PWR0(base) ((volatile unsigned int*)((base) + 0x0018))
40 #define MD_TOPSM_SM_REQ_MASK(base) ((volatile unsigned int*)((base) + 0x08B0))
41 #define MD_TOPSM_RM_PWR_CON0(base) ((volatile unsigned int*)((base) + 0x0800))
42 #define MD_TOPSM_RM_PWR_CON1(base) ((volatile unsigned int*)((base) + 0x0804))
43 #define MD_TOPSM_RM_PLL_MASK0(base) ((volatile unsigned int*)((base) + 0x0830))
44 #define MD_TOPSM_RM_PLL_MASK1(base) ((volatile unsigned int*)((base) + 0x0834))
46 #define MODEM2G_TOPSM_BASE (0x23010000)
47 #define MODEM2G_TOPSM_RM_CLK_SETTLE(base) ((volatile unsigned int*)((base) + 0x0000))
48 #define MODEM2G_TOPSM_RM_TMRPWR_SETTLE(base) ((volatile unsigned int*)((base) + 0x0004))
49 #define MODEM2G_TOPSM_RM_TMR_TRG0(base) ((volatile unsigned int*)((base) + 0x0010))
50 #define MODEM2G_TOPSM_RM_TMR_TRG1(base) ((volatile unsigned int*)((base) + 0x0014))
51 #define MODEM2G_TOPSM_RM_TMR_PWR0(base) ((volatile unsigned int*)((base) + 0x0018))
52 #define MODEM2G_TOPSM_RM_TMR_PWR1(base) ((volatile unsigned int*)((base) + 0x001C))
53 #define MODEM2G_TOPSM_RM_PWR_CON0(base) ((volatile unsigned int*)((base) + 0x0800))
54 #define MODEM2G_TOPSM_RM_PWR_CON1(base) ((volatile unsigned int*)((base) + 0x0804))
55 #define MODEM2G_TOPSM_RM_PWR_CON2(base) ((volatile unsigned int*)((base) + 0x0808))
56 #define MODEM2G_TOPSM_RM_PWR_CON3(base) ((volatile unsigned int*)((base) + 0x080C))
57 #define MODEM2G_TOPSM_RM_PWR_CON4(base) ((volatile unsigned int*)((base) + 0x0810))
58 #define MODEM2G_TOPSM_RM_PWR_CON5(base) ((volatile unsigned int*)((base) + 0x0814))
59 #define MODEM2G_TOPSM_RM_PWR_CON6(base) ((volatile unsigned int*)((base) + 0x0818))
60 #define MODEM2G_TOPSM_RM_PWR_CON7(base) ((volatile unsigned int*)((base) + 0x081C))
61 #define MODEM2G_TOPSM_RM_PLL_MASK0(base) ((volatile unsigned int*)((base) + 0x0830))
62 #define MODEM2G_TOPSM_RM_PLL_MASK1(base) ((volatile unsigned int*)((base) + 0x0834))
63 #define MODEM2G_TOPSM_RM_PLL_MASK2(base) ((volatile unsigned int*)((base) + 0x0838))
64 #define MODEM2G_TOPSM_RM_PLL_MASK3(base) ((volatile unsigned int*)((base) + 0x083C))
65 #define MODEM2G_TOPSM_SM_REQ_MASK(base) ((volatile unsigned int*)((base) + 0x08B0))
67 *[TDD] MDMCU Control Power Registers
69 #define TDD_BASE (0x24000000)
70 #define TDD_HALT_CFG_ADDR(base) ((volatile unsigned int*)((base) + 0x0000))
71 #define TDD_HALT_STATUS_ADDR(base) ((volatile unsigned int*)((base) + 0x0002))
73 unsigned short status
;
75 unsigned int md_topsm_base
, modem2g_topsm_base
, tdd_base
;
77 printk("[ccci/ctl] (0)internal md disabled, so power down!\n");
79 //printk("[ccci/ctl] (0)call md_power_on...\n");
83 md_topsm_base
= (unsigned int)ioremap_nocache(MD_TOPSM_BASE
, 0x840);
84 modem2g_topsm_base
= (unsigned int)ioremap_nocache(MODEM2G_TOPSM_BASE
, 0x8C0);
85 tdd_base
= (unsigned int)ioremap_nocache(TDD_BASE
, 0x010);
87 //printk("[ccci/ctl] (0)MD2G/HSPA power down...\n");
89 /*[MD2G/HSPA] MDMCU Control Power Down Sequence*/
90 mt65xx_reg_sync_writel((*MODEM2G_TOPSM_RM_PWR_CON0(modem2g_topsm_base
)) | 0x44, MODEM2G_TOPSM_RM_PWR_CON0(modem2g_topsm_base
));
91 mt65xx_reg_sync_writel((*MODEM2G_TOPSM_RM_PWR_CON1(modem2g_topsm_base
)) | 0x44, MODEM2G_TOPSM_RM_PWR_CON1(modem2g_topsm_base
));
92 mt65xx_reg_sync_writel((*MODEM2G_TOPSM_RM_PWR_CON2(modem2g_topsm_base
)) | 0x44, MODEM2G_TOPSM_RM_PWR_CON2(modem2g_topsm_base
));
93 mt65xx_reg_sync_writel((*MODEM2G_TOPSM_RM_PWR_CON3(modem2g_topsm_base
)) | 0x44, MODEM2G_TOPSM_RM_PWR_CON3(modem2g_topsm_base
));
94 mt65xx_reg_sync_writel((*MODEM2G_TOPSM_RM_PWR_CON4(modem2g_topsm_base
)) | 0x44, MODEM2G_TOPSM_RM_PWR_CON4(modem2g_topsm_base
));
96 mt65xx_reg_sync_writel((*MODEM2G_TOPSM_RM_PWR_CON0(modem2g_topsm_base
)) & 0xFFFFFF7F, MODEM2G_TOPSM_RM_PWR_CON0(modem2g_topsm_base
));
97 mt65xx_reg_sync_writel(0x00000200, MODEM2G_TOPSM_RM_PWR_CON0(modem2g_topsm_base
));
98 mt65xx_reg_sync_writel((*MODEM2G_TOPSM_RM_PWR_CON1(modem2g_topsm_base
)) & 0xFFFFFF7F, MODEM2G_TOPSM_RM_PWR_CON1(modem2g_topsm_base
));
99 mt65xx_reg_sync_writel(0x00000200, MODEM2G_TOPSM_RM_PWR_CON1(modem2g_topsm_base
));
100 mt65xx_reg_sync_writel((*MODEM2G_TOPSM_RM_PWR_CON2(modem2g_topsm_base
)) & 0xFFFFFF7F, MODEM2G_TOPSM_RM_PWR_CON2(modem2g_topsm_base
));
101 mt65xx_reg_sync_writel(0x00000200, MODEM2G_TOPSM_RM_PWR_CON2(modem2g_topsm_base
));
102 mt65xx_reg_sync_writel((*MODEM2G_TOPSM_RM_PWR_CON3(modem2g_topsm_base
)) & 0xFFFFFF7F, MODEM2G_TOPSM_RM_PWR_CON3(modem2g_topsm_base
));
103 mt65xx_reg_sync_writel(0x00000200, MODEM2G_TOPSM_RM_PWR_CON3(modem2g_topsm_base
));
104 mt65xx_reg_sync_writel((*MODEM2G_TOPSM_RM_PWR_CON4(modem2g_topsm_base
)) & 0xFFFFFF7F, MODEM2G_TOPSM_RM_PWR_CON4(modem2g_topsm_base
));
105 mt65xx_reg_sync_writel(0x00000200, MODEM2G_TOPSM_RM_PWR_CON4(modem2g_topsm_base
));
107 mt65xx_reg_sync_writel(0xFFFFFFFF, MD_TOPSM_SM_REQ_MASK(md_topsm_base
));
108 mt65xx_reg_sync_writel(0x00000000, MODEM2G_TOPSM_RM_TMR_PWR0(modem2g_topsm_base
));
109 mt65xx_reg_sync_writel(0x00000000, MODEM2G_TOPSM_RM_TMR_PWR1(modem2g_topsm_base
));
110 mt65xx_reg_sync_writel((*MODEM2G_TOPSM_RM_PWR_CON0(modem2g_topsm_base
)) & ~(0x1<<2) & ~(0x1<<6), MODEM2G_TOPSM_RM_PWR_CON0(modem2g_topsm_base
));
111 mt65xx_reg_sync_writel((*MODEM2G_TOPSM_RM_PWR_CON1(modem2g_topsm_base
)) & ~(0x1<<2) & ~(0x1<<6), MODEM2G_TOPSM_RM_PWR_CON1(modem2g_topsm_base
));
112 mt65xx_reg_sync_writel((*MODEM2G_TOPSM_RM_PWR_CON2(modem2g_topsm_base
)) & ~(0x1<<2) & ~(0x1<<6), MODEM2G_TOPSM_RM_PWR_CON2(modem2g_topsm_base
));
113 mt65xx_reg_sync_writel((*MODEM2G_TOPSM_RM_PWR_CON3(modem2g_topsm_base
)) & ~(0x1<<2) & ~(0x1<<6), MODEM2G_TOPSM_RM_PWR_CON3(modem2g_topsm_base
));
114 mt65xx_reg_sync_writel((*MODEM2G_TOPSM_RM_PWR_CON4(modem2g_topsm_base
)) & ~(0x1<<2) & ~(0x1<<6), MODEM2G_TOPSM_RM_PWR_CON4(modem2g_topsm_base
));
116 //printk("[ccci/ctl] (0)TDD power down...\n");
118 /*[TDD] MDMCU Control Power Down Sequence*/
119 mt65xx_reg_sync_writew(0x1, TDD_HALT_CFG_ADDR(tdd_base
));
120 status
= *((volatile unsigned short*)TDD_HALT_STATUS_ADDR(tdd_base
));
121 while ((status
& 0x1) == 0) {
122 if (status
& 0x1) { //halted
123 /*TINFO=''TDD is in *HALT* STATE*/
124 } else if (status
& 0x2) { //normal
125 /*TINFO=''TDD is in *NORMAL* STATE*/
126 } else if (status
& 0x4) { //sleep
127 /*TINFO=''TDD is in *SLEEP* STATE*/
131 status
= *((volatile unsigned short*)TDD_HALT_STATUS_ADDR(tdd_base
));
134 //printk("[ccci/ctl] (0)ABB power down...\n");
136 /*[ABB] MDMCU Control Power Down Sequence*/
137 mt65xx_reg_sync_writel((*MD_TOPSM_RM_PWR_CON0(md_topsm_base
)) | 0x00000090, MD_TOPSM_RM_PWR_CON0(md_topsm_base
));
138 mt65xx_reg_sync_writel((*MD_TOPSM_RM_PLL_MASK0(md_topsm_base
)) | 0xFFFF0000, MD_TOPSM_RM_PLL_MASK0(md_topsm_base
));
139 mt65xx_reg_sync_writel((*MD_TOPSM_RM_PLL_MASK1(md_topsm_base
)) | 0x000000FF, MD_TOPSM_RM_PLL_MASK1(md_topsm_base
));
140 mt65xx_reg_sync_writel((*MODEM2G_TOPSM_RM_PLL_MASK0(modem2g_topsm_base
)) | 0xFFFFFFFF, MODEM2G_TOPSM_RM_PLL_MASK0(modem2g_topsm_base
));
141 mt65xx_reg_sync_writel((*MODEM2G_TOPSM_RM_PLL_MASK1(modem2g_topsm_base
)) | 0x0000000F, MODEM2G_TOPSM_RM_PLL_MASK1(modem2g_topsm_base
));
143 //printk("[ccci/ctl] (0)MDMCU power down...\n");
145 /*[MDMCU] APMCU Control Power Down Sequence*/
146 mt65xx_reg_sync_writel(0xFFFFFFFF, MD_TOPSM_SM_REQ_MASK(md_topsm_base
));
147 mt65xx_reg_sync_writel(0x00000000, MD_TOPSM_RM_TMR_PWR0(md_topsm_base
));
148 mt65xx_reg_sync_writel(0x0005229A, MD_TOPSM_RM_PWR_CON0(md_topsm_base
));
149 mt65xx_reg_sync_writel(0xFFFFFFFF, MD_TOPSM_RM_PLL_MASK0(md_topsm_base
));
150 mt65xx_reg_sync_writel(0xFFFFFFFF, MD_TOPSM_RM_PLL_MASK1(md_topsm_base
));
152 mt65xx_reg_sync_writel(0xFFFFFFFF, MODEM2G_TOPSM_SM_REQ_MASK(modem2g_topsm_base
));
153 mt65xx_reg_sync_writel(0xFFFFFFFF, MODEM2G_TOPSM_RM_PLL_MASK0(modem2g_topsm_base
));
154 mt65xx_reg_sync_writel(0xFFFFFFFF, MODEM2G_TOPSM_RM_PLL_MASK1(modem2g_topsm_base
));
156 //printk("[ccci/ctl] (0)call md_power_off...\n");
158 md_power_off(0, 100);
160 iounmap((void*)md_topsm_base
);
161 iounmap((void*)modem2g_topsm_base
);
162 iounmap((void*)tdd_base
);
167 #ifndef __USING_DUMMY_CCCI_API__
169 //-------------feature enable/disable configure----------------//
170 //#define FEATURE_GET_TD_EINT_NUM
171 #define FEATURE_GET_MD_GPIO_NUM //disable for bring up
172 #define FEATURE_GET_MD_GPIO_VAL //disable for bring up
173 #define FEATURE_GET_MD_ADC_NUM //disable for bring up
174 #define FEATURE_GET_MD_ADC_VAL //disable for bring up
175 #define FEATURE_GET_MD_EINT_ATTR //disable for bring up
176 //#define FEATURE_GET_DRAM_TYPE_CLK
177 //#define FEATURE_MD_FAST_DORMANCY
178 #define FEATURE_GET_MD_BAT_VOL //disable for bring up
179 #define FEATURE_PM_IPO_H //disable for bring up
180 #define FEATURE_DFO_EN //Always bring up
182 //-------------grobal variable define----------------//
183 #define SHOW_WARNING_NUM (5)
186 #define MD1_MEM_SIZE (22*1024*1024)
187 #define MD1_SMEM_SIZE (2*1024*1024)
189 typedef struct _dfo_item
196 #ifndef FEATURE_DFO_EN
198 //---------- None-DFO Begin ------------
199 #if defined(MTK_ENABLE_MD1)
200 // Only modem 1 enable
201 static dfo_item_t ccci_dfo_setting
[] =
203 #if defined(MODEM_2G)
204 {"MTK_MD1_SUPPORT", modem_2g
},
207 #ifdef MTK_UMTS_TDD128_MODE
208 {"MTK_MD1_SUPPORT", modem_tg
},
210 {"MTK_MD1_SUPPORT", modem_wg
},
215 {"MTK_MD2_SUPPORT", modem_tg
},
216 {"MD1_SMEM_SIZE", MD1_SMEM_SIZE
},
217 {"MD2_SMEM_SIZE", 0},
218 {"MTK_ENABLE_MD1", 1},
219 {"MTK_ENABLE_MD2", 0},
220 {"MD1_SIZE", MD1_MEM_SIZE
},
225 static dfo_item_t ccci_dfo_setting
[] =
227 {"MTK_MD1_SUPPORT", modem_wg
},
228 {"MTK_MD2_SUPPORT", modem_tg
},
229 {"MD1_SMEM_SIZE", MD1_SMEM_SIZE
},
230 {"MD2_SMEM_SIZE", 0},
231 {"MTK_ENABLE_MD1", 0},
232 {"MTK_ENABLE_MD2", 0},
233 {"MD1_SIZE", MD1_MEM_SIZE
},
240 //----------- ---DFO Begin ------------
241 static dfo_item_t ccci_dfo_setting
[] =
243 {"MTK_MD1_SUPPORT", modem_wg
},
244 {"MTK_MD2_SUPPORT", modem_tg
},
245 {"MD1_SMEM_SIZE", 0},
246 {"MD2_SMEM_SIZE", 0},
247 {"MTK_ENABLE_MD1", 0},
248 {"MTK_ENABLE_MD2", 0},
252 #endif // FEATURE_DFO_EN
254 // Common for md memory setting
255 static unsigned int md_resv_mem_addr
[MAX_MD_NUM
];
256 static unsigned int md_resv_smem_addr
[MAX_MD_NUM
];
257 static unsigned int md_resv_smem_base
;
258 static unsigned int md_resv_mem_size
[MAX_MD_NUM
];
259 static unsigned int md_share_mem_size
[MAX_MD_NUM
];
260 static unsigned int modem_num
= 0;
261 static unsigned int md_usage_case
= 0;
262 static unsigned int md_support
[MAX_MD_NUM
];
263 static unsigned int modem_size_list
[MAX_MD_NUM
];
264 static char kern_func_err_num
[MAX_MD_NUM
][MAX_KERN_API
];
266 ccci_kern_func_info ccci_func_table
[MAX_MD_NUM
][MAX_KERN_API
];
267 ccci_sys_cb_func_info_t ccci_sys_cb_table_1000
[MAX_MD_NUM
][MAX_KERN_API
];
268 ccci_sys_cb_func_info_t ccci_sys_cb_table_100
[MAX_MD_NUM
][MAX_KERN_API
];
270 int (*ccci_sys_msg_notify_func
[MAX_MD_NUM
])(int, unsigned int, unsigned int);
273 //-------------external function declaration----------------//
274 extern unsigned long *get_modem_start_addr_list(void);
276 #if defined (FEATURE_GET_MD_ADC_NUM)
277 extern int IMM_get_adc_channel_num(char *channel_name
, int len
);
280 #if defined (FEATURE_GET_MD_ADC_VAL)
281 extern int IMM_GetOneChannelValue(int dwChannel
, int data
[4], int* rawdata
);
284 #if defined (FEATURE_GET_DRAM_TYPE_CLK)
285 extern int get_dram_info(int *clk
, int *type
);
288 #if defined (FEATURE_GET_MD_EINT_ATTR)
289 extern int get_eint_attribute(char *name
, unsigned int name_len
, unsigned int type
, char * result
, unsigned int *len
);
295 /***************************************************************************/
296 /* API of getting md information */
298 /***************************************************************************/
299 static int get_ccci_dfo_setting(char item
[], unsigned int *val
)
305 for (i
=0; i
<(sizeof(ccci_dfo_setting
)/sizeof(dfo_item_t
)); i
++) { // CCCI DFO feature index
306 ccci_name
= ccci_dfo_setting
[i
].name
;
307 ccci_value
= ccci_dfo_setting
[i
].value
;
308 if(!strcmp(ccci_name
, item
)) {
309 printk("[ccci/ctl] (0)Get DFO:%s:0x%08X\n", ccci_name
, ccci_value
);
310 *val
= (unsigned int)ccci_value
;
314 printk("[ccci/ctl] (0)DFO:%s not found\n", item
);
318 static void cal_md_mem_usage(void)
321 unsigned int md1_en
= 0;
326 if(get_ccci_dfo_setting("MTK_ENABLE_MD1", &tmp
) == 0) {
331 if(get_ccci_dfo_setting("MD1_SIZE", &tmp
) == 0) {
332 tmp
= round_up(tmp
, 0x200000);
333 md_resv_mem_size
[MD_SYS1
] = tmp
;
336 if(get_ccci_dfo_setting("MD1_SMEM_SIZE", &tmp
) == 0) {
337 tmp
= round_up(tmp
, 0x200000);
338 md_share_mem_size
[MD_SYS1
] = tmp
;
341 if(get_ccci_dfo_setting("MTK_MD1_SUPPORT", &tmp
) == 0) {
342 md_support
[MD_SYS1
] = tmp
;
345 // Setting conflict checking
346 if(md1_en
&& (md_share_mem_size
[MD_SYS1
]>0) && (md_resv_mem_size
[MD_SYS1
]>0)) {
348 } else if (md1_en
&& ((md_share_mem_size
[MD_SYS1
]<=0) || (md_resv_mem_size
[MD_SYS1
]<=0))) {
349 printk("[ccci/ctl] (0)[Error]DFO Setting for md1 wrong: <%d:0x%08X:0x%08X>\n",
350 md1_en
, md_resv_mem_size
[MD_SYS1
], md_share_mem_size
[MD_SYS1
]);
351 md_share_mem_size
[MD_SYS1
] = MD1_SMEM_SIZE
;
352 md_resv_mem_size
[MD_SYS1
] = MD1_MEM_SIZE
;
355 printk("[ccci/ctl] (0)[Error]DFO Setting for md1 conflict: <%d:0x%08X:0x%08X>\n",
356 md1_en
, md_resv_mem_size
[MD_SYS1
], md_share_mem_size
[MD_SYS1
]);
358 md_share_mem_size
[MD_SYS1
]=0;
359 md_resv_mem_size
[MD_SYS1
]=0;
363 md_usage_case
|= MD1_EN
;
367 if( (md_usage_case
&MD1_EN
) == MD1_EN
) { //Only MD1 enabled
368 modem_size_list
[0] = md_resv_mem_size
[MD_SYS1
]+md_share_mem_size
[MD_SYS1
];
369 //modem_size_list[1] = 0;
370 } else { // No MD is enabled
371 modem_size_list
[0] = 0;
372 //modem_size_list[1] = 0;
375 //printk("[ccci/ctl] (0)md_num: %d, md1_size: 0x%08X\n", modem_num, modem_size_list[0]);
380 //get the info about how many modem is running currently
381 unsigned int get_nr_modem(void)
383 // 2 additional modems (rear end)
387 EXPORT_SYMBOL(get_nr_modem
);
390 unsigned int *get_modem_size_list(void)
393 //return modem_size_list;
395 EXPORT_SYMBOL(get_modem_size_list
);
397 //Reserve DRAM memory for MD from system
398 void ccci_md_mem_reserve(void)
401 ptr
= (void*)arm_memblock_steal(modem_size_list
[0],SZ_32M
);
404 md_resv_mem_addr
[MD_SYS1
] =(unsigned int) ptr
;
405 printk("[ccci/ctl] (0)md mem reserve successfully,ptr=%p,size=%d\n",ptr
,modem_size_list
[0]);
407 printk("[ccci/ctl] (0)md mem reserve fail.\n");
408 md_resv_mem_addr
[MD_SYS1
] =0;
413 #if defined(FEATURE_DFO_EN)
415 int parse_ccci_dfo_setting(void *dfo_tbl
, int num
)
423 tag_dfo_boot
*dfo_data
;
428 dfo_data
= (tag_dfo_boot
*)dfo_tbl
;
429 for (i
=0; i
<(sizeof(ccci_dfo_setting
)/sizeof(dfo_item_t
)); i
++) { // CCCI DFO feature index
430 ccci_name
= ccci_dfo_setting
[i
].name
;
431 ccci_value
= &(ccci_dfo_setting
[i
].value
);
432 for (j
=0; j
<num
; j
++) { // DFO tag index
433 tag_name
= dfo_data
->name
[j
];
434 tag_value
= dfo_data
->value
[j
];
435 if(!strcmp(ccci_name
, tag_name
)) {
436 *ccci_value
= tag_value
;
439 printk("[ccci/ctl] (0)DFO:%s:0x%08X\n", ccci_name
, *ccci_value
);
447 int parse_ccci_dfo_setting(void *dfo_data
, int num
)
453 for (i
=0; i
<(sizeof(ccci_dfo_setting
)/sizeof(dfo_item_t
)); i
++) { // CCCI DFO feature index
454 ccci_name
= ccci_dfo_setting
[i
].name
;
455 ccci_value
= ccci_dfo_setting
[i
].value
;
456 printk("[ccci/ctl] (0)DFO:%s:0x%08X\n", ccci_name
, ccci_value
);
465 static void collect_md_setting(void)
470 //addr = get_modem_start_addr_list();
471 addr
= (unsigned long *)md_resv_mem_addr
;
473 if( (md_usage_case
&MD1_EN
)== MD1_EN
) { //Only MD1 enabled
475 md_resv_mem_addr
[MD_SYS1
] = (unsigned int)addr
[0];
476 md_resv_smem_addr
[MD_SYS1
] = (unsigned int)(addr
[0] + md_resv_mem_size
[MD_SYS1
]);
477 md_resv_smem_base
= (unsigned int)addr
[0];
478 } else { // No MD is enabled
480 md_resv_mem_addr
[MD_SYS1
] = 0;
481 md_resv_smem_addr
[MD_SYS1
] = 0;
482 md_resv_smem_base
= 0;
485 if ( (md_resv_mem_addr
[MD_SYS1
]&(32*1024*1024 - 1)) != 0 )
486 printk("[ccci/ctl] (0) md1 memory addr is not 32M align!!!\n");
488 if ( (md_resv_smem_addr
[MD_SYS1
]&(2*1024*1024 - 1)) != 0 )
489 printk("[ccci/ctl] (0) md1 share memory addr %08x is not 2M align!!\n", md_resv_smem_addr
[MD_SYS1
]);
491 printk("[ccci/ctl] (0)EN(%d):MemBase(0x%08X)\n", md1_en
, md_resv_smem_base
);
493 printk("[ccci/ctl] (0)MemStart(0x%08X):MemSize(0x%08X)\n", \
494 md_resv_mem_addr
[MD_SYS1
], md_resv_mem_size
[MD_SYS1
]);
496 printk("[ccci/ctl] (0)SmemStart(0x%08X):SmemSize(0x%08X)\n", \
497 md_resv_smem_addr
[MD_SYS1
], md_share_mem_size
[MD_SYS1
]);
501 int parse_meta_md_setting(unsigned char args
[])
503 char md_active_setting
= args
[1];
504 char md_setting_flag
= args
[0];
507 if(md_active_setting
& MD1_SETTING_ACTIVE
)
509 else if(md_active_setting
& MD2_SETTING_ACTIVE
)
514 if(md_setting_flag
&MD_WG_FLAG
) {
515 md_support
[MD_SYS1
] = modem_wg
;
516 } else if(md_setting_flag
&MD_TG_FLAG
) {
517 md_support
[MD_SYS1
] = modem_tg
;
518 } else if(md_setting_flag
&MD_2G_FLAG
) {
519 md_support
[MD_SYS1
] = modem_2g
;
521 printk("[ccci/ctl] (0)Meta active id:1, md type:%d\n", md_support
[MD_SYS1
]);
530 unsigned int get_modem_is_enabled(int md_id
)
535 return !!(md_usage_case
&MD1_EN
);
541 EXPORT_SYMBOL(get_modem_is_enabled
);
544 unsigned int get_modem_support(int md_id
)
549 return md_support
[MD_SYS1
];
555 EXPORT_SYMBOL(get_modem_support
);
557 unsigned int set_modem_support(int md_id
, int md_type
)
562 if (md_type
>= modem_2g
&& md_type
<= modem_tg
){
563 md_support
[MD_SYS1
] = md_type
;
566 printk("[ccci/ctl] error: set_modem_support fail(md:%d, md_type:%d)!\n", md_id
+1, md_type
);
573 EXPORT_SYMBOL(set_modem_support
);
576 unsigned int get_resv_mem_size_for_md(int md_id
)
581 return md_resv_mem_size
[MD_SYS1
];
587 EXPORT_SYMBOL(get_resv_mem_size_for_md
);
590 unsigned int get_resv_share_mem_size_for_md(int md_id
)
595 return md_share_mem_size
[MD_SYS1
];
601 EXPORT_SYMBOL(get_resv_share_mem_size_for_md
);
604 unsigned int get_md_mem_start_addr(int md_id
)
609 return md_resv_mem_addr
[MD_SYS1
];
615 EXPORT_SYMBOL(get_md_mem_start_addr
);
617 unsigned int get_md_share_mem_start_addr(int md_id
)
622 return md_resv_smem_addr
[MD_SYS1
];
628 EXPORT_SYMBOL(get_md_share_mem_start_addr
);
631 //unsigned int get_md_mem_base_addr(int md_id)
632 unsigned int get_smem_base_addr(int md_id
)
637 return md_resv_smem_base
;
643 EXPORT_SYMBOL(get_smem_base_addr
);
646 void get_md_post_fix(int md_id
, char buf
[], char buf_ex
[])
648 // modem_X_YY_K_[Ex].img
653 unsigned int feature_val
= 0;
663 feature_val
= md_support
[MD_SYS1
];
673 snprintf(YY_K
, 8, "_2g_n");
677 snprintf(YY_K
, 8, "_3g_n");
681 snprintf(YY_K
, 8, "_wg_n");
685 snprintf(YY_K
, 8, "_tg_n");
692 // [_Ex] Get chip version
693 //if(get_chip_version() == CHIP_SW_VER_01)
695 //else if(get_chip_version() == CHIP_SW_VER_02)
700 snprintf(buf
, 12, "%d%s", X
, YY_K
);
703 snprintf(buf_ex
, 12, "%d%s_E%d", X
, YY_K
, Ex
);
705 EXPORT_SYMBOL(get_md_post_fix
);
708 /***************************************************************************/
709 /* provide API called by ccci module */
711 /***************************************************************************/
712 AP_IMG_TYPE
get_ap_img_ver(void)
714 #if defined(MODEM_2G)
716 #elif defined(MODEM_3G)
719 return AP_IMG_INVALID
;
722 EXPORT_SYMBOL(get_ap_img_ver
);
725 int get_td_eint_info(int md_id
, char * eint_name
, unsigned int len
)
727 #if defined (FEATURE_GET_TD_EINT_NUM)
728 return get_td_eint_num(eint_name
, len
);
734 EXPORT_SYMBOL(get_td_eint_info
);
737 int get_md_gpio_info(int md_id
, char *gpio_name
, unsigned int len
)
739 #if defined (FEATURE_GET_MD_GPIO_NUM)
740 return mt_get_md_gpio(gpio_name
, len
);
746 EXPORT_SYMBOL(get_md_gpio_info
);
749 int get_md_gpio_val(int md_id
, unsigned int num
)
751 #if defined (FEATURE_GET_MD_GPIO_VAL)
752 return mt_get_gpio_in(num
);
758 EXPORT_SYMBOL(get_md_gpio_val
);
761 int get_md_adc_info(int md_id
, char *adc_name
, unsigned int len
)
763 #if defined (FEATURE_GET_MD_ADC_NUM)
764 return IMM_get_adc_channel_num(adc_name
, len
);
770 EXPORT_SYMBOL(get_md_adc_info
);
773 int get_md_adc_val(int md_id
, unsigned int num
)
775 int data
[4] = {0,0,0,0};
779 #if defined (FEATURE_GET_MD_ADC_VAL)
780 ret
= IMM_GetOneChannelValue(num
, data
, &val
);
790 EXPORT_SYMBOL(get_md_adc_val
);
793 int get_eint_attr(char *name
, unsigned int name_len
, unsigned int type
, char * result
, unsigned int *len
)
795 #if defined (FEATURE_GET_MD_EINT_ATTR)
796 return get_eint_attribute(name
, name_len
, type
, result
, len
);
802 EXPORT_SYMBOL(get_eint_attr
);
805 int get_dram_type_clk(int *clk
, int *type
)
807 #if defined (FEATURE_GET_DRAM_TYPE_CLK)
808 return get_dram_info(clk
, type
);
813 EXPORT_SYMBOL(get_dram_type_clk
);
816 void md_fast_dormancy(int md_id
)
818 #if defined (FEATURE_MD_FAST_DORMANCY)
819 #ifdef MTK_FD_SUPPORT
820 exec_ccci_kern_func_by_md_id(md_id
, ID_CCCI_DORMANCY
, NULL
, 0);
824 EXPORT_SYMBOL(md_fast_dormancy
);
827 int get_bat_info(unsigned int para
)
829 #if defined (FEATURE_GET_MD_BAT_VOL)
830 return (int)BAT_Get_Battery_Voltage(0);
833 EXPORT_SYMBOL(get_bat_info
);
837 /***************************************************************************/
838 /* Make sysfs node helper function section */
840 /***************************************************************************/
841 ssize_t
mtk_ccci_attr_show(struct kobject
*kobj
, struct attribute
*attr
, char *buffer
);
842 ssize_t
mtk_ccci_attr_store(struct kobject
*kobj
, struct attribute
*attr
, const char *buffer
, size_t size
);
843 ssize_t
mtk_ccci_filter_show(struct kobject
*kobj
, char *page
);
844 ssize_t
mtk_ccci_filter_store(struct kobject
*kobj
, const char *page
, size_t size
);
846 struct sysfs_ops mtk_ccci_sysfs_ops
= {
847 .show
= mtk_ccci_attr_show
,
848 .store
= mtk_ccci_attr_store
,
851 struct mtk_ccci_sys_entry
{
852 struct attribute attr
;
853 ssize_t (*show
)(struct kobject
*kobj
, char *page
);
854 ssize_t (*store
)(struct kobject
*kobj
, const char *page
, size_t size
);
857 static struct mtk_ccci_sys_entry filter_setting_entry
= {
858 { .name
= "filter", .mode
= S_IRUGO
| S_IWUSR
},
859 mtk_ccci_filter_show
,
860 mtk_ccci_filter_store
,
863 struct attribute
*mtk_ccci_attributes
[] = {
864 &filter_setting_entry
.attr
,
868 struct kobj_type mtk_ccci_ktype
= {
869 .sysfs_ops
= &mtk_ccci_sysfs_ops
,
870 .default_attrs
= mtk_ccci_attributes
,
873 static struct mtk_ccci_sysobj
{
878 static int mtk_ccci_sysfs(void)
880 struct mtk_ccci_sysobj
*obj
= &ccci_sysobj
;
882 memset(&obj
->kobj
, 0x00, sizeof(obj
->kobj
));
884 obj
->kobj
.parent
= kernel_kobj
;
885 if (kobject_init_and_add(&obj
->kobj
, &mtk_ccci_ktype
, NULL
, "ccci")) {
886 kobject_put(&obj
->kobj
);
889 kobject_uevent(&obj
->kobj
, KOBJ_ADD
);
894 ssize_t
mtk_ccci_attr_show(struct kobject
*kobj
, struct attribute
*attr
, char *buffer
)
896 struct mtk_ccci_sys_entry
*entry
= container_of(attr
, struct mtk_ccci_sys_entry
, attr
);
897 return entry
->show(kobj
, buffer
);
900 ssize_t
mtk_ccci_attr_store(struct kobject
*kobj
, struct attribute
*attr
, const char *buffer
, size_t size
)
902 struct mtk_ccci_sys_entry
*entry
= container_of(attr
, struct mtk_ccci_sys_entry
, attr
);
903 return entry
->store(kobj
, buffer
, size
);
906 //----------------------------------------------------------//
908 //----------------------------------------------------------//
909 cmd_op_map_t cmd_map_table
[MAX_FILTER_MEMBER
] = {{"",0}, {"",0}, {"",0}, {"",0}};
911 ssize_t
mtk_ccci_filter_show(struct kobject
*kobj
, char *buffer
)
914 int remain
= PAGE_SIZE
;
918 for(i
=0; i
<MAX_FILTER_MEMBER
; i
++){
919 if( cmd_map_table
[i
].cmd_len
!=0 ){
921 if(NULL
!= cmd_map_table
[i
].show
){
922 len
= cmd_map_table
[i
].show(ptr
, remain
);
929 return (PAGE_SIZE
-remain
);
932 ssize_t
mtk_ccci_filter_store(struct kobject
*kobj
, const char *buffer
, size_t size
)
936 for(i
=0; i
<MAX_FILTER_MEMBER
; i
++){
937 if( strncmp(buffer
, cmd_map_table
[i
].cmd
, cmd_map_table
[i
].cmd_len
)==0 ){
939 if(NULL
!= cmd_map_table
[i
].store
){
940 return cmd_map_table
[i
].store((char*)buffer
, size
);
944 printk("[ccci/ctl] (0)unsupport cmd\n");
948 int register_filter_func(char cmd
[], ccci_filter_cb_func_t store
, ccci_filter_cb_func_t show
)
954 for(i
=0; i
<MAX_FILTER_MEMBER
; i
++){
955 if( 0 == cmd_map_table
[i
].cmd_len
){
959 }else if( strcmp(cmd
, cmd_map_table
[i
].cmd
)==0 ){
960 // Find a duplicate cmd
964 if( -1 != empty_slot
){
965 cmd_len
= strlen(cmd
);
970 cmd_map_table
[empty_slot
].cmd_len
= cmd_len
;
971 for(i
=0; i
<cmd_len
; i
++)
972 cmd_map_table
[empty_slot
].cmd
[i
] = cmd
[i
];
973 cmd_map_table
[empty_slot
].cmd
[i
] = 0; // termio char
974 cmd_map_table
[empty_slot
].store
= store
;
975 cmd_map_table
[empty_slot
].show
= show
;
980 EXPORT_SYMBOL(register_filter_func
);
984 /***************************************************************************/
985 /* Register kernel API for ccci driver invoking */
987 /***************************************************************************/
988 int register_ccci_kern_func_by_md_id(int md_id
, unsigned int id
, ccci_kern_cb_func_t func
)
991 ccci_kern_func_info
*info_ptr
;
993 if((id
>= MAX_KERN_API
) || (func
== NULL
) || (md_id
>= MAX_MD_NUM
)) {
994 printk("[ccci/ctl] (0)register kern func fail: md_id:%d, func_id:%d!\n", md_id
+1, id
);
998 info_ptr
= &(ccci_func_table
[md_id
][id
]);
999 if(info_ptr
->func
== NULL
) {
1001 info_ptr
->func
= func
;
1004 printk("[ccci/ctl] (%d)register kern func fail: func(%d) registered!\n", md_id
+1, id
);
1008 EXPORT_SYMBOL(register_ccci_kern_func_by_md_id
);
1011 int register_ccci_kern_func(unsigned int id
, ccci_kern_cb_func_t func
)
1013 return register_ccci_kern_func_by_md_id(CURR_MD_ID
, id
, func
);
1015 EXPORT_SYMBOL(register_ccci_kern_func
);
1018 int exec_ccci_kern_func_by_md_id(int md_id
, unsigned int id
, char *buf
, unsigned int len
)
1020 ccci_kern_cb_func_t func
;
1023 if(md_id
>= MAX_MD_NUM
) {
1024 printk("[ccci/ctl] (0)exec kern func fail: invalid md id(%d)\n", md_id
+1);
1028 if(id
>= MAX_KERN_API
) {
1029 printk("[ccci/ctl] (%d)exec kern func fail: invalid func id(%d)!\n", md_id
, id
);
1033 func
= ccci_func_table
[md_id
][id
].func
;
1035 ret
= func(md_id
, buf
, len
);
1039 if(kern_func_err_num
[md_id
][id
] < SHOW_WARNING_NUM
) {
1040 kern_func_err_num
[md_id
][id
]++;
1041 printk("[ccci/ctl] (%d)exec kern func fail: func%d not register!\n", md_id
+1, id
);
1047 EXPORT_SYMBOL(exec_ccci_kern_func_by_md_id
);
1050 int exec_ccci_kern_func(unsigned int id
, char *buf
, unsigned int len
)
1052 return exec_ccci_kern_func_by_md_id(CURR_MD_ID
, id
, buf
, len
);
1054 EXPORT_SYMBOL(exec_ccci_kern_func
);
1058 /***************************************************************************/
1059 /* Register ccci call back function when AP receive system channel message */
1061 /***************************************************************************/
1062 int register_sys_msg_notify_func(int md_id
, int (*func
)(int, unsigned int, unsigned int))
1066 if( md_id
>= MAX_MD_NUM
) {
1067 printk("[ccci/ctl] (0)register_sys_msg_notify_func fail: invalid md id(%d)\n", md_id
+1);
1071 if(ccci_sys_msg_notify_func
[md_id
] == NULL
) {
1072 ccci_sys_msg_notify_func
[md_id
] = func
;
1074 printk("[ccci/ctl] (%d)ccci_sys_msg_notify_func fail: func registered!\n", md_id
+1);
1079 EXPORT_SYMBOL(register_sys_msg_notify_func
);
1082 int notify_md_by_sys_msg(int md_id
, unsigned int msg
, unsigned int data
)
1085 int (*func
)(int, unsigned int, unsigned int);
1087 if(md_id
>= MAX_MD_NUM
) {
1088 printk("[ccci/ctl] (0)notify_md_by_sys_msg: invalid md id(%d)\n", md_id
+1);
1092 func
= ccci_sys_msg_notify_func
[md_id
];
1094 ret
= func(md_id
, msg
, data
);
1097 printk("[ccci/ctl] (%d)notify_md_by_sys_msg fail: func not register!\n", md_id
+1);
1102 EXPORT_SYMBOL(notify_md_by_sys_msg
);
1105 int register_ccci_sys_call_back(int md_id
, unsigned int id
, ccci_sys_cb_func_t func
)
1108 ccci_sys_cb_func_info_t
*info_ptr
;
1110 if( md_id
>= MAX_MD_NUM
) {
1111 printk("[ccci/ctl] (0)register_sys_call_back fail: invalid md id(%d)\n", md_id
+1);
1115 if((id
>= 0x100)&&((id
-0x100) < MAX_KERN_API
)) {
1116 info_ptr
= &(ccci_sys_cb_table_100
[md_id
][id
-0x100]);
1117 } else if((id
>= 0x1000)&&((id
-0x1000) < MAX_KERN_API
)) {
1118 info_ptr
= &(ccci_sys_cb_table_1000
[md_id
][id
-0x1000]);
1120 printk("[ccci/ctl] (%d)register_sys_call_back fail: invalid func id(0x%x)\n", md_id
+1, id
);
1124 if(info_ptr
->func
== NULL
) {
1126 info_ptr
->func
= func
;
1129 printk("[ccci/ctl] (%d)register_sys_call_back fail: func(0x%x) registered!\n", md_id
+1, id
);
1133 EXPORT_SYMBOL(register_ccci_sys_call_back
);
1136 void exec_ccci_sys_call_back(int md_id
, int cb_id
, int data
)
1138 ccci_sys_cb_func_t func
;
1140 ccci_sys_cb_func_info_t
*curr_table
;
1142 if(md_id
>= MAX_MD_NUM
) {
1143 printk("[ccci/ctl] (0)exec_sys_cb fail: invalid md id(%d) \n", md_id
+1);
1148 if(id
>= MAX_KERN_API
) {
1149 printk("[ccci/ctl] (%d)exec_sys_cb fail: invalid func id(0x%x)\n", md_id
+1, cb_id
);
1153 if ((cb_id
& (0x1000|0x100))==0x1000) {
1154 curr_table
= ccci_sys_cb_table_1000
[md_id
];
1155 } else if ((cb_id
& (0x1000|0x100))==0x100) {
1156 curr_table
= ccci_sys_cb_table_100
[md_id
];
1158 printk("[ccci/ctl] (%d)exec_sys_cb fail: invalid func id(0x%x)\n", md_id
+1, cb_id
);
1162 func
= curr_table
[id
].func
;
1166 printk("[ccci/ctl] (%d)exec_sys_cb fail: func id(0x%x) not register!\n", md_id
+1, cb_id
);
1169 EXPORT_SYMBOL(exec_ccci_sys_call_back
);
1173 /***************************************************************************/
1174 /* Register ccci suspend & resume function */
1176 /***************************************************************************/
1177 typedef struct ccci_pm_cb_item
1179 void (*cb_func
)(int);
1184 static ccci_pm_cb_item_t suspend_cb_table
[MAX_MD_NUM
][MAX_SLEEP_API
];
1185 static ccci_pm_cb_item_t resume_cb_table
[MAX_MD_NUM
][MAX_SLEEP_API
];
1188 void register_suspend_notify(int md_id
, unsigned int id
, void (*func
)(int))
1190 if((id
>= MAX_SLEEP_API
) || (func
== NULL
) || (md_id
>= MAX_MD_NUM
)) {
1191 printk("[ccci/ctl] (0)invalid suspend parameter(md:%d, cmd:%d)!\n", md_id
, id
);
1194 if (suspend_cb_table
[md_id
][id
].cb_func
== NULL
){
1195 suspend_cb_table
[md_id
][id
].cb_func
= func
;
1196 suspend_cb_table
[md_id
][id
].md_id
= md_id
;
1199 EXPORT_SYMBOL(register_suspend_notify
);
1202 void register_resume_notify(int md_id
, unsigned int id
, void (*func
)(int))
1204 if((id
>= MAX_SLEEP_API
) || (func
== NULL
) || (md_id
>= MAX_MD_NUM
)) {
1205 printk("[ccci/ctl] (0)invalid resume parameter(md:%d, cmd:%d)!\n", md_id
, id
);
1208 if (resume_cb_table
[md_id
][id
].cb_func
== NULL
){
1209 resume_cb_table
[md_id
][id
].cb_func
= func
;
1210 resume_cb_table
[md_id
][id
].md_id
= md_id
;
1213 EXPORT_SYMBOL(register_resume_notify
);
1216 static int ccci_helper_probe(struct platform_device
*dev
)
1219 //printk( "\nccci_helper_probe\n" );
1223 static int ccci_helper_remove(struct platform_device
*dev
)
1225 //printk( "\nccci_helper_remove\n" );
1229 static void ccci_helper_shutdown(struct platform_device
*dev
)
1231 //printk( "\nccci_helper_shutdown\n" );
1234 static int ccci_helper_suspend(struct platform_device
*dev
, pm_message_t state
)
1240 printk( "\nccci_helper_suspend\n" );
1242 for (i
= 0; i
< MAX_MD_NUM
; i
++) {
1243 for (j
= 0; j
< SLP_ID_MAX
; j
++) {
1244 func
= suspend_cb_table
[i
][j
].cb_func
;
1245 md_id
= suspend_cb_table
[i
][j
].md_id
;
1254 static int ccci_helper_resume(struct platform_device
*dev
)
1260 printk( "\nccci_helper_resume\n" );
1262 for (i
= 0; i
< MAX_MD_NUM
; i
++) {
1263 for (j
= 0; j
< RSM_ID_MAX
; j
++) {
1264 func
= resume_cb_table
[i
][j
].cb_func
;
1265 md_id
= resume_cb_table
[i
][j
].md_id
;
1275 //*-------------------------------------------------------------*//
1276 #if defined (CONFIG_PM) && defined (FEATURE_PM_IPO_H)
1277 int ccci_helper_pm_suspend(struct device
*device
)
1279 //pr_debug("calling %s()\n", __func__);
1281 struct platform_device
*pdev
= to_platform_device(device
);
1282 BUG_ON(pdev
== NULL
);
1284 return ccci_helper_suspend(pdev
, PMSG_SUSPEND
);
1287 int ccci_helper_pm_resume(struct device
*device
)
1289 //pr_debug("calling %s()\n", __func__);
1291 struct platform_device
*pdev
= to_platform_device(device
);
1292 BUG_ON(pdev
== NULL
);
1294 return ccci_helper_resume(pdev
);
1297 extern void mt_irq_set_sens(unsigned int irq
, unsigned int sens
);
1298 extern void mt_irq_set_polarity(unsigned int irq
, unsigned int polarity
);
1299 int ccci_helper_pm_restore_noirq(struct device
*device
)
1301 pr_debug("calling %s()\n", __func__
);
1304 mt_irq_set_sens(CCIF0_AP_IRQ_ID
, MT_LEVEL_SENSITIVE
);
1305 mt_irq_set_polarity(CCIF0_AP_IRQ_ID
, MT_POLARITY_LOW
);
1308 mt_irq_set_sens(MD_WDT_IRQ_ID
, MT_EDGE_SENSITIVE
);
1309 mt_irq_set_polarity(MD_WDT_IRQ_ID
, MT_POLARITY_LOW
);
1312 exec_ccci_kern_func_by_md_id(0, ID_IPO_H_RESTORE_CB
, NULL
, 0);
1320 #define ccci_helper_pm_suspend NULL
1321 #define ccci_helper_pm_resume NULL
1322 #define ccci_helper_pm_restore_noirq NULL
1324 #endif /*CONFIG_PM*/
1325 //*-------------------------------------------------------------*//
1327 struct dev_pm_ops ccci_helper_pm_ops
= {
1328 .suspend
= ccci_helper_pm_suspend
,
1329 .resume
= ccci_helper_pm_resume
,
1330 .freeze
= ccci_helper_pm_suspend
,
1331 .thaw
= ccci_helper_pm_resume
,
1332 .poweroff
= ccci_helper_pm_suspend
,
1333 .restore
= ccci_helper_pm_resume
,
1334 .restore_noirq
= ccci_helper_pm_restore_noirq
,
1337 static struct platform_driver ccci_helper_driver
=
1340 .name
= "ccci-helper",
1342 .pm
= &ccci_helper_pm_ops
,
1345 .probe
= ccci_helper_probe
,
1346 .remove
= ccci_helper_remove
,
1347 .shutdown
= ccci_helper_shutdown
,
1348 .suspend
= ccci_helper_suspend
,
1349 .resume
= ccci_helper_resume
,
1352 struct platform_device ccci_helper_device
= {
1353 .name
= "ccci-helper",
1359 static int __init
ccci_helper_init(void)
1363 #if defined (MTK_KERNEL_POWER_OFF_CHARGING)
1364 if ((g_boot_mode
== KERNEL_POWER_OFF_CHARGING_BOOT
) || (g_boot_mode
== LOW_POWER_OFF_CHARGING_BOOT
))
1365 internal_md_power_down();
1368 collect_md_setting();
1370 // Init ccci helper sys fs
1371 memset( (void*)cmd_map_table
, 0, sizeof(cmd_map_table
) );
1374 // init ccci kernel API register table
1375 memset((void*)ccci_func_table
, 0, sizeof(ccci_func_table
));
1376 memset((void*)kern_func_err_num
, 0, sizeof(kern_func_err_num
));
1378 // init ccci system channel call back function register table
1379 memset((void*)ccci_sys_cb_table_100
, 0, sizeof(ccci_sys_cb_table_100
));
1380 memset((void*)ccci_sys_cb_table_1000
, 0, sizeof(ccci_sys_cb_table_1000
));
1382 ret
= platform_device_register(&ccci_helper_device
);
1384 printk("[ccci/ctl] (0)ccci_helper_device register fail(%d)\n", ret
);
1388 ret
= platform_driver_register(&ccci_helper_driver
);
1390 printk("[ccci/ctl] (0)ccci_helper_driver register fail(%d)\n", ret
);
1398 void ccci_helper_exit(void)
1400 printk("[ccci/ctl] (0)ccci_helper_exit\n");
1402 // free ccci helper sys fs
1403 memset((void*)cmd_map_table
, 0, sizeof(cmd_map_table
));
1405 // free ccci kernel API register table
1406 memset((void*)ccci_func_table
, 0, sizeof(ccci_func_table
));
1407 memset((void*)ccci_sys_msg_notify_func
, 0, sizeof(ccci_sys_msg_notify_func
));
1409 // free ccci system channel call back function register table
1410 memset((void*)ccci_sys_cb_table_100
, 0, sizeof(ccci_sys_cb_table_100
));
1411 memset((void*)ccci_sys_cb_table_1000
, 0, sizeof(ccci_sys_cb_table_1000
));
1413 //free suspend/resume function table
1414 memset((void*)suspend_cb_table
, 0, sizeof(suspend_cb_table
));
1415 memset((void*)resume_cb_table
, 0, sizeof(resume_cb_table
));
1418 EXPORT_SYMBOL(ccci_helper_exit
);
1421 module_init(ccci_helper_init
);
1423 MODULE_LICENSE("GPL");
1424 MODULE_AUTHOR("MTK");
1425 MODULE_DESCRIPTION("The ccci helper function");
1428 unsigned int modem_size_list
[1] = {0};
1429 unsigned int get_nr_modem(void)
1434 unsigned int *get_modem_size_list(void)
1436 return modem_size_list
;
1438 int parse_ccci_dfo_setting(void *dfo_tbl
, int num
)
1443 int parse_meta_md_setting(unsigned char args
[])
1448 unsigned int get_modem_is_enabled(int md_id
)
1453 unsigned int get_modem_support(int md_id
)
1458 unsigned int set_modem_support(int md_id
, int md_type
)
1464 int register_ccci_kern_func(unsigned int id
, ccci_kern_cb_func_t func
)
1469 int register_ccci_kern_func_by_md_id(int md_id
, unsigned int id
, ccci_kern_cb_func_t func
)
1474 int exec_ccci_kern_func(unsigned int id
, char *buf
, unsigned int len
)
1479 int exec_ccci_kern_func_by_md_id(int md_id
, unsigned int id
, char *buf
, unsigned int len
)
1484 int register_ccci_sys_call_back(int md_id
, unsigned int id
, ccci_sys_cb_func_t func
)
1489 void exec_ccci_sys_call_back(int md_id
, int cb_id
, int data
)
1493 void ccci_helper_exit(void)
1496 void ccci_md_mem_reserve(void)
1501 #ifndef MTK_ENABLE_MD1
1503 static int __init
ccci_helper_init(void)
1505 #ifndef MTK_TB_WIFI_3G_MODE_WIFI_ONLY
1506 internal_md_power_down();
1511 #ifndef CONFIG_MT8127_EVB_BOARD
1512 module_init(ccci_helper_init
);
1515 MODULE_LICENSE("GPL");
1516 MODULE_AUTHOR("MTK");
1517 MODULE_DESCRIPTION("The ccci helper function");
1518 #endif//MTK_ENABLE_MD1