aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorLoc Ho <lho@apm.com>2013-07-02 16:38:58 -0400
committerAnton Vorontsov <anton@enomsg.org>2013-08-09 17:28:17 -0400
commit67778e0eda37ae0cde60fa190bfa883ec403fdbf (patch)
tree5df8fac30650d92d043b5a2ef43434688c17d2f5 /drivers/power
parent0e81ef588028feae7abb077a80acc27adf3e818d (diff)
power: Add APM X-Gene system reboot driver
Add APM X-Gene SoC system reboot driver. This driver handles only system reboot. System shutdown is board specific and can be handled by board driver or GPIO based shutdown driver. Signed-off-by: Loc Ho <lho@apm.com> Signed-off-by: Feng Kan <fkan@apm.com> Signed-off-by: Kumar Sankaran <ksankaran@apm.com> Signed-off-by: Anton Vorontsov <anton@enomsg.org>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/reset/Kconfig7
-rw-r--r--drivers/power/reset/Makefile1
-rw-r--r--drivers/power/reset/xgene-reboot.c103
3 files changed, 111 insertions, 0 deletions
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
index 94122906f9cf..5482280467e5 100644
--- a/drivers/power/reset/Kconfig
+++ b/drivers/power/reset/Kconfig
@@ -44,3 +44,10 @@ config POWER_RESET_VEXPRESS
44 help 44 help
45 Power off and reset support for the ARM Ltd. Versatile 45 Power off and reset support for the ARM Ltd. Versatile
46 Express boards. 46 Express boards.
47
48config POWER_RESET_XGENE
49 bool "APM SoC X-Gene reset driver"
50 depends on ARM64
51 depends on POWER_RESET
52 help
53 Reboot support for the APM SoC X-Gene Eval boards.
diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
index b82288e99e92..3e6ed88725ac 100644
--- a/drivers/power/reset/Makefile
+++ b/drivers/power/reset/Makefile
@@ -3,3 +3,4 @@ obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o
3obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o 3obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o
4obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o 4obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o
5obj-$(CONFIG_POWER_RESET_VEXPRESS) += vexpress-poweroff.o 5obj-$(CONFIG_POWER_RESET_VEXPRESS) += vexpress-poweroff.o
6obj-$(CONFIG_POWER_RESET_XGENE) += xgene-reboot.o
diff --git a/drivers/power/reset/xgene-reboot.c b/drivers/power/reset/xgene-reboot.c
new file mode 100644
index 000000000000..ecd55f81b9d1
--- /dev/null
+++ b/drivers/power/reset/xgene-reboot.c
@@ -0,0 +1,103 @@
1/*
2 * AppliedMicro X-Gene SoC Reboot Driver
3 *
4 * Copyright (c) 2013, Applied Micro Circuits Corporation
5 * Author: Feng Kan <fkan@apm.com>
6 * Author: Loc Ho <lho@apm.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 *
23 * This driver provides system reboot functionality for APM X-Gene SoC.
24 * For system shutdown, this is board specify. If a board designer
25 * implements GPIO shutdown, use the gpio-poweroff.c driver.
26 */
27#include <linux/io.h>
28#include <linux/of_device.h>
29#include <linux/of_address.h>
30#include <linux/platform_device.h>
31#include <linux/stat.h>
32#include <linux/slab.h>
33#include <asm/system_misc.h>
34
35struct xgene_reboot_context {
36 struct platform_device *pdev;
37 void *csr;
38 u32 mask;
39};
40
41static struct xgene_reboot_context *xgene_restart_ctx;
42
43static void xgene_restart(char str, const char *cmd)
44{
45 struct xgene_reboot_context *ctx = xgene_restart_ctx;
46 unsigned long timeout;
47
48 /* Issue the reboot */
49 if (ctx)
50 writel(ctx->mask, ctx->csr);
51
52 timeout = jiffies + HZ;
53 while (time_before(jiffies, timeout))
54 cpu_relax();
55
56 dev_emerg(&ctx->pdev->dev, "Unable to restart system\n");
57}
58
59static int xgene_reboot_probe(struct platform_device *pdev)
60{
61 struct xgene_reboot_context *ctx;
62
63 ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
64 if (!ctx) {
65 dev_err(&pdev->dev, "out of memory for context\n");
66 return -ENODEV;
67 }
68
69 ctx->csr = of_iomap(pdev->dev.of_node, 0);
70 if (!ctx->csr) {
71 devm_kfree(&pdev->dev, ctx);
72 dev_err(&pdev->dev, "can not map resource\n");
73 return -ENODEV;
74 }
75
76 if (of_property_read_u32(pdev->dev.of_node, "mask", &ctx->mask))
77 ctx->mask = 0xFFFFFFFF;
78
79 ctx->pdev = pdev;
80 arm_pm_restart = xgene_restart;
81 xgene_restart_ctx = ctx;
82
83 return 0;
84}
85
86static struct of_device_id xgene_reboot_of_match[] = {
87 { .compatible = "apm,xgene-reboot" },
88 {}
89};
90
91static struct platform_driver xgene_reboot_driver = {
92 .probe = xgene_reboot_probe,
93 .driver = {
94 .name = "xgene-reboot",
95 .of_match_table = xgene_reboot_of_match,
96 },
97};
98
99static int __init xgene_reboot_init(void)
100{
101 return platform_driver_register(&xgene_reboot_driver);
102}
103device_initcall(xgene_reboot_init);