diff options
| author | Jun Nie <jun.nie@linaro.org> | 2015-07-14 23:25:58 -0400 |
|---|---|---|
| committer | Sebastian Reichel <sre@kernel.org> | 2015-07-24 11:29:17 -0400 |
| commit | dd9f1486ae207cd947416f1bdc461edc4880f2df (patch) | |
| tree | 56c6a07438fb850778b4df3b1a53bdd7cccb4284 /drivers/power/reset | |
| parent | 377b641ac84c573bcea06aec47f7ad1ba4047e1c (diff) | |
power/reset: zx: Register restart handler
Register with kernel restart handler instead of setting arm_pm_restart
directly.
Signed-off-by: Jun Nie <jun.nie@linaro.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/power/reset')
| -rw-r--r-- | drivers/power/reset/Kconfig | 7 | ||||
| -rw-r--r-- | drivers/power/reset/Makefile | 1 | ||||
| -rw-r--r-- | drivers/power/reset/zx-reboot.c | 82 |
3 files changed, 90 insertions, 0 deletions
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig index 17d93a73c513..5a0189bf19bb 100644 --- a/drivers/power/reset/Kconfig +++ b/drivers/power/reset/Kconfig | |||
| @@ -166,5 +166,12 @@ config POWER_RESET_RMOBILE | |||
| 166 | help | 166 | help |
| 167 | Reboot support for Renesas R-Mobile and SH-Mobile SoCs. | 167 | Reboot support for Renesas R-Mobile and SH-Mobile SoCs. |
| 168 | 168 | ||
| 169 | config POWER_RESET_ZX | ||
| 170 | tristate "ZTE SoCs reset driver" | ||
| 171 | depends on ARCH_ZX || COMPILE_TEST | ||
| 172 | depends on HAS_IOMEM | ||
| 173 | help | ||
| 174 | Reboot support for ZTE SoCs. | ||
| 175 | |||
| 169 | endif | 176 | endif |
| 170 | 177 | ||
diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile index dbe06c368743..096fa67047f6 100644 --- a/drivers/power/reset/Makefile +++ b/drivers/power/reset/Makefile | |||
| @@ -19,3 +19,4 @@ obj-$(CONFIG_POWER_RESET_KEYSTONE) += keystone-reset.o | |||
| 19 | obj-$(CONFIG_POWER_RESET_SYSCON) += syscon-reboot.o | 19 | obj-$(CONFIG_POWER_RESET_SYSCON) += syscon-reboot.o |
| 20 | obj-$(CONFIG_POWER_RESET_SYSCON_POWEROFF) += syscon-poweroff.o | 20 | obj-$(CONFIG_POWER_RESET_SYSCON_POWEROFF) += syscon-poweroff.o |
| 21 | obj-$(CONFIG_POWER_RESET_RMOBILE) += rmobile-reset.o | 21 | obj-$(CONFIG_POWER_RESET_RMOBILE) += rmobile-reset.o |
| 22 | obj-$(CONFIG_POWER_RESET_ZX) += zx-reboot.o | ||
diff --git a/drivers/power/reset/zx-reboot.c b/drivers/power/reset/zx-reboot.c new file mode 100644 index 000000000000..cf4b973dcedf --- /dev/null +++ b/drivers/power/reset/zx-reboot.c | |||
| @@ -0,0 +1,82 @@ | |||
| 1 | /* | ||
| 2 | * ZTE zx296702 SoC reset code | ||
| 3 | * | ||
| 4 | * Copyright (c) 2015 Linaro Ltd. | ||
| 5 | * | ||
| 6 | * Author: Jun Nie <jun.nie@linaro.org> | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify | ||
| 9 | * it under the terms of the GNU General Public License version 2 as | ||
| 10 | * published by the Free Software Foundation. | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include <linux/delay.h> | ||
| 14 | #include <linux/io.h> | ||
| 15 | #include <linux/module.h> | ||
| 16 | #include <linux/notifier.h> | ||
| 17 | #include <linux/of_address.h> | ||
| 18 | #include <linux/platform_device.h> | ||
| 19 | #include <linux/reboot.h> | ||
| 20 | |||
| 21 | #include <asm/proc-fns.h> | ||
| 22 | |||
| 23 | static void __iomem *base; | ||
| 24 | static void __iomem *pcu_base; | ||
| 25 | |||
| 26 | static int zx_restart_handler(struct notifier_block *this, | ||
| 27 | unsigned long mode, void *cmd) | ||
| 28 | { | ||
| 29 | writel_relaxed(1, base + 0xb0); | ||
| 30 | writel_relaxed(1, pcu_base + 0x34); | ||
| 31 | |||
| 32 | mdelay(50); | ||
| 33 | pr_emerg("Unable to restart system\n"); | ||
| 34 | |||
| 35 | return NOTIFY_DONE; | ||
| 36 | } | ||
| 37 | |||
| 38 | static struct notifier_block zx_restart_nb = { | ||
| 39 | .notifier_call = zx_restart_handler, | ||
| 40 | .priority = 128, | ||
| 41 | }; | ||
| 42 | |||
| 43 | static int zx_reboot_probe(struct platform_device *pdev) | ||
| 44 | { | ||
| 45 | struct device_node *np = pdev->dev.of_node; | ||
| 46 | int err; | ||
| 47 | |||
| 48 | base = of_iomap(np, 0); | ||
| 49 | if (!base) { | ||
| 50 | WARN(1, "failed to map base address"); | ||
| 51 | return -ENODEV; | ||
| 52 | } | ||
| 53 | |||
| 54 | np = of_find_compatible_node(NULL, NULL, "zte,zx296702-pcu"); | ||
| 55 | pcu_base = of_iomap(np, 0); | ||
| 56 | if (!pcu_base) { | ||
| 57 | iounmap(base); | ||
| 58 | WARN(1, "failed to map pcu_base address"); | ||
| 59 | return -ENODEV; | ||
| 60 | } | ||
| 61 | |||
| 62 | err = register_restart_handler(&zx_restart_nb); | ||
| 63 | if (err) | ||
| 64 | dev_err(&pdev->dev, "Register restart handler failed(err=%d)\n", | ||
| 65 | err); | ||
| 66 | |||
| 67 | return err; | ||
| 68 | } | ||
| 69 | |||
| 70 | static const struct of_device_id zx_reboot_of_match[] = { | ||
| 71 | { .compatible = "zte,sysctrl" }, | ||
| 72 | {} | ||
| 73 | }; | ||
| 74 | |||
| 75 | static struct platform_driver zx_reboot_driver = { | ||
| 76 | .probe = zx_reboot_probe, | ||
| 77 | .driver = { | ||
| 78 | .name = "zx-reboot", | ||
| 79 | .of_match_table = zx_reboot_of_match, | ||
| 80 | }, | ||
| 81 | }; | ||
| 82 | module_platform_driver(zx_reboot_driver); | ||
