aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power/reset
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert+renesas@glider.be>2014-12-04 10:33:21 -0500
committerSebastian Reichel <sre@kernel.org>2015-01-21 10:32:05 -0500
commitfa0f8d670085745711da1fde727996d587a3a0d4 (patch)
treec9fe03ead3d8058e10654c6ea7ac974a55cda95b /drivers/power/reset
parent85cdf36e11557dc367c1361e4b7bb2c4619cae91 (diff)
power: reset: Add reset driver for R-Mobile platforms
Add a reset driver for Renesas R-Mobile and SH-Mobile SoCs. It registers a restart handler to trigger a soft power-on reset through the R-Mobile System Controller. The priority of this restart handler is 192, to allow a watchdog driver to use priority 128. Note that we do not use syscon-reboot, as the HPB (Peripheral Bus Bridge) semaphore should be acquired on systems where both the ARM and SH core are in use. The driver can be extended later to support this, when needed. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/power/reset')
-rw-r--r--drivers/power/reset/Kconfig6
-rw-r--r--drivers/power/reset/Makefile1
-rw-r--r--drivers/power/reset/rmobile-reset.c91
3 files changed, 98 insertions, 0 deletions
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
index 028e76504519..d743145e0001 100644
--- a/drivers/power/reset/Kconfig
+++ b/drivers/power/reset/Kconfig
@@ -159,5 +159,11 @@ config POWER_RESET_SYSCON
159 help 159 help
160 Reboot support for generic SYSCON mapped register reset. 160 Reboot support for generic SYSCON mapped register reset.
161 161
162config POWER_RESET_RMOBILE
163 tristate "Renesas R-Mobile reset driver"
164 depends on ARCH_RMOBILE || COMPILE_TEST
165 help
166 Reboot support for Renesas R-Mobile and SH-Mobile SoCs.
167
162endif 168endif
163 169
diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
index 1d4804d6b323..1631652009ac 100644
--- a/drivers/power/reset/Makefile
+++ b/drivers/power/reset/Makefile
@@ -18,3 +18,4 @@ obj-$(CONFIG_POWER_RESET_VEXPRESS) += vexpress-poweroff.o
18obj-$(CONFIG_POWER_RESET_XGENE) += xgene-reboot.o 18obj-$(CONFIG_POWER_RESET_XGENE) += xgene-reboot.o
19obj-$(CONFIG_POWER_RESET_KEYSTONE) += keystone-reset.o 19obj-$(CONFIG_POWER_RESET_KEYSTONE) += keystone-reset.o
20obj-$(CONFIG_POWER_RESET_SYSCON) += syscon-reboot.o 20obj-$(CONFIG_POWER_RESET_SYSCON) += syscon-reboot.o
21obj-$(CONFIG_POWER_RESET_RMOBILE) += rmobile-reset.o
diff --git a/drivers/power/reset/rmobile-reset.c b/drivers/power/reset/rmobile-reset.c
new file mode 100644
index 000000000000..e6569df76941
--- /dev/null
+++ b/drivers/power/reset/rmobile-reset.c
@@ -0,0 +1,91 @@
1/*
2 * Renesas R-Mobile Reset Driver
3 *
4 * Copyright (C) 2014 Glider bvba
5 *
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 */
10
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>
18
19/* SYSC Register Bank 2 */
20#define RESCNT2 0x20 /* Reset Control Register 2 */
21
22/* Reset Control Register 2 */
23#define RESCNT2_PRES 0x80000000 /* Soft power-on reset */
24
25static void __iomem *sysc_base2;
26
27static int rmobile_reset_handler(struct notifier_block *this,
28 unsigned long mode, void *cmd)
29{
30 pr_debug("%s %lu\n", __func__, mode);
31
32 /* Let's assume we have acquired the HPB semaphore */
33 writel(RESCNT2_PRES, sysc_base2 + RESCNT2);
34
35 return NOTIFY_DONE;
36}
37
38static struct notifier_block rmobile_reset_nb = {
39 .notifier_call = rmobile_reset_handler,
40 .priority = 192,
41};
42
43static int rmobile_reset_probe(struct platform_device *pdev)
44{
45 int error;
46
47 sysc_base2 = of_iomap(pdev->dev.of_node, 1);
48 if (!sysc_base2)
49 return -ENODEV;
50
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;
56 }
57
58 return 0;
59
60fail_unmap:
61 iounmap(sysc_base2);
62 return error;
63}
64
65static int rmobile_reset_remove(struct platform_device *pdev)
66{
67 unregister_restart_handler(&rmobile_reset_nb);
68 iounmap(sysc_base2);
69 return 0;
70}
71
72static const struct of_device_id rmobile_reset_of_match[] = {
73 { .compatible = "renesas,sysc-rmobile", },
74 { /* sentinel */ }
75};
76MODULE_DEVICE_TABLE(of, rmobile_reset_of_match);
77
78static 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,
84 },
85};
86
87module_platform_driver(rmobile_reset_driver);
88
89MODULE_DESCRIPTION("Renesas R-Mobile Reset Driver");
90MODULE_AUTHOR("Geert Uytterhoeven <geert+renesas@glider.be>");
91MODULE_LICENSE("GPL v2");