hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/watchdog/bcm2835_wdt.c
....@@ -12,6 +12,7 @@
1212
1313 #include <linux/delay.h>
1414 #include <linux/types.h>
15
+#include <linux/mfd/bcm2835-pm.h>
1516 #include <linux/module.h>
1617 #include <linux/io.h>
1718 #include <linux/watchdog.h>
....@@ -46,6 +47,8 @@
4647 void __iomem *base;
4748 spinlock_t lock;
4849 };
50
+
51
+static struct bcm2835_wdt *bcm2835_power_off_wdt;
4952
5053 static unsigned int heartbeat;
5154 static bool nowayout = WATCHDOG_NOWAYOUT;
....@@ -148,10 +151,7 @@
148151 */
149152 static void bcm2835_power_off(void)
150153 {
151
- struct device_node *np =
152
- of_find_compatible_node(NULL, NULL, "brcm,bcm2835-pm-wdt");
153
- struct platform_device *pdev = of_find_device_by_node(np);
154
- struct bcm2835_wdt *wdt = platform_get_drvdata(pdev);
154
+ struct bcm2835_wdt *wdt = bcm2835_power_off_wdt;
155155 u32 val;
156156
157157 /*
....@@ -169,7 +169,7 @@
169169
170170 static int bcm2835_wdt_probe(struct platform_device *pdev)
171171 {
172
- struct resource *res;
172
+ struct bcm2835_pm *pm = dev_get_drvdata(pdev->dev.parent);
173173 struct device *dev = &pdev->dev;
174174 struct bcm2835_wdt *wdt;
175175 int err;
....@@ -177,14 +177,10 @@
177177 wdt = devm_kzalloc(dev, sizeof(struct bcm2835_wdt), GFP_KERNEL);
178178 if (!wdt)
179179 return -ENOMEM;
180
- platform_set_drvdata(pdev, wdt);
181180
182181 spin_lock_init(&wdt->lock);
183182
184
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
185
- wdt->base = devm_ioremap_resource(dev, res);
186
- if (IS_ERR(wdt->base))
187
- return PTR_ERR(wdt->base);
183
+ wdt->base = pm->base;
188184
189185 watchdog_set_drvdata(&bcm2835_wdt_wdd, wdt);
190186 watchdog_init_timeout(&bcm2835_wdt_wdd, heartbeat, dev);
....@@ -206,13 +202,13 @@
206202
207203 watchdog_stop_on_reboot(&bcm2835_wdt_wdd);
208204 err = devm_watchdog_register_device(dev, &bcm2835_wdt_wdd);
209
- if (err) {
210
- dev_err(dev, "Failed to register watchdog device");
205
+ if (err)
211206 return err;
212
- }
213207
214
- if (pm_power_off == NULL)
208
+ if (pm_power_off == NULL) {
215209 pm_power_off = bcm2835_power_off;
210
+ bcm2835_power_off_wdt = wdt;
211
+ }
216212
217213 dev_info(dev, "Broadcom BCM2835 watchdog timer");
218214 return 0;
....@@ -226,18 +222,11 @@
226222 return 0;
227223 }
228224
229
-static const struct of_device_id bcm2835_wdt_of_match[] = {
230
- { .compatible = "brcm,bcm2835-pm-wdt", },
231
- {},
232
-};
233
-MODULE_DEVICE_TABLE(of, bcm2835_wdt_of_match);
234
-
235225 static struct platform_driver bcm2835_wdt_driver = {
236226 .probe = bcm2835_wdt_probe,
237227 .remove = bcm2835_wdt_remove,
238228 .driver = {
239229 .name = "bcm2835-wdt",
240
- .of_match_table = bcm2835_wdt_of_match,
241230 },
242231 };
243232 module_platform_driver(bcm2835_wdt_driver);