Skip to content

Commit bde327e

Browse files
haukelinvjw
authored andcommitted
ssb: register watchdog driver
Register the watchdog driver to the system if it is a SoC. Using the watchdog on a non SoC device, like a PCI card, will make the PCI card die when the timeout expired, but starting it again is not supported by ssb. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 9f640a6 commit bde327e

4 files changed

Lines changed: 55 additions & 0 deletions

File tree

‎drivers/ssb/embedded.c‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
*
55
* Copyright 2005-2008, Broadcom Corporation
66
* Copyright 2006-2008, Michael Buesch <m@bues.ch>
7+
* Copyright 2012, Hauke Mehrtens <hauke@hauke-m.de>
78
*
89
* Licensed under the GNU/GPL. See COPYING for details.
910
*/
1011

1112
#include <linux/export.h>
13+
#include <linux/platform_device.h>
1214
#include <linux/ssb/ssb.h>
1315
#include <linux/ssb/ssb_embedded.h>
1416
#include <linux/ssb/ssb_driver_pci.h>
@@ -32,6 +34,39 @@ int ssb_watchdog_timer_set(struct ssb_bus *bus, u32 ticks)
3234
}
3335
EXPORT_SYMBOL(ssb_watchdog_timer_set);
3436

37+
int ssb_watchdog_register(struct ssb_bus *bus)
38+
{
39+
struct bcm47xx_wdt wdt = {};
40+
struct platform_device *pdev;
41+
42+
if (ssb_chipco_available(&bus->chipco)) {
43+
wdt.driver_data = &bus->chipco;
44+
wdt.timer_set = ssb_chipco_watchdog_timer_set_wdt;
45+
wdt.timer_set_ms = ssb_chipco_watchdog_timer_set_ms;
46+
wdt.max_timer_ms = bus->chipco.max_timer_ms;
47+
} else if (ssb_extif_available(&bus->extif)) {
48+
wdt.driver_data = &bus->extif;
49+
wdt.timer_set = ssb_extif_watchdog_timer_set_wdt;
50+
wdt.timer_set_ms = ssb_extif_watchdog_timer_set_ms;
51+
wdt.max_timer_ms = SSB_EXTIF_WATCHDOG_MAX_TIMER_MS;
52+
} else {
53+
return -ENODEV;
54+
}
55+
56+
pdev = platform_device_register_data(NULL, "bcm47xx-wdt",
57+
bus->busnumber, &wdt,
58+
sizeof(wdt));
59+
if (IS_ERR(pdev)) {
60+
ssb_dprintk(KERN_INFO PFX
61+
"can not register watchdog device, err: %li\n",
62+
PTR_ERR(pdev));
63+
return PTR_ERR(pdev);
64+
}
65+
66+
bus->watchdog = pdev;
67+
return 0;
68+
}
69+
3570
u32 ssb_gpio_in(struct ssb_bus *bus, u32 mask)
3671
{
3772
unsigned long flags;

‎drivers/ssb/main.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/delay.h>
1414
#include <linux/io.h>
1515
#include <linux/module.h>
16+
#include <linux/platform_device.h>
1617
#include <linux/ssb/ssb.h>
1718
#include <linux/ssb/ssb_regs.h>
1819
#include <linux/ssb/ssb_driver_gige.h>
@@ -433,6 +434,11 @@ static void ssb_devices_unregister(struct ssb_bus *bus)
433434
if (sdev->dev)
434435
device_unregister(sdev->dev);
435436
}
437+
438+
#ifdef CONFIG_SSB_EMBEDDED
439+
if (bus->bustype == SSB_BUSTYPE_SSB)
440+
platform_device_unregister(bus->watchdog);
441+
#endif
436442
}
437443

438444
void ssb_bus_unregister(struct ssb_bus *bus)
@@ -561,6 +567,8 @@ static int __devinit ssb_attach_queued_buses(void)
561567
if (err)
562568
goto error;
563569
ssb_pcicore_init(&bus->pcicore);
570+
if (bus->bustype == SSB_BUSTYPE_SSB)
571+
ssb_watchdog_register(bus);
564572
ssb_bus_may_powerdown(bus);
565573

566574
err = ssb_devices_register(bus);

‎drivers/ssb/ssb_private.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,4 +232,14 @@ static inline u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt,
232232
return 0;
233233
}
234234
#endif
235+
236+
#ifdef CONFIG_SSB_EMBEDDED
237+
extern int ssb_watchdog_register(struct ssb_bus *bus);
238+
#else /* CONFIG_SSB_EMBEDDED */
239+
static inline int ssb_watchdog_register(struct ssb_bus *bus)
240+
{
241+
return 0;
242+
}
243+
#endif /* CONFIG_SSB_EMBEDDED */
244+
235245
#endif /* LINUX_SSB_PRIVATE_H_ */

‎include/linux/ssb/ssb.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/pci.h>
99
#include <linux/mod_devicetable.h>
1010
#include <linux/dma-mapping.h>
11+
#include <linux/platform_device.h>
1112

1213
#include <linux/ssb/ssb_regs.h>
1314

@@ -432,6 +433,7 @@ struct ssb_bus {
432433
#ifdef CONFIG_SSB_EMBEDDED
433434
/* Lock for GPIO register access. */
434435
spinlock_t gpio_lock;
436+
struct platform_device *watchdog;
435437
#endif /* EMBEDDED */
436438

437439
/* Internal-only stuff follows. Do not touch. */

0 commit comments

Comments
 (0)