ccci_util_lib_fo.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. #include <linux/module.h>
  2. #include <linux/device.h>
  3. #include <linux/fs.h>
  4. #include <linux/cdev.h>
  5. #include <linux/interrupt.h>
  6. #include <linux/spinlock.h>
  7. #include <linux/uaccess.h>
  8. #include <linux/mm.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 <linux/seq_file.h>
  16. #include <linux/memblock.h>
  17. #ifdef CONFIG_OF
  18. #include <linux/of.h>
  19. #include <linux/of_fdt.h>
  20. #endif
  21. #ifdef CONFIG_OF_RESERVED_MEM
  22. #include <linux/of_reserved_mem.h>
  23. #endif
  24. #include <asm/setup.h>
  25. #include <linux/atomic.h>
  26. #include <mt-plat/mt_boot_common.h>
  27. #include <mt-plat/mt_ccci_common.h>
  28. #include "ccci_util_log.h"
  29. #define CCCI_MEM_ALIGN (SZ_32M)
  30. #define CCCI_SMEM_ALIGN_MD1 (0x200000) /*2M */
  31. #define CCCI_SMEM_ALIGN_MD2 (0x200000) /*2M */
  32. /*====================================================== */
  33. /* DFO support section */
  34. /*====================================================== */
  35. typedef struct fos_item { /* Feature Option Setting */
  36. char *name;
  37. volatile int value;
  38. } fos_item_t;
  39. /* DFO table */
  40. /* TODO : the following macro can be removed sometime */
  41. /* MD1 */
  42. #ifdef CONFIG_MTK_ENABLE_MD1
  43. #define MTK_MD1_EN (1)
  44. #else
  45. #define MTK_MD1_EN (0)
  46. #endif
  47. #ifdef CONFIG_MTK_MD1_SUPPORT
  48. #define MTK_MD1_SUPPORT (CONFIG_MTK_MD1_SUPPORT)
  49. #else
  50. #define MTK_MD1_SUPPORT (5)
  51. #endif
  52. /* MD2 */
  53. #ifdef CONFIG_MTK_ENABLE_MD2
  54. #define MTK_MD2_EN (1)
  55. #else
  56. #define MTK_MD2_EN (0)
  57. #endif
  58. #ifdef CONFIG_MTK_MD2_SUPPORT
  59. #define MTK_MD2_SUPPORT (CONFIG_MTK_MD2_SUPPORT)
  60. #else
  61. #define MTK_MD2_SUPPORT (1)
  62. #endif
  63. /* MD3 */
  64. #ifdef CONFIG_MTK_ECCCI_C2K
  65. #define MTK_MD3_EN (1)
  66. #else
  67. #define MTK_MD3_EN (0)
  68. #endif
  69. #ifdef CONFIG_MTK_MD3_SUPPORT
  70. #define MTK_MD3_SUPPORT (CONFIG_MTK_MD3_SUPPORT)
  71. #else
  72. #define MTK_MD3_SUPPORT (2)
  73. #endif
  74. /* MD5 */
  75. #ifdef CONFIG_MTK_ENABLE_MD5
  76. #define MTK_MD5_EN (1)
  77. #else
  78. #define MTK_MD5_EN (0)
  79. #endif
  80. #ifdef CONFIG_MTK_MD5_SUPPORT
  81. #define MTK_MD5_SUPPORT (CONFIG_MTK_MD5_SUPPORT)
  82. #else
  83. #define MTK_MD5_SUPPORT (3)
  84. #endif
  85. /*#define FEATURE_DFO_EN */
  86. static fos_item_t ccci_fos_default_setting[] = {
  87. {"MTK_ENABLE_MD1", MTK_MD1_EN},
  88. {"MTK_MD1_SUPPORT", MTK_MD1_SUPPORT},
  89. {"MTK_ENABLE_MD2", MTK_MD2_EN},
  90. {"MTK_MD2_SUPPORT", MTK_MD2_SUPPORT},
  91. {"MTK_ENABLE_MD3", MTK_MD3_EN},
  92. {"MTK_MD3_SUPPORT", MTK_MD3_SUPPORT},
  93. {"MTK_ENABLE_MD5", MTK_MD5_EN},
  94. {"MTK_MD5_SUPPORT", MTK_MD5_SUPPORT},
  95. };
  96. /* Tag value from LK */
  97. static unsigned char md_info_tag_val[4];
  98. static unsigned int md_support[MAX_MD_NUM];
  99. static unsigned int meta_md_support[MAX_MD_NUM];
  100. int ccci_get_fo_setting(char item[], unsigned int *val)
  101. {
  102. char *ccci_name;
  103. int ccci_value;
  104. int i;
  105. for (i = 0; i < ARRAY_SIZE(ccci_fos_default_setting); i++) {
  106. ccci_name = ccci_fos_default_setting[i].name;
  107. ccci_value = ccci_fos_default_setting[i].value;
  108. if (!strcmp(ccci_name, item)) {
  109. CCCI_UTIL_ERR_MSG("FO:%s -> %08x\n", item, ccci_value);
  110. *val = (unsigned int)ccci_value;
  111. return 0;
  112. }
  113. }
  114. CCCI_UTIL_ERR_MSG("FO:%s not found\n", item);
  115. return -CCCI_ERR_INVALID_PARAM;
  116. }
  117. /*--- LK tag and device tree ----- */
  118. static unsigned long dt_chosen_node;
  119. static int __init early_init_dt_get_chosen(unsigned long node, const char *uname, int depth, void *data)
  120. {
  121. if (depth != 1 || (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0))
  122. return 0;
  123. dt_chosen_node = node;
  124. return 1;
  125. }
  126. static void lk_meta_tag_info_collect(void)
  127. {
  128. /* Device tree method */
  129. char *tags;
  130. int ret;
  131. ret = of_scan_flat_dt(early_init_dt_get_chosen, NULL);
  132. if (ret == 0) {
  133. CCCI_UTIL_INF_MSG("device node no chosen node\n");
  134. return;
  135. }
  136. tags = (char *)of_get_flat_dt_prop(dt_chosen_node, "atag,mdinfo", NULL);
  137. if (tags) {
  138. tags += 8; /* Fix me, Arm64 doesn't have atag defination now */
  139. md_info_tag_val[0] = tags[0];
  140. md_info_tag_val[1] = tags[1];
  141. md_info_tag_val[2] = tags[2];
  142. md_info_tag_val[3] = tags[3];
  143. CCCI_UTIL_INF_MSG("Get MD info Tags\n");
  144. CCCI_UTIL_INF_MSG("md_inf[0]=%d\n", md_info_tag_val[0]);
  145. CCCI_UTIL_INF_MSG("md_inf[1]=%d\n", md_info_tag_val[1]);
  146. CCCI_UTIL_INF_MSG("md_inf[2]=%d\n", md_info_tag_val[2]);
  147. CCCI_UTIL_INF_MSG("md_inf[3]=%d\n", md_info_tag_val[3]);
  148. } else {
  149. CCCI_UTIL_INF_MSG("atag,mdinfo=NULL\n");
  150. }
  151. }
  152. /*--- META arguments parse ------- */
  153. static int ccci_parse_meta_md_setting(unsigned char args[])
  154. {
  155. unsigned char md_active_setting = args[1];
  156. unsigned char md_setting_flag = args[0];
  157. int active_id = -1;
  158. if (md_active_setting & MD1_EN)
  159. active_id = MD_SYS1;
  160. else if (md_active_setting & MD2_EN)
  161. active_id = MD_SYS2;
  162. else if (md_active_setting & MD3_EN)
  163. active_id = MD_SYS3;
  164. else if (md_active_setting & MD5_EN)
  165. active_id = MD_SYS5;
  166. else
  167. CCCI_UTIL_ERR_MSG("META MD setting not found [%d][%d]\n", args[0], args[1]);
  168. switch (active_id) {
  169. case MD_SYS1:
  170. case MD_SYS2:
  171. case MD_SYS3:
  172. case MD_SYS5:
  173. if (md_setting_flag == MD_2G_FLAG)
  174. meta_md_support[active_id] = modem_2g;
  175. else if (md_setting_flag == MD_WG_FLAG)
  176. meta_md_support[active_id] = modem_wg;
  177. else if (md_setting_flag == MD_TG_FLAG)
  178. meta_md_support[active_id] = modem_tg;
  179. else if (md_setting_flag == MD_LWG_FLAG)
  180. meta_md_support[active_id] = modem_lwg;
  181. else if (md_setting_flag == MD_LTG_FLAG)
  182. meta_md_support[active_id] = modem_ltg;
  183. else if (md_setting_flag & MD_SGLTE_FLAG)
  184. meta_md_support[active_id] = modem_sglte;
  185. CCCI_UTIL_INF_MSG("META MD%d to type:%d\n", active_id + 1, meta_md_support[active_id]);
  186. break;
  187. }
  188. return 0;
  189. }
  190. int get_modem_support_cap(int md_id)
  191. {
  192. if (md_id < MAX_MD_NUM) {
  193. if (((get_boot_mode() == META_BOOT) || (get_boot_mode() == ADVMETA_BOOT))
  194. && (meta_md_support[md_id] != 0))
  195. return meta_md_support[md_id];
  196. else
  197. return md_support[md_id];
  198. }
  199. return -1;
  200. }
  201. int set_modem_support_cap(int md_id, int new_val)
  202. {
  203. if (md_id < MAX_MD_NUM) {
  204. if (((get_boot_mode() == META_BOOT) || (get_boot_mode() == ADVMETA_BOOT))
  205. && (meta_md_support[md_id] != 0))
  206. meta_md_support[md_id] = new_val;
  207. else
  208. md_support[md_id] = new_val;
  209. return 0;
  210. }
  211. return -1;
  212. }
  213. /*--- MD setting collect */
  214. /* modem index is not continuous, so there may be gap in this arrays */
  215. static unsigned int md_usage_case;
  216. static unsigned int md_resv_mem_size[MAX_MD_NUM]; /* MD ROM+RAM */
  217. static unsigned int md_resv_smem_size[MAX_MD_NUM]; /* share memory */
  218. static unsigned int md_resv_size_list[MAX_MD_NUM];
  219. static unsigned int resv_smem_size;
  220. static unsigned int md1md3_resv_smem_size;
  221. static phys_addr_t md_resv_mem_list[MAX_MD_NUM];
  222. static phys_addr_t md_resv_mem_addr[MAX_MD_NUM];
  223. static phys_addr_t md_resv_smem_addr[MAX_MD_NUM];
  224. static phys_addr_t resv_smem_addr;
  225. static phys_addr_t md1md3_resv_smem_addr;
  226. int get_md_resv_mem_info(int md_id, phys_addr_t *r_rw_base, unsigned int *r_rw_size, phys_addr_t *srw_base,
  227. unsigned int *srw_size)
  228. {
  229. if (md_id >= MAX_MD_NUM)
  230. return -1;
  231. if (r_rw_base != NULL)
  232. *r_rw_base = md_resv_mem_addr[md_id];
  233. if (r_rw_size != NULL)
  234. *r_rw_size = md_resv_mem_size[md_id];
  235. if (srw_base != NULL)
  236. *srw_base = md_resv_smem_addr[md_id];
  237. if (srw_size != NULL)
  238. *srw_size = md_resv_smem_size[md_id];
  239. return 0;
  240. }
  241. int get_md1_md3_resv_smem_info(int md_id, phys_addr_t *rw_base, unsigned int *rw_size)
  242. {
  243. if ((md_id != MD_SYS1) && (md_id != MD_SYS3))
  244. return -1;
  245. if (rw_base != NULL)
  246. *rw_base = md1md3_resv_smem_addr;
  247. if (rw_size != NULL)
  248. *rw_size = md1md3_resv_smem_size;
  249. return 0;
  250. }
  251. unsigned int get_md_smem_align(int md_id)
  252. {
  253. return 0x4000;
  254. }
  255. unsigned int get_modem_is_enabled(int md_id)
  256. {
  257. return !!(md_usage_case & (1 << md_id));
  258. }
  259. static void cal_md_settings(int md_id)
  260. {
  261. unsigned int tmp;
  262. unsigned int md_en = 0;
  263. char tmp_buf[30];
  264. char *node_name = NULL;
  265. struct device_node *node = NULL;
  266. snprintf(tmp_buf, sizeof(tmp_buf), "MTK_ENABLE_MD%d", (md_id + 1));
  267. /* MTK_ENABLE_MD* */
  268. if (ccci_get_fo_setting(tmp_buf, &tmp) == 0) {
  269. if (tmp > 0)
  270. md_en = 1;
  271. }
  272. if (!(md_en && (md_usage_case & (1 << md_id)))) {
  273. CCCI_UTIL_INF_MSG_WITH_ID(md_id, "md%d is disabled\n", (md_id + 1));
  274. return;
  275. }
  276. /* MTK_MD*_SUPPORT */
  277. snprintf(tmp_buf, sizeof(tmp_buf), "MTK_MD%d_SUPPORT", (md_id + 1));
  278. if (ccci_get_fo_setting(tmp_buf, &tmp) == 0)
  279. md_support[md_id] = tmp;
  280. /* MD*_SMEM_SIZE */
  281. if (md_id == MD_SYS1) {
  282. node_name = "mediatek,mdcldma";
  283. } else if (md_id == MD_SYS2) {
  284. node_name = "mediatek,ap_ccif1";
  285. } else if (md_id == MD_SYS3) {
  286. node_name = "mediatek,ap2c2k_ccif";
  287. } else {
  288. CCCI_UTIL_ERR_MSG_WITH_ID(md_id, "md%d id is not supported,need to check\n", (md_id + 1));
  289. md_usage_case &= ~(1 << md_id);
  290. return;
  291. }
  292. node = of_find_compatible_node(NULL, NULL, node_name);
  293. if (node) {
  294. of_property_read_u32(node, "mediatek,md_smem_size", &md_resv_smem_size[md_id]);
  295. } else {
  296. CCCI_UTIL_ERR_MSG_WITH_ID(md_id, "md%d smem size is not set in device tree,need to check\n",
  297. (md_id + 1));
  298. md_usage_case &= ~(1 << md_id);
  299. return;
  300. }
  301. /* MD ROM start address should be 32M align as remap hardware limitation */
  302. md_resv_mem_addr[md_id] = md_resv_mem_list[md_id];
  303. /*
  304. * for legacy CCCI: make share memory start address to be 2MB align, as share
  305. * memory size is 2MB - requested by MD MPU.
  306. * for ECCCI: ROM+RAM size will be align to 1M, and share memory is 2K,
  307. * 1M alignment is also 2K alignment.
  308. */
  309. md_resv_mem_size[md_id] = round_up(md_resv_size_list[md_id] - md_resv_smem_size[md_id],
  310. get_md_smem_align(md_id));
  311. md_resv_smem_addr[md_id] = md_resv_mem_list[md_id] + md_resv_mem_size[md_id];
  312. CCCI_UTIL_INF_MSG_WITH_ID(md_id, "md%d modem_total_size=0x%x,md_size=0x%x, smem_size=0x%x\n", (md_id + 1),
  313. md_resv_size_list[md_id], md_resv_mem_size[md_id], md_resv_smem_size[md_id]);
  314. if ((md_usage_case & (1 << md_id)) && ((md_resv_mem_addr[md_id] & (CCCI_MEM_ALIGN - 1)) != 0))
  315. CCCI_UTIL_ERR_MSG_WITH_ID(md_id, "md%d memory addr is not 32M align!!!\n", (md_id + 1));
  316. if ((md_usage_case & (1 << md_id)) && ((md_resv_smem_addr[md_id] & (CCCI_SMEM_ALIGN_MD1 - 1)) != 0))
  317. CCCI_UTIL_ERR_MSG_WITH_ID(md_id, "md%d share memory addr %pa is not 0x%x align!!\n", (md_id + 1),
  318. &md_resv_smem_addr[md_id], CCCI_SMEM_ALIGN_MD1);
  319. CCCI_UTIL_INF_MSG_WITH_ID(md_id, "MemStart: 0x%pa, MemSize:0x%08X\n", &md_resv_mem_addr[md_id],
  320. md_resv_mem_size[md_id]);
  321. CCCI_UTIL_INF_MSG_WITH_ID(md_id, "SMemStart: 0x%pa, SMemSize:0x%08X\n", &md_resv_smem_addr[md_id],
  322. md_resv_smem_size[md_id]);
  323. }
  324. static void cal_md_settings_v2(struct device_node *node)
  325. {
  326. unsigned int tmp;
  327. char tmp_buf[30];
  328. int i;
  329. /* MTK_MD*_SUPPORT */
  330. for (i = 0; i < MAX_MD_NUM; i++) {
  331. snprintf(tmp_buf, sizeof(tmp_buf), "MTK_MD%d_SUPPORT", (i + 1));
  332. if (ccci_get_fo_setting(tmp_buf, &tmp) == 0)
  333. md_support[i] = tmp;
  334. }
  335. /* MD*_SMEM_SIZE */
  336. for (i = 0; i < MAX_MD_NUM; i++) {
  337. snprintf(tmp_buf, 30, "mediatek,md%d-smem-size", i+1);
  338. if (0 == of_property_read_u32(node, tmp_buf, &tmp)) {
  339. CCCI_UTIL_INF_MSG("DT[%s]:%08X\n", tmp_buf, tmp);
  340. md_resv_smem_size[MD_SYS1+i] = tmp;
  341. } else
  342. CCCI_UTIL_INF_MSG("DT[%s]:%08X\n", tmp_buf, md_resv_smem_size[MD_SYS1+i]);
  343. }
  344. /* MD1MD3_SMEM_SIZE*/
  345. snprintf(tmp_buf, 30, "mediatek,md1md3-smem-size");
  346. if (0 == of_property_read_u32(node, tmp_buf, &tmp)) {
  347. CCCI_UTIL_INF_MSG("DT[%s]:%08X\n", tmp_buf, tmp);
  348. md1md3_resv_smem_size = tmp;
  349. } else
  350. CCCI_UTIL_INF_MSG("DT[%s]:%08X\n", tmp_buf, md1md3_resv_smem_size);
  351. /* CFG version */
  352. snprintf(tmp_buf, 30, "mediatek,version");
  353. tmp = 0;
  354. of_property_read_u32(node, tmp_buf, &tmp);
  355. CCCI_UTIL_INF_MSG("DT[%s]:%08X\n", tmp_buf, tmp);
  356. if (tmp != 1) {
  357. CCCI_UTIL_INF_MSG("Un-support version:%d\n", tmp);
  358. return;
  359. }
  360. /* MD ROM and RW part */
  361. for (i = 0; i < MAX_MD_NUM; i++) {
  362. if (md_usage_case & (1 << i)) {
  363. md_resv_mem_size[i] = md_resv_size_list[i];
  364. md_resv_mem_addr[i] = md_resv_mem_list[i];
  365. CCCI_UTIL_INF_MSG("md%d MemStart: 0x%p, MemSize:0x%08X\n", i+1, (void *)md_resv_mem_addr[i],
  366. md_resv_mem_size[i]);
  367. }
  368. }
  369. /* MD Share memory part */
  370. /* AP <--> MD1 */
  371. /* MD1 <--> MD3 */
  372. /* AP <--> MD3 */
  373. md_resv_smem_addr[MD_SYS1] = resv_smem_addr;
  374. if (md_usage_case & (1 << MD_SYS3)) {
  375. md1md3_resv_smem_addr = resv_smem_addr + md_resv_smem_size[MD_SYS1];
  376. md_resv_smem_addr[MD_SYS3] = md1md3_resv_smem_addr + md1md3_resv_smem_size;
  377. } else {
  378. md1md3_resv_smem_addr = 0;
  379. md1md3_resv_smem_size = 0;
  380. md_resv_smem_addr[MD_SYS3] = 0;
  381. md_resv_smem_size[MD_SYS3] = 0;
  382. }
  383. CCCI_UTIL_INF_MSG("AP <--> MD1 SMEM(0x%08X):%p~%p\n", md_resv_smem_size[MD_SYS1],
  384. (void *)md_resv_smem_addr[MD_SYS1],
  385. (void *)(md_resv_smem_addr[MD_SYS1]+md_resv_smem_size[MD_SYS1]-1));
  386. CCCI_UTIL_INF_MSG("MD1 <--> MD3 SMEM(0x%08X):%p~%p\n", md1md3_resv_smem_size,
  387. (void *)md1md3_resv_smem_addr,
  388. (void *)(md1md3_resv_smem_addr+md1md3_resv_smem_size-1));
  389. CCCI_UTIL_INF_MSG("AP <--> MD3 SMEM(0x%08X):%p~%p\n", md_resv_smem_size[MD_SYS3],
  390. (void *)md_resv_smem_addr[MD_SYS3],
  391. (void *)(md_resv_smem_addr[MD_SYS3]+md_resv_smem_size[MD_SYS3]-1));
  392. }
  393. void ccci_md_mem_reserve(void)
  394. {
  395. CCCI_UTIL_INF_MSG("ccci_md_mem_reserve phased out.\n");
  396. }
  397. #ifdef CONFIG_OF_RESERVED_MEM
  398. #define CCCI_MD1_MEM_RESERVED_KEY "mediatek,reserve-memory-ccci_md1"
  399. #define CCCI_MD2_MEM_RESERVED_KEY "mediatek,reserve-memory-ccci_md2"
  400. #define CCCI_MD3_MEM_RESERVED_KEY "mediatek,reserve-memory-ccci_md3_ccif"
  401. #define CCCI_MD1MD3_SMEM_RESERVED_KEY "mediatek,reserve-memory-ccci_share"
  402. #include <mt-plat/mtk_memcfg.h>
  403. int ccci_reserve_mem_of_init(struct reserved_mem *rmem)
  404. {
  405. phys_addr_t rptr = 0;
  406. unsigned int rsize = 0;
  407. int md_id = -1;
  408. rptr = rmem->base;
  409. rsize = (unsigned int)rmem->size;
  410. if (strstr(CCCI_MD1_MEM_RESERVED_KEY, rmem->name))
  411. md_id = MD_SYS1;
  412. else if (strstr(CCCI_MD2_MEM_RESERVED_KEY, rmem->name))
  413. md_id = MD_SYS2;
  414. else if (strstr(CCCI_MD3_MEM_RESERVED_KEY, rmem->name))
  415. md_id = MD_SYS3;
  416. else {
  417. if (strstr(CCCI_MD1MD3_SMEM_RESERVED_KEY, rmem->name)) {
  418. CCCI_UTIL_INF_MSG("reserve_mem_of_init, rptr=0x%pa, rsize=0x%x\n", &rptr, rsize);
  419. resv_smem_addr = rptr;
  420. resv_smem_size = rsize;
  421. } else
  422. CCCI_UTIL_INF_MSG("memory reserve key %s not support\n", rmem->name);
  423. return 0;
  424. }
  425. CCCI_UTIL_INF_MSG("reserve_mem_of_init, rptr=0x%pa, rsize=0x%x\n", &rptr, rsize);
  426. md_resv_mem_list[md_id] = rptr;
  427. md_resv_size_list[md_id] = rsize;
  428. md_usage_case |= (1 << md_id);
  429. return 0;
  430. }
  431. RESERVEDMEM_OF_DECLARE(ccci_reserve_mem_md1_init, CCCI_MD1_MEM_RESERVED_KEY, ccci_reserve_mem_of_init);
  432. RESERVEDMEM_OF_DECLARE(ccci_reserve_mem_md2_init, CCCI_MD2_MEM_RESERVED_KEY, ccci_reserve_mem_of_init);
  433. RESERVEDMEM_OF_DECLARE(ccci_reserve_mem_md3_init, CCCI_MD3_MEM_RESERVED_KEY, ccci_reserve_mem_of_init);
  434. RESERVEDMEM_OF_DECLARE(ccci_reserve_smem_md1md3_init, CCCI_MD1MD3_SMEM_RESERVED_KEY, ccci_reserve_mem_of_init);
  435. #endif
  436. int ccci_util_fo_init(void)
  437. {
  438. int idx;
  439. struct device_node *node = NULL;
  440. CCCI_UTIL_INF_MSG("ccci_util_fo_init 0.\n");
  441. node = of_find_compatible_node(NULL, NULL, "mediatek,ccci_util_cfg");
  442. if (node == NULL) {
  443. CCCI_UTIL_INF_MSG("using v1.\n");
  444. lk_meta_tag_info_collect();
  445. /* Parse META setting */
  446. ccci_parse_meta_md_setting(md_info_tag_val);
  447. /* Calculate memory layout */
  448. for (idx = 0; idx < MAX_MD_NUM; idx++)
  449. cal_md_settings(idx);
  450. } else {
  451. CCCI_UTIL_INF_MSG("using v2.\n");
  452. cal_md_settings_v2(node);
  453. }
  454. CCCI_UTIL_INF_MSG("ccci_util_fo_init 2.\n");
  455. return 0;
  456. }