From b86d608d631d5d50f51e202d8e28107b2dd69f9a Mon Sep 17 00:00:00 2001 From: michael Date: Tue, 15 Sep 2020 11:20:15 +0800 Subject: [PATCH] bsp:ls2k: add reboot and shutdown support --- bsp/ls2kdev/drivers/board.c | 5 +++++ bsp/ls2kdev/drivers/board.h | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/bsp/ls2kdev/drivers/board.c b/bsp/ls2kdev/drivers/board.c index 6a66777121..f970e60574 100644 --- a/bsp/ls2kdev/drivers/board.c +++ b/bsp/ls2kdev/drivers/board.c @@ -22,6 +22,9 @@ */ void rt_hw_cpu_reset(void) { + WDT_EN = 0x01; + WDT_TIMER = 0x01; + WDT_SET = 0x01; rt_kprintf("reboot system...\n"); while (1); } @@ -32,6 +35,8 @@ void rt_hw_cpu_reset(void) */ void rt_hw_cpu_shutdown(void) { + PM1_STS &= 0xffffffff; + PM1_CNT = 0x3c00; rt_kprintf("shutdown...\n"); while (1); diff --git a/bsp/ls2kdev/drivers/board.h b/bsp/ls2kdev/drivers/board.h index ca57ebf3f2..3c9347931c 100644 --- a/bsp/ls2kdev/drivers/board.h +++ b/bsp/ls2kdev/drivers/board.h @@ -12,6 +12,8 @@ #define BOARD_H__ #include +#include +#include "ls2k1000.h" extern unsigned char __bss_end; @@ -19,6 +21,28 @@ extern unsigned char __bss_end; #define RT_HW_HEAP_BEGIN (void*)&__bss_end #define RT_HW_HEAP_END (void*)(RT_HW_HEAP_BEGIN + 64 * 1024 * 1024) +/* + * General PM Configuration Register + */ +#define PMCON_BASE (APB_BASE | (0x7 << 12)) + +/* + * Power Management1 Configuration Registers + */ +#define PM1_BASE (PMCON_BASE + 0x0C) +#define PM1_STS HWREG32(PM1_BASE) +#define PM1_EN HWREG32(PM1_BASE + 0x04) +#define PM1_CNT HWREG32(PM1_BASE + 0x08) + +/* + * Watch Dog Configuration Registers + */ +#define WDT_BASE (PMCON_BASE + 0x30) +#define WDT_EN HWREG32(WDT_BASE) +#define WDT_SET HWREG32(WDT_BASE + 0x04) +#define WDT_TIMER HWREG32(WDT_BASE + 0x08) + + void rt_hw_board_init(void); #endif