1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2019 Frank Wunderlich <frank-w@public-files.de>
9 #include <linux/delay.h>
11 #define PWRAP_BASE 0x1000d000
12 #define PWRAP_WACS2_CMD 0x9c
14 #define PWRAP_CALC(adr, wdata) ((1 << 31) | (((adr) >> 1) << 16) | (wdata))
16 #define MT6323_PWRC_BASE 0x8000
17 #define RTC_BBPU 0x0000
18 #define RTC_BBPU_KEY (0x43 << 8)
19 #define RTC_WRTGR 0x003c
21 int do_poweroff(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
25 addr = PWRAP_BASE + PWRAP_WACS2_CMD;
26 val = PWRAP_CALC(MT6323_PWRC_BASE + RTC_BBPU, RTC_BBPU_KEY);
31 val = PWRAP_CALC(MT6323_PWRC_BASE + RTC_WRTGR, 1);
34 // wait some time and then print error
36 printf("Failed to power off!!!\n");