platform.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082
  1. /* Copyright Statement:
  2. *
  3. * This software/firmware and related documentation ("MediaTek Software") are
  4. * protected under relevant copyright laws. The information contained herein
  5. * is confidential and proprietary to MediaTek Inc. and/or its licensors.
  6. * Without the prior written permission of MediaTek inc. and/or its licensors,
  7. * any reproduction, modification, use or disclosure of MediaTek Software,
  8. * and information contained herein, in whole or in part, shall be strictly prohibited.
  9. */
  10. /* MediaTek Inc. (C) 2015. All rights reserved.
  11. *
  12. * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  13. * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  14. * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
  15. * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  18. * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  19. * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  20. * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
  21. * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
  22. * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
  23. * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
  24. * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
  25. * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
  26. * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  27. * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  28. * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
  29. * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
  30. */
  31. #include <debug.h>
  32. #include <stdlib.h>
  33. #include <string.h>
  34. #include <video.h>
  35. #include <dev/uart.h>
  36. #include <arch/arm.h>
  37. #include <arch/arm/mmu.h>
  38. #include <arch/ops.h>
  39. #include <target/board.h>
  40. #include <platform/mt_reg_base.h>
  41. #include <platform/mt_disp_drv.h>
  42. #include <platform/disp_drv.h>
  43. #include <platform/boot_mode.h>
  44. #include <platform/mt_logo.h>
  45. #include <platform/partition.h>
  46. #include <env.h>
  47. #include <platform/mt_gpio.h>
  48. #include <platform/mt_pmic.h>
  49. #include <platform/mt_pmic_wrap_init.h>
  50. #include <platform/mt_i2c.h>
  51. #include <platform/mtk_key.h>
  52. #include <platform/mt_rtc.h>
  53. #include <platform/mt_leds.h>
  54. #include <platform/upmu_common.h>
  55. #ifdef CFG_MTK_WDT_COMMON
  56. #include <mtk_wdt.h>
  57. #else
  58. #include <platform/mtk_wdt.h>
  59. #endif
  60. #include <platform/disp_drv_platform.h>
  61. #include <platform/sec_devinfo.h> // for internal_get_devinfo_with_index()
  62. #include <plinfo.h> // for plinfo_get_brom_header_block_size()
  63. #include <libfdt.h>
  64. #include <mt_gic.h> // for platform_init_interrupts()
  65. #include <mt_boot.h> // for bldr_load_dtb()
  66. #include <platform.h> // for platform_uninit()
  67. #include <mtk_smi.h> // for smi_apply_register_setting()
  68. #include <platform/verified_boot.h> // for seclib_set_oemkey(), sec_logo_check()
  69. #include <mtk_dcm.h> // for mt_dcm_init()
  70. #include <plat_debug_interface.h> // for mt_secure_call()
  71. #include <dev/aee_platform_debug.h> // for platform_lastpc_postinit()
  72. #include <profiling.h>
  73. #include <pal_assert.h>
  74. #include <sec_export.h>
  75. #include "load_vfy_boot.h"
  76. #include <fdt_op.h>
  77. #include <verified_boot_common.h>
  78. #include <fpga_boot_argument.h>
  79. #include <platform/mtk_charger_intf.h>
  80. #include <platform/mt_pmic_dlpt.h>
  81. #include <platform/mt_gpt.h> // for get_timer()
  82. #include <show_animation_common.h>
  83. #include "mtk_secure_api.h"
  84. #include "memory_layout.h"
  85. #include <rsc.h>
  86. #ifdef MTK_EMMC_SUPPORT
  87. #include "mmc_rpmb.h"
  88. #endif
  89. #define DEVAPC_TURN_ON 1
  90. #ifdef MTK_AB_OTA_UPDATER
  91. #include "bootctrl.h"
  92. #endif
  93. #if defined(MTK_SECURITY_SW_SUPPORT)
  94. #include "oemkey.h"
  95. #endif
  96. #ifdef MTK_UFS_SUPPORT
  97. #include "ufs_aio_interface.h"
  98. #endif
  99. #ifdef MTK_CHARGER_NEW_ARCH
  100. #include <mtk_charger.h>
  101. #include <mtk_battery.h>
  102. #endif
  103. #ifdef MTK_SECURITY_SW_SUPPORT
  104. extern u8 g_oemkey[OEM_PUBK_SZ];
  105. #endif
  106. #ifdef LK_DL_CHECK
  107. /*block if check dl fail*/
  108. #undef LK_DL_CHECK_BLOCK_LEVEL
  109. #endif
  110. extern void platform_early_init_timer();
  111. extern void jump_da(u32 addr, u32 arg1, u32 arg2);
  112. extern int i2c_hw_init(void);
  113. extern int mboot_common_load_logo(unsigned long logo_addr, char* filename);
  114. extern int sec_func_init(u64 pl_start_addr);
  115. extern int sec_usbdl_enabled (void);
  116. extern void mtk_wdt_disable(void);
  117. extern void platform_deinit_interrupts(void);
  118. extern int mmc_get_dl_info(void);
  119. extern int mmc_legacy_init(int);
  120. extern void platform_clear_cache_retention_select(void);
  121. extern unsigned int crypto_hw_engine_disable(void);
  122. #ifdef MTK_AEE_PLATFORM_DEBUG_SUPPORT
  123. extern void latch_lastbus_init(void);
  124. #endif
  125. #ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
  126. extern kal_bool is_low_battery(kal_int32 val);
  127. extern int hw_charging_get_charger_type(void);
  128. #endif
  129. void config_shared_SRAM_size(void);
  130. extern int dev_info_nr_cpu(void);
  131. extern void mt_pll_turn_off(void);
  132. extern void mt_pll_clk_bootargs(void);
  133. struct mmu_initial_mapping mmu_initial_mappings[] = {
  134. {
  135. .phys = (uint64_t)0,
  136. .virt = (uint32_t)0,
  137. .size = 0x40000000,
  138. .flags = MMU_MEMORY_TYPE_STRONGLY_ORDERED | MMU_MEMORY_AP_P_RW_U_NA,
  139. .name = "mcusys"
  140. },
  141. {
  142. .phys = (uint64_t)MEMBASE,
  143. .virt = (uint32_t)MEMBASE,
  144. .size = ROUNDUP(MEMSIZE, SECTION_SIZE),
  145. .flags = MMU_MEMORY_TYPE_NORMAL_WRITE_BACK | MMU_MEMORY_AP_P_RW_U_NA,
  146. .name = "ram"
  147. },
  148. {
  149. .phys = (uint64_t)SCRATCH_ADDR,
  150. .virt = (uint32_t)SCRATCH_ADDR,
  151. .size = SCRATCH_SIZE,
  152. .flags = MMU_MEMORY_TYPE_NORMAL_WRITE_BACK | MMU_MEMORY_AP_P_RW_U_NA,
  153. .name = "download"
  154. },
  155. /* null entry to terminate the list */
  156. { 0 }
  157. };
  158. BOOT_ARGUMENT *g_boot_arg;
  159. BOOT_ARGUMENT boot_addr;
  160. int g_nr_bank;
  161. BI_DRAM bi_dram[MAX_NR_BANK];
  162. unsigned int g_fb_base;
  163. unsigned int g_fb_size;
  164. #if (MTK_DUAL_DISPLAY_SUPPORT == 2)
  165. unsigned int g_ext_fb_base;
  166. unsigned int g_ext_fb_size;
  167. #endif
  168. static int g_dram_init_ret;
  169. static unsigned int bootarg_addr;
  170. static unsigned int bootarg_size;
  171. extern unsigned int logo_lk_t;
  172. extern unsigned int boot_time;
  173. int dram_init(void)
  174. {
  175. unsigned int i;
  176. struct boot_tag *tags;
  177. /* Get parameters from pre-loader. Get as early as possible
  178. * The address of BOOT_ARGUMENT_LOCATION will be used by Linux later
  179. * So copy the parameters from BOOT_ARGUMENT_LOCATION to LK's memory region
  180. */
  181. g_boot_arg = &boot_addr;
  182. bootarg_addr = (unsigned int)((unsigned int *)BOOT_ARGUMENT_LOCATION);
  183. bootarg_size = 0;
  184. fpga_set_boot_argument((BOOT_ARGUMENT*)bootarg_addr);
  185. if (*(unsigned int *)BOOT_ARGUMENT_LOCATION == BOOT_ARGUMENT_MAGIC) {
  186. memcpy(g_boot_arg, (void*)BOOT_ARGUMENT_LOCATION, sizeof(BOOT_ARGUMENT));
  187. bootarg_size = sizeof(BOOT_ARGUMENT);
  188. } else {
  189. g_boot_arg->maggic_number = BOOT_ARGUMENT_MAGIC;
  190. for (tags = (void *)BOOT_ARGUMENT_LOCATION; tags->hdr.size; tags = boot_tag_next(tags)) {
  191. switch (tags->hdr.tag) {
  192. case BOOT_TAG_BOOT_REASON:
  193. g_boot_arg->boot_reason = tags->u.boot_reason.boot_reason;
  194. break;
  195. case BOOT_TAG_BOOT_MODE:
  196. g_boot_arg->boot_mode = tags->u.boot_mode.boot_mode;
  197. break;
  198. case BOOT_TAG_META_COM:
  199. g_boot_arg->meta_com_type = tags->u.meta_com.meta_com_type;
  200. g_boot_arg->meta_com_id = tags->u.meta_com.meta_com_id;
  201. g_boot_arg->meta_uart_port = tags->u.meta_com.meta_uart_port;
  202. g_boot_arg->meta_log_disable = tags->u.meta_com.meta_log_disable;
  203. g_boot_arg->fast_meta_gpio = tags->u.meta_com.fast_meta_gpio;
  204. break;
  205. case BOOT_TAG_LOG_COM:
  206. g_boot_arg->log_port = tags->u.log_com.log_port;
  207. g_boot_arg->log_baudrate = tags->u.log_com.log_baudrate;
  208. g_boot_arg->log_enable = tags->u.log_com.log_enable;
  209. g_boot_arg->log_dynamic_switch = tags->u.log_com.log_dynamic_switch;
  210. break;
  211. case BOOT_TAG_MEM:
  212. g_boot_arg->dram_rank_num = tags->u.mem.dram_rank_num;
  213. for (i = 0; i < tags->u.mem.dram_rank_num; i++) {
  214. g_boot_arg->dram_rank_size[i] = tags->u.mem.dram_rank_size[i];
  215. }
  216. g_boot_arg->mblock_info = tags->u.mem.mblock_info;
  217. g_boot_arg->orig_dram_info = tags->u.mem.orig_dram_info;
  218. g_boot_arg->lca_reserved_mem = tags->u.mem.lca_reserved_mem;
  219. g_boot_arg->tee_reserved_mem = tags->u.mem.tee_reserved_mem;
  220. break;
  221. case BOOT_TAG_MD_INFO:
  222. for (i = 0; i < 4; i++) {
  223. g_boot_arg->md_type[i] = tags->u.md_info.md_type[i];
  224. }
  225. break;
  226. case BOOT_TAG_BOOT_TIME:
  227. g_boot_arg->boot_time = tags->u.boot_time.boot_time;
  228. break;
  229. case BOOT_TAG_DA_INFO:
  230. memcpy(&g_boot_arg->da_info, &tags->u.da_info.da_info, sizeof(da_info_t));
  231. break;
  232. case BOOT_TAG_SEC_INFO:
  233. memcpy(&g_boot_arg->sec_limit, &tags->u.sec_info.sec_limit, sizeof(SEC_LIMIT));
  234. break;
  235. case BOOT_TAG_PART_NUM:
  236. g_boot_arg->part_num = tags->u.part_num.part_num;
  237. break;
  238. case BOOT_TAG_PART_INFO:
  239. g_boot_arg->part_info = tags->u.part_info.part_info; /* only copy the pointer but the contains*/
  240. break;
  241. case BOOT_TAG_EFLAG:
  242. g_boot_arg->e_flag = tags->u.eflag.e_flag;
  243. break;
  244. case BOOT_TAG_DDR_RESERVE:
  245. g_boot_arg->ddr_reserve_enable = tags->u.ddr_reserve.ddr_reserve_enable;
  246. g_boot_arg->ddr_reserve_success = tags->u.ddr_reserve.ddr_reserve_success;
  247. g_boot_arg->ddr_reserve_ready = tags->u.ddr_reserve.ddr_reserve_ready;
  248. break;
  249. case BOOT_TAG_DRAM_BUF:
  250. g_boot_arg->dram_buf_size = tags->u.dram_buf.dram_buf_size;
  251. break;
  252. case BOOT_TAG_SRAM_INFO:
  253. g_boot_arg->non_secure_sram_addr = tags->u.sram_info.non_secure_sram_addr;
  254. g_boot_arg->non_secure_sram_size = tags->u.sram_info.non_secure_sram_size;
  255. break;
  256. case BOOT_TAG_PLAT_DBG_INFO:
  257. g_boot_arg->plat_dbg_info_max = tags->u.plat_dbg_info.info_max;
  258. for (i = 0; (i < INFO_TYPE_MAX) && (i < g_boot_arg->plat_dbg_info_max); i++) {
  259. g_boot_arg->plat_dbg_info[i].key = tags->u.plat_dbg_info.info[i].key;
  260. g_boot_arg->plat_dbg_info[i].base = tags->u.plat_dbg_info.info[i].base;
  261. g_boot_arg->plat_dbg_info[i].size = tags->u.plat_dbg_info.info[i].size;
  262. }
  263. break;
  264. case BOOT_TAG_PTP:
  265. memcpy(&g_boot_arg->ptp_volt_info, &tags->u.ptp_volt.ptp_volt_info, sizeof(ptp_info_t));
  266. break;
  267. case BOOT_TAG_EMI_INFO:
  268. memcpy(&(g_boot_arg->emi_info), &(tags->u.emi_info), sizeof(emi_info_t));
  269. break;
  270. case BOOT_TAG_IMGVER_INFO:
  271. g_boot_arg->pl_imgver_status = tags->u.imgver_info.pl_imgver_status;
  272. break;
  273. case BOOT_TAG_MAX_CPUS:
  274. g_boot_arg->max_cpus = tags->u.max_cpus.max_cpus;
  275. break;
  276. case BOOT_TAG_CHR_INFO:
  277. g_boot_arg->charger_type = tags->u.chr_info.charger_type;
  278. break;
  279. case BOOT_TAG_RAM_CONSOLE_INFO:
  280. g_boot_arg->ram_console_sram_addr = tags->u.ram_console_info.sram_addr;
  281. g_boot_arg->ram_console_sram_size = tags->u.ram_console_info.sram_size;
  282. g_boot_arg->ram_console_def_type = tags->u.ram_console_info.def_type;
  283. g_boot_arg->ram_console_memory_info_offset = tags->u.ram_console_info.memory_info_offset;
  284. break;
  285. case BOOT_TAG_SOC_ID:
  286. memcpy(g_boot_arg->socid, tags->u.socid.id, SOC_ID_LEN);
  287. break;
  288. default:
  289. break;
  290. }
  291. bootarg_size += tags->hdr.size;
  292. }
  293. }
  294. fpga_copy_boot_argument(g_boot_arg);
  295. g_nr_bank = g_boot_arg->dram_rank_num;
  296. if (g_nr_bank == 0 || g_nr_bank > MAX_NR_BANK) {
  297. g_dram_init_ret = -1;
  298. //dprintf(CRITICAL, "[LK ERROR] DRAM bank number is not correct!!!");
  299. //while (1) ;
  300. return -1;
  301. }
  302. #ifndef CUSTOM_CONFIG_MAX_DRAM_SIZE
  303. /* return the actual DRAM info */
  304. for (i = 0; i < (unsigned int)(g_boot_arg->mblock_info.mblock_num); i++) {
  305. bi_dram[i].start = g_boot_arg->mblock_info.mblock[i].start;
  306. bi_dram[i].size = g_boot_arg->mblock_info.mblock[i].size;
  307. }
  308. //#elif (CUSTOM_CONFIG_MAX_DRAM_SIZE < 0x10000000)
  309. //#error "DRAM size < 0x10000000" /* DRAM is less than 256MB, trigger build error */
  310. #else
  311. #endif
  312. return 0;
  313. }
  314. unsigned int platform_get_bootarg_addr(void)
  315. {
  316. return bootarg_addr;
  317. }
  318. unsigned int platform_get_bootarg_size(void)
  319. {
  320. return bootarg_size;
  321. }
  322. /*******************************************************
  323. * Routine: memory_size
  324. * Description: return DRAM size to LCM driver
  325. ******************************************************/
  326. u32 ddr_enable_4gb(void)
  327. {
  328. u32 status;
  329. #define INFRA_MISC (INFRACFG_AO_BASE + 0x0F00)
  330. #define INFRA_4GB_EN (1 << 13)
  331. #define PERI_MISC (PERICFG_BASE + 0x0208)
  332. #define PERI_4GB_EN (1 << 15)
  333. status = ((DRV_Reg32(INFRA_MISC) & INFRA_4GB_EN) && (DRV_Reg32(PERI_MISC) & PERI_4GB_EN)) ? 1 : 0;
  334. dprintf(CRITICAL, "%s() status=%u\n", __func__, status);
  335. return status;
  336. }
  337. u64 physical_memory_size(void)
  338. {
  339. int i;
  340. unsigned long long size = 0;
  341. for (i = 0; i < (int)(g_boot_arg->orig_dram_info.rank_num); i++) {
  342. size += g_boot_arg->orig_dram_info.rank_info[i].size;
  343. }
  344. return size;
  345. }
  346. u32 memory_size(void)
  347. {
  348. unsigned long long size = physical_memory_size();
  349. while (((unsigned long long)DRAM_PHY_ADDR + size) > 0x100000000ULL) {
  350. size -= (unsigned long long)(1024*1024*1024);
  351. }
  352. return (unsigned int)size;
  353. }
  354. void sw_env()
  355. {
  356. #ifdef LK_DL_CHECK
  357. #if defined(MTK_EMMC_SUPPORT) || defined(MTK_UFS_SUPPORT)
  358. int dl_status = 0;
  359. dl_status = mmc_get_dl_info();
  360. dprintf(INFO, "mt65xx_sw_env--dl_status: %d\n", dl_status);
  361. if (dl_status != 0) {
  362. video_printf("=> TOOL DL image Fail!\n");
  363. dprintf(CRITICAL, "TOOL DL image Fail\n");
  364. #ifdef LK_DL_CHECK_BLOCK_LEVEL
  365. dprintf(CRITICAL, "uboot is blocking by dl info\n");
  366. while (1) ;
  367. #endif
  368. }
  369. #endif
  370. #endif
  371. #ifndef MACH_FPGA_NO_DISPLAY
  372. #ifndef USER_BUILD
  373. switch (g_boot_mode) {
  374. case META_BOOT:
  375. video_printf(" => META MODE\n");
  376. break;
  377. case FACTORY_BOOT:
  378. video_printf(" => FACTORY MODE\n");
  379. break;
  380. case RECOVERY_BOOT:
  381. video_printf(" => RECOVERY MODE\n");
  382. break;
  383. case SW_REBOOT:
  384. //video_printf(" => SW RESET\n");
  385. break;
  386. case NORMAL_BOOT:
  387. //if(g_boot_arg->boot_reason != BR_RTC && get_env("hibboot") != NULL && atoi(get_env("hibboot")) == 1)
  388. if (get_env("hibboot") != NULL && atoi(get_env("hibboot")) == 1)
  389. video_printf(" => HIBERNATION BOOT\n");
  390. else
  391. video_printf(" => NORMAL BOOT\n");
  392. break;
  393. case ADVMETA_BOOT:
  394. video_printf(" => ADVANCED META MODE\n");
  395. break;
  396. case ATE_FACTORY_BOOT:
  397. video_printf(" => ATE FACTORY MODE\n");
  398. break;
  399. #ifdef MTK_KERNEL_POWER_OFF_CHARGING
  400. case KERNEL_POWER_OFF_CHARGING_BOOT:
  401. video_printf(" => POWER OFF CHARGING MODE\n");
  402. break;
  403. case LOW_POWER_OFF_CHARGING_BOOT:
  404. video_printf(" => LOW POWER OFF CHARGING MODE\n");
  405. break;
  406. #endif
  407. case ALARM_BOOT:
  408. video_printf(" => ALARM BOOT\n");
  409. break;
  410. case FASTBOOT:
  411. video_printf(" => FASTBOOT mode...\n");
  412. break;
  413. default:
  414. video_printf(" => UNKNOWN BOOT\n");
  415. }
  416. return;
  417. #endif
  418. #ifdef USER_BUILD
  419. /* it's ok to display META MODE since it already verfied by preloader */
  420. if (g_boot_mode == META_BOOT)
  421. video_printf(" => META MODE\n");
  422. if (g_boot_mode == FASTBOOT)
  423. video_printf(" => FASTBOOT mode...\n");
  424. return;
  425. #endif
  426. #endif
  427. }
  428. extern uint64_t ld_tt_l1[4];
  429. void platform_init_mmu(void)
  430. {
  431. /* configure available RAM banks */
  432. dram_init();
  433. /* Long-descriptor translation with lpae enable */
  434. arm_mmu_lpae_init();
  435. struct mmu_initial_mapping *m = mmu_initial_mappings;
  436. for (uint i = 0; i < countof(mmu_initial_mappings); i++, m++) {
  437. arch_mmu_map(m->phys, m->virt, m->flags, m->size);
  438. }
  439. arch_enable_mmu(); //enable mmu after setup page table to avoid cpu prefetch which may bring on emi violation
  440. }
  441. /******************************************************************************
  442. ******************************************************************************/
  443. void init_storage(void)
  444. {
  445. PROFILING_START("NAND/EMMC init");
  446. #if defined(MTK_EMMC_SUPPORT)
  447. mmc_legacy_init(1);
  448. #elif defined(MTK_UFS_SUPPORT)
  449. ufs_lk_init();
  450. #else
  451. #ifndef MACH_FPGA
  452. nand_init();
  453. nand_driver_test();
  454. #endif // MACH_FPGA
  455. #endif // MTK_EMMC_SUPPORT
  456. #if defined(MTK_EMMC_SUPPORT) || defined(MTK_UFS_SUPPORT)
  457. init_rpmb_sharemem();
  458. #endif
  459. PROFILING_END(); /* NAND/EMMC init */
  460. }
  461. /******************************************************************************
  462. ******************************************************************************/
  463. void platform_early_init(void)
  464. {
  465. PROFILING_START("platform_early_init");
  466. /* initialize the uart */
  467. uart_init_early();
  468. PROFILING_START("Devinfo Init");
  469. #ifdef MTK_MT22_MODE
  470. devinfo_init_mode(MTK_MT22_MODE);
  471. #endif
  472. init_devinfo_data();
  473. PROFILING_END();
  474. platform_init_interrupts();
  475. platform_early_init_timer();
  476. #if !defined(USE_DTB_NO_DWS) && !defined(MACH_FPGA)
  477. mt_gpio_set_default();
  478. #endif // !defined(USE_DTB_NO_DWS) && !defined(MACH_FPGA)
  479. dprintf(SPEW, "bootarg_addr: 0x%x, bootarg_size: 0x%x\n", platform_get_bootarg_addr(), platform_get_bootarg_size());
  480. if (g_dram_init_ret < 0) {
  481. dprintf(CRITICAL, "[LK ERROR] DRAM bank number is not correct!!!\n");
  482. while (1) ;
  483. }
  484. //i2c_v1_init();
  485. PROFILING_START("WDT Init");
  486. mtk_wdt_init();
  487. PROFILING_END();
  488. //i2c init
  489. i2c_hw_init();
  490. #ifdef MACH_FPGA
  491. mtk_timer_init(); // GPT4 will be initialized at PL after
  492. mtk_wdt_disable(); // WDT will be triggered when uncompressing linux image on FPGA
  493. #endif
  494. pwrap_init_lk();
  495. #if !defined(MACH_FPGA) && !defined(NO_PMIC)
  496. PROFILING_START("pmic_init");
  497. pmic_init();
  498. PROFILING_END();
  499. #endif // !defined(MACH_FPGA) && !defined(NO_PMIC)
  500. PROFILING_END(); /* platform_early_init */
  501. }
  502. extern void mt65xx_bat_init(void);
  503. extern bool mtk_bat_allow_backlight_enable(void);
  504. #if defined (MTK_KERNEL_POWER_OFF_CHARGING)
  505. int kernel_charging_boot(void)
  506. {
  507. if ((g_boot_mode == KERNEL_POWER_OFF_CHARGING_BOOT || g_boot_mode == LOW_POWER_OFF_CHARGING_BOOT) && upmu_is_chr_det() == KAL_TRUE) {
  508. dprintf(INFO,"[%s] Kernel Power Off Charging with Charger/Usb \n", __func__);
  509. return 1;
  510. } else if ((g_boot_mode == KERNEL_POWER_OFF_CHARGING_BOOT || g_boot_mode == LOW_POWER_OFF_CHARGING_BOOT) && upmu_is_chr_det() == KAL_FALSE) {
  511. dprintf(INFO,"[%s] Kernel Power Off Charging without Charger/Usb \n", __func__);
  512. return -1;
  513. } else
  514. return 0;
  515. }
  516. #endif
  517. static void lk_vb_init(void)
  518. {
  519. #ifdef MTK_SECURITY_SW_SUPPORT
  520. u64 pl_start_addr = 0;
  521. PROFILING_START("lk_vb_init");
  522. #ifdef MTK_VER_SIMPLE_TEST
  523. u32 ret = 0;
  524. ret = sec_mtk_internal_ver_test(MTK_VER_SIMPLE_TEST);
  525. if (ret)
  526. assert(0);
  527. #endif
  528. #ifdef MTK_OTP_FRAMEWORK_V2
  529. enable_anti_rollback_v2_framework();
  530. #endif
  531. /* get preloader start address */
  532. plinfo_get_brom_header_block_size(&pl_start_addr);
  533. /* initialize security library */
  534. sec_func_init(pl_start_addr);
  535. seclib_set_oemkey(g_oemkey, OEM_PUBK_SZ);
  536. PROFILING_END();
  537. #endif
  538. }
  539. static void lk_vb_vfy_logo(void)
  540. {
  541. #ifdef MTK_SECURITY_SW_SUPPORT
  542. /* bypass logo vfy in fast meta mode */
  543. if(g_boot_mode == META_BOOT)
  544. return;
  545. PROFILING_START("logo verify");
  546. /* Verify logo before use it */
  547. if ( 0 != img_auth_stor("logo", "logo", 0x0) ) {
  548. dprintf(CRITICAL,"<ASSERT> %s:line %d\n",__FILE__,__LINE__);
  549. PAL_ASSERT(0);
  550. }
  551. PROFILING_END();
  552. #endif
  553. return;
  554. }
  555. void platform_init(void)
  556. {
  557. bool bearly_backlight_on = false;
  558. int logo_size;
  559. PROFILING_START("platform_init");
  560. dprintf(CRITICAL, "platform_init()\n");
  561. init_storage();
  562. lk_vb_init();
  563. extern void dummy_ap_entry(void)__attribute__((weak)); /* This is empty function for normal load */
  564. if (dummy_ap_entry)
  565. dummy_ap_entry();
  566. #ifdef MTK_AB_OTA_UPDATER
  567. /* get A/B system parameter before load dtb from boot image */
  568. get_AB_OTA_param();
  569. #endif
  570. /*
  571. * RSC initialize. It must be done before load device tree.
  572. * rsc_init will ectract DTBO index, which will be used in device
  573. * tree overlay, from PARA partition
  574. */
  575. rsc_init();
  576. /* The device tree should be loaded as early as possible. */
  577. load_device_tree();
  578. #if defined(USE_DTB_NO_DWS) && !defined(MACH_FPGA)
  579. mt_gpio_set_default();
  580. #endif // defined(USE_DTB_NO_DWS) && !defined(MACH_FPGA)
  581. #ifndef MACH_FPGA
  582. PROFILING_START("led init");
  583. leds_init();
  584. PROFILING_END();
  585. #endif // MACH_FPGA
  586. #ifdef MTK_KERNEL_POWER_OFF_CHARGING
  587. if ((g_boot_arg->boot_reason == BR_USB) && (upmu_is_chr_det() == KAL_FALSE)) {
  588. dprintf(INFO, "[%s] Unplugged Charger/Usb between Pre-loader and Uboot in Kernel Charging Mode, Power Off \n", __func__);
  589. mt_power_off();
  590. }
  591. #endif // MTK_KERNEL_POWER_OFF_CHARGING
  592. PROFILING_START("ENV init");
  593. env_init();
  594. print_env();
  595. PROFILING_END();
  596. PROFILING_START("disp init");
  597. #if defined(MTK_SMI_SUPPORT) && !defined(MACH_FPGA)
  598. /* write SMI non on-the-fly register before DISP init */
  599. smi_apply_register_setting();
  600. #endif
  601. /* initialize the frame buffet information */
  602. g_fb_size = mt_disp_get_vram_size();
  603. #if (MTK_DUAL_DISPLAY_SUPPORT == 2)
  604. g_ext_fb_size = mt_disp_get_ext_vram_size();
  605. #endif
  606. g_fb_base = mblock_reserve_ext(&g_boot_arg->mblock_info, g_fb_size, 0x10000, 0x80000000, 0, "framebuffer");
  607. #if (MTK_DUAL_DISPLAY_SUPPORT == 2)
  608. g_ext_fb_base = mblock_reserve_ext(&g_boot_arg->mblock_info, g_ext_fb_size, 0x10000, 0x80000000, 0, "framebuffer_ext");
  609. if (!g_fb_base) {
  610. dprintf(CRITICAL, "reserve framebuffer failed\n");
  611. }
  612. #if (MTK_DUAL_DISPLAY_SUPPORT == 2)
  613. if (!g_ext_fb_base) {
  614. dprintf(CRITICAL, "reserve framebuffer_ext failed\n");
  615. }
  616. #endif
  617. #endif
  618. dprintf(CRITICAL, "FB base = 0x%x, FB size = 0x%x (%d)\n", g_fb_base, g_fb_size, g_fb_size);
  619. #if (MTK_DUAL_DISPLAY_SUPPORT == 2)
  620. dprintf(CRITICAL, "EXT_FB base = 0x%x, EXT_FB size = 0x%x (%d)\n", g_ext_fb_base, g_ext_fb_size, g_ext_fb_size);
  621. #endif
  622. #ifndef MACH_FPGA_NO_DISPLAY
  623. mt_disp_init((void *)g_fb_base);
  624. #if (MTK_DUAL_DISPLAY_SUPPORT == 2)
  625. mt_ext_disp_init((void *)g_ext_fb_base);
  626. #endif
  627. drv_video_init();
  628. #endif
  629. PROFILING_END();
  630. /*for kpd pmic mode setting*/
  631. set_kpd_pmic_mode();
  632. #ifndef MACH_FPGA
  633. PROFILING_START("boot mode select");
  634. #if !defined(NO_BOOT_MODE_SEL)
  635. boot_mode_select();
  636. #endif
  637. #ifdef CFG_MTK_WDT_COMMON
  638. PROFILING_START("wdt_check_exception");
  639. wdt_check_exception();
  640. PROFILING_END();
  641. #endif //CFG_MTK_WDT_COMMON
  642. #ifdef MTK_USB2JTAG_SUPPORT
  643. if (g_boot_mode != FASTBOOT) {
  644. extern void usb2jtag_init(void);
  645. usb2jtag_init();
  646. }
  647. #endif
  648. #ifdef MTK_AEE_PLATFORM_DEBUG_SUPPORT
  649. /* init lastbus: MUST call after kedump (in boot_mode_select) */
  650. latch_lastbus_init();
  651. #endif
  652. PROFILING_END(); /* boot mode select */
  653. #endif /*MACH_FPGA */
  654. #ifndef MACH_FPGA_NO_DISPLAY
  655. /* fast meta mode */
  656. if(g_boot_mode != META_BOOT){
  657. PROFILING_START("load_logo");
  658. logo_size = mboot_common_load_logo((unsigned long)mt_get_logo_db_addr_pa(), "logo");
  659. PAL_ASSERT(logo_size <= LK_LOGO_MAX_SIZE);
  660. PROFILING_END();
  661. } else {
  662. /* Indicate logo lib that logo partition is not loaded */
  663. enable_logo(0);
  664. }
  665. #endif // MACH_FPGA_NO_DISPLAY
  666. lk_vb_vfy_logo();
  667. /*Show download logo & message on screen */
  668. if (g_boot_arg->boot_mode == DOWNLOAD_BOOT) {
  669. dprintf(CRITICAL, "[LK] boot mode is DOWNLOAD_BOOT\n");
  670. #ifndef MACH_FPGA_NO_DISPLAY
  671. PROFILING_START("show logo");
  672. mt_disp_show_boot_logo();
  673. PROFILING_END();
  674. #endif
  675. video_printf(" => Downloading...\n");
  676. dprintf(CRITICAL, "enable backlight after show bootlogo! \n");
  677. #ifndef MACH_FPGA
  678. PROFILING_START("backlight");
  679. mt65xx_backlight_on();
  680. PROFILING_END();
  681. #endif
  682. #ifndef MACH_FPGA_NO_DISPLAY
  683. /* pwm need display sof */
  684. PROFILING_START("disp update");
  685. mt_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);
  686. PROFILING_END();
  687. #endif
  688. logo_lk_t = ((unsigned int)get_timer(boot_time));
  689. PROFILING_START("disable wdt, l2, cache, mmu");
  690. mtk_wdt_disable(); //Disable wdt before jump to DA
  691. platform_uninit();
  692. #ifdef HAVE_CACHE_PL310
  693. l2_disable();
  694. #endif
  695. arch_disable_cache(UCACHE);
  696. arch_disable_mmu();
  697. #ifdef ENABLE_L2_SHARING
  698. config_shared_SRAM_size();
  699. #endif
  700. PROFILING_END();
  701. jump_da(g_boot_arg->da_info.addr, g_boot_arg->da_info.arg1, g_boot_arg->da_info.arg2);
  702. }
  703. #ifdef MTK_KERNEL_POWER_OFF_CHARGING
  704. else if (g_boot_mode != ALARM_BOOT && g_boot_mode != FASTBOOT && g_boot_mode != KERNEL_POWER_OFF_CHARGING_BOOT && g_boot_mode != LOW_POWER_OFF_CHARGING_BOOT && mtk_bat_allow_backlight_enable()) {
  705. #ifndef MACH_FPGA_NO_DISPLAY
  706. /* fast meta mode */
  707. if(g_boot_mode != META_BOOT){
  708. PROFILING_START("show logo");
  709. mt_disp_show_boot_logo();
  710. PROFILING_END();
  711. }
  712. #endif // MACH_FPGA_NO_DISPLAY
  713. #ifndef MACH_FPGA
  714. PROFILING_START("backlight");
  715. mt65xx_backlight_on();
  716. PROFILING_END(); /* backlight */
  717. #endif // MACH_FPGA
  718. #ifndef MACH_FPGA_NO_DISPLAY
  719. /* fast meta mode */
  720. if(g_boot_mode != META_BOOT){
  721. PROFILING_START("disp update");
  722. mt_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);
  723. PROFILING_END();
  724. }
  725. #endif // MACH_FPGA_NO_DISPLAY
  726. bearly_backlight_on = true;
  727. dprintf(INFO, "backlight enabled before battery init\n");
  728. logo_lk_t = ((unsigned int)get_timer(boot_time));
  729. }
  730. #endif // MTK_KERNEL_POWER_OFF_CHARGING
  731. PROFILING_START("battery init");
  732. #ifndef MACH_FPGA
  733. mt_pll_clk_bootargs();
  734. #if !defined(NO_PLL_TURN_OFF)
  735. mt_pll_turn_off();
  736. #endif // !defined(NO_PLL_TURN_OFF)
  737. #if !defined(NO_DCM)
  738. if (mt_dcm_init())
  739. dprintf(CRITICAL, "mt_dcm_init fail\n");
  740. #endif // !defined(NO_DCM)
  741. #if !defined(NO_BAT_INIT)
  742. #ifdef MTK_CHARGER_NEW_ARCH
  743. mtk_charger_init();
  744. pmic_dlpt_init();
  745. check_sw_ocv();
  746. mtk_charger_start();
  747. get_dlpt_imix_r();
  748. #else
  749. mt65xx_bat_init();
  750. #endif // MTK_CHARGER_NEW_ARCH
  751. #endif // !defined(NO_BAT_INIT)
  752. #endif // MACH_FPGA
  753. PROFILING_END(); /* battery init */
  754. #ifndef CFG_POWER_CHARGING
  755. PROFILING_START("RTC boot check Init");
  756. /* NOTE: if define CFG_POWER_CHARGING, will rtc_boot_check() in mt65xx_bat_init() */
  757. rtc_boot_check(false);
  758. PROFILING_END();
  759. #endif // CFG_POWER_CHARGING
  760. #ifdef MTK_KERNEL_POWER_OFF_CHARGING
  761. if (kernel_charging_boot() == 1) {
  762. PROFILING_START("show logo");
  763. #ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
  764. CHARGER_TYPE CHR_Type_num = CHARGER_UNKNOWN;
  765. CHR_Type_num = hw_charging_get_charger_type();
  766. if ((g_boot_mode != LOW_POWER_OFF_CHARGING_BOOT) ||
  767. ((CHR_Type_num != STANDARD_HOST) && (CHR_Type_num != NONSTANDARD_CHARGER))) {
  768. #endif // MTK_BATLOWV_NO_PANEL_ON_EARLY
  769. mt_disp_power(TRUE);
  770. #ifndef MACH_FPGA_NO_DISPLAY
  771. mt_disp_show_low_battery();
  772. #endif
  773. mt65xx_leds_brightness_set(6, 110);
  774. #ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
  775. }
  776. #endif
  777. PROFILING_END();
  778. } else if (g_boot_mode != KERNEL_POWER_OFF_CHARGING_BOOT && g_boot_mode != LOW_POWER_OFF_CHARGING_BOOT) {
  779. /* fast meta mode */
  780. if(g_boot_mode != META_BOOT)
  781. if (g_boot_mode != ALARM_BOOT && (g_boot_mode != FASTBOOT) && !bearly_backlight_on) {
  782. #ifndef MACH_FPGA_NO_DISPLAY
  783. PROFILING_START("show logo");
  784. mt_disp_show_boot_logo();
  785. PROFILING_END();
  786. #endif
  787. }
  788. }
  789. #else // MTK_KERNEL_POWER_OFF_CHARGING
  790. /* fast meta mode */
  791. if(g_boot_mode != META_BOOT)
  792. if (g_boot_mode != ALARM_BOOT && (g_boot_mode != FASTBOOT) && !bearly_backlight_on) {
  793. #ifndef MACH_FPGA_NO_DISPLAY
  794. PROFILING_START("show logo");
  795. mt_disp_show_boot_logo();
  796. PROFILING_END(); /* show logo */
  797. #endif
  798. }
  799. #endif // MTK_KERNEL_POWER_OFF_CHARGING
  800. #ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
  801. if (!is_low_battery(0)) {
  802. #endif
  803. #ifndef MACH_FPGA
  804. PROFILING_START("backlight");
  805. mt65xx_backlight_on();
  806. PROFILING_END(); /* backlight */
  807. #endif
  808. //pwm need display sof
  809. #ifndef MACH_FPGA_NO_DISPLAY
  810. PROFILING_START("display update");
  811. mt_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);
  812. PROFILING_END();
  813. if (!bearly_backlight_on)
  814. logo_lk_t = ((unsigned int)get_timer(boot_time));
  815. #endif
  816. #ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
  817. }
  818. #endif
  819. #ifndef MACH_FPGA
  820. PROFILING_START("sw_env");
  821. sw_env();
  822. PROFILING_END();
  823. #endif
  824. PROFILING_END(); /* platform_init */
  825. }
  826. void platform_uninit(void)
  827. {
  828. #if 0
  829. #if (MTK_DUAL_DISPLAY_SUPPORT == 2)
  830. /* mt_ext_disp_deinit();*/
  831. #endif
  832. leds_deinit();
  833. platform_lastpc_postinit();
  834. #endif
  835. platform_deinit_interrupts();
  836. return;
  837. }
  838. #ifdef ENABLE_L2_SHARING
  839. #define ADDR_CA7L_CACHE_CONFIG_MP(x) (CA7MCUCFG_BASE + 0x200 * x)
  840. #define L2C_SIZE_CFG_OFFSET 8
  841. #define L2C_SHARE_EN_OFFSET 12
  842. /* 4'b1111: 2048KB(not support)
  843. * 4'b0111: 1024KB(not support)
  844. * 4'b0011: 512KB
  845. * 4'b0001: 256KB
  846. * 4'b0000: 128KB (not support)
  847. */
  848. int is_l2_need_config(void)
  849. {
  850. volatile unsigned int cache_cfg, addr;
  851. addr = ADDR_CA7L_CACHE_CONFIG_MP(0);
  852. cache_cfg = DRV_Reg32(addr);
  853. cache_cfg = cache_cfg >> L2C_SIZE_CFG_OFFSET;
  854. /* only read 256KB need to be config.*/
  855. if ((cache_cfg &(0x7)) == 0x1) {
  856. return 1;
  857. }
  858. return 0;
  859. }
  860. void cluster_l2_share_enable(int cluster)
  861. {
  862. volatile unsigned int cache_cfg, addr;
  863. addr = ADDR_CA7L_CACHE_CONFIG_MP(cluster);
  864. /* set L2C size to 256KB */
  865. cache_cfg = DRV_Reg32(addr);
  866. cache_cfg &= (~0x7) << L2C_SIZE_CFG_OFFSET;
  867. cache_cfg |= 0x1 << L2C_SIZE_CFG_OFFSET;
  868. /* enable L2C_share_en. Sram only for other to use*/
  869. cache_cfg |= (0x1 << L2C_SHARE_EN_OFFSET);
  870. DRV_WriteReg32(addr, cache_cfg);
  871. }
  872. void cluster_l2_share_disable(int cluster)
  873. {
  874. volatile unsigned int cache_cfg, addr;
  875. addr = ADDR_CA7L_CACHE_CONFIG_MP(cluster);
  876. /* set L2C size to 512KB */
  877. cache_cfg = DRV_Reg32(addr);
  878. cache_cfg &= (~0x7) << L2C_SIZE_CFG_OFFSET;
  879. cache_cfg |= 0x3 << L2C_SIZE_CFG_OFFSET;
  880. DRV_WriteReg32(addr, cache_cfg);
  881. /* disable L2C_share_en. Sram only for cpu to use*/
  882. cache_cfg &= ~(0x1 << L2C_SHARE_EN_OFFSET);
  883. DRV_WriteReg32(addr, cache_cfg);
  884. }
  885. /* config L2 cache and sram to its size */
  886. void config_L2_size(void)
  887. {
  888. int cluster;
  889. if (is_l2_need_config()) {
  890. /*
  891. * Becuase mcu config is protected.
  892. * only can write in secutity mode
  893. */
  894. if (dev_info_nr_cpu() == 6) {
  895. cluster_l2_share_disable(0);
  896. cluster_l2_share_enable(1);
  897. }
  898. else {
  899. for (cluster = 0; cluster < 2; cluster++) {
  900. cluster_l2_share_disable(cluster);
  901. }
  902. }
  903. }
  904. }
  905. /* config SRAM back from L2 cache for DA relocation */
  906. void config_shared_SRAM_size(void)
  907. {
  908. int cluster;
  909. if (is_l2_need_config()) {
  910. /*
  911. * Becuase mcu config is protected.
  912. * only can write in secutity mode
  913. */
  914. for (cluster = 0; cluster < 2; cluster++) {
  915. cluster_l2_share_enable(cluster);
  916. }
  917. }
  918. }
  919. #endif
  920. void platform_sec_post_init(void)
  921. {
  922. unsigned int ret = 0;
  923. /* Lock Device APC in LK */
  924. dprintf(CRITICAL, "[DEVAPC] sec_post_init\n");
  925. ret = crypto_hw_engine_disable();
  926. if (ret) {
  927. dprintf(CRITICAL, "[SEC] crypto engine HW disable fail\n");
  928. }
  929. #if DEVAPC_TURN_ON
  930. dprintf(CRITICAL, "[DEVAPC] platform_sec_post_init - SMC call to ATF from LK\n");
  931. mt_secure_call(MTK_SIP_LK_DAPC_INIT, 0, 0, 0, 0);
  932. #endif
  933. }
  934. u32 get_devinfo_with_index(u32 index)
  935. {
  936. return internal_get_devinfo_with_index(index);
  937. }
  938. int platform_skip_hibernation(void)
  939. {
  940. switch (g_boot_arg->boot_reason) {
  941. #if 0 // let schedule power on to go hiberantion bootup process
  942. case BR_RTC:
  943. #endif
  944. case BR_WDT:
  945. case BR_WDT_BY_PASS_PWK:
  946. case BR_WDT_SW:
  947. case BR_WDT_HW:
  948. return 1;
  949. }
  950. return 0;
  951. }
  952. int is_meta_log_disable(void)
  953. {
  954. return g_boot_arg->meta_log_disable;
  955. }