1 // SPDX-License-Identifier: GPL-2.0-only
3 * ZTE zx296702 SoC reset code
5 * Copyright (c) 2015 Linaro Ltd.
7 * Author: Jun Nie <jun.nie@linaro.org>
10 #include <linux/delay.h>
12 #include <linux/module.h>
13 #include <linux/notifier.h>
14 #include <linux/of_address.h>
15 #include <linux/platform_device.h>
16 #include <linux/reboot.h>
18 static void __iomem
*base
;
19 static void __iomem
*pcu_base
;
21 static int zx_restart_handler(struct notifier_block
*this,
22 unsigned long mode
, void *cmd
)
24 writel_relaxed(1, base
+ 0xb0);
25 writel_relaxed(1, pcu_base
+ 0x34);
28 pr_emerg("Unable to restart system\n");
33 static struct notifier_block zx_restart_nb
= {
34 .notifier_call
= zx_restart_handler
,
38 static int zx_reboot_probe(struct platform_device
*pdev
)
40 struct device_node
*np
= pdev
->dev
.of_node
;
43 base
= of_iomap(np
, 0);
45 WARN(1, "failed to map base address");
49 np
= of_find_compatible_node(NULL
, NULL
, "zte,zx296702-pcu");
50 pcu_base
= of_iomap(np
, 0);
54 WARN(1, "failed to map pcu_base address");
58 err
= register_restart_handler(&zx_restart_nb
);
62 dev_err(&pdev
->dev
, "Register restart handler failed(err=%d)\n",
69 static const struct of_device_id zx_reboot_of_match
[] = {
70 { .compatible
= "zte,sysctrl" },
73 MODULE_DEVICE_TABLE(of
, zx_reboot_of_match
);
75 static struct platform_driver zx_reboot_driver
= {
76 .probe
= zx_reboot_probe
,
79 .of_match_table
= zx_reboot_of_match
,
82 module_platform_driver(zx_reboot_driver
);
84 MODULE_DESCRIPTION("ZTE SoCs reset driver");
85 MODULE_AUTHOR("Jun Nie <jun.nie@linaro.org>");
86 MODULE_LICENSE("GPL v2");