diff options
| -rw-r--r-- | drivers/power/reset/Kconfig | 3 | ||||
| -rw-r--r-- | drivers/power/reset/syscon-reboot.c | 27 |
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 | ||
| 121 | config POWER_RESET_SYSCON | 121 | config 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 | ||
| 26 | struct syscon_reboot_context { | 27 | struct 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 | ||
| 33 | static struct syscon_reboot_context *syscon_reboot_ctx; | ||
| 34 | |||
| 35 | static int syscon_restart_handle(struct notifier_block *this, | 34 | static 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 | ||
| 84 | static struct of_device_id syscon_reboot_of_match[] = { | 79 | static struct of_device_id syscon_reboot_of_match[] = { |
