dm thin metadata: fix __udivdi3 undefined on 32-bit
[linux/fpc-iii.git] / drivers / power / reset / rmobile-reset.c
blobe6569df76941afa649563651c037aa27939b9e01
1 /*
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
8 * for more details.
9 */
11 #include <linux/io.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/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);
35 return NOTIFY_DONE;
38 static struct notifier_block rmobile_reset_nb = {
39 .notifier_call = rmobile_reset_handler,
40 .priority = 192,
43 static int rmobile_reset_probe(struct platform_device *pdev)
45 int error;
47 sysc_base2 = of_iomap(pdev->dev.of_node, 1);
48 if (!sysc_base2)
49 return -ENODEV;
51 error = register_restart_handler(&rmobile_reset_nb);
52 if (error) {
53 dev_err(&pdev->dev,
54 "cannot register restart handler (err=%d)\n", error);
55 goto fail_unmap;
58 return 0;
60 fail_unmap:
61 iounmap(sysc_base2);
62 return error;
65 static int rmobile_reset_remove(struct platform_device *pdev)
67 unregister_restart_handler(&rmobile_reset_nb);
68 iounmap(sysc_base2);
69 return 0;
72 static const struct of_device_id rmobile_reset_of_match[] = {
73 { .compatible = "renesas,sysc-rmobile", },
74 { /* sentinel */ }
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,
81 .driver = {
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");