]>
Commit | Line | Data |
---|---|---|
36b8b5d3 FW |
1 | // SPDX-License-Identifier: GPL-2.0+ |
2 | /* | |
3 | * Copyright (C) 2019 Frank Wunderlich <[email protected]> | |
4 | */ | |
5 | ||
36b8b5d3 FW |
6 | #include <command.h> |
7 | #include <asm/io.h> | |
c05ed00a | 8 | #include <linux/delay.h> |
36b8b5d3 FW |
9 | |
10 | #define PWRAP_BASE 0x1000d000 | |
11 | #define PWRAP_WACS2_CMD 0x9c | |
12 | ||
13 | #define PWRAP_CALC(adr, wdata) ((1 << 31) | (((adr) >> 1) << 16) | (wdata)) | |
14 | ||
15 | #define MT6323_PWRC_BASE 0x8000 | |
16 | #define RTC_BBPU 0x0000 | |
17 | #define RTC_BBPU_KEY (0x43 << 8) | |
18 | #define RTC_WRTGR 0x003c | |
19 | ||
09140113 | 20 | int do_poweroff(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
36b8b5d3 FW |
21 | { |
22 | u32 addr, val; | |
23 | ||
24 | addr = PWRAP_BASE + PWRAP_WACS2_CMD; | |
25 | val = PWRAP_CALC(MT6323_PWRC_BASE + RTC_BBPU, RTC_BBPU_KEY); | |
26 | writel(val, addr); | |
27 | ||
28 | mdelay(10); | |
29 | ||
30 | val = PWRAP_CALC(MT6323_PWRC_BASE + RTC_WRTGR, 1); | |
31 | writel(val, addr); | |
32 | ||
33 | // wait some time and then print error | |
34 | mdelay(10000); | |
35 | printf("Failed to power off!!!\n"); | |
36 | return 1; | |
37 | } |