• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2022 Beken Corporation
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <common/bk_include.h>
16 #include <components/log.h>
17 #include <common/bk_err.h>
18 #include <components/system.h>
19 #include <driver/wdt.h>
20 #include "bk_misc.h"
21 #include "reset_reason.h"
22 #include "drv_model_pub.h"
23 #include "param_config.h"
24 #include "aon_pmu_driver.h"
25 
26 #define TAG "sys"
27 
28 extern volatile unsigned int g_enter_exception;
29 
bk_reboot(void)30 void bk_reboot(void)
31 {
32 	UINT32 wdt_val = 5;
33 
34 	BK_LOGI(TAG, "bk_reboot\r\n");
35 
36 #if (CONFIG_SOC_BK7256XX)
37 	set_reboot_tag(REBOOT_TAG_REQ);
38 	g_enter_exception = 1;
39 #endif
40 #if (CONFIG_SYSTEM_CTRL)
41 	uint32_t param =0;
42 	param = aon_pmu_drv_reg_get(PMU_REG0x41);
43 	param &= ~0x3; //select clk_DIVD as lpo_src
44 	aon_pmu_drv_reg_set(PMU_REG0x41,param);
45 	aon_pmu_drv_wdt_rst_dev_enable();
46 #endif
47 	bk_misc_update_set_type(RESET_SOURCE_REBOOT);
48 
49 	GLOBAL_INT_DECLARATION();
50 
51 	GLOBAL_INT_DISABLE();
52 
53 	bk_wdt_stop();
54 	BK_LOGI(TAG, "wdt reboot\r\n");
55 #if (CONFIG_SOC_BK7231N) || (CONFIG_SOC_BK7236A) || (CONFIG_SOC_BK7256XX)
56 	delay_ms(100); //add delay for bk_writer BEKEN_DO_REBOOT cmd
57 #endif
58 	bk_wdt_start(wdt_val);
59 	while (1);
60 	GLOBAL_INT_RESTORE();
61 }
62