Skip to content

Commit b86d608

Browse files
committed
bsp:ls2k: add reboot and shutdown support
1 parent a8928c8 commit b86d608

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

bsp/ls2kdev/drivers/board.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
*/
2323
void rt_hw_cpu_reset(void)
2424
{
25+
WDT_EN = 0x01;
26+
WDT_TIMER = 0x01;
27+
WDT_SET = 0x01;
2528
rt_kprintf("reboot system...\n");
2629
while (1);
2730
}
@@ -32,6 +35,8 @@ void rt_hw_cpu_reset(void)
3235
*/
3336
void rt_hw_cpu_shutdown(void)
3437
{
38+
PM1_STS &= 0xffffffff;
39+
PM1_CNT = 0x3c00;
3540
rt_kprintf("shutdown...\n");
3641

3742
while (1);

bsp/ls2kdev/drivers/board.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,37 @@
1212
#define BOARD_H__
1313

1414
#include <stdint.h>
15+
#include <rthw.h>
16+
#include "ls2k1000.h"
1517

1618
extern unsigned char __bss_end;
1719

1820
#define CPU_HZ (1000 * 1000 * 1000) //QEMU 200*1000*1000
1921
#define RT_HW_HEAP_BEGIN (void*)&__bss_end
2022
#define RT_HW_HEAP_END (void*)(RT_HW_HEAP_BEGIN + 64 * 1024 * 1024)
2123

24+
/*
25+
* General PM Configuration Register
26+
*/
27+
#define PMCON_BASE (APB_BASE | (0x7 << 12))
28+
29+
/*
30+
* Power Management1 Configuration Registers
31+
*/
32+
#define PM1_BASE (PMCON_BASE + 0x0C)
33+
#define PM1_STS HWREG32(PM1_BASE)
34+
#define PM1_EN HWREG32(PM1_BASE + 0x04)
35+
#define PM1_CNT HWREG32(PM1_BASE + 0x08)
36+
37+
/*
38+
* Watch Dog Configuration Registers
39+
*/
40+
#define WDT_BASE (PMCON_BASE + 0x30)
41+
#define WDT_EN HWREG32(WDT_BASE)
42+
#define WDT_SET HWREG32(WDT_BASE + 0x04)
43+
#define WDT_TIMER HWREG32(WDT_BASE + 0x08)
44+
45+
2246
void rt_hw_board_init(void);
2347

2448
#endif

0 commit comments

Comments
 (0)