aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Cernekee <cernekee@gmail.com>2014-11-25 19:49:47 -0500
committerSebastian Reichel <sre@kernel.org>2015-01-21 20:25:32 -0500
commitbb1de7f61f1834af81a1665e6450f47dd18a0dd5 (patch)
treee0b2ba92857b611678439e5dd508728df5afcda2
parent4f5fd640469839532cb2bd558f878539548f2861 (diff)
power/reset: brcmstb: Use the DT "compatible" string to indicate bit positions
Some of the older chips used different bits to arm and trigger the reset. Add the infrastructure needed to specify this through the "compatible" string. Signed-off-by: Kevin Cernekee <cernekee@gmail.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
-rw-r--r--drivers/power/reset/brcmstb-reboot.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/drivers/power/reset/brcmstb-reboot.c b/drivers/power/reset/brcmstb-reboot.c
index 100606f9b3dc..af5aedf39261 100644
--- a/drivers/power/reset/brcmstb-reboot.c
+++ b/drivers/power/reset/brcmstb-reboot.c
@@ -11,6 +11,7 @@
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 */ 12 */
13 13
14#include <linux/bitops.h>
14#include <linux/device.h> 15#include <linux/device.h>
15#include <linux/errno.h> 16#include <linux/errno.h>
16#include <linux/init.h> 17#include <linux/init.h>
@@ -34,13 +35,20 @@ static struct regmap *regmap;
34static u32 rst_src_en; 35static u32 rst_src_en;
35static u32 sw_mstr_rst; 36static u32 sw_mstr_rst;
36 37
38struct reset_reg_mask {
39 u32 rst_src_en_mask;
40 u32 sw_mstr_rst_mask;
41};
42
43static const struct reset_reg_mask *reset_masks;
44
37static int brcmstb_restart_handler(struct notifier_block *this, 45static int brcmstb_restart_handler(struct notifier_block *this,
38 unsigned long mode, void *cmd) 46 unsigned long mode, void *cmd)
39{ 47{
40 int rc; 48 int rc;
41 u32 tmp; 49 u32 tmp;
42 50
43 rc = regmap_write(regmap, rst_src_en, 1); 51 rc = regmap_write(regmap, rst_src_en, reset_masks->rst_src_en_mask);
44 if (rc) { 52 if (rc) {
45 pr_err("failed to write rst_src_en (%d)\n", rc); 53 pr_err("failed to write rst_src_en (%d)\n", rc);
46 return NOTIFY_DONE; 54 return NOTIFY_DONE;
@@ -52,7 +60,7 @@ static int brcmstb_restart_handler(struct notifier_block *this,
52 return NOTIFY_DONE; 60 return NOTIFY_DONE;
53 } 61 }
54 62
55 rc = regmap_write(regmap, sw_mstr_rst, 1); 63 rc = regmap_write(regmap, sw_mstr_rst, reset_masks->sw_mstr_rst_mask);
56 if (rc) { 64 if (rc) {
57 pr_err("failed to write sw_mstr_rst (%d)\n", rc); 65 pr_err("failed to write sw_mstr_rst (%d)\n", rc);
58 return NOTIFY_DONE; 66 return NOTIFY_DONE;
@@ -75,10 +83,28 @@ static struct notifier_block brcmstb_restart_nb = {
75 .priority = 128, 83 .priority = 128,
76}; 84};
77 85
86static const struct reset_reg_mask reset_bits_40nm = {
87 .rst_src_en_mask = BIT(0),
88 .sw_mstr_rst_mask = BIT(0),
89};
90
91static const struct of_device_id of_match[] = {
92 { .compatible = "brcm,brcmstb-reboot", .data = &reset_bits_40nm },
93 {},
94};
95
78static int brcmstb_reboot_probe(struct platform_device *pdev) 96static int brcmstb_reboot_probe(struct platform_device *pdev)
79{ 97{
80 int rc; 98 int rc;
81 struct device_node *np = pdev->dev.of_node; 99 struct device_node *np = pdev->dev.of_node;
100 const struct of_device_id *of_id;
101
102 of_id = of_match_node(of_match, np);
103 if (!of_id) {
104 pr_err("failed to look up compatible string\n");
105 return -EINVAL;
106 }
107 reset_masks = of_id->data;
82 108
83 regmap = syscon_regmap_lookup_by_phandle(np, "syscon"); 109 regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
84 if (IS_ERR(regmap)) { 110 if (IS_ERR(regmap)) {
@@ -108,11 +134,6 @@ static int brcmstb_reboot_probe(struct platform_device *pdev)
108 return rc; 134 return rc;
109} 135}
110 136
111static const struct of_device_id of_match[] = {
112 { .compatible = "brcm,brcmstb-reboot", },
113 {},
114};
115
116static struct platform_driver brcmstb_reboot_driver = { 137static struct platform_driver brcmstb_reboot_driver = {
117 .probe = brcmstb_reboot_probe, 138 .probe = brcmstb_reboot_probe,
118 .driver = { 139 .driver = {