diff options
-rw-r--r-- | drivers/power/reset/brcmstb-reboot.c | 35 |
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; | |||
34 | static u32 rst_src_en; | 35 | static u32 rst_src_en; |
35 | static u32 sw_mstr_rst; | 36 | static u32 sw_mstr_rst; |
36 | 37 | ||
38 | struct reset_reg_mask { | ||
39 | u32 rst_src_en_mask; | ||
40 | u32 sw_mstr_rst_mask; | ||
41 | }; | ||
42 | |||
43 | static const struct reset_reg_mask *reset_masks; | ||
44 | |||
37 | static int brcmstb_restart_handler(struct notifier_block *this, | 45 | static 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 | ||
86 | static const struct reset_reg_mask reset_bits_40nm = { | ||
87 | .rst_src_en_mask = BIT(0), | ||
88 | .sw_mstr_rst_mask = BIT(0), | ||
89 | }; | ||
90 | |||
91 | static const struct of_device_id of_match[] = { | ||
92 | { .compatible = "brcm,brcmstb-reboot", .data = &reset_bits_40nm }, | ||
93 | {}, | ||
94 | }; | ||
95 | |||
78 | static int brcmstb_reboot_probe(struct platform_device *pdev) | 96 | static 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 | ||
111 | static const struct of_device_id of_match[] = { | ||
112 | { .compatible = "brcm,brcmstb-reboot", }, | ||
113 | {}, | ||
114 | }; | ||
115 | |||
116 | static struct platform_driver brcmstb_reboot_driver = { | 137 | static struct platform_driver brcmstb_reboot_driver = { |
117 | .probe = brcmstb_reboot_probe, | 138 | .probe = brcmstb_reboot_probe, |
118 | .driver = { | 139 | .driver = { |