powerpc/fadump: Do not allow hot-remove memory from fadump reserved area.
[linux/fpc-iii.git] / drivers / power / reset / zx-reboot.c
blob186901c96c01769ee5b6f87dc17d57e0df44517d
1 /*
2 * ZTE zx296702 SoC reset code
4 * Copyright (c) 2015 Linaro Ltd.
6 * Author: Jun Nie <jun.nie@linaro.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/delay.h>
14 #include <linux/io.h>
15 #include <linux/module.h>
16 #include <linux/notifier.h>
17 #include <linux/of_address.h>
18 #include <linux/platform_device.h>
19 #include <linux/reboot.h>
21 static void __iomem *base;
22 static void __iomem *pcu_base;
24 static int zx_restart_handler(struct notifier_block *this,
25 unsigned long mode, void *cmd)
27 writel_relaxed(1, base + 0xb0);
28 writel_relaxed(1, pcu_base + 0x34);
30 mdelay(50);
31 pr_emerg("Unable to restart system\n");
33 return NOTIFY_DONE;
36 static struct notifier_block zx_restart_nb = {
37 .notifier_call = zx_restart_handler,
38 .priority = 128,
41 static int zx_reboot_probe(struct platform_device *pdev)
43 struct device_node *np = pdev->dev.of_node;
44 int err;
46 base = of_iomap(np, 0);
47 if (!base) {
48 WARN(1, "failed to map base address");
49 return -ENODEV;
52 np = of_find_compatible_node(NULL, NULL, "zte,zx296702-pcu");
53 pcu_base = of_iomap(np, 0);
54 of_node_put(np);
55 if (!pcu_base) {
56 iounmap(base);
57 WARN(1, "failed to map pcu_base address");
58 return -ENODEV;
61 err = register_restart_handler(&zx_restart_nb);
62 if (err) {
63 iounmap(base);
64 iounmap(pcu_base);
65 dev_err(&pdev->dev, "Register restart handler failed(err=%d)\n",
66 err);
69 return err;
72 static const struct of_device_id zx_reboot_of_match[] = {
73 { .compatible = "zte,sysctrl" },
76 MODULE_DEVICE_TABLE(of, zx_reboot_of_match);
78 static struct platform_driver zx_reboot_driver = {
79 .probe = zx_reboot_probe,
80 .driver = {
81 .name = "zx-reboot",
82 .of_match_table = zx_reboot_of_match,
85 module_platform_driver(zx_reboot_driver);
87 MODULE_DESCRIPTION("ZTE SoCs reset driver");
88 MODULE_AUTHOR("Jun Nie <jun.nie@linaro.org>");
89 MODULE_LICENSE("GPL v2");