1 // SPDX-License-Identifier: GPL-2.0-only
3 * Hisilicon SoC reset code
5 * Copyright (c) 2014 Hisilicon Ltd.
6 * Copyright (c) 2014 Linaro Ltd.
8 * Author: Haojian Zhuang <haojian.zhuang@linaro.org>
11 #include <linux/delay.h>
13 #include <linux/module.h>
14 #include <linux/notifier.h>
15 #include <linux/of_address.h>
16 #include <linux/platform_device.h>
17 #include <linux/reboot.h>
19 #include <asm/proc-fns.h>
21 static void __iomem
*base
;
22 static u32 reboot_offset
;
24 static int hisi_restart_handler(struct notifier_block
*this,
25 unsigned long mode
, void *cmd
)
27 writel_relaxed(0xdeadbeef, base
+ reboot_offset
);
35 static struct notifier_block hisi_restart_nb
= {
36 .notifier_call
= hisi_restart_handler
,
40 static int hisi_reboot_probe(struct platform_device
*pdev
)
42 struct device_node
*np
= pdev
->dev
.of_node
;
45 base
= of_iomap(np
, 0);
47 WARN(1, "failed to map base address");
51 if (of_property_read_u32(np
, "reboot-offset", &reboot_offset
) < 0) {
52 pr_err("failed to find reboot-offset property\n");
57 err
= register_restart_handler(&hisi_restart_nb
);
59 dev_err(&pdev
->dev
, "cannot register restart handler (err=%d)\n",
67 static const struct of_device_id hisi_reboot_of_match
[] = {
68 { .compatible
= "hisilicon,sysctrl" },
72 static struct platform_driver hisi_reboot_driver
= {
73 .probe
= hisi_reboot_probe
,
75 .name
= "hisi-reboot",
76 .of_match_table
= hisi_reboot_of_match
,
79 module_platform_driver(hisi_reboot_driver
);