aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2014-09-30 13:48:36 -0400
committerSebastian Reichel <sre@kernel.org>2014-11-16 21:07:10 -0500
commit6136c41ae9c7af4bd89d845bda5dd84b9c9f3138 (patch)
tree390c62b237e0d2e483b08adb122ff2f2b62d7760
parent6724534c79ead70e310616d0e4380bb9fbb67c15 (diff)
power/reset: brcmstb: Register with kernel restart handler
Register with kernel restart handler instead of setting arm_pm_restart directly. Cc: Marc Carino <marc.ceeeee@gmail.com> Cc: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r--drivers/power/reset/brcmstb-reboot.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/drivers/power/reset/brcmstb-reboot.c b/drivers/power/reset/brcmstb-reboot.c
index 3f236924742a..1ad56298c6c7 100644
--- a/drivers/power/reset/brcmstb-reboot.c
+++ b/drivers/power/reset/brcmstb-reboot.c
@@ -16,6 +16,7 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/io.h> 17#include <linux/io.h>
18#include <linux/jiffies.h> 18#include <linux/jiffies.h>
19#include <linux/notifier.h>
19#include <linux/of_address.h> 20#include <linux/of_address.h>
20#include <linux/of_irq.h> 21#include <linux/of_irq.h>
21#include <linux/of_platform.h> 22#include <linux/of_platform.h>
@@ -26,8 +27,6 @@
26#include <linux/smp.h> 27#include <linux/smp.h>
27#include <linux/mfd/syscon.h> 28#include <linux/mfd/syscon.h>
28 29
29#include <asm/system_misc.h>
30
31#define RESET_SOURCE_ENABLE_REG 1 30#define RESET_SOURCE_ENABLE_REG 1
32#define SW_MASTER_RESET_REG 2 31#define SW_MASTER_RESET_REG 2
33 32
@@ -35,7 +34,8 @@ static struct regmap *regmap;
35static u32 rst_src_en; 34static u32 rst_src_en;
36static u32 sw_mstr_rst; 35static u32 sw_mstr_rst;
37 36
38static void brcmstb_reboot(enum reboot_mode mode, const char *cmd) 37static int brcmstb_restart_handler(struct notifier_block *this,
38 unsigned long mode, void *cmd)
39{ 39{
40 int rc; 40 int rc;
41 u32 tmp; 41 u32 tmp;
@@ -43,31 +43,38 @@ static void brcmstb_reboot(enum reboot_mode mode, const char *cmd)
43 rc = regmap_write(regmap, rst_src_en, 1); 43 rc = regmap_write(regmap, rst_src_en, 1);
44 if (rc) { 44 if (rc) {
45 pr_err("failed to write rst_src_en (%d)\n", rc); 45 pr_err("failed to write rst_src_en (%d)\n", rc);
46 return; 46 return NOTIFY_DONE;
47 } 47 }
48 48
49 rc = regmap_read(regmap, rst_src_en, &tmp); 49 rc = regmap_read(regmap, rst_src_en, &tmp);
50 if (rc) { 50 if (rc) {
51 pr_err("failed to read rst_src_en (%d)\n", rc); 51 pr_err("failed to read rst_src_en (%d)\n", rc);
52 return; 52 return NOTIFY_DONE;
53 } 53 }
54 54
55 rc = regmap_write(regmap, sw_mstr_rst, 1); 55 rc = regmap_write(regmap, sw_mstr_rst, 1);
56 if (rc) { 56 if (rc) {
57 pr_err("failed to write sw_mstr_rst (%d)\n", rc); 57 pr_err("failed to write sw_mstr_rst (%d)\n", rc);
58 return; 58 return NOTIFY_DONE;
59 } 59 }
60 60
61 rc = regmap_read(regmap, sw_mstr_rst, &tmp); 61 rc = regmap_read(regmap, sw_mstr_rst, &tmp);
62 if (rc) { 62 if (rc) {
63 pr_err("failed to read sw_mstr_rst (%d)\n", rc); 63 pr_err("failed to read sw_mstr_rst (%d)\n", rc);
64 return; 64 return NOTIFY_DONE;
65 } 65 }
66 66
67 while (1) 67 while (1)
68 ; 68 ;
69
70 return NOTIFY_DONE;
69} 71}
70 72
73static struct notifier_block brcmstb_restart_nb = {
74 .notifier_call = brcmstb_restart_handler,
75 .priority = 128,
76};
77
71static int brcmstb_reboot_probe(struct platform_device *pdev) 78static int brcmstb_reboot_probe(struct platform_device *pdev)
72{ 79{
73 int rc; 80 int rc;
@@ -93,9 +100,12 @@ static int brcmstb_reboot_probe(struct platform_device *pdev)
93 return -EINVAL; 100 return -EINVAL;
94 } 101 }
95 102
96 arm_pm_restart = brcmstb_reboot; 103 rc = register_restart_handler(&brcmstb_restart_nb);
104 if (rc)
105 dev_err(&pdev->dev,
106 "cannot register restart handler (err=%d)\n", rc);
97 107
98 return 0; 108 return rc;
99} 109}
100 110
101static const struct of_device_id of_match[] = { 111static const struct of_device_id of_match[] = {