Skip to content

Commit ab78ea1

Browse files
committed
bsp:ls2k:improved implement of shutdown and reboot command
1 parent 623bf0a commit ab78ea1

File tree

4 files changed

+28
-50
lines changed

4 files changed

+28
-50
lines changed

bsp/ls2kdev/applications/pmcon.c

Lines changed: 0 additions & 26 deletions
This file was deleted.

bsp/ls2kdev/drivers/board.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include "exception.h"
1717
#include "drv_uart.h"
1818
#include "board.h"
19+
#include "ls2k1000.h"
20+
1921
/**
2022
* this function will reset CPU
2123
*
@@ -28,6 +30,8 @@ void rt_hw_cpu_reset(void)
2830
rt_kprintf("reboot system...\n");
2931
while (1);
3032
}
33+
MSH_CMD_EXPORT_ALIAS(rt_hw_cpu_reset, reboot, reset cpu);
34+
3135

3236
/**
3337
* this function will shutdown CPU
@@ -41,6 +45,7 @@ void rt_hw_cpu_shutdown(void)
4145

4246
while (1);
4347
}
48+
MSH_CMD_EXPORT_ALIAS(rt_hw_cpu_shutdown, poweroff, shutdown cpu);
4449

4550

4651
/**

bsp/ls2kdev/drivers/board.h

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

1414
#include <stdint.h>
15-
#include <rthw.h>
16-
#include "ls2k1000.h"
1715

1816
extern unsigned char __bss_end;
1917

2018
#define CPU_HZ (1000 * 1000 * 1000) //QEMU 200*1000*1000
2119
#define RT_HW_HEAP_BEGIN (void*)&__bss_end
2220
#define RT_HW_HEAP_END (void*)(RT_HW_HEAP_BEGIN + 64 * 1024 * 1024)
2321

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-
4622
void rt_hw_board_init(void);
4723

4824
#endif

bsp/ls2kdev/drivers/ls2k1000.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <mips.h>
55
#include "interrupt.h"
6+
#include <rthw.h>
67

78
#define APB_BASE CKSEG1ADDR(0xbfe00000)
89

@@ -24,6 +25,28 @@
2425

2526
#define GEN_CONFIG0_REG (0xFFFFFFFFBfe10420)
2627

28+
29+
/*
30+
* General PM Configuration Register
31+
*/
32+
#define PMCON_BASE (APB_BASE | (0x7 << 12))
33+
34+
/*
35+
* Power Management1 Configuration Registers
36+
*/
37+
#define PM1_BASE (PMCON_BASE + 0x0C)
38+
#define PM1_STS HWREG32(PM1_BASE)
39+
#define PM1_EN HWREG32(PM1_BASE + 0x04)
40+
#define PM1_CNT HWREG32(PM1_BASE + 0x08)
41+
42+
/*
43+
* Watch Dog Configuration Registers
44+
*/
45+
#define WDT_BASE (PMCON_BASE + 0x30)
46+
#define WDT_EN HWREG32(WDT_BASE)
47+
#define WDT_SET HWREG32(WDT_BASE + 0x04)
48+
#define WDT_TIMER HWREG32(WDT_BASE + 0x08)
49+
2750
void rt_hw_timer_handler(void);
2851
void rt_hw_uart_init(void);
2952

0 commit comments

Comments
 (0)