1 // SPDX-License-Identifier: GPL-2.0
3 * Renesas R-Mobile Reset Driver
5 * Copyright (C) 2014 Glider bvba
9 #include <linux/module.h>
10 #include <linux/notifier.h>
11 #include <linux/of_address.h>
12 #include <linux/platform_device.h>
13 #include <linux/printk.h>
14 #include <linux/reboot.h>
16 /* SYSC Register Bank 2 */
17 #define RESCNT2 0x20 /* Reset Control Register 2 */
19 /* Reset Control Register 2 */
20 #define RESCNT2_PRES 0x80000000 /* Soft power-on reset */
22 static void __iomem *sysc_base2;
24 static int rmobile_reset_handler(struct notifier_block *this,
25 unsigned long mode, void *cmd)
27 pr_debug("%s %lu\n", __func__, mode);
29 /* Let's assume we have acquired the HPB semaphore */
30 writel(RESCNT2_PRES, sysc_base2 + RESCNT2);
35 static struct notifier_block rmobile_reset_nb = {
36 .notifier_call = rmobile_reset_handler,
40 static int rmobile_reset_probe(struct platform_device *pdev)
44 sysc_base2 = of_iomap(pdev->dev.of_node, 1);
48 error = register_restart_handler(&rmobile_reset_nb);
51 "cannot register restart handler (err=%d)\n", error);
62 static int rmobile_reset_remove(struct platform_device *pdev)
64 unregister_restart_handler(&rmobile_reset_nb);
69 static const struct of_device_id rmobile_reset_of_match[] = {
70 { .compatible = "renesas,sysc-rmobile", },
73 MODULE_DEVICE_TABLE(of, rmobile_reset_of_match);
75 static struct platform_driver rmobile_reset_driver = {
76 .probe = rmobile_reset_probe,
77 .remove = rmobile_reset_remove,
79 .name = "rmobile_reset",
80 .of_match_table = rmobile_reset_of_match,
84 module_platform_driver(rmobile_reset_driver);
86 MODULE_DESCRIPTION("Renesas R-Mobile Reset Driver");
87 MODULE_AUTHOR("Geert Uytterhoeven <geert+renesas@glider.be>");
88 MODULE_LICENSE("GPL v2");