2 * Renesas R-Mobile Reset Driver
4 * Copyright (C) 2014 Glider bvba
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
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/printk.h>
17 #include <linux/reboot.h>
19 /* SYSC Register Bank 2 */
20 #define RESCNT2 0x20 /* Reset Control Register 2 */
22 /* Reset Control Register 2 */
23 #define RESCNT2_PRES 0x80000000 /* Soft power-on reset */
25 static void __iomem
*sysc_base2
;
27 static int rmobile_reset_handler(struct notifier_block
*this,
28 unsigned long mode
, void *cmd
)
30 pr_debug("%s %lu\n", __func__
, mode
);
32 /* Let's assume we have acquired the HPB semaphore */
33 writel(RESCNT2_PRES
, sysc_base2
+ RESCNT2
);
38 static struct notifier_block rmobile_reset_nb
= {
39 .notifier_call
= rmobile_reset_handler
,
43 static int rmobile_reset_probe(struct platform_device
*pdev
)
47 sysc_base2
= of_iomap(pdev
->dev
.of_node
, 1);
51 error
= register_restart_handler(&rmobile_reset_nb
);
54 "cannot register restart handler (err=%d)\n", error
);
65 static int rmobile_reset_remove(struct platform_device
*pdev
)
67 unregister_restart_handler(&rmobile_reset_nb
);
72 static const struct of_device_id rmobile_reset_of_match
[] = {
73 { .compatible
= "renesas,sysc-rmobile", },
76 MODULE_DEVICE_TABLE(of
, rmobile_reset_of_match
);
78 static struct platform_driver rmobile_reset_driver
= {
79 .probe
= rmobile_reset_probe
,
80 .remove
= rmobile_reset_remove
,
82 .name
= "rmobile_reset",
83 .of_match_table
= rmobile_reset_of_match
,
87 module_platform_driver(rmobile_reset_driver
);
89 MODULE_DESCRIPTION("Renesas R-Mobile Reset Driver");
90 MODULE_AUTHOR("Geert Uytterhoeven <geert+renesas@glider.be>");
91 MODULE_LICENSE("GPL v2");