mt6323.c 866 B

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