platform.c 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049
  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/boot_mode.h>
  43. #include <platform/mt_logo.h>
  44. #include <platform/partition.h>
  45. #include <env.h>
  46. #include <platform/mt_gpio.h>
  47. #include <platform/mt_pmic.h>
  48. #include <platform/mt_pmic_wrap_init.h>
  49. #include <platform/mt_i2c.h>
  50. #include <platform/mtk_key.h>
  51. #include <platform/mt_rtc.h>
  52. #include <platform/mt_leds.h>
  53. #include <platform/upmu_common.h>
  54. #include <platform/mtk_wdt.h>
  55. #include <platform/disp_drv_platform.h>
  56. #include <platform/verified_boot.h>
  57. #include <libfdt.h>
  58. #include <fdt_op.h>
  59. #ifdef MTK_AB_OTA_UPDATER
  60. #include "bootctrl.h"
  61. #endif
  62. #if defined(MTK_SECURITY_SW_SUPPORT)
  63. #include "oemkey.h"
  64. #endif
  65. #ifdef MTK_SECURITY_SW_SUPPORT
  66. extern u8 g_oemkey[OEM_PUBK_SZ];
  67. #endif
  68. #ifdef LK_DL_CHECK
  69. /*block if check dl fail*/
  70. #undef LK_DL_CHECK_BLOCK_LEVEL
  71. #endif
  72. //#define MT_SRAM_REPAIR_SUPPORT
  73. /*#define MBLOCK_TEST*/
  74. extern void platform_early_init_timer();
  75. extern void jump_da(u32 addr, u32 arg1, u32 arg2);
  76. extern int i2c_hw_init(void);
  77. extern int mboot_common_load_logo(unsigned long logo_addr, char* filename);
  78. extern int sec_usbdl_verify_da(unsigned char*, unsigned int, unsigned char*, unsigned int);
  79. extern void mtk_wdt_disable(void);
  80. extern void platform_deinit_interrupts(void);
  81. extern int mmc_get_dl_info(void);
  82. extern int mmc_legacy_init(int);
  83. #ifdef MT_SRAM_REPAIR_SUPPORT
  84. extern int repair_sram(void);
  85. #endif
  86. extern bool g_boot_menu;
  87. #ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
  88. extern kal_bool is_low_battery(kal_int32 val);
  89. extern int hw_charging_get_charger_type(void);
  90. #endif
  91. #ifdef MTK_MT8193_SUPPORT
  92. extern int mt8193_init(void);
  93. #endif
  94. void platform_uninit(void);
  95. void config_shared_SRAM_size(void);
  96. extern int dev_info_nr_cpu(void);
  97. extern void mt_pll_turn_off(void);
  98. struct mmu_initial_mapping mmu_initial_mappings[] = {
  99. {
  100. .phys = (uint64_t)0,
  101. .virt = (uint32_t)0,
  102. .size = 0x40000000,
  103. .flags = MMU_MEMORY_TYPE_STRONGLY_ORDERED | MMU_MEMORY_AP_P_RW_U_NA,
  104. .name = "mcusys"
  105. },
  106. {
  107. .phys = (uint64_t)MEMBASE,
  108. .virt = (uint32_t)MEMBASE,
  109. .size = ROUNDUP(MEMSIZE, SECTION_SIZE),
  110. .flags = MMU_MEMORY_TYPE_NORMAL_WRITE_BACK | MMU_MEMORY_AP_P_RW_U_NA,
  111. .name = "ram"
  112. },
  113. {
  114. .phys = (uint64_t)CFG_BOOTIMG_LOAD_ADDR,
  115. .virt = (uint32_t)CFG_BOOTIMG_LOAD_ADDR,
  116. .size = 64*MB,
  117. .flags = MMU_MEMORY_TYPE_NORMAL_WRITE_BACK | MMU_MEMORY_AP_P_RW_U_NA,
  118. .name = "bootimg"
  119. },
  120. {
  121. .phys = (uint64_t)SCRATCH_ADDR,
  122. .virt = (uint32_t)SCRATCH_ADDR,
  123. .size = SCRATCH_SIZE,
  124. .flags = MMU_MEMORY_TYPE_NORMAL_WRITE_BACK | MMU_MEMORY_AP_P_RW_U_NA,
  125. .name = "download"
  126. },
  127. /* null entry to terminate the list */
  128. { 0 }
  129. };
  130. BOOT_ARGUMENT *g_boot_arg;
  131. BOOT_ARGUMENT boot_addr;
  132. int g_nr_bank;
  133. BI_DRAM bi_dram[MAX_NR_BANK];
  134. unsigned int g_fb_base;
  135. unsigned int g_fb_size;
  136. static int g_dram_init_ret;
  137. static unsigned int bootarg_addr;
  138. static unsigned int bootarg_size;
  139. int dram_init(void)
  140. {
  141. int i;
  142. struct boot_tag *tags;
  143. /* Get parameters from pre-loader. Get as early as possible
  144. * The address of BOOT_ARGUMENT_LOCATION will be used by Linux later
  145. * So copy the parameters from BOOT_ARGUMENT_LOCATION to LK's memory region
  146. */
  147. g_boot_arg = &boot_addr;
  148. bootarg_addr = (unsigned int *)BOOT_ARGUMENT_LOCATION;
  149. bootarg_size = 0;
  150. if (*(unsigned int *)BOOT_ARGUMENT_LOCATION == BOOT_ARGUMENT_MAGIC) {
  151. memcpy(g_boot_arg, (void*)BOOT_ARGUMENT_LOCATION, sizeof(BOOT_ARGUMENT));
  152. bootarg_size = sizeof(BOOT_ARGUMENT);
  153. } else {
  154. g_boot_arg->maggic_number = BOOT_ARGUMENT_MAGIC;
  155. for (tags = (void *)BOOT_ARGUMENT_LOCATION; tags->hdr.size; tags = boot_tag_next(tags)) {
  156. switch (tags->hdr.tag) {
  157. case BOOT_TAG_BOOT_REASON:
  158. g_boot_arg->boot_reason = tags->u.boot_reason.boot_reason;
  159. break;
  160. case BOOT_TAG_BOOT_MODE:
  161. g_boot_arg->boot_mode = tags->u.boot_mode.boot_mode;
  162. break;
  163. case BOOT_TAG_META_COM:
  164. g_boot_arg->meta_com_type = tags->u.meta_com.meta_com_type;
  165. g_boot_arg->meta_com_id = tags->u.meta_com.meta_com_id;
  166. g_boot_arg->meta_uart_port = tags->u.meta_com.meta_uart_port;
  167. break;
  168. case BOOT_TAG_LOG_COM:
  169. g_boot_arg->log_port = tags->u.log_com.log_port;
  170. g_boot_arg->log_baudrate = tags->u.log_com.log_baudrate;
  171. g_boot_arg->log_enable = tags->u.log_com.log_enable;
  172. g_boot_arg->log_dynamic_switch = tags->u.log_com.log_dynamic_switch;
  173. break;
  174. case BOOT_TAG_MEM:
  175. g_boot_arg->dram_rank_num = tags->u.mem.dram_rank_num;
  176. for (i = 0; i < tags->u.mem.dram_rank_num; i++) {
  177. g_boot_arg->dram_rank_size[i] = tags->u.mem.dram_rank_size[i];
  178. }
  179. g_boot_arg->mblock_info = tags->u.mem.mblock_info;
  180. g_boot_arg->orig_dram_info = tags->u.mem.orig_dram_info;
  181. g_boot_arg->lca_reserved_mem = tags->u.mem.lca_reserved_mem;
  182. g_boot_arg->tee_reserved_mem = tags->u.mem.tee_reserved_mem;
  183. break;
  184. case BOOT_TAG_MD_INFO:
  185. for (i = 0; i < 4; i++) {
  186. g_boot_arg->md_type[i] = tags->u.md_info.md_type[i];
  187. }
  188. break;
  189. case BOOT_TAG_BOOT_TIME:
  190. g_boot_arg->boot_time = tags->u.boot_time.boot_time;
  191. break;
  192. case BOOT_TAG_DA_INFO:
  193. memcpy(&g_boot_arg->da_info, &tags->u.da_info.da_info, sizeof(da_info_t));
  194. break;
  195. case BOOT_TAG_SEC_INFO:
  196. memcpy(&g_boot_arg->sec_limit, &tags->u.sec_info.sec_limit, sizeof(SEC_LIMIT));
  197. break;
  198. case BOOT_TAG_PART_NUM:
  199. g_boot_arg->part_num = tags->u.part_num.part_num;
  200. break;
  201. case BOOT_TAG_PART_INFO:
  202. g_boot_arg->part_info = tags->u.part_info.part_info; /* only copy the pointer but the contains*/
  203. break;
  204. case BOOT_TAG_EFLAG:
  205. g_boot_arg->e_flag = tags->u.eflag.e_flag;
  206. break;
  207. case BOOT_TAG_DDR_RESERVE:
  208. g_boot_arg->ddr_reserve_enable = tags->u.ddr_reserve.ddr_reserve_enable;
  209. g_boot_arg->ddr_reserve_success = tags->u.ddr_reserve.ddr_reserve_success;
  210. g_boot_arg->ddr_reserve_ready = tags->u.ddr_reserve.ddr_reserve_ready;
  211. break;
  212. case BOOT_TAG_DRAM_BUF:
  213. g_boot_arg->dram_buf_size = tags->u.dram_buf.dram_buf_size;
  214. break;
  215. case BOOT_TAG_SRAM_INFO:
  216. g_boot_arg->non_secure_sram_addr = tags->u.sram_info.non_secure_sram_addr;
  217. g_boot_arg->non_secure_sram_size = tags->u.sram_info.non_secure_sram_size;
  218. break;
  219. case BOOT_TAG_PTP:
  220. memcpy(&g_boot_arg->ptp_volt_info, &tags->u.ptp_volt.ptp_volt_info, sizeof(ptp_info_t));
  221. break;
  222. case BOOT_TAG_PL_VERSION:
  223. memcpy(&g_boot_arg->pl_version, &tags->u.pl_version.pl_version, sizeof(tags->u.pl_version.pl_version));
  224. break;
  225. case BOOT_TAG_IMGVER_INFO:
  226. g_boot_arg->pl_imgver_status = tags->u.imgver_info.pl_imgver_status;
  227. break;
  228. case BOOT_TAG_RAM_CONSOLE_INFO:
  229. g_boot_arg->ram_console_sram_addr = tags->u.ram_console_info.sram_addr;
  230. g_boot_arg->ram_console_sram_size = tags->u.ram_console_info.sram_size;
  231. g_boot_arg->ram_console_def_type = tags->u.ram_console_info.def_type;
  232. g_boot_arg->ram_console_memory_info_offset = tags->u.ram_console_info.memory_info_offset;
  233. break;
  234. default:
  235. break;
  236. }
  237. bootarg_size += tags->hdr.size;
  238. }
  239. }
  240. #ifdef MACH_FPGA
  241. g_nr_bank = 2;
  242. bi_dram[0].start = DRAM_PHY_ADDR + RIL_SIZE;
  243. bi_dram[0].size = (256 * 1024 * 1024) - RIL_SIZE;
  244. bi_dram[1].start = bi_dram[0].start + bi_dram[0].size;
  245. bi_dram[1].size = (256 * 1024 * 1024);
  246. #else
  247. g_nr_bank = g_boot_arg->dram_rank_num;
  248. if (g_nr_bank == 0 || g_nr_bank > MAX_NR_BANK) {
  249. g_dram_init_ret = -1;
  250. //dprintf(CRITICAL, "[LK ERROR] DRAM bank number is not correct!!!");
  251. //while (1) ;
  252. return -1;
  253. }
  254. /* return the actual DRAM info */
  255. for (i = 0; i < g_boot_arg->mblock_info.mblock_num; i++) {
  256. bi_dram[i].start = g_boot_arg->mblock_info.mblock[i].start;
  257. bi_dram[i].size = g_boot_arg->mblock_info.mblock[i].size;
  258. }
  259. #endif
  260. return 0;
  261. }
  262. unsigned int platform_get_bootarg_addr(void)
  263. {
  264. return bootarg_addr;
  265. }
  266. unsigned int platform_get_bootarg_size(void)
  267. {
  268. return bootarg_size;
  269. }
  270. /*******************************************************
  271. * Routine: memory_size
  272. * Description: return DRAM size to LCM driver
  273. ******************************************************/
  274. u32 ddr_enable_4gb(void)
  275. {
  276. #define INFRA_MISC (INFRACFG_AO_BASE + 0x0F00)
  277. #define INFRA_4GB_EN (1 << 13)
  278. #define PERI_MISC (PERICFG_BASE + 0x0208)
  279. #define PERI_4GB_EN (1 << 15)
  280. return ((DRV_Reg32(INFRA_MISC) & INFRA_4GB_EN) && (DRV_Reg32(PERI_MISC) & PERI_4GB_EN)) ? 1 : 0;
  281. }
  282. u64 physical_memory_size(void)
  283. {
  284. int i;
  285. unsigned long long size = 0;
  286. for (i = 0; i < g_boot_arg->orig_dram_info.rank_num; i++) {
  287. size += g_boot_arg->orig_dram_info.rank_info[i].size;
  288. }
  289. return size;
  290. }
  291. u32 memory_size(void)
  292. {
  293. unsigned long long size = physical_memory_size();
  294. while (((unsigned long long)DRAM_PHY_ADDR + size) > 0x100000000ULL) {
  295. size -= (unsigned long long)(1024*1024*1024);
  296. }
  297. return (unsigned int)size;
  298. }
  299. void sw_env()
  300. {
  301. #ifdef LK_DL_CHECK
  302. #ifdef MTK_EMMC_SUPPORT
  303. int dl_status = 0;
  304. dl_status = mmc_get_dl_info();
  305. dprintf(INFO, "mt65xx_sw_env--dl_status: %d\n", dl_status);
  306. if (dl_status != 0) {
  307. video_printf("=> TOOL DL image Fail!\n");
  308. dprintf(CRITICAL, "TOOL DL image Fail\n");
  309. #ifdef LK_DL_CHECK_BLOCK_LEVEL
  310. dprintf(CRITICAL, "uboot is blocking by dl info\n");
  311. while (1) ;
  312. #endif
  313. }
  314. #endif
  315. #endif
  316. #ifndef USER_BUILD
  317. switch (g_boot_mode) {
  318. case META_BOOT:
  319. video_printf(" => META MODE\n");
  320. break;
  321. case FACTORY_BOOT:
  322. video_printf(" => FACTORY MODE\n");
  323. break;
  324. case RECOVERY_BOOT:
  325. video_printf(" => RECOVERY MODE\n");
  326. break;
  327. case SW_REBOOT:
  328. //video_printf(" => SW RESET\n");
  329. break;
  330. case NORMAL_BOOT:
  331. //if(g_boot_arg->boot_reason != BR_RTC && get_env("hibboot") != NULL && atoi(get_env("hibboot")) == 1)
  332. if (!g_boot_menu && get_env("hibboot") != NULL && atoi(get_env("hibboot")) == 1)
  333. video_printf(" => HIBERNATION BOOT\n");
  334. else
  335. video_printf(" => NORMAL BOOT\n");
  336. break;
  337. case ADVMETA_BOOT:
  338. video_printf(" => ADVANCED META MODE\n");
  339. break;
  340. case ATE_FACTORY_BOOT:
  341. video_printf(" => ATE FACTORY MODE\n");
  342. break;
  343. #ifdef MTK_KERNEL_POWER_OFF_CHARGING
  344. case KERNEL_POWER_OFF_CHARGING_BOOT:
  345. video_printf(" => POWER OFF CHARGING MODE\n");
  346. break;
  347. case LOW_POWER_OFF_CHARGING_BOOT:
  348. video_printf(" => LOW POWER OFF CHARGING MODE\n");
  349. break;
  350. #endif
  351. case ALARM_BOOT:
  352. video_printf(" => ALARM BOOT\n");
  353. break;
  354. case FASTBOOT:
  355. video_printf(" => FASTBOOT mode...\n");
  356. break;
  357. default:
  358. video_printf(" => UNKNOWN BOOT\n");
  359. }
  360. return;
  361. #endif
  362. #ifdef USER_BUILD
  363. if (g_boot_mode == FASTBOOT)
  364. video_printf(" => FASTBOOT mode...\n");
  365. return;
  366. #endif
  367. }
  368. extern uint64_t ld_tt_l1[4];
  369. void platform_init_mmu(void)
  370. {
  371. unsigned long long addr;
  372. unsigned int vaddr;
  373. unsigned long long dram_size;
  374. /* configure available RAM banks */
  375. dram_init();
  376. /* Long-descriptor translation with lpae enable */
  377. arm_mmu_lpae_init();
  378. struct mmu_initial_mapping *m = mmu_initial_mappings;
  379. for (uint i = 0; i < countof(mmu_initial_mappings); i++, m++) {
  380. arch_mmu_map(m->phys, m->virt, m->flags, m->size);
  381. }
  382. arch_enable_mmu(); //enable mmu after setup page table to avoid cpu prefetch which may bring on emi violation
  383. }
  384. void platform_early_init(void)
  385. {
  386. #ifdef MT_SRAM_REPAIR_SUPPORT
  387. int repair_ret;
  388. #endif
  389. #ifdef LK_PROFILING
  390. #ifdef MT_SRAM_REPAIR_SUPPORT
  391. unsigned int time_repair_sram;
  392. #endif
  393. unsigned int time_wdt_early_init;
  394. unsigned int time_pmic_init;
  395. unsigned int time_platform_early_init;
  396. #endif
  397. platform_init_interrupts();
  398. platform_early_init_timer();
  399. #if defined(MACH_FPGA) || defined(SB_LK_BRINGUP)
  400. mtk_timer_init(); // GPT4 will be initialized at PL after
  401. #endif
  402. #ifdef LK_PROFILING
  403. time_platform_early_init = get_timer(0);
  404. #endif
  405. #ifndef MACH_FPGA
  406. #ifndef DUMMY_AP
  407. mt_gpio_set_default();
  408. #endif
  409. #endif
  410. /* initialize the uart */
  411. uart_init_early();
  412. dprintf(SPEW, "bootarg_addr: 0x%x, bootarg_size: 0x%x\n", platform_get_bootarg_addr(), platform_get_bootarg_size());
  413. if (g_dram_init_ret < 0) {
  414. dprintf(CRITICAL, "[LK ERROR] DRAM bank number is not correct!!!\n");
  415. while (1) ;
  416. }
  417. //i2c_v1_init();
  418. #ifdef LK_PROFILING
  419. time_wdt_early_init = get_timer(0);
  420. #endif
  421. mtk_wdt_init();
  422. #ifdef LK_PROFILING
  423. dprintf(INFO, "[PROFILE] ------- WDT Init takes %d ms -------- \n", (int)get_timer(time_wdt_early_init));
  424. #endif
  425. #ifdef MT_SRAM_REPAIR_SUPPORT
  426. #ifdef LK_PROFILING
  427. time_repair_sram = get_timer(0);
  428. #endif
  429. repair_ret = repair_sram();
  430. if (repair_ret != 0) {
  431. dprintf(CRITICAL, "Sram repair failed %d\n", repair_ret);
  432. while (1);
  433. }
  434. #ifdef LK_PROFILING
  435. dprintf(INFO, "[PROFILE] ------- Repair SRAM takes %d ms -------- \n", (int)get_timer(time_repair_sram));
  436. #endif
  437. #endif
  438. //i2c init
  439. i2c_hw_init();
  440. #if defined(MACH_FPGA) || defined(SB_LK_BRINGUP)
  441. //mtk_timer_init(); // GPT4 will be initialized at PL after
  442. mtk_wdt_disable(); // WDT will be triggered when uncompressing linux image on FPGA
  443. *(volatile unsigned int *)0x10212000 = 0x22000064;
  444. #endif
  445. #if MTK_MT8193_SUPPORT
  446. mt8193_init();
  447. #endif
  448. // Workaround by Peng
  449. //pwrap_init_lk();
  450. //pwrap_init_for_early_porting();
  451. #ifdef LK_PROFILING
  452. time_pmic_init = get_timer(0);
  453. #endif
  454. pmic_init();
  455. /*
  456. // Workaround by Weiqi
  457. mt6331_upmu_set_rg_vgp1_en(1);
  458. mt6331_upmu_set_rg_vcam_io_en(1);
  459. */
  460. #ifdef LK_PROFILING
  461. dprintf(INFO, "[PROFILE] ------- pmic_init takes %d ms -------- \n", (int)get_timer(time_pmic_init));
  462. #endif
  463. #ifdef LK_PROFILING
  464. dprintf(INFO, "[PROFILE] ------- platform_early_init takes %d ms -------- \n", (int)get_timer(time_platform_early_init));
  465. #endif
  466. }
  467. extern void mt65xx_bat_init(void);
  468. #if defined (MTK_KERNEL_POWER_OFF_CHARGING)
  469. int kernel_charging_boot(void)
  470. {
  471. if ((g_boot_mode == KERNEL_POWER_OFF_CHARGING_BOOT || g_boot_mode == LOW_POWER_OFF_CHARGING_BOOT) && upmu_is_chr_det() == KAL_TRUE) {
  472. dprintf(INFO,"[%s] Kernel Power Off Charging with Charger/Usb \n", __func__);
  473. return 1;
  474. } else if ((g_boot_mode == KERNEL_POWER_OFF_CHARGING_BOOT || g_boot_mode == LOW_POWER_OFF_CHARGING_BOOT) && upmu_is_chr_det() == KAL_FALSE) {
  475. dprintf(INFO,"[%s] Kernel Power Off Charging without Charger/Usb \n", __func__);
  476. return -1;
  477. } else
  478. return 0;
  479. }
  480. #endif
  481. #ifdef MBLOCK_TEST
  482. static void mblock_create_test(void)
  483. {
  484. u64 addr = 0;
  485. dprintf(CRITICAL,"######################################johnson test###########################\n",addr);
  486. addr = mblock_reserve(&g_boot_arg->mblock_info, 0x2100000, 0x100000, 0xa0000000, RANKMAX);
  487. mblock_resize(&g_boot_arg->mblock_info,&g_boot_arg->orig_dram_info,addr, 0x2100000, 0x1f00000);
  488. dprintf(CRITICAL,"%s:reserved addr = %lx\n",__func__,addr);
  489. if (addr) {
  490. mblock_create(&g_boot_arg->mblock_info, &g_boot_arg->orig_dram_info, addr+0x100000,0x100000);
  491. mblock_create(&g_boot_arg->mblock_info, &g_boot_arg->orig_dram_info, addr+0x200000,0x100000);
  492. mblock_create(&g_boot_arg->mblock_info, &g_boot_arg->orig_dram_info, addr+0x1100000,0x100000);
  493. mblock_create(&g_boot_arg->mblock_info, &g_boot_arg->orig_dram_info, addr+0x1400000,0x100000);
  494. mblock_create(&g_boot_arg->mblock_info, &g_boot_arg->orig_dram_info, addr+0x1800000,0x100000);
  495. mblock_create(&g_boot_arg->mblock_info, &g_boot_arg->orig_dram_info, addr+0x700000,0x100000);
  496. mblock_create(&g_boot_arg->mblock_info, &g_boot_arg->orig_dram_info, addr+0x600000,0x100000);
  497. mblock_create(&g_boot_arg->mblock_info, &g_boot_arg->orig_dram_info, addr+0x500000,0x100000);
  498. mblock_create(&g_boot_arg->mblock_info, &g_boot_arg->orig_dram_info, addr+0x400000,0x100000);
  499. mblock_create(&g_boot_arg->mblock_info, &g_boot_arg->orig_dram_info, addr+0x300000,0x100000);
  500. }
  501. dprintf(CRITICAL,"######################################johnson test###########################\n",addr);
  502. return ;
  503. }
  504. #endif
  505. void platform_init(void)
  506. {
  507. #ifdef LK_PROFILING
  508. unsigned int time_nand_emmc;
  509. unsigned int time_led_init;
  510. unsigned int time_env;
  511. unsigned int time_disp_init;
  512. unsigned int time_load_logo;
  513. unsigned int time_backlight;
  514. unsigned int time_boot_mode;
  515. #ifdef MTK_SECURITY_SW_SUPPORT
  516. unsigned int time_security_init;
  517. unsigned int time_logo_vfy;
  518. #endif
  519. unsigned int time_bat_init;
  520. unsigned int time_RTC_boot_Check;
  521. unsigned int time_show_logo;
  522. unsigned int time_sw_env;
  523. unsigned int time_platform_init;
  524. time_platform_init = get_timer(0);
  525. #endif
  526. u64 pl_start_addr = 0;
  527. plinfo_get_brom_header_block_size(&pl_start_addr);
  528. dprintf(CRITICAL," ==LK info ==\n");
  529. dprintf(CRITICAL," chip_code[0x%x]\n", mt_get_chip_hw_code());
  530. dprintf(CRITICAL," chip_ver[0x%x]\n", mt_get_chip_sw_ver());
  531. dprintf(CRITICAL," ==LK info ==\n");
  532. dprintf(CRITICAL, "platform_init()\n");
  533. #ifdef LK_PROFILING
  534. time_nand_emmc = get_timer(0);
  535. #endif
  536. #ifdef MTK_EMMC_SUPPORT
  537. mmc_legacy_init(1);
  538. #else
  539. #ifndef MACH_FPGA
  540. nand_init();
  541. nand_driver_test();
  542. #endif
  543. #endif
  544. #ifdef LK_PROFILING
  545. dprintf(INFO, "[PROFILE] ------- NAND/EMMC init takes %d ms -------- \n", (int)get_timer(time_nand_emmc));
  546. #endif
  547. extern void dummy_ap_entry(void)__attribute__((weak)); /* This is empty function for normal load */
  548. if (dummy_ap_entry)
  549. dummy_ap_entry();
  550. #ifdef MTK_AB_OTA_UPDATER
  551. /* get A/B system parameter before load dtb from boot image */
  552. get_AB_OTA_param();
  553. #endif
  554. /* The device tree should be loaded as early as possible. */
  555. load_device_tree();
  556. #ifndef MACH_FPGA
  557. #ifdef LK_PROFILING
  558. time_led_init = get_timer(0);
  559. #endif
  560. leds_init();
  561. #ifdef LK_PROFILING
  562. dprintf(INFO, "[PROFILE] ------- led init takes %d ms -------- \n", (int)get_timer(time_led_init));
  563. #endif
  564. #endif
  565. #ifdef MTK_KERNEL_POWER_OFF_CHARGING
  566. if ((g_boot_arg->boot_reason == BR_USB) && (upmu_is_chr_det() == KAL_FALSE)) {
  567. dprintf(INFO, "[%s] Unplugged Charger/Usb between Pre-loader and Uboot in Kernel Charging Mode, Power Off \n", __func__);
  568. mt6575_power_off();
  569. }
  570. #endif
  571. #ifdef LK_PROFILING
  572. time_env = get_timer(0);
  573. #endif
  574. env_init();
  575. print_env();
  576. #ifdef MTK_USB2JTAG_SUPPORT
  577. extern void usb2jtag_init(void);
  578. usb2jtag_init();
  579. #endif
  580. #ifdef LK_PROFILING
  581. dprintf(INFO, "[PROFILE] ------- ENV init takes %d ms -------- \n", (int)get_timer(time_env));
  582. #endif
  583. #ifdef LK_PROFILING
  584. time_disp_init = get_timer(0);
  585. #endif
  586. /* initialize the frame buffet information */
  587. #ifndef MACH_FPGA_NO_DISPLAY
  588. g_fb_size = mt_disp_get_vram_size();
  589. #else
  590. g_fb_size = 0x01800000;
  591. #endif
  592. #if 0
  593. g_fb_base = memory_size() - g_fb_size + DRAM_PHY_ADDR;
  594. #else
  595. #if 0
  596. if (g_is_64bit_kernel) {
  597. g_fb_base = mblock_reserve(&g_boot_arg->mblock_info, g_fb_size, 0x200000, 0x100000000, RANKMAX);
  598. g_fb_base = ALIGN_TO(g_fb_base,0x200000); // size 2MB align
  599. } else {
  600. g_fb_base = mblock_reserve(&g_boot_arg->mblock_info, g_fb_size, 0x100000, 0x100000000, RANKMAX);
  601. }
  602. #else
  603. g_fb_base = mblock_reserve_ext(&g_boot_arg->mblock_info, g_fb_size, 0x10000, 0x80000000, 0, "framebuffer");
  604. #endif
  605. if (!g_fb_base) {
  606. /* ERROR */
  607. }
  608. #endif
  609. dprintf(CRITICAL, "FB base = 0x%x, FB size = %d\n", g_fb_base, g_fb_size);
  610. #ifdef MBLOCK_TEST
  611. mblock_test();
  612. #endif
  613. #ifndef MACH_FPGA_NO_DISPLAY
  614. mt_disp_init((void *)g_fb_base);
  615. /* show black picture fisrtly in case of backlight is on before nothing is drawed*/
  616. mt_disp_fill_rect(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT, 0x0);
  617. mt_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);
  618. #ifdef LK_PROFILING
  619. dprintf(INFO, "[PROFILE] ------- disp init takes %d ms -------- \n", (int)get_timer(time_disp_init));
  620. #endif
  621. drv_video_init();
  622. #endif
  623. /*for kpd pmic mode setting*/
  624. set_kpd_pmic_mode();
  625. #ifndef MACH_FPGA
  626. #ifdef LK_PROFILING
  627. time_boot_mode = get_timer(0);
  628. #endif
  629. boot_mode_select();
  630. /* If RECOVERY_AS_BOOT is enabled, there is no recovery partition. */
  631. #if defined(CFG_DTB_EARLY_LOADER_SUPPORT) && !defined(RECOVERY_AS_BOOT)
  632. /* reload dtb when boot mode = recovery */
  633. if ((g_boot_mode == RECOVERY_BOOT) && (get_recovery_dtbo_loaded() != 1)){
  634. if (bldr_load_dtb("recovery") < 0)
  635. dprintf(CRITICAL, "bldr_load_dtb fail\n");
  636. }
  637. #endif // CFG_DTB_EARLY_LOADER_SUPPORT
  638. #ifdef LK_PROFILING
  639. dprintf(INFO, "[PROFILE] ------- boot mode select takes %d ms -------- \n", (int)get_timer(time_boot_mode));
  640. #endif
  641. #ifdef MTK_AEE_PLATFORM_DEBUG_SUPPORT
  642. /* init lastbus: MUST call after kedump (in boot_mode_select) */
  643. latch_lastbus_init();
  644. #endif
  645. #endif
  646. #ifndef MACH_FPGA_NO_DISPLAY
  647. #ifdef LK_PROFILING
  648. time_load_logo = get_timer(0);
  649. #endif
  650. mboot_common_load_logo((unsigned long)mt_get_logo_db_addr_pa(), "logo");
  651. #ifdef LK_PROFILING
  652. dprintf(INFO, "[PROFILE] ------- load_logo takes %d ms -------- \n", (int)get_timer(time_load_logo));
  653. #endif
  654. #endif
  655. #ifdef MTK_SECURITY_SW_SUPPORT
  656. #ifdef LK_PROFILING
  657. time_security_init = get_timer(0);
  658. #endif
  659. /* initialize security library */
  660. sec_func_init(pl_start_addr);
  661. #ifdef LK_PROFILING
  662. dprintf(INFO,"[PROFILE] ------- Security init takes %d ms -------- \n", (int)get_timer(time_security_init));
  663. #endif
  664. #ifdef LK_PROFILING
  665. time_logo_vfy = get_timer(0);
  666. #endif
  667. seclib_set_oemkey(g_oemkey, OEM_PUBK_SZ);
  668. if ( 0 != img_auth_stor("logo", "logo", 0x0) ) {
  669. dprintf(CRITICAL,"<ASSERT> %s:line %d\n",__FILE__,__LINE__);
  670. while (1);
  671. }
  672. if (DTBO_FROM_STANDALONE == get_dtbo_src()) {
  673. if (0 != img_auth_stor(get_dtbo_part_name(), "dtbo", 0x0)) {
  674. dprintf(CRITICAL,"<ASSERT> %s:line %d\n",__FILE__,__LINE__);
  675. while (1);
  676. }
  677. }
  678. #ifdef LK_PROFILING
  679. dprintf(INFO,"[PROFILE] ------- logo verify takes %d ms -------- \n", (int)get_timer(time_logo_vfy));
  680. #endif
  681. #endif
  682. /*Show download logo & message on screen */
  683. if (g_boot_arg->boot_mode == DOWNLOAD_BOOT) {
  684. dprintf(CRITICAL, "[LK] boot mode is DOWNLOAD_BOOT\n");
  685. #ifndef MACH_FPGA_NO_DISPLAY
  686. mt_disp_show_boot_logo();
  687. #endif
  688. video_printf(" => Downloading...\n");
  689. dprintf(CRITICAL, "enable backlight after show bootlogo! \n");
  690. #ifndef MACH_FPGA
  691. mt65xx_backlight_on();
  692. #endif
  693. //pwm need display sof
  694. mt_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);
  695. mtk_wdt_disable(); //Disable wdt before jump to DA
  696. platform_uninit();
  697. #ifdef HAVE_CACHE_PL310
  698. l2_disable();
  699. #endif
  700. arch_disable_cache(UCACHE);
  701. arch_disable_mmu();
  702. #ifdef ENABLE_L2_SHARING
  703. config_shared_SRAM_size();
  704. #endif
  705. jump_da(g_boot_arg->da_info.addr, g_boot_arg->da_info.arg1, g_boot_arg->da_info.arg2);
  706. }
  707. #ifdef LK_PROFILING
  708. time_bat_init = get_timer(0);
  709. #endif
  710. mt_pll_turn_off();
  711. mt65xx_bat_init();
  712. #ifdef LK_PROFILING
  713. dprintf(INFO, "[PROFILE] ------- battery init takes %d ms -------- \n", (int)get_timer(time_bat_init));
  714. #endif
  715. #ifndef CFG_POWER_CHARGING
  716. #ifdef LK_PROFILING
  717. time_RTC_boot_Check = get_timer(0);
  718. #endif
  719. /* NOTE: if define CFG_POWER_CHARGING, will rtc_boot_check() in mt65xx_bat_init() */
  720. rtc_boot_check(false);
  721. #ifdef LK_PROFILING
  722. dprintf(INFO, "[PROFILE] ------- RTC boot check Init takes %d ms -------- \n", (int)get_timer(time_RTC_boot_Check));
  723. #endif
  724. #endif
  725. #ifdef LK_PROFILING
  726. time_show_logo = get_timer(0);
  727. #endif
  728. #ifdef MTK_KERNEL_POWER_OFF_CHARGING
  729. if (kernel_charging_boot() == 1) {
  730. #ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
  731. CHARGER_TYPE CHR_Type_num = CHARGER_UNKNOWN;
  732. CHR_Type_num = hw_charging_get_charger_type();
  733. if ((g_boot_mode != LOW_POWER_OFF_CHARGING_BOOT) ||
  734. ((CHR_Type_num != STANDARD_HOST) && (CHR_Type_num != NONSTANDARD_CHARGER))) {
  735. #endif
  736. mt_disp_power(TRUE);
  737. mt_disp_show_low_battery();
  738. mt65xx_leds_brightness_set(6, 110);
  739. #ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
  740. }
  741. #endif
  742. } else if (g_boot_mode != KERNEL_POWER_OFF_CHARGING_BOOT && g_boot_mode != LOW_POWER_OFF_CHARGING_BOOT) {
  743. if (g_boot_mode != ALARM_BOOT && (g_boot_mode != FASTBOOT)) {
  744. #ifndef MACH_FPGA_NO_DISPLAY
  745. mt_disp_show_boot_logo();
  746. #endif
  747. }
  748. }
  749. #else
  750. if (g_boot_mode != ALARM_BOOT && (g_boot_mode != FASTBOOT)) {
  751. #ifndef MACH_FPGA_NO_DISPLAY
  752. mt_disp_show_boot_logo();
  753. #endif
  754. }
  755. #endif
  756. #ifdef LK_PROFILING
  757. time_backlight = get_timer(0);
  758. #endif
  759. #ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
  760. if (!is_low_battery(0)) {
  761. #endif
  762. #ifndef MACH_FPGA
  763. mt65xx_backlight_on();
  764. #endif
  765. #ifndef MACH_FPGA_NO_DISPLAY
  766. //pwm need display sof
  767. mt_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);
  768. #endif
  769. #ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
  770. }
  771. #endif
  772. #ifdef LK_PROFILING
  773. dprintf(INFO, "[PROFILE] ------- backlight takes %d ms -------- \n", (int)get_timer(time_backlight));
  774. #endif
  775. #ifdef LK_PROFILING
  776. dprintf(INFO, "[PROFILE] ------- show logo takes %d ms -------- \n", (int)get_timer(time_show_logo));
  777. #endif
  778. #ifndef MACH_FPGA
  779. #ifdef LK_PROFILING
  780. time_sw_env = get_timer(0);
  781. #endif
  782. sw_env();
  783. #ifdef LK_PROFILING
  784. dprintf(INFO, "[PROFILE] ------- sw_env takes %d ms -------- \n", (int)get_timer(time_sw_env));
  785. #endif
  786. #endif
  787. #ifdef LK_PROFILING
  788. dprintf(INFO, "[PROFILE] ------- platform_init takes %d ms -------- \n", (int)get_timer(time_platform_init));
  789. #endif
  790. }
  791. void platform_uninit(void)
  792. {
  793. #ifndef MACH_FPGA
  794. leds_deinit();
  795. #endif
  796. platform_deinit_interrupts();
  797. return;
  798. }
  799. #ifdef ENABLE_L2_SHARING
  800. #define ADDR_CA7L_CACHE_CONFIG_MP(x) (CA7MCUCFG_BASE + 0x200 * x)
  801. #define L2C_SIZE_CFG_OFFSET 8
  802. #define L2C_SHARE_EN_OFFSET 12
  803. /* 4'b1111: 2048KB(not support)
  804. * 4'b0111: 1024KB(not support)
  805. * 4'b0011: 512KB
  806. * 4'b0001: 256KB
  807. * 4'b0000: 128KB (not support)
  808. */
  809. int is_l2_need_config(void)
  810. {
  811. volatile unsigned int cache_cfg, addr;
  812. addr = ADDR_CA7L_CACHE_CONFIG_MP(0);
  813. cache_cfg = DRV_Reg32(addr);
  814. cache_cfg = cache_cfg >> L2C_SIZE_CFG_OFFSET;
  815. /* only read 256KB need to be config.*/
  816. if ((cache_cfg &(0x7)) == 0x1) {
  817. return 1;
  818. }
  819. return 0;
  820. }
  821. void cluster_l2_share_enable(int cluster)
  822. {
  823. volatile unsigned int cache_cfg, addr;
  824. addr = ADDR_CA7L_CACHE_CONFIG_MP(cluster);
  825. /* set L2C size to 256KB */
  826. cache_cfg = DRV_Reg32(addr);
  827. cache_cfg &= (~0x7) << L2C_SIZE_CFG_OFFSET;
  828. cache_cfg |= 0x1 << L2C_SIZE_CFG_OFFSET;
  829. /* enable L2C_share_en. Sram only for other to use*/
  830. cache_cfg |= (0x1 << L2C_SHARE_EN_OFFSET);
  831. DRV_WriteReg32(addr, cache_cfg);
  832. }
  833. void cluster_l2_share_disable(int cluster)
  834. {
  835. volatile unsigned int cache_cfg, addr;
  836. addr = ADDR_CA7L_CACHE_CONFIG_MP(cluster);
  837. /* set L2C size to 512KB */
  838. cache_cfg = DRV_Reg32(addr);
  839. cache_cfg &= (~0x7) << L2C_SIZE_CFG_OFFSET;
  840. cache_cfg |= 0x3 << L2C_SIZE_CFG_OFFSET;
  841. DRV_WriteReg32(addr, cache_cfg);
  842. /* disable L2C_share_en. Sram only for cpu to use*/
  843. cache_cfg &= ~(0x1 << L2C_SHARE_EN_OFFSET);
  844. DRV_WriteReg32(addr, cache_cfg);
  845. }
  846. /* config L2 cache and sram to its size */
  847. void config_L2_size(void)
  848. {
  849. int cluster;
  850. if (is_l2_need_config()) {
  851. /*
  852. * Becuase mcu config is protected.
  853. * only can write in secutity mode
  854. */
  855. if (dev_info_nr_cpu() == 6) {
  856. cluster_l2_share_disable(0);
  857. cluster_l2_share_enable(1);
  858. }
  859. else {
  860. for (cluster = 0; cluster < 2; cluster++) {
  861. cluster_l2_share_disable(cluster);
  862. }
  863. }
  864. }
  865. }
  866. /* config SRAM back from L2 cache for DA relocation */
  867. void config_shared_SRAM_size(void)
  868. {
  869. int cluster;
  870. if (is_l2_need_config()) {
  871. /*
  872. * Becuase mcu config is protected.
  873. * only can write in secutity mode
  874. */
  875. for (cluster = 0; cluster < 2; cluster++) {
  876. cluster_l2_share_enable(cluster);
  877. }
  878. }
  879. }
  880. #endif
  881. void platform_sec_post_init(void)
  882. {
  883. /* Lock Device APC in LK (wait to open after bring-up) */
  884. dprintf(CRITICAL, "[DEVAPC] sec_post_init\n");
  885. #if 1
  886. dprintf(CRITICAL, "[DEVAPC] platform_sec_post_init - SMC call to ATF from LK\n");
  887. mt_secure_call(0x82000101, 0, 0, 0);
  888. #endif
  889. }
  890. u32 get_devinfo_with_index(u32 index)
  891. {
  892. #ifdef MTK_FORCE_MODEL
  893. u32 segcode = 0;
  894. #endif
  895. #ifdef MTK_FORCE_MODEL
  896. if (index == 21) {
  897. segcode = (internal_get_devinfo_with_index(index) & 0xFFFFFF00) | (MTK_FORCE_MODEL & 0xFF);
  898. if ((MTK_FORCE_MODEL == 0xC1) || (MTK_FORCE_MODEL == 0xC2) || (MTK_FORCE_MODEL == 0xC5)
  899. || (MTK_FORCE_MODEL == 0xC6) || (MTK_FORCE_MODEL == 0x82) || (MTK_FORCE_MODEL == 0x86)) {
  900. segcode |= 0x00008000;
  901. }
  902. return segcode;
  903. }
  904. #endif
  905. return internal_get_devinfo_with_index(index);
  906. }
  907. int platform_skip_hibernation(void)
  908. {
  909. if (g_boot_menu == true)
  910. return 1;
  911. switch (g_boot_arg->boot_reason) {
  912. #if 0 // let schedule power on to go hiberantion bootup process
  913. case BR_RTC:
  914. #endif
  915. case BR_WDT:
  916. case BR_WDT_BY_PASS_PWK:
  917. case BR_WDT_SW:
  918. case BR_WDT_HW:
  919. return 1;
  920. }
  921. return 0;
  922. }