diff options
author | Lee Jones <lee.jones@linaro.org> | 2014-07-22 10:52:28 -0400 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2014-09-26 11:34:15 -0400 |
commit | f0745f3696e88b4055c6229e1306a78fbe503066 (patch) | |
tree | 80287d0e02fe5fa145f39982f8f6f282decf9215 /drivers/power/reset/st-poweroff.c | |
parent | 661a88860274e059fdb744dfaa98c045db7b5d1d (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>
Diffstat (limited to 'drivers/power/reset/st-poweroff.c')
-rw-r--r-- | drivers/power/reset/st-poweroff.c | 151 |
1 files changed, 151 insertions, 0 deletions
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 | |||
22 | struct 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 | |||
36 | static 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 | |||
47 | static 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 | |||
58 | static 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 | |||
69 | static 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 | |||
76 | static struct reset_syscfg *st_restart_syscfg; | ||
77 | |||
78 | static 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 | |||
93 | static 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 | |||
110 | static 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 | |||
134 | static 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 | |||
142 | static int __init st_reset_init(void) | ||
143 | { | ||
144 | return platform_driver_register(&st_reset_driver); | ||
145 | } | ||
146 | |||
147 | device_initcall(st_reset_init); | ||
148 | |||
149 | MODULE_AUTHOR("Christophe Kerello <christophe.kerello@st.com>"); | ||
150 | MODULE_DESCRIPTION("STMicroelectronics Power off Restart driver"); | ||
151 | MODULE_LICENSE("GPL v2"); | ||