diff options
author | Haojian Zhuang <haojian.zhuang@linaro.org> | 2014-05-13 05:11:28 -0400 |
---|---|---|
committer | Olof Johansson <olof@lixom.net> | 2014-07-31 01:32:21 -0400 |
commit | 4a9b37371822c6b47fdd87118e4f91b5ebc70b6f (patch) | |
tree | d8f574cf2bbf95cb24cd483c08a87917c460cfba | |
parent | 75a4795a1d1bccb2e7c7def1be50b32cd1389b6e (diff) |
power: reset: move hisilicon reboot code
Move reboot code from hisilicon platform driver into reset driver.
Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
Acked-by: Wei Xu <xuwei5@hisilicon.com>
Signed-off-by: Olof Johansson <olof@lixom.net>
-rw-r--r-- | arch/arm/mach-hisi/Kconfig | 3 | ||||
-rw-r--r-- | arch/arm/mach-hisi/hisilicon.c | 33 | ||||
-rw-r--r-- | drivers/power/reset/Kconfig | 6 | ||||
-rw-r--r-- | drivers/power/reset/Makefile | 1 | ||||
-rw-r--r-- | drivers/power/reset/hisi-reboot.c | 67 |
5 files changed, 77 insertions, 33 deletions
diff --git a/arch/arm/mach-hisi/Kconfig b/arch/arm/mach-hisi/Kconfig index 90fdbb4ae00a..984882943f77 100644 --- a/arch/arm/mach-hisi/Kconfig +++ b/arch/arm/mach-hisi/Kconfig | |||
@@ -4,6 +4,9 @@ config ARCH_HISI | |||
4 | select ARM_AMBA | 4 | select ARM_AMBA |
5 | select ARM_GIC | 5 | select ARM_GIC |
6 | select ARM_TIMER_SP804 | 6 | select ARM_TIMER_SP804 |
7 | select POWER_RESET | ||
8 | select POWER_RESET_HISI | ||
9 | select POWER_SUPPLY | ||
7 | 10 | ||
8 | if ARCH_HISI | 11 | if ARCH_HISI |
9 | 12 | ||
diff --git a/arch/arm/mach-hisi/hisilicon.c b/arch/arm/mach-hisi/hisilicon.c index 2bfbe3f1392d..7996c6b74339 100644 --- a/arch/arm/mach-hisi/hisilicon.c +++ b/arch/arm/mach-hisi/hisilicon.c | |||
@@ -14,10 +14,6 @@ | |||
14 | #include <linux/clk-provider.h> | 14 | #include <linux/clk-provider.h> |
15 | #include <linux/clocksource.h> | 15 | #include <linux/clocksource.h> |
16 | #include <linux/irqchip.h> | 16 | #include <linux/irqchip.h> |
17 | #include <linux/of_address.h> | ||
18 | #include <linux/of_platform.h> | ||
19 | |||
20 | #include <asm/proc-fns.h> | ||
21 | 17 | ||
22 | #include <asm/mach/arch.h> | 18 | #include <asm/mach/arch.h> |
23 | #include <asm/mach/map.h> | 19 | #include <asm/mach/map.h> |
@@ -51,32 +47,6 @@ static void __init hi3620_map_io(void) | |||
51 | iotable_init(hi3620_io_desc, ARRAY_SIZE(hi3620_io_desc)); | 47 | iotable_init(hi3620_io_desc, ARRAY_SIZE(hi3620_io_desc)); |
52 | } | 48 | } |
53 | 49 | ||
54 | static void hi3xxx_restart(enum reboot_mode mode, const char *cmd) | ||
55 | { | ||
56 | struct device_node *np; | ||
57 | void __iomem *base; | ||
58 | int offset; | ||
59 | |||
60 | np = of_find_compatible_node(NULL, NULL, "hisilicon,sysctrl"); | ||
61 | if (!np) { | ||
62 | pr_err("failed to find hisilicon,sysctrl node\n"); | ||
63 | return; | ||
64 | } | ||
65 | base = of_iomap(np, 0); | ||
66 | if (!base) { | ||
67 | pr_err("failed to map address in hisilicon,sysctrl node\n"); | ||
68 | return; | ||
69 | } | ||
70 | if (of_property_read_u32(np, "reboot-offset", &offset) < 0) { | ||
71 | pr_err("failed to find reboot-offset property\n"); | ||
72 | return; | ||
73 | } | ||
74 | writel_relaxed(0xdeadbeef, base + offset); | ||
75 | |||
76 | while (1) | ||
77 | cpu_do_idle(); | ||
78 | } | ||
79 | |||
80 | static const char *hi3xxx_compat[] __initconst = { | 50 | static const char *hi3xxx_compat[] __initconst = { |
81 | "hisilicon,hi3620-hi4511", | 51 | "hisilicon,hi3620-hi4511", |
82 | NULL, | 52 | NULL, |
@@ -86,7 +56,6 @@ DT_MACHINE_START(HI3620, "Hisilicon Hi3620 (Flattened Device Tree)") | |||
86 | .map_io = hi3620_map_io, | 56 | .map_io = hi3620_map_io, |
87 | .dt_compat = hi3xxx_compat, | 57 | .dt_compat = hi3xxx_compat, |
88 | .smp = smp_ops(hi3xxx_smp_ops), | 58 | .smp = smp_ops(hi3xxx_smp_ops), |
89 | .restart = hi3xxx_restart, | ||
90 | MACHINE_END | 59 | MACHINE_END |
91 | 60 | ||
92 | static const char *hix5hd2_compat[] __initconst = { | 61 | static const char *hix5hd2_compat[] __initconst = { |
@@ -96,7 +65,5 @@ static const char *hix5hd2_compat[] __initconst = { | |||
96 | 65 | ||
97 | DT_MACHINE_START(HIX5HD2_DT, "Hisilicon HIX5HD2 (Flattened Device Tree)") | 66 | DT_MACHINE_START(HIX5HD2_DT, "Hisilicon HIX5HD2 (Flattened Device Tree)") |
98 | .dt_compat = hix5hd2_compat, | 67 | .dt_compat = hix5hd2_compat, |
99 | .init_late = hi3xxx_init_late, | ||
100 | .smp = smp_ops(hix5hd2_smp_ops), | 68 | .smp = smp_ops(hix5hd2_smp_ops), |
101 | .restart = hi3xxx_restart, | ||
102 | MACHINE_END | 69 | MACHINE_END |
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig index bdcf5173e377..4127f494b651 100644 --- a/drivers/power/reset/Kconfig +++ b/drivers/power/reset/Kconfig | |||
@@ -28,6 +28,12 @@ config POWER_RESET_GPIO | |||
28 | If your board needs a GPIO high/low to power down, say Y and | 28 | If your board needs a GPIO high/low to power down, say Y and |
29 | create a binding in your devicetree. | 29 | create a binding in your devicetree. |
30 | 30 | ||
31 | config POWER_RESET_HISI | ||
32 | bool "Hisilicon power-off driver" | ||
33 | depends on POWER_RESET && ARCH_HISI | ||
34 | help | ||
35 | Reboot support for Hisilicon boards. | ||
36 | |||
31 | config POWER_RESET_MSM | 37 | config POWER_RESET_MSM |
32 | bool "Qualcomm MSM power-off driver" | 38 | bool "Qualcomm MSM power-off driver" |
33 | depends on POWER_RESET && ARCH_QCOM | 39 | depends on POWER_RESET && ARCH_QCOM |
diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile index dde2e8bbac53..fe0f22877e58 100644 --- a/drivers/power/reset/Makefile +++ b/drivers/power/reset/Makefile | |||
@@ -1,6 +1,7 @@ | |||
1 | obj-$(CONFIG_POWER_RESET_AS3722) += as3722-poweroff.o | 1 | obj-$(CONFIG_POWER_RESET_AS3722) += as3722-poweroff.o |
2 | obj-$(CONFIG_POWER_RESET_AXXIA) += axxia-reset.o | 2 | obj-$(CONFIG_POWER_RESET_AXXIA) += axxia-reset.o |
3 | obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o | 3 | obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o |
4 | obj-$(CONFIG_POWER_RESET_HISI) += hisi-reboot.o | ||
4 | obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o | 5 | obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o |
5 | obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o | 6 | obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o |
6 | obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o | 7 | obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o |
diff --git a/drivers/power/reset/hisi-reboot.c b/drivers/power/reset/hisi-reboot.c new file mode 100644 index 000000000000..0c91d0231d36 --- /dev/null +++ b/drivers/power/reset/hisi-reboot.c | |||
@@ -0,0 +1,67 @@ | |||
1 | /* | ||
2 | * Hisilicon SoC reset code | ||
3 | * | ||
4 | * Copyright (c) 2014 Hisilicon Ltd. | ||
5 | * Copyright (c) 2014 Linaro Ltd. | ||
6 | * | ||
7 | * Author: Haojian Zhuang <haojian.zhuang@linaro.org> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | ||
13 | |||
14 | #include <linux/delay.h> | ||
15 | #include <linux/io.h> | ||
16 | #include <linux/module.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 | #include <asm/system_misc.h> | ||
23 | |||
24 | static void __iomem *base; | ||
25 | static u32 reboot_offset; | ||
26 | |||
27 | static void hisi_restart(enum reboot_mode mode, const char *cmd) | ||
28 | { | ||
29 | writel_relaxed(0xdeadbeef, base + reboot_offset); | ||
30 | |||
31 | while (1) | ||
32 | cpu_do_idle(); | ||
33 | } | ||
34 | |||
35 | static int hisi_reboot_probe(struct platform_device *pdev) | ||
36 | { | ||
37 | struct device_node *np = pdev->dev.of_node; | ||
38 | |||
39 | base = of_iomap(np, 0); | ||
40 | if (!base) { | ||
41 | WARN(1, "failed to map base address"); | ||
42 | return -ENODEV; | ||
43 | } | ||
44 | |||
45 | if (of_property_read_u32(np, "reboot-offset", &reboot_offset) < 0) { | ||
46 | pr_err("failed to find reboot-offset property\n"); | ||
47 | return -EINVAL; | ||
48 | } | ||
49 | |||
50 | arm_pm_restart = hisi_restart; | ||
51 | |||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | static struct of_device_id hisi_reboot_of_match[] = { | ||
56 | { .compatible = "hisilicon,sysctrl" }, | ||
57 | {} | ||
58 | }; | ||
59 | |||
60 | static struct platform_driver hisi_reboot_driver = { | ||
61 | .probe = hisi_reboot_probe, | ||
62 | .driver = { | ||
63 | .name = "hisi-reboot", | ||
64 | .of_match_table = hisi_reboot_of_match, | ||
65 | }, | ||
66 | }; | ||
67 | module_platform_driver(hisi_reboot_driver); | ||