添加boot0获取唤醒源

This commit is contained in:
2025-02-24 17:04:54 +08:00
parent b10824bc07
commit 47d6d64341
5 changed files with 152 additions and 1 deletions

View File

@@ -13,6 +13,9 @@
#include <arch/dram.h>
#include <arch/rtc.h>
#include <arch/gpio.h>
#ifdef CFG_SET_BACKLIGHT
#include <arch/gpio_new.h>
#endif
#include <board_helper.h>
#include <config.h>
#include <boot_param.h>
@@ -41,8 +44,19 @@ void main(void)
rtos_base = 0, opensbi_base = 0, cpus_rtos_base = 0;
u16 pmu_type = 0, key_input = 0; /* TODO: set real value */
#ifdef CFG_SET_BACKLIGHT
normal_gpio_set_t gpio_bl;
#endif
#ifdef CFG_GET_WKSRC
normal_gpio_cfg M0_uart_gpio[2];
/* has_get_wksrc[10] = 0; 默认唤醒源是0 */
u8 has_get_wksrc[11] = {0xaa, 0x55, 0xaa, 0x55, 0x0e, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00}; // has get wake up source, len is 11
#ifdef CFG_WKSRC_ADDR
u8 *buff;
#endif
#endif
sunxi_board_init_early();
sunxi_serial_init(BT0_head.prvt_head.uart_port, (void *)BT0_head.prvt_head.uart_ctrl, 6);
sunxi_serial_init(BT0_head.prvt_head.uart_port, (void *)BT0_head.prvt_head.uart_ctrl, 2);
print_commit_log();
status = sunxi_board_init();
@@ -60,10 +74,46 @@ void main(void)
#endif
}
#ifdef CFG_SET_BACKLIGHT
/* gpio back light */
gpio_bl.port = SUNXI_GPIO_D; /*使用PD口*/
gpio_bl.port_num = 20; /*端口为20口*/
gpio_bl.mul_sel = SUNXI_GPIO_OUTPUT; /*配置为输出模式*/
gpio_bl.pull = SUNXI_GPIO_PULL_DISABLE; /*不配置默认上下拉*/
gpio_bl.drv_level = SUNXI_GPIO_DRV_LEVEL1; /*输出等级为1级*/
gpio_bl.data = 1; /*默认输出high电平*/
// gpio_bl.data = 0; /*默认输出low电平*/
if (boot_set_gpio_new(&gpio_bl, 1, 1) < 0)
{
pr_emerg("boot_set_gpio error\n");
}
#endif
#ifdef CFG_GET_WKSRC
/* init uart for M0 */
M0_uart_gpio[0] = BT0_head.prvt_head.uart_ctrl[0];
M0_uart_gpio[0].port = SUNXI_GPIO_D + 1; // ZZP:using API without _new needs to +1, please ref macro:PIO_REG_CFG
M0_uart_gpio[0].port_num = 18;
M0_uart_gpio[0].mul_sel = 7; // Multiplex funciton
M0_uart_gpio[1] = BT0_head.prvt_head.uart_ctrl[1];
M0_uart_gpio[1].port = SUNXI_GPIO_D + 1;
M0_uart_gpio[1].port_num = 19;
M0_uart_gpio[1].mul_sel = 7;
sunxi_serial_M0_init(2, (void *)M0_uart_gpio, 2); // UART2
if (has_sunxi_serial_M0_send(has_get_wksrc, sizeof(has_get_wksrc)) == sizeof(has_get_wksrc))
{
if (has_sunxi_serial_M0_get(has_get_wksrc, sizeof(has_get_wksrc)) != sizeof(has_get_wksrc))
{
has_get_wksrc[10] = 0; // 默认唤醒源是0
}
}
// pr_emerg("wksrc:%d\n", has_get_wksrc[10]);
#else
if (BT0_head.prvt_head.enable_jtag) {
printf("enable_jtag\n");
boot_set_gpio((normal_gpio_cfg *)BT0_head.prvt_head.jtag_gpio, 5, 1);
}
#endif
char uart_input_value = get_uart_input(); /* Prevent DRAM jamming */
if (uart_input_value == '2') {
@@ -88,6 +138,7 @@ void main(void)
handler_super_standby();
#endif
#ifndef CFG_GET_WKSRC
uart_input_value = get_uart_input();
if (uart_input_value == '2') {
sunxi_set_printf_debug_mode(3, 0);
@@ -100,6 +151,7 @@ void main(void)
printf("detected user input q\n");
sunxi_set_printf_debug_mode(0, 1);
}
#endif
mmu_enable(dram_size);
malloc_init(CONFIG_HEAP_BASE, CONFIG_HEAP_SIZE);
@@ -123,6 +175,14 @@ void main(void)
update_uboot_info(uboot_base, optee_base, monitor_base, rtos_base, dram_size,
pmu_type, uart_input_value, key_input);
#ifdef CFG_GET_WKSRC
#ifdef CFG_WKSRC_ADDR
/* must operate after dram init */
buff = (u8 *)CFG_WKSRC_ADDR;
buff[0] = has_get_wksrc[10];
#endif
#endif
#if CFG_BOOT0_LOAD_KERNEL
exist_uboot_jmp_cardproduct(uboot_base);
void load_and_run_kernel(u32 optee_base, u32 opensbi_base, u32 monitor_base);