diff options
author | Frank Wunderlich | 2019-11-22 15:32:24 +0100 |
---|---|---|
committer | Tom Rini | 2020-01-10 10:25:13 -0500 |
commit | 36b8b5d3adf7f8de6e5692c21b23a980da50884c (patch) | |
tree | 4ebb5d283925be3390a98a0d187b1599fac864ee /drivers/power/mt6323.c | |
parent | 0b326fc296435ce27aa41320b6f7eb9266da39ef (diff) |
poweroff: add poweroff for mt6323 pmic
this adds poweroff to bananapi r2 / mt7623 / mt6323 pmic
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
Diffstat (limited to 'drivers/power/mt6323.c')
-rw-r--r-- | drivers/power/mt6323.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/drivers/power/mt6323.c b/drivers/power/mt6323.c new file mode 100644 index 00000000000..566be5f39e5 --- /dev/null +++ b/drivers/power/mt6323.c @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2019 Frank Wunderlich <frank-w@public-files.de> + */ + +#include <common.h> +#include <command.h> +#include <asm/io.h> + +#define PWRAP_BASE 0x1000d000 +#define PWRAP_WACS2_CMD 0x9c + +#define PWRAP_CALC(adr, wdata) ((1 << 31) | (((adr) >> 1) << 16) | (wdata)) + +#define MT6323_PWRC_BASE 0x8000 +#define RTC_BBPU 0x0000 +#define RTC_BBPU_KEY (0x43 << 8) +#define RTC_WRTGR 0x003c + +int do_poweroff(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + u32 addr, val; + + addr = PWRAP_BASE + PWRAP_WACS2_CMD; + val = PWRAP_CALC(MT6323_PWRC_BASE + RTC_BBPU, RTC_BBPU_KEY); + writel(val, addr); + + mdelay(10); + + val = PWRAP_CALC(MT6323_PWRC_BASE + RTC_WRTGR, 1); + writel(val, addr); + + // wait some time and then print error + mdelay(10000); + printf("Failed to power off!!!\n"); + return 1; +} |