0001
0002
0003
0004
0005
0006
0007
0008 #include <linux/io.h>
0009 #include <linux/module.h>
0010 #include <linux/notifier.h>
0011 #include <linux/of_address.h>
0012 #include <linux/platform_device.h>
0013 #include <linux/printk.h>
0014 #include <linux/reboot.h>
0015
0016
0017 #define RESCNT2 0x20
0018
0019
0020 #define RESCNT2_PRES 0x80000000
0021
0022 static void __iomem *sysc_base2;
0023
0024 static int rmobile_reset_handler(struct notifier_block *this,
0025 unsigned long mode, void *cmd)
0026 {
0027 pr_debug("%s %lu\n", __func__, mode);
0028
0029
0030 writel(RESCNT2_PRES, sysc_base2 + RESCNT2);
0031
0032 return NOTIFY_DONE;
0033 }
0034
0035 static struct notifier_block rmobile_reset_nb = {
0036 .notifier_call = rmobile_reset_handler,
0037 .priority = 192,
0038 };
0039
0040 static int rmobile_reset_probe(struct platform_device *pdev)
0041 {
0042 int error;
0043
0044 sysc_base2 = of_iomap(pdev->dev.of_node, 1);
0045 if (!sysc_base2)
0046 return -ENODEV;
0047
0048 error = register_restart_handler(&rmobile_reset_nb);
0049 if (error) {
0050 dev_err(&pdev->dev,
0051 "cannot register restart handler (err=%d)\n", error);
0052 goto fail_unmap;
0053 }
0054
0055 return 0;
0056
0057 fail_unmap:
0058 iounmap(sysc_base2);
0059 return error;
0060 }
0061
0062 static int rmobile_reset_remove(struct platform_device *pdev)
0063 {
0064 unregister_restart_handler(&rmobile_reset_nb);
0065 iounmap(sysc_base2);
0066 return 0;
0067 }
0068
0069 static const struct of_device_id rmobile_reset_of_match[] = {
0070 { .compatible = "renesas,sysc-rmobile", },
0071 { }
0072 };
0073 MODULE_DEVICE_TABLE(of, rmobile_reset_of_match);
0074
0075 static struct platform_driver rmobile_reset_driver = {
0076 .probe = rmobile_reset_probe,
0077 .remove = rmobile_reset_remove,
0078 .driver = {
0079 .name = "rmobile_reset",
0080 .of_match_table = rmobile_reset_of_match,
0081 },
0082 };
0083
0084 module_platform_driver(rmobile_reset_driver);
0085
0086 MODULE_DESCRIPTION("Renesas R-Mobile Reset Driver");
0087 MODULE_AUTHOR("Geert Uytterhoeven <geert+renesas@glider.be>");
0088 MODULE_LICENSE("GPL v2");