ccci_common.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. /*****************************************************************************
  2. *
  3. * Filename:
  4. * ---------
  5. * ccci_common.h
  6. *
  7. * Project:
  8. * --------
  9. *
  10. * Description:
  11. * ------------
  12. *
  13. * Author:
  14. * -------
  15. *
  16. ****************************************************************************/
  17. #ifndef __CCCI_COMMON_H__
  18. #define __CCCI_COMMON_H__
  19. #include <ccci_cfg.h>
  20. #include <ccci_err_no.h>
  21. #include <ccci_md.h>
  22. #include <ccci_layer.h>
  23. #include <ccci_rpc.h>
  24. #include <ccci_ipc.h>
  25. #include <ccci_fs.h>
  26. #include <ccmni_net.h>
  27. #include <ccci_platform_cfg.h>
  28. #include <mach/mtk_ccci_helper.h>
  29. /* ======================================================== */
  30. /* debug log define */
  31. /* ======================================================== */
  32. #define CCCI_MSG(fmt, args...) pr_notice("[com] (0)" fmt, ##args)
  33. #define CCCI_MSG_INF(idx, tag, fmt, args...) pr_notice("[" tag "] (%d)" fmt, (idx+1), ##args)
  34. #define CCCI_DBG_MSG(idx, tag, fmt, args...) pr_debug("[" tag "] (%d)" fmt, (idx+1), ##args)
  35. #define CCCI_DBG_COM_MSG(fmt, args...) pr_notice("[com] (0)" fmt, ##args)
  36. #define CCCI_ERR(fmt, args...) pr_err("[err] (0)" fmt, ##args)
  37. #define CCCI_ERR_INF(idx, tag, fmt, args...) pr_err("[" tag "] (%d)" fmt, (idx+1), ##args)
  38. /*---------------------------Switchable log--------------------------------*/
  39. /* Debug message switch */
  40. #define CCCI_DBG_NONE (0x00000000) /* No debug log */
  41. #define CCCI_DBG_CTL (0x00000001) /* Control log */
  42. #define CCCI_DBG_TTY (0x00000002) /* TTY channel log */
  43. #define CCCI_DBG_FS (0x00000004) /* FS channel log */
  44. #define CCCI_DBG_RPC (0x00000008) /* RPC channel log */
  45. #define CCCI_DBG_IPC (0x00000010) /* IPC channel log */
  46. #define CCCI_DBG_PMIC (0x00000020) /* PMIC channel log */
  47. #define CCCI_DBG_CCMNI (0x00000040) /* CCMIN channel log */
  48. #define CCCI_DBG_FUNC (0x00000080) /* Functiong entry log */
  49. #define CCCI_DBG_MISC (0x00000100) /* Misc log */
  50. #define CCCI_DBG_CHR (0x00000200) /* Char dev log */
  51. #define CCCI_DBG_CCIF (0x00000400) /* Ccif log */
  52. #define CCCI_DBG_ALL (0xffffffff)
  53. #define ENABLE_ALL_RX_LOG (1ULL<<63)
  54. /*---------------------------------------------------------------------------*/
  55. /* Switchable messages */
  56. extern unsigned int ccci_msg_mask[];
  57. #ifdef USING_PRINTK_LOG
  58. #define CCCI_FILTER_MSG(mask, fmt, args...) \
  59. do { \
  60. if (CCCI_DBG_##mask & ccci_msg_mask) \
  61. pr_debug("[ccci]" fmt, ##args); \
  62. } while (0)
  63. #define CCCI_CTL_MSG(fmt, args...) CCCI_FILTER_MSG(CTL, "<ctl>"fmt, ##args)
  64. #define CCCI_TTY_MSG(fmt, args...) CCCI_FILTER_MSG(TTY, "<tty>"fmt, ##args)
  65. #define CCCI_FS_MSG(fmt, args...) CCCI_FILTER_MSG(FS, "<fs>"fmt, ##args)
  66. #define CCCI_RPC_MSG(fmt, args...) CCCI_FILTER_MSG(RPC, "<rpc>"fmt, ##args)
  67. #define CCCI_IPC_MSG(fmt, args...) CCCI_FILTER_MSG(IPC, "<ipc>"fmt, ##args)
  68. #define CCCI_PMIC_MSG(fmt, args...) CCCI_FILTER_MSG(PMIC, "<pmic>"fmt, ##args)
  69. #define CCCI_FUNC_ENTRY(f) CCCI_FILTER_MSG(FUNC, "%s\n", __func__)
  70. #define CCCI_MISC_MSG(fmt, args...) CCCI_FILTER_MSG(MISC, fmt, ##args)
  71. #define CCCI_CHR_MSG(fmt, args...) CCCI_FILTER_MSG(CHR, "<chr>"fmt, ##args)
  72. #define CCCI_CCIF_MSG(fmt, args...) CCCI_FILTER_MSG(CCIF, "<chr>"fmt, ##args)
  73. #define CCCI_CCMNI_MSG(fmt, args...) CCCI_FILTER_MSG(CCMNI, "<ccmni>"fmt, ##args)
  74. #else
  75. #define CCCI_FILTER_MSG(mask, tag, idx, fmt, args...) \
  76. do { \
  77. if (CCCI_DBG_##mask & ccci_msg_mask[idx]) \
  78. CCCI_MSG_INF(idx, tag, fmt, ##args); \
  79. } while (0)
  80. #define CCCI_CTL_MSG(idx, fmt, args...) CCCI_FILTER_MSG(CTL, "/ctl", idx, fmt, ##args)
  81. #define CCCI_TTY_MSG(idx, fmt, args...) CCCI_FILTER_MSG(TTY, "/tty", idx, fmt, ##args)
  82. #define CCCI_FS_MSG(idx, fmt, args...) CCCI_FILTER_MSG(FS, "/fs ", idx, fmt, ##args)
  83. #define CCCI_RPC_MSG(idx, fmt, args...) CCCI_FILTER_MSG(RPC, "/rpc", idx, fmt, ##args)
  84. #define CCCI_IPC_MSG(idx, fmt, args...) CCCI_FILTER_MSG(IPC, "/ipc", idx, fmt, ##args)
  85. #define CCCI_PMIC_MSG(idx, fmt, args...) CCCI_FILTER_MSG(PMIC, "/pmc", idx, fmt, ##args)
  86. #define CCCI_FUNC_ENTRY(idx) CCCI_FILTER_MSG(FUNC, "/fun", idx, "%s\n", __func__)
  87. #define CCCI_MISC_MSG(idx, fmt, args...) CCCI_FILTER_MSG(MISC, "/mis", idx, fmt, ##args)
  88. #define CCCI_CHR_MSG(idx, fmt, args...) CCCI_FILTER_MSG(CHR, "/chr", idx, fmt, ##args)
  89. #define CCCI_CCIF_MSG(idx, fmt, args...) CCCI_FILTER_MSG(CCIF, "/cci", idx, fmt, ##args)
  90. #define CCCI_CCMNI_MSG(idx, fmt, args...) CCCI_FILTER_MSG(CCMNI, "/net", idx, fmt, ##args)
  91. #endif
  92. /* ============================================================ */
  93. /* AEE function and macro define */
  94. /* ============================================================ */
  95. #define CCCI_AED_DUMP_EX_MEM (1<<0)
  96. #define CCCI_AED_DUMP_MD_IMG_MEM (1<<1)
  97. #define CCCI_AED_DUMP_CCIF_REG (1<<2)
  98. void ccci_aed(int, unsigned int, char *);
  99. /* ============================================================ */
  100. /* ccci related macro and structure define */
  101. /* ============================================================ */
  102. #define CAN_BE_RELOAD (0x1<<1)
  103. #define LOAD_ONE_TIME (0x1<<0)
  104. #define LOAD_ALL_IMG (LOAD_ONE_TIME|CAN_BE_RELOAD)
  105. #define RELOAD_ONLY (CAN_BE_RELOAD)
  106. #define CCCI_LOG_TX 0
  107. #define CCCI_LOG_RX 1
  108. #define DBG_FLAG_DEBUG (1<<0)
  109. #define DBG_FLAG_JTAG (1<<1)
  110. enum {
  111. MD_DEBUG_REL_INFO_NOT_READY = 0,
  112. MD_IS_DEBUG_VERSION,
  113. MD_IS_RELEASE_VERSION
  114. };
  115. enum ccif_type_t {
  116. CCIF_STD_V1 = 0, /* 16 channel ccif, tx 8, rx 8 */
  117. CCIF_VIR, /* Virtual CCIF type */
  118. };
  119. struct ccif_hw_info_t {
  120. unsigned long reg_base;
  121. unsigned long md_reg_base;
  122. unsigned int irq_id;
  123. unsigned int irq_attr;
  124. enum ccif_type_t type;
  125. unsigned int md_id;
  126. };
  127. struct rpc_cfg_inf_t {
  128. int rpc_ch_num;
  129. int rpc_max_buf_size;
  130. };
  131. /* ============================================================ */
  132. /* share memory layout define */
  133. /* ============================================================ */
  134. /* share memory table */
  135. struct smem_alloc_t {
  136. /* Share memory */
  137. unsigned int ccci_smem_size;
  138. unsigned int ccci_smem_vir;
  139. unsigned int ccci_smem_phy;
  140. /* -- Log */
  141. unsigned int ccci_mdlog_smem_base_virt;
  142. unsigned int ccci_mdlog_smem_base_phy;
  143. unsigned int ccci_mdlog_smem_size;
  144. /* -- PCM */
  145. unsigned int ccci_pcm_smem_base_virt;
  146. unsigned int ccci_pcm_smem_base_phy;
  147. unsigned int ccci_pcm_smem_size;
  148. /* -- PMIC */
  149. unsigned int ccci_pmic_smem_base_virt;
  150. unsigned int ccci_pmic_smem_base_phy;
  151. unsigned int ccci_pmic_smem_size;
  152. /* -- FS */
  153. unsigned int ccci_fs_smem_base_virt;
  154. unsigned int ccci_fs_smem_base_phy;
  155. unsigned int ccci_fs_smem_size;
  156. /* -- RPC */
  157. unsigned int ccci_rpc_smem_base_virt;
  158. unsigned int ccci_rpc_smem_base_phy;
  159. unsigned int ccci_rpc_smem_size;
  160. /* -- TTY */
  161. unsigned int ccci_uart_smem_base_virt[CCCI_UART_PORT_NUM];
  162. unsigned int ccci_uart_smem_base_phy[CCCI_UART_PORT_NUM];
  163. unsigned int ccci_uart_smem_size[CCCI_UART_PORT_NUM];
  164. /* -- Exception */
  165. unsigned int ccci_exp_smem_base_virt;
  166. unsigned int ccci_exp_smem_base_phy;
  167. unsigned int ccci_exp_smem_size;
  168. /* -- IPC */
  169. unsigned int ccci_ipc_smem_base_virt;
  170. unsigned int ccci_ipc_smem_base_phy;
  171. unsigned int ccci_ipc_smem_size;
  172. /* -- SYS - Eint exchagne */
  173. unsigned int ccci_sys_smem_base_virt;
  174. unsigned int ccci_sys_smem_base_phy;
  175. unsigned int ccci_sys_smem_size;
  176. /* -- CCMNI new version */
  177. /* ----- Up-link */
  178. unsigned int ccci_ccmni_smem_ul_base_virt;
  179. unsigned int ccci_ccmni_smem_ul_base_phy;
  180. unsigned int ccci_ccmni_smem_ul_size;
  181. /* ----- Donw-link */
  182. unsigned int ccci_ccmni_smem_dl_base_virt;
  183. unsigned int ccci_ccmni_smem_dl_base_phy;
  184. unsigned int ccci_ccmni_smem_dl_size;
  185. unsigned int ccci_ccmni_ctl_smem_base_virt[NET_PORT_NUM];
  186. unsigned int ccci_ccmni_ctl_smem_base_phy[NET_PORT_NUM];
  187. unsigned int ccci_ccmni_ctl_smem_size[NET_PORT_NUM];
  188. /* -- EXT MD Exception */
  189. unsigned int ccci_md_ex_exp_info_smem_base_virt;
  190. unsigned int ccci_md_ex_exp_info_smem_base_phy;
  191. unsigned int ccci_md_ex_exp_info_smem_size;
  192. /* -- MD Runtime Data */
  193. unsigned int ccci_md_runtime_data_smem_base_virt;
  194. unsigned int ccci_md_runtime_data_smem_base_phy;
  195. unsigned int ccci_md_runtime_data_smem_size;
  196. /* -- Misc Info Data */
  197. unsigned int ccci_misc_info_base_virt;
  198. unsigned int ccci_misc_info_base_phy;
  199. unsigned int ccci_misc_info_size;
  200. };
  201. /* Memory layout table */
  202. struct ccci_mem_layout_t {
  203. /* MD image */
  204. unsigned int md_region_vir;
  205. unsigned int md_region_phy;
  206. unsigned int md_region_size;
  207. /* DSP image */
  208. unsigned int dsp_region_vir;
  209. unsigned int dsp_region_phy;
  210. unsigned int dsp_region_size;
  211. /* Share memory */
  212. unsigned int smem_region_vir;
  213. unsigned int smem_region_phy;
  214. unsigned int smem_region_size;
  215. unsigned int smem_region_phy_before_map;
  216. };
  217. /* Misc info structure */
  218. struct misc_info_t {
  219. unsigned int prefix; /* "CCIF" */
  220. unsigned int support_mask;
  221. unsigned int index;
  222. unsigned int next;
  223. unsigned int feature_0_val[4];
  224. unsigned int feature_1_val[4];
  225. unsigned int feature_2_val[4];
  226. unsigned int feature_3_val[4];
  227. unsigned int feature_4_val[4];
  228. unsigned int feature_5_val[4];
  229. unsigned int feature_6_val[4];
  230. unsigned int feature_7_val[4];
  231. unsigned int feature_8_val[4];
  232. unsigned int feature_9_val[4];
  233. unsigned int feature_10_val[4];
  234. unsigned int feature_11_val[4];
  235. unsigned int feature_12_val[4];
  236. unsigned int feature_13_val[4];
  237. unsigned int feature_14_val[4];
  238. unsigned int feature_15_val[4];
  239. unsigned int reserved_2[3];
  240. unsigned int postfix; /* "CCIF" */
  241. };
  242. enum misc_feature_sta_t {
  243. FEATURE_NOT_EXIST = 0,
  244. FEATURE_NOT_SUPPORT,
  245. FEATURE_SUPPORT,
  246. FEATURE_PARTIALLY_SUPPORT,
  247. };
  248. enum misc_feature_id_t {
  249. MISC_DMA_ADDR = 0,
  250. MISC_32K_LESS,
  251. MISC_RAND_SEED,
  252. MISC_MD_COCLK_SETTING,
  253. MISC_MD_SBP_SETTING,
  254. };
  255. /* ========================================================== */
  256. /* API need implemented by ccci platform */
  257. /* ========================================================== */
  258. int get_dev_major_for_md_sys(int md_id);
  259. int get_ccif_hw_info(int md_id, struct ccif_hw_info_t *ccif_hw_info);
  260. void md_env_setup_before_boot(int md_id);
  261. void md_env_setup_before_ready(int md_id);
  262. void md_boot_up_additional_operation(int md_id);
  263. void md_boot_ready_additional_operation(int md_id);
  264. void additional_operation_before_stop_md(int md_id);
  265. struct smem_alloc_t *get_md_smem_layout(int md_id);
  266. unsigned int get_md_sys_max_num(void);
  267. void ccci_md_wdt_notify_register(int, int (*funcp) (int));
  268. int ccci_load_firmware(int md_id, unsigned int load_flag, char img_err_str[],
  269. int len);
  270. int ccci_power_on_md(int md_id);
  271. int ccci_power_down_md(int md_id);
  272. int let_md_stop(int md_id, unsigned int timeout);
  273. int let_md_go(int md_id);
  274. int ccci_get_sub_module_cfg(int md_id, char name[], char out_buf[], int size);
  275. int ccci_alloc_smem(int md_id);
  276. void ccci_free_smem(int md_id);
  277. struct ccci_mem_layout_t *get_md_sys_layout(int md_id);
  278. int is_modem_debug_ver(int md_id);
  279. char *get_md_info_str(int md_id);
  280. void platform_set_runtime_data(int md_id, struct modem_runtime_t *runtime);
  281. void config_misc_info(int md_id, unsigned int base[], unsigned int size);
  282. void send_battery_info(int md_id);
  283. #ifdef CONFIG_MTK_ICUSB_SUPPORT
  284. void send_icusb_notify(int md_id, unsigned int sim_id);
  285. #endif
  286. void md_fast_dormancy(int md_id);
  287. void start_md_wdt_recov_timer(int md_id);
  288. int platform_init(int md_id, int power_down);
  289. void platform_deinit(int md_id);
  290. unsigned int get_debug_mode_flag(void);
  291. int ccci_ipo_h_platform_restore(int md_id);
  292. int set_sim_type(int md_id, int data);
  293. int get_sim_type(int md_id, int *p_sim_type);
  294. int enable_get_sim_type(int md_id, unsigned int enable);
  295. void ccci_dump_md_register(int md_id);
  296. #ifdef CONFIG_MTK_MD_SBP_CUSTOM_VALUE
  297. int ccci_set_md_sbp(int md_id, unsigned int md_sbp);
  298. #endif /* CONFIG_MTK_MD_SBP_CUSTOM_VALUE */
  299. /* Generally, AP and MD has same share memory address after hw remapp.
  300. * however, if hardware remapp does not work, then need software remap,
  301. *This variable is used to fix md phy addr does not equeal with AP.
  302. * If hardware remap works, then the variable is 0.
  303. */
  304. int get_md2_ap_phy_addr_fixed(void);
  305. #ifdef ENABLE_GPS_MD_COCLK
  306. extern unsigned int wmt_get_coclock_setting_for_ccci(void);
  307. #endif
  308. /* ============================================================= */
  309. /* CCCI API cannot be directly called by platform, */
  310. /* since ccci.ko is loaded after ccci_platform.ko, */
  311. /* so there is no API exported to platform. */
  312. /* ============================================================= */
  313. #endif /* __CCCI_COMMON_H__ */