Commit afaebbdb authored by Feng Kan's avatar Feng Kan Committed by Sebastian Reichel

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: default avatarFeng Kan <fkan@apm.com>
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
[ sre: return err instead of 0 in syscon_reboot_probe() ]
Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
parent a7ba749e
...@@ -120,6 +120,7 @@ config POWER_RESET_KEYSTONE ...@@ -120,6 +120,7 @@ config POWER_RESET_KEYSTONE
config POWER_RESET_SYSCON config POWER_RESET_SYSCON
bool "Generic SYSCON regmap reset driver" bool "Generic SYSCON regmap reset driver"
depends on POWER_RESET && MFD_SYSCON && OF depends on POWER_RESET && OF
select MFD_SYSCON
help help
Reboot support for generic SYSCON mapped register reset. Reboot support for generic SYSCON mapped register reset.
...@@ -14,14 +14,15 @@ ...@@ -14,14 +14,15 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include <linux/delay.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/of_device.h>
#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/notifier.h> #include <linux/notifier.h>
#include <linux/mfd/syscon.h> #include <linux/mfd/syscon.h>
#include <linux/regmap.h> #include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/reboot.h> #include <linux/reboot.h>
#include <linux/regmap.h>
struct syscon_reboot_context { struct syscon_reboot_context {
struct regmap *map; struct regmap *map;
...@@ -30,21 +31,17 @@ struct syscon_reboot_context { ...@@ -30,21 +31,17 @@ struct syscon_reboot_context {
struct notifier_block restart_handler; struct notifier_block restart_handler;
}; };
static struct syscon_reboot_context *syscon_reboot_ctx;
static int syscon_restart_handle(struct notifier_block *this, static int syscon_restart_handle(struct notifier_block *this,
unsigned long mode, void *cmd) unsigned long mode, void *cmd)
{ {
struct syscon_reboot_context *ctx = syscon_reboot_ctx; struct syscon_reboot_context *ctx =
unsigned long timeout; container_of(this, struct syscon_reboot_context,
restart_handler);
/* Issue the reboot */ /* Issue the reboot */
if (ctx->map)
regmap_write(ctx->map, ctx->offset, ctx->mask); regmap_write(ctx->map, ctx->offset, ctx->mask);
timeout = jiffies + HZ; mdelay(1000);
while (time_before(jiffies, timeout))
cpu_relax();
pr_emerg("Unable to restart system\n"); pr_emerg("Unable to restart system\n");
return NOTIFY_DONE; return NOTIFY_DONE;
...@@ -76,9 +73,7 @@ static int syscon_reboot_probe(struct platform_device *pdev) ...@@ -76,9 +73,7 @@ static int syscon_reboot_probe(struct platform_device *pdev)
if (err) if (err)
dev_err(dev, "can't register restart notifier (err=%d)\n", err); dev_err(dev, "can't register restart notifier (err=%d)\n", err);
syscon_reboot_ctx = ctx; return err;
return 0;
} }
static struct of_device_id syscon_reboot_of_match[] = { static struct of_device_id syscon_reboot_of_match[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment