aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFeng Kan <fkan@apm.com>2014-10-02 14:24:15 -0400
committerSebastian Reichel <sre@kernel.org>2014-10-02 22:32:08 -0400
commitafaebbdbd48ada5ead707d6a90ce4b604e1d77d4 (patch)
treefc11ce4144991227bac55c4c100061f109f60df2
parenta7ba749e01461a3802d22157fc0e6c4ecbe0dd32 (diff)
power: reset: corrections for simple syscon reboot driver
This patch is to fix some bugs in reboot driver. Which includes auto selection of the MFD_SYSCON for the driver, use of container to locate restart handler, correction of the count down failure timer and ordering of the header file. Signed-off-by: Feng Kan <fkan@apm.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> [ sre: return err instead of 0 in syscon_reboot_probe() ] Signed-off-by: Sebastian Reichel <sre@kernel.org>
-rw-r--r--drivers/power/reset/Kconfig3
-rw-r--r--drivers/power/reset/syscon-reboot.c27
2 files changed, 13 insertions, 17 deletions
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
index addb26afae5a..3b451e162a98 100644
--- a/drivers/power/reset/Kconfig
+++ b/drivers/power/reset/Kconfig
@@ -120,6 +120,7 @@ config POWER_RESET_KEYSTONE
120 120
121config POWER_RESET_SYSCON 121config POWER_RESET_SYSCON
122 bool "Generic SYSCON regmap reset driver" 122 bool "Generic SYSCON regmap reset driver"
123 depends on POWER_RESET && MFD_SYSCON && OF 123 depends on POWER_RESET && OF
124 select MFD_SYSCON
124 help 125 help
125 Reboot support for generic SYSCON mapped register reset. 126 Reboot support for generic SYSCON mapped register reset.
diff --git a/drivers/power/reset/syscon-reboot.c b/drivers/power/reset/syscon-reboot.c
index 948e0ee32a4d..815b901822cf 100644
--- a/drivers/power/reset/syscon-reboot.c
+++ b/drivers/power/reset/syscon-reboot.c
@@ -14,14 +14,15 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 */ 16 */
17#include <linux/delay.h>
17#include <linux/io.h> 18#include <linux/io.h>
18#include <linux/of_device.h>
19#include <linux/of_address.h>
20#include <linux/platform_device.h>
21#include <linux/notifier.h> 19#include <linux/notifier.h>
22#include <linux/mfd/syscon.h> 20#include <linux/mfd/syscon.h>
23#include <linux/regmap.h> 21#include <linux/of_address.h>
22#include <linux/of_device.h>
23#include <linux/platform_device.h>
24#include <linux/reboot.h> 24#include <linux/reboot.h>
25#include <linux/regmap.h>
25 26
26struct syscon_reboot_context { 27struct syscon_reboot_context {
27 struct regmap *map; 28 struct regmap *map;
@@ -30,21 +31,17 @@ struct syscon_reboot_context {
30 struct notifier_block restart_handler; 31 struct notifier_block restart_handler;
31}; 32};
32 33
33static struct syscon_reboot_context *syscon_reboot_ctx;
34
35static int syscon_restart_handle(struct notifier_block *this, 34static int syscon_restart_handle(struct notifier_block *this,
36 unsigned long mode, void *cmd) 35 unsigned long mode, void *cmd)
37{ 36{
38 struct syscon_reboot_context *ctx = syscon_reboot_ctx; 37 struct syscon_reboot_context *ctx =
39 unsigned long timeout; 38 container_of(this, struct syscon_reboot_context,
39 restart_handler);
40 40
41 /* Issue the reboot */ 41 /* Issue the reboot */
42 if (ctx->map) 42 regmap_write(ctx->map, ctx->offset, ctx->mask);
43 regmap_write(ctx->map, ctx->offset, ctx->mask);
44 43
45 timeout = jiffies + HZ; 44 mdelay(1000);
46 while (time_before(jiffies, timeout))
47 cpu_relax();
48 45
49 pr_emerg("Unable to restart system\n"); 46 pr_emerg("Unable to restart system\n");
50 return NOTIFY_DONE; 47 return NOTIFY_DONE;
@@ -76,9 +73,7 @@ static int syscon_reboot_probe(struct platform_device *pdev)
76 if (err) 73 if (err)
77 dev_err(dev, "can't register restart notifier (err=%d)\n", err); 74 dev_err(dev, "can't register restart notifier (err=%d)\n", err);
78 75
79 syscon_reboot_ctx = ctx; 76 return err;
80
81 return 0;
82} 77}
83 78
84static struct of_device_id syscon_reboot_of_match[] = { 79static struct of_device_id syscon_reboot_of_match[] = {