aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLee Jones <lee.jones@linaro.org>2014-07-22 10:52:28 -0400
committerSebastian Reichel <sre@kernel.org>2014-09-26 11:34:15 -0400
commitf0745f3696e88b4055c6229e1306a78fbe503066 (patch)
tree80287d0e02fe5fa145f39982f8f6f282decf9215
parent661a88860274e059fdb744dfaa98c045db7b5d1d (diff)
power: reset: Add restart functionality for STiH41x platforms
This driver adds the restart functionality for STiH415 and STiH416 platforms from STMicroelectronics. This driver registers an arm_pm_restart function to reset the platform. Signed-off-by: Christophe Kerello <christophe.kerello@st.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Sebastian Reichel <sre@kernel.org>
-rw-r--r--drivers/power/reset/Kconfig6
-rw-r--r--drivers/power/reset/Makefile1
-rw-r--r--drivers/power/reset/st-poweroff.c151
3 files changed, 158 insertions, 0 deletions
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
index 76156394d68a..88603b6990ed 100644
--- a/drivers/power/reset/Kconfig
+++ b/drivers/power/reset/Kconfig
@@ -82,6 +82,12 @@ config POWER_RESET_SUN6I
82 help 82 help
83 Reboot support for the Allwinner A31 SoCs. 83 Reboot support for the Allwinner A31 SoCs.
84 84
85config POWER_RESET_ST
86 bool "ST restart power-off driver"
87 depends on POWER_RESET && ARCH_STI
88 help
89 Power off and reset support for STMicroelectronics boards.
90
85config POWER_RESET_VEXPRESS 91config POWER_RESET_VEXPRESS
86 bool "ARM Versatile Express power-off and reset driver" 92 bool "ARM Versatile Express power-off and reset driver"
87 depends on ARM || ARM64 93 depends on ARM || ARM64
diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
index 5d943528c8f7..06f106b6cfc8 100644
--- a/drivers/power/reset/Makefile
+++ b/drivers/power/reset/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_POWER_RESET_LTC2952) += ltc2952-poweroff.o
8obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o 8obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o
9obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o 9obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o
10obj-$(CONFIG_POWER_RESET_SUN6I) += sun6i-reboot.o 10obj-$(CONFIG_POWER_RESET_SUN6I) += sun6i-reboot.o
11obj-$(CONFIG_POWER_RESET_ST) += st-poweroff.o
11obj-$(CONFIG_POWER_RESET_VEXPRESS) += vexpress-poweroff.o 12obj-$(CONFIG_POWER_RESET_VEXPRESS) += vexpress-poweroff.o
12obj-$(CONFIG_POWER_RESET_XGENE) += xgene-reboot.o 13obj-$(CONFIG_POWER_RESET_XGENE) += xgene-reboot.o
13obj-$(CONFIG_POWER_RESET_KEYSTONE) += keystone-reset.o 14obj-$(CONFIG_POWER_RESET_KEYSTONE) += keystone-reset.o
diff --git a/drivers/power/reset/st-poweroff.c b/drivers/power/reset/st-poweroff.c
new file mode 100644
index 000000000000..a0acf25ee2a2
--- /dev/null
+++ b/drivers/power/reset/st-poweroff.c
@@ -0,0 +1,151 @@
1/*
2 * Copyright (C) 2014 STMicroelectronics
3 *
4 * Power off Restart driver, used in STMicroelectronics devices.
5 *
6 * Author: Christophe Kerello <christophe.kerello@st.com>
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/module.h>
14#include <linux/of.h>
15#include <linux/of_platform.h>
16#include <linux/platform_device.h>
17#include <linux/mfd/syscon.h>
18#include <linux/regmap.h>
19
20#include <asm/system_misc.h>
21
22struct reset_syscfg {
23 struct regmap *regmap;
24 /* syscfg used for reset */
25 unsigned int offset_rst;
26 unsigned int mask_rst;
27 /* syscfg used for unmask the reset */
28 unsigned int offset_rst_msk;
29 unsigned int mask_rst_msk;
30};
31
32/* STiH415 */
33#define STIH415_SYSCFG_11 0x2c
34#define STIH415_SYSCFG_15 0x3c
35
36static struct reset_syscfg stih415_reset = {
37 .offset_rst = STIH415_SYSCFG_11,
38 .mask_rst = BIT(0),
39 .offset_rst_msk = STIH415_SYSCFG_15,
40 .mask_rst_msk = BIT(0)
41};
42
43/* STiH416 */
44#define STIH416_SYSCFG_500 0x7d0
45#define STIH416_SYSCFG_504 0x7e0
46
47static struct reset_syscfg stih416_reset = {
48 .offset_rst = STIH416_SYSCFG_500,
49 .mask_rst = BIT(0),
50 .offset_rst_msk = STIH416_SYSCFG_504,
51 .mask_rst_msk = BIT(0)
52};
53
54/* STiH407 */
55#define STIH407_SYSCFG_4000 0x0
56#define STIH407_SYSCFG_4008 0x20
57
58static struct reset_syscfg stih407_reset = {
59 .offset_rst = STIH407_SYSCFG_4000,
60 .mask_rst = BIT(0),
61 .offset_rst_msk = STIH407_SYSCFG_4008,
62 .mask_rst_msk = BIT(0)
63};
64
65/* STiD127 */
66#define STID127_SYSCFG_700 0x0
67#define STID127_SYSCFG_773 0x124
68
69static struct reset_syscfg stid127_reset = {
70 .offset_rst = STID127_SYSCFG_773,
71 .mask_rst = BIT(0),
72 .offset_rst_msk = STID127_SYSCFG_700,
73 .mask_rst_msk = BIT(8)
74};
75
76static struct reset_syscfg *st_restart_syscfg;
77
78static void st_restart(enum reboot_mode reboot_mode, const char *cmd)
79{
80 /* reset syscfg updated */
81 regmap_update_bits(st_restart_syscfg->regmap,
82 st_restart_syscfg->offset_rst,
83 st_restart_syscfg->mask_rst,
84 0);
85
86 /* unmask the reset */
87 regmap_update_bits(st_restart_syscfg->regmap,
88 st_restart_syscfg->offset_rst_msk,
89 st_restart_syscfg->mask_rst_msk,
90 0);
91}
92
93static struct of_device_id st_reset_of_match[] = {
94 {
95 .compatible = "st,stih415-restart",
96 .data = (void *)&stih415_reset,
97 }, {
98 .compatible = "st,stih416-restart",
99 .data = (void *)&stih416_reset,
100 }, {
101 .compatible = "st,stih407-restart",
102 .data = (void *)&stih407_reset,
103 }, {
104 .compatible = "st,stid127-restart",
105 .data = (void *)&stid127_reset,
106 },
107 {}
108};
109
110static int st_reset_probe(struct platform_device *pdev)
111{
112 struct device_node *np = pdev->dev.of_node;
113 const struct of_device_id *match;
114 struct device *dev = &pdev->dev;
115
116 match = of_match_device(st_reset_of_match, dev);
117 if (!match)
118 return -ENODEV;
119
120 st_restart_syscfg = (struct reset_syscfg *)match->data;
121
122 st_restart_syscfg->regmap =
123 syscon_regmap_lookup_by_phandle(np, "st,syscfg");
124 if (IS_ERR(st_restart_syscfg->regmap)) {
125 dev_err(dev, "No syscfg phandle specified\n");
126 return PTR_ERR(st_restart_syscfg->regmap);
127 }
128
129 arm_pm_restart = st_restart;
130
131 return 0;
132}
133
134static struct platform_driver st_reset_driver = {
135 .probe = st_reset_probe,
136 .driver = {
137 .name = "st_reset",
138 .of_match_table = st_reset_of_match,
139 },
140};
141
142static int __init st_reset_init(void)
143{
144 return platform_driver_register(&st_reset_driver);
145}
146
147device_initcall(st_reset_init);
148
149MODULE_AUTHOR("Christophe Kerello <christophe.kerello@st.com>");
150MODULE_DESCRIPTION("STMicroelectronics Power off Restart driver");
151MODULE_LICENSE("GPL v2");