reset.c 878 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. *
  4. * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  5. * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  6. * Copyright (C) 2013 John Crispin <john@phrozen.org>
  7. */
  8. #include <linux/pm.h>
  9. #include <linux/io.h>
  10. #include <linux/of.h>
  11. #include <linux/delay.h>
  12. #include <asm/reboot.h>
  13. #include <asm/mach-ralink/ralink_regs.h>
  14. /* Reset Control */
  15. #define SYSC_REG_RESET_CTRL 0x034
  16. #define RSTCTL_RESET_PCI BIT(26)
  17. #define RSTCTL_RESET_SYSTEM BIT(0)
  18. static void ralink_restart(char *command)
  19. {
  20. if (IS_ENABLED(CONFIG_PCI)) {
  21. rt_sysc_m32(0, RSTCTL_RESET_PCI, SYSC_REG_RESET_CTRL);
  22. mdelay(50);
  23. }
  24. local_irq_disable();
  25. rt_sysc_w32(RSTCTL_RESET_SYSTEM, SYSC_REG_RESET_CTRL);
  26. unreachable();
  27. }
  28. static int __init mips_reboot_setup(void)
  29. {
  30. _machine_restart = ralink_restart;
  31. return 0;
  32. }
  33. arch_initcall(mips_reboot_setup);