hisi-reboot.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Hisilicon SoC reset code
  3. *
  4. * Copyright (c) 2014 Hisilicon Ltd.
  5. * Copyright (c) 2014 Linaro Ltd.
  6. *
  7. * Author: Haojian Zhuang <haojian.zhuang@linaro.org>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/delay.h>
  14. #include <linux/io.h>
  15. #include <linux/module.h>
  16. #include <linux/of_address.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/reboot.h>
  19. #include <asm/proc-fns.h>
  20. #include <asm/system_misc.h>
  21. static void __iomem *base;
  22. static u32 reboot_offset;
  23. static void hisi_restart(enum reboot_mode mode, const char *cmd)
  24. {
  25. writel_relaxed(0xdeadbeef, base + reboot_offset);
  26. while (1)
  27. cpu_do_idle();
  28. }
  29. static int hisi_reboot_probe(struct platform_device *pdev)
  30. {
  31. struct device_node *np = pdev->dev.of_node;
  32. base = of_iomap(np, 0);
  33. if (!base) {
  34. WARN(1, "failed to map base address");
  35. return -ENODEV;
  36. }
  37. if (of_property_read_u32(np, "reboot-offset", &reboot_offset) < 0) {
  38. pr_err("failed to find reboot-offset property\n");
  39. return -EINVAL;
  40. }
  41. arm_pm_restart = hisi_restart;
  42. return 0;
  43. }
  44. static struct of_device_id hisi_reboot_of_match[] = {
  45. { .compatible = "hisilicon,sysctrl" },
  46. {}
  47. };
  48. static struct platform_driver hisi_reboot_driver = {
  49. .probe = hisi_reboot_probe,
  50. .driver = {
  51. .name = "hisi-reboot",
  52. .of_match_table = hisi_reboot_of_match,
  53. },
  54. };
  55. module_platform_driver(hisi_reboot_driver);